Fixing pointer array-indexing *((word[3]) main::words + (number) 1)
Fixing pointer array-indexing *((word[3]) main::words + (number) 2)

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@1
main: scope:[main]  from @1
  (byte*) main::SCREEN#0 ← ((byte*)) (number) $400+(number) 6*(number) $28
  (word[3]) main::words#0 ← ((word*)) (number) $400
  (number~) main::$4 ← (number) 1 * (const byte) SIZEOF_WORD
  (word) main::w1#0 ← *((word[3]) main::words#0 + (number~) main::$4)
  (byte~) main::$0 ← < (word) main::w1#0
  *((byte*) main::SCREEN#0 + (number) 0) ← (byte~) main::$0
  (byte~) main::$1 ← > (word) main::w1#0
  *((byte*) main::SCREEN#0 + (number) 1) ← (byte~) main::$1
  (number~) main::$5 ← (number) 2 * (const byte) SIZEOF_WORD
  (word) main::w2#0 ← *((word[3]) main::words#0 + (number~) main::$5)
  (byte~) main::$2 ← < (word) main::w2#0
  *((byte*) main::SCREEN#0 + (number) 2) ← (byte~) main::$2
  (byte~) main::$3 ← > (word) main::w2#0
  *((byte*) main::SCREEN#0 + (number) 3) ← (byte~) main::$3
  to:main::@return
main::@return: scope:[main]  from main
  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) SIZEOF_WORD = (byte) 2
(void()) main()
(byte~) main::$0
(byte~) main::$1
(byte~) main::$2
(byte~) main::$3
(number~) main::$4
(number~) main::$5
(label) main::@return
(byte*) main::SCREEN
(byte*) main::SCREEN#0
(word) main::w1
(word) main::w1#0
(word) main::w2
(word) main::w2#0
(word[3]) main::words
(word[3]) main::words#0

Adding number conversion cast (unumber) 1 in (number~) main::$4 ← (number) 1 * (const byte) SIZEOF_WORD
Adding number conversion cast (unumber) main::$4 in (number~) main::$4 ← (unumber)(number) 1 * (const byte) SIZEOF_WORD
Adding number conversion cast (unumber) 0 in *((byte*) main::SCREEN#0 + (number) 0) ← (byte~) main::$0
Adding number conversion cast (unumber) 1 in *((byte*) main::SCREEN#0 + (number) 1) ← (byte~) main::$1
Adding number conversion cast (unumber) 2 in (number~) main::$5 ← (number) 2 * (const byte) SIZEOF_WORD
Adding number conversion cast (unumber) main::$5 in (number~) main::$5 ← (unumber)(number) 2 * (const byte) SIZEOF_WORD
Adding number conversion cast (unumber) 2 in *((byte*) main::SCREEN#0 + (number) 2) ← (byte~) main::$2
Adding number conversion cast (unumber) 3 in *((byte*) main::SCREEN#0 + (number) 3) ← (byte~) main::$3
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) main::SCREEN#0 ← (byte*)(number) $400+(number) 6*(number) $28
Inlining cast (word[3]) main::words#0 ← (word*)(number) $400
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (word*) 1024
Simplifying constant integer cast 1
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 2
Simplifying constant integer cast 2
Simplifying constant integer cast 3
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 3
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) main::$4 ← (byte) 1 * (const byte) SIZEOF_WORD
Inferred type updated to byte in (unumber~) main::$5 ← (byte) 2 * (const byte) SIZEOF_WORD
Constant right-side identified [0] (byte*) main::SCREEN#0 ← (byte*)(number) $400+(number) 6*(number) $28
Constant right-side identified [2] (byte~) main::$4 ← (byte) 1 * (const byte) SIZEOF_WORD
Constant right-side identified [8] (byte~) main::$5 ← (byte) 2 * (const byte) SIZEOF_WORD
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) main::SCREEN#0 = (byte*)$400+6*$28
Constant (const word[3]) main::words#0 = (word*) 1024
Constant (const byte) main::$4 = 1*SIZEOF_WORD
Constant (const byte) main::$5 = 2*SIZEOF_WORD
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero main::SCREEN#0 in [5] *((const byte*) main::SCREEN#0 + (byte) 0) ← (byte~) main::$0
Successful SSA optimization PassNSimplifyExpressionWithZero
Constant inlined main::$5 = (byte) 2*(const byte) SIZEOF_WORD
Constant inlined main::$4 = (byte) 1*(const byte) SIZEOF_WORD
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(main::words#0+1*SIZEOF_WORD)
Consolidated array index constant in *(main::SCREEN#0+1)
Consolidated array index constant in *(main::words#0+2*SIZEOF_WORD)
Consolidated array index constant in *(main::SCREEN#0+2)
Consolidated array index constant in *(main::SCREEN#0+3)
Successful SSA optimization Pass2ConstantAdditionElimination
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
CALL GRAPH
Calls in [] to main:2 

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block (label) @2
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end

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] (word) main::w1#0 ← *((const word[3]) main::words#0+(byte) 1*(const byte) SIZEOF_WORD)
  [5] (byte~) main::$0 ← < (word) main::w1#0
  [6] *((const byte*) main::SCREEN#0) ← (byte~) main::$0
  [7] (byte~) main::$1 ← > (word) main::w1#0
  [8] *((const byte*) main::SCREEN#0+(byte) 1) ← (byte~) main::$1
  [9] (word) main::w2#0 ← *((const word[3]) main::words#0+(byte) 2*(const byte) SIZEOF_WORD)
  [10] (byte~) main::$2 ← < (word) main::w2#0
  [11] *((const byte*) main::SCREEN#0+(byte) 2) ← (byte~) main::$2
  [12] (byte~) main::$3 ← > (word) main::w2#0
  [13] *((const byte*) main::SCREEN#0+(byte) 3) ← (byte~) main::$3
  to:main::@return
main::@return: scope:[main]  from main
  [14] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(byte~) main::$0 4.0
(byte~) main::$1 4.0
(byte~) main::$2 4.0
(byte~) main::$3 4.0
(byte*) main::SCREEN
(word) main::w1
(word) main::w1#0 2.0
(word) main::w2
(word) main::w2#0 2.0
(word[3]) main::words

Initial phi equivalence classes
Added variable main::w1#0 to zero page equivalence class [ main::w1#0 ]
Added variable main::$0 to zero page equivalence class [ main::$0 ]
Added variable main::$1 to zero page equivalence class [ main::$1 ]
Added variable main::w2#0 to zero page equivalence class [ main::w2#0 ]
Added variable main::$2 to zero page equivalence class [ main::$2 ]
Added variable main::$3 to zero page equivalence class [ main::$3 ]
Complete equivalence classes
[ main::w1#0 ]
[ main::$0 ]
[ main::$1 ]
[ main::w2#0 ]
[ main::$2 ]
[ main::$3 ]
Allocated zp ZP_WORD:2 [ main::w1#0 ]
Allocated zp ZP_BYTE:4 [ main::$0 ]
Allocated zp ZP_BYTE:5 [ main::$1 ]
Allocated zp ZP_WORD:6 [ main::w2#0 ]
Allocated zp ZP_BYTE:8 [ main::$2 ]
Allocated zp ZP_BYTE:9 [ main::$3 ]

INITIAL ASM
  // File Comments
// Tests a simple word array
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .const SIZEOF_WORD = 2
  // @begin
bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
  // @1
b1:
  // [2] call main 
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
main: {
    .label SCREEN = $400+6*$28
    .label words = $400
    .label _0 = 4
    .label _1 = 5
    .label _2 = 8
    .label _3 = 9
    .label w1 = 2
    .label w2 = 6
    // [4] (word) main::w1#0 ← *((const word[3]) main::words#0+(byte) 1*(const byte) SIZEOF_WORD) -- vwuz1=_deref_pwuc1 
    lda words+1*SIZEOF_WORD
    sta w1
    lda words+1*SIZEOF_WORD+1
    sta w1+1
    // [5] (byte~) main::$0 ← < (word) main::w1#0 -- vbuz1=_lo_vwuz2 
    lda w1
    sta _0
    // [6] *((const byte*) main::SCREEN#0) ← (byte~) main::$0 -- _deref_pbuc1=vbuz1 
    lda _0
    sta SCREEN
    // [7] (byte~) main::$1 ← > (word) main::w1#0 -- vbuz1=_hi_vwuz2 
    lda w1+1
    sta _1
    // [8] *((const byte*) main::SCREEN#0+(byte) 1) ← (byte~) main::$1 -- _deref_pbuc1=vbuz1 
    lda _1
    sta SCREEN+1
    // [9] (word) main::w2#0 ← *((const word[3]) main::words#0+(byte) 2*(const byte) SIZEOF_WORD) -- vwuz1=_deref_pwuc1 
    lda words+2*SIZEOF_WORD
    sta w2
    lda words+2*SIZEOF_WORD+1
    sta w2+1
    // [10] (byte~) main::$2 ← < (word) main::w2#0 -- vbuz1=_lo_vwuz2 
    lda w2
    sta _2
    // [11] *((const byte*) main::SCREEN#0+(byte) 2) ← (byte~) main::$2 -- _deref_pbuc1=vbuz1 
    lda _2
    sta SCREEN+2
    // [12] (byte~) main::$3 ← > (word) main::w2#0 -- vbuz1=_hi_vwuz2 
    lda w2+1
    sta _3
    // [13] *((const byte*) main::SCREEN#0+(byte) 3) ← (byte~) main::$3 -- _deref_pbuc1=vbuz1 
    lda _3
    sta SCREEN+3
    jmp breturn
    // main::@return
  breturn:
    // [14] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] (word) main::w1#0 ← *((const word[3]) main::words#0+(byte) 1*(const byte) SIZEOF_WORD) [ main::w1#0 ] ( main:2 [ main::w1#0 ] ) always clobbers reg byte a 
Statement [5] (byte~) main::$0 ← < (word) main::w1#0 [ main::w1#0 main::$0 ] ( main:2 [ main::w1#0 main::$0 ] ) always clobbers reg byte a 
Statement [7] (byte~) main::$1 ← > (word) main::w1#0 [ main::$1 ] ( main:2 [ main::$1 ] ) always clobbers reg byte a 
Statement [9] (word) main::w2#0 ← *((const word[3]) main::words#0+(byte) 2*(const byte) SIZEOF_WORD) [ main::w2#0 ] ( main:2 [ main::w2#0 ] ) always clobbers reg byte a 
Statement [10] (byte~) main::$2 ← < (word) main::w2#0 [ main::w2#0 main::$2 ] ( main:2 [ main::w2#0 main::$2 ] ) always clobbers reg byte a 
Statement [12] (byte~) main::$3 ← > (word) main::w2#0 [ main::$3 ] ( main:2 [ main::$3 ] ) always clobbers reg byte a 
Potential registers zp ZP_WORD:2 [ main::w1#0 ] : zp ZP_WORD:2 , 
Potential registers zp ZP_BYTE:4 [ main::$0 ] : zp ZP_BYTE:4 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:5 [ main::$1 ] : zp ZP_BYTE:5 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_WORD:6 [ main::w2#0 ] : zp ZP_WORD:6 , 
Potential registers zp ZP_BYTE:8 [ main::$2 ] : zp ZP_BYTE:8 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:9 [ main::$3 ] : zp ZP_BYTE:9 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 4: zp ZP_BYTE:4 [ main::$0 ] 4: zp ZP_BYTE:5 [ main::$1 ] 4: zp ZP_BYTE:8 [ main::$2 ] 4: zp ZP_BYTE:9 [ main::$3 ] 2: zp ZP_WORD:2 [ main::w1#0 ] 2: zp ZP_WORD:6 [ main::w2#0 ] 
Uplift Scope [] 

Uplifting [main] best 77 combination reg byte a [ main::$0 ] reg byte a [ main::$1 ] reg byte a [ main::$2 ] reg byte a [ main::$3 ] zp ZP_WORD:2 [ main::w1#0 ] zp ZP_WORD:6 [ main::w2#0 ] 
Limited combination testing to 100 combinations of 256 possible.
Uplifting [] best 77 combination 
Allocated (was zp ZP_WORD:6) zp ZP_WORD:4 [ main::w2#0 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests a simple word array
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .const SIZEOF_WORD = 2
  // @begin
bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
  // @1
b1:
  // [2] call main 
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
main: {
    .label SCREEN = $400+6*$28
    .label words = $400
    .label w1 = 2
    .label w2 = 4
    // [4] (word) main::w1#0 ← *((const word[3]) main::words#0+(byte) 1*(const byte) SIZEOF_WORD) -- vwuz1=_deref_pwuc1 
    lda words+1*SIZEOF_WORD
    sta w1
    lda words+1*SIZEOF_WORD+1
    sta w1+1
    // [5] (byte~) main::$0 ← < (word) main::w1#0 -- vbuaa=_lo_vwuz1 
    lda w1
    // [6] *((const byte*) main::SCREEN#0) ← (byte~) main::$0 -- _deref_pbuc1=vbuaa 
    sta SCREEN
    // [7] (byte~) main::$1 ← > (word) main::w1#0 -- vbuaa=_hi_vwuz1 
    lda w1+1
    // [8] *((const byte*) main::SCREEN#0+(byte) 1) ← (byte~) main::$1 -- _deref_pbuc1=vbuaa 
    sta SCREEN+1
    // [9] (word) main::w2#0 ← *((const word[3]) main::words#0+(byte) 2*(const byte) SIZEOF_WORD) -- vwuz1=_deref_pwuc1 
    lda words+2*SIZEOF_WORD
    sta w2
    lda words+2*SIZEOF_WORD+1
    sta w2+1
    // [10] (byte~) main::$2 ← < (word) main::w2#0 -- vbuaa=_lo_vwuz1 
    lda w2
    // [11] *((const byte*) main::SCREEN#0+(byte) 2) ← (byte~) main::$2 -- _deref_pbuc1=vbuaa 
    sta SCREEN+2
    // [12] (byte~) main::$3 ← > (word) main::w2#0 -- vbuaa=_hi_vwuz1 
    lda w2+1
    // [13] *((const byte*) main::SCREEN#0+(byte) 3) ← (byte~) main::$3 -- _deref_pbuc1=vbuaa 
    sta SCREEN+3
    jmp breturn
    // main::@return
  breturn:
    // [14] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction bend_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(const byte) SIZEOF_WORD SIZEOF_WORD = (byte) 2
(void()) main()
(byte~) main::$0 reg byte a 4.0
(byte~) main::$1 reg byte a 4.0
(byte~) main::$2 reg byte a 4.0
(byte~) main::$3 reg byte a 4.0
(label) main::@return
(byte*) main::SCREEN
(const byte*) main::SCREEN#0 SCREEN = (byte*)(number) $400+(number) 6*(number) $28
(word) main::w1
(word) main::w1#0 w1 zp ZP_WORD:2 2.0
(word) main::w2
(word) main::w2#0 w2 zp ZP_WORD:4 2.0
(word[3]) main::words
(const word[3]) main::words#0 words = (word*) 1024

zp ZP_WORD:2 [ main::w1#0 ]
reg byte a [ main::$0 ]
reg byte a [ main::$1 ]
zp ZP_WORD:4 [ main::w2#0 ]
reg byte a [ main::$2 ]
reg byte a [ main::$3 ]


FINAL ASSEMBLER
Score: 62

  // File Comments
// Tests a simple word array
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .const SIZEOF_WORD = 2
  // @begin
  // [1] phi from @begin to @1 [phi:@begin->@1]
  // @1
  // [2] call main 
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    .label SCREEN = $400+6*$28
    .label words = $400
    .label w1 = 2
    .label w2 = 4
    // w1 = words[1]
    // [4] (word) main::w1#0 ← *((const word[3]) main::words#0+(byte) 1*(const byte) SIZEOF_WORD) -- vwuz1=_deref_pwuc1 
    lda words+1*SIZEOF_WORD
    sta w1
    lda words+1*SIZEOF_WORD+1
    sta w1+1
    // <w1
    // [5] (byte~) main::$0 ← < (word) main::w1#0 -- vbuaa=_lo_vwuz1 
    lda w1
    // SCREEN[0] = <w1
    // [6] *((const byte*) main::SCREEN#0) ← (byte~) main::$0 -- _deref_pbuc1=vbuaa 
    sta SCREEN
    // >w1
    // [7] (byte~) main::$1 ← > (word) main::w1#0 -- vbuaa=_hi_vwuz1 
    lda w1+1
    // SCREEN[1] = >w1
    // [8] *((const byte*) main::SCREEN#0+(byte) 1) ← (byte~) main::$1 -- _deref_pbuc1=vbuaa 
    sta SCREEN+1
    // w2 = words[2]
    // [9] (word) main::w2#0 ← *((const word[3]) main::words#0+(byte) 2*(const byte) SIZEOF_WORD) -- vwuz1=_deref_pwuc1 
    lda words+2*SIZEOF_WORD
    sta w2
    lda words+2*SIZEOF_WORD+1
    sta w2+1
    // <w2
    // [10] (byte~) main::$2 ← < (word) main::w2#0 -- vbuaa=_lo_vwuz1 
    lda w2
    // SCREEN[2] = <w2
    // [11] *((const byte*) main::SCREEN#0+(byte) 2) ← (byte~) main::$2 -- _deref_pbuc1=vbuaa 
    sta SCREEN+2
    // >w2
    // [12] (byte~) main::$3 ← > (word) main::w2#0 -- vbuaa=_hi_vwuz1 
    lda w2+1
    // SCREEN[3] = >w2
    // [13] *((const byte*) main::SCREEN#0+(byte) 3) ← (byte~) main::$3 -- _deref_pbuc1=vbuaa 
    sta SCREEN+3
    // main::@return
    // }
    // [14] return 
    rts
}
  // File Data

