Created struct value member variable (byte) point1_x
Created struct value member variable (byte) point1_y
Converted struct value to member variables (struct Point) point1
Created struct value member variable (byte) point2_x
Created struct value member variable (byte) point2_y
Converted struct value to member variables (struct Point) point2
Adding struct value member variable default initializer (byte) point1_x ← (byte) 0
Adding struct value member variable default initializer (byte) point1_y ← (byte) 0
Adding struct value member variable default initializer (byte) point2_x ← (byte) 0
Adding struct value member variable default initializer (byte) point2_y ← (byte) 0
Adding struct value member variable copy (byte) point2_x ← (byte) point1_x
Adding struct value member variable copy (byte) point2_y ← (byte) point1_y
Replacing struct member reference (struct Point) point1.x with member variable reference (byte) point1_x
Replacing struct member reference (struct Point) point1.y with member variable reference (byte) point1_y
Replacing struct member reference (struct Point) point2.x with member variable reference (byte) point2_x
Replacing struct member reference (struct Point) point1.x with member variable reference (byte) point1_x
Replacing struct member reference (struct Point) point1.y with member variable reference (byte) point1_y
Replacing struct member reference (struct Point) point2.x with member variable reference (byte) point2_x
Replacing struct member reference (struct Point) point2.y with member variable reference (byte) point2_y

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte) point1_x#0 ← (byte) 0
  (byte) point1_y#0 ← (byte) 0
  (byte) point2_x#0 ← (byte) 0
  (byte) point2_y#0 ← (byte) 0
  to:@1
main: scope:[main]  from @1
  (byte) point1_x#1 ← (number) 2
  (byte) point1_y#1 ← (number) 3
  (byte) point2_x#1 ← (byte) point1_x#1
  (byte) point2_y#1 ← (byte) point1_y#1
  (byte) point2_x#2 ← (number) 4
  (byte*) main::SCREEN#0 ← ((byte*)) (number) $400
  *((byte*) main::SCREEN#0 + (number) 0) ← (byte) point1_x#1
  *((byte*) main::SCREEN#0 + (number) 1) ← (byte) point1_y#1
  *((byte*) main::SCREEN#0 + (number) 2) ← (byte) point2_x#2
  *((byte*) main::SCREEN#0 + (number) 3) ← (byte) point2_y#1
  to:main::@return
main::@return: scope:[main]  from main
  (byte) point2_y#4 ← phi( main/(byte) point2_y#1 )
  (byte) point2_x#5 ← phi( main/(byte) point2_x#2 )
  (byte) point1_y#4 ← phi( main/(byte) point1_y#1 )
  (byte) point1_x#4 ← phi( main/(byte) point1_x#1 )
  (byte) point1_x#2 ← (byte) point1_x#4
  (byte) point1_y#2 ← (byte) point1_y#4
  (byte) point2_x#3 ← (byte) point2_x#5
  (byte) point2_y#2 ← (byte) point2_y#4
  return 
  to:@return
@1: scope:[]  from @begin
  (byte) point2_y#6 ← phi( @begin/(byte) point2_y#0 )
  (byte) point2_x#7 ← phi( @begin/(byte) point2_x#0 )
  (byte) point1_y#6 ← phi( @begin/(byte) point1_y#0 )
  (byte) point1_x#6 ← phi( @begin/(byte) point1_x#0 )
  call main 
  to:@2
@2: scope:[]  from @1
  (byte) point2_y#5 ← phi( @1/(byte) point2_y#2 )
  (byte) point2_x#6 ← phi( @1/(byte) point2_x#3 )
  (byte) point1_y#5 ← phi( @1/(byte) point1_y#2 )
  (byte) point1_x#5 ← phi( @1/(byte) point1_x#2 )
  (byte) point1_x#3 ← (byte) point1_x#5
  (byte) point1_y#3 ← (byte) point1_y#5
  (byte) point2_x#4 ← (byte) point2_x#6
  (byte) point2_y#3 ← (byte) point2_y#5
  to:@end
@end: scope:[]  from @2

SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(byte) Point::x
(byte) Point::y
(void()) main()
(label) main::@return
(byte*) main::SCREEN
(byte*) main::SCREEN#0
(byte) point1_x
(byte) point1_x#0
(byte) point1_x#1
(byte) point1_x#2
(byte) point1_x#3
(byte) point1_x#4
(byte) point1_x#5
(byte) point1_x#6
(byte) point1_y
(byte) point1_y#0
(byte) point1_y#1
(byte) point1_y#2
(byte) point1_y#3
(byte) point1_y#4
(byte) point1_y#5
(byte) point1_y#6
(byte) point2_x
(byte) point2_x#0
(byte) point2_x#1
(byte) point2_x#2
(byte) point2_x#3
(byte) point2_x#4
(byte) point2_x#5
(byte) point2_x#6
(byte) point2_x#7
(byte) point2_y
(byte) point2_y#0
(byte) point2_y#1
(byte) point2_y#2
(byte) point2_y#3
(byte) point2_y#4
(byte) point2_y#5
(byte) point2_y#6

Adding number conversion cast (unumber) 2 in (byte) point1_x#1 ← (number) 2
Adding number conversion cast (unumber) 3 in (byte) point1_y#1 ← (number) 3
Adding number conversion cast (unumber) 4 in (byte) point2_x#2 ← (number) 4
Adding number conversion cast (unumber) 0 in *((byte*) main::SCREEN#0 + (number) 0) ← (byte) point1_x#1
Adding number conversion cast (unumber) 1 in *((byte*) main::SCREEN#0 + (number) 1) ← (byte) point1_y#1
Adding number conversion cast (unumber) 2 in *((byte*) main::SCREEN#0 + (number) 2) ← (byte) point2_x#2
Adding number conversion cast (unumber) 3 in *((byte*) main::SCREEN#0 + (number) 3) ← (byte) point2_y#1
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte) point1_x#1 ← (unumber)(number) 2
Inlining cast (byte) point1_y#1 ← (unumber)(number) 3
Inlining cast (byte) point2_x#2 ← (unumber)(number) 4
Inlining cast (byte*) main::SCREEN#0 ← (byte*)(number) $400
Successful SSA optimization Pass2InlineCast
Simplifying constant integer cast 2
Simplifying constant integer cast 3
Simplifying constant integer cast 4
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 2
Simplifying constant integer cast 3
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 3
Finalized unsigned number type (byte) 4
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 3
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte) point1_x#1 = (byte) point2_x#1 (byte) point1_x#4 (byte) point1_x#2 
Alias (byte) point1_y#1 = (byte) point2_y#1 (byte) point1_y#4 (byte) point2_y#4 (byte) point1_y#2 (byte) point2_y#2 
Alias (byte) point2_x#2 = (byte) point2_x#5 (byte) point2_x#3 
Alias (byte) point1_x#0 = (byte) point1_x#6 
Alias (byte) point1_y#0 = (byte) point1_y#6 
Alias (byte) point2_x#0 = (byte) point2_x#7 
Alias (byte) point2_y#0 = (byte) point2_y#6 
Alias (byte) point1_x#3 = (byte) point1_x#5 
Alias (byte) point1_y#3 = (byte) point1_y#5 
Alias (byte) point2_x#4 = (byte) point2_x#6 
Alias (byte) point2_y#3 = (byte) point2_y#5 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) point1_x#3 (byte) point1_x#1
Identical Phi Values (byte) point1_y#3 (byte) point1_y#1
Identical Phi Values (byte) point2_x#4 (byte) point2_x#2
Identical Phi Values (byte) point2_y#3 (byte) point1_y#1
Successful SSA optimization Pass2IdenticalPhiElimination
Constant (const byte) point1_x#0 = 0
Constant (const byte) point1_y#0 = 0
Constant (const byte) point2_x#0 = 0
Constant (const byte) point2_y#0 = 0
Constant (const byte) point1_x#1 = 2
Constant (const byte) point1_y#1 = 3
Constant (const byte) point2_x#2 = 4
Constant (const byte*) main::SCREEN#0 = (byte*) 1024
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero main::SCREEN#0 in [10] *((const byte*) main::SCREEN#0 + (byte) 0) ← (const byte) point1_x#1
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant (const byte) point1_x#0
Eliminating unused constant (const byte) point1_y#0
Eliminating unused constant (const byte) point2_x#0
Eliminating unused constant (const byte) point2_y#0
Successful SSA optimization PassNEliminateUnusedVars
Consolidated array index constant in *(main::SCREEN#0+1)
Consolidated array index constant in *(main::SCREEN#0+2)
Consolidated array index constant in *(main::SCREEN#0+3)
Successful SSA optimization Pass2ConstantAdditionElimination
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
CALL GRAPH
Calls in [] to main:2 

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block (label) @2
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi()
  to:@1
@1: scope:[]  from @begin
  [1] phi()
  [2] call main 
  to:@end
@end: scope:[]  from @1
  [3] phi()
main: scope:[main]  from @1
  [4] *((const byte*) main::SCREEN#0) ← (const byte) point1_x#1
  [5] *((const byte*) main::SCREEN#0+(byte) 1) ← (const byte) point1_y#1
  [6] *((const byte*) main::SCREEN#0+(byte) 2) ← (const byte) point2_x#2
  [7] *((const byte*) main::SCREEN#0+(byte) 3) ← (const byte) point1_y#1
  to:main::@return
main::@return: scope:[main]  from main
  [8] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte) Point::x
(byte) Point::y
(void()) main()
(byte*) main::SCREEN
(byte) point1_x
(byte) point1_y
(byte) point2_x
(byte) point2_y

Initial phi equivalence classes
Complete equivalence classes

INITIAL ASM
  // File Comments
// Minimal struct - two instances being copied (using assignment)
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .const point1_x = 2
  .const point1_y = 3
  .const point2_x = 4
  // @begin
bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
  // @1
b1:
  // [2] call main 
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
main: {
    .label SCREEN = $400
    // [4] *((const byte*) main::SCREEN#0) ← (const byte) point1_x#1 -- _deref_pbuc1=vbuc2 
    lda #point1_x
    sta SCREEN
    // [5] *((const byte*) main::SCREEN#0+(byte) 1) ← (const byte) point1_y#1 -- _deref_pbuc1=vbuc2 
    lda #point1_y
    sta SCREEN+1
    // [6] *((const byte*) main::SCREEN#0+(byte) 2) ← (const byte) point2_x#2 -- _deref_pbuc1=vbuc2 
    lda #point2_x
    sta SCREEN+2
    // [7] *((const byte*) main::SCREEN#0+(byte) 3) ← (const byte) point1_y#1 -- _deref_pbuc1=vbuc2 
    lda #point1_y
    sta SCREEN+3
    jmp breturn
    // main::@return
  breturn:
    // [8] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] *((const byte*) main::SCREEN#0) ← (const byte) point1_x#1 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [5] *((const byte*) main::SCREEN#0+(byte) 1) ← (const byte) point1_y#1 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [6] *((const byte*) main::SCREEN#0+(byte) 2) ← (const byte) point2_x#2 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [7] *((const byte*) main::SCREEN#0+(byte) 3) ← (const byte) point1_y#1 [ ] ( main:2 [ ] ) always clobbers reg byte a 

REGISTER UPLIFT SCOPES
Uplift Scope [Point] 
Uplift Scope [main] 
Uplift Scope [] 

Uplifting [Point] best 45 combination 
Uplifting [main] best 45 combination 
Uplifting [] best 45 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Minimal struct - two instances being copied (using assignment)
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .const point1_x = 2
  .const point1_y = 3
  .const point2_x = 4
  // @begin
bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
  // @1
b1:
  // [2] call main 
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
main: {
    .label SCREEN = $400
    // [4] *((const byte*) main::SCREEN#0) ← (const byte) point1_x#1 -- _deref_pbuc1=vbuc2 
    lda #point1_x
    sta SCREEN
    // [5] *((const byte*) main::SCREEN#0+(byte) 1) ← (const byte) point1_y#1 -- _deref_pbuc1=vbuc2 
    lda #point1_y
    sta SCREEN+1
    // [6] *((const byte*) main::SCREEN#0+(byte) 2) ← (const byte) point2_x#2 -- _deref_pbuc1=vbuc2 
    lda #point2_x
    sta SCREEN+2
    // [7] *((const byte*) main::SCREEN#0+(byte) 3) ← (const byte) point1_y#1 -- _deref_pbuc1=vbuc2 
    lda #point1_y
    sta SCREEN+3
    jmp breturn
    // main::@return
  breturn:
    // [8] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction bend_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte) Point::x
(byte) Point::y
(void()) main()
(label) main::@return
(byte*) main::SCREEN
(const byte*) main::SCREEN#0 SCREEN = (byte*) 1024
(byte) point1_x
(const byte) point1_x#1 point1_x = (byte) 2
(byte) point1_y
(const byte) point1_y#1 point1_y = (byte) 3
(byte) point2_x
(const byte) point2_x#2 point2_x = (byte) 4
(byte) point2_y



FINAL ASSEMBLER
Score: 30

  // File Comments
// Minimal struct - two instances being copied (using assignment)
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .const point1_x = 2
  .const point1_y = 3
  .const point2_x = 4
  // @begin
  // [1] phi from @begin to @1 [phi:@begin->@1]
  // @1
  // [2] call main 
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    .label SCREEN = $400
    // SCREEN[0] = point1.x
    // [4] *((const byte*) main::SCREEN#0) ← (const byte) point1_x#1 -- _deref_pbuc1=vbuc2 
    lda #point1_x
    sta SCREEN
    // SCREEN[1] = point1.y
    // [5] *((const byte*) main::SCREEN#0+(byte) 1) ← (const byte) point1_y#1 -- _deref_pbuc1=vbuc2 
    lda #point1_y
    sta SCREEN+1
    // SCREEN[2] = point2.x
    // [6] *((const byte*) main::SCREEN#0+(byte) 2) ← (const byte) point2_x#2 -- _deref_pbuc1=vbuc2 
    lda #point2_x
    sta SCREEN+2
    // SCREEN[3] = point2.y
    // [7] *((const byte*) main::SCREEN#0+(byte) 3) ← (const byte) point1_y#1 -- _deref_pbuc1=vbuc2 
    lda #point1_y
    sta SCREEN+3
    // main::@return
    // }
    // [8] return 
    rts
}
  // File Data

