Fixing pointer array-indexing *((const struct Point*) SCREEN + (byte) main::i)
Created struct value member variable (byte~) main::$0_x
Created struct value member variable (byte~) main::$0_y
Converted struct value to member variables (struct Point~) main::$0
Created struct value member variable (byte~) main::$1_x
Created struct value member variable (byte~) main::$1_y
Converted struct value to member variables (struct Point~) main::$1
Created struct value member variable (byte) get::return_x
Created struct value member variable (byte) get::return_y
Converted struct value to member variables (struct Point) get::return
Created struct value member variable (byte) get::p_x
Created struct value member variable (byte) get::p_y
Converted struct value to member variables (struct Point) get::p
Converted procedure call LValue to member unwinding { (byte~) main::$0_x, (byte~) main::$0_y } ← call get (number) 0 
Unwinding value copy *((const struct Point*) SCREEN) ← (struct Point~) main::$0
Adding value simple copy *((byte*)(const struct Point*) SCREEN+(const byte) OFFSET_STRUCT_POINT_X) ← (byte~) main::$0_x
Adding value simple copy *((byte*)(const struct Point*) SCREEN+(const byte) OFFSET_STRUCT_POINT_Y) ← (byte~) main::$0_y
Converted procedure call LValue to member unwinding { (byte~) main::$1_x, (byte~) main::$1_y } ← call get (byte) main::i 
Unwinding value copy *((const struct Point*) SCREEN + (byte~) main::$3) ← (struct Point~) main::$1
Adding value simple copy *((byte*)(const struct Point*) SCREEN+(const byte) OFFSET_STRUCT_POINT_X + (byte~) main::$3) ← (byte~) main::$1_x
Adding value simple copy *((byte*)(const struct Point*) SCREEN+(const byte) OFFSET_STRUCT_POINT_Y + (byte~) main::$3) ← (byte~) main::$1_y
Unwinding value copy (struct Point) get::p ← (struct Point){ (byte) get::i, (byte) 7 }
Adding value simple copy (byte) get::p_x ← (byte) get::i
Adding value simple copy (byte) get::p_y ← (byte) 7
Unwinding value copy (struct Point) get::return ← (struct Point) get::p
Adding value simple copy (byte) get::return_x ← (byte) get::p_x
Adding value simple copy (byte) get::return_y ← (byte) get::p_y
Unwinding value copy (struct Point) get::return ← (struct Point) get::return
Adding value simple copy (byte) get::return_x ← (byte) get::return_x
Adding value simple copy (byte) get::return_y ← (byte) get::return_y
Converted procedure struct return value to member unwinding return { (byte) get::return_x, (byte) get::return_y }
Identified constant variable (byte) idx
Identified constant variable (byte) get::p_y
Culled Empty Block (label) main::@2
Culled Empty Block (label) @1
Culled Empty Block (label) get::@1
Unwinding list assignment { (byte~) main::$0_x, (byte~) main::$0_y } ← { (byte) get::return_x, (byte) get::return_y }
Unwinding list assignment { (byte~) main::$1_x, (byte~) main::$1_y } ← { (byte) get::return_x, (byte) get::return_y }
Unwinding list assignment { (byte) get::return_x#0, (byte) get::return_y#0 } ← { (byte) get::return_x#3, (byte) get::return_y#3 }
Unwinding list assignment { (byte) get::return_x#1, (byte) get::return_y#1 } ← { (byte) get::return_x#3, (byte) get::return_y#3 }

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

(void()) main()
main: scope:[main]  from @2
  (byte) get::i#0 ← (number) 0
  call get 
  (byte) get::return_x#0 ← (byte) get::return_x#3
  (byte) get::return_y#0 ← (byte) get::return_y#3
  to:main::@3
main::@3: scope:[main]  from main
  (byte) get::return_y#4 ← phi( main/(byte) get::return_y#0 )
  (byte) get::return_x#4 ← phi( main/(byte) get::return_x#0 )
  (byte~) main::$0_x ← (byte) get::return_x#4
  (byte~) main::$0_y ← (byte) get::return_y#4
  *((byte*)(const struct Point*) SCREEN+(const byte) OFFSET_STRUCT_POINT_X) ← (byte~) main::$0_x
  *((byte*)(const struct Point*) SCREEN+(const byte) OFFSET_STRUCT_POINT_Y) ← (byte~) main::$0_y
  (byte) main::i#0 ← (byte) 1
  to:main::@1
main::@1: scope:[main]  from main::@3 main::@4
  (byte) main::i#2 ← phi( main::@3/(byte) main::i#0 main::@4/(byte) main::i#1 )
  (byte) get::i#1 ← (byte) main::i#2
  call get 
  (byte) get::return_x#1 ← (byte) get::return_x#3
  (byte) get::return_y#1 ← (byte) get::return_y#3
  to:main::@4
main::@4: scope:[main]  from main::@1
  (byte) main::i#3 ← phi( main::@1/(byte) main::i#2 )
  (byte) get::return_y#5 ← phi( main::@1/(byte) get::return_y#1 )
  (byte) get::return_x#5 ← phi( main::@1/(byte) get::return_x#1 )
  (byte~) main::$1_x ← (byte) get::return_x#5
  (byte~) main::$1_y ← (byte) get::return_y#5
  (byte~) main::$3 ← (byte) main::i#3 * (const byte) SIZEOF_STRUCT_POINT
  *((byte*)(const struct Point*) SCREEN+(const byte) OFFSET_STRUCT_POINT_X + (byte~) main::$3) ← (byte~) main::$1_x
  *((byte*)(const struct Point*) SCREEN+(const byte) OFFSET_STRUCT_POINT_Y + (byte~) main::$3) ← (byte~) main::$1_y
  (byte) main::i#1 ← (byte) main::i#3 + rangenext(1,2)
  (bool~) main::$2 ← (byte) main::i#1 != rangelast(1,2)
  if((bool~) main::$2) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@4
  return 
  to:@return

(struct Point()) get((byte) get::i)
get: scope:[get]  from main main::@1
  (byte) get::i#2 ← phi( main/(byte) get::i#0 main::@1/(byte) get::i#1 )
  (byte) get::p_x#0 ← (byte) get::i#2
  (byte) get::return_x#2 ← (byte) get::p_x#0
  (byte) get::return_y#2 ← (const byte) get::p_y
  (struct Point) get::return#0 ← struct-unwound {(byte) get::return_x#2, (byte) get::return_y#2}
  to:get::@return
get::@return: scope:[get]  from get
  (byte) get::return_y#6 ← phi( get/(byte) get::return_y#2 )
  (byte) get::return_x#6 ← phi( get/(byte) get::return_x#2 )
  (byte) get::return_x#3 ← (byte) get::return_x#6
  (byte) get::return_y#3 ← (byte) get::return_y#6
  (struct Point) get::return#1 ← struct-unwound {(byte) get::return_x#3, (byte) get::return_y#3}
  return 
  to:@return
@2: scope:[]  from @begin
  call main 
  to:@3
@3: scope:[]  from @2
  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
(const struct Point*) SCREEN = (struct Point*)(number) $400
(const byte) SIZEOF_STRUCT_POINT = (byte) 2
(struct Point()) get((byte) get::i)
(label) get::@return
(byte) get::i
(byte) get::i#0
(byte) get::i#1
(byte) get::i#2
(byte) get::p_x
(byte) get::p_x#0
(const byte) get::p_y = (byte) 7
(struct Point) get::return
(struct Point) get::return#0
(struct Point) get::return#1
(byte) get::return_x
(byte) get::return_x#0
(byte) get::return_x#1
(byte) get::return_x#2
(byte) get::return_x#3
(byte) get::return_x#4
(byte) get::return_x#5
(byte) get::return_x#6
(byte) get::return_y
(byte) get::return_y#0
(byte) get::return_y#1
(byte) get::return_y#2
(byte) get::return_y#3
(byte) get::return_y#4
(byte) get::return_y#5
(byte) get::return_y#6
(void()) main()
(struct Point~) main::$0
(byte~) main::$0_x
(byte~) main::$0_y
(struct Point~) main::$1
(byte~) main::$1_x
(byte~) main::$1_y
(bool~) main::$2
(byte~) main::$3
(label) main::@1
(label) main::@3
(label) main::@4
(label) main::@return
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(byte) main::i#3

Adding number conversion cast (unumber) 0 in (byte) get::i#0 ← (number) 0
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte) get::i#0 ← (unumber)(number) 0
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (struct Point*) 1024
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte) get::return_x#0 = (byte) get::return_x#4 
Alias (byte) get::return_y#0 = (byte) get::return_y#4 
Alias (byte) get::return_x#1 = (byte) get::return_x#5 
Alias (byte) get::return_y#1 = (byte) get::return_y#5 
Alias (byte) main::i#2 = (byte) main::i#3 
Alias (byte) get::return_x#2 = (byte) get::p_x#0 (byte) get::i#2 (byte) get::return_x#6 (byte) get::return_x#3 
Alias (byte) get::return_y#2 = (byte) get::return_y#6 (byte) get::return_y#3 
Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) main::$2 [23] if((byte) main::i#1!=rangelast(1,2)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) get::i#0 = 0
Constant (const byte) main::i#0 = 1
Constant (const byte) get::return_y#2 = get::p_y
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte) get::return_y#0 = get::return_y#2
Constant (const byte) get::return_y#1 = get::return_y#2
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte) main::$0_y = get::return_y#0
Constant (const byte) main::$1_y = get::return_y#1
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [21] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [23] if(main::i#1!=rangelast(1,2)) goto main::@1 to (number) 3
Simplifying expression containing zero (byte*)SCREEN in [7] *((byte*)(const struct Point*) SCREEN+(const byte) OFFSET_STRUCT_POINT_X) ← (byte~) main::$0_x
Simplifying expression containing zero (byte*)SCREEN in [19] *((byte*)(const struct Point*) SCREEN+(const byte) OFFSET_STRUCT_POINT_X + (byte~) main::$3) ← (byte~) main::$1_x
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable (struct Point) get::return#0 and assignment [17] (struct Point) get::return#0 ← struct-unwound {(byte) get::return_x#2, (const byte) get::return_y#2}
Eliminating unused variable (struct Point) get::return#1 and assignment [18] (struct Point) get::return#1 ← struct-unwound {(byte) get::return_x#2, (const byte) get::return_y#2}
Eliminating unused constant (const byte) OFFSET_STRUCT_POINT_X
Successful SSA optimization PassNEliminateUnusedVars
Adding number conversion cast (unumber) 3 in if((byte) main::i#1!=(number) 3) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 3
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 3
Successful SSA optimization PassNFinalizeNumberTypeConversions
Rewriting multiplication to use shift [10] (byte~) main::$3 ← (byte) main::i#2 * (const byte) SIZEOF_STRUCT_POINT
Successful SSA optimization Pass2MultiplyToShiftRewriting
Inlining constant with var siblings (const byte) main::i#0
Inlining constant with var siblings (const byte) get::i#0
Constant inlined main::$1_y = (const byte) get::p_y
Constant inlined main::$0_y = (const byte) get::p_y
Constant inlined main::i#0 = (byte) 1
Constant inlined get::return_y#0 = (const byte) get::p_y
Constant inlined get::i#0 = (byte) 0
Constant inlined get::return_y#1 = (const byte) get::p_y
Constant inlined get::return_y#2 = (const byte) get::p_y
Successful SSA optimization Pass2ConstantInlining
Eliminating unused constant (const byte) SIZEOF_STRUCT_POINT
Successful SSA optimization PassNEliminateUnusedVars
Added new block during phi lifting main::@5(between main::@4 and main::@1)
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
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to get:6 get:14 

Created 2 initial phi equivalence classes
Coalesced [13] get::return_x#7 ← get::i#1
Coalesced [23] main::i#4 ← main::i#1
Coalesced down to 2 phi equivalence classes
Culled Empty Block (label) @3
Culled Empty Block (label) main::@5
Renumbering block @2 to @1
Renumbering block main::@3 to main::@2
Renumbering block main::@4 to main::@3
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

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 get 
  [6] (byte) get::return_x#0 ← (byte) get::return_x#2
  to:main::@2
main::@2: scope:[main]  from main
  [7] (byte~) main::$0_x ← (byte) get::return_x#0
  [8] *((byte*)(const struct Point*) SCREEN) ← (byte~) main::$0_x
  [9] *((byte*)(const struct Point*) SCREEN+(const byte) OFFSET_STRUCT_POINT_Y) ← (const byte) get::p_y
  to:main::@1
main::@1: scope:[main]  from main::@2 main::@3
  [10] (byte) main::i#2 ← phi( main::@2/(byte) 1 main::@3/(byte) main::i#1 )
  [11] (byte) get::i#1 ← (byte) main::i#2
  [12] call get 
  [13] (byte) get::return_x#1 ← (byte) get::return_x#2
  to:main::@3
main::@3: scope:[main]  from main::@1
  [14] (byte~) main::$1_x ← (byte) get::return_x#1
  [15] (byte~) main::$3 ← (byte) main::i#2 << (byte) 1
  [16] *((byte*)(const struct Point*) SCREEN + (byte~) main::$3) ← (byte~) main::$1_x
  [17] *((byte*)(const struct Point*) SCREEN+(const byte) OFFSET_STRUCT_POINT_Y + (byte~) main::$3) ← (const byte) get::p_y
  [18] (byte) main::i#1 ← ++ (byte) main::i#2
  [19] if((byte) main::i#1!=(byte) 3) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@3
  [20] return 
  to:@return

(struct Point()) get((byte) get::i)
get: scope:[get]  from main main::@1
  [21] (byte) get::return_x#2 ← phi( main/(byte) 0 main::@1/(byte) get::i#1 )
  to:get::@return
get::@return: scope:[get]  from get
  [22] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte) Point::x
(byte) Point::y
(struct Point()) get((byte) get::i)
(byte) get::i
(byte) get::i#1 22.0
(byte) get::p_x
(struct Point) get::return
(byte) get::return_x
(byte) get::return_x#0 4.0
(byte) get::return_x#1 22.0
(byte) get::return_x#2 6.0
(byte) get::return_y
(void()) main()
(struct Point~) main::$0
(byte~) main::$0_x 4.0
(struct Point~) main::$1
(byte~) main::$1_x 11.0
(byte~) main::$3 16.5
(byte) main::i
(byte) main::i#1 16.5
(byte) main::i#2 5.5

Initial phi equivalence classes
[ main::i#2 main::i#1 ]
[ get::return_x#2 get::i#1 ]
Added variable get::return_x#0 to live range equivalence class [ get::return_x#0 ]
Added variable main::$0_x to live range equivalence class [ main::$0_x ]
Added variable get::return_x#1 to live range equivalence class [ get::return_x#1 ]
Added variable main::$1_x to live range equivalence class [ main::$1_x ]
Added variable main::$3 to live range equivalence class [ main::$3 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ get::return_x#2 get::i#1 ]
[ get::return_x#0 ]
[ main::$0_x ]
[ get::return_x#1 ]
[ main::$1_x ]
[ main::$3 ]
Allocated zp[1]:2 [ main::i#2 main::i#1 ]
Allocated zp[1]:3 [ get::return_x#2 get::i#1 ]
Allocated zp[1]:4 [ get::return_x#0 ]
Allocated zp[1]:5 [ main::$0_x ]
Allocated zp[1]:6 [ get::return_x#1 ]
Allocated zp[1]:7 [ main::$1_x ]
Allocated zp[1]:8 [ main::$3 ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// Demonstrates problem with returning a struct into a dereferenced pointer to a struct
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  .const OFFSET_STRUCT_POINT_Y = 1
  // @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 __3 = 8
    .label __0_x = 5
    .label __1_x = 7
    .label i = 2
    // [5] call get 
    // [21] phi from main to get [phi:main->get]
  get_from_main:
    // [21] phi (byte) get::return_x#2 = (byte) 0 [phi:main->get#0] -- vbuz1=vbuc1 
    lda #0
    sta.z get.return_x_2
    jsr get
    // [6] (byte) get::return_x#0 ← (byte) get::return_x#2 -- vbuz1=vbuz2 
    lda.z get.return_x_2
    sta.z get.return_x
    jmp __b2
    // main::@2
  __b2:
    // [7] (byte~) main::$0_x ← (byte) get::return_x#0 -- vbuz1=vbuz2 
    lda.z get.return_x
    sta.z __0_x
    // [8] *((byte*)(const struct Point*) SCREEN) ← (byte~) main::$0_x -- _deref_pbuc1=vbuz1 
    lda.z __0_x
    sta SCREEN
    // [9] *((byte*)(const struct Point*) SCREEN+(const byte) OFFSET_STRUCT_POINT_Y) ← (const byte) get::p_y -- _deref_pbuc1=vbuc2 
    lda #get.p_y
    sta SCREEN+OFFSET_STRUCT_POINT_Y
    // [10] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  __b1_from___b2:
    // [10] phi (byte) main::i#2 = (byte) 1 [phi:main::@2->main::@1#0] -- vbuz1=vbuc1 
    lda #1
    sta.z i
    jmp __b1
    // [10] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  __b1_from___b3:
    // [10] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy 
    jmp __b1
    // main::@1
  __b1:
    // [11] (byte) get::i#1 ← (byte) main::i#2 -- vbuz1=vbuz2 
    lda.z i
    sta.z get.i
    // [12] call get 
    // [21] phi from main::@1 to get [phi:main::@1->get]
  get_from___b1:
    // [21] phi (byte) get::return_x#2 = (byte) get::i#1 [phi:main::@1->get#0] -- register_copy 
    jsr get
    // [13] (byte) get::return_x#1 ← (byte) get::return_x#2 -- vbuz1=vbuz2 
    lda.z get.return_x_2
    sta.z get.return_x_1
    jmp __b3
    // main::@3
  __b3:
    // [14] (byte~) main::$1_x ← (byte) get::return_x#1 -- vbuz1=vbuz2 
    lda.z get.return_x_1
    sta.z __1_x
    // [15] (byte~) main::$3 ← (byte) main::i#2 << (byte) 1 -- vbuz1=vbuz2_rol_1 
    lda.z i
    asl
    sta.z __3
    // [16] *((byte*)(const struct Point*) SCREEN + (byte~) main::$3) ← (byte~) main::$1_x -- pbuc1_derefidx_vbuz1=vbuz2 
    lda.z __1_x
    ldy.z __3
    sta SCREEN,y
    // [17] *((byte*)(const struct Point*) SCREEN+(const byte) OFFSET_STRUCT_POINT_Y + (byte~) main::$3) ← (const byte) get::p_y -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #get.p_y
    ldy.z __3
    sta SCREEN+OFFSET_STRUCT_POINT_Y,y
    // [18] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 
    inc.z i
    // [19] if((byte) main::i#1!=(byte) 3) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #3
    cmp.z i
    bne __b1_from___b3
    jmp __breturn
    // main::@return
  __breturn:
    // [20] return 
    rts
}
  // get
// get(byte zp(3) i)
get: {
    .label p_y = 7
    .label return_x = 4
    .label i = 3
    .label return_x_1 = 6
    .label return_x_2 = 3
    jmp __breturn
    // get::@return
  __breturn:
    // [22] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [9] *((byte*)(const struct Point*) SCREEN+(const byte) OFFSET_STRUCT_POINT_Y) ← (const byte) get::p_y [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [15] (byte~) main::$3 ← (byte) main::i#2 << (byte) 1 [ main::i#2 main::$1_x main::$3 ] ( main:2 [ main::i#2 main::$1_x main::$3 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::i#2 main::i#1 ]
Removing always clobbered register reg byte a as potential for zp[1]:7 [ main::$1_x ]
Statement [16] *((byte*)(const struct Point*) SCREEN + (byte~) main::$3) ← (byte~) main::$1_x [ main::i#2 main::$3 ] ( main:2 [ main::i#2 main::$3 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:8 [ main::$3 ]
Statement [17] *((byte*)(const struct Point*) SCREEN+(const byte) OFFSET_STRUCT_POINT_Y + (byte~) main::$3) ← (const byte) get::p_y [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a 
Statement [9] *((byte*)(const struct Point*) SCREEN+(const byte) OFFSET_STRUCT_POINT_Y) ← (const byte) get::p_y [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [15] (byte~) main::$3 ← (byte) main::i#2 << (byte) 1 [ main::i#2 main::$1_x main::$3 ] ( main:2 [ main::i#2 main::$1_x main::$3 ] ) always clobbers reg byte a 
Statement [16] *((byte*)(const struct Point*) SCREEN + (byte~) main::$3) ← (byte~) main::$1_x [ main::i#2 main::$3 ] ( main:2 [ main::i#2 main::$3 ] ) always clobbers reg byte a 
Statement [17] *((byte*)(const struct Point*) SCREEN+(const byte) OFFSET_STRUCT_POINT_Y + (byte~) main::$3) ← (const byte) get::p_y [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a 
Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ get::return_x#2 get::i#1 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:4 [ get::return_x#0 ] : zp[1]:4 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:5 [ main::$0_x ] : zp[1]:5 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:6 [ get::return_x#1 ] : zp[1]:6 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:7 [ main::$1_x ] : zp[1]:7 , reg byte x , reg byte y , 
Potential registers zp[1]:8 [ main::$3 ] : zp[1]:8 , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [get] 28: zp[1]:3 [ get::return_x#2 get::i#1 ] 22: zp[1]:6 [ get::return_x#1 ] 4: zp[1]:4 [ get::return_x#0 ] 
Uplift Scope [main] 22: zp[1]:2 [ main::i#2 main::i#1 ] 16.5: zp[1]:8 [ main::$3 ] 11: zp[1]:7 [ main::$1_x ] 4: zp[1]:5 [ main::$0_x ] 
Uplift Scope [Point] 
Uplift Scope [] 

Uplifting [get] best 732 combination reg byte a [ get::return_x#2 get::i#1 ] reg byte a [ get::return_x#1 ] reg byte a [ get::return_x#0 ] 
Uplifting [main] best 546 combination reg byte y [ main::i#2 main::i#1 ] reg byte x [ main::$3 ] zp[1]:7 [ main::$1_x ] reg byte a [ main::$0_x ] 
Limited combination testing to 100 combinations of 108 possible.
Uplifting [Point] best 546 combination 
Uplifting [] best 546 combination 
Attempting to uplift remaining variables inzp[1]:7 [ main::$1_x ]
Uplifting [main] best 546 combination zp[1]:7 [ main::$1_x ] 
Allocated (was zp[1]:7) zp[1]:2 [ main::$1_x ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Demonstrates problem with returning a struct into a dereferenced pointer to a struct
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  .const OFFSET_STRUCT_POINT_Y = 1
  // @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 __1_x = 2
    // [5] call get 
    // [21] phi from main to get [phi:main->get]
  get_from_main:
    // [21] phi (byte) get::return_x#2 = (byte) 0 [phi:main->get#0] -- vbuaa=vbuc1 
    lda #0
    jsr get
    // [6] (byte) get::return_x#0 ← (byte) get::return_x#2
    jmp __b2
    // main::@2
  __b2:
    // [7] (byte~) main::$0_x ← (byte) get::return_x#0
    // [8] *((byte*)(const struct Point*) SCREEN) ← (byte~) main::$0_x -- _deref_pbuc1=vbuaa 
    sta SCREEN
    // [9] *((byte*)(const struct Point*) SCREEN+(const byte) OFFSET_STRUCT_POINT_Y) ← (const byte) get::p_y -- _deref_pbuc1=vbuc2 
    lda #get.p_y
    sta SCREEN+OFFSET_STRUCT_POINT_Y
    // [10] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  __b1_from___b2:
    // [10] phi (byte) main::i#2 = (byte) 1 [phi:main::@2->main::@1#0] -- vbuyy=vbuc1 
    ldy #1
    jmp __b1
    // [10] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  __b1_from___b3:
    // [10] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy 
    jmp __b1
    // main::@1
  __b1:
    // [11] (byte) get::i#1 ← (byte) main::i#2 -- vbuaa=vbuyy 
    tya
    // [12] call get 
    // [21] phi from main::@1 to get [phi:main::@1->get]
  get_from___b1:
    // [21] phi (byte) get::return_x#2 = (byte) get::i#1 [phi:main::@1->get#0] -- register_copy 
    jsr get
    // [13] (byte) get::return_x#1 ← (byte) get::return_x#2
    jmp __b3
    // main::@3
  __b3:
    // [14] (byte~) main::$1_x ← (byte) get::return_x#1 -- vbuz1=vbuaa 
    sta.z __1_x
    // [15] (byte~) main::$3 ← (byte) main::i#2 << (byte) 1 -- vbuxx=vbuyy_rol_1 
    tya
    asl
    tax
    // [16] *((byte*)(const struct Point*) SCREEN + (byte~) main::$3) ← (byte~) main::$1_x -- pbuc1_derefidx_vbuxx=vbuz1 
    lda.z __1_x
    sta SCREEN,x
    // [17] *((byte*)(const struct Point*) SCREEN+(const byte) OFFSET_STRUCT_POINT_Y + (byte~) main::$3) ← (const byte) get::p_y -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #get.p_y
    sta SCREEN+OFFSET_STRUCT_POINT_Y,x
    // [18] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuyy=_inc_vbuyy 
    iny
    // [19] if((byte) main::i#1!=(byte) 3) goto main::@1 -- vbuyy_neq_vbuc1_then_la1 
    cpy #3
    bne __b1_from___b3
    jmp __breturn
    // main::@return
  __breturn:
    // [20] return 
    rts
}
  // get
// get(byte register(A) i)
get: {
    .label p_y = 7
    jmp __breturn
    // get::@return
  __breturn:
    // [22] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b2
Removing instruction jmp __b1
Removing instruction jmp __b3
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __bbegin with __b1
Replacing label __b1_from___b3 with __b1
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Removing instruction __b1_from___b3:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction get_from_main:
Removing instruction __b2:
Removing instruction __b1_from___b2:
Removing instruction get_from___b1:
Removing instruction __b3:
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 jmp __b1
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(const byte) OFFSET_STRUCT_POINT_Y = (byte) 1
(byte) Point::x
(byte) Point::y
(const struct Point*) SCREEN = (struct Point*) 1024
(struct Point()) get((byte) get::i)
(label) get::@return
(byte) get::i
(byte) get::i#1 reg byte a 22.0
(byte) get::p_x
(const byte) get::p_y = (byte) 7
(struct Point) get::return
(byte) get::return_x
(byte) get::return_x#0 reg byte a 4.0
(byte) get::return_x#1 reg byte a 22.0
(byte) get::return_x#2 reg byte a 6.0
(byte) get::return_y
(void()) main()
(struct Point~) main::$0
(byte~) main::$0_x reg byte a 4.0
(struct Point~) main::$1
(byte~) main::$1_x zp[1]:2 11.0
(byte~) main::$3 reg byte x 16.5
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte) main::i
(byte) main::i#1 reg byte y 16.5
(byte) main::i#2 reg byte y 5.5

reg byte y [ main::i#2 main::i#1 ]
reg byte a [ get::return_x#2 get::i#1 ]
reg byte a [ get::return_x#0 ]
reg byte a [ main::$0_x ]
reg byte a [ get::return_x#1 ]
zp[1]:2 [ main::$1_x ]
reg byte x [ main::$3 ]


FINAL ASSEMBLER
Score: 381

  // File Comments
// Demonstrates problem with returning a struct into a dereferenced pointer to a struct
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  .const OFFSET_STRUCT_POINT_Y = 1
  // @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 __1_x = 2
    // get(0)
    // [5] call get 
    // [21] phi from main to get [phi:main->get]
    // [21] phi (byte) get::return_x#2 = (byte) 0 [phi:main->get#0] -- vbuaa=vbuc1 
    lda #0
    jsr get
    // get(0)
    // [6] (byte) get::return_x#0 ← (byte) get::return_x#2
    // main::@2
    // [7] (byte~) main::$0_x ← (byte) get::return_x#0
    // *SCREEN = get(0)
    // [8] *((byte*)(const struct Point*) SCREEN) ← (byte~) main::$0_x -- _deref_pbuc1=vbuaa 
    sta SCREEN
    // [9] *((byte*)(const struct Point*) SCREEN+(const byte) OFFSET_STRUCT_POINT_Y) ← (const byte) get::p_y -- _deref_pbuc1=vbuc2 
    lda #get.p_y
    sta SCREEN+OFFSET_STRUCT_POINT_Y
    // [10] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
    // [10] phi (byte) main::i#2 = (byte) 1 [phi:main::@2->main::@1#0] -- vbuyy=vbuc1 
    ldy #1
    // [10] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
    // [10] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy 
    // main::@1
  __b1:
    // get(i)
    // [11] (byte) get::i#1 ← (byte) main::i#2 -- vbuaa=vbuyy 
    tya
    // [12] call get 
    // [21] phi from main::@1 to get [phi:main::@1->get]
    // [21] phi (byte) get::return_x#2 = (byte) get::i#1 [phi:main::@1->get#0] -- register_copy 
    jsr get
    // get(i)
    // [13] (byte) get::return_x#1 ← (byte) get::return_x#2
    // main::@3
    // [14] (byte~) main::$1_x ← (byte) get::return_x#1 -- vbuz1=vbuaa 
    sta.z __1_x
    // SCREEN[i] = get(i)
    // [15] (byte~) main::$3 ← (byte) main::i#2 << (byte) 1 -- vbuxx=vbuyy_rol_1 
    tya
    asl
    tax
    // [16] *((byte*)(const struct Point*) SCREEN + (byte~) main::$3) ← (byte~) main::$1_x -- pbuc1_derefidx_vbuxx=vbuz1 
    lda.z __1_x
    sta SCREEN,x
    // [17] *((byte*)(const struct Point*) SCREEN+(const byte) OFFSET_STRUCT_POINT_Y + (byte~) main::$3) ← (const byte) get::p_y -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #get.p_y
    sta SCREEN+OFFSET_STRUCT_POINT_Y,x
    // for ( char i: 1..2)
    // [18] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuyy=_inc_vbuyy 
    iny
    // [19] if((byte) main::i#1!=(byte) 3) goto main::@1 -- vbuyy_neq_vbuc1_then_la1 
    cpy #3
    bne __b1
    // main::@return
    // }
    // [20] return 
    rts
}
  // get
// get(byte register(A) i)
get: {
    .label p_y = 7
    // get::@return
    // [22] return 
    rts
}
  // File Data

