Warning! Adding boolean cast to non-boolean condition (byte) main::i
Warning! Adding boolean cast to non-boolean condition (byte) main::j
Warning! Adding boolean cast to non-boolean condition (byte) main::k
Culled Empty Block (label) main::@4
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@6
Culled Empty Block (label) main::@10
Culled Empty Block (label) main::@11
Culled Empty Block (label) main::@12
Culled Empty Block (label) main::@14

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) SCREEN#0 ← ((byte*)) (number) $400
  (byte) idx#0 ← (number) 0
  to:@1
main: scope:[main]  from @1
  (byte) idx#18 ← phi( @1/(byte) idx#17 )
  (byte) main::i#0 ← (number) 2
  to:main::@1
main::@1: scope:[main]  from main main::@2
  (byte) idx#15 ← phi( main/(byte) idx#18 main::@2/(byte) idx#1 )
  (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@2/(byte) main::i#1 )
  (bool~) main::$0 ← (number) 0 != (byte) main::i#2
  if((bool~) main::$0) goto main::@2
  to:main::@3
main::@2: scope:[main]  from main::@1
  (byte) idx#8 ← phi( main::@1/(byte) idx#15 )
  (byte) main::i#3 ← phi( main::@1/(byte) main::i#2 )
  *((byte*) SCREEN#0 + (byte) idx#8) ← (byte) main::i#3
  (byte) idx#1 ← ++ (byte) idx#8
  (byte) main::i#1 ← -- (byte) main::i#3
  to:main::@1
main::@3: scope:[main]  from main::@1
  (byte) idx#9 ← phi( main::@1/(byte) idx#15 )
  *((byte*) SCREEN#0 + (byte) idx#9) ← (byte) ' '
  (byte) idx#2 ← ++ (byte) idx#9
  (byte) main::j#0 ← (number) 3
  to:main::@7
main::@7: scope:[main]  from main::@3 main::@8
  (byte) idx#16 ← phi( main::@3/(byte) idx#2 main::@8/(byte) idx#3 )
  (byte) main::j#2 ← phi( main::@3/(byte) main::j#0 main::@8/(byte) main::j#3 )
  (byte) main::j#1 ← -- (byte) main::j#2
  (bool~) main::$1 ← (number) 0 != (byte) main::j#1
  if((bool~) main::$1) goto main::@8
  to:main::@9
main::@8: scope:[main]  from main::@7
  (byte) idx#10 ← phi( main::@7/(byte) idx#16 )
  (byte) main::j#3 ← phi( main::@7/(byte) main::j#1 )
  *((byte*) SCREEN#0 + (byte) idx#10) ← (byte) main::j#3
  (byte) idx#3 ← ++ (byte) idx#10
  to:main::@7
main::@9: scope:[main]  from main::@7
  (byte) idx#11 ← phi( main::@7/(byte) idx#16 )
  *((byte*) SCREEN#0 + (byte) idx#11) ← (byte) ' '
  (byte) idx#4 ← ++ (byte) idx#11
  (byte) main::k#0 ← (number) 2
  to:main::@13
main::@13: scope:[main]  from main::@13 main::@9
  (byte) idx#12 ← phi( main::@13/(byte) idx#5 main::@9/(byte) idx#4 )
  (byte) main::k#2 ← phi( main::@13/(byte) main::k#1 main::@9/(byte) main::k#0 )
  *((byte*) SCREEN#0 + (byte) idx#12) ← (byte) main::k#2
  (byte) idx#5 ← ++ (byte) idx#12
  (byte) main::k#1 ← -- (byte) main::k#2
  (bool~) main::$2 ← (number) 0 != (byte) main::k#1
  if((bool~) main::$2) goto main::@13
  to:main::@return
main::@return: scope:[main]  from main::@13
  (byte) idx#13 ← phi( main::@13/(byte) idx#5 )
  (byte) idx#6 ← (byte) idx#13
  return 
  to:@return
@1: scope:[]  from @begin
  (byte) idx#17 ← phi( @begin/(byte) idx#0 )
  call main 
  to:@2
@2: scope:[]  from @1
  (byte) idx#14 ← phi( @1/(byte) idx#6 )
  (byte) idx#7 ← (byte) idx#14
  to:@end
@end: scope:[]  from @2

SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(byte*) SCREEN
(byte*) SCREEN#0
(byte) idx
(byte) idx#0
(byte) idx#1
(byte) idx#10
(byte) idx#11
(byte) idx#12
(byte) idx#13
(byte) idx#14
(byte) idx#15
(byte) idx#16
(byte) idx#17
(byte) idx#18
(byte) idx#2
(byte) idx#3
(byte) idx#4
(byte) idx#5
(byte) idx#6
(byte) idx#7
(byte) idx#8
(byte) idx#9
(void()) main()
(bool~) main::$0
(bool~) main::$1
(bool~) main::$2
(label) main::@1
(label) main::@13
(label) main::@2
(label) main::@3
(label) main::@7
(label) main::@8
(label) main::@9
(label) main::@return
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(byte) main::i#3
(byte) main::j
(byte) main::j#0
(byte) main::j#1
(byte) main::j#2
(byte) main::j#3
(byte) main::k
(byte) main::k#0
(byte) main::k#1
(byte) main::k#2

Adding number conversion cast (unumber) 0 in (byte) idx#0 ← (number) 0
Adding number conversion cast (unumber) 2 in (byte) main::i#0 ← (number) 2
Adding number conversion cast (unumber) 0 in (bool~) main::$0 ← (number) 0 != (byte) main::i#2
Adding number conversion cast (unumber) 3 in (byte) main::j#0 ← (number) 3
Adding number conversion cast (unumber) 0 in (bool~) main::$1 ← (number) 0 != (byte) main::j#1
Adding number conversion cast (unumber) 2 in (byte) main::k#0 ← (number) 2
Adding number conversion cast (unumber) 0 in (bool~) main::$2 ← (number) 0 != (byte) main::k#1
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
Inlining cast (byte) idx#0 ← (unumber)(number) 0
Inlining cast (byte) main::i#0 ← (unumber)(number) 2
Inlining cast (byte) main::j#0 ← (unumber)(number) 3
Inlining cast (byte) main::k#0 ← (unumber)(number) 2
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 2
Simplifying constant integer cast 0
Simplifying constant integer cast 3
Simplifying constant integer cast 0
Simplifying constant integer cast 2
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 3
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte) main::i#2 = (byte) main::i#3 
Alias (byte) idx#15 = (byte) idx#8 (byte) idx#9 
Alias (byte) main::j#1 = (byte) main::j#3 
Alias (byte) idx#10 = (byte) idx#16 (byte) idx#11 
Alias (byte) idx#13 = (byte) idx#5 (byte) idx#6 
Alias (byte) idx#0 = (byte) idx#17 
Alias (byte) idx#14 = (byte) idx#7 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) idx#18 (byte) idx#0
Identical Phi Values (byte) idx#14 (byte) idx#13
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$0 [6] if((byte) 0!=(byte) main::i#2) goto main::@2
Simple Condition (bool~) main::$1 [18] if((byte) 0!=(byte) main::j#1) goto main::@8
Simple Condition (bool~) main::$2 [31] if((byte) 0!=(byte) main::k#1) goto main::@13
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) SCREEN#0 = (byte*) 1024
Constant (const byte) idx#0 = 0
Constant (const byte) main::i#0 = 2
Constant (const byte) main::j#0 = 3
Constant (const byte) main::k#0 = 2
Successful SSA optimization Pass2ConstantIdentification
Successful SSA optimization Pass2LoopHeadConstantIdentification
Alias (byte) main::i#1 = (byte) main::i#2 
Alias (byte) idx#1 = (byte) idx#15 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) main::i#5 (const byte) main::i#0
Identical Phi Values (byte) idx#21 (const byte) idx#0
Successful SSA optimization Pass2IdenticalPhiElimination
Removing PHI-reference to removed block (main::@1_1) in block main::@3
if() condition always true - replacing block destination [24] if((byte) 0!=(const byte) main::i#0) goto main::@2
Successful SSA optimization Pass2ConstantIfs
Alias (byte) idx#1 = (byte) idx#20 
Successful SSA optimization Pass2AliasElimination
Inlining constant with var siblings (const byte) main::i#0
Inlining constant with var siblings (const byte) main::j#0
Inlining constant with var siblings (const byte) main::k#0
Inlining constant with var siblings (const byte) idx#0
Constant inlined main::i#0 = (byte) 2
Constant inlined main::k#0 = (byte) 2
Constant inlined main::j#0 = (byte) 3
Constant inlined idx#0 = (byte) 0
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@15(between main::@1 and main::@2)
Added new block during phi lifting main::@16(between main::@13 and main::@13)
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::@1_1
CALL GRAPH
Calls in [] to main:2 

Created 6 initial phi equivalence classes
Coalesced [14] idx#23 ← idx#2
Coalesced [20] idx#26 ← idx#4
Coalesced [27] main::k#3 ← main::k#1
Coalesced [28] idx#25 ← idx#13
Coalesced [31] main::j#4 ← main::j#1
Coalesced [32] idx#24 ← idx#3
Coalesced [33] main::i#6 ← main::i#1
Coalesced [34] idx#22 ← idx#1
Coalesced down to 6 phi equivalence classes
Culled Empty Block (label) @2
Culled Empty Block (label) main::@1_1
Culled Empty Block (label) main::@16
Culled Empty Block (label) main::@15
Renumbering block main::@7 to main::@4
Renumbering block main::@8 to main::@5
Renumbering block main::@9 to main::@6
Renumbering block main::@13 to main::@7
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::@2
main::@2: scope:[main]  from main main::@1
  [5] (byte) idx#19 ← phi( main::@1/(byte) idx#1 main/(byte) 0 )
  [5] (byte) main::i#4 ← phi( main::@1/(byte) main::i#1 main/(byte) 2 )
  [6] *((const byte*) SCREEN#0 + (byte) idx#19) ← (byte) main::i#4
  [7] (byte) idx#1 ← ++ (byte) idx#19
  [8] (byte) main::i#1 ← -- (byte) main::i#4
  to:main::@1
main::@1: scope:[main]  from main::@2
  [9] if((byte) 0!=(byte) main::i#1) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@1
  [10] *((const byte*) SCREEN#0 + (byte) idx#1) ← (byte) ' '
  [11] (byte) idx#2 ← ++ (byte) idx#1
  to:main::@4
main::@4: scope:[main]  from main::@3 main::@5
  [12] (byte) idx#10 ← phi( main::@3/(byte) idx#2 main::@5/(byte) idx#3 )
  [12] (byte) main::j#2 ← phi( main::@3/(byte) 3 main::@5/(byte) main::j#1 )
  [13] (byte) main::j#1 ← -- (byte) main::j#2
  [14] if((byte) 0!=(byte) main::j#1) goto main::@5
  to:main::@6
main::@6: scope:[main]  from main::@4
  [15] *((const byte*) SCREEN#0 + (byte) idx#10) ← (byte) ' '
  [16] (byte) idx#4 ← ++ (byte) idx#10
  to:main::@7
main::@7: scope:[main]  from main::@6 main::@7
  [17] (byte) idx#12 ← phi( main::@7/(byte) idx#13 main::@6/(byte) idx#4 )
  [17] (byte) main::k#2 ← phi( main::@7/(byte) main::k#1 main::@6/(byte) 2 )
  [18] *((const byte*) SCREEN#0 + (byte) idx#12) ← (byte) main::k#2
  [19] (byte) idx#13 ← ++ (byte) idx#12
  [20] (byte) main::k#1 ← -- (byte) main::k#2
  [21] if((byte) 0!=(byte) main::k#1) goto main::@7
  to:main::@return
main::@return: scope:[main]  from main::@7
  [22] return 
  to:@return
main::@5: scope:[main]  from main::@4
  [23] *((const byte*) SCREEN#0 + (byte) idx#10) ← (byte) main::j#1
  [24] (byte) idx#3 ← ++ (byte) idx#10
  to:main::@4


VARIABLE REGISTER WEIGHTS
(byte*) SCREEN
(byte) idx
(byte) idx#1 6.5
(byte) idx#10 7.8
(byte) idx#12 17.5
(byte) idx#13 7.333333333333333
(byte) idx#19 16.5
(byte) idx#2 4.0
(byte) idx#3 22.0
(byte) idx#4 4.0
(void()) main()
(byte) main::i
(byte) main::i#1 16.5
(byte) main::i#4 11.0
(byte) main::j
(byte) main::j#1 11.0
(byte) main::j#2 22.0
(byte) main::k
(byte) main::k#1 16.5
(byte) main::k#2 11.0

Initial phi equivalence classes
[ main::i#4 main::i#1 ]
[ idx#19 idx#1 ]
[ main::j#2 main::j#1 ]
[ idx#10 idx#2 idx#3 ]
[ main::k#2 main::k#1 ]
[ idx#12 idx#13 idx#4 ]
Complete equivalence classes
[ main::i#4 main::i#1 ]
[ idx#19 idx#1 ]
[ main::j#2 main::j#1 ]
[ idx#10 idx#2 idx#3 ]
[ main::k#2 main::k#1 ]
[ idx#12 idx#13 idx#4 ]
Allocated zp ZP_BYTE:2 [ main::i#4 main::i#1 ]
Allocated zp ZP_BYTE:3 [ idx#19 idx#1 ]
Allocated zp ZP_BYTE:4 [ main::j#2 main::j#1 ]
Allocated zp ZP_BYTE:5 [ idx#10 idx#2 idx#3 ]
Allocated zp ZP_BYTE:6 [ main::k#2 main::k#1 ]
Allocated zp ZP_BYTE:7 [ idx#12 idx#13 idx#4 ]

INITIAL ASM
Target platform is c64basic
  // File Comments
// Tests using integer conditions in while() / for() / do..while
// This should produce 'ba ba ba' at the top of the screen
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  .label idx = 3
  .label idx_2 = 5
  .label idx_3 = 5
  .label idx_4 = 7
  .label idx_10 = 5
  .label idx_12 = 7
  .label idx_13 = 7
  // @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 i = 2
    .label j = 4
    .label k = 6
    // [5] phi from main to main::@2 [phi:main->main::@2]
  b2_from_main:
    // [5] phi (byte) idx#19 = (byte) 0 [phi:main->main::@2#0] -- vbuz1=vbuc1 
    lda #0
    sta.z idx
    // [5] phi (byte) main::i#4 = (byte) 2 [phi:main->main::@2#1] -- vbuz1=vbuc1 
    lda #2
    sta.z i
    jmp b2
    // [5] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
    // [5] phi (byte) idx#19 = (byte) idx#1 [phi:main::@1->main::@2#0] -- register_copy 
    // [5] phi (byte) main::i#4 = (byte) main::i#1 [phi:main::@1->main::@2#1] -- register_copy 
    jmp b2
    // main::@2
  b2:
    // [6] *((const byte*) SCREEN#0 + (byte) idx#19) ← (byte) main::i#4 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda.z i
    ldy.z idx
    sta SCREEN,y
    // [7] (byte) idx#1 ← ++ (byte) idx#19 -- vbuz1=_inc_vbuz1 
    inc.z idx
    // [8] (byte) main::i#1 ← -- (byte) main::i#4 -- vbuz1=_dec_vbuz1 
    dec.z i
    jmp b1
  // for()
    // main::@1
  b1:
    // [9] if((byte) 0!=(byte) main::i#1) goto main::@2 -- vbuc1_neq_vbuz1_then_la1 
    lda #0
    cmp.z i
    bne b2_from_b1
    jmp b3
    // main::@3
  b3:
    // [10] *((const byte*) SCREEN#0 + (byte) idx#1) ← (byte) ' ' -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #' '
    ldy.z idx
    sta SCREEN,y
    // [11] (byte) idx#2 ← ++ (byte) idx#1 -- vbuz1=_inc_vbuz2 
    ldy.z idx
    iny
    sty.z idx_2
    // [12] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
  b4_from_b3:
    // [12] phi (byte) idx#10 = (byte) idx#2 [phi:main::@3->main::@4#0] -- register_copy 
    // [12] phi (byte) main::j#2 = (byte) 3 [phi:main::@3->main::@4#1] -- vbuz1=vbuc1 
    lda #3
    sta.z j
    jmp b4
    // main::@4
  b4:
    // [13] (byte) main::j#1 ← -- (byte) main::j#2 -- vbuz1=_dec_vbuz1 
    dec.z j
    // [14] if((byte) 0!=(byte) main::j#1) goto main::@5 -- vbuc1_neq_vbuz1_then_la1 
    lda #0
    cmp.z j
    bne b5
    jmp b6
    // main::@6
  b6:
    // [15] *((const byte*) SCREEN#0 + (byte) idx#10) ← (byte) ' ' -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #' '
    ldy.z idx_10
    sta SCREEN,y
    // [16] (byte) idx#4 ← ++ (byte) idx#10 -- vbuz1=_inc_vbuz2 
    ldy.z idx_10
    iny
    sty.z idx_4
    // [17] phi from main::@6 to main::@7 [phi:main::@6->main::@7]
  b7_from_b6:
    // [17] phi (byte) idx#12 = (byte) idx#4 [phi:main::@6->main::@7#0] -- register_copy 
    // [17] phi (byte) main::k#2 = (byte) 2 [phi:main::@6->main::@7#1] -- vbuz1=vbuc1 
    lda #2
    sta.z k
    jmp b7
    // [17] phi from main::@7 to main::@7 [phi:main::@7->main::@7]
  b7_from_b7:
    // [17] phi (byte) idx#12 = (byte) idx#13 [phi:main::@7->main::@7#0] -- register_copy 
    // [17] phi (byte) main::k#2 = (byte) main::k#1 [phi:main::@7->main::@7#1] -- register_copy 
    jmp b7
    // main::@7
  b7:
    // [18] *((const byte*) SCREEN#0 + (byte) idx#12) ← (byte) main::k#2 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda.z k
    ldy.z idx_12
    sta SCREEN,y
    // [19] (byte) idx#13 ← ++ (byte) idx#12 -- vbuz1=_inc_vbuz1 
    inc.z idx_13
    // [20] (byte) main::k#1 ← -- (byte) main::k#2 -- vbuz1=_dec_vbuz1 
    dec.z k
    // [21] if((byte) 0!=(byte) main::k#1) goto main::@7 -- vbuc1_neq_vbuz1_then_la1 
    lda #0
    cmp.z k
    bne b7_from_b7
    jmp breturn
    // main::@return
  breturn:
    // [22] return 
    rts
    // main::@5
  b5:
    // [23] *((const byte*) SCREEN#0 + (byte) idx#10) ← (byte) main::j#1 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda.z j
    ldy.z idx_10
    sta SCREEN,y
    // [24] (byte) idx#3 ← ++ (byte) idx#10 -- vbuz1=_inc_vbuz1 
    inc.z idx_3
    // [12] phi from main::@5 to main::@4 [phi:main::@5->main::@4]
  b4_from_b5:
    // [12] phi (byte) idx#10 = (byte) idx#3 [phi:main::@5->main::@4#0] -- register_copy 
    // [12] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@5->main::@4#1] -- register_copy 
    jmp b4
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [10] *((const byte*) SCREEN#0 + (byte) idx#1) ← (byte) ' ' [ idx#1 ] ( main:2 [ idx#1 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:3 [ idx#19 idx#1 ]
Statement [15] *((const byte*) SCREEN#0 + (byte) idx#10) ← (byte) ' ' [ idx#10 ] ( main:2 [ idx#10 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:5 [ idx#10 idx#2 idx#3 ]
Statement [10] *((const byte*) SCREEN#0 + (byte) idx#1) ← (byte) ' ' [ idx#1 ] ( main:2 [ idx#1 ] ) always clobbers reg byte a 
Statement [15] *((const byte*) SCREEN#0 + (byte) idx#10) ← (byte) ' ' [ idx#10 ] ( main:2 [ idx#10 ] ) always clobbers reg byte a 
Potential registers zp ZP_BYTE:2 [ main::i#4 main::i#1 ] : zp ZP_BYTE:2 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:3 [ idx#19 idx#1 ] : zp ZP_BYTE:3 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:4 [ main::j#2 main::j#1 ] : zp ZP_BYTE:4 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:5 [ idx#10 idx#2 idx#3 ] : zp ZP_BYTE:5 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:6 [ main::k#2 main::k#1 ] : zp ZP_BYTE:6 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:7 [ idx#12 idx#13 idx#4 ] : zp ZP_BYTE:7 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 33: zp ZP_BYTE:4 [ main::j#2 main::j#1 ] 27.5: zp ZP_BYTE:2 [ main::i#4 main::i#1 ] 27.5: zp ZP_BYTE:6 [ main::k#2 main::k#1 ] 
Uplift Scope [] 33.8: zp ZP_BYTE:5 [ idx#10 idx#2 idx#3 ] 28.83: zp ZP_BYTE:7 [ idx#12 idx#13 idx#4 ] 23: zp ZP_BYTE:3 [ idx#19 idx#1 ] 

Uplifting [main] best 1109 combination reg byte a [ main::j#2 main::j#1 ] reg byte x [ main::i#4 main::i#1 ] reg byte a [ main::k#2 main::k#1 ] 
Uplifting [] best 881 combination reg byte y [ idx#10 idx#2 idx#3 ] reg byte y [ idx#12 idx#13 idx#4 ] reg byte y [ idx#19 idx#1 ] 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests using integer conditions in while() / for() / do..while
// This should produce 'ba ba ba' at the top of the screen
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  // @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::@2 [phi:main->main::@2]
  b2_from_main:
    // [5] phi (byte) idx#19 = (byte) 0 [phi:main->main::@2#0] -- vbuyy=vbuc1 
    ldy #0
    // [5] phi (byte) main::i#4 = (byte) 2 [phi:main->main::@2#1] -- vbuxx=vbuc1 
    ldx #2
    jmp b2
    // [5] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
    // [5] phi (byte) idx#19 = (byte) idx#1 [phi:main::@1->main::@2#0] -- register_copy 
    // [5] phi (byte) main::i#4 = (byte) main::i#1 [phi:main::@1->main::@2#1] -- register_copy 
    jmp b2
    // main::@2
  b2:
    // [6] *((const byte*) SCREEN#0 + (byte) idx#19) ← (byte) main::i#4 -- pbuc1_derefidx_vbuyy=vbuxx 
    txa
    sta SCREEN,y
    // [7] (byte) idx#1 ← ++ (byte) idx#19 -- vbuyy=_inc_vbuyy 
    iny
    // [8] (byte) main::i#1 ← -- (byte) main::i#4 -- vbuxx=_dec_vbuxx 
    dex
    jmp b1
  // for()
    // main::@1
  b1:
    // [9] if((byte) 0!=(byte) main::i#1) goto main::@2 -- vbuc1_neq_vbuxx_then_la1 
    cpx #0
    bne b2_from_b1
    jmp b3
    // main::@3
  b3:
    // [10] *((const byte*) SCREEN#0 + (byte) idx#1) ← (byte) ' ' -- pbuc1_derefidx_vbuyy=vbuc2 
    lda #' '
    sta SCREEN,y
    // [11] (byte) idx#2 ← ++ (byte) idx#1 -- vbuyy=_inc_vbuyy 
    iny
    // [12] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
  b4_from_b3:
    // [12] phi (byte) idx#10 = (byte) idx#2 [phi:main::@3->main::@4#0] -- register_copy 
    // [12] phi (byte) main::j#2 = (byte) 3 [phi:main::@3->main::@4#1] -- vbuaa=vbuc1 
    lda #3
    jmp b4
    // main::@4
  b4:
    // [13] (byte) main::j#1 ← -- (byte) main::j#2 -- vbuaa=_dec_vbuaa 
    sec
    sbc #1
    // [14] if((byte) 0!=(byte) main::j#1) goto main::@5 -- vbuc1_neq_vbuaa_then_la1 
    cmp #0
    bne b5
    jmp b6
    // main::@6
  b6:
    // [15] *((const byte*) SCREEN#0 + (byte) idx#10) ← (byte) ' ' -- pbuc1_derefidx_vbuyy=vbuc2 
    lda #' '
    sta SCREEN,y
    // [16] (byte) idx#4 ← ++ (byte) idx#10 -- vbuyy=_inc_vbuyy 
    iny
    // [17] phi from main::@6 to main::@7 [phi:main::@6->main::@7]
  b7_from_b6:
    // [17] phi (byte) idx#12 = (byte) idx#4 [phi:main::@6->main::@7#0] -- register_copy 
    // [17] phi (byte) main::k#2 = (byte) 2 [phi:main::@6->main::@7#1] -- vbuaa=vbuc1 
    lda #2
    jmp b7
    // [17] phi from main::@7 to main::@7 [phi:main::@7->main::@7]
  b7_from_b7:
    // [17] phi (byte) idx#12 = (byte) idx#13 [phi:main::@7->main::@7#0] -- register_copy 
    // [17] phi (byte) main::k#2 = (byte) main::k#1 [phi:main::@7->main::@7#1] -- register_copy 
    jmp b7
    // main::@7
  b7:
    // [18] *((const byte*) SCREEN#0 + (byte) idx#12) ← (byte) main::k#2 -- pbuc1_derefidx_vbuyy=vbuaa 
    sta SCREEN,y
    // [19] (byte) idx#13 ← ++ (byte) idx#12 -- vbuyy=_inc_vbuyy 
    iny
    // [20] (byte) main::k#1 ← -- (byte) main::k#2 -- vbuaa=_dec_vbuaa 
    sec
    sbc #1
    // [21] if((byte) 0!=(byte) main::k#1) goto main::@7 -- vbuc1_neq_vbuaa_then_la1 
    cmp #0
    bne b7_from_b7
    jmp breturn
    // main::@return
  breturn:
    // [22] return 
    rts
    // main::@5
  b5:
    // [23] *((const byte*) SCREEN#0 + (byte) idx#10) ← (byte) main::j#1 -- pbuc1_derefidx_vbuyy=vbuaa 
    sta SCREEN,y
    // [24] (byte) idx#3 ← ++ (byte) idx#10 -- vbuyy=_inc_vbuyy 
    iny
    // [12] phi from main::@5 to main::@4 [phi:main::@5->main::@4]
  b4_from_b5:
    // [12] phi (byte) idx#10 = (byte) idx#3 [phi:main::@5->main::@4#0] -- register_copy 
    // [12] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@5->main::@4#1] -- register_copy 
    jmp b4
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b2
Removing instruction jmp b1
Removing instruction jmp b3
Removing instruction jmp b4
Removing instruction jmp b6
Removing instruction jmp b7
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b2_from_b1 with b2
Replacing label b7_from_b7 with b7
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b2_from_b1:
Removing instruction b7_from_b7:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b2_from_main:
Removing instruction b1:
Removing instruction b3:
Removing instruction b4_from_b3:
Removing instruction b6:
Removing instruction b7_from_b6:
Removing instruction breturn:
Removing instruction b4_from_b5:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction jmp b2
Removing instruction jmp b7
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) idx
(byte) idx#1 reg byte y 6.5
(byte) idx#10 reg byte y 7.8
(byte) idx#12 reg byte y 17.5
(byte) idx#13 reg byte y 7.333333333333333
(byte) idx#19 reg byte y 16.5
(byte) idx#2 reg byte y 4.0
(byte) idx#3 reg byte y 22.0
(byte) idx#4 reg byte y 4.0
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@7
(label) main::@return
(byte) main::i
(byte) main::i#1 reg byte x 16.5
(byte) main::i#4 reg byte x 11.0
(byte) main::j
(byte) main::j#1 reg byte a 11.0
(byte) main::j#2 reg byte a 22.0
(byte) main::k
(byte) main::k#1 reg byte a 16.5
(byte) main::k#2 reg byte a 11.0

reg byte x [ main::i#4 main::i#1 ]
reg byte y [ idx#19 idx#1 ]
reg byte a [ main::j#2 main::j#1 ]
reg byte y [ idx#10 idx#2 idx#3 ]
reg byte a [ main::k#2 main::k#1 ]
reg byte y [ idx#12 idx#13 idx#4 ]


FINAL ASSEMBLER
Score: 599

  // File Comments
// Tests using integer conditions in while() / for() / do..while
// This should produce 'ba ba ba' at the top of the screen
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  // @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::@2 [phi:main->main::@2]
    // [5] phi (byte) idx#19 = (byte) 0 [phi:main->main::@2#0] -- vbuyy=vbuc1 
    ldy #0
    // [5] phi (byte) main::i#4 = (byte) 2 [phi:main->main::@2#1] -- vbuxx=vbuc1 
    ldx #2
    // [5] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
    // [5] phi (byte) idx#19 = (byte) idx#1 [phi:main::@1->main::@2#0] -- register_copy 
    // [5] phi (byte) main::i#4 = (byte) main::i#1 [phi:main::@1->main::@2#1] -- register_copy 
    // main::@2
  b2:
    // SCREEN[idx++] = i
    // [6] *((const byte*) SCREEN#0 + (byte) idx#19) ← (byte) main::i#4 -- pbuc1_derefidx_vbuyy=vbuxx 
    txa
    sta SCREEN,y
    // SCREEN[idx++] = i;
    // [7] (byte) idx#1 ← ++ (byte) idx#19 -- vbuyy=_inc_vbuyy 
    iny
    // for( byte i=2;i;i--)
    // [8] (byte) main::i#1 ← -- (byte) main::i#4 -- vbuxx=_dec_vbuxx 
    dex
  // for()
    // main::@1
    // [9] if((byte) 0!=(byte) main::i#1) goto main::@2 -- vbuc1_neq_vbuxx_then_la1 
    cpx #0
    bne b2
    // main::@3
    // SCREEN[idx++] = ' '
    // [10] *((const byte*) SCREEN#0 + (byte) idx#1) ← (byte) ' ' -- pbuc1_derefidx_vbuyy=vbuc2 
    lda #' '
    sta SCREEN,y
    // SCREEN[idx++] = ' ';
    // [11] (byte) idx#2 ← ++ (byte) idx#1 -- vbuyy=_inc_vbuyy 
    iny
    // [12] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
    // [12] phi (byte) idx#10 = (byte) idx#2 [phi:main::@3->main::@4#0] -- register_copy 
    // [12] phi (byte) main::j#2 = (byte) 3 [phi:main::@3->main::@4#1] -- vbuaa=vbuc1 
    lda #3
    // main::@4
  b4:
    // while( j-- )
    // [13] (byte) main::j#1 ← -- (byte) main::j#2 -- vbuaa=_dec_vbuaa 
    sec
    sbc #1
    // [14] if((byte) 0!=(byte) main::j#1) goto main::@5 -- vbuc1_neq_vbuaa_then_la1 
    cmp #0
    bne b5
    // main::@6
    // SCREEN[idx++] = ' '
    // [15] *((const byte*) SCREEN#0 + (byte) idx#10) ← (byte) ' ' -- pbuc1_derefidx_vbuyy=vbuc2 
    lda #' '
    sta SCREEN,y
    // SCREEN[idx++] = ' ';
    // [16] (byte) idx#4 ← ++ (byte) idx#10 -- vbuyy=_inc_vbuyy 
    iny
    // [17] phi from main::@6 to main::@7 [phi:main::@6->main::@7]
    // [17] phi (byte) idx#12 = (byte) idx#4 [phi:main::@6->main::@7#0] -- register_copy 
    // [17] phi (byte) main::k#2 = (byte) 2 [phi:main::@6->main::@7#1] -- vbuaa=vbuc1 
    lda #2
    // [17] phi from main::@7 to main::@7 [phi:main::@7->main::@7]
    // [17] phi (byte) idx#12 = (byte) idx#13 [phi:main::@7->main::@7#0] -- register_copy 
    // [17] phi (byte) main::k#2 = (byte) main::k#1 [phi:main::@7->main::@7#1] -- register_copy 
    // main::@7
  b7:
    // SCREEN[idx++] = k
    // [18] *((const byte*) SCREEN#0 + (byte) idx#12) ← (byte) main::k#2 -- pbuc1_derefidx_vbuyy=vbuaa 
    sta SCREEN,y
    // SCREEN[idx++] = k;
    // [19] (byte) idx#13 ← ++ (byte) idx#12 -- vbuyy=_inc_vbuyy 
    iny
    // while(k--)
    // [20] (byte) main::k#1 ← -- (byte) main::k#2 -- vbuaa=_dec_vbuaa 
    sec
    sbc #1
    // [21] if((byte) 0!=(byte) main::k#1) goto main::@7 -- vbuc1_neq_vbuaa_then_la1 
    cmp #0
    bne b7
    // main::@return
    // }
    // [22] return 
    rts
    // main::@5
  b5:
    // SCREEN[idx++] = j
    // [23] *((const byte*) SCREEN#0 + (byte) idx#10) ← (byte) main::j#1 -- pbuc1_derefidx_vbuyy=vbuaa 
    sta SCREEN,y
    // SCREEN[idx++] = j;
    // [24] (byte) idx#3 ← ++ (byte) idx#10 -- vbuyy=_inc_vbuyy 
    iny
    // [12] phi from main::@5 to main::@4 [phi:main::@5->main::@4]
    // [12] phi (byte) idx#10 = (byte) idx#3 [phi:main::@5->main::@4#0] -- register_copy 
    // [12] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@5->main::@4#1] -- register_copy 
    jmp b4
}
  // File Data

