Setting inferred volatile on symbol affected by address-of (struct Point*~) main::$0 ← & (struct Point) main::point
Created struct value member variable (byte) main::point_x
Created struct value member variable (byte) main::point_y
Converted struct value to member variables (struct Point) main::point
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)
Adding struct value list initializer (byte) main::point_x ← (number) 1
Adding struct value list initializer (byte) main::point_y ← (number) 2
Converted procedure struct value parameter to member unwinding in call (void~) main::$1 ← call print (byte) main::point_x (byte) main::point_y 
Converted procedure struct value parameter to member unwinding in call (void~) main::$2 ← call print *((byte*) main::$3) *((byte*) main::$4) 
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
Culled Empty Block (label) @1
Adding versioned struct unwinding for (struct Point) main::point#0

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) SCREEN#0 ← ((byte*)) (number) $400
  (byte) idx#0 ← (number) 0
  to:@2
main: scope:[main]  from @2
  (byte) idx#14 ← phi( @2/(byte) idx#15 )
  (byte) main::point_x#0 ← (number) 1
  (byte) main::point_y#0 ← (number) 2
  (struct Point) main::point#0 ← struct-unwound {(byte) main::point_x#0, (byte) main::point_y#0}
  (struct Point*~) main::$0 ← & (struct Point) main::point#0
  (struct Point*) main::ptr#0 ← (struct Point*~) main::$0
  (byte) print::p_x#0 ← (byte) main::point_x#0
  (byte) print::p_y#0 ← (byte) main::point_y#0
  call print 
  to:main::@1
main::@1: scope:[main]  from main
  (struct Point*) main::ptr#2 ← phi( main/(struct Point*) main::ptr#0 )
  (byte) idx#8 ← phi( main/(byte) idx#6 )
  (byte) idx#1 ← (byte) idx#8
  (byte) print::p_x#1 ← *((byte*) main::$3)
  (byte) print::p_y#1 ← *((byte*) main::$4)
  call print 
  to:main::@2
main::@2: scope:[main]  from main::@1
  (struct Point*) main::ptr#1 ← phi( main::@1/(struct Point*) main::ptr#2 )
  (byte) idx#9 ← phi( main::@1/(byte) idx#6 )
  (byte) idx#2 ← (byte) idx#9
  (byte*) main::$3 ← (byte*)(struct Point*) main::ptr#1 + (const byte) OFFSET_STRUCT_POINT_X
  (byte*) main::$4 ← (byte*)(struct Point*) main::ptr#1 + (const byte) OFFSET_STRUCT_POINT_Y
  to:main::@return
main::@return: scope:[main]  from main::@2
  (byte) idx#10 ← phi( main::@2/(byte) idx#2 )
  (byte) idx#3 ← (byte) idx#10
  return 
  to:@return
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#1 )
  (byte) print::p_x#2 ← phi( main/(byte) print::p_x#0 main::@1/(byte) print::p_x#1 )
  *((byte*) SCREEN#0 + (byte) idx#11) ← (byte) print::p_x#2
  (byte) idx#4 ← ++ (byte) idx#11
  *((byte*) SCREEN#0 + (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 @begin
  (byte) idx#15 ← phi( @begin/(byte) idx#0 )
  call main 
  to:@3
@3: scope:[]  from @2
  (byte) idx#13 ← phi( @2/(byte) idx#3 )
  (byte) idx#7 ← (byte) idx#13
  to:@end
@end: scope:[]  from @3

SYMBOL TABLE SSA
(label) @2
(label) @3
(label) @begin
(label) @end
(const byte) OFFSET_STRUCT_POINT_X = (byte) 0
(const byte) OFFSET_STRUCT_POINT_Y = (byte) 1
(byte) Point::x
(byte) Point::y
(byte*) SCREEN
(byte*) SCREEN#0
(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()
(struct Point*~) main::$0
(byte*) main::$3
(byte*) main::$4
(label) main::@1
(label) main::@2
(label) main::@return
(struct Point) main::point
(struct Point) main::point#0
(byte) main::point_x
(byte) main::point_x#0
(byte) main::point_y
(byte) main::point_y#0
(struct Point*) main::ptr
(struct Point*) main::ptr#0
(struct Point*) main::ptr#1
(struct Point*) main::ptr#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) 0 in (byte) idx#0 ← (number) 0
Adding number conversion cast (unumber) 1 in (byte) main::point_x#0 ← (number) 1
Adding number conversion cast (unumber) 2 in (byte) main::point_y#0 ← (number) 2
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
Inlining cast (byte) idx#0 ← (unumber)(number) 0
Inlining cast (byte) main::point_x#0 ← (unumber)(number) 1
Inlining cast (byte) main::point_y#0 ← (unumber)(number) 2
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 2
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (struct Point*) main::ptr#0 = (struct Point*~) main::$0 (struct Point*) main::ptr#2 (struct Point*) main::ptr#1 
Alias (byte) idx#1 = (byte) idx#8 
Alias (byte) idx#10 = (byte) idx#2 (byte) idx#9 (byte) idx#3 
Alias (byte) idx#12 = (byte) idx#5 (byte) idx#6 
Alias (byte) idx#0 = (byte) idx#15 
Alias (byte) idx#13 = (byte) idx#7 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) idx#14 (byte) idx#0
Identical Phi Values (byte) idx#1 (byte) idx#12
Identical Phi Values (byte) idx#10 (byte) idx#12
Identical Phi Values (byte) idx#13 (byte) idx#10
Successful SSA optimization Pass2IdenticalPhiElimination
Rewriting struct address-of to first member [6] (struct Point*) main::ptr#0 ← (struct Point*)&(byte) main::point_x#0
Successful SSA optimization PassNStructAddressOfRewriting
Constant right-side identified [6] (struct Point*) main::ptr#0 ← (struct Point*)&(byte) main::point_x#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) SCREEN#0 = (byte*) 1024
Constant (const byte) idx#0 = 0
Constant (const struct Point*) main::ptr#0 = (struct Point*)&main::point_x#0
Successful SSA optimization Pass2ConstantIdentification
Constant value identified (byte*)main::ptr#0 in [18] (byte*) main::$3 ← (byte*)(const struct Point*) main::ptr#0 + (const byte) OFFSET_STRUCT_POINT_X
Constant value identified (byte*)main::ptr#0 in [19] (byte*) main::$4 ← (byte*)(const struct Point*) main::ptr#0 + (const byte) OFFSET_STRUCT_POINT_Y
Successful SSA optimization Pass2ConstantValues
Converting *(pointer+n) to pointer[n] [13] (byte) print::p_x#1 ← *((byte*) main::$3)  -- *((byte*)main::ptr#0 + OFFSET_STRUCT_POINT_X)
Converting *(pointer+n) to pointer[n] [14] (byte) print::p_y#1 ← *((byte*) main::$4)  -- *((byte*)main::ptr#0 + OFFSET_STRUCT_POINT_Y)
Successful SSA optimization Pass2InlineDerefIdx
Simplifying expression containing zero (byte*)main::ptr#0 in [13] (byte) print::p_x#1 ← *((byte*)(const struct Point*) main::ptr#0 + (const byte) OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (byte*)main::ptr#0 in [18] (byte*) main::$3 ← (byte*)(const struct Point*) main::ptr#0 + (const byte) OFFSET_STRUCT_POINT_X
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable (struct Point) main::point#0 and assignment [2] (struct Point) main::point#0 ← struct-unwound {(byte) main::point_x#0, (byte) main::point_y#0}
Eliminating unused variable (byte*) main::$3 and assignment [9] (byte*) main::$3 ← (byte*)(const struct Point*) main::ptr#0
Eliminating unused variable (byte*) main::$4 and assignment [10] (byte*) main::$4 ← (byte*)(const struct Point*) main::ptr#0 + (const byte) OFFSET_STRUCT_POINT_Y
Eliminating unused constant (const byte) OFFSET_STRUCT_POINT_X
Successful SSA optimization PassNEliminateUnusedVars
Inlining constant with var siblings (const byte) idx#0
Constant inlined idx#0 = (byte) 0
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *((byte*)main::ptr#0+OFFSET_STRUCT_POINT_Y)
Successful SSA optimization Pass2ConstantAdditionElimination
Adding NOP phi() at start of @begin
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::@2
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to print:11 print:17 

Created 3 initial phi equivalence classes
Coalesced [9] print::p_x#3 ← print::p_x#0
Coalesced [10] print::p_y#3 ← print::p_y#0
Coalesced [14] print::p_x#4 ← print::p_x#1
Coalesced [15] idx#16 ← idx#12
Coalesced [16] print::p_y#4 ← print::p_y#1
Coalesced down to 3 phi equivalence classes
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

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] (byte) main::point_x#0 ← (byte) 1
  [5] (byte) main::point_y#0 ← (byte) 2
  [6] (byte) print::p_x#0 ← (byte) main::point_x#0
  [7] (byte) print::p_y#0 ← (byte) main::point_y#0
  [8] call print 
  to:main::@1
main::@1: scope:[main]  from main
  [9] (byte) print::p_x#1 ← *((byte*)(const struct Point*) main::ptr#0)
  [10] (byte) print::p_y#1 ← *((byte*)(const struct Point*) main::ptr#0+(const byte) OFFSET_STRUCT_POINT_Y)
  [11] call print 
  to:main::@return
main::@return: scope:[main]  from main::@1
  [12] return 
  to:@return
print: scope:[print]  from main main::@1
  [13] (byte) print::p_y#2 ← phi( main/(byte) print::p_y#0 main::@1/(byte) print::p_y#1 )
  [13] (byte) idx#11 ← phi( main/(byte) 0 main::@1/(byte) idx#12 )
  [13] (byte) print::p_x#2 ← phi( main/(byte) print::p_x#0 main::@1/(byte) print::p_x#1 )
  [14] *((const byte*) SCREEN#0 + (byte) idx#11) ← (byte) print::p_x#2
  [15] (byte) idx#4 ← ++ (byte) idx#11
  [16] *((const byte*) SCREEN#0 + (byte) idx#4) ← (byte) print::p_y#2
  [17] (byte) idx#12 ← ++ (byte) idx#4
  to:print::@return
print::@return: scope:[print]  from print
  [18] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte) Point::x
(byte) Point::y
(byte*) SCREEN
(byte) idx
(byte) idx#11 3.0
(byte) idx#12 0.8
(byte) idx#4 3.0
(void()) main()
(struct Point) main::point
(byte) main::point_x
(byte) main::point_x#0 2.0
(byte) main::point_y
(byte) main::point_y#0 2.0
(struct Point*) main::ptr
(void()) print((byte) print::p_x , (byte) print::p_y)
(struct Point) print::p
(byte) print::p_x
(byte) print::p_x#0 2.0
(byte) print::p_x#1 2.0
(byte) print::p_x#2 6.0
(byte) print::p_y
(byte) print::p_y#0 4.0
(byte) print::p_y#1 4.0
(byte) print::p_y#2 2.0

Initial phi equivalence classes
[ print::p_x#2 print::p_x#0 print::p_x#1 ]
[ idx#11 idx#12 ]
[ print::p_y#2 print::p_y#0 print::p_y#1 ]
Added variable idx#4 to zero page equivalence class [ idx#4 ]
Complete equivalence classes
[ print::p_x#2 print::p_x#0 print::p_x#1 ]
[ idx#11 idx#12 ]
[ print::p_y#2 print::p_y#0 print::p_y#1 ]
[ main::point_x#0 ]
[ main::point_y#0 ]
[ idx#4 ]
Allocated zp ZP_BYTE:2 [ print::p_x#2 print::p_x#0 print::p_x#1 ]
Allocated zp ZP_BYTE:3 [ idx#11 idx#12 ]
Allocated zp ZP_BYTE:4 [ print::p_y#2 print::p_y#0 print::p_y#1 ]
Allocated zp ZP_BYTE:5 [ main::point_x#0 ]
Allocated zp ZP_BYTE:6 [ main::point_y#0 ]
Allocated zp ZP_BYTE:7 [ idx#4 ]

INITIAL ASM
Target platform is c64basic
  // File Comments
// Demonstrates problem with passing struct pointer deref as parameter to call
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .const OFFSET_STRUCT_POINT_Y = 1
  .label SCREEN = $400
  .label idx = 7
  .label idx_11 = 3
  .label idx_12 = 3
  // @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 ptr = point_x
    .label point_x = 5
    .label point_y = 6
    // [4] (byte) main::point_x#0 ← (byte) 1 -- vbuz1=vbuc1 
    lda #1
    sta.z point_x
    // [5] (byte) main::point_y#0 ← (byte) 2 -- vbuz1=vbuc1 
    lda #2
    sta.z point_y
    // [6] (byte) print::p_x#0 ← (byte) main::point_x#0 -- vbuz1=vbuz2 
    lda.z point_x
    sta.z print.p_x
    // [7] (byte) print::p_y#0 ← (byte) main::point_y#0 -- vbuz1=vbuz2 
    lda.z point_y
    sta.z print.p_y
    // [8] call print 
    // [13] phi from main to print [phi:main->print]
  print_from_main:
    // [13] phi (byte) print::p_y#2 = (byte) print::p_y#0 [phi:main->print#0] -- register_copy 
    // [13] phi (byte) idx#11 = (byte) 0 [phi:main->print#1] -- vbuz1=vbuc1 
    lda #0
    sta.z idx_11
    // [13] phi (byte) print::p_x#2 = (byte) print::p_x#0 [phi:main->print#2] -- register_copy 
    jsr print
    jmp b1
    // main::@1
  b1:
    // [9] (byte) print::p_x#1 ← *((byte*)(const struct Point*) main::ptr#0) -- vbuz1=_deref_pbuc1 
    lda ptr
    sta.z print.p_x
    // [10] (byte) print::p_y#1 ← *((byte*)(const struct Point*) main::ptr#0+(const byte) OFFSET_STRUCT_POINT_Y) -- vbuz1=_deref_pbuc1 
    lda ptr+OFFSET_STRUCT_POINT_Y
    sta.z print.p_y
    // [11] call print 
    // [13] phi from main::@1 to print [phi:main::@1->print]
  print_from_b1:
    // [13] phi (byte) print::p_y#2 = (byte) print::p_y#1 [phi:main::@1->print#0] -- register_copy 
    // [13] phi (byte) idx#11 = (byte) idx#12 [phi:main::@1->print#1] -- register_copy 
    // [13] phi (byte) print::p_x#2 = (byte) print::p_x#1 [phi:main::@1->print#2] -- register_copy 
    jsr print
    jmp breturn
    // main::@return
  breturn:
    // [12] return 
    rts
}
  // print
// print(byte zeropage(2) p_x, byte zeropage(4) p_y)
print: {
    .label p_x = 2
    .label p_y = 4
    // [14] *((const byte*) SCREEN#0 + (byte) idx#11) ← (byte) print::p_x#2 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda.z p_x
    ldy.z idx_11
    sta SCREEN,y
    // [15] (byte) idx#4 ← ++ (byte) idx#11 -- vbuz1=_inc_vbuz2 
    ldy.z idx_11
    iny
    sty.z idx
    // [16] *((const byte*) SCREEN#0 + (byte) idx#4) ← (byte) print::p_y#2 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda.z p_y
    ldy.z idx
    sta SCREEN,y
    // [17] (byte) idx#12 ← ++ (byte) idx#4 -- vbuz1=_inc_vbuz2 
    ldy.z idx
    iny
    sty.z idx_12
    jmp breturn
    // print::@return
  breturn:
    // [18] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] (byte) main::point_x#0 ← (byte) 1 [ main::point_x#0 ] ( main:2 [ main::point_x#0 ] ) always clobbers reg byte a 
Statement [5] (byte) main::point_y#0 ← (byte) 2 [ main::point_x#0 main::point_y#0 ] ( main:2 [ main::point_x#0 main::point_y#0 ] ) always clobbers reg byte a 
Potential registers zp ZP_BYTE:2 [ print::p_x#2 print::p_x#0 print::p_x#1 ] : zp ZP_BYTE:2 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:3 [ idx#11 idx#12 ] : zp ZP_BYTE:3 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:4 [ print::p_y#2 print::p_y#0 print::p_y#1 ] : zp ZP_BYTE:4 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:5 [ main::point_x#0 ] : zp ZP_BYTE:5 , 
Potential registers zp ZP_BYTE:6 [ main::point_y#0 ] : zp ZP_BYTE:6 , 
Potential registers zp ZP_BYTE:7 [ idx#4 ] : zp ZP_BYTE:7 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [print] 10: zp ZP_BYTE:2 [ print::p_x#2 print::p_x#0 print::p_x#1 ] 10: zp ZP_BYTE:4 [ print::p_y#2 print::p_y#0 print::p_y#1 ] 
Uplift Scope [] 3.8: zp ZP_BYTE:3 [ idx#11 idx#12 ] 3: zp ZP_BYTE:7 [ idx#4 ] 
Uplift Scope [main] 2: zp ZP_BYTE:5 [ main::point_x#0 ] 2: zp ZP_BYTE:6 [ main::point_y#0 ] 
Uplift Scope [Point] 

Uplifting [print] best 110 combination reg byte y [ print::p_x#2 print::p_x#0 print::p_x#1 ] reg byte x [ print::p_y#2 print::p_y#0 print::p_y#1 ] 
Uplifting [] best 101 combination zp ZP_BYTE:3 [ idx#11 idx#12 ] reg byte y [ idx#4 ] 
Uplifting [main] best 101 combination zp ZP_BYTE:5 [ main::point_x#0 ] zp ZP_BYTE:6 [ main::point_y#0 ] 
Uplifting [Point] best 101 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:3 [ idx#11 idx#12 ]
Uplifting [] best 101 combination zp ZP_BYTE:3 [ idx#11 idx#12 ] 
Attempting to uplift remaining variables inzp ZP_BYTE:5 [ main::point_x#0 ]
Uplifting [main] best 101 combination zp ZP_BYTE:5 [ main::point_x#0 ] 
Attempting to uplift remaining variables inzp ZP_BYTE:6 [ main::point_y#0 ]
Uplifting [main] best 101 combination zp ZP_BYTE:6 [ main::point_y#0 ] 
Allocated (was zp ZP_BYTE:3) zp ZP_BYTE:2 [ idx#11 idx#12 ]
Allocated (was zp ZP_BYTE:5) zp ZP_BYTE:3 [ main::point_x#0 ]
Allocated (was zp ZP_BYTE:6) zp ZP_BYTE:4 [ main::point_y#0 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Demonstrates problem with passing struct pointer deref as parameter to call
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .const OFFSET_STRUCT_POINT_Y = 1
  .label SCREEN = $400
  .label idx = 2
  // @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 ptr = point_x
    .label point_x = 3
    .label point_y = 4
    // [4] (byte) main::point_x#0 ← (byte) 1 -- vbuz1=vbuc1 
    lda #1
    sta.z point_x
    // [5] (byte) main::point_y#0 ← (byte) 2 -- vbuz1=vbuc1 
    lda #2
    sta.z point_y
    // [6] (byte) print::p_x#0 ← (byte) main::point_x#0 -- vbuyy=vbuz1 
    ldy.z point_x
    // [7] (byte) print::p_y#0 ← (byte) main::point_y#0 -- vbuxx=vbuz1 
    ldx.z point_y
    // [8] call print 
    // [13] phi from main to print [phi:main->print]
  print_from_main:
    // [13] phi (byte) print::p_y#2 = (byte) print::p_y#0 [phi:main->print#0] -- register_copy 
    // [13] phi (byte) idx#11 = (byte) 0 [phi:main->print#1] -- vbuz1=vbuc1 
    lda #0
    sta.z idx
    // [13] phi (byte) print::p_x#2 = (byte) print::p_x#0 [phi:main->print#2] -- register_copy 
    jsr print
    jmp b1
    // main::@1
  b1:
    // [9] (byte) print::p_x#1 ← *((byte*)(const struct Point*) main::ptr#0) -- vbuyy=_deref_pbuc1 
    ldy ptr
    // [10] (byte) print::p_y#1 ← *((byte*)(const struct Point*) main::ptr#0+(const byte) OFFSET_STRUCT_POINT_Y) -- vbuxx=_deref_pbuc1 
    ldx ptr+OFFSET_STRUCT_POINT_Y
    // [11] call print 
    // [13] phi from main::@1 to print [phi:main::@1->print]
  print_from_b1:
    // [13] phi (byte) print::p_y#2 = (byte) print::p_y#1 [phi:main::@1->print#0] -- register_copy 
    // [13] phi (byte) idx#11 = (byte) idx#12 [phi:main::@1->print#1] -- register_copy 
    // [13] phi (byte) print::p_x#2 = (byte) print::p_x#1 [phi:main::@1->print#2] -- register_copy 
    jsr print
    jmp breturn
    // main::@return
  breturn:
    // [12] return 
    rts
}
  // print
// print(byte register(Y) p_x, byte register(X) p_y)
print: {
    // [14] *((const byte*) SCREEN#0 + (byte) idx#11) ← (byte) print::p_x#2 -- pbuc1_derefidx_vbuz1=vbuyy 
    tya
    ldy.z idx
    sta SCREEN,y
    // [15] (byte) idx#4 ← ++ (byte) idx#11 -- vbuyy=_inc_vbuz1 
    ldy.z idx
    iny
    // [16] *((const byte*) SCREEN#0 + (byte) idx#4) ← (byte) print::p_y#2 -- pbuc1_derefidx_vbuyy=vbuxx 
    txa
    sta SCREEN,y
    // [17] (byte) idx#12 ← ++ (byte) idx#4 -- vbuz1=_inc_vbuyy 
    iny
    sty.z idx
    jmp breturn
    // print::@return
  breturn:
    // [18] 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 instruction ldx.z point_y with TAX
Removing instruction ldy.z idx
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction bend_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction print_from_main:
Removing instruction b1:
Removing instruction print_from_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 bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(const byte) OFFSET_STRUCT_POINT_Y OFFSET_STRUCT_POINT_Y = (byte) 1
(byte) Point::x
(byte) Point::y
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
(byte) idx
(byte) idx#11 idx zp ZP_BYTE:2 3.0
(byte) idx#12 idx zp ZP_BYTE:2 0.8
(byte) idx#4 reg byte y 3.0
(void()) main()
(label) main::@1
(label) main::@return
(struct Point) main::point
(byte) main::point_x
(byte) main::point_x#0 point_x zp ZP_BYTE:3 2.0
(byte) main::point_y
(byte) main::point_y#0 point_y zp ZP_BYTE:4 2.0
(struct Point*) main::ptr
(const struct Point*) main::ptr#0 ptr = (struct Point*)&(byte) main::point_x#0
(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 reg byte y 2.0
(byte) print::p_x#1 reg byte y 2.0
(byte) print::p_x#2 reg byte y 6.0
(byte) print::p_y
(byte) print::p_y#0 reg byte x 4.0
(byte) print::p_y#1 reg byte x 4.0
(byte) print::p_y#2 reg byte x 2.0

reg byte y [ print::p_x#2 print::p_x#0 print::p_x#1 ]
zp ZP_BYTE:2 [ idx#11 idx#12 ]
reg byte x [ print::p_y#2 print::p_y#0 print::p_y#1 ]
zp ZP_BYTE:3 [ main::point_x#0 ]
zp ZP_BYTE:4 [ main::point_y#0 ]
reg byte y [ idx#4 ]


FINAL ASSEMBLER
Score: 76

  // File Comments
// Demonstrates problem with passing struct pointer deref as parameter to call
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .const OFFSET_STRUCT_POINT_Y = 1
  .label SCREEN = $400
  .label idx = 2
  // @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 ptr = point_x
    .label point_x = 3
    .label point_y = 4
    // point = { 1, 2 }
    // [4] (byte) main::point_x#0 ← (byte) 1 -- vbuz1=vbuc1 
    lda #1
    sta.z point_x
    // [5] (byte) main::point_y#0 ← (byte) 2 -- vbuz1=vbuc1 
    lda #2
    sta.z point_y
    // print(point)
    // [6] (byte) print::p_x#0 ← (byte) main::point_x#0 -- vbuyy=vbuz1 
    ldy.z point_x
    // [7] (byte) print::p_y#0 ← (byte) main::point_y#0 -- vbuxx=vbuz1 
    tax
    // [8] call print 
    // [13] phi from main to print [phi:main->print]
    // [13] phi (byte) print::p_y#2 = (byte) print::p_y#0 [phi:main->print#0] -- register_copy 
    // [13] phi (byte) idx#11 = (byte) 0 [phi:main->print#1] -- vbuz1=vbuc1 
    lda #0
    sta.z idx
    // [13] phi (byte) print::p_x#2 = (byte) print::p_x#0 [phi:main->print#2] -- register_copy 
    jsr print
    // main::@1
    // print(*ptr)
    // [9] (byte) print::p_x#1 ← *((byte*)(const struct Point*) main::ptr#0) -- vbuyy=_deref_pbuc1 
    ldy ptr
    // [10] (byte) print::p_y#1 ← *((byte*)(const struct Point*) main::ptr#0+(const byte) OFFSET_STRUCT_POINT_Y) -- vbuxx=_deref_pbuc1 
    ldx ptr+OFFSET_STRUCT_POINT_Y
    // [11] call print 
    // [13] phi from main::@1 to print [phi:main::@1->print]
    // [13] phi (byte) print::p_y#2 = (byte) print::p_y#1 [phi:main::@1->print#0] -- register_copy 
    // [13] phi (byte) idx#11 = (byte) idx#12 [phi:main::@1->print#1] -- register_copy 
    // [13] phi (byte) print::p_x#2 = (byte) print::p_x#1 [phi:main::@1->print#2] -- register_copy 
    jsr print
    // main::@return
    // }
    // [12] return 
    rts
}
  // print
// print(byte register(Y) p_x, byte register(X) p_y)
print: {
    // SCREEN[idx++] = p.x
    // [14] *((const byte*) SCREEN#0 + (byte) idx#11) ← (byte) print::p_x#2 -- pbuc1_derefidx_vbuz1=vbuyy 
    tya
    ldy.z idx
    sta SCREEN,y
    // SCREEN[idx++] = p.x;
    // [15] (byte) idx#4 ← ++ (byte) idx#11 -- vbuyy=_inc_vbuz1 
    iny
    // SCREEN[idx++] = p.y
    // [16] *((const byte*) SCREEN#0 + (byte) idx#4) ← (byte) print::p_y#2 -- pbuc1_derefidx_vbuyy=vbuxx 
    txa
    sta SCREEN,y
    // SCREEN[idx++] = p.y;
    // [17] (byte) idx#12 ← ++ (byte) idx#4 -- vbuz1=_inc_vbuyy 
    iny
    sty.z idx
    // print::@return
    // }
    // [18] return 
    rts
}
  // File Data

