Removing C-classic struct-unwound assignment main::p1 = struct-unwound {*(&main::p1)}

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  *(&main::p1) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT)
  print1::p_x#0 = *((char *)&main::p1+OFFSET_STRUCT_POINT_X)
  print1::p_y#0 = *((char *)&main::p1+OFFSET_STRUCT_POINT_Y)
  print1::idx#0 = 0
  call print1
  to:main::@1
main::@1: scope:[main]  from main
  print2::p_x#0 = *((char *)&main::p1+OFFSET_STRUCT_POINT_X)
  print2::p_y#0 = *((char *)&main::p1+OFFSET_STRUCT_POINT_Y)
  print2::idx#0 = 2
  call print2
  to:main::@2
main::@2: scope:[main]  from main::@1
  print1::p_x#1 = main::p2_x
  print1::p_y#1 = main::p2_y
  print1::idx#1 = 4
  call print1
  to:main::@3
main::@3: scope:[main]  from main::@2
  print2::p_x#1 = main::p2_x
  print2::p_y#1 = main::p2_y
  print2::idx#1 = 6
  call print2
  to:main::@4
main::@4: scope:[main]  from main::@3
  to:main::@return
main::@return: scope:[main]  from main::@4
  return 
  to:@return

void print1(char p_x , char p_y , char idx)
print1: scope:[print1]  from main main::@2
  print1::p_y#2 = phi( main/print1::p_y#0, main::@2/print1::p_y#1 )
  print1::p_x#2 = phi( main/print1::p_x#0, main::@2/print1::p_x#1 )
  print1::idx#2 = phi( main/print1::idx#0, main::@2/print1::idx#1 )
  print1::$0 = print1::idx#2 * SIZEOF_STRUCT_POINT
  ((char *)SCREEN+OFFSET_STRUCT_POINT_X)[print1::$0] = print1::p_x#2
  ((char *)SCREEN+OFFSET_STRUCT_POINT_Y)[print1::$0] = print1::p_y#2
  to:print1::@return
print1::@return: scope:[print1]  from print1
  return 
  to:@return

void print2(char p_x , char p_y , char idx)
print2: scope:[print2]  from main::@1 main::@3
  print2::p_y#2 = phi( main::@1/print2::p_y#0, main::@3/print2::p_y#1 )
  print2::p_x#2 = phi( main::@1/print2::p_x#0, main::@3/print2::p_x#1 )
  print2::idx#2 = phi( main::@1/print2::idx#0, main::@3/print2::idx#1 )
  print2::$0 = print2::idx#2 * SIZEOF_STRUCT_POINT
  ((char *)SCREEN+OFFSET_STRUCT_POINT_X)[print2::$0] = print2::p_x#2
  ((char *)SCREEN+OFFSET_STRUCT_POINT_Y)[print2::$0] = print2::p_y#2
  to:print2::@return
print2::@return: scope:[print2]  from print2
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  call main
  to:__start::@1
__start::@1: scope:[__start]  from __start
  to:__start::@return
__start::@return: scope:[__start]  from __start::@1
  return 
  to:@return

SYMBOL TABLE SSA
__constant struct Point $0 = { x: 1, y: 2 }
__constant char OFFSET_STRUCT_POINT_X = 0
__constant char OFFSET_STRUCT_POINT_Y = 1
__constant struct Point * const SCREEN = (struct Point *)$400
__constant char SIZEOF_STRUCT_POINT = 2
void __start()
void main()
__loadstore struct Point main::p1
__constant char main::p2_x = 3
__constant char main::p2_y = 4
void print1(char p_x , char p_y , char idx)
char print1::$0
char print1::idx
char print1::idx#0
char print1::idx#1
char print1::idx#2
struct Point print1::p
char print1::p_x
char print1::p_x#0
char print1::p_x#1
char print1::p_x#2
char print1::p_y
char print1::p_y#0
char print1::p_y#1
char print1::p_y#2
void print2(char p_x , char p_y , char idx)
char print2::$0
char print2::idx
char print2::idx#0
char print2::idx#1
char print2::idx#2
struct Point print2::p
char print2::p_x
char print2::p_x#0
char print2::p_x#1
char print2::p_x#2
char print2::p_y
char print2::p_y#0
char print2::p_y#1
char print2::p_y#2

Adding number conversion cast (unumber) 0 in print1::idx#0 = 0
Adding number conversion cast (unumber) 2 in print2::idx#0 = 2
Adding number conversion cast (unumber) 4 in print1::idx#1 = 4
Adding number conversion cast (unumber) 6 in print2::idx#1 = 6
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast print1::idx#0 = (unumber)0
Inlining cast print2::idx#0 = (unumber)2
Inlining cast print1::idx#1 = (unumber)4
Inlining cast print2::idx#1 = (unumber)6
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (struct Point *) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 2
Simplifying constant integer cast 4
Simplifying constant integer cast 6
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 2
Finalized unsigned number type (char) 4
Finalized unsigned number type (char) 6
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant print1::idx#0 = 0
Constant print2::idx#0 = 2
Constant print1::p_x#1 = main::p2_x
Constant print1::p_y#1 = main::p2_y
Constant print1::idx#1 = 4
Constant print2::p_x#1 = main::p2_x
Constant print2::p_y#1 = main::p2_y
Constant print2::idx#1 = 6
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero (char *)&main::p1 in [1] print1::p_x#0 = *((char *)&main::p1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (char *)&main::p1 in [5] print2::p_x#0 = *((char *)&main::p1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (char *)SCREEN in [20] ((char *)SCREEN+OFFSET_STRUCT_POINT_X)[print1::$0] = print1::p_x#2
Simplifying expression containing zero (char *)SCREEN in [25] ((char *)SCREEN+OFFSET_STRUCT_POINT_X)[print2::$0] = print2::p_x#2
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant OFFSET_STRUCT_POINT_X
Successful SSA optimization PassNEliminateUnusedVars
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::@1
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Rewriting multiplication to use shift [11] print1::$0 = print1::idx#2 * SIZEOF_STRUCT_POINT
Rewriting multiplication to use shift [16] print2::$0 = print2::idx#2 * SIZEOF_STRUCT_POINT
Successful SSA optimization Pass2MultiplyToShiftRewriting
Inlining constant with var siblings print1::idx#0
Inlining constant with var siblings print1::p_x#1
Inlining constant with var siblings print1::p_y#1
Inlining constant with var siblings print1::idx#1
Inlining constant with var siblings print2::idx#0
Inlining constant with var siblings print2::p_x#1
Inlining constant with var siblings print2::p_y#1
Inlining constant with var siblings print2::idx#1
Constant inlined print2::p_y#1 = main::p2_y
Constant inlined print1::p_x#1 = main::p2_x
Constant inlined print2::p_x#1 = main::p2_x
Constant inlined print1::p_y#1 = main::p2_y
Constant inlined print2::idx#0 = 2
Constant inlined print2::idx#1 = 6
Constant inlined print1::idx#1 = 4
Constant inlined print1::idx#0 = 0
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of main::@2
Adding NOP phi() at start of main::@3
Adding NOP phi() at start of main::@4
CALL GRAPH
Calls in [main] to print1:5 print2:10 print1:12 print2:14 

Created 6 initial phi equivalence classes
Coalesced [3] print1::p_x#3 = print1::p_x#0
Coalesced [4] print1::p_y#3 = print1::p_y#0
Coalesced [8] print2::p_x#3 = print2::p_x#0
Coalesced [9] print2::p_y#3 = print2::p_y#0
Coalesced down to 6 phi equivalence classes
Culled Empty Block label main::@4
Adding NOP phi() at start of main::@2
Adding NOP phi() at start of main::@3

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] *(&main::p1) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT)
  [1] print1::p_x#0 = *((char *)&main::p1)
  [2] print1::p_y#0 = *((char *)&main::p1+OFFSET_STRUCT_POINT_Y)
  [3] call print1
  to:main::@1
main::@1: scope:[main]  from main
  [4] print2::p_x#0 = *((char *)&main::p1)
  [5] print2::p_y#0 = *((char *)&main::p1+OFFSET_STRUCT_POINT_Y)
  [6] call print2
  to:main::@2
main::@2: scope:[main]  from main::@1
  [7] phi()
  [8] call print1
  to:main::@3
main::@3: scope:[main]  from main::@2
  [9] phi()
  [10] call print2
  to:main::@return
main::@return: scope:[main]  from main::@3
  [11] return 
  to:@return

void print1(char p_x , char p_y , char idx)
print1: scope:[print1]  from main main::@2
  [12] print1::p_y#2 = phi( main/print1::p_y#0, main::@2/main::p2_y )
  [12] print1::p_x#2 = phi( main/print1::p_x#0, main::@2/main::p2_x )
  [12] print1::idx#2 = phi( main/0, main::@2/4 )
  [13] print1::$0 = print1::idx#2 << 1
  [14] ((char *)SCREEN)[print1::$0] = print1::p_x#2
  [15] ((char *)SCREEN+OFFSET_STRUCT_POINT_Y)[print1::$0] = print1::p_y#2
  to:print1::@return
print1::@return: scope:[print1]  from print1
  [16] return 
  to:@return

void print2(char p_x , char p_y , char idx)
print2: scope:[print2]  from main::@1 main::@3
  [17] print2::p_y#2 = phi( main::@1/print2::p_y#0, main::@3/main::p2_y )
  [17] print2::p_x#2 = phi( main::@1/print2::p_x#0, main::@3/main::p2_x )
  [17] print2::idx#2 = phi( main::@1/2, main::@3/6 )
  [18] print2::$0 = print2::idx#2 << 1
  [19] ((char *)SCREEN)[print2::$0] = print2::p_x#2
  [20] ((char *)SCREEN+OFFSET_STRUCT_POINT_Y)[print2::$0] = print2::p_y#2
  to:print2::@return
print2::@return: scope:[print2]  from print2
  [21] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
__loadstore struct Point main::p1
void print1(char p_x , char p_y , char idx)
char print1::$0 // 16.5
char print1::idx
char print1::idx#2 // 11.0
struct Point print1::p
char print1::p_x
char print1::p_x#0 // 2.0
char print1::p_x#2 // 6.5
char print1::p_y
char print1::p_y#0 // 4.0
char print1::p_y#2 // 4.333333333333333
void print2(char p_x , char p_y , char idx)
char print2::$0 // 16.5
char print2::idx
char print2::idx#2 // 11.0
struct Point print2::p
char print2::p_x
char print2::p_x#0 // 2.0
char print2::p_x#2 // 6.5
char print2::p_y
char print2::p_y#0 // 4.0
char print2::p_y#2 // 4.333333333333333

Initial phi equivalence classes
[ print1::idx#2 ]
[ print1::p_x#2 print1::p_x#0 ]
[ print1::p_y#2 print1::p_y#0 ]
[ print2::idx#2 ]
[ print2::p_x#2 print2::p_x#0 ]
[ print2::p_y#2 print2::p_y#0 ]
Added variable print1::$0 to live range equivalence class [ print1::$0 ]
Added variable print2::$0 to live range equivalence class [ print2::$0 ]
Added variable main::p1 to live range equivalence class [ main::p1 ]
Complete equivalence classes
[ print1::idx#2 ]
[ print1::p_x#2 print1::p_x#0 ]
[ print1::p_y#2 print1::p_y#0 ]
[ print2::idx#2 ]
[ print2::p_x#2 print2::p_x#0 ]
[ print2::p_y#2 print2::p_y#0 ]
[ print1::$0 ]
[ print2::$0 ]
[ main::p1 ]
Allocated zp[1]:2 [ print1::$0 ]
Allocated zp[1]:3 [ print2::$0 ]
Allocated zp[1]:4 [ print1::idx#2 ]
Allocated zp[1]:5 [ print2::idx#2 ]
Allocated zp[1]:6 [ print1::p_x#2 print1::p_x#0 ]
Allocated zp[1]:7 [ print2::p_x#2 print2::p_x#0 ]
Allocated zp[1]:8 [ print1::p_y#2 print1::p_y#0 ]
Allocated zp[1]:9 [ print2::p_y#2 print2::p_y#0 ]
Allocated zp[2]:10 [ main::p1 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] *(&main::p1) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT) [ main::p1 ] (  [ main::p1 ] { { print1::p_x#0 = print1::p_x#2 } { print1::p_y#0 = print1::p_y#2 } }  ) always clobbers reg byte a reg byte y 
Statement [13] print1::$0 = print1::idx#2 << 1 [ print1::p_x#2 print1::p_y#2 print1::$0 ] ( print1:3 [ main::p1 print1::p_x#2 print1::p_y#2 print1::$0 ] { { print1::p_x#0 = print1::p_x#2 } { print1::p_y#0 = print1::p_y#2 } }  print1:8 [ print1::p_x#2 print1::p_y#2 print1::$0 ] { }  ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:6 [ print1::p_x#2 print1::p_x#0 ]
Removing always clobbered register reg byte a as potential for zp[1]:8 [ print1::p_y#2 print1::p_y#0 ]
Statement [14] ((char *)SCREEN)[print1::$0] = print1::p_x#2 [ print1::p_y#2 print1::$0 ] ( print1:3 [ main::p1 print1::p_y#2 print1::$0 ] { { print1::p_x#0 = print1::p_x#2 } { print1::p_y#0 = print1::p_y#2 } }  print1:8 [ print1::p_y#2 print1::$0 ] { }  ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:2 [ print1::$0 ]
Statement [15] ((char *)SCREEN+OFFSET_STRUCT_POINT_Y)[print1::$0] = print1::p_y#2 [ ] ( print1:3 [ main::p1 ] { { print1::p_x#0 = print1::p_x#2 } { print1::p_y#0 = print1::p_y#2 } }  print1:8 [ ] { }  ) always clobbers reg byte a 
Statement [18] print2::$0 = print2::idx#2 << 1 [ print2::p_x#2 print2::p_y#2 print2::$0 ] ( print2:6 [ print2::p_x#2 print2::p_y#2 print2::$0 ] { { print2::p_x#0 = print2::p_x#2 } { print2::p_y#0 = print2::p_y#2 } }  print2:10 [ print2::p_x#2 print2::p_y#2 print2::$0 ] { }  ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:7 [ print2::p_x#2 print2::p_x#0 ]
Removing always clobbered register reg byte a as potential for zp[1]:9 [ print2::p_y#2 print2::p_y#0 ]
Statement [19] ((char *)SCREEN)[print2::$0] = print2::p_x#2 [ print2::p_y#2 print2::$0 ] ( print2:6 [ print2::p_y#2 print2::$0 ] { { print2::p_x#0 = print2::p_x#2 } { print2::p_y#0 = print2::p_y#2 } }  print2:10 [ print2::p_y#2 print2::$0 ] { }  ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:3 [ print2::$0 ]
Statement [20] ((char *)SCREEN+OFFSET_STRUCT_POINT_Y)[print2::$0] = print2::p_y#2 [ ] ( print2:6 [ ] { { print2::p_x#0 = print2::p_x#2 } { print2::p_y#0 = print2::p_y#2 } }  print2:10 [ ] { }  ) always clobbers reg byte a 
Statement [0] *(&main::p1) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT) [ main::p1 ] (  [ main::p1 ] { { print1::p_x#0 = print1::p_x#2 } { print1::p_y#0 = print1::p_y#2 } }  ) always clobbers reg byte a reg byte y 
Statement [13] print1::$0 = print1::idx#2 << 1 [ print1::p_x#2 print1::p_y#2 print1::$0 ] ( print1:3 [ main::p1 print1::p_x#2 print1::p_y#2 print1::$0 ] { { print1::p_x#0 = print1::p_x#2 } { print1::p_y#0 = print1::p_y#2 } }  print1:8 [ print1::p_x#2 print1::p_y#2 print1::$0 ] { }  ) always clobbers reg byte a 
Statement [14] ((char *)SCREEN)[print1::$0] = print1::p_x#2 [ print1::p_y#2 print1::$0 ] ( print1:3 [ main::p1 print1::p_y#2 print1::$0 ] { { print1::p_x#0 = print1::p_x#2 } { print1::p_y#0 = print1::p_y#2 } }  print1:8 [ print1::p_y#2 print1::$0 ] { }  ) always clobbers reg byte a 
Statement [15] ((char *)SCREEN+OFFSET_STRUCT_POINT_Y)[print1::$0] = print1::p_y#2 [ ] ( print1:3 [ main::p1 ] { { print1::p_x#0 = print1::p_x#2 } { print1::p_y#0 = print1::p_y#2 } }  print1:8 [ ] { }  ) always clobbers reg byte a 
Statement [18] print2::$0 = print2::idx#2 << 1 [ print2::p_x#2 print2::p_y#2 print2::$0 ] ( print2:6 [ print2::p_x#2 print2::p_y#2 print2::$0 ] { { print2::p_x#0 = print2::p_x#2 } { print2::p_y#0 = print2::p_y#2 } }  print2:10 [ print2::p_x#2 print2::p_y#2 print2::$0 ] { }  ) always clobbers reg byte a 
Statement [19] ((char *)SCREEN)[print2::$0] = print2::p_x#2 [ print2::p_y#2 print2::$0 ] ( print2:6 [ print2::p_y#2 print2::$0 ] { { print2::p_x#0 = print2::p_x#2 } { print2::p_y#0 = print2::p_y#2 } }  print2:10 [ print2::p_y#2 print2::$0 ] { }  ) always clobbers reg byte a 
Statement [20] ((char *)SCREEN+OFFSET_STRUCT_POINT_Y)[print2::$0] = print2::p_y#2 [ ] ( print2:6 [ ] { { print2::p_x#0 = print2::p_x#2 } { print2::p_y#0 = print2::p_y#2 } }  print2:10 [ ] { }  ) always clobbers reg byte a 
Potential registers zp[1]:4 [ print1::idx#2 ] : zp[1]:4 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:6 [ print1::p_x#2 print1::p_x#0 ] : zp[1]:6 , reg byte x , reg byte y , 
Potential registers zp[1]:8 [ print1::p_y#2 print1::p_y#0 ] : zp[1]:8 , reg byte x , reg byte y , 
Potential registers zp[1]:5 [ print2::idx#2 ] : zp[1]:5 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:7 [ print2::p_x#2 print2::p_x#0 ] : zp[1]:7 , reg byte x , reg byte y , 
Potential registers zp[1]:9 [ print2::p_y#2 print2::p_y#0 ] : zp[1]:9 , reg byte x , reg byte y , 
Potential registers zp[1]:2 [ print1::$0 ] : zp[1]:2 , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ print2::$0 ] : zp[1]:3 , reg byte x , reg byte y , 
Potential registers zp[2]:10 [ main::p1 ] : zp[2]:10 , 

REGISTER UPLIFT SCOPES
Uplift Scope [print1] 16.5: zp[1]:2 [ print1::$0 ] 11: zp[1]:4 [ print1::idx#2 ] 8.5: zp[1]:6 [ print1::p_x#2 print1::p_x#0 ] 8.33: zp[1]:8 [ print1::p_y#2 print1::p_y#0 ] 
Uplift Scope [print2] 16.5: zp[1]:3 [ print2::$0 ] 11: zp[1]:5 [ print2::idx#2 ] 8.5: zp[1]:7 [ print2::p_x#2 print2::p_x#0 ] 8.33: zp[1]:9 [ print2::p_y#2 print2::p_y#0 ] 
Uplift Scope [Point] 
Uplift Scope [main] 0: zp[2]:10 [ main::p1 ] 
Uplift Scope [] 

Uplifting [print1] best 179 combination zp[1]:2 [ print1::$0 ] reg byte a [ print1::idx#2 ] reg byte y [ print1::p_x#2 print1::p_x#0 ] reg byte x [ print1::p_y#2 print1::p_y#0 ] 
Limited combination testing to 100 combinations of 108 possible.
Uplifting [print2] best 156 combination zp[1]:3 [ print2::$0 ] reg byte a [ print2::idx#2 ] reg byte y [ print2::p_x#2 print2::p_x#0 ] reg byte x [ print2::p_y#2 print2::p_y#0 ] 
Limited combination testing to 100 combinations of 108 possible.
Uplifting [Point] best 156 combination 
Uplifting [main] best 156 combination zp[2]:10 [ main::p1 ] 
Uplifting [] best 156 combination 
Attempting to uplift remaining variables inzp[1]:2 [ print1::$0 ]
Uplifting [print1] best 156 combination zp[1]:2 [ print1::$0 ] 
Attempting to uplift remaining variables inzp[1]:3 [ print2::$0 ]
Uplifting [print2] best 156 combination zp[1]:3 [ print2::$0 ] 
Coalescing zero page register [ zp[1]:3 [ print2::$0 ] ] with [ zp[1]:2 [ print1::$0 ] ]
Allocated (was zp[1]:3) zp[1]:2 [ print2::$0 print1::$0 ]
Allocated (was zp[2]:10) zp[2]:3 [ main::p1 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test combining unwind structs with classic structs
// Function calls parameter passing
  // Upstart
  // Commodore 64 PRG executable file
.file [name="struct-unwinding-2.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
  // Global Constants & labels
  .const SIZEOF_STRUCT_POINT = 2
  .const OFFSET_STRUCT_POINT_Y = 1
  .label SCREEN = $400
.segment Code
  // main
main: {
    .const p2_x = 3
    .const p2_y = 4
    .label p1 = 3
    // [0] *(&main::p1) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT) -- _deref_pssc1=_deref_pssc2_memcpy_vbuc3 
    ldy #SIZEOF_STRUCT_POINT
  !:
    lda __0-1,y
    sta p1-1,y
    dey
    bne !-
    // [1] print1::p_x#0 = *((char *)&main::p1) -- vbuyy=_deref_pbuc1 
    ldy.z p1
    // [2] print1::p_y#0 = *((char *)&main::p1+OFFSET_STRUCT_POINT_Y) -- vbuxx=_deref_pbuc1 
    ldx p1+OFFSET_STRUCT_POINT_Y
    // [3] call print1
  // Pass classic struct to function taking unwound struct
    // [12] phi from main to print1 [phi:main->print1]
  print1_from_main:
    // [12] phi print1::p_y#2 = print1::p_y#0 [phi:main->print1#0] -- register_copy 
    // [12] phi print1::p_x#2 = print1::p_x#0 [phi:main->print1#1] -- register_copy 
    // [12] phi print1::idx#2 = 0 [phi:main->print1#2] -- vbuaa=vbuc1 
    lda #0
    jsr print1
    jmp __b1
    // main::@1
  __b1:
    // [4] print2::p_x#0 = *((char *)&main::p1) -- vbuyy=_deref_pbuc1 
    ldy.z p1
    // [5] print2::p_y#0 = *((char *)&main::p1+OFFSET_STRUCT_POINT_Y) -- vbuxx=_deref_pbuc1 
    ldx p1+OFFSET_STRUCT_POINT_Y
    // [6] call print2
  // Pass classic struct to function taking classic struct
    // [17] phi from main::@1 to print2 [phi:main::@1->print2]
  print2_from___b1:
    // [17] phi print2::p_y#2 = print2::p_y#0 [phi:main::@1->print2#0] -- register_copy 
    // [17] phi print2::p_x#2 = print2::p_x#0 [phi:main::@1->print2#1] -- register_copy 
    // [17] phi print2::idx#2 = 2 [phi:main::@1->print2#2] -- vbuaa=vbuc1 
    lda #2
    jsr print2
    // [7] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  __b2_from___b1:
    jmp __b2
    // main::@2
  __b2:
    // [8] call print1
  // Pass unwound struct to function taking unwound struct
    // [12] phi from main::@2 to print1 [phi:main::@2->print1]
  print1_from___b2:
    // [12] phi print1::p_y#2 = main::p2_y [phi:main::@2->print1#0] -- vbuxx=vbuc1 
    ldx #p2_y
    // [12] phi print1::p_x#2 = main::p2_x [phi:main::@2->print1#1] -- vbuyy=vbuc1 
    ldy #p2_x
    // [12] phi print1::idx#2 = 4 [phi:main::@2->print1#2] -- vbuaa=vbuc1 
    lda #4
    jsr print1
    // [9] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
  __b3_from___b2:
    jmp __b3
    // main::@3
  __b3:
    // [10] call print2
  // Pass unwound struct to function taking classic struct
    // [17] phi from main::@3 to print2 [phi:main::@3->print2]
  print2_from___b3:
    // [17] phi print2::p_y#2 = main::p2_y [phi:main::@3->print2#0] -- vbuxx=vbuc1 
    ldx #p2_y
    // [17] phi print2::p_x#2 = main::p2_x [phi:main::@3->print2#1] -- vbuyy=vbuc1 
    ldy #p2_x
    // [17] phi print2::idx#2 = 6 [phi:main::@3->print2#2] -- vbuaa=vbuc1 
    lda #6
    jsr print2
    jmp __breturn
    // main::@return
  __breturn:
    // [11] return 
    rts
}
  // print1
// Function taking unwound struct as parameter
// void print1(__register(Y) char p_x, __register(X) char p_y, __register(A) char idx)
print1: {
    .label __0 = 2
    // [13] print1::$0 = print1::idx#2 << 1 -- vbuz1=vbuaa_rol_1 
    asl
    sta.z __0
    // [14] ((char *)SCREEN)[print1::$0] = print1::p_x#2 -- pbuc1_derefidx_vbuz1=vbuyy 
    tya
    ldy.z __0
    sta SCREEN,y
    // [15] ((char *)SCREEN+OFFSET_STRUCT_POINT_Y)[print1::$0] = print1::p_y#2 -- pbuc1_derefidx_vbuz1=vbuxx 
    ldy.z __0
    txa
    sta SCREEN+OFFSET_STRUCT_POINT_Y,y
    jmp __breturn
    // print1::@return
  __breturn:
    // [16] return 
    rts
}
  // print2
// Function taking classic struct as parameter
// void print2(__register(Y) char p_x, __register(X) char p_y, __register(A) char idx)
print2: {
    .label __0 = 2
    // [18] print2::$0 = print2::idx#2 << 1 -- vbuz1=vbuaa_rol_1 
    asl
    sta.z __0
    // [19] ((char *)SCREEN)[print2::$0] = print2::p_x#2 -- pbuc1_derefidx_vbuz1=vbuyy 
    tya
    ldy.z __0
    sta SCREEN,y
    // [20] ((char *)SCREEN+OFFSET_STRUCT_POINT_Y)[print2::$0] = print2::p_y#2 -- pbuc1_derefidx_vbuz1=vbuxx 
    ldy.z __0
    txa
    sta SCREEN+OFFSET_STRUCT_POINT_Y,y
    jmp __breturn
    // print2::@return
  __breturn:
    // [21] return 
    rts
}
  // File Data
.segment Data
  __0: .byte 1, 2

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __b3
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction ldy.z __0
Removing instruction ldy.z __0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Removing instruction __b2_from___b1:
Removing instruction __b3_from___b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction print1_from_main:
Removing instruction __b1:
Removing instruction print2_from___b1:
Removing instruction __b2:
Removing instruction print1_from___b2:
Removing instruction __b3:
Removing instruction print2_from___b3:
Removing instruction __breturn:
Removing instruction __breturn:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
__constant struct Point $0 = { x: 1, y: 2 }
__constant char OFFSET_STRUCT_POINT_Y = 1
__constant struct Point * const SCREEN = (struct Point *) 1024
__constant char SIZEOF_STRUCT_POINT = 2
void main()
__loadstore struct Point main::p1 // zp[2]:3
__constant char main::p2_x = 3
__constant char main::p2_y = 4
void print1(char p_x , char p_y , char idx)
char print1::$0 // zp[1]:2 16.5
char print1::idx
char print1::idx#2 // reg byte a 11.0
struct Point print1::p
char print1::p_x
char print1::p_x#0 // reg byte y 2.0
char print1::p_x#2 // reg byte y 6.5
char print1::p_y
char print1::p_y#0 // reg byte x 4.0
char print1::p_y#2 // reg byte x 4.333333333333333
void print2(char p_x , char p_y , char idx)
char print2::$0 // zp[1]:2 16.5
char print2::idx
char print2::idx#2 // reg byte a 11.0
struct Point print2::p
char print2::p_x
char print2::p_x#0 // reg byte y 2.0
char print2::p_x#2 // reg byte y 6.5
char print2::p_y
char print2::p_y#0 // reg byte x 4.0
char print2::p_y#2 // reg byte x 4.333333333333333

reg byte a [ print1::idx#2 ]
reg byte y [ print1::p_x#2 print1::p_x#0 ]
reg byte x [ print1::p_y#2 print1::p_y#0 ]
reg byte a [ print2::idx#2 ]
reg byte y [ print2::p_x#2 print2::p_x#0 ]
reg byte x [ print2::p_y#2 print2::p_y#0 ]
zp[1]:2 [ print2::$0 print1::$0 ]
zp[2]:3 [ main::p1 ]


FINAL ASSEMBLER
Score: 132

  // File Comments
// Test combining unwind structs with classic structs
// Function calls parameter passing
  // Upstart
  // Commodore 64 PRG executable file
.file [name="struct-unwinding-2.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
  // Global Constants & labels
  .const SIZEOF_STRUCT_POINT = 2
  .const OFFSET_STRUCT_POINT_Y = 1
  .label SCREEN = $400
.segment Code
  // main
main: {
    .const p2_x = 3
    .const p2_y = 4
    .label p1 = 3
    // __ma struct Point p1 = { 1, 2 }
    // [0] *(&main::p1) = memcpy(*(&$0), struct Point, SIZEOF_STRUCT_POINT) -- _deref_pssc1=_deref_pssc2_memcpy_vbuc3 
    ldy #SIZEOF_STRUCT_POINT
  !:
    lda __0-1,y
    sta p1-1,y
    dey
    bne !-
    // print1(p1, 0)
    // [1] print1::p_x#0 = *((char *)&main::p1) -- vbuyy=_deref_pbuc1 
    ldy.z p1
    // [2] print1::p_y#0 = *((char *)&main::p1+OFFSET_STRUCT_POINT_Y) -- vbuxx=_deref_pbuc1 
    ldx p1+OFFSET_STRUCT_POINT_Y
    // [3] call print1
  // Pass classic struct to function taking unwound struct
    // [12] phi from main to print1 [phi:main->print1]
    // [12] phi print1::p_y#2 = print1::p_y#0 [phi:main->print1#0] -- register_copy 
    // [12] phi print1::p_x#2 = print1::p_x#0 [phi:main->print1#1] -- register_copy 
    // [12] phi print1::idx#2 = 0 [phi:main->print1#2] -- vbuaa=vbuc1 
    lda #0
    jsr print1
    // main::@1
    // print2(p1, 2)
    // [4] print2::p_x#0 = *((char *)&main::p1) -- vbuyy=_deref_pbuc1 
    ldy.z p1
    // [5] print2::p_y#0 = *((char *)&main::p1+OFFSET_STRUCT_POINT_Y) -- vbuxx=_deref_pbuc1 
    ldx p1+OFFSET_STRUCT_POINT_Y
    // [6] call print2
  // Pass classic struct to function taking classic struct
    // [17] phi from main::@1 to print2 [phi:main::@1->print2]
    // [17] phi print2::p_y#2 = print2::p_y#0 [phi:main::@1->print2#0] -- register_copy 
    // [17] phi print2::p_x#2 = print2::p_x#0 [phi:main::@1->print2#1] -- register_copy 
    // [17] phi print2::idx#2 = 2 [phi:main::@1->print2#2] -- vbuaa=vbuc1 
    lda #2
    jsr print2
    // [7] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
    // main::@2
    // print1(p2, 4)
    // [8] call print1
  // Pass unwound struct to function taking unwound struct
    // [12] phi from main::@2 to print1 [phi:main::@2->print1]
    // [12] phi print1::p_y#2 = main::p2_y [phi:main::@2->print1#0] -- vbuxx=vbuc1 
    ldx #p2_y
    // [12] phi print1::p_x#2 = main::p2_x [phi:main::@2->print1#1] -- vbuyy=vbuc1 
    ldy #p2_x
    // [12] phi print1::idx#2 = 4 [phi:main::@2->print1#2] -- vbuaa=vbuc1 
    lda #4
    jsr print1
    // [9] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
    // main::@3
    // print2(p2, 6)
    // [10] call print2
  // Pass unwound struct to function taking classic struct
    // [17] phi from main::@3 to print2 [phi:main::@3->print2]
    // [17] phi print2::p_y#2 = main::p2_y [phi:main::@3->print2#0] -- vbuxx=vbuc1 
    ldx #p2_y
    // [17] phi print2::p_x#2 = main::p2_x [phi:main::@3->print2#1] -- vbuyy=vbuc1 
    ldy #p2_x
    // [17] phi print2::idx#2 = 6 [phi:main::@3->print2#2] -- vbuaa=vbuc1 
    lda #6
    jsr print2
    // main::@return
    // }
    // [11] return 
    rts
}
  // print1
// Function taking unwound struct as parameter
// void print1(__register(Y) char p_x, __register(X) char p_y, __register(A) char idx)
print1: {
    .label __0 = 2
    // SCREEN[idx] = p
    // [13] print1::$0 = print1::idx#2 << 1 -- vbuz1=vbuaa_rol_1 
    asl
    sta.z __0
    // [14] ((char *)SCREEN)[print1::$0] = print1::p_x#2 -- pbuc1_derefidx_vbuz1=vbuyy 
    tya
    ldy.z __0
    sta SCREEN,y
    // [15] ((char *)SCREEN+OFFSET_STRUCT_POINT_Y)[print1::$0] = print1::p_y#2 -- pbuc1_derefidx_vbuz1=vbuxx 
    txa
    sta SCREEN+OFFSET_STRUCT_POINT_Y,y
    // print1::@return
    // }
    // [16] return 
    rts
}
  // print2
// Function taking classic struct as parameter
// void print2(__register(Y) char p_x, __register(X) char p_y, __register(A) char idx)
print2: {
    .label __0 = 2
    // SCREEN[idx] = p
    // [18] print2::$0 = print2::idx#2 << 1 -- vbuz1=vbuaa_rol_1 
    asl
    sta.z __0
    // [19] ((char *)SCREEN)[print2::$0] = print2::p_x#2 -- pbuc1_derefidx_vbuz1=vbuyy 
    tya
    ldy.z __0
    sta SCREEN,y
    // [20] ((char *)SCREEN+OFFSET_STRUCT_POINT_Y)[print2::$0] = print2::p_y#2 -- pbuc1_derefidx_vbuz1=vbuxx 
    txa
    sta SCREEN+OFFSET_STRUCT_POINT_Y,y
    // print2::@return
    // }
    // [21] return 
    rts
}
  // File Data
.segment Data
  __0: .byte 1, 2

