
CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) SCREEN#0 ← ((byte*)) (word/signed word/dword/signed dword) 1024
  (byte/signed byte/word/signed word/dword/signed dword~) $0 ← (byte/signed byte/word/signed word/dword/signed dword) 40 * (byte/signed byte/word/signed word/dword/signed dword) 3
  (byte*~) $1 ← (byte*) SCREEN#0 + (byte/signed byte/word/signed word/dword/signed dword~) $0
  (byte*) SCREEN2#0 ← (byte*~) $1
  (byte/word/signed word/dword/signed dword~) $2 ← (byte/signed byte/word/signed word/dword/signed dword) 40 * (byte/signed byte/word/signed word/dword/signed dword) 6
  (byte*~) $3 ← (byte*) SCREEN#0 + (byte/word/signed word/dword/signed dword~) $2
  (byte*) SCREEN3#0 ← (byte*~) $3
  (word/signed word/dword/signed dword~) $4 ← (byte/signed byte/word/signed word/dword/signed dword) 40 * (byte/signed byte/word/signed word/dword/signed dword) 9
  (byte*~) $5 ← (byte*) SCREEN#0 + (word/signed word/dword/signed dword~) $4
  (byte*) SCREEN4#0 ← (byte*~) $5
  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*) SCREEN#2 ← phi( @2/(byte*) SCREEN#3 )
  (byte) main::b#0 ← (byte/signed byte/word/signed word/dword/signed dword) 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*) SCREEN#1 ← phi( main/(byte*) SCREEN#2 main::@1/(byte*) SCREEN#1 )
  (byte) main::b#2 ← phi( main/(byte) main::b#0 main::@1/(byte) main::b#1 )
  (byte/word/signed word/dword/signed dword~) main::$0 ← (byte/word/signed word/dword/signed dword) 200 - (byte) main::b#2
  (byte) main::b2#0 ← (byte/word/signed word/dword/signed dword~) main::$0
  *((byte*) SCREEN#1 + (byte) main::b#2) ← (byte) main::b2#0
  (signed byte~) main::$1 ← ((signed byte)) (byte) main::b#2
  (signed byte~) main::$2 ← - (signed byte~) main::$1
  (signed byte) main::sb#0 ← (signed byte~) main::$2
  (byte~) main::$3 ← ((byte)) (signed byte) main::sb#0
  *((byte*) SCREEN2#1 + (byte) main::b#2) ← (byte~) main::$3
  (byte) main::b#1 ← (byte) main::b#2 + rangenext(0,100)
  (bool~) main::$4 ← (byte) main::b#1 != rangelast(0,100)
  if((bool~) main::$4) 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/signed byte/word/signed word/dword/signed dword) 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 ← (word/signed word/dword/signed dword) 1300
  (word) w::w2#0 ← (word/signed word/dword/signed dword) 1250
  (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
  (byte/signed byte/word/signed word/dword/signed dword~) w::$2 ← (word/signed word/dword/signed dword) 1400 - (word/signed word/dword/signed dword) 1350
  (byte/signed word/word/dword/signed dword~) w::$3 ← (byte/signed byte/word/signed word/dword/signed dword~) w::$2 + (byte) w::i#2
  (byte) w::b2#0 ← (byte/signed word/word/dword/signed dword~) w::$3
  *((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,10)
  (bool~) w::$4 ← (byte) w::i#1 != rangelast(0,10)
  if((bool~) w::$4) 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 )
  (byte*) SCREEN#3 ← phi( @begin/(byte*) SCREEN#0 )
  call main 
  to:@3
@3: scope:[]  from @2
  to:@end
@end: scope:[]  from @3

SYMBOL TABLE SSA
(byte/signed byte/word/signed word/dword/signed dword~) $0
(byte*~) $1
(byte/word/signed word/dword/signed dword~) $2
(byte*~) $3
(word/signed word/dword/signed dword~) $4
(byte*~) $5
(label) @2
(label) @3
(label) @begin
(label) @end
(byte*) SCREEN
(byte*) SCREEN#0
(byte*) SCREEN#1
(byte*) SCREEN#2
(byte*) SCREEN#3
(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()
(byte/word/signed word/dword/signed dword~) main::$0
(signed byte~) main::$1
(signed byte~) main::$2
(byte~) main::$3
(bool~) main::$4
(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
(byte/signed byte/word/signed word/dword/signed dword~) w::$2
(byte/signed word/word/dword/signed dword~) w::$3
(bool~) w::$4
(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

Culled Empty Block (label) main::@3
Culled Empty Block (label) @3
Successful SSA optimization Pass2CullEmptyBlocks
Alias (byte*) SCREEN2#0 = (byte*~) $1 (byte*) SCREEN2#3 
Alias (byte*) SCREEN3#0 = (byte*~) $3 (byte*) SCREEN3#6 
Alias (byte*) SCREEN4#0 = (byte*~) $5 (byte*) SCREEN4#6 
Alias (byte) main::b2#0 = (byte/word/signed word/dword/signed dword~) main::$0 
Alias (signed byte) main::sb#0 = (signed byte~) main::$2 
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/signed word/word/dword/signed dword~) w::$3 
Alias (byte*) SCREEN#0 = (byte*) SCREEN#3 
Successful SSA optimization Pass2AliasElimination
Self Phi Eliminated (byte*) SCREEN#1
Self Phi Eliminated (byte*) SCREEN2#1
Self Phi Eliminated (byte*) SCREEN3#3
Self Phi Eliminated (byte*) SCREEN4#3
Self Phi Eliminated (byte*) SCREEN3#1
Self Phi Eliminated (byte*) SCREEN4#1
Successful SSA optimization Pass2SelfPhiElimination
Redundant Phi (byte*) SCREEN#2 (byte*) SCREEN#0
Redundant Phi (byte*) SCREEN2#2 (byte*) SCREEN2#0
Redundant Phi (byte*) SCREEN3#5 (byte*) SCREEN3#0
Redundant Phi (byte*) SCREEN4#5 (byte*) SCREEN4#0
Redundant Phi (byte*) SCREEN#1 (byte*) SCREEN#2
Redundant Phi (byte*) SCREEN2#1 (byte*) SCREEN2#2
Redundant Phi (byte*) SCREEN3#3 (byte*) SCREEN3#5
Redundant Phi (byte*) SCREEN4#3 (byte*) SCREEN4#5
Redundant Phi (byte*) SCREEN3#2 (byte*) SCREEN3#3
Redundant Phi (byte*) SCREEN4#2 (byte*) SCREEN4#3
Redundant Phi (byte*) SCREEN3#1 (byte*) SCREEN3#2
Redundant Phi (byte*) SCREEN4#1 (byte*) SCREEN4#2
Successful SSA optimization Pass2RedundantPhiElimination
Simple Condition (bool~) main::$4 [23] if((byte) main::b#1!=rangelast(0,100)) goto main::@1
Simple Condition (bool~) w::$4 [42] if((byte) w::i#1!=rangelast(0,10)) goto w::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) SCREEN#0 = ((byte*))1024
Constant (const byte/signed byte/word/signed word/dword/signed dword) $0 = 40*3
Constant (const byte/word/signed word/dword/signed dword) $2 = 40*6
Constant (const word/signed word/dword/signed dword) $4 = 40*9
Constant (const byte) main::b#0 = 0
Constant (const byte) w::i#0 = 0
Constant (const word) w::w1#0 = 1300
Constant (const word) w::w2#0 = 1250
Constant (const byte/signed byte/word/signed word/dword/signed dword) w::$2 = 1400-1350
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte*) SCREEN2#0 = SCREEN#0+$0
Constant (const byte*) SCREEN3#0 = SCREEN#0+$2
Constant (const byte*) SCREEN4#0 = SCREEN#0+$4
Constant (const word) w::$0 = w::w1#0-w::w2#0
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte) w::b#0 = ((byte))w::$0
Successful SSA optimization Pass2ConstantIdentification
Eliminating Noop Cast (signed byte~) main::$1 ← ((signed byte)) (byte) main::b#2
Eliminating Noop Cast (byte~) main::$3 ← ((byte)) (signed byte) main::sb#0
Successful SSA optimization Pass2NopCastElimination
Resolved ranged next value main::b#1 ← ++ main::b#2 to ++
Resolved ranged comparison value if(main::b#1!=rangelast(0,100)) goto main::@1 to (byte/signed byte/word/signed word/dword/signed dword) 101
Resolved ranged next value w::i#1 ← ++ w::i#2 to ++
Resolved ranged comparison value if(w::i#1!=rangelast(0,10)) goto w::@1 to (byte/signed byte/word/signed word/dword/signed dword) 11
Inlining constant with var siblings (const byte) main::b#0
Inlining constant with var siblings (const byte) w::i#0
Constant inlined $4 = (byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 9
Constant inlined w::i#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Constant inlined main::b#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Constant inlined w::$0 = (const word) w::w1#0-(const word) w::w2#0
Constant inlined $0 = (byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 3
Constant inlined w::$2 = (word/signed word/dword/signed dword) 1400-(word/signed word/dword/signed dword) 1350
Constant inlined $2 = (byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 6
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 @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@2
Adding NOP phi() at start of w
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to w:13 

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

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi()
  to:@2
@2: scope:[]  from @begin
  [1] phi()
  [2] call main 
  to:@end
@end: scope:[]  from @2
  [3] phi()
main: scope:[main]  from @2
  [4] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@1
  [5] (byte) main::b#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) main::b#1 )
  [6] (byte) main::b2#0 ← (byte/word/signed word/dword/signed dword) 200 - (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/signed byte/word/signed word/dword/signed dword) 101) 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/signed byte/word/signed word/dword/signed dword) 0 w::@1/(byte) w::i#1 )
  [17] (byte) w::b2#0 ← (word/signed word/dword/signed dword) 1400-(word/signed word/dword/signed dword) 1350 + (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/signed byte/word/signed word/dword/signed dword) 11) 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
//SEG0 File Comments
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label SCREEN = $400
  .label SCREEN2 = SCREEN+$28*3
  .label SCREEN3 = SCREEN+$28*6
  .label SCREEN4 = SCREEN+$28*9
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @2 [phi:@begin->@2]
b2_from_bbegin:
  jmp b2
//SEG5 @2
b2:
//SEG6 [2] call main 
//SEG7 [4] phi from @2 to main [phi:@2->main]
main_from_b2:
  jsr main
//SEG8 [3] phi from @2 to @end [phi:@2->@end]
bend_from_b2:
  jmp bend
//SEG9 @end
bend:
//SEG10 main
main: {
    .label b2 = 4
    .label sb = 5
    .label b = 2
  //SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
  //SEG12 [5] phi (byte) main::b#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta b
    jmp b1
  //SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
  //SEG14 [5] phi (byte) main::b#2 = (byte) main::b#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
  //SEG15 main::@1
  b1:
  //SEG16 [6] (byte) main::b2#0 ← (byte/word/signed word/dword/signed dword) 200 - (byte) main::b#2 -- vbuz1=vbuc1_minus_vbuz2 
    lda #$c8
    sec
    sbc b
    sta b2
  //SEG17 [7] *((const byte*) SCREEN#0 + (byte) main::b#2) ← (byte) main::b2#0 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda b2
    ldy b
    sta SCREEN,y
  //SEG18 [8] (signed byte) main::sb#0 ← - (signed byte)(byte) main::b#2 -- vbsz1=_neg_vbsz2 
    lda b
    eor #$ff
    clc
    adc #1
    sta sb
  //SEG19 [9] *((const byte*) SCREEN2#0 + (byte) main::b#2) ← (byte)(signed byte) main::sb#0 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda sb
    ldy b
    sta SCREEN2,y
  //SEG20 [10] (byte) main::b#1 ← ++ (byte) main::b#2 -- vbuz1=_inc_vbuz1 
    inc b
  //SEG21 [11] if((byte) main::b#1!=(byte/signed byte/word/signed word/dword/signed dword) 101) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda b
    cmp #$65
    bne b1_from_b1
  //SEG22 [12] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
    jmp b2
  //SEG23 main::@2
  b2:
  //SEG24 [13] call w 
  //SEG25 [15] phi from main::@2 to w [phi:main::@2->w]
  w_from_b2:
    jsr w
    jmp breturn
  //SEG26 main::@return
  breturn:
  //SEG27 [14] return 
    rts
}
//SEG28 w
w: {
    .const w1 = $514
    .const w2 = $4e2
    .const b = w1-w2
    .label b2 = 6
    .label i = 3
  //SEG29 [16] phi from w to w::@1 [phi:w->w::@1]
  b1_from_w:
  //SEG30 [16] phi (byte) w::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:w->w::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta i
    jmp b1
  //SEG31 [16] phi from w::@1 to w::@1 [phi:w::@1->w::@1]
  b1_from_b1:
  //SEG32 [16] phi (byte) w::i#2 = (byte) w::i#1 [phi:w::@1->w::@1#0] -- register_copy 
    jmp b1
  //SEG33 w::@1
  b1:
  //SEG34 [17] (byte) w::b2#0 ← (word/signed word/dword/signed dword) 1400-(word/signed word/dword/signed dword) 1350 + (byte) w::i#2 -- vbuz1=vbuc1_plus_vbuz2 
    lda #$578-$546
    clc
    adc i
    sta b2
  //SEG35 [18] *((const byte*) SCREEN3#0 + (byte) w::i#2) ← (const byte) w::b#0 -- pbuc1_derefidx_vbuz1=vbuc2 
    ldy i
    lda #b
    sta SCREEN3,y
  //SEG36 [19] *((const byte*) SCREEN4#0 + (byte) w::i#2) ← (byte) w::b2#0 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda b2
    ldy i
    sta SCREEN4,y
  //SEG37 [20] (byte) w::i#1 ← ++ (byte) w::i#2 -- vbuz1=_inc_vbuz1 
    inc i
  //SEG38 [21] if((byte) w::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto w::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda i
    cmp #$b
    bne b1_from_b1
    jmp breturn
  //SEG39 w::@return
  breturn:
  //SEG40 [22] return 
    rts
}

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] (byte) main::b2#0 ← (byte/word/signed word/dword/signed dword) 200 - (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 [17] (byte) w::b2#0 ← (word/signed word/dword/signed dword) 1400-(word/signed word/dword/signed dword) 1350 + (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 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:3 [ w::i#2 w::i#1 ]
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: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/word/signed word/dword/signed dword) 200 - (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 ← (word/signed word/dword/signed dword) 1400-(word/signed word/dword/signed dword) 1350 + (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 1016 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 836 combination reg byte y [ w::i#2 w::i#1 ] reg byte x [ w::b2#0 ] 
Uplifting [] best 836 combination 

ASSEMBLER BEFORE OPTIMIZATION
//SEG0 File Comments
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label SCREEN = $400
  .label SCREEN2 = SCREEN+$28*3
  .label SCREEN3 = SCREEN+$28*6
  .label SCREEN4 = SCREEN+$28*9
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @2 [phi:@begin->@2]
b2_from_bbegin:
  jmp b2
//SEG5 @2
b2:
//SEG6 [2] call main 
//SEG7 [4] phi from @2 to main [phi:@2->main]
main_from_b2:
  jsr main
//SEG8 [3] phi from @2 to @end [phi:@2->@end]
bend_from_b2:
  jmp bend
//SEG9 @end
bend:
//SEG10 main
main: {
  //SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
  //SEG12 [5] phi (byte) main::b#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    jmp b1
  //SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
  //SEG14 [5] phi (byte) main::b#2 = (byte) main::b#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
  //SEG15 main::@1
  b1:
  //SEG16 [6] (byte) main::b2#0 ← (byte/word/signed word/dword/signed dword) 200 - (byte) main::b#2 -- vbuaa=vbuc1_minus_vbuxx 
    txa
    eor #$ff
    clc
    adc #$c8+1
  //SEG17 [7] *((const byte*) SCREEN#0 + (byte) main::b#2) ← (byte) main::b2#0 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN,x
  //SEG18 [8] (signed byte) main::sb#0 ← - (signed byte)(byte) main::b#2 -- vbsaa=_neg_vbsxx 
    txa
    eor #$ff
    clc
    adc #1
  //SEG19 [9] *((const byte*) SCREEN2#0 + (byte) main::b#2) ← (byte)(signed byte) main::sb#0 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN2,x
  //SEG20 [10] (byte) main::b#1 ← ++ (byte) main::b#2 -- vbuxx=_inc_vbuxx 
    inx
  //SEG21 [11] if((byte) main::b#1!=(byte/signed byte/word/signed word/dword/signed dword) 101) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$65
    bne b1_from_b1
  //SEG22 [12] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
    jmp b2
  //SEG23 main::@2
  b2:
  //SEG24 [13] call w 
  //SEG25 [15] phi from main::@2 to w [phi:main::@2->w]
  w_from_b2:
    jsr w
    jmp breturn
  //SEG26 main::@return
  breturn:
  //SEG27 [14] return 
    rts
}
//SEG28 w
w: {
    .const w1 = $514
    .const w2 = $4e2
    .const b = w1-w2
  //SEG29 [16] phi from w to w::@1 [phi:w->w::@1]
  b1_from_w:
  //SEG30 [16] phi (byte) w::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:w->w::@1#0] -- vbuyy=vbuc1 
    ldy #0
    jmp b1
  //SEG31 [16] phi from w::@1 to w::@1 [phi:w::@1->w::@1]
  b1_from_b1:
  //SEG32 [16] phi (byte) w::i#2 = (byte) w::i#1 [phi:w::@1->w::@1#0] -- register_copy 
    jmp b1
  //SEG33 w::@1
  b1:
  //SEG34 [17] (byte) w::b2#0 ← (word/signed word/dword/signed dword) 1400-(word/signed word/dword/signed dword) 1350 + (byte) w::i#2 -- vbuxx=vbuc1_plus_vbuyy 
    tya
    clc
    adc #$578-$546
    tax
  //SEG35 [18] *((const byte*) SCREEN3#0 + (byte) w::i#2) ← (const byte) w::b#0 -- pbuc1_derefidx_vbuyy=vbuc2 
    lda #b
    sta SCREEN3,y
  //SEG36 [19] *((const byte*) SCREEN4#0 + (byte) w::i#2) ← (byte) w::b2#0 -- pbuc1_derefidx_vbuyy=vbuxx 
    txa
    sta SCREEN4,y
  //SEG37 [20] (byte) w::i#1 ← ++ (byte) w::i#2 -- vbuyy=_inc_vbuyy 
    iny
  //SEG38 [21] if((byte) w::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto w::@1 -- vbuyy_neq_vbuc1_then_la1 
    cpy #$b
    bne b1_from_b1
    jmp breturn
  //SEG39 w::@return
  breturn:
  //SEG40 [22] return 
    rts
}

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b2
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 b2_from_bbegin:
Removing instruction b2:
Removing instruction main_from_b2:
Removing instruction bend_from_b2:
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) @2
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) 1024
(byte*) SCREEN2
(const byte*) SCREEN2#0 SCREEN2 = (const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 3
(byte*) SCREEN3
(const byte*) SCREEN3#0 SCREEN3 = (const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 6
(byte*) SCREEN4
(const byte*) SCREEN4#0 SCREEN4 = (const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 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/signed word/dword/signed dword) 1300
(word) w::w2
(const word) w::w2#0 w2 = (word/signed word/dword/signed dword) 1250

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: 668

//SEG0 File Comments
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label SCREEN = $400
  .label SCREEN2 = SCREEN+$28*3
  .label SCREEN3 = SCREEN+$28*6
  .label SCREEN4 = SCREEN+$28*9
//SEG3 @begin
//SEG4 [1] phi from @begin to @2 [phi:@begin->@2]
//SEG5 @2
//SEG6 [2] call main 
//SEG7 [4] phi from @2 to main [phi:@2->main]
//SEG8 [3] phi from @2 to @end [phi:@2->@end]
//SEG9 @end
//SEG10 main
main: {
  //SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
  //SEG12 [5] phi (byte) main::b#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
  //SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  //SEG14 [5] phi (byte) main::b#2 = (byte) main::b#1 [phi:main::@1->main::@1#0] -- register_copy 
  //SEG15 main::@1
  b1:
  //SEG16 [6] (byte) main::b2#0 ← (byte/word/signed word/dword/signed dword) 200 - (byte) main::b#2 -- vbuaa=vbuc1_minus_vbuxx 
    txa
    eor #$ff
    clc
    adc #$c8+1
  //SEG17 [7] *((const byte*) SCREEN#0 + (byte) main::b#2) ← (byte) main::b2#0 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN,x
  //SEG18 [8] (signed byte) main::sb#0 ← - (signed byte)(byte) main::b#2 -- vbsaa=_neg_vbsxx 
    txa
    eor #$ff
    clc
    adc #1
  //SEG19 [9] *((const byte*) SCREEN2#0 + (byte) main::b#2) ← (byte)(signed byte) main::sb#0 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN2,x
  //SEG20 [10] (byte) main::b#1 ← ++ (byte) main::b#2 -- vbuxx=_inc_vbuxx 
    inx
  //SEG21 [11] if((byte) main::b#1!=(byte/signed byte/word/signed word/dword/signed dword) 101) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$65
    bne b1
  //SEG22 [12] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  //SEG23 main::@2
  //SEG24 [13] call w 
  //SEG25 [15] phi from main::@2 to w [phi:main::@2->w]
    jsr w
  //SEG26 main::@return
  //SEG27 [14] return 
    rts
}
//SEG28 w
w: {
    .const w1 = $514
    .const w2 = $4e2
    .const b = w1-w2
  //SEG29 [16] phi from w to w::@1 [phi:w->w::@1]
  //SEG30 [16] phi (byte) w::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:w->w::@1#0] -- vbuyy=vbuc1 
    ldy #0
  //SEG31 [16] phi from w::@1 to w::@1 [phi:w::@1->w::@1]
  //SEG32 [16] phi (byte) w::i#2 = (byte) w::i#1 [phi:w::@1->w::@1#0] -- register_copy 
  //SEG33 w::@1
  b1:
  //SEG34 [17] (byte) w::b2#0 ← (word/signed word/dword/signed dword) 1400-(word/signed word/dword/signed dword) 1350 + (byte) w::i#2 -- vbuxx=vbuc1_plus_vbuyy 
    tya
    clc
    adc #$578-$546
    tax
  //SEG35 [18] *((const byte*) SCREEN3#0 + (byte) w::i#2) ← (const byte) w::b#0 -- pbuc1_derefidx_vbuyy=vbuc2 
    lda #b
    sta SCREEN3,y
  //SEG36 [19] *((const byte*) SCREEN4#0 + (byte) w::i#2) ← (byte) w::b2#0 -- pbuc1_derefidx_vbuyy=vbuxx 
    txa
    sta SCREEN4,y
  //SEG37 [20] (byte) w::i#1 ← ++ (byte) w::i#2 -- vbuyy=_inc_vbuyy 
    iny
  //SEG38 [21] if((byte) w::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto w::@1 -- vbuyy_neq_vbuc1_then_la1 
    cpy #$b
    bne b1
  //SEG39 w::@return
  //SEG40 [22] return 
    rts
}

