Created struct value member variable (byte) main::p1_x
Created struct value member variable (byte) main::p1_y
Converted struct value to member variables (struct Point) main::p1
Created struct value member variable (byte) print::p_x
Created struct value member variable (byte) print::p_y
Converted struct value to member variables (struct Point) print::p
Converted procedure struct value parameter to member unwinding (void()) print((byte) print::p_x , (byte) print::p_y)
Unwinding value copy (struct Point) main::p1 ← {}
Adding value simple copy (byte) main::p1_x ← (byte) 0
Adding value simple copy (byte) main::p1_y ← (byte) 0
Converted procedure struct value parameter to member unwinding in call (void~) main::$0 ← call print (byte) main::p1_x (byte) main::p1_y 
Converted procedure struct value parameter to member unwinding in call (void~) main::$1 ← call print (byte) main::p1_x (byte) main::p1_y 
Replacing struct member reference (struct Point) main::p1.x with member unwinding reference (byte) main::p1_x
Replacing struct member reference (struct Point) main::p1.y with member unwinding reference (byte) main::p1_y
Replacing struct member reference (struct Point) main::p1.x with member unwinding reference (byte) main::p1_x
Replacing struct member reference (struct Point) print::p.x with member unwinding reference (byte) print::p_x
Replacing struct member reference (struct Point) print::p.y with member unwinding reference (byte) print::p_y

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@1

(void()) main()
main: scope:[main]  from @2
  (byte) idx#14 ← phi( @2/(byte) idx#15 )
  (byte) main::p1_x#0 ← (byte) 0
  (byte) main::p1_y#0 ← (byte) 0
  (byte) main::p1_x#1 ← (number) 1
  (byte) main::p1_y#1 ← (number) 4
  (byte) print::p_x#0 ← (byte) main::p1_x#1
  (byte) print::p_y#0 ← (byte) main::p1_y#1
  call print 
  to:main::@1
main::@1: scope:[main]  from main
  (byte) main::p1_y#2 ← phi( main/(byte) main::p1_y#1 )
  (byte) idx#8 ← phi( main/(byte) idx#6 )
  (byte) idx#0 ← (byte) idx#8
  (byte) main::p1_x#2 ← (number) 2
  (byte) print::p_x#1 ← (byte) main::p1_x#2
  (byte) print::p_y#1 ← (byte) main::p1_y#2
  call print 
  to:main::@2
main::@2: scope:[main]  from main::@1
  (byte) idx#9 ← phi( main::@1/(byte) idx#6 )
  (byte) idx#1 ← (byte) idx#9
  to:main::@return
main::@return: scope:[main]  from main::@2
  (byte) idx#10 ← phi( main::@2/(byte) idx#1 )
  (byte) idx#2 ← (byte) idx#10
  return 
  to:@return
@1: scope:[]  from @begin
  (byte) idx#3 ← (byte) 0
  to:@2

(void()) print((byte) print::p_x , (byte) print::p_y)
print: scope:[print]  from main main::@1
  (byte) print::p_y#2 ← phi( main/(byte) print::p_y#0 main::@1/(byte) print::p_y#1 )
  (byte) idx#11 ← phi( main/(byte) idx#14 main::@1/(byte) idx#0 )
  (byte) print::p_x#2 ← phi( main/(byte) print::p_x#0 main::@1/(byte) print::p_x#1 )
  *((const byte*) SCREEN + (byte) idx#11) ← (byte) print::p_x#2
  (byte) idx#4 ← ++ (byte) idx#11
  *((const byte*) SCREEN + (byte) idx#4) ← (byte) print::p_y#2
  (byte) idx#5 ← ++ (byte) idx#4
  to:print::@return
print::@return: scope:[print]  from print
  (byte) idx#12 ← phi( print/(byte) idx#5 )
  (byte) idx#6 ← (byte) idx#12
  return 
  to:@return
@2: scope:[]  from @1
  (byte) idx#15 ← phi( @1/(byte) idx#3 )
  call main 
  to:@3
@3: scope:[]  from @2
  (byte) idx#13 ← phi( @2/(byte) idx#2 )
  (byte) idx#7 ← (byte) idx#13
  to:@end
@end: scope:[]  from @3

SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @3
(label) @begin
(label) @end
(byte) Point::x
(byte) Point::y
(const byte*) SCREEN = (byte*)(number) $400
(byte) idx
(byte) idx#0
(byte) idx#1
(byte) idx#10
(byte) idx#11
(byte) idx#12
(byte) idx#13
(byte) idx#14
(byte) idx#15
(byte) idx#2
(byte) idx#3
(byte) idx#4
(byte) idx#5
(byte) idx#6
(byte) idx#7
(byte) idx#8
(byte) idx#9
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(byte) main::p1_x
(byte) main::p1_x#0
(byte) main::p1_x#1
(byte) main::p1_x#2
(byte) main::p1_y
(byte) main::p1_y#0
(byte) main::p1_y#1
(byte) main::p1_y#2
(void()) print((byte) print::p_x , (byte) print::p_y)
(label) print::@return
(struct Point) print::p
(byte) print::p_x
(byte) print::p_x#0
(byte) print::p_x#1
(byte) print::p_x#2
(byte) print::p_y
(byte) print::p_y#0
(byte) print::p_y#1
(byte) print::p_y#2

Adding number conversion cast (unumber) 1 in (byte) main::p1_x#1 ← (number) 1
Adding number conversion cast (unumber) 4 in (byte) main::p1_y#1 ← (number) 4
Adding number conversion cast (unumber) 2 in (byte) main::p1_x#2 ← (number) 2
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte) main::p1_x#1 ← (unumber)(number) 1
Inlining cast (byte) main::p1_y#1 ← (unumber)(number) 4
Inlining cast (byte) main::p1_x#2 ← (unumber)(number) 2
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 1
Simplifying constant integer cast 4
Simplifying constant integer cast 2
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 4
Finalized unsigned number type (byte) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte) main::p1_y#1 = (byte) main::p1_y#2 
Alias (byte) idx#0 = (byte) idx#8 
Alias (byte) idx#1 = (byte) idx#9 (byte) idx#10 (byte) idx#2 
Alias (byte) idx#12 = (byte) idx#5 (byte) idx#6 
Alias (byte) idx#15 = (byte) idx#3 
Alias (byte) idx#13 = (byte) idx#7 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) idx#14 (byte) idx#15
Identical Phi Values (byte) idx#0 (byte) idx#12
Identical Phi Values (byte) idx#1 (byte) idx#12
Identical Phi Values (byte) idx#13 (byte) idx#1
Successful SSA optimization Pass2IdenticalPhiElimination
Constant (const byte) main::p1_x#0 = 0
Constant (const byte) main::p1_y#0 = 0
Constant (const byte) main::p1_x#1 = 1
Constant (const byte) main::p1_y#1 = 4
Constant (const byte) main::p1_x#2 = 2
Constant (const byte) idx#15 = 0
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte) print::p_x#0 = main::p1_x#1
Constant (const byte) print::p_y#0 = main::p1_y#1
Constant (const byte) print::p_x#1 = main::p1_x#2
Constant (const byte) print::p_y#1 = main::p1_y#1
Successful SSA optimization Pass2ConstantIdentification
Eliminating unused constant (const byte) main::p1_x#0
Eliminating unused constant (const byte) main::p1_y#0
Successful SSA optimization PassNEliminateUnusedVars
Inlining constant with different constant siblings (const byte) main::p1_x#1
Inlining constant with different constant siblings (const byte) main::p1_x#2
Inlining constant with var siblings (const byte) print::p_x#0
Inlining constant with var siblings (const byte) print::p_y#0
Inlining constant with var siblings (const byte) print::p_x#1
Inlining constant with var siblings (const byte) print::p_y#1
Inlining constant with var siblings (const byte) idx#15
Constant inlined print::p_x#0 = (byte) 1
Constant inlined print::p_y#1 = (const byte) main::p1_y#1
Constant inlined print::p_y#0 = (const byte) main::p1_y#1
Constant inlined print::p_x#1 = (byte) 2
Constant inlined main::p1_x#2 = (byte) 2
Constant inlined main::p1_x#1 = (byte) 1
Constant inlined idx#15 = (byte) 0
Successful SSA optimization Pass2ConstantInlining
Identical Phi Values (byte) print::p_y#2 (const byte) main::p1_y#1
Successful SSA optimization Pass2IdenticalPhiElimination
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 @3
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@2
CALL GRAPH
Calls in [] to main:3 
Calls in [main] to print:7 print:9 

Created 2 initial phi equivalence classes
Coalesced [8] idx#16 ← idx#12
Coalesced down to 2 phi equivalence classes
Culled Empty Block (label) @1
Culled Empty Block (label) @3
Culled Empty Block (label) main::@2
Renumbering block @2 to @1
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@1

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()

(void()) main()
main: scope:[main]  from @1
  [4] phi()
  [5] call print 
  to:main::@1
main::@1: scope:[main]  from main
  [6] phi()
  [7] call print 
  to:main::@return
main::@return: scope:[main]  from main::@1
  [8] return 
  to:@return

(void()) print((byte) print::p_x , (byte) print::p_y)
print: scope:[print]  from main main::@1
  [9] (byte) idx#11 ← phi( main/(byte) 0 main::@1/(byte) idx#12 )
  [9] (byte) print::p_x#2 ← phi( main/(byte) 1 main::@1/(byte) 2 )
  [10] *((const byte*) SCREEN + (byte) idx#11) ← (byte) print::p_x#2
  [11] (byte) idx#4 ← ++ (byte) idx#11
  [12] *((const byte*) SCREEN + (byte) idx#4) ← (const byte) main::p1_y#1
  [13] (byte) idx#12 ← ++ (byte) idx#4
  to:print::@return
print::@return: scope:[print]  from print
  [14] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte) Point::x
(byte) Point::y
(byte) idx
(byte) idx#11 3.0
(byte) idx#12 1.0
(byte) idx#4 3.0
(void()) main()
(byte) main::p1_x
(byte) main::p1_y
(void()) print((byte) print::p_x , (byte) print::p_y)
(struct Point) print::p
(byte) print::p_x
(byte) print::p_x#2 2.0
(byte) print::p_y

Initial phi equivalence classes
[ print::p_x#2 ]
[ idx#11 idx#12 ]
Added variable idx#4 to live range equivalence class [ idx#4 ]
Complete equivalence classes
[ print::p_x#2 ]
[ idx#11 idx#12 ]
[ idx#4 ]
Allocated zp[1]:2 [ print::p_x#2 ]
Allocated zp[1]:3 [ idx#11 idx#12 ]
Allocated zp[1]:4 [ idx#4 ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// Minimal struct - passing struct value parameter
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  .label idx = 4
  .label idx_1 = 3
  // @begin
__bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
  jmp __b1
  // @1
__b1:
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
main_from___b1:
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
  jmp __bend
  // @end
__bend:
  // main
main: {
    .label p1_y = 4
    // [5] call print 
    // [9] phi from main to print [phi:main->print]
  print_from_main:
    // [9] phi (byte) idx#11 = (byte) 0 [phi:main->print#0] -- vbuz1=vbuc1 
    lda #0
    sta.z idx_1
    // [9] phi (byte) print::p_x#2 = (byte) 1 [phi:main->print#1] -- vbuz1=vbuc1 
    lda #1
    sta.z print.p_x
    jsr print
    // [6] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    jmp __b1
    // main::@1
  __b1:
    // [7] call print 
    // [9] phi from main::@1 to print [phi:main::@1->print]
  print_from___b1:
    // [9] phi (byte) idx#11 = (byte) idx#12 [phi:main::@1->print#0] -- register_copy 
    // [9] phi (byte) print::p_x#2 = (byte) 2 [phi:main::@1->print#1] -- vbuz1=vbuc1 
    lda #2
    sta.z print.p_x
    jsr print
    jmp __breturn
    // main::@return
  __breturn:
    // [8] return 
    rts
}
  // print
// print(byte zp(2) p_x)
print: {
    .label p_x = 2
    // [10] *((const byte*) SCREEN + (byte) idx#11) ← (byte) print::p_x#2 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda.z p_x
    ldy.z idx_1
    sta SCREEN,y
    // [11] (byte) idx#4 ← ++ (byte) idx#11 -- vbuz1=_inc_vbuz2 
    ldy.z idx_1
    iny
    sty.z idx
    // [12] *((const byte*) SCREEN + (byte) idx#4) ← (const byte) main::p1_y#1 -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #main.p1_y
    ldy.z idx
    sta SCREEN,y
    // [13] (byte) idx#12 ← ++ (byte) idx#4 -- vbuz1=_inc_vbuz2 
    ldy.z idx
    iny
    sty.z idx_1
    jmp __breturn
    // print::@return
  __breturn:
    // [14] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [12] *((const byte*) SCREEN + (byte) idx#4) ← (const byte) main::p1_y#1 [ idx#4 ] ( main:2::print:5 [ idx#4 ] main:2::print:7 [ idx#4 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:4 [ idx#4 ]
Statement [12] *((const byte*) SCREEN + (byte) idx#4) ← (const byte) main::p1_y#1 [ idx#4 ] ( main:2::print:5 [ idx#4 ] main:2::print:7 [ idx#4 ] ) always clobbers reg byte a 
Potential registers zp[1]:2 [ print::p_x#2 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ idx#11 idx#12 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:4 [ idx#4 ] : zp[1]:4 , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [] 4: zp[1]:3 [ idx#11 idx#12 ] 3: zp[1]:4 [ idx#4 ] 
Uplift Scope [print] 2: zp[1]:2 [ print::p_x#2 ] 
Uplift Scope [Point] 
Uplift Scope [main] 

Uplifting [] best 76 combination reg byte x [ idx#11 idx#12 ] reg byte x [ idx#4 ] 
Uplifting [print] best 67 combination reg byte a [ print::p_x#2 ] 
Uplifting [Point] best 67 combination 
Uplifting [main] best 67 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Minimal struct - passing struct value parameter
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  // @begin
__bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
  jmp __b1
  // @1
__b1:
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
main_from___b1:
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
  jmp __bend
  // @end
__bend:
  // main
main: {
    .label p1_y = 4
    // [5] call print 
    // [9] phi from main to print [phi:main->print]
  print_from_main:
    // [9] phi (byte) idx#11 = (byte) 0 [phi:main->print#0] -- vbuxx=vbuc1 
    ldx #0
    // [9] phi (byte) print::p_x#2 = (byte) 1 [phi:main->print#1] -- vbuaa=vbuc1 
    lda #1
    jsr print
    // [6] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    jmp __b1
    // main::@1
  __b1:
    // [7] call print 
    // [9] phi from main::@1 to print [phi:main::@1->print]
  print_from___b1:
    // [9] phi (byte) idx#11 = (byte) idx#12 [phi:main::@1->print#0] -- register_copy 
    // [9] phi (byte) print::p_x#2 = (byte) 2 [phi:main::@1->print#1] -- vbuaa=vbuc1 
    lda #2
    jsr print
    jmp __breturn
    // main::@return
  __breturn:
    // [8] return 
    rts
}
  // print
// print(byte register(A) p_x)
print: {
    // [10] *((const byte*) SCREEN + (byte) idx#11) ← (byte) print::p_x#2 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN,x
    // [11] (byte) idx#4 ← ++ (byte) idx#11 -- vbuxx=_inc_vbuxx 
    inx
    // [12] *((const byte*) SCREEN + (byte) idx#4) ← (const byte) main::p1_y#1 -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #main.p1_y
    sta SCREEN,x
    // [13] (byte) idx#12 ← ++ (byte) idx#4 -- vbuxx=_inc_vbuxx 
    inx
    jmp __breturn
    // print::@return
  __breturn:
    // [14] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __bbegin with __b1
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Removing instruction __b1_from_main:
Removing instruction print_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction print_from_main:
Removing instruction __b1:
Removing instruction __breturn:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction __b1:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte) Point::x
(byte) Point::y
(const byte*) SCREEN = (byte*) 1024
(byte) idx
(byte) idx#11 reg byte x 3.0
(byte) idx#12 reg byte x 1.0
(byte) idx#4 reg byte x 3.0
(void()) main()
(label) main::@1
(label) main::@return
(byte) main::p1_x
(byte) main::p1_y
(const byte) main::p1_y#1 p1_y = (byte) 4
(void()) print((byte) print::p_x , (byte) print::p_y)
(label) print::@return
(struct Point) print::p
(byte) print::p_x
(byte) print::p_x#2 reg byte a 2.0
(byte) print::p_y

reg byte a [ print::p_x#2 ]
reg byte x [ idx#11 idx#12 ]
reg byte x [ idx#4 ]


FINAL ASSEMBLER
Score: 46

  // File Comments
// Minimal struct - passing struct value parameter
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  // @begin
  // [1] phi from @begin to @1 [phi:@begin->@1]
  // @1
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    .label p1_y = 4
    // print(p1)
    // [5] call print 
    // [9] phi from main to print [phi:main->print]
    // [9] phi (byte) idx#11 = (byte) 0 [phi:main->print#0] -- vbuxx=vbuc1 
    ldx #0
    // [9] phi (byte) print::p_x#2 = (byte) 1 [phi:main->print#1] -- vbuaa=vbuc1 
    lda #1
    jsr print
    // [6] phi from main to main::@1 [phi:main->main::@1]
    // main::@1
    // print(p1)
    // [7] call print 
    // [9] phi from main::@1 to print [phi:main::@1->print]
    // [9] phi (byte) idx#11 = (byte) idx#12 [phi:main::@1->print#0] -- register_copy 
    // [9] phi (byte) print::p_x#2 = (byte) 2 [phi:main::@1->print#1] -- vbuaa=vbuc1 
    lda #2
    jsr print
    // main::@return
    // }
    // [8] return 
    rts
}
  // print
// print(byte register(A) p_x)
print: {
    // SCREEN[idx++] = p.x
    // [10] *((const byte*) SCREEN + (byte) idx#11) ← (byte) print::p_x#2 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN,x
    // SCREEN[idx++] = p.x;
    // [11] (byte) idx#4 ← ++ (byte) idx#11 -- vbuxx=_inc_vbuxx 
    inx
    // SCREEN[idx++] = p.y
    // [12] *((const byte*) SCREEN + (byte) idx#4) ← (const byte) main::p1_y#1 -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #main.p1_y
    sta SCREEN,x
    // SCREEN[idx++] = p.y;
    // [13] (byte) idx#12 ← ++ (byte) idx#4 -- vbuxx=_inc_vbuxx 
    inx
    // print::@return
    // }
    // [14] return 
    rts
}
  // File Data

