Fixing pointer increment (struct Point*) main::points ← ++ (struct Point*) main::points
Fixing pointer increment (struct Point*) main::points ← ++ (struct Point*) main::points
Rewriting struct pointer member access *((struct Point*) main::points).x
Rewriting struct pointer member access *((struct Point*) main::points).y
Rewriting struct pointer member access *((struct Point*) main::points).x
Rewriting struct pointer member access *((struct Point*) main::points).y
Identified constant variable (struct Point*) POINTS
Culled Empty Block (label) main::@4

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (struct Point*) POINTS#0 ← ((struct Point*)) (number) $1000
  to:@1
main: scope:[main]  from @1
  (struct Point*) main::points#0 ← (struct Point*) POINTS#0
  (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::SCREEN#0 ← ((byte*)) (number) $400
  (byte) main::idx#0 ← (number) 0
  (struct Point*) main::points#2 ← (struct Point*) POINTS#0
  (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
  *((byte*) main::SCREEN#0 + (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
  *((byte*) main::SCREEN#0 + (byte) main::idx#1) ← *((byte*) main::$6)
  (byte) main::idx#2 ← ++ (byte) main::idx#1
  *((byte*) main::SCREEN#0 + (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
(struct Point*) POINTS
(struct Point*) POINTS#0
(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
(byte*) main::SCREEN
(byte*) main::SCREEN#0
(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
Adding number conversion cast (unumber) 0 in (byte) main::idx#0 ← (number) 0
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (struct Point*) POINTS#0 ← (struct Point*)(number) $1000
Inlining cast (byte*) main::SCREEN#0 ← (byte*)(number) $400
Inlining cast (byte) main::idx#0 ← (unumber)(number) 0
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (struct Point*) 4096
Simplifying constant integer cast 5
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 5
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) main::$0 ← (byte) main::i#2 + (byte) 5
Simple Condition (bool~) main::$1 [12] if((byte) main::i#1!=rangelast(0,3)) goto main::@1
Simple Condition (bool~) main::$2 [29] if((byte) main::i1#1!=rangelast(0,3)) goto main::@3
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const struct Point*) POINTS#0 = (struct Point*) 4096
Constant (const byte) main::i#0 = 0
Constant (const byte*) main::SCREEN#0 = (byte*) 1024
Constant (const byte) main::idx#0 = 0
Constant (const byte) main::i1#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Constant (const struct Point*) main::points#0 = POINTS#0
Constant (const struct Point*) main::points#2 = POINTS#0
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [10] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [12] if(main::i#1!=rangelast(0,3)) goto main::@1 to (number) 4
Resolved ranged next value [27] main::i1#1 ← ++ main::i1#2 to ++
Resolved ranged comparison value [29] if(main::i1#1!=rangelast(0,3)) goto main::@3 to (number) 4
Converting *(pointer+n) to pointer[n] [5] *((byte*) main::$3) ← (byte) main::i#2  -- *((byte*)main::points#4 + OFFSET_STRUCT_POINT_X)
Converting *(pointer+n) to pointer[n] [8] *((byte*) main::$4) ← (byte~) main::$0  -- *((byte*)main::points#4 + OFFSET_STRUCT_POINT_Y)
Converting *(pointer+n) to pointer[n] [19] *((const byte*) main::SCREEN#0 + (byte) main::idx#4) ← *((byte*) main::$5)  -- *((byte*)main::points#5 + OFFSET_STRUCT_POINT_X)
Converting *(pointer+n) to pointer[n] [22] *((const byte*) main::SCREEN#0 + (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 [4] (byte*) main::$3 ← (byte*)(struct Point*) main::points#4 + (const byte) OFFSET_STRUCT_POINT_X
Simplifying expression containing zero (byte*)main::points#4 in [5] *((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 [18] (byte*) main::$5 ← (byte*)(struct Point*) main::points#5 + (const byte) OFFSET_STRUCT_POINT_X
Simplifying expression containing zero (byte*)main::points#5 in [19] *((const byte*) main::SCREEN#0 + (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 byte) main::i#0
Inlining constant with var siblings (const byte) main::idx#0
Inlining constant with var siblings (const byte) main::i1#0
Inlining constant with var siblings (const struct Point*) main::points#0
Inlining constant with var siblings (const struct Point*) main::points#2
Constant inlined main::points#2 = (const struct Point*) POINTS#0
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#0
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()
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#0 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#0 main::@2/(struct Point*) main::points#3 )
  [13] *((const byte*) main::SCREEN#0 + (byte) main::idx#4) ← *((byte*)(struct Point*) main::points#5)
  [14] (byte) main::idx#1 ← ++ (byte) main::idx#4
  [15] *((const byte*) main::SCREEN#0 + (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#0 + (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
(struct Point*) POINTS
(byte) Point::x
(byte) Point::y
(void()) main()
(byte~) main::$0 22.0
(byte*) main::SCREEN
(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 zero page equivalence class [ main::$0 ]
Added variable main::idx#1 to zero page equivalence class [ main::idx#1 ]
Added variable main::idx#2 to zero page 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 ZP_WORD:2 [ main::points#4 main::points#1 ]
Allocated zp ZP_BYTE:4 [ main::i#2 main::i#1 ]
Allocated zp ZP_WORD:5 [ main::points#5 main::points#3 ]
Allocated zp ZP_BYTE:7 [ main::idx#4 main::idx#3 ]
Allocated zp ZP_BYTE:8 [ main::i1#2 main::i1#1 ]
Allocated zp ZP_BYTE:9 [ main::$0 ]
Allocated zp ZP_BYTE:10 [ main::idx#1 ]
Allocated zp ZP_BYTE:11 [ main::idx#2 ]

INITIAL ASM
Target platform is c64basic
  // 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
    .label points = 2
    .label i = 4
    .label idx = $a
    .label idx_2 = $b
    .label idx_3 = 7
    .label points_3 = 5
    .label i1 = 8
    .label points_5 = 5
    .label idx_4 = 7
    // [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#0 [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_4
    // [12] phi (struct Point*) main::points#5 = (const struct Point*) POINTS#0 [phi:main::@1->main::@2#2] -- pssz1=pssc1 
    lda #<POINTS
    sta.z points_5
    lda #>POINTS
    sta.z points_5+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#0 + (byte) main::idx#4) ← *((byte*)(struct Point*) main::points#5) -- pbuc1_derefidx_vbuz1=_deref_pbuz2 
    ldx.z idx_4
    ldy #0
    lda (points_5),y
    sta SCREEN,x
    // [14] (byte) main::idx#1 ← ++ (byte) main::idx#4 -- vbuz1=_inc_vbuz2 
    ldy.z idx_4
    iny
    sty.z idx
    // [15] *((const byte*) main::SCREEN#0 + (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_5),y
    sta SCREEN,x
    // [16] (byte) main::idx#2 ← ++ (byte) main::idx#1 -- vbuz1=_inc_vbuz2 
    ldy.z idx
    iny
    sty.z idx_2
    // [17] *((const byte*) main::SCREEN#0 + (byte) main::idx#2) ← (byte) ' ' -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #' '
    ldy.z idx_2
    sta SCREEN,y
    // [18] (byte) main::idx#3 ← ++ (byte) main::idx#2 -- vbuz1=_inc_vbuz2 
    ldy.z idx_2
    iny
    sty.z idx_3
    // [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_3
    sta.z points_3
    bcc !+
    inc.z points_3+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 ZP_BYTE: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 ZP_BYTE:4 [ main::i#2 main::i#1 ]
Statement [13] *((const byte*) main::SCREEN#0 + (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 ZP_BYTE:7 [ main::idx#4 main::idx#3 ]
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:7 [ main::idx#4 main::idx#3 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:8 [ main::i1#2 main::i1#1 ]
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:8 [ main::i1#2 main::i1#1 ]
Statement [15] *((const byte*) main::SCREEN#0 + (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 ZP_BYTE:10 [ main::idx#1 ]
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:10 [ main::idx#1 ]
Statement [17] *((const byte*) main::SCREEN#0 + (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 ZP_BYTE: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#0 + (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#0 + (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#0 + (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 ZP_WORD:2 [ main::points#4 main::points#1 ] : zp ZP_WORD:2 , 
Potential registers zp ZP_BYTE:4 [ main::i#2 main::i#1 ] : zp ZP_BYTE:4 , reg byte x , 
Potential registers zp ZP_WORD:5 [ main::points#5 main::points#3 ] : zp ZP_WORD:5 , 
Potential registers zp ZP_BYTE:7 [ main::idx#4 main::idx#3 ] : zp ZP_BYTE:7 , reg byte x , 
Potential registers zp ZP_BYTE:8 [ main::i1#2 main::i1#1 ] : zp ZP_BYTE:8 , reg byte x , 
Potential registers zp ZP_BYTE:9 [ main::$0 ] : zp ZP_BYTE:9 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:10 [ main::idx#1 ] : zp ZP_BYTE:10 , reg byte x , 
Potential registers zp ZP_BYTE:11 [ main::idx#2 ] : zp ZP_BYTE:11 , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 25.3: zp ZP_BYTE:4 [ main::i#2 main::i#1 ] 22: zp ZP_BYTE:7 [ main::idx#4 main::idx#3 ] 22: zp ZP_BYTE:9 [ main::$0 ] 19.25: zp ZP_BYTE:8 [ main::i1#2 main::i1#1 ] 16.5: zp ZP_BYTE:10 [ main::idx#1 ] 16.5: zp ZP_BYTE:11 [ main::idx#2 ] 12.83: zp ZP_WORD:2 [ main::points#4 main::points#1 ] 10.48: zp ZP_WORD: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 ZP_BYTE:8 [ main::i1#2 main::i1#1 ] reg byte x [ main::idx#1 ] zp ZP_BYTE:11 [ main::idx#2 ] zp ZP_WORD:2 [ main::points#4 main::points#1 ] zp ZP_WORD: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 ZP_BYTE:8 [ main::i1#2 main::i1#1 ]
Uplifting [main] best 1708 combination zp ZP_BYTE:8 [ main::i1#2 main::i1#1 ] 
Attempting to uplift remaining variables inzp ZP_BYTE:11 [ main::idx#2 ]
Uplifting [main] best 1618 combination reg byte x [ main::idx#2 ] 
Allocated (was zp ZP_WORD:5) zp ZP_WORD:4 [ main::points#5 main::points#3 ]
Allocated (was zp ZP_BYTE:8) zp ZP_BYTE: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
    .label points = 2
    .label points_3 = 4
    .label i1 = 6
    .label points_5 = 4
    // [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#0 [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#0 [phi:main::@1->main::@2#2] -- pssz1=pssc1 
    lda #<POINTS
    sta.z points_5
    lda #>POINTS
    sta.z points_5+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#0 + (byte) main::idx#4) ← *((byte*)(struct Point*) main::points#5) -- pbuc1_derefidx_vbuxx=_deref_pbuz1 
    ldy #0
    lda (points_5),y
    sta SCREEN,x
    // [14] (byte) main::idx#1 ← ++ (byte) main::idx#4 -- vbuxx=_inc_vbuxx 
    inx
    // [15] *((const byte*) main::SCREEN#0 + (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_5),y
    sta SCREEN,x
    // [16] (byte) main::idx#2 ← ++ (byte) main::idx#1 -- vbuxx=_inc_vbuxx 
    inx
    // [17] *((const byte*) main::SCREEN#0 + (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_3
    sta.z points_3
    bcc !+
    inc.z points_3+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 b1_from_b1 with b1
Replacing label b2_from_b2 with b2
Removing instruction b1_from_bbegin:
Removing instruction b1:
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 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
(struct Point*) POINTS
(const struct Point*) POINTS#0 POINTS = (struct Point*) 4096
(byte) Point::x
(byte) Point::y
(const byte) SIZEOF_STRUCT_POINT SIZEOF_STRUCT_POINT = (byte) 2
(void()) main()
(byte~) main::$0 reg byte a 22.0
(label) main::@1
(label) main::@2
(label) main::@return
(byte*) main::SCREEN
(const byte*) main::SCREEN#0 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 ZP_BYTE:6 16.5
(byte) main::i1#2 i1 zp ZP_BYTE: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 ZP_WORD:2 7.333333333333333
(struct Point*) main::points#3 points#3 zp ZP_WORD:4 7.333333333333333
(struct Point*) main::points#4 points zp ZP_WORD:2 5.5
(struct Point*) main::points#5 points#5 zp ZP_WORD:4 3.142857142857143

zp ZP_WORD:2 [ main::points#4 main::points#1 ]
reg byte x [ main::i#2 main::i#1 ]
zp ZP_WORD:4 [ main::points#5 main::points#3 ]
reg byte x [ main::idx#4 main::idx#3 ]
zp ZP_BYTE: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
    .label points = 2
    .label points_3 = 4
    .label i1 = 6
    .label points_5 = 4
    // [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#0 [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#0 [phi:main::@1->main::@2#2] -- pssz1=pssc1 
    lda #<POINTS
    sta.z points_5
    lda #>POINTS
    sta.z points_5+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#0 + (byte) main::idx#4) ← *((byte*)(struct Point*) main::points#5) -- pbuc1_derefidx_vbuxx=_deref_pbuz1 
    ldy #0
    lda (points_5),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#0 + (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_5),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#0 + (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_3
    sta.z points_3
    bcc !+
    inc.z points_3+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

