Identified constant variable (byte*) SCREEN
Identified constant variable (word) w::w1
Identified constant variable (word) w::w2
Culled Empty Block (label) @1
Culled Empty Block (label) w::@2

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) SCREEN#0 ← ((byte*)) (number) $400
  (byte*~) $0 ← (byte*) SCREEN#0 + (number) $28*(number) 3
  (byte*) SCREEN2#0 ← (byte*~) $0
  (byte*~) $1 ← (byte*) SCREEN#0 + (number) $28*(number) 6
  (byte*) SCREEN3#0 ← (byte*~) $1
  (byte*~) $2 ← (byte*) SCREEN#0 + (number) $28*(number) 9
  (byte*) SCREEN4#0 ← (byte*~) $2
  to:@2
main: scope:[main]  from @2
  (byte*) SCREEN4#5 ← phi( @2/(byte*) SCREEN4#6 )
  (byte*) SCREEN3#5 ← phi( @2/(byte*) SCREEN3#6 )
  (byte*) SCREEN2#2 ← phi( @2/(byte*) SCREEN2#3 )
  (byte) main::b#0 ← (byte) 0
  to:main::@1
main::@1: scope:[main]  from main main::@1
  (byte*) SCREEN4#4 ← phi( main/(byte*) SCREEN4#5 main::@1/(byte*) SCREEN4#4 )
  (byte*) SCREEN3#4 ← phi( main/(byte*) SCREEN3#5 main::@1/(byte*) SCREEN3#4 )
  (byte*) SCREEN2#1 ← phi( main/(byte*) SCREEN2#2 main::@1/(byte*) SCREEN2#1 )
  (byte) main::b#2 ← phi( main/(byte) main::b#0 main::@1/(byte) main::b#1 )
  (number~) main::$1 ← (number) $c8 - (byte) main::b#2
  (byte) main::b2#0 ← (number~) main::$1
  *((byte*) SCREEN#0 + (byte) main::b#2) ← (byte) main::b2#0
  (signed byte~) main::$2 ← ((signed byte)) (byte) main::b#2
  (signed byte~) main::$3 ← - (signed byte~) main::$2
  (signed byte) main::sb#0 ← (signed byte~) main::$3
  (byte~) main::$4 ← ((byte)) (signed byte) main::sb#0
  *((byte*) SCREEN2#1 + (byte) main::b#2) ← (byte~) main::$4
  (byte) main::b#1 ← (byte) main::b#2 + rangenext(0,$64)
  (bool~) main::$5 ← (byte) main::b#1 != rangelast(0,$64)
  if((bool~) main::$5) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1
  (byte*) SCREEN4#3 ← phi( main::@1/(byte*) SCREEN4#4 )
  (byte*) SCREEN3#3 ← phi( main::@1/(byte*) SCREEN3#4 )
  call w 
  to:main::@3
main::@3: scope:[main]  from main::@2
  to:main::@return
main::@return: scope:[main]  from main::@3
  return 
  to:@return
w: scope:[w]  from main::@2
  (byte*) SCREEN4#2 ← phi( main::@2/(byte*) SCREEN4#3 )
  (byte*) SCREEN3#2 ← phi( main::@2/(byte*) SCREEN3#3 )
  (byte) w::i#0 ← (byte) 0
  to:w::@1
w::@1: scope:[w]  from w w::@1
  (byte*) SCREEN4#1 ← phi( w/(byte*) SCREEN4#2 w::@1/(byte*) SCREEN4#1 )
  (byte*) SCREEN3#1 ← phi( w/(byte*) SCREEN3#2 w::@1/(byte*) SCREEN3#1 )
  (byte) w::i#2 ← phi( w/(byte) w::i#0 w::@1/(byte) w::i#1 )
  (word) w::w1#0 ← (number) $514
  (word) w::w2#0 ← (number) $4e2
  (word~) w::$0 ← (word) w::w1#0 - (word) w::w2#0
  (byte~) w::$1 ← ((byte)) (word~) w::$0
  (byte) w::b#0 ← (byte~) w::$1
  (number~) w::$2 ← (number) $578-(number) $546 + (byte) w::i#2
  (byte) w::b2#0 ← (number~) w::$2
  *((byte*) SCREEN3#1 + (byte) w::i#2) ← (byte) w::b#0
  *((byte*) SCREEN4#1 + (byte) w::i#2) ← (byte) w::b2#0
  (byte) w::i#1 ← (byte) w::i#2 + rangenext(0,$a)
  (bool~) w::$3 ← (byte) w::i#1 != rangelast(0,$a)
  if((bool~) w::$3) goto w::@1
  to:w::@return
w::@return: scope:[w]  from w::@1
  return 
  to:@return
@2: scope:[]  from @begin
  (byte*) SCREEN4#6 ← phi( @begin/(byte*) SCREEN4#0 )
  (byte*) SCREEN3#6 ← phi( @begin/(byte*) SCREEN3#0 )
  (byte*) SCREEN2#3 ← phi( @begin/(byte*) SCREEN2#0 )
  call main 
  to:@3
@3: scope:[]  from @2
  to:@end
@end: scope:[]  from @3

SYMBOL TABLE SSA
(byte*~) $0
(byte*~) $1
(byte*~) $2
(label) @2
(label) @3
(label) @begin
(label) @end
(byte*) SCREEN
(byte*) SCREEN#0
(byte*) SCREEN2
(byte*) SCREEN2#0
(byte*) SCREEN2#1
(byte*) SCREEN2#2
(byte*) SCREEN2#3
(byte*) SCREEN3
(byte*) SCREEN3#0
(byte*) SCREEN3#1
(byte*) SCREEN3#2
(byte*) SCREEN3#3
(byte*) SCREEN3#4
(byte*) SCREEN3#5
(byte*) SCREEN3#6
(byte*) SCREEN4
(byte*) SCREEN4#0
(byte*) SCREEN4#1
(byte*) SCREEN4#2
(byte*) SCREEN4#3
(byte*) SCREEN4#4
(byte*) SCREEN4#5
(byte*) SCREEN4#6
(void()) main()
(number~) main::$1
(signed byte~) main::$2
(signed byte~) main::$3
(byte~) main::$4
(bool~) main::$5
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte) main::b
(byte) main::b#0
(byte) main::b#1
(byte) main::b#2
(byte) main::b2
(byte) main::b2#0
(signed byte) main::sb
(signed byte) main::sb#0
(void()) w()
(word~) w::$0
(byte~) w::$1
(number~) w::$2
(bool~) w::$3
(label) w::@1
(label) w::@return
(byte) w::b
(byte) w::b#0
(byte) w::b2
(byte) w::b2#0
(byte) w::i
(byte) w::i#0
(byte) w::i#1
(byte) w::i#2
(word) w::w1
(word) w::w1#0
(word) w::w2
(word) w::w2#0

Adding number conversion cast (unumber) $28*3 in (byte*~) $0 ← (byte*) SCREEN#0 + (number) $28*(number) 3
Adding number conversion cast (unumber) $28*6 in (byte*~) $1 ← (byte*) SCREEN#0 + (number) $28*(number) 6
Adding number conversion cast (unumber) $28*9 in (byte*~) $2 ← (byte*) SCREEN#0 + (number) $28*(number) 9
Adding number conversion cast (unumber) $c8 in (number~) main::$1 ← (number) $c8 - (byte) main::b#2
Adding number conversion cast (unumber) main::$1 in (number~) main::$1 ← (unumber)(number) $c8 - (byte) main::b#2
Adding number conversion cast (unumber) $514 in (word) w::w1#0 ← (number) $514
Adding number conversion cast (unumber) $4e2 in (word) w::w2#0 ← (number) $4e2
Adding number conversion cast (unumber) $578-$546 in (number~) w::$2 ← (number) $578-(number) $546 + (byte) w::i#2
Adding number conversion cast (unumber) w::$2 in (number~) w::$2 ← (unumber)(number) $578-(number) $546 + (byte) w::i#2
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
Inlining cast (signed byte~) main::$2 ← (signed byte)(byte) main::b#2
Inlining cast (byte~) main::$4 ← (byte)(signed byte) main::sb#0
Inlining cast (word) w::w1#0 ← (unumber)(number) $514
Inlining cast (word) w::w2#0 ← (unumber)(number) $4e2
Inlining cast (byte~) w::$1 ← (byte)(word~) w::$0
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast $c8
Simplifying constant integer cast $514
Simplifying constant integer cast $4e2
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $c8
Finalized unsigned number type (word) $514
Finalized unsigned number type (word) $4e2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) main::$1 ← (byte) $c8 - (byte) main::b#2
Inferred type updated to byte in (unumber~) w::$2 ← (byte)(number) $578-(number) $546 + (byte) w::i#2
Alias (byte*) SCREEN2#0 = (byte*~) $0 (byte*) SCREEN2#3 
Alias (byte*) SCREEN3#0 = (byte*~) $1 (byte*) SCREEN3#6 
Alias (byte*) SCREEN4#0 = (byte*~) $2 (byte*) SCREEN4#6 
Alias (byte) main::b2#0 = (byte~) main::$1 
Alias (signed byte) main::sb#0 = (signed byte~) main::$3 
Alias (byte*) SCREEN3#3 = (byte*) SCREEN3#4 
Alias (byte*) SCREEN4#3 = (byte*) SCREEN4#4 
Alias (byte) w::b#0 = (byte~) w::$1 
Alias (byte) w::b2#0 = (byte~) w::$2 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte*) SCREEN2#2 (byte*) SCREEN2#0
Identical Phi Values (byte*) SCREEN3#5 (byte*) SCREEN3#0
Identical Phi Values (byte*) SCREEN4#5 (byte*) SCREEN4#0
Identical Phi Values (byte*) SCREEN2#1 (byte*) SCREEN2#2
Identical Phi Values (byte*) SCREEN3#3 (byte*) SCREEN3#5
Identical Phi Values (byte*) SCREEN4#3 (byte*) SCREEN4#5
Identical Phi Values (byte*) SCREEN3#2 (byte*) SCREEN3#3
Identical Phi Values (byte*) SCREEN4#2 (byte*) SCREEN4#3
Identical Phi Values (byte*) SCREEN3#1 (byte*) SCREEN3#2
Identical Phi Values (byte*) SCREEN4#1 (byte*) SCREEN4#2
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$5 [20] if((byte) main::b#1!=rangelast(0,$64)) goto main::@1
Simple Condition (bool~) w::$3 [38] if((byte) w::i#1!=rangelast(0,$a)) goto w::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) SCREEN#0 = (byte*) 1024
Constant (const byte) main::b#0 = 0
Constant (const byte) w::i#0 = 0
Constant (const word) w::w1#0 = $514
Constant (const word) w::w2#0 = $4e2
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [18] main::b#1 ← ++ main::b#2 to ++
Resolved ranged comparison value [20] if(main::b#1!=rangelast(0,$64)) goto main::@1 to (number) $65
Resolved ranged next value [36] w::i#1 ← ++ w::i#2 to ++
Resolved ranged comparison value [38] if(w::i#1!=rangelast(0,$a)) goto w::@1 to (number) $b
Adding number conversion cast (unumber) $65 in if((byte) main::b#1!=(number) $65) goto main::@1
Adding number conversion cast (unumber) $b in if((byte) w::i#1!=(number) $b) goto w::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast $65
Simplifying constant integer cast $b
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $65
Finalized unsigned number type (byte) $b
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant right-side identified [0] (byte*) SCREEN2#0 ← (const byte*) SCREEN#0 + (byte)(number) $28*(number) 3
Constant right-side identified [1] (byte*) SCREEN3#0 ← (const byte*) SCREEN#0 + (byte)(number) $28*(number) 6
Constant right-side identified [2] (byte*) SCREEN4#0 ← (const byte*) SCREEN#0 + (word)(number) $28*(number) 9
Constant right-side identified [15] (word~) w::$0 ← (const word) w::w1#0 - (const word) w::w2#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) SCREEN2#0 = SCREEN#0+(byte)$28*3
Constant (const byte*) SCREEN3#0 = SCREEN#0+(byte)$28*6
Constant (const byte*) SCREEN4#0 = SCREEN#0+(word)$28*9
Constant (const word) w::$0 = w::w1#0-w::w2#0
Successful SSA optimization Pass2ConstantIdentification
Constant value identified (byte)w::$0 in [16] (byte) w::b#0 ← (byte)(const word) w::$0
Successful SSA optimization Pass2ConstantValues
Constant (const byte) w::b#0 = (byte)w::$0
Successful SSA optimization Pass2ConstantIdentification
Inlining Noop Cast [3] (signed byte~) main::$2 ← (signed byte)(byte) main::b#2 keeping main::b#2
Inlining Noop Cast [5] (byte~) main::$4 ← (byte)(signed byte) main::sb#0 keeping main::sb#0
Successful SSA optimization Pass2NopCastInlining
Inlining constant with var siblings (const byte) main::b#0
Inlining constant with var siblings (const byte) w::i#0
Constant inlined w::i#0 = (byte) 0
Constant inlined w::$0 = (const word) w::w1#0-(const word) w::w2#0
Constant inlined main::b#0 = (byte) 0
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@4(between main::@1 and main::@1)
Added new block during phi lifting w::@3(between w::@1 and w::@1)
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @3
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@2
Adding NOP phi() at start of main::@3
Adding NOP phi() at start of w
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to w:14 

Created 2 initial phi equivalence classes
Coalesced [17] main::b#3 ← main::b#1
Coalesced [26] w::i#3 ← w::i#1
Coalesced down to 2 phi equivalence classes
Culled Empty Block (label) @3
Culled Empty Block (label) main::@3
Culled Empty Block (label) main::@4
Culled Empty Block (label) w::@3
Renumbering block @2 to @1
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
Adding NOP phi() at start of main::@2
Adding NOP phi() at start of w

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::b#2 ← phi( main/(byte) 0 main::@1/(byte) main::b#1 )
  [6] (byte) main::b2#0 ← (byte) $c8 - (byte) main::b#2
  [7] *((const byte*) SCREEN#0 + (byte) main::b#2) ← (byte) main::b2#0
  [8] (signed byte) main::sb#0 ← - (signed byte)(byte) main::b#2
  [9] *((const byte*) SCREEN2#0 + (byte) main::b#2) ← (byte)(signed byte) main::sb#0
  [10] (byte) main::b#1 ← ++ (byte) main::b#2
  [11] if((byte) main::b#1!=(byte) $65) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1
  [12] phi()
  [13] call w 
  to:main::@return
main::@return: scope:[main]  from main::@2
  [14] return 
  to:@return
w: scope:[w]  from main::@2
  [15] phi()
  to:w::@1
w::@1: scope:[w]  from w w::@1
  [16] (byte) w::i#2 ← phi( w/(byte) 0 w::@1/(byte) w::i#1 )
  [17] (byte) w::b2#0 ← (byte)(number) $578-(number) $546 + (byte) w::i#2
  [18] *((const byte*) SCREEN3#0 + (byte) w::i#2) ← (const byte) w::b#0
  [19] *((const byte*) SCREEN4#0 + (byte) w::i#2) ← (byte) w::b2#0
  [20] (byte) w::i#1 ← ++ (byte) w::i#2
  [21] if((byte) w::i#1!=(byte) $b) goto w::@1
  to:w::@return
w::@return: scope:[w]  from w::@1
  [22] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte*) SCREEN
(byte*) SCREEN2
(byte*) SCREEN3
(byte*) SCREEN4
(void()) main()
(byte) main::b
(byte) main::b#1 16.5
(byte) main::b#2 11.0
(byte) main::b2
(byte) main::b2#0 22.0
(signed byte) main::sb
(signed byte) main::sb#0 11.0
(void()) w()
(byte) w::b
(byte) w::b2
(byte) w::b2#0 11.0
(byte) w::i
(byte) w::i#1 16.5
(byte) w::i#2 13.75
(word) w::w1
(word) w::w2

Initial phi equivalence classes
[ main::b#2 main::b#1 ]
[ w::i#2 w::i#1 ]
Added variable main::b2#0 to zero page equivalence class [ main::b2#0 ]
Added variable main::sb#0 to zero page equivalence class [ main::sb#0 ]
Added variable w::b2#0 to zero page equivalence class [ w::b2#0 ]
Complete equivalence classes
[ main::b#2 main::b#1 ]
[ w::i#2 w::i#1 ]
[ main::b2#0 ]
[ main::sb#0 ]
[ w::b2#0 ]
Allocated zp ZP_BYTE:2 [ main::b#2 main::b#1 ]
Allocated zp ZP_BYTE:3 [ w::i#2 w::i#1 ]
Allocated zp ZP_BYTE:4 [ main::b2#0 ]
Allocated zp ZP_BYTE:5 [ main::sb#0 ]
Allocated zp ZP_BYTE:6 [ w::b2#0 ]

INITIAL ASM
Target platform is c64basic
  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  .label SCREEN2 = SCREEN+$28*3
  .label SCREEN3 = SCREEN+$28*6
  .label SCREEN4 = SCREEN+$28*9
  // @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 b2 = 4
    .label sb = 5
    .label b = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [5] phi (byte) main::b#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z b
    jmp b1
    // [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
    // [5] phi (byte) main::b#2 = (byte) main::b#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] (byte) main::b2#0 ← (byte) $c8 - (byte) main::b#2 -- vbuz1=vbuc1_minus_vbuz2 
    lda #$c8
    sec
    sbc.z b
    sta.z b2
    // [7] *((const byte*) SCREEN#0 + (byte) main::b#2) ← (byte) main::b2#0 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda.z b2
    ldy.z b
    sta SCREEN,y
    // [8] (signed byte) main::sb#0 ← - (signed byte)(byte) main::b#2 -- vbsz1=_neg_vbsz2 
    lda.z b
    eor #$ff
    clc
    adc #1
    sta.z sb
    // [9] *((const byte*) SCREEN2#0 + (byte) main::b#2) ← (byte)(signed byte) main::sb#0 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda.z sb
    ldy.z b
    sta SCREEN2,y
    // [10] (byte) main::b#1 ← ++ (byte) main::b#2 -- vbuz1=_inc_vbuz1 
    inc.z b
    // [11] if((byte) main::b#1!=(byte) $65) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #$65
    cmp.z b
    bne b1_from_b1
    // [12] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
    jmp b2
    // main::@2
  b2:
    // [13] call w 
    // [15] phi from main::@2 to w [phi:main::@2->w]
  w_from_b2:
    jsr w
    jmp breturn
    // main::@return
  breturn:
    // [14] return 
    rts
}
  // w
w: {
    .const w1 = $514
    .const w2 = $4e2
    .const b = w1-w2
    .label b2 = 6
    .label i = 3
    // [16] phi from w to w::@1 [phi:w->w::@1]
  b1_from_w:
    // [16] phi (byte) w::i#2 = (byte) 0 [phi:w->w::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z i
    jmp b1
    // [16] phi from w::@1 to w::@1 [phi:w::@1->w::@1]
  b1_from_b1:
    // [16] phi (byte) w::i#2 = (byte) w::i#1 [phi:w::@1->w::@1#0] -- register_copy 
    jmp b1
    // w::@1
  b1:
    // [17] (byte) w::b2#0 ← (byte)(number) $578-(number) $546 + (byte) w::i#2 -- vbuz1=vbuc1_plus_vbuz2 
    lax.z i
    axs #-[$578-$546]
    stx.z b2
    // [18] *((const byte*) SCREEN3#0 + (byte) w::i#2) ← (const byte) w::b#0 -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #b
    ldy.z i
    sta SCREEN3,y
    // [19] *((const byte*) SCREEN4#0 + (byte) w::i#2) ← (byte) w::b2#0 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda.z b2
    ldy.z i
    sta SCREEN4,y
    // [20] (byte) w::i#1 ← ++ (byte) w::i#2 -- vbuz1=_inc_vbuz1 
    inc.z i
    // [21] if((byte) w::i#1!=(byte) $b) goto w::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #$b
    cmp.z i
    bne b1_from_b1
    jmp breturn
    // w::@return
  breturn:
    // [22] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] (byte) main::b2#0 ← (byte) $c8 - (byte) main::b#2 [ main::b#2 main::b2#0 ] ( main:2 [ main::b#2 main::b2#0 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::b#2 main::b#1 ]
Statement [8] (signed byte) main::sb#0 ← - (signed byte)(byte) main::b#2 [ main::b#2 main::sb#0 ] ( main:2 [ main::b#2 main::sb#0 ] ) always clobbers reg byte a 
Statement [18] *((const byte*) SCREEN3#0 + (byte) w::i#2) ← (const byte) w::b#0 [ w::i#2 w::b2#0 ] ( main:2::w:13 [ w::i#2 w::b2#0 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:3 [ w::i#2 w::i#1 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:6 [ w::b2#0 ]
Statement [19] *((const byte*) SCREEN4#0 + (byte) w::i#2) ← (byte) w::b2#0 [ w::i#2 ] ( main:2::w:13 [ w::i#2 ] ) always clobbers reg byte a 
Statement [6] (byte) main::b2#0 ← (byte) $c8 - (byte) main::b#2 [ main::b#2 main::b2#0 ] ( main:2 [ main::b#2 main::b2#0 ] ) always clobbers reg byte a 
Statement [8] (signed byte) main::sb#0 ← - (signed byte)(byte) main::b#2 [ main::b#2 main::sb#0 ] ( main:2 [ main::b#2 main::sb#0 ] ) always clobbers reg byte a 
Statement [17] (byte) w::b2#0 ← (byte)(number) $578-(number) $546 + (byte) w::i#2 [ w::i#2 w::b2#0 ] ( main:2::w:13 [ w::i#2 w::b2#0 ] ) always clobbers reg byte a 
Statement [18] *((const byte*) SCREEN3#0 + (byte) w::i#2) ← (const byte) w::b#0 [ w::i#2 w::b2#0 ] ( main:2::w:13 [ w::i#2 w::b2#0 ] ) always clobbers reg byte a 
Statement [19] *((const byte*) SCREEN4#0 + (byte) w::i#2) ← (byte) w::b2#0 [ w::i#2 ] ( main:2::w:13 [ w::i#2 ] ) always clobbers reg byte a 
Potential registers zp ZP_BYTE:2 [ main::b#2 main::b#1 ] : zp ZP_BYTE:2 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:3 [ w::i#2 w::i#1 ] : zp ZP_BYTE:3 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:4 [ main::b2#0 ] : zp ZP_BYTE:4 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:5 [ main::sb#0 ] : zp ZP_BYTE:5 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:6 [ w::b2#0 ] : zp ZP_BYTE:6 , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 27.5: zp ZP_BYTE:2 [ main::b#2 main::b#1 ] 22: zp ZP_BYTE:4 [ main::b2#0 ] 11: zp ZP_BYTE:5 [ main::sb#0 ] 
Uplift Scope [w] 30.25: zp ZP_BYTE:3 [ w::i#2 w::i#1 ] 11: zp ZP_BYTE:6 [ w::b2#0 ] 
Uplift Scope [] 

Uplifting [main] best 996 combination reg byte x [ main::b#2 main::b#1 ] reg byte a [ main::b2#0 ] reg byte a [ main::sb#0 ] 
Uplifting [w] best 816 combination reg byte y [ w::i#2 w::i#1 ] reg byte x [ w::b2#0 ] 
Uplifting [] best 816 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  .label SCREEN2 = SCREEN+$28*3
  .label SCREEN3 = SCREEN+$28*6
  .label SCREEN4 = SCREEN+$28*9
  // @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: {
    // [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [5] phi (byte) main::b#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::b#2 = (byte) main::b#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] (byte) main::b2#0 ← (byte) $c8 - (byte) main::b#2 -- vbuaa=vbuc1_minus_vbuxx 
    txa
    eor #$ff
    clc
    adc #$c8+1
    // [7] *((const byte*) SCREEN#0 + (byte) main::b#2) ← (byte) main::b2#0 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN,x
    // [8] (signed byte) main::sb#0 ← - (signed byte)(byte) main::b#2 -- vbsaa=_neg_vbsxx 
    txa
    eor #$ff
    clc
    adc #1
    // [9] *((const byte*) SCREEN2#0 + (byte) main::b#2) ← (byte)(signed byte) main::sb#0 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN2,x
    // [10] (byte) main::b#1 ← ++ (byte) main::b#2 -- vbuxx=_inc_vbuxx 
    inx
    // [11] if((byte) main::b#1!=(byte) $65) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$65
    bne b1_from_b1
    // [12] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
    jmp b2
    // main::@2
  b2:
    // [13] call w 
    // [15] phi from main::@2 to w [phi:main::@2->w]
  w_from_b2:
    jsr w
    jmp breturn
    // main::@return
  breturn:
    // [14] return 
    rts
}
  // w
w: {
    .const w1 = $514
    .const w2 = $4e2
    .const b = w1-w2
    // [16] phi from w to w::@1 [phi:w->w::@1]
  b1_from_w:
    // [16] phi (byte) w::i#2 = (byte) 0 [phi:w->w::@1#0] -- vbuyy=vbuc1 
    ldy #0
    jmp b1
    // [16] phi from w::@1 to w::@1 [phi:w::@1->w::@1]
  b1_from_b1:
    // [16] phi (byte) w::i#2 = (byte) w::i#1 [phi:w::@1->w::@1#0] -- register_copy 
    jmp b1
    // w::@1
  b1:
    // [17] (byte) w::b2#0 ← (byte)(number) $578-(number) $546 + (byte) w::i#2 -- vbuxx=vbuc1_plus_vbuyy 
    tya
    tax
    axs #-[$578-$546]
    // [18] *((const byte*) SCREEN3#0 + (byte) w::i#2) ← (const byte) w::b#0 -- pbuc1_derefidx_vbuyy=vbuc2 
    lda #b
    sta SCREEN3,y
    // [19] *((const byte*) SCREEN4#0 + (byte) w::i#2) ← (byte) w::b2#0 -- pbuc1_derefidx_vbuyy=vbuxx 
    txa
    sta SCREEN4,y
    // [20] (byte) w::i#1 ← ++ (byte) w::i#2 -- vbuyy=_inc_vbuyy 
    iny
    // [21] if((byte) w::i#1!=(byte) $b) goto w::@1 -- vbuyy_neq_vbuc1_then_la1 
    cpy #$b
    bne b1_from_b1
    jmp breturn
    // w::@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
Removing instruction jmp b1
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b1_from_b1 with b1
Replacing label b1_from_b1 with b1
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_b1:
Removing instruction w_from_b2:
Removing instruction b1_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction b2:
Removing instruction breturn:
Removing instruction b1_from_w:
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 b1
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
(byte*) SCREEN2
(const byte*) SCREEN2#0 SCREEN2 = (const byte*) SCREEN#0+(byte)(number) $28*(number) 3
(byte*) SCREEN3
(const byte*) SCREEN3#0 SCREEN3 = (const byte*) SCREEN#0+(byte)(number) $28*(number) 6
(byte*) SCREEN4
(const byte*) SCREEN4#0 SCREEN4 = (const byte*) SCREEN#0+(word)(number) $28*(number) 9
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(byte) main::b
(byte) main::b#1 reg byte x 16.5
(byte) main::b#2 reg byte x 11.0
(byte) main::b2
(byte) main::b2#0 reg byte a 22.0
(signed byte) main::sb
(signed byte) main::sb#0 reg byte a 11.0
(void()) w()
(label) w::@1
(label) w::@return
(byte) w::b
(const byte) w::b#0 b = (byte)(const word) w::w1#0-(const word) w::w2#0
(byte) w::b2
(byte) w::b2#0 reg byte x 11.0
(byte) w::i
(byte) w::i#1 reg byte y 16.5
(byte) w::i#2 reg byte y 13.75
(word) w::w1
(const word) w::w1#0 w1 = (word) $514
(word) w::w2
(const word) w::w2#0 w2 = (word) $4e2

reg byte x [ main::b#2 main::b#1 ]
reg byte y [ w::i#2 w::i#1 ]
reg byte a [ main::b2#0 ]
reg byte a [ main::sb#0 ]
reg byte x [ w::b2#0 ]


FINAL ASSEMBLER
Score: 648

  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  .label SCREEN2 = SCREEN+$28*3
  .label SCREEN3 = SCREEN+$28*6
  .label SCREEN4 = SCREEN+$28*9
  // @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: {
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // [5] phi (byte) main::b#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::b#2 = (byte) main::b#1 [phi:main::@1->main::@1#0] -- register_copy 
    // main::@1
  b1:
    // b2 = 200-b
    // [6] (byte) main::b2#0 ← (byte) $c8 - (byte) main::b#2 -- vbuaa=vbuc1_minus_vbuxx 
    txa
    eor #$ff
    clc
    adc #$c8+1
    // SCREEN[b] = b2
    // [7] *((const byte*) SCREEN#0 + (byte) main::b#2) ← (byte) main::b2#0 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN,x
    // sb = - (signed byte)b
    // [8] (signed byte) main::sb#0 ← - (signed byte)(byte) main::b#2 -- vbsaa=_neg_vbsxx 
    txa
    eor #$ff
    clc
    adc #1
    // SCREEN2[b] = (byte)sb
    // [9] *((const byte*) SCREEN2#0 + (byte) main::b#2) ← (byte)(signed byte) main::sb#0 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN2,x
    // for( byte b: 0..100)
    // [10] (byte) main::b#1 ← ++ (byte) main::b#2 -- vbuxx=_inc_vbuxx 
    inx
    // [11] if((byte) main::b#1!=(byte) $65) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$65
    bne b1
    // [12] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
    // main::@2
    // w()
    // [13] call w 
    // [15] phi from main::@2 to w [phi:main::@2->w]
    jsr w
    // main::@return
    // }
    // [14] return 
    rts
}
  // w
w: {
    .const w1 = $514
    .const w2 = $4e2
    .const b = w1-w2
    // [16] phi from w to w::@1 [phi:w->w::@1]
    // [16] phi (byte) w::i#2 = (byte) 0 [phi:w->w::@1#0] -- vbuyy=vbuc1 
    ldy #0
    // [16] phi from w::@1 to w::@1 [phi:w::@1->w::@1]
    // [16] phi (byte) w::i#2 = (byte) w::i#1 [phi:w::@1->w::@1#0] -- register_copy 
    // w::@1
  b1:
    // b2 = 1400-1350+i
    // [17] (byte) w::b2#0 ← (byte)(number) $578-(number) $546 + (byte) w::i#2 -- vbuxx=vbuc1_plus_vbuyy 
    tya
    tax
    axs #-[$578-$546]
    // SCREEN3[i] = b
    // [18] *((const byte*) SCREEN3#0 + (byte) w::i#2) ← (const byte) w::b#0 -- pbuc1_derefidx_vbuyy=vbuc2 
    lda #b
    sta SCREEN3,y
    // SCREEN4[i] = b2
    // [19] *((const byte*) SCREEN4#0 + (byte) w::i#2) ← (byte) w::b2#0 -- pbuc1_derefidx_vbuyy=vbuxx 
    txa
    sta SCREEN4,y
    // for(byte i : 0..10)
    // [20] (byte) w::i#1 ← ++ (byte) w::i#2 -- vbuyy=_inc_vbuyy 
    iny
    // [21] if((byte) w::i#1!=(byte) $b) goto w::@1 -- vbuyy_neq_vbuc1_then_la1 
    cpy #$b
    bne b1
    // w::@return
    // }
    // [22] return 
    rts
}
  // File Data

