Culled Empty Block (label) main::@4

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

Adding number conversion cast (unumber) 2 in (byte) SIZEOF_POINT#0 ← (number) 2
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::$8 ← (byte) main::i#2 + (number) 4
Adding number conversion cast (unumber) main::$8 in (number~) main::$8 ← (byte) main::i#2 + (unumber)(number) 4
Adding number conversion cast (unumber) $28 in (byte*~) main::$14 ← (byte*) main::SCREEN#0 + (number) $28
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte) SIZEOF_POINT#0 ← (unumber)(number) 2
Inlining cast (byte) OFFS_X#0 ← (unumber)(number) 0
Inlining cast (byte) OFFS_Y#0 ← (unumber)(number) 1
Inlining cast (byte*~) main::$0 ← (byte*)(struct Point[4]) points#0
Inlining cast (byte*~) main::$4 ← (byte*)(struct Point[4]) points#0
Inlining cast (byte*) main::SCREEN#0 ← (byte*)(number) $400
Inlining cast (byte*~) main::$10 ← (byte*)(struct Point[4]) points#0
Inlining cast (byte*~) main::$15 ← (byte*)(struct Point[4]) points#0
Successful SSA optimization Pass2InlineCast
Simplifying constant integer cast 2
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) 2
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::$8 ← (byte) main::i#2 + (byte) 4
Identified duplicate assignment right side [13] (byte~) main::$6 ← (byte) main::i#2 * (byte) SIZEOF_POINT#0
Identified duplicate assignment right side [31] (byte~) main::$17 ← (byte) main::i1#2 * (byte) SIZEOF_POINT#0
Successful SSA optimization Pass2DuplicateRValueIdentification
Simple Condition (bool~) main::$9 [19] if((byte) main::i#1!=rangelast(0,3)) goto main::@1
Simple Condition (bool~) main::$19 [36] 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) SIZEOF_POINT#0 = 2
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
Constant value identified (byte*)points#0 in [6] (byte*~) main::$0 ← (byte*)(const struct Point[4]) points#0
Constant value identified (byte*)points#0 in [11] (byte*~) main::$4 ← (byte*)(const struct Point[4]) points#0
Constant value identified (byte*)points#0 in [23] (byte*~) main::$10 ← (byte*)(const struct Point[4]) points#0
Constant value identified (byte*)points#0 in [29] (byte*~) main::$15 ← (byte*)(const struct Point[4]) points#0
Successful SSA optimization Pass2ConstantValues
Resolved ranged next value [17] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [19] if(main::i#1!=rangelast(0,3)) goto main::@1 to (number) 4
Resolved ranged next value [34] main::i1#1 ← ++ main::i1#2 to ++
Resolved ranged comparison value [36] if(main::i1#1!=rangelast(0,3)) goto main::@3 to (number) 4
Converting *(pointer+n) to pointer[n] [10] *((byte*~) main::$3) ← (byte) main::i#2  -- *(main::$1 + main::$2)
Converting *(pointer+n) to pointer[n] [16] *((byte*~) main::$7) ← (byte~) main::$8  -- *(main::$5 + main::$6)
Converting *(pointer+n) to pointer[n] [27] *((const byte*) main::SCREEN#0 + (byte) main::i1#2) ← *((byte*~) main::$13)  -- *(main::$11 + main::$12)
Converting *(pointer+n) to pointer[n] [33] *((byte*~) main::$14 + (byte) main::i1#2) ← *((byte*~) main::$18)  -- *(main::$16 + main::$17)
Successful SSA optimization Pass2InlineDerefIdx
Simplifying expression containing zero main::$0 in [7] (byte*~) main::$1 ← (byte*~) main::$0 + (const byte) OFFS_X#0
Simplifying expression containing zero main::$10 in [24] (byte*~) main::$11 ← (byte*~) main::$10 + (const byte) OFFS_X#0
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable (byte*~) main::$3 and assignment [4] (byte*~) main::$3 ← (byte*~) main::$1 + (byte~) main::$2
Eliminating unused variable (byte*~) main::$7 and assignment [9] (byte*~) main::$7 ← (byte*~) main::$5 + (byte~) main::$6
Eliminating unused variable (byte*~) main::$13 and assignment [18] (byte*~) main::$13 ← (byte*~) main::$11 + (byte~) main::$12
Eliminating unused variable (byte*~) main::$18 and assignment [24] (byte*~) main::$18 ← (byte*~) main::$16 + (byte~) main::$17
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
Alias (byte*~) main::$1 = (byte*~) main::$0 
Alias (byte~) main::$6 = (byte~) main::$2 
Alias (byte*~) main::$11 = (byte*~) main::$10 
Alias (byte~) main::$17 = (byte~) main::$12 
Successful SSA optimization Pass2AliasElimination
Constant right-side identified [17] (byte*~) main::$14 ← (const byte*) main::SCREEN#0 + (byte) $28
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) main::$1 = (byte*)points#0
Constant (const byte*) main::$4 = (byte*)points#0
Constant (const byte*) main::$11 = (byte*)points#0
Constant (const byte*) main::$14 = main::SCREEN#0+$28
Constant (const byte*) main::$15 = (byte*)points#0
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [3] (byte*~) main::$5 ← (const byte*) main::$4 + (const byte) OFFS_Y#0
Constant right-side identified [11] (byte*~) main::$16 ← (const byte*) main::$15 + (const byte) OFFS_Y#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) main::$5 = main::$4+OFFS_Y#0
Constant (const byte*) main::$16 = main::$15+OFFS_Y#0
Successful SSA optimization Pass2ConstantIdentification
Rewriting multiplication to use shift [1] (byte~) main::$6 ← (byte) main::i#2 * (const byte) SIZEOF_POINT#0
Rewriting multiplication to use shift [8] (byte~) main::$17 ← (byte) main::i1#2 * (const byte) SIZEOF_POINT#0
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::$1 = (byte*)(const struct Point[4]) points#0
Constant inlined main::$16 = (byte*)(const struct Point[4]) points#0+(const byte) OFFS_Y#0
Constant inlined main::$5 = (byte*)(const struct Point[4]) points#0+(const byte) OFFS_Y#0
Constant inlined main::i#0 = (byte) 0
Constant inlined main::i1#0 = (byte) 0
Constant inlined main::$14 = (const byte*) main::SCREEN#0+(byte) $28
Constant inlined main::$4 = (byte*)(const struct Point[4]) points#0
Constant inlined main::$15 = (byte*)(const struct Point[4]) points#0
Constant inlined main::$11 = (byte*)(const struct Point[4]) points#0
Successful SSA optimization Pass2ConstantInlining
Eliminating unused constant (const byte) SIZEOF_POINT#0
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 [21] main::i1#3 ← main::i1#1
Coalesced [22] 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::$6 ← (byte) main::i#2 << (byte) 1
  [7] *((byte*)(const struct Point[4]) points#0 + (byte~) main::$6) ← (byte) main::i#2
  [8] (byte~) main::$8 ← (byte) main::i#2 + (byte) 4
  [9] *((byte*)(const struct Point[4]) points#0+(const byte) OFFS_Y#0 + (byte~) main::$6) ← (byte~) main::$8
  [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 )
  [13] (byte~) main::$17 ← (byte) main::i1#2 << (byte) 1
  [14] *((const byte*) main::SCREEN#0 + (byte) main::i1#2) ← *((byte*)(const struct Point[4]) points#0 + (byte~) main::$17)
  [15] *((const byte*) main::SCREEN#0+(byte) $28 + (byte) main::i1#2) ← *((byte*)(const struct Point[4]) points#0+(const byte) OFFS_Y#0 + (byte~) main::$17)
  [16] (byte) main::i1#1 ← ++ (byte) main::i1#2
  [17] if((byte) main::i1#1!=(byte) 4) goto main::@2
  to:main::@return
main::@return: scope:[main]  from main::@2
  [18] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte) OFFS_X
(byte) OFFS_Y
(byte) Point::x
(byte) Point::y
(byte) SIZEOF_POINT
(void()) main()
(byte~) main::$17 16.5
(byte~) main::$6 11.0
(byte~) main::$8 22.0
(byte*) main::SCREEN
(byte) main::i
(byte) main::i#1 16.5
(byte) main::i#2 11.0
(byte) main::i1
(byte) main::i1#1 16.5
(byte) main::i1#2 13.75
(struct Point[4]) points

Initial phi equivalence classes
[ main::i#2 main::i#1 ]
[ main::i1#2 main::i1#1 ]
Added variable main::$6 to zero page equivalence class [ main::$6 ]
Added variable main::$8 to zero page equivalence class [ main::$8 ]
Added variable main::$17 to zero page equivalence class [ main::$17 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ main::i1#2 main::i1#1 ]
[ main::$6 ]
[ main::$8 ]
[ main::$17 ]
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::$6 ]
Allocated zp ZP_BYTE:5 [ main::$8 ]
Allocated zp ZP_BYTE:6 [ main::$17 ]

INITIAL ASM
  // File Comments
// Minimal struct - array of struct - near pointer math indexing
  // Basic 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 _6 = 4
    .label _8 = 5
    .label _17 = 6
    .label i = 2
    .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 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::$6 ← (byte) main::i#2 << (byte) 1 -- vbuz1=vbuz2_rol_1 
    lda i
    asl
    sta _6
    // [7] *((byte*)(const struct Point[4]) points#0 + (byte~) main::$6) ← (byte) main::i#2 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda i
    ldy _6
    sta points,y
    // [8] (byte~) main::$8 ← (byte) main::i#2 + (byte) 4 -- vbuz1=vbuz2_plus_vbuc1 
    lax i
    axs #-[4]
    stx _8
    // [9] *((byte*)(const struct Point[4]) points#0+(const byte) OFFS_Y#0 + (byte~) main::$6) ← (byte~) main::$8 -- pbuc1_derefidx_vbuz1=vbuz2 
    // points[i].x = i;
    lda _8
    ldy _6
    sta points+OFFS_Y,y
    // [10] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 
    inc i
    // [11] if((byte) main::i#1!=(byte) 4) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #4
    cmp 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 i1
    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 
    jmp b2
    // main::@2
  b2:
    // [13] (byte~) main::$17 ← (byte) main::i1#2 << (byte) 1 -- vbuz1=vbuz2_rol_1 
    lda i1
    asl
    sta _17
    // [14] *((const byte*) main::SCREEN#0 + (byte) main::i1#2) ← *((byte*)(const struct Point[4]) points#0 + (byte~) main::$17) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz2 
    ldy _17
    lda points,y
    ldy i1
    sta SCREEN,y
    // [15] *((const byte*) main::SCREEN#0+(byte) $28 + (byte) main::i1#2) ← *((byte*)(const struct Point[4]) points#0+(const byte) OFFS_Y#0 + (byte~) main::$17) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz2 
    // SCREEN[i] = points[i].x;
    ldy _17
    lda points+OFFS_Y,y
    ldy i1
    sta SCREEN+$28,y
    // [16] (byte) main::i1#1 ← ++ (byte) main::i1#2 -- vbuz1=_inc_vbuz1 
    inc i1
    // [17] if((byte) main::i1#1!=(byte) 4) goto main::@2 -- vbuz1_neq_vbuc1_then_la1 
    lda #4
    cmp i1
    bne b2_from_b2
    jmp breturn
    // main::@return
  breturn:
    // [18] return 
    rts
}
  // File Data
  points: .fill 2*4, 0

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

REGISTER UPLIFT SCOPES
Uplift Scope [main] 30.25: zp ZP_BYTE:3 [ main::i1#2 main::i1#1 ] 27.5: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 22: zp ZP_BYTE:5 [ main::$8 ] 16.5: zp ZP_BYTE:6 [ main::$17 ] 11: zp ZP_BYTE:4 [ main::$6 ] 
Uplift Scope [Point] 
Uplift Scope [] 

Uplifting [main] best 898 combination reg byte y [ main::i1#2 main::i1#1 ] reg byte x [ main::i#2 main::i#1 ] reg byte a [ main::$8 ] reg byte x [ main::$17 ] zp ZP_BYTE:4 [ main::$6 ] 
Limited combination testing to 100 combinations of 324 possible.
Uplifting [Point] best 898 combination 
Uplifting [] best 898 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:4 [ main::$6 ]
Uplifting [main] best 828 combination reg byte y [ main::$6 ] 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Minimal struct - array of struct - near pointer math indexing
  // Basic 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
    // [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::$6 ← (byte) main::i#2 << (byte) 1 -- vbuyy=vbuxx_rol_1 
    txa
    asl
    tay
    // [7] *((byte*)(const struct Point[4]) points#0 + (byte~) main::$6) ← (byte) main::i#2 -- pbuc1_derefidx_vbuyy=vbuxx 
    txa
    sta points,y
    // [8] (byte~) main::$8 ← (byte) main::i#2 + (byte) 4 -- vbuaa=vbuxx_plus_vbuc1 
    txa
    clc
    adc #4
    // [9] *((byte*)(const struct Point[4]) points#0+(const byte) OFFS_Y#0 + (byte~) main::$6) ← (byte~) main::$8 -- pbuc1_derefidx_vbuyy=vbuaa 
    // points[i].x = i;
    sta points+OFFS_Y,y
    // [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] -- vbuyy=vbuc1 
    ldy #0
    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 
    jmp b2
    // main::@2
  b2:
    // [13] (byte~) main::$17 ← (byte) main::i1#2 << (byte) 1 -- vbuxx=vbuyy_rol_1 
    tya
    asl
    tax
    // [14] *((const byte*) main::SCREEN#0 + (byte) main::i1#2) ← *((byte*)(const struct Point[4]) points#0 + (byte~) main::$17) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuxx 
    lda points,x
    sta SCREEN,y
    // [15] *((const byte*) main::SCREEN#0+(byte) $28 + (byte) main::i1#2) ← *((byte*)(const struct Point[4]) points#0+(const byte) OFFS_Y#0 + (byte~) main::$17) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuxx 
    // SCREEN[i] = points[i].x;
    lda points+OFFS_Y,x
    sta SCREEN+$28,y
    // [16] (byte) main::i1#1 ← ++ (byte) main::i1#2 -- vbuyy=_inc_vbuyy 
    iny
    // [17] if((byte) main::i1#1!=(byte) 4) goto main::@2 -- vbuyy_neq_vbuc1_then_la1 
    cpy #4
    bne b2_from_b2
    jmp breturn
    // main::@return
  breturn:
    // [18] 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
(byte) SIZEOF_POINT
(void()) main()
(byte~) main::$17 reg byte x 16.5
(byte~) main::$6 reg byte y 11.0
(byte~) main::$8 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 11.0
(byte) main::i1
(byte) main::i1#1 reg byte y 16.5
(byte) main::i1#2 reg byte y 13.75
(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 y [ main::i1#2 main::i1#1 ]
reg byte y [ main::$6 ]
reg byte a [ main::$8 ]
reg byte x [ main::$17 ]


FINAL ASSEMBLER
Score: 666

  // File Comments
// Minimal struct - array of struct - near pointer math indexing
  // Basic 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
    // [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:
    // i*SIZEOF_POINT
    // [6] (byte~) main::$6 ← (byte) main::i#2 << (byte) 1 -- vbuyy=vbuxx_rol_1 
    txa
    asl
    tay
    // *((byte*)points+OFFS_X+i*SIZEOF_POINT) = i
    // [7] *((byte*)(const struct Point[4]) points#0 + (byte~) main::$6) ← (byte) main::i#2 -- pbuc1_derefidx_vbuyy=vbuxx 
    txa
    sta points,y
    // i+4
    // [8] (byte~) main::$8 ← (byte) main::i#2 + (byte) 4 -- vbuaa=vbuxx_plus_vbuc1 
    txa
    clc
    adc #4
    // *((byte*)points+OFFS_Y+i*SIZEOF_POINT) = i+4
    // [9] *((byte*)(const struct Point[4]) points#0+(const byte) OFFS_Y#0 + (byte~) main::$6) ← (byte~) main::$8 -- pbuc1_derefidx_vbuyy=vbuaa 
    // points[i].x = i;
    sta points+OFFS_Y,y
    // 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] -- vbuyy=vbuc1 
    ldy #0
    // [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 
    // main::@2
  b2:
    // i*SIZEOF_POINT
    // [13] (byte~) main::$17 ← (byte) main::i1#2 << (byte) 1 -- vbuxx=vbuyy_rol_1 
    tya
    asl
    tax
    // SCREEN[i] = *((byte*)points+OFFS_X+i*SIZEOF_POINT)
    // [14] *((const byte*) main::SCREEN#0 + (byte) main::i1#2) ← *((byte*)(const struct Point[4]) points#0 + (byte~) main::$17) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuxx 
    lda points,x
    sta SCREEN,y
    // (SCREEN+40)[i] = *((byte*)points+OFFS_Y+i*SIZEOF_POINT)
    // [15] *((const byte*) main::SCREEN#0+(byte) $28 + (byte) main::i1#2) ← *((byte*)(const struct Point[4]) points#0+(const byte) OFFS_Y#0 + (byte~) main::$17) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuxx 
    // SCREEN[i] = points[i].x;
    lda points+OFFS_Y,x
    sta SCREEN+$28,y
    // for( byte i: 0..3)
    // [16] (byte) main::i1#1 ← ++ (byte) main::i1#2 -- vbuyy=_inc_vbuyy 
    iny
    // [17] if((byte) main::i1#1!=(byte) 4) goto main::@2 -- vbuyy_neq_vbuc1_then_la1 
    cpy #4
    bne b2
    // main::@return
    // }
    // [18] return 
    rts
}
  // File Data
  points: .fill 2*4, 0

