Fixing pointer increment (struct Point*) main::points ← ++ (struct Point*) main::points
Fixing pointer increment (struct Point*) main::points ← ++ (struct Point*) main::points
Replacing struct member reference *((struct Point*) main::points).x with member unwinding reference *((byte*~) main::$3)
Replacing struct member reference *((struct Point*) main::points).y with member unwinding reference *((byte*~) main::$4)
Replacing struct member reference *((struct Point*) main::points).x with member unwinding reference *((byte*~) main::$5)
Replacing struct member reference *((struct Point*) main::points).y with member unwinding reference *((byte*~) main::$6)
Identified constant variable (struct Point*) POINTS
Culled Empty Block (label) main::@4

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

(void()) main()
main: scope:[main]  from @1
  (struct Point*) main::points#0 ← (const struct Point*) POINTS
  (byte) main::i#0 ← (byte) 0
  to:main::@1
main::@1: scope:[main]  from main main::@1
  (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
  (struct Point*) main::points#4 ← phi( main/(struct Point*) main::points#0 main::@1/(struct Point*) main::points#1 )
  (byte*~) main::$3 ← (byte*)(struct Point*) main::points#4 + (const byte) OFFSET_STRUCT_POINT_X
  *((byte*~) main::$3) ← (byte) main::i#2
  (number~) main::$0 ← (byte) main::i#2 + (number) 5
  (byte*~) main::$4 ← (byte*)(struct Point*) main::points#4 + (const byte) OFFSET_STRUCT_POINT_Y
  *((byte*~) main::$4) ← (number~) main::$0
  (struct Point*) main::points#1 ← (struct Point*) main::points#4 + (const byte) SIZEOF_STRUCT_POINT
  (byte) main::i#1 ← (byte) main::i#2 + rangenext(0,3)
  (bool~) main::$1 ← (byte) main::i#1 != rangelast(0,3)
  if((bool~) main::$1) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1
  (byte) main::idx#0 ← (byte) 0
  (struct Point*) main::points#2 ← (const struct Point*) POINTS
  (byte) main::i1#0 ← (byte) 0
  to:main::@3
main::@3: scope:[main]  from main::@2 main::@3
  (byte) main::i1#2 ← phi( main::@2/(byte) main::i1#0 main::@3/(byte) main::i1#1 )
  (byte) main::idx#4 ← phi( main::@2/(byte) main::idx#0 main::@3/(byte) main::idx#3 )
  (struct Point*) main::points#5 ← phi( main::@2/(struct Point*) main::points#2 main::@3/(struct Point*) main::points#3 )
  (byte*~) main::$5 ← (byte*)(struct Point*) main::points#5 + (const byte) OFFSET_STRUCT_POINT_X
  *((const byte*) main::SCREEN + (byte) main::idx#4) ← *((byte*~) main::$5)
  (byte) main::idx#1 ← ++ (byte) main::idx#4
  (byte*~) main::$6 ← (byte*)(struct Point*) main::points#5 + (const byte) OFFSET_STRUCT_POINT_Y
  *((const byte*) main::SCREEN + (byte) main::idx#1) ← *((byte*~) main::$6)
  (byte) main::idx#2 ← ++ (byte) main::idx#1
  *((const byte*) main::SCREEN + (byte) main::idx#2) ← (byte) ' '
  (byte) main::idx#3 ← ++ (byte) main::idx#2
  (struct Point*) main::points#3 ← (struct Point*) main::points#5 + (const byte) SIZEOF_STRUCT_POINT
  (byte) main::i1#1 ← (byte) main::i1#2 + rangenext(0,3)
  (bool~) main::$2 ← (byte) main::i1#1 != rangelast(0,3)
  if((bool~) main::$2) goto main::@3
  to:main::@return
main::@return: scope:[main]  from main::@3
  return 
  to:@return
@1: scope:[]  from @begin
  call main 
  to:@2
@2: scope:[]  from @1
  to:@end
@end: scope:[]  from @2

SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(const byte) OFFSET_STRUCT_POINT_X = (byte) 0
(const byte) OFFSET_STRUCT_POINT_Y = (byte) 1
(const struct Point*) POINTS = (struct Point*)(number) $1000
(byte) Point::x
(byte) Point::y
(const byte) SIZEOF_STRUCT_POINT = (byte) 2
(void()) main()
(number~) main::$0
(bool~) main::$1
(bool~) main::$2
(byte*~) main::$3
(byte*~) main::$4
(byte*~) main::$5
(byte*~) main::$6
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(const byte*) main::SCREEN = (byte*)(number) $400
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(byte) main::i1
(byte) main::i1#0
(byte) main::i1#1
(byte) main::i1#2
(byte) main::idx
(byte) main::idx#0
(byte) main::idx#1
(byte) main::idx#2
(byte) main::idx#3
(byte) main::idx#4
(struct Point*) main::points
(struct Point*) main::points#0
(struct Point*) main::points#1
(struct Point*) main::points#2
(struct Point*) main::points#3
(struct Point*) main::points#4
(struct Point*) main::points#5

Adding number conversion cast (unumber) 5 in (number~) main::$0 ← (byte) main::i#2 + (number) 5
Adding number conversion cast (unumber) main::$0 in (number~) main::$0 ← (byte) main::i#2 + (unumber)(number) 5
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (struct Point*) 4096
Simplifying constant integer cast 5
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 5
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) main::$0 ← (byte) main::i#2 + (byte) 5
Simple Condition (bool~) main::$1 [11] if((byte) main::i#1!=rangelast(0,3)) goto main::@1
Simple Condition (bool~) main::$2 [27] if((byte) main::i1#1!=rangelast(0,3)) goto main::@3
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const struct Point*) main::points#0 = POINTS
Constant (const byte) main::i#0 = 0
Constant (const byte) main::idx#0 = 0
Constant (const struct Point*) main::points#2 = POINTS
Constant (const byte) main::i1#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [9] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [11] if(main::i#1!=rangelast(0,3)) goto main::@1 to (number) 4
Resolved ranged next value [25] main::i1#1 ← ++ main::i1#2 to ++
Resolved ranged comparison value [27] if(main::i1#1!=rangelast(0,3)) goto main::@3 to (number) 4
Converting *(pointer+n) to pointer[n] [4] *((byte*~) main::$3) ← (byte) main::i#2  -- *((byte*)main::points#4 + OFFSET_STRUCT_POINT_X)
Converting *(pointer+n) to pointer[n] [7] *((byte*~) main::$4) ← (byte~) main::$0  -- *((byte*)main::points#4 + OFFSET_STRUCT_POINT_Y)
Converting *(pointer+n) to pointer[n] [17] *((const byte*) main::SCREEN + (byte) main::idx#4) ← *((byte*~) main::$5)  -- *((byte*)main::points#5 + OFFSET_STRUCT_POINT_X)
Converting *(pointer+n) to pointer[n] [20] *((const byte*) main::SCREEN + (byte) main::idx#1) ← *((byte*~) main::$6)  -- *((byte*)main::points#5 + OFFSET_STRUCT_POINT_Y)
Successful SSA optimization Pass2InlineDerefIdx
Simplifying expression containing zero (byte*)main::points#4 in [3] (byte*~) main::$3 ← (byte*)(struct Point*) main::points#4 + (const byte) OFFSET_STRUCT_POINT_X
Simplifying expression containing zero (byte*)main::points#4 in [4] *((byte*)(struct Point*) main::points#4 + (const byte) OFFSET_STRUCT_POINT_X) ← (byte) main::i#2
Simplifying expression containing zero (byte*)main::points#5 in [16] (byte*~) main::$5 ← (byte*)(struct Point*) main::points#5 + (const byte) OFFSET_STRUCT_POINT_X
Simplifying expression containing zero (byte*)main::points#5 in [17] *((const byte*) main::SCREEN + (byte) main::idx#4) ← *((byte*)(struct Point*) main::points#5 + (const byte) OFFSET_STRUCT_POINT_X)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable (byte*~) main::$3 and assignment [1] (byte*~) main::$3 ← (byte*)(struct Point*) main::points#4
Eliminating unused variable (byte*~) main::$4 and assignment [4] (byte*~) main::$4 ← (byte*)(struct Point*) main::points#4 + (const byte) OFFSET_STRUCT_POINT_Y
Eliminating unused variable (byte*~) main::$5 and assignment [10] (byte*~) main::$5 ← (byte*)(struct Point*) main::points#5
Eliminating unused variable (byte*~) main::$6 and assignment [13] (byte*~) main::$6 ← (byte*)(struct Point*) main::points#5 + (const byte) OFFSET_STRUCT_POINT_Y
Eliminating unused constant (const byte) OFFSET_STRUCT_POINT_X
Successful SSA optimization PassNEliminateUnusedVars
Adding number conversion cast (unumber) 4 in if((byte) main::i#1!=(number) 4) goto main::@1
Adding number conversion cast (unumber) 4 in if((byte) main::i1#1!=(number) 4) goto main::@3
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 4
Simplifying constant integer cast 4
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 4
Finalized unsigned number type (byte) 4
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inlining constant with var siblings (const struct Point*) main::points#0
Inlining constant with var siblings (const byte) main::i#0
Inlining constant with var siblings (const byte) main::idx#0
Inlining constant with var siblings (const struct Point*) main::points#2
Inlining constant with var siblings (const byte) main::i1#0
Constant inlined main::points#2 = (const struct Point*) POINTS
Constant inlined main::i#0 = (byte) 0
Constant inlined main::i1#0 = (byte) 0
Constant inlined main::idx#0 = (byte) 0
Constant inlined main::points#0 = (const struct Point*) POINTS
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@5(between main::@1 and main::@1)
Added new block during phi lifting main::@6(between main::@3 and main::@3)
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@2
CALL GRAPH
Calls in [] to main:2 

Created 5 initial phi equivalence classes
Coalesced [25] main::points#7 ← main::points#3
Coalesced [26] main::idx#5 ← main::idx#3
Coalesced [27] main::i1#3 ← main::i1#1
Coalesced [28] main::points#6 ← main::points#1
Coalesced [29] main::i#3 ← main::i#1
Coalesced down to 5 phi equivalence classes
Culled Empty Block (label) @2
Culled Empty Block (label) main::@2
Culled Empty Block (label) main::@6
Culled Empty Block (label) main::@5
Renumbering block main::@3 to main::@2
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()
  to:main::@1
main::@1: scope:[main]  from main main::@1
  [5] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
  [5] (struct Point*) main::points#4 ← phi( main/(const struct Point*) POINTS main::@1/(struct Point*) main::points#1 )
  [6] *((byte*)(struct Point*) main::points#4) ← (byte) main::i#2
  [7] (byte~) main::$0 ← (byte) main::i#2 + (byte) 5
  [8] *((byte*)(struct Point*) main::points#4 + (const byte) OFFSET_STRUCT_POINT_Y) ← (byte~) main::$0
  [9] (struct Point*) main::points#1 ← (struct Point*) main::points#4 + (const byte) SIZEOF_STRUCT_POINT
  [10] (byte) main::i#1 ← ++ (byte) main::i#2
  [11] if((byte) main::i#1!=(byte) 4) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@2
  [12] (byte) main::i1#2 ← phi( main::@1/(byte) 0 main::@2/(byte) main::i1#1 )
  [12] (byte) main::idx#4 ← phi( main::@1/(byte) 0 main::@2/(byte) main::idx#3 )
  [12] (struct Point*) main::points#5 ← phi( main::@1/(const struct Point*) POINTS main::@2/(struct Point*) main::points#3 )
  [13] *((const byte*) main::SCREEN + (byte) main::idx#4) ← *((byte*)(struct Point*) main::points#5)
  [14] (byte) main::idx#1 ← ++ (byte) main::idx#4
  [15] *((const byte*) main::SCREEN + (byte) main::idx#1) ← *((byte*)(struct Point*) main::points#5 + (const byte) OFFSET_STRUCT_POINT_Y)
  [16] (byte) main::idx#2 ← ++ (byte) main::idx#1
  [17] *((const byte*) main::SCREEN + (byte) main::idx#2) ← (byte) ' '
  [18] (byte) main::idx#3 ← ++ (byte) main::idx#2
  [19] (struct Point*) main::points#3 ← (struct Point*) main::points#5 + (const byte) SIZEOF_STRUCT_POINT
  [20] (byte) main::i1#1 ← ++ (byte) main::i1#2
  [21] if((byte) main::i1#1!=(byte) 4) goto main::@2
  to:main::@return
main::@return: scope:[main]  from main::@2
  [22] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte) Point::x
(byte) Point::y
(void()) main()
(byte~) main::$0 22.0
(byte) main::i
(byte) main::i#1 16.5
(byte) main::i#2 8.8
(byte) main::i1
(byte) main::i1#1 16.5
(byte) main::i1#2 2.75
(byte) main::idx
(byte) main::idx#1 16.5
(byte) main::idx#2 16.5
(byte) main::idx#3 5.5
(byte) main::idx#4 16.5
(struct Point*) main::points
(struct Point*) main::points#1 7.333333333333333
(struct Point*) main::points#3 7.333333333333333
(struct Point*) main::points#4 5.5
(struct Point*) main::points#5 3.142857142857143

Initial phi equivalence classes
[ main::points#4 main::points#1 ]
[ main::i#2 main::i#1 ]
[ main::points#5 main::points#3 ]
[ main::idx#4 main::idx#3 ]
[ main::i1#2 main::i1#1 ]
Added variable main::$0 to live range equivalence class [ main::$0 ]
Added variable main::idx#1 to live range equivalence class [ main::idx#1 ]
Added variable main::idx#2 to live range equivalence class [ main::idx#2 ]
Complete equivalence classes
[ main::points#4 main::points#1 ]
[ main::i#2 main::i#1 ]
[ main::points#5 main::points#3 ]
[ main::idx#4 main::idx#3 ]
[ main::i1#2 main::i1#1 ]
[ main::$0 ]
[ main::idx#1 ]
[ main::idx#2 ]
Allocated zp[2]:2 [ main::points#4 main::points#1 ]
Allocated zp[1]:4 [ main::i#2 main::i#1 ]
Allocated zp[2]:5 [ main::points#5 main::points#3 ]
Allocated zp[1]:7 [ main::idx#4 main::idx#3 ]
Allocated zp[1]:8 [ main::i1#2 main::i1#1 ]
Allocated zp[1]:9 [ main::$0 ]
Allocated zp[1]:10 [ main::idx#1 ]
Allocated zp[1]:11 [ main::idx#2 ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// Minimal struct - accessing pointer to struct  in memory in a loop
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .const SIZEOF_STRUCT_POINT = 2
  .const OFFSET_STRUCT_POINT_Y = 1
  .label POINTS = $1000
  // @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: {
    // Print points
    .label SCREEN = $400
    .label __0 = 9
    // Fill points
    .label points = 2
    .label i = 4
    .label idx = $a
    .label idx_1 = $b
    .label idx_2 = 7
    // Fill points
    .label points_1 = 5
    .label i1 = 8
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z i
    // [5] phi (struct Point*) main::points#4 = (const struct Point*) POINTS [phi:main->main::@1#1] -- pssz1=pssc1 
    lda #<POINTS
    sta.z points
    lda #>POINTS
    sta.z points+1
    jmp __b1
    // [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  __b1_from___b1:
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    // [5] phi (struct Point*) main::points#4 = (struct Point*) main::points#1 [phi:main::@1->main::@1#1] -- register_copy 
    jmp __b1
    // main::@1
  __b1:
    // [6] *((byte*)(struct Point*) main::points#4) ← (byte) main::i#2 -- _deref_pbuz1=vbuz2 
    lda.z i
    ldy #0
    sta (points),y
    // [7] (byte~) main::$0 ← (byte) main::i#2 + (byte) 5 -- vbuz1=vbuz2_plus_vbuc1 
    lax.z i
    axs #-[5]
    stx.z __0
    // [8] *((byte*)(struct Point*) main::points#4 + (const byte) OFFSET_STRUCT_POINT_Y) ← (byte~) main::$0 -- pbuz1_derefidx_vbuc1=vbuz2 
    lda.z __0
    ldy #OFFSET_STRUCT_POINT_Y
    sta (points),y
    // [9] (struct Point*) main::points#1 ← (struct Point*) main::points#4 + (const byte) SIZEOF_STRUCT_POINT -- pssz1=pssz1_plus_vbuc1 
    lda #SIZEOF_STRUCT_POINT
    clc
    adc.z points
    sta.z points
    bcc !+
    inc.z points+1
  !:
    // [10] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 
    inc.z i
    // [11] if((byte) main::i#1!=(byte) 4) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #4
    cmp.z i
    bne __b1_from___b1
    // [12] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  __b2_from___b1:
    // [12] phi (byte) main::i1#2 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuz1=vbuc1 
    lda #0
    sta.z i1
    // [12] phi (byte) main::idx#4 = (byte) 0 [phi:main::@1->main::@2#1] -- vbuz1=vbuc1 
    lda #0
    sta.z idx_2
    // [12] phi (struct Point*) main::points#5 = (const struct Point*) POINTS [phi:main::@1->main::@2#2] -- pssz1=pssc1 
    lda #<POINTS
    sta.z points_1
    lda #>POINTS
    sta.z points_1+1
    jmp __b2
    // [12] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
  __b2_from___b2:
    // [12] phi (byte) main::i1#2 = (byte) main::i1#1 [phi:main::@2->main::@2#0] -- register_copy 
    // [12] phi (byte) main::idx#4 = (byte) main::idx#3 [phi:main::@2->main::@2#1] -- register_copy 
    // [12] phi (struct Point*) main::points#5 = (struct Point*) main::points#3 [phi:main::@2->main::@2#2] -- register_copy 
    jmp __b2
    // main::@2
  __b2:
    // [13] *((const byte*) main::SCREEN + (byte) main::idx#4) ← *((byte*)(struct Point*) main::points#5) -- pbuc1_derefidx_vbuz1=_deref_pbuz2 
    ldx.z idx_2
    ldy #0
    lda (points_1),y
    sta SCREEN,x
    // [14] (byte) main::idx#1 ← ++ (byte) main::idx#4 -- vbuz1=_inc_vbuz2 
    ldy.z idx_2
    iny
    sty.z idx
    // [15] *((const byte*) main::SCREEN + (byte) main::idx#1) ← *((byte*)(struct Point*) main::points#5 + (const byte) OFFSET_STRUCT_POINT_Y) -- pbuc1_derefidx_vbuz1=pbuz2_derefidx_vbuc2 
    ldx.z idx
    ldy #OFFSET_STRUCT_POINT_Y
    lda (points_1),y
    sta SCREEN,x
    // [16] (byte) main::idx#2 ← ++ (byte) main::idx#1 -- vbuz1=_inc_vbuz2 
    ldy.z idx
    iny
    sty.z idx_1
    // [17] *((const byte*) main::SCREEN + (byte) main::idx#2) ← (byte) ' ' -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #' '
    ldy.z idx_1
    sta SCREEN,y
    // [18] (byte) main::idx#3 ← ++ (byte) main::idx#2 -- vbuz1=_inc_vbuz2 
    ldy.z idx_1
    iny
    sty.z idx_2
    // [19] (struct Point*) main::points#3 ← (struct Point*) main::points#5 + (const byte) SIZEOF_STRUCT_POINT -- pssz1=pssz1_plus_vbuc1 
    lda #SIZEOF_STRUCT_POINT
    clc
    adc.z points_1
    sta.z points_1
    bcc !+
    inc.z points_1+1
  !:
    // [20] (byte) main::i1#1 ← ++ (byte) main::i1#2 -- vbuz1=_inc_vbuz1 
    inc.z i1
    // [21] if((byte) main::i1#1!=(byte) 4) goto main::@2 -- vbuz1_neq_vbuc1_then_la1 
    lda #4
    cmp.z i1
    bne __b2_from___b2
    jmp __breturn
    // main::@return
  __breturn:
    // [22] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] *((byte*)(struct Point*) main::points#4) ← (byte) main::i#2 [ main::points#4 main::i#2 ] ( main:2 [ main::points#4 main::i#2 ] ) always clobbers reg byte y 
Removing always clobbered register reg byte y as potential for zp[1]:4 [ main::i#2 main::i#1 ]
Statement [8] *((byte*)(struct Point*) main::points#4 + (const byte) OFFSET_STRUCT_POINT_Y) ← (byte~) main::$0 [ main::points#4 main::i#2 ] ( main:2 [ main::points#4 main::i#2 ] ) always clobbers reg byte y 
Statement [9] (struct Point*) main::points#1 ← (struct Point*) main::points#4 + (const byte) SIZEOF_STRUCT_POINT [ main::i#2 main::points#1 ] ( main:2 [ main::i#2 main::points#1 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:4 [ main::i#2 main::i#1 ]
Statement [13] *((const byte*) main::SCREEN + (byte) main::idx#4) ← *((byte*)(struct Point*) main::points#5) [ main::points#5 main::idx#4 main::i1#2 ] ( main:2 [ main::points#5 main::idx#4 main::i1#2 ] ) always clobbers reg byte a reg byte y 
Removing always clobbered register reg byte a as potential for zp[1]:7 [ main::idx#4 main::idx#3 ]
Removing always clobbered register reg byte y as potential for zp[1]:7 [ main::idx#4 main::idx#3 ]
Removing always clobbered register reg byte a as potential for zp[1]:8 [ main::i1#2 main::i1#1 ]
Removing always clobbered register reg byte y as potential for zp[1]:8 [ main::i1#2 main::i1#1 ]
Statement [15] *((const byte*) main::SCREEN + (byte) main::idx#1) ← *((byte*)(struct Point*) main::points#5 + (const byte) OFFSET_STRUCT_POINT_Y) [ main::points#5 main::i1#2 main::idx#1 ] ( main:2 [ main::points#5 main::i1#2 main::idx#1 ] ) always clobbers reg byte a reg byte y 
Removing always clobbered register reg byte a as potential for zp[1]:10 [ main::idx#1 ]
Removing always clobbered register reg byte y as potential for zp[1]:10 [ main::idx#1 ]
Statement [17] *((const byte*) main::SCREEN + (byte) main::idx#2) ← (byte) ' ' [ main::points#5 main::i1#2 main::idx#2 ] ( main:2 [ main::points#5 main::i1#2 main::idx#2 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:11 [ main::idx#2 ]
Statement [19] (struct Point*) main::points#3 ← (struct Point*) main::points#5 + (const byte) SIZEOF_STRUCT_POINT [ main::i1#2 main::points#3 main::idx#3 ] ( main:2 [ main::i1#2 main::points#3 main::idx#3 ] ) always clobbers reg byte a 
Statement [6] *((byte*)(struct Point*) main::points#4) ← (byte) main::i#2 [ main::points#4 main::i#2 ] ( main:2 [ main::points#4 main::i#2 ] ) always clobbers reg byte a reg byte y 
Statement [7] (byte~) main::$0 ← (byte) main::i#2 + (byte) 5 [ main::points#4 main::i#2 main::$0 ] ( main:2 [ main::points#4 main::i#2 main::$0 ] ) always clobbers reg byte a 
Statement [8] *((byte*)(struct Point*) main::points#4 + (const byte) OFFSET_STRUCT_POINT_Y) ← (byte~) main::$0 [ main::points#4 main::i#2 ] ( main:2 [ main::points#4 main::i#2 ] ) always clobbers reg byte y 
Statement [9] (struct Point*) main::points#1 ← (struct Point*) main::points#4 + (const byte) SIZEOF_STRUCT_POINT [ main::i#2 main::points#1 ] ( main:2 [ main::i#2 main::points#1 ] ) always clobbers reg byte a 
Statement [13] *((const byte*) main::SCREEN + (byte) main::idx#4) ← *((byte*)(struct Point*) main::points#5) [ main::points#5 main::idx#4 main::i1#2 ] ( main:2 [ main::points#5 main::idx#4 main::i1#2 ] ) always clobbers reg byte a reg byte y 
Statement [15] *((const byte*) main::SCREEN + (byte) main::idx#1) ← *((byte*)(struct Point*) main::points#5 + (const byte) OFFSET_STRUCT_POINT_Y) [ main::points#5 main::i1#2 main::idx#1 ] ( main:2 [ main::points#5 main::i1#2 main::idx#1 ] ) always clobbers reg byte a reg byte y 
Statement [17] *((const byte*) main::SCREEN + (byte) main::idx#2) ← (byte) ' ' [ main::points#5 main::i1#2 main::idx#2 ] ( main:2 [ main::points#5 main::i1#2 main::idx#2 ] ) always clobbers reg byte a 
Statement [19] (struct Point*) main::points#3 ← (struct Point*) main::points#5 + (const byte) SIZEOF_STRUCT_POINT [ main::i1#2 main::points#3 main::idx#3 ] ( main:2 [ main::i1#2 main::points#3 main::idx#3 ] ) always clobbers reg byte a 
Potential registers zp[2]:2 [ main::points#4 main::points#1 ] : zp[2]:2 , 
Potential registers zp[1]:4 [ main::i#2 main::i#1 ] : zp[1]:4 , reg byte x , 
Potential registers zp[2]:5 [ main::points#5 main::points#3 ] : zp[2]:5 , 
Potential registers zp[1]:7 [ main::idx#4 main::idx#3 ] : zp[1]:7 , reg byte x , 
Potential registers zp[1]:8 [ main::i1#2 main::i1#1 ] : zp[1]:8 , reg byte x , 
Potential registers zp[1]:9 [ main::$0 ] : zp[1]:9 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:10 [ main::idx#1 ] : zp[1]:10 , reg byte x , 
Potential registers zp[1]:11 [ main::idx#2 ] : zp[1]:11 , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 25.3: zp[1]:4 [ main::i#2 main::i#1 ] 22: zp[1]:7 [ main::idx#4 main::idx#3 ] 22: zp[1]:9 [ main::$0 ] 19.25: zp[1]:8 [ main::i1#2 main::i1#1 ] 16.5: zp[1]:10 [ main::idx#1 ] 16.5: zp[1]:11 [ main::idx#2 ] 12.83: zp[2]:2 [ main::points#4 main::points#1 ] 10.48: zp[2]:5 [ main::points#5 main::points#3 ] 
Uplift Scope [Point] 
Uplift Scope [] 

Uplifting [main] best 1708 combination reg byte x [ main::i#2 main::i#1 ] reg byte x [ main::idx#4 main::idx#3 ] reg byte a [ main::$0 ] zp[1]:8 [ main::i1#2 main::i1#1 ] reg byte x [ main::idx#1 ] zp[1]:11 [ main::idx#2 ] zp[2]:2 [ main::points#4 main::points#1 ] zp[2]:5 [ main::points#5 main::points#3 ] 
Limited combination testing to 100 combinations of 192 possible.
Uplifting [Point] best 1708 combination 
Uplifting [] best 1708 combination 
Attempting to uplift remaining variables inzp[1]:8 [ main::i1#2 main::i1#1 ]
Uplifting [main] best 1708 combination zp[1]:8 [ main::i1#2 main::i1#1 ] 
Attempting to uplift remaining variables inzp[1]:11 [ main::idx#2 ]
Uplifting [main] best 1618 combination reg byte x [ main::idx#2 ] 
Allocated (was zp[2]:5) zp[2]:4 [ main::points#5 main::points#3 ]
Allocated (was zp[1]:8) zp[1]:6 [ main::i1#2 main::i1#1 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Minimal struct - accessing pointer to struct  in memory in a loop
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .const SIZEOF_STRUCT_POINT = 2
  .const OFFSET_STRUCT_POINT_Y = 1
  .label POINTS = $1000
  // @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: {
    // Print points
    .label SCREEN = $400
    // Fill points
    .label points = 2
    // Fill points
    .label points_1 = 4
    .label i1 = 6
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // [5] phi (struct Point*) main::points#4 = (const struct Point*) POINTS [phi:main->main::@1#1] -- pssz1=pssc1 
    lda #<POINTS
    sta.z points
    lda #>POINTS
    sta.z points+1
    jmp __b1
    // [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  __b1_from___b1:
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    // [5] phi (struct Point*) main::points#4 = (struct Point*) main::points#1 [phi:main::@1->main::@1#1] -- register_copy 
    jmp __b1
    // main::@1
  __b1:
    // [6] *((byte*)(struct Point*) main::points#4) ← (byte) main::i#2 -- _deref_pbuz1=vbuxx 
    txa
    ldy #0
    sta (points),y
    // [7] (byte~) main::$0 ← (byte) main::i#2 + (byte) 5 -- vbuaa=vbuxx_plus_vbuc1 
    txa
    clc
    adc #5
    // [8] *((byte*)(struct Point*) main::points#4 + (const byte) OFFSET_STRUCT_POINT_Y) ← (byte~) main::$0 -- pbuz1_derefidx_vbuc1=vbuaa 
    ldy #OFFSET_STRUCT_POINT_Y
    sta (points),y
    // [9] (struct Point*) main::points#1 ← (struct Point*) main::points#4 + (const byte) SIZEOF_STRUCT_POINT -- pssz1=pssz1_plus_vbuc1 
    lda #SIZEOF_STRUCT_POINT
    clc
    adc.z points
    sta.z points
    bcc !+
    inc.z points+1
  !:
    // [10] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [11] if((byte) main::i#1!=(byte) 4) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #4
    bne __b1_from___b1
    // [12] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  __b2_from___b1:
    // [12] phi (byte) main::i1#2 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuz1=vbuc1 
    lda #0
    sta.z i1
    // [12] phi (byte) main::idx#4 = (byte) 0 [phi:main::@1->main::@2#1] -- vbuxx=vbuc1 
    ldx #0
    // [12] phi (struct Point*) main::points#5 = (const struct Point*) POINTS [phi:main::@1->main::@2#2] -- pssz1=pssc1 
    lda #<POINTS
    sta.z points_1
    lda #>POINTS
    sta.z points_1+1
    jmp __b2
    // [12] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
  __b2_from___b2:
    // [12] phi (byte) main::i1#2 = (byte) main::i1#1 [phi:main::@2->main::@2#0] -- register_copy 
    // [12] phi (byte) main::idx#4 = (byte) main::idx#3 [phi:main::@2->main::@2#1] -- register_copy 
    // [12] phi (struct Point*) main::points#5 = (struct Point*) main::points#3 [phi:main::@2->main::@2#2] -- register_copy 
    jmp __b2
    // main::@2
  __b2:
    // [13] *((const byte*) main::SCREEN + (byte) main::idx#4) ← *((byte*)(struct Point*) main::points#5) -- pbuc1_derefidx_vbuxx=_deref_pbuz1 
    ldy #0
    lda (points_1),y
    sta SCREEN,x
    // [14] (byte) main::idx#1 ← ++ (byte) main::idx#4 -- vbuxx=_inc_vbuxx 
    inx
    // [15] *((const byte*) main::SCREEN + (byte) main::idx#1) ← *((byte*)(struct Point*) main::points#5 + (const byte) OFFSET_STRUCT_POINT_Y) -- pbuc1_derefidx_vbuxx=pbuz1_derefidx_vbuc2 
    ldy #OFFSET_STRUCT_POINT_Y
    lda (points_1),y
    sta SCREEN,x
    // [16] (byte) main::idx#2 ← ++ (byte) main::idx#1 -- vbuxx=_inc_vbuxx 
    inx
    // [17] *((const byte*) main::SCREEN + (byte) main::idx#2) ← (byte) ' ' -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #' '
    sta SCREEN,x
    // [18] (byte) main::idx#3 ← ++ (byte) main::idx#2 -- vbuxx=_inc_vbuxx 
    inx
    // [19] (struct Point*) main::points#3 ← (struct Point*) main::points#5 + (const byte) SIZEOF_STRUCT_POINT -- pssz1=pssz1_plus_vbuc1 
    lda #SIZEOF_STRUCT_POINT
    clc
    adc.z points_1
    sta.z points_1
    bcc !+
    inc.z points_1+1
  !:
    // [20] (byte) main::i1#1 ← ++ (byte) main::i1#2 -- vbuz1=_inc_vbuz1 
    inc.z i1
    // [21] if((byte) main::i1#1!=(byte) 4) goto main::@2 -- vbuz1_neq_vbuc1_then_la1 
    lda #4
    cmp.z i1
    bne __b2_from___b2
    jmp __breturn
    // main::@return
  __breturn:
    // [22] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing instruction ldx #0 with TAX
Replacing label __bbegin with __b1
Replacing label __b1_from___b1 with __b1
Replacing label __b2_from___b2 with __b2
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Removing instruction __b1_from___b1:
Removing instruction __b2_from___b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __b1_from_main:
Removing instruction __b2_from___b1:
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
Removing instruction jmp __b2
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
(const struct Point*) POINTS = (struct Point*) 4096
(byte) Point::x
(byte) Point::y
(const byte) SIZEOF_STRUCT_POINT = (byte) 2
(void()) main()
(byte~) main::$0 reg byte a 22.0
(label) main::@1
(label) main::@2
(label) main::@return
(const byte*) main::SCREEN = (byte*) 1024
(byte) main::i
(byte) main::i#1 reg byte x 16.5
(byte) main::i#2 reg byte x 8.8
(byte) main::i1
(byte) main::i1#1 i1 zp[1]:6 16.5
(byte) main::i1#2 i1 zp[1]:6 2.75
(byte) main::idx
(byte) main::idx#1 reg byte x 16.5
(byte) main::idx#2 reg byte x 16.5
(byte) main::idx#3 reg byte x 5.5
(byte) main::idx#4 reg byte x 16.5
(struct Point*) main::points
(struct Point*) main::points#1 points zp[2]:2 7.333333333333333
(struct Point*) main::points#3 points_1 zp[2]:4 7.333333333333333
(struct Point*) main::points#4 points zp[2]:2 5.5
(struct Point*) main::points#5 points_1 zp[2]:4 3.142857142857143

zp[2]:2 [ main::points#4 main::points#1 ]
reg byte x [ main::i#2 main::i#1 ]
zp[2]:4 [ main::points#5 main::points#3 ]
reg byte x [ main::idx#4 main::idx#3 ]
zp[1]:6 [ main::i1#2 main::i1#1 ]
reg byte a [ main::$0 ]
reg byte x [ main::idx#1 ]
reg byte x [ main::idx#2 ]


FINAL ASSEMBLER
Score: 1456

  // File Comments
// Minimal struct - accessing pointer to struct  in memory in a loop
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .const SIZEOF_STRUCT_POINT = 2
  .const OFFSET_STRUCT_POINT_Y = 1
  .label POINTS = $1000
  // @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: {
    // Print points
    .label SCREEN = $400
    // Fill points
    .label points = 2
    // Fill points
    .label points_1 = 4
    .label i1 = 6
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // [5] phi (struct Point*) main::points#4 = (const struct Point*) POINTS [phi:main->main::@1#1] -- pssz1=pssc1 
    lda #<POINTS
    sta.z points
    lda #>POINTS
    sta.z points+1
    // [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    // [5] phi (struct Point*) main::points#4 = (struct Point*) main::points#1 [phi:main::@1->main::@1#1] -- register_copy 
    // main::@1
  __b1:
    // (*points).x = i
    // [6] *((byte*)(struct Point*) main::points#4) ← (byte) main::i#2 -- _deref_pbuz1=vbuxx 
    txa
    ldy #0
    sta (points),y
    // i+5
    // [7] (byte~) main::$0 ← (byte) main::i#2 + (byte) 5 -- vbuaa=vbuxx_plus_vbuc1 
    txa
    clc
    adc #5
    // (*points).y = i+5
    // [8] *((byte*)(struct Point*) main::points#4 + (const byte) OFFSET_STRUCT_POINT_Y) ← (byte~) main::$0 -- pbuz1_derefidx_vbuc1=vbuaa 
    ldy #OFFSET_STRUCT_POINT_Y
    sta (points),y
    // points++;
    // [9] (struct Point*) main::points#1 ← (struct Point*) main::points#4 + (const byte) SIZEOF_STRUCT_POINT -- pssz1=pssz1_plus_vbuc1 
    lda #SIZEOF_STRUCT_POINT
    clc
    adc.z points
    sta.z points
    bcc !+
    inc.z points+1
  !:
    // for( byte i: 0..3)
    // [10] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [11] if((byte) main::i#1!=(byte) 4) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #4
    bne __b1
    // [12] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
    // [12] phi (byte) main::i1#2 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuz1=vbuc1 
    lda #0
    sta.z i1
    // [12] phi (byte) main::idx#4 = (byte) 0 [phi:main::@1->main::@2#1] -- vbuxx=vbuc1 
    tax
    // [12] phi (struct Point*) main::points#5 = (const struct Point*) POINTS [phi:main::@1->main::@2#2] -- pssz1=pssc1 
    lda #<POINTS
    sta.z points_1
    lda #>POINTS
    sta.z points_1+1
    // [12] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
    // [12] phi (byte) main::i1#2 = (byte) main::i1#1 [phi:main::@2->main::@2#0] -- register_copy 
    // [12] phi (byte) main::idx#4 = (byte) main::idx#3 [phi:main::@2->main::@2#1] -- register_copy 
    // [12] phi (struct Point*) main::points#5 = (struct Point*) main::points#3 [phi:main::@2->main::@2#2] -- register_copy 
    // main::@2
  __b2:
    // SCREEN[idx++] = (*points).x
    // [13] *((const byte*) main::SCREEN + (byte) main::idx#4) ← *((byte*)(struct Point*) main::points#5) -- pbuc1_derefidx_vbuxx=_deref_pbuz1 
    ldy #0
    lda (points_1),y
    sta SCREEN,x
    // SCREEN[idx++] = (*points).x;
    // [14] (byte) main::idx#1 ← ++ (byte) main::idx#4 -- vbuxx=_inc_vbuxx 
    inx
    // SCREEN[idx++] = (*points).y
    // [15] *((const byte*) main::SCREEN + (byte) main::idx#1) ← *((byte*)(struct Point*) main::points#5 + (const byte) OFFSET_STRUCT_POINT_Y) -- pbuc1_derefidx_vbuxx=pbuz1_derefidx_vbuc2 
    ldy #OFFSET_STRUCT_POINT_Y
    lda (points_1),y
    sta SCREEN,x
    // SCREEN[idx++] = (*points).y;
    // [16] (byte) main::idx#2 ← ++ (byte) main::idx#1 -- vbuxx=_inc_vbuxx 
    inx
    // SCREEN[idx++] = ' '
    // [17] *((const byte*) main::SCREEN + (byte) main::idx#2) ← (byte) ' ' -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #' '
    sta SCREEN,x
    // SCREEN[idx++] = ' ';
    // [18] (byte) main::idx#3 ← ++ (byte) main::idx#2 -- vbuxx=_inc_vbuxx 
    inx
    // points++;
    // [19] (struct Point*) main::points#3 ← (struct Point*) main::points#5 + (const byte) SIZEOF_STRUCT_POINT -- pssz1=pssz1_plus_vbuc1 
    lda #SIZEOF_STRUCT_POINT
    clc
    adc.z points_1
    sta.z points_1
    bcc !+
    inc.z points_1+1
  !:
    // for( byte i: 0..3)
    // [20] (byte) main::i1#1 ← ++ (byte) main::i1#2 -- vbuz1=_inc_vbuz1 
    inc.z i1
    // [21] if((byte) main::i1#1!=(byte) 4) goto main::@2 -- vbuz1_neq_vbuc1_then_la1 
    lda #4
    cmp.z i1
    bne __b2
    // main::@return
    // }
    // [22] return 
    rts
}
  // File Data

