Fixing pointer addition (struct Point*~) main::$0 ← (struct Point[4]) points + (byte) main::i
Fixing pointer addition (struct Point*~) main::$7 ← (struct Point[4]) points + (byte) main::i1
Culled Empty Block (label) main::@4

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (struct Point[4]) points#0 ← { fill( 4, 0) }
  (byte) OFFS_X#0 ← (number) 0
  (byte) OFFS_Y#0 ← (number) 1
  to:@1
main: scope:[main]  from @1
  (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 )
  (byte~) main::$14 ← (byte) main::i#2 * (const byte) SIZEOF_STRUCT_POINT
  (struct Point*~) main::$0 ← (struct Point[4]) points#0 + (byte~) main::$14
  (struct Point*) main::point_i#0 ← (struct Point*~) main::$0
  (byte*~) main::$1 ← ((byte*)) (struct Point*) main::point_i#0
  (byte*~) main::$2 ← (byte*~) main::$1 + (byte) OFFS_X#0
  *((byte*~) main::$2) ← (byte) main::i#2
  (byte*~) main::$3 ← ((byte*)) (struct Point*) main::point_i#0
  (byte*~) main::$4 ← (byte*~) main::$3 + (byte) OFFS_Y#0
  (number~) main::$5 ← (byte) main::i#2 + (number) 4
  *((byte*~) main::$4) ← (number~) main::$5
  (byte) main::i#1 ← (byte) main::i#2 + rangenext(0,3)
  (bool~) main::$6 ← (byte) main::i#1 != rangelast(0,3)
  if((bool~) main::$6) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1
  (byte*) main::SCREEN#0 ← ((byte*)) (number) $400
  (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::$15 ← (byte) main::i1#2 * (const byte) SIZEOF_STRUCT_POINT
  (struct Point*~) main::$7 ← (struct Point[4]) points#0 + (byte~) main::$15
  (struct Point*) main::point_i1#0 ← (struct Point*~) main::$7
  (byte*~) main::$8 ← ((byte*)) (struct Point*) main::point_i1#0
  (byte*~) main::$9 ← (byte*~) main::$8 + (byte) OFFS_X#0
  *((byte*) main::SCREEN#0 + (byte) main::i1#2) ← *((byte*~) main::$9)
  (byte*~) main::$10 ← (byte*) main::SCREEN#0 + (number) $28
  (byte*~) main::$11 ← ((byte*)) (struct Point*) main::point_i1#0
  (byte*~) main::$12 ← (byte*~) main::$11 + (byte) OFFS_Y#0
  *((byte*~) main::$10 + (byte) main::i1#2) ← *((byte*~) main::$12)
  (byte) main::i1#1 ← (byte) main::i1#2 + rangenext(0,3)
  (bool~) main::$13 ← (byte) main::i1#1 != rangelast(0,3)
  if((bool~) main::$13) 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
(byte) OFFS_X
(byte) OFFS_X#0
(byte) OFFS_Y
(byte) OFFS_Y#0
(byte) Point::x
(byte) Point::y
(const byte) SIZEOF_STRUCT_POINT = (byte) 2
(void()) main()
(struct Point*~) main::$0
(byte*~) main::$1
(byte*~) main::$10
(byte*~) main::$11
(byte*~) main::$12
(bool~) main::$13
(byte~) main::$14
(byte~) main::$15
(byte*~) main::$2
(byte*~) main::$3
(byte*~) main::$4
(number~) main::$5
(bool~) main::$6
(struct Point*~) main::$7
(byte*~) main::$8
(byte*~) main::$9
(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
(struct Point*) main::point_i
(struct Point*) main::point_i#0
(struct Point*) main::point_i1
(struct Point*) main::point_i1#0
(struct Point[4]) points
(struct Point[4]) points#0

Adding number conversion cast (unumber) 0 in (byte) OFFS_X#0 ← (number) 0
Adding number conversion cast (unumber) 1 in (byte) OFFS_Y#0 ← (number) 1
Adding number conversion cast (unumber) 4 in (number~) main::$5 ← (byte) main::i#2 + (number) 4
Adding number conversion cast (unumber) main::$5 in (number~) main::$5 ← (byte) main::i#2 + (unumber)(number) 4
Adding number conversion cast (unumber) $28 in (byte*~) main::$10 ← (byte*) main::SCREEN#0 + (number) $28
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte) OFFS_X#0 ← (unumber)(number) 0
Inlining cast (byte) OFFS_Y#0 ← (unumber)(number) 1
Inlining cast (byte*~) main::$1 ← (byte*)(struct Point*) main::point_i#0
Inlining cast (byte*~) main::$3 ← (byte*)(struct Point*) main::point_i#0
Inlining cast (byte*) main::SCREEN#0 ← (byte*)(number) $400
Inlining cast (byte*~) main::$8 ← (byte*)(struct Point*) main::point_i1#0
Inlining cast (byte*~) main::$11 ← (byte*)(struct Point*) main::point_i1#0
Successful SSA optimization Pass2InlineCast
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 4
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast $28
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 4
Finalized unsigned number type (byte) $28
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) main::$5 ← (byte) main::i#2 + (byte) 4
Alias (struct Point*) main::point_i#0 = (struct Point*~) main::$0 
Alias (struct Point*) main::point_i1#0 = (struct Point*~) main::$7 
Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) main::$6 [17] if((byte) main::i#1!=rangelast(0,3)) goto main::@1
Simple Condition (bool~) main::$13 [33] if((byte) main::i1#1!=rangelast(0,3)) goto main::@3
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant right-side identified [0] (struct Point[4]) points#0 ← { fill( 4, 0) }
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const struct Point[4]) points#0 = { fill( 4, 0) }
Constant (const byte) OFFS_X#0 = 0
Constant (const byte) OFFS_Y#0 = 1
Constant (const byte) main::i#0 = 0
Constant (const byte*) main::SCREEN#0 = (byte*) 1024
Constant (const byte) main::i1#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [15] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [17] if(main::i#1!=rangelast(0,3)) goto main::@1 to (number) 4
Resolved ranged next value [31] main::i1#1 ← ++ main::i1#2 to ++
Resolved ranged comparison value [33] if(main::i1#1!=rangelast(0,3)) goto main::@3 to (number) 4
Converting *(pointer+n) to pointer[n] [10] *((byte*~) main::$2) ← (byte) main::i#2  -- *(main::$1 + OFFS_X#0)
Converting *(pointer+n) to pointer[n] [14] *((byte*~) main::$4) ← (byte~) main::$5  -- *(main::$3 + OFFS_Y#0)
Converting *(pointer+n) to pointer[n] [26] *((const byte*) main::SCREEN#0 + (byte) main::i1#2) ← *((byte*~) main::$9)  -- *(main::$8 + OFFS_X#0)
Converting *(pointer+n) to pointer[n] [30] *((byte*~) main::$10 + (byte) main::i1#2) ← *((byte*~) main::$12)  -- *(main::$11 + OFFS_Y#0)
Successful SSA optimization Pass2InlineDerefIdx
Simplifying expression containing zero main::$1 in [9] (byte*~) main::$2 ← (byte*~) main::$1 + (const byte) OFFS_X#0
Simplifying expression containing zero main::$1 in [10] *((byte*~) main::$1 + (const byte) OFFS_X#0) ← (byte) main::i#2
Simplifying expression containing zero main::$8 in [25] (byte*~) main::$9 ← (byte*~) main::$8 + (const byte) OFFS_X#0
Simplifying expression containing zero main::$8 in [26] *((const byte*) main::SCREEN#0 + (byte) main::i1#2) ← *((byte*~) main::$8 + (const byte) OFFS_X#0)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable (byte*~) main::$2 and assignment [4] (byte*~) main::$2 ← (byte*~) main::$1
Eliminating unused variable (byte*~) main::$4 and assignment [7] (byte*~) main::$4 ← (byte*~) main::$3 + (const byte) OFFS_Y#0
Eliminating unused variable (byte*~) main::$9 and assignment [16] (byte*~) main::$9 ← (byte*~) main::$8
Eliminating unused variable (byte*~) main::$12 and assignment [20] (byte*~) main::$12 ← (byte*~) main::$11 + (const byte) OFFS_Y#0
Eliminating unused constant (const byte) OFFS_X#0
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
Constant right-side identified [15] (byte*~) main::$10 ← (const byte*) main::SCREEN#0 + (byte) $28
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) main::$10 = main::SCREEN#0+$28
Successful SSA optimization Pass2ConstantIdentification
Converting *(pointer+n) to pointer[n] [4] *((byte*~) main::$1) ← (byte) main::i#2  -- *((byte*)points#0 + main::$14)
Converting *(pointer+n) to pointer[n] [14] *((const byte*) main::SCREEN#0 + (byte) main::i1#2) ← *((byte*~) main::$8)  -- *((byte*)points#0 + main::$15)
Successful SSA optimization Pass2InlineDerefIdx
Eliminating unused variable (byte*~) main::$1 and assignment [3] (byte*~) main::$1 ← (byte*)(struct Point*) main::point_i#0
Eliminating unused variable (byte*~) main::$8 and assignment [13] (byte*~) main::$8 ← (byte*)(struct Point*) main::point_i1#0
Successful SSA optimization PassNEliminateUnusedVars
Constant value identified (byte*)points#0 in [3] *((byte*)(const struct Point[4]) points#0 + (byte~) main::$14) ← (byte) main::i#2
Constant value identified (byte*)points#0 in [12] *((const byte*) main::SCREEN#0 + (byte) main::i1#2) ← *((byte*)(const struct Point[4]) points#0 + (byte~) main::$15)
Successful SSA optimization Pass2ConstantValues
Inlining Noop Cast [4] (byte*~) main::$3 ← (byte*)(struct Point*) main::point_i#0 keeping main::point_i#0
Inlining Noop Cast [13] (byte*~) main::$11 ← (byte*)(struct Point*) main::point_i1#0 keeping main::point_i1#0
Successful SSA optimization Pass2NopCastInlining
Rewriting multiplication to use shift [1] (byte~) main::$14 ← (byte) main::i#2 * (const byte) SIZEOF_STRUCT_POINT
Rewriting multiplication to use shift [10] (byte~) main::$15 ← (byte) main::i1#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) main::i1#0
Constant inlined main::i#0 = (byte) 0
Constant inlined main::i1#0 = (byte) 0
Constant inlined main::$10 = (const byte*) main::SCREEN#0+(byte) $28
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::@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 2 initial phi equivalence classes
Coalesced [23] main::i1#3 ← main::i1#1
Coalesced [24] main::i#3 ← main::i#1
Coalesced down to 2 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 )
  [6] (byte~) main::$14 ← (byte) main::i#2 << (byte) 1
  [7] (struct Point*) main::point_i#0 ← (const struct Point[4]) points#0 + (byte~) main::$14
  [8] *((byte*)(const struct Point[4]) points#0 + (byte~) main::$14) ← (byte) main::i#2
  [9] (byte~) main::$5 ← (byte) main::i#2 + (byte) 4
  [10] *((byte*)(struct Point*) main::point_i#0 + (const byte) OFFS_Y#0) ← (byte~) main::$5
  [11] (byte) main::i#1 ← ++ (byte) main::i#2
  [12] if((byte) main::i#1!=(byte) 4) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@2
  [13] (byte) main::i1#2 ← phi( main::@1/(byte) 0 main::@2/(byte) main::i1#1 )
  [14] (byte~) main::$15 ← (byte) main::i1#2 << (byte) 1
  [15] (struct Point*) main::point_i1#0 ← (const struct Point[4]) points#0 + (byte~) main::$15
  [16] *((const byte*) main::SCREEN#0 + (byte) main::i1#2) ← *((byte*)(const struct Point[4]) points#0 + (byte~) main::$15)
  [17] *((const byte*) main::SCREEN#0+(byte) $28 + (byte) main::i1#2) ← *((byte*)(struct Point*) main::point_i1#0 + (const byte) OFFS_Y#0)
  [18] (byte) main::i1#1 ← ++ (byte) main::i1#2
  [19] if((byte) main::i1#1!=(byte) 4) goto main::@2
  to:main::@return
main::@return: scope:[main]  from main::@2
  [20] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte) OFFS_X
(byte) OFFS_Y
(byte) Point::x
(byte) Point::y
(void()) main()
(byte~) main::$14 16.5
(byte~) main::$15 16.5
(byte~) main::$5 22.0
(byte*) main::SCREEN
(byte) main::i
(byte) main::i#1 16.5
(byte) main::i#2 9.166666666666666
(byte) main::i1
(byte) main::i1#1 16.5
(byte) main::i1#2 11.0
(struct Point*) main::point_i
(struct Point*) main::point_i#0 3.6666666666666665
(struct Point*) main::point_i1
(struct Point*) main::point_i1#0 5.5
(struct Point[4]) points

Initial phi equivalence classes
[ main::i#2 main::i#1 ]
[ main::i1#2 main::i1#1 ]
Added variable main::$14 to zero page equivalence class [ main::$14 ]
Added variable main::point_i#0 to zero page equivalence class [ main::point_i#0 ]
Added variable main::$5 to zero page equivalence class [ main::$5 ]
Added variable main::$15 to zero page equivalence class [ main::$15 ]
Added variable main::point_i1#0 to zero page equivalence class [ main::point_i1#0 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ main::i1#2 main::i1#1 ]
[ main::$14 ]
[ main::point_i#0 ]
[ main::$5 ]
[ main::$15 ]
[ main::point_i1#0 ]
Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Allocated zp ZP_BYTE:3 [ main::i1#2 main::i1#1 ]
Allocated zp ZP_BYTE:4 [ main::$14 ]
Allocated zp ZP_WORD:5 [ main::point_i#0 ]
Allocated zp ZP_BYTE:7 [ main::$5 ]
Allocated zp ZP_BYTE:8 [ main::$15 ]
Allocated zp ZP_WORD:9 [ main::point_i1#0 ]

INITIAL ASM
Target platform is c64basic
  // File Comments
// Minimal struct - array of struct - far pointer math indexing
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .const OFFS_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 SCREEN = $400
    .label _5 = 7
    .label _14 = 4
    .label _15 = 8
    .label point_i = 5
    .label i = 2
    .label point_i1 = 9
    .label i1 = 3
    // [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
    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 
    jmp b1
    // main::@1
  b1:
    // [6] (byte~) main::$14 ← (byte) main::i#2 << (byte) 1 -- vbuz1=vbuz2_rol_1 
    lda.z i
    asl
    sta.z _14
    // [7] (struct Point*) main::point_i#0 ← (const struct Point[4]) points#0 + (byte~) main::$14 -- pssz1=pssc1_plus_vbuz2 
    lda.z _14
    clc
    adc #<points
    sta.z point_i
    lda #>points
    adc #0
    sta.z point_i+1
    // [8] *((byte*)(const struct Point[4]) points#0 + (byte~) main::$14) ← (byte) main::i#2 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda.z i
    ldy.z _14
    sta points,y
    // [9] (byte~) main::$5 ← (byte) main::i#2 + (byte) 4 -- vbuz1=vbuz2_plus_vbuc1 
    lax.z i
    axs #-[4]
    stx.z _5
    // [10] *((byte*)(struct Point*) main::point_i#0 + (const byte) OFFS_Y#0) ← (byte~) main::$5 -- pbuz1_derefidx_vbuc1=vbuz2 
    // points[i].x = i;
    lda.z _5
    ldy #OFFS_Y
    sta (point_i),y
    // [11] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 
    inc.z i
    // [12] if((byte) main::i#1!=(byte) 4) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #4
    cmp.z i
    bne b1_from_b1
    // [13] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
    // [13] phi (byte) main::i1#2 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuz1=vbuc1 
    lda #0
    sta.z i1
    jmp b2
    // [13] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
  b2_from_b2:
    // [13] phi (byte) main::i1#2 = (byte) main::i1#1 [phi:main::@2->main::@2#0] -- register_copy 
    jmp b2
    // main::@2
  b2:
    // [14] (byte~) main::$15 ← (byte) main::i1#2 << (byte) 1 -- vbuz1=vbuz2_rol_1 
    lda.z i1
    asl
    sta.z _15
    // [15] (struct Point*) main::point_i1#0 ← (const struct Point[4]) points#0 + (byte~) main::$15 -- pssz1=pssc1_plus_vbuz2 
    lda.z _15
    clc
    adc #<points
    sta.z point_i1
    lda #>points
    adc #0
    sta.z point_i1+1
    // [16] *((const byte*) main::SCREEN#0 + (byte) main::i1#2) ← *((byte*)(const struct Point[4]) points#0 + (byte~) main::$15) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz2 
    ldy.z _15
    lda points,y
    ldy.z i1
    sta SCREEN,y
    // [17] *((const byte*) main::SCREEN#0+(byte) $28 + (byte) main::i1#2) ← *((byte*)(struct Point*) main::point_i1#0 + (const byte) OFFS_Y#0) -- pbuc1_derefidx_vbuz1=pbuz2_derefidx_vbuc2 
    // SCREEN[i] = points[i].x;
    ldx.z i1
    ldy #OFFS_Y
    lda (point_i1),y
    sta SCREEN+$28,x
    // [18] (byte) main::i1#1 ← ++ (byte) main::i1#2 -- vbuz1=_inc_vbuz1 
    inc.z i1
    // [19] 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:
    // [20] return 
    rts
}
  // File Data
  points: .fill 2*4, 0

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] (byte~) main::$14 ← (byte) main::i#2 << (byte) 1 [ main::i#2 main::$14 ] ( main:2 [ main::i#2 main::$14 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Statement [7] (struct Point*) main::point_i#0 ← (const struct Point[4]) points#0 + (byte~) main::$14 [ main::i#2 main::$14 main::point_i#0 ] ( main:2 [ main::i#2 main::$14 main::point_i#0 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:4 [ main::$14 ]
Statement [8] *((byte*)(const struct Point[4]) points#0 + (byte~) main::$14) ← (byte) main::i#2 [ main::i#2 main::point_i#0 ] ( main:2 [ main::i#2 main::point_i#0 ] ) always clobbers reg byte a 
Statement [9] (byte~) main::$5 ← (byte) main::i#2 + (byte) 4 [ main::i#2 main::point_i#0 main::$5 ] ( main:2 [ main::i#2 main::point_i#0 main::$5 ] ) always clobbers reg byte a 
Statement [10] *((byte*)(struct Point*) main::point_i#0 + (const byte) OFFS_Y#0) ← (byte~) main::$5 [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte y 
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Statement [14] (byte~) main::$15 ← (byte) main::i1#2 << (byte) 1 [ main::i1#2 main::$15 ] ( main:2 [ main::i1#2 main::$15 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:3 [ main::i1#2 main::i1#1 ]
Statement [15] (struct Point*) main::point_i1#0 ← (const struct Point[4]) points#0 + (byte~) main::$15 [ main::i1#2 main::$15 main::point_i1#0 ] ( main:2 [ main::i1#2 main::$15 main::point_i1#0 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:8 [ main::$15 ]
Statement [16] *((const byte*) main::SCREEN#0 + (byte) main::i1#2) ← *((byte*)(const struct Point[4]) points#0 + (byte~) main::$15) [ main::i1#2 main::point_i1#0 ] ( main:2 [ main::i1#2 main::point_i1#0 ] ) always clobbers reg byte a 
Statement [17] *((const byte*) main::SCREEN#0+(byte) $28 + (byte) main::i1#2) ← *((byte*)(struct Point*) main::point_i1#0 + (const byte) OFFS_Y#0) [ main::i1#2 ] ( main:2 [ main::i1#2 ] ) always clobbers reg byte a reg byte y 
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:3 [ main::i1#2 main::i1#1 ]
Statement [6] (byte~) main::$14 ← (byte) main::i#2 << (byte) 1 [ main::i#2 main::$14 ] ( main:2 [ main::i#2 main::$14 ] ) always clobbers reg byte a 
Statement [7] (struct Point*) main::point_i#0 ← (const struct Point[4]) points#0 + (byte~) main::$14 [ main::i#2 main::$14 main::point_i#0 ] ( main:2 [ main::i#2 main::$14 main::point_i#0 ] ) always clobbers reg byte a 
Statement [8] *((byte*)(const struct Point[4]) points#0 + (byte~) main::$14) ← (byte) main::i#2 [ main::i#2 main::point_i#0 ] ( main:2 [ main::i#2 main::point_i#0 ] ) always clobbers reg byte a 
Statement [9] (byte~) main::$5 ← (byte) main::i#2 + (byte) 4 [ main::i#2 main::point_i#0 main::$5 ] ( main:2 [ main::i#2 main::point_i#0 main::$5 ] ) always clobbers reg byte a 
Statement [10] *((byte*)(struct Point*) main::point_i#0 + (const byte) OFFS_Y#0) ← (byte~) main::$5 [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte y 
Statement [14] (byte~) main::$15 ← (byte) main::i1#2 << (byte) 1 [ main::i1#2 main::$15 ] ( main:2 [ main::i1#2 main::$15 ] ) always clobbers reg byte a 
Statement [15] (struct Point*) main::point_i1#0 ← (const struct Point[4]) points#0 + (byte~) main::$15 [ main::i1#2 main::$15 main::point_i1#0 ] ( main:2 [ main::i1#2 main::$15 main::point_i1#0 ] ) always clobbers reg byte a 
Statement [16] *((const byte*) main::SCREEN#0 + (byte) main::i1#2) ← *((byte*)(const struct Point[4]) points#0 + (byte~) main::$15) [ main::i1#2 main::point_i1#0 ] ( main:2 [ main::i1#2 main::point_i1#0 ] ) always clobbers reg byte a 
Statement [17] *((const byte*) main::SCREEN#0+(byte) $28 + (byte) main::i1#2) ← *((byte*)(struct Point*) main::point_i1#0 + (const byte) OFFS_Y#0) [ main::i1#2 ] ( main:2 [ main::i1#2 ] ) always clobbers reg byte a reg byte y 
Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte x , 
Potential registers zp ZP_BYTE:3 [ main::i1#2 main::i1#1 ] : zp ZP_BYTE:3 , reg byte x , 
Potential registers zp ZP_BYTE:4 [ main::$14 ] : zp ZP_BYTE:4 , reg byte x , reg byte y , 
Potential registers zp ZP_WORD:5 [ main::point_i#0 ] : zp ZP_WORD:5 , 
Potential registers zp ZP_BYTE:7 [ main::$5 ] : zp ZP_BYTE:7 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:8 [ main::$15 ] : zp ZP_BYTE:8 , reg byte x , reg byte y , 
Potential registers zp ZP_WORD:9 [ main::point_i1#0 ] : zp ZP_WORD:9 , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 27.5: zp ZP_BYTE:3 [ main::i1#2 main::i1#1 ] 25.67: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 22: zp ZP_BYTE:7 [ main::$5 ] 16.5: zp ZP_BYTE:4 [ main::$14 ] 16.5: zp ZP_BYTE:8 [ main::$15 ] 5.5: zp ZP_WORD:9 [ main::point_i1#0 ] 3.67: zp ZP_WORD:5 [ main::point_i#0 ] 
Uplift Scope [Point] 
Uplift Scope [] 

Uplifting [main] best 1258 combination reg byte x [ main::i1#2 main::i1#1 ] reg byte x [ main::i#2 main::i#1 ] reg byte a [ main::$5 ] reg byte y [ main::$14 ] zp ZP_BYTE:8 [ main::$15 ] zp ZP_WORD:9 [ main::point_i1#0 ] zp ZP_WORD:5 [ main::point_i#0 ] 
Limited combination testing to 100 combinations of 144 possible.
Uplifting [Point] best 1258 combination 
Uplifting [] best 1258 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:8 [ main::$15 ]
Uplifting [main] best 1208 combination reg byte y [ main::$15 ] 
Allocated (was zp ZP_WORD:5) zp ZP_WORD:2 [ main::point_i#0 ]
Allocated (was zp ZP_WORD:9) zp ZP_WORD:4 [ main::point_i1#0 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Minimal struct - array of struct - far pointer math indexing
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .const OFFS_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 SCREEN = $400
    .label point_i = 2
    .label point_i1 = 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
    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 
    jmp b1
    // main::@1
  b1:
    // [6] (byte~) main::$14 ← (byte) main::i#2 << (byte) 1 -- vbuyy=vbuxx_rol_1 
    txa
    asl
    tay
    // [7] (struct Point*) main::point_i#0 ← (const struct Point[4]) points#0 + (byte~) main::$14 -- pssz1=pssc1_plus_vbuyy 
    tya
    clc
    adc #<points
    sta.z point_i
    lda #>points
    adc #0
    sta.z point_i+1
    // [8] *((byte*)(const struct Point[4]) points#0 + (byte~) main::$14) ← (byte) main::i#2 -- pbuc1_derefidx_vbuyy=vbuxx 
    txa
    sta points,y
    // [9] (byte~) main::$5 ← (byte) main::i#2 + (byte) 4 -- vbuaa=vbuxx_plus_vbuc1 
    txa
    clc
    adc #4
    // [10] *((byte*)(struct Point*) main::point_i#0 + (const byte) OFFS_Y#0) ← (byte~) main::$5 -- pbuz1_derefidx_vbuc1=vbuaa 
    // points[i].x = i;
    ldy #OFFS_Y
    sta (point_i),y
    // [11] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [12] if((byte) main::i#1!=(byte) 4) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #4
    bne b1_from_b1
    // [13] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
    // [13] phi (byte) main::i1#2 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuxx=vbuc1 
    ldx #0
    jmp b2
    // [13] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
  b2_from_b2:
    // [13] phi (byte) main::i1#2 = (byte) main::i1#1 [phi:main::@2->main::@2#0] -- register_copy 
    jmp b2
    // main::@2
  b2:
    // [14] (byte~) main::$15 ← (byte) main::i1#2 << (byte) 1 -- vbuyy=vbuxx_rol_1 
    txa
    asl
    tay
    // [15] (struct Point*) main::point_i1#0 ← (const struct Point[4]) points#0 + (byte~) main::$15 -- pssz1=pssc1_plus_vbuyy 
    tya
    clc
    adc #<points
    sta.z point_i1
    lda #>points
    adc #0
    sta.z point_i1+1
    // [16] *((const byte*) main::SCREEN#0 + (byte) main::i1#2) ← *((byte*)(const struct Point[4]) points#0 + (byte~) main::$15) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuyy 
    lda points,y
    sta SCREEN,x
    // [17] *((const byte*) main::SCREEN#0+(byte) $28 + (byte) main::i1#2) ← *((byte*)(struct Point*) main::point_i1#0 + (const byte) OFFS_Y#0) -- pbuc1_derefidx_vbuxx=pbuz1_derefidx_vbuc2 
    // SCREEN[i] = points[i].x;
    ldy #OFFS_Y
    lda (point_i1),y
    sta SCREEN+$28,x
    // [18] (byte) main::i1#1 ← ++ (byte) main::i1#2 -- vbuxx=_inc_vbuxx 
    inx
    // [19] if((byte) main::i1#1!=(byte) 4) goto main::@2 -- vbuxx_neq_vbuc1_then_la1 
    cpx #4
    bne b2_from_b2
    jmp breturn
    // main::@return
  breturn:
    // [20] return 
    rts
}
  // File Data
  points: .fill 2*4, 0

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 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
(byte) OFFS_X
(byte) OFFS_Y
(const byte) OFFS_Y#0 OFFS_Y = (byte) 1
(byte) Point::x
(byte) Point::y
(void()) main()
(byte~) main::$14 reg byte y 16.5
(byte~) main::$15 reg byte y 16.5
(byte~) main::$5 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 9.166666666666666
(byte) main::i1
(byte) main::i1#1 reg byte x 16.5
(byte) main::i1#2 reg byte x 11.0
(struct Point*) main::point_i
(struct Point*) main::point_i#0 point_i zp ZP_WORD:2 3.6666666666666665
(struct Point*) main::point_i1
(struct Point*) main::point_i1#0 point_i1 zp ZP_WORD:4 5.5
(struct Point[4]) points
(const struct Point[4]) points#0 points = { fill( 4, 0) }

reg byte x [ main::i#2 main::i#1 ]
reg byte x [ main::i1#2 main::i1#1 ]
reg byte y [ main::$14 ]
zp ZP_WORD:2 [ main::point_i#0 ]
reg byte a [ main::$5 ]
reg byte y [ main::$15 ]
zp ZP_WORD:4 [ main::point_i1#0 ]


FINAL ASSEMBLER
Score: 1046

  // File Comments
// Minimal struct - array of struct - far pointer math indexing
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .const OFFS_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 SCREEN = $400
    .label point_i = 2
    .label point_i1 = 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 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 
    // main::@1
  b1:
    // points+i
    // [6] (byte~) main::$14 ← (byte) main::i#2 << (byte) 1 -- vbuyy=vbuxx_rol_1 
    txa
    asl
    tay
    // point_i = points+i
    // [7] (struct Point*) main::point_i#0 ← (const struct Point[4]) points#0 + (byte~) main::$14 -- pssz1=pssc1_plus_vbuyy 
    tya
    clc
    adc #<points
    sta.z point_i
    lda #>points
    adc #0
    sta.z point_i+1
    // *((byte*)point_i+OFFS_X) = i
    // [8] *((byte*)(const struct Point[4]) points#0 + (byte~) main::$14) ← (byte) main::i#2 -- pbuc1_derefidx_vbuyy=vbuxx 
    txa
    sta points,y
    // i+4
    // [9] (byte~) main::$5 ← (byte) main::i#2 + (byte) 4 -- vbuaa=vbuxx_plus_vbuc1 
    txa
    clc
    adc #4
    // *((byte*)point_i+OFFS_Y)  = i+4
    // [10] *((byte*)(struct Point*) main::point_i#0 + (const byte) OFFS_Y#0) ← (byte~) main::$5 -- pbuz1_derefidx_vbuc1=vbuaa 
    // points[i].x = i;
    ldy #OFFS_Y
    sta (point_i),y
    // for( byte i: 0..3)
    // [11] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [12] if((byte) main::i#1!=(byte) 4) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #4
    bne b1
    // [13] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
    // [13] phi (byte) main::i1#2 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuxx=vbuc1 
    ldx #0
    // [13] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
    // [13] phi (byte) main::i1#2 = (byte) main::i1#1 [phi:main::@2->main::@2#0] -- register_copy 
    // main::@2
  b2:
    // points+i
    // [14] (byte~) main::$15 ← (byte) main::i1#2 << (byte) 1 -- vbuyy=vbuxx_rol_1 
    txa
    asl
    tay
    // point_i = points+i
    // [15] (struct Point*) main::point_i1#0 ← (const struct Point[4]) points#0 + (byte~) main::$15 -- pssz1=pssc1_plus_vbuyy 
    tya
    clc
    adc #<points
    sta.z point_i1
    lda #>points
    adc #0
    sta.z point_i1+1
    // SCREEN[i] = *((byte*)point_i+OFFS_X)
    // [16] *((const byte*) main::SCREEN#0 + (byte) main::i1#2) ← *((byte*)(const struct Point[4]) points#0 + (byte~) main::$15) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuyy 
    lda points,y
    sta SCREEN,x
    // (SCREEN+40)[i] = *((byte*)point_i+OFFS_Y)
    // [17] *((const byte*) main::SCREEN#0+(byte) $28 + (byte) main::i1#2) ← *((byte*)(struct Point*) main::point_i1#0 + (const byte) OFFS_Y#0) -- pbuc1_derefidx_vbuxx=pbuz1_derefidx_vbuc2 
    // SCREEN[i] = points[i].x;
    ldy #OFFS_Y
    lda (point_i1),y
    sta SCREEN+$28,x
    // for( byte i: 0..3)
    // [18] (byte) main::i1#1 ← ++ (byte) main::i1#2 -- vbuxx=_inc_vbuxx 
    inx
    // [19] if((byte) main::i1#1!=(byte) 4) goto main::@2 -- vbuxx_neq_vbuc1_then_la1 
    cpx #4
    bne b2
    // main::@return
    // }
    // [20] return 
    rts
}
  // File Data
  points: .fill 2*4, 0

