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) idx#0 ← (byte) 0
  to:@1

(void()) main()
main: scope:[main]  from @1
  (byte) idx#18 ← phi( @1/(byte) idx#17 )
  (byte) main::i#0 ← (byte) 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 )
  *((const byte*) SCREEN + (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 )
  *((const byte*) SCREEN + (byte) idx#9) ← (byte) ' '
  (byte) idx#2 ← ++ (byte) idx#9
  (byte) main::j#0 ← (byte) 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 )
  *((const byte*) SCREEN + (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 )
  *((const byte*) SCREEN + (byte) idx#11) ← (byte) ' '
  (byte) idx#4 ← ++ (byte) idx#11
  (byte) main::k#0 ← (byte) 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 )
  *((const byte*) SCREEN + (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
(const byte*) SCREEN = (byte*)(number) $400
(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 (bool~) main::$0 ← (number) 0 != (byte) main::i#2
Adding number conversion cast (unumber) 0 in (bool~) main::$1 ← (number) 0 != (byte) main::j#1
Adding number conversion cast (unumber) 0 in (bool~) main::$2 ← (number) 0 != (byte) main::k#1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
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 [5] if((byte) 0!=(byte) main::i#2) goto main::@2
Simple Condition (bool~) main::$1 [17] if((byte) 0!=(byte) main::j#1) goto main::@8
Simple Condition (bool~) main::$2 [30] if((byte) 0!=(byte) main::k#1) goto main::@13
Successful SSA optimization Pass2ConditionalJumpSimplification
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
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::@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
CALL GRAPH
Calls in [] to main:2 

Created 6 initial phi equivalence classes
Coalesced [10] idx#20 ← idx#2
Coalesced [16] idx#23 ← idx#4
Coalesced [23] main::k#3 ← main::k#1
Coalesced [24] idx#22 ← idx#13
Coalesced [27] main::j#4 ← main::j#1
Coalesced [28] idx#21 ← idx#3
Coalesced [32] main::i#4 ← main::i#1
Coalesced [33] idx#19 ← idx#1
Coalesced down to 6 phi equivalence classes
Culled Empty Block (label) @2
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()

(void()) main()
main: scope:[main]  from @1
  [4] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@2
  [5] (byte) idx#15 ← phi( main/(byte) 0 main::@2/(byte) idx#1 )
  [5] (byte) main::i#2 ← phi( main/(byte) 2 main::@2/(byte) main::i#1 )
  [6] if((byte) 0!=(byte) main::i#2) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@1
  [7] *((const byte*) SCREEN + (byte) idx#15) ← (byte) ' '
  [8] (byte) idx#2 ← ++ (byte) idx#15
  to:main::@4
main::@4: scope:[main]  from main::@3 main::@5
  [9] (byte) idx#10 ← phi( main::@3/(byte) idx#2 main::@5/(byte) idx#3 )
  [9] (byte) main::j#2 ← phi( main::@3/(byte) 3 main::@5/(byte) main::j#1 )
  [10] (byte) main::j#1 ← -- (byte) main::j#2
  [11] if((byte) 0!=(byte) main::j#1) goto main::@5
  to:main::@6
main::@6: scope:[main]  from main::@4
  [12] *((const byte*) SCREEN + (byte) idx#10) ← (byte) ' '
  [13] (byte) idx#4 ← ++ (byte) idx#10
  to:main::@7
main::@7: scope:[main]  from main::@6 main::@7
  [14] (byte) idx#12 ← phi( main::@7/(byte) idx#13 main::@6/(byte) idx#4 )
  [14] (byte) main::k#2 ← phi( main::@7/(byte) main::k#1 main::@6/(byte) 2 )
  [15] *((const byte*) SCREEN + (byte) idx#12) ← (byte) main::k#2
  [16] (byte) idx#13 ← ++ (byte) idx#12
  [17] (byte) main::k#1 ← -- (byte) main::k#2
  [18] if((byte) 0!=(byte) main::k#1) goto main::@7
  to:main::@return
main::@return: scope:[main]  from main::@7
  [19] return 
  to:@return
main::@5: scope:[main]  from main::@4
  [20] *((const byte*) SCREEN + (byte) idx#10) ← (byte) main::j#1
  [21] (byte) idx#3 ← ++ (byte) idx#10
  to:main::@4
main::@2: scope:[main]  from main::@1
  [22] *((const byte*) SCREEN + (byte) idx#15) ← (byte) main::i#2
  [23] (byte) idx#1 ← ++ (byte) idx#15
  [24] (byte) main::i#1 ← -- (byte) main::i#2
  to:main::@1


VARIABLE REGISTER WEIGHTS
(byte) idx
(byte) idx#1 11.0
(byte) idx#10 7.8
(byte) idx#12 17.5
(byte) idx#13 7.333333333333333
(byte) idx#15 9.25
(byte) idx#2 4.0
(byte) idx#3 22.0
(byte) idx#4 4.0
(void()) main()
(byte) main::i
(byte) main::i#1 22.0
(byte) main::i#2 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#2 main::i#1 ]
[ idx#15 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#2 main::i#1 ]
[ idx#15 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[1]:2 [ main::i#2 main::i#1 ]
Allocated zp[1]:3 [ idx#15 idx#1 ]
Allocated zp[1]:4 [ main::j#2 main::j#1 ]
Allocated zp[1]:5 [ idx#10 idx#2 idx#3 ]
Allocated zp[1]:6 [ main::k#2 main::k#1 ]
Allocated zp[1]:7 [ idx#12 idx#13 idx#4 ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // 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_1 = 5
  .label idx_2 = 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
    // while()
    .label j = 4
    // do...while()
    .label k = 6
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (byte) idx#15 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z idx
    // [5] phi (byte) main::i#2 = (byte) 2 [phi:main->main::@1#1] -- vbuz1=vbuc1 
    lda #2
    sta.z i
    jmp __b1
  // for()
    // main::@1
  __b1:
    // [6] if((byte) 0!=(byte) main::i#2) goto main::@2 -- vbuc1_neq_vbuz1_then_la1 
    lda #0
    cmp.z i
    bne __b2
    jmp __b3
    // main::@3
  __b3:
    // [7] *((const byte*) SCREEN + (byte) idx#15) ← (byte) ' ' -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #' '
    ldy.z idx
    sta SCREEN,y
    // [8] (byte) idx#2 ← ++ (byte) idx#15 -- vbuz1=_inc_vbuz2 
    ldy.z idx
    iny
    sty.z idx_1
    // [9] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
  __b4_from___b3:
    // [9] phi (byte) idx#10 = (byte) idx#2 [phi:main::@3->main::@4#0] -- register_copy 
    // [9] 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:
    // [10] (byte) main::j#1 ← -- (byte) main::j#2 -- vbuz1=_dec_vbuz1 
    dec.z j
    // [11] 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:
    // [12] *((const byte*) SCREEN + (byte) idx#10) ← (byte) ' ' -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #' '
    ldy.z idx_1
    sta SCREEN,y
    // [13] (byte) idx#4 ← ++ (byte) idx#10 -- vbuz1=_inc_vbuz2 
    ldy.z idx_1
    iny
    sty.z idx_2
    // [14] phi from main::@6 to main::@7 [phi:main::@6->main::@7]
  __b7_from___b6:
    // [14] phi (byte) idx#12 = (byte) idx#4 [phi:main::@6->main::@7#0] -- register_copy 
    // [14] phi (byte) main::k#2 = (byte) 2 [phi:main::@6->main::@7#1] -- vbuz1=vbuc1 
    lda #2
    sta.z k
    jmp __b7
    // [14] phi from main::@7 to main::@7 [phi:main::@7->main::@7]
  __b7_from___b7:
    // [14] phi (byte) idx#12 = (byte) idx#13 [phi:main::@7->main::@7#0] -- register_copy 
    // [14] phi (byte) main::k#2 = (byte) main::k#1 [phi:main::@7->main::@7#1] -- register_copy 
    jmp __b7
    // main::@7
  __b7:
    // [15] *((const byte*) SCREEN + (byte) idx#12) ← (byte) main::k#2 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda.z k
    ldy.z idx_2
    sta SCREEN,y
    // [16] (byte) idx#13 ← ++ (byte) idx#12 -- vbuz1=_inc_vbuz1 
    inc.z idx_2
    // [17] (byte) main::k#1 ← -- (byte) main::k#2 -- vbuz1=_dec_vbuz1 
    dec.z k
    // [18] 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:
    // [19] return 
    rts
    // main::@5
  __b5:
    // [20] *((const byte*) SCREEN + (byte) idx#10) ← (byte) main::j#1 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda.z j
    ldy.z idx_1
    sta SCREEN,y
    // [21] (byte) idx#3 ← ++ (byte) idx#10 -- vbuz1=_inc_vbuz1 
    inc.z idx_1
    // [9] phi from main::@5 to main::@4 [phi:main::@5->main::@4]
  __b4_from___b5:
    // [9] phi (byte) idx#10 = (byte) idx#3 [phi:main::@5->main::@4#0] -- register_copy 
    // [9] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@5->main::@4#1] -- register_copy 
    jmp __b4
    // main::@2
  __b2:
    // [22] *((const byte*) SCREEN + (byte) idx#15) ← (byte) main::i#2 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda.z i
    ldy.z idx
    sta SCREEN,y
    // [23] (byte) idx#1 ← ++ (byte) idx#15 -- vbuz1=_inc_vbuz1 
    inc.z idx
    // [24] (byte) main::i#1 ← -- (byte) main::i#2 -- vbuz1=_dec_vbuz1 
    dec.z i
    // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  __b1_from___b2:
    // [5] phi (byte) idx#15 = (byte) idx#1 [phi:main::@2->main::@1#0] -- register_copy 
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#1] -- register_copy 
    jmp __b1
}
  // File Data

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

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

Uplifting [main] best 1079 combination reg byte x [ main::i#2 main::i#1 ] reg byte a [ main::j#2 main::j#1 ] reg byte a [ main::k#2 main::k#1 ] 
Uplifting [] best 851 combination reg byte y [ idx#10 idx#2 idx#3 ] reg byte y [ idx#12 idx#13 idx#4 ] reg byte y [ idx#15 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::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (byte) idx#15 = (byte) 0 [phi:main->main::@1#0] -- vbuyy=vbuc1 
    ldy #0
    // [5] phi (byte) main::i#2 = (byte) 2 [phi:main->main::@1#1] -- vbuxx=vbuc1 
    ldx #2
    jmp __b1
  // for()
    // main::@1
  __b1:
    // [6] if((byte) 0!=(byte) main::i#2) goto main::@2 -- vbuc1_neq_vbuxx_then_la1 
    cpx #0
    bne __b2
    jmp __b3
    // main::@3
  __b3:
    // [7] *((const byte*) SCREEN + (byte) idx#15) ← (byte) ' ' -- pbuc1_derefidx_vbuyy=vbuc2 
    lda #' '
    sta SCREEN,y
    // [8] (byte) idx#2 ← ++ (byte) idx#15 -- vbuyy=_inc_vbuyy 
    iny
    // [9] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
  __b4_from___b3:
    // [9] phi (byte) idx#10 = (byte) idx#2 [phi:main::@3->main::@4#0] -- register_copy 
    // [9] phi (byte) main::j#2 = (byte) 3 [phi:main::@3->main::@4#1] -- vbuaa=vbuc1 
    lda #3
    jmp __b4
    // main::@4
  __b4:
    // [10] (byte) main::j#1 ← -- (byte) main::j#2 -- vbuaa=_dec_vbuaa 
    sec
    sbc #1
    // [11] if((byte) 0!=(byte) main::j#1) goto main::@5 -- vbuc1_neq_vbuaa_then_la1 
    cmp #0
    bne __b5
    jmp __b6
    // main::@6
  __b6:
    // [12] *((const byte*) SCREEN + (byte) idx#10) ← (byte) ' ' -- pbuc1_derefidx_vbuyy=vbuc2 
    lda #' '
    sta SCREEN,y
    // [13] (byte) idx#4 ← ++ (byte) idx#10 -- vbuyy=_inc_vbuyy 
    iny
    // [14] phi from main::@6 to main::@7 [phi:main::@6->main::@7]
  __b7_from___b6:
    // [14] phi (byte) idx#12 = (byte) idx#4 [phi:main::@6->main::@7#0] -- register_copy 
    // [14] phi (byte) main::k#2 = (byte) 2 [phi:main::@6->main::@7#1] -- vbuaa=vbuc1 
    lda #2
    jmp __b7
    // [14] phi from main::@7 to main::@7 [phi:main::@7->main::@7]
  __b7_from___b7:
    // [14] phi (byte) idx#12 = (byte) idx#13 [phi:main::@7->main::@7#0] -- register_copy 
    // [14] phi (byte) main::k#2 = (byte) main::k#1 [phi:main::@7->main::@7#1] -- register_copy 
    jmp __b7
    // main::@7
  __b7:
    // [15] *((const byte*) SCREEN + (byte) idx#12) ← (byte) main::k#2 -- pbuc1_derefidx_vbuyy=vbuaa 
    sta SCREEN,y
    // [16] (byte) idx#13 ← ++ (byte) idx#12 -- vbuyy=_inc_vbuyy 
    iny
    // [17] (byte) main::k#1 ← -- (byte) main::k#2 -- vbuaa=_dec_vbuaa 
    sec
    sbc #1
    // [18] 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:
    // [19] return 
    rts
    // main::@5
  __b5:
    // [20] *((const byte*) SCREEN + (byte) idx#10) ← (byte) main::j#1 -- pbuc1_derefidx_vbuyy=vbuaa 
    sta SCREEN,y
    // [21] (byte) idx#3 ← ++ (byte) idx#10 -- vbuyy=_inc_vbuyy 
    iny
    // [9] phi from main::@5 to main::@4 [phi:main::@5->main::@4]
  __b4_from___b5:
    // [9] phi (byte) idx#10 = (byte) idx#3 [phi:main::@5->main::@4#0] -- register_copy 
    // [9] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@5->main::@4#1] -- register_copy 
    jmp __b4
    // main::@2
  __b2:
    // [22] *((const byte*) SCREEN + (byte) idx#15) ← (byte) main::i#2 -- pbuc1_derefidx_vbuyy=vbuxx 
    txa
    sta SCREEN,y
    // [23] (byte) idx#1 ← ++ (byte) idx#15 -- vbuyy=_inc_vbuyy 
    iny
    // [24] (byte) main::i#1 ← -- (byte) main::i#2 -- vbuxx=_dec_vbuxx 
    dex
    // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  __b1_from___b2:
    // [5] phi (byte) idx#15 = (byte) idx#1 [phi:main::@2->main::@1#0] -- register_copy 
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#1] -- register_copy 
    jmp __b1
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
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 __bbegin with __b1
Replacing label __b7_from___b7 with __b7
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Removing instruction __b7_from___b7:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __b1_from_main:
Removing instruction __b3:
Removing instruction __b4_from___b3:
Removing instruction __b6:
Removing instruction __b7_from___b6:
Removing instruction __breturn:
Removing instruction __b4_from___b5:
Removing instruction __b1_from___b2:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction jmp __b7
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(const byte*) SCREEN = (byte*) 1024
(byte) idx
(byte) idx#1 reg byte y 11.0
(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#15 reg byte y 9.25
(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 22.0
(byte) main::i#2 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#2 main::i#1 ]
reg byte y [ idx#15 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: 629

  // 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::@1 [phi:main->main::@1]
    // [5] phi (byte) idx#15 = (byte) 0 [phi:main->main::@1#0] -- vbuyy=vbuc1 
    ldy #0
    // [5] phi (byte) main::i#2 = (byte) 2 [phi:main->main::@1#1] -- vbuxx=vbuc1 
    ldx #2
  // for()
    // main::@1
  __b1:
    // for( byte i=2;i;i--)
    // [6] if((byte) 0!=(byte) main::i#2) goto main::@2 -- vbuc1_neq_vbuxx_then_la1 
    cpx #0
    bne __b2
    // main::@3
    // SCREEN[idx++] = ' '
    // [7] *((const byte*) SCREEN + (byte) idx#15) ← (byte) ' ' -- pbuc1_derefidx_vbuyy=vbuc2 
    lda #' '
    sta SCREEN,y
    // SCREEN[idx++] = ' ';
    // [8] (byte) idx#2 ← ++ (byte) idx#15 -- vbuyy=_inc_vbuyy 
    iny
    // [9] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
    // [9] phi (byte) idx#10 = (byte) idx#2 [phi:main::@3->main::@4#0] -- register_copy 
    // [9] phi (byte) main::j#2 = (byte) 3 [phi:main::@3->main::@4#1] -- vbuaa=vbuc1 
    lda #3
    // main::@4
  __b4:
    // while( j-- )
    // [10] (byte) main::j#1 ← -- (byte) main::j#2 -- vbuaa=_dec_vbuaa 
    sec
    sbc #1
    // [11] if((byte) 0!=(byte) main::j#1) goto main::@5 -- vbuc1_neq_vbuaa_then_la1 
    cmp #0
    bne __b5
    // main::@6
    // SCREEN[idx++] = ' '
    // [12] *((const byte*) SCREEN + (byte) idx#10) ← (byte) ' ' -- pbuc1_derefidx_vbuyy=vbuc2 
    lda #' '
    sta SCREEN,y
    // SCREEN[idx++] = ' ';
    // [13] (byte) idx#4 ← ++ (byte) idx#10 -- vbuyy=_inc_vbuyy 
    iny
    // [14] phi from main::@6 to main::@7 [phi:main::@6->main::@7]
    // [14] phi (byte) idx#12 = (byte) idx#4 [phi:main::@6->main::@7#0] -- register_copy 
    // [14] phi (byte) main::k#2 = (byte) 2 [phi:main::@6->main::@7#1] -- vbuaa=vbuc1 
    lda #2
    // [14] phi from main::@7 to main::@7 [phi:main::@7->main::@7]
    // [14] phi (byte) idx#12 = (byte) idx#13 [phi:main::@7->main::@7#0] -- register_copy 
    // [14] phi (byte) main::k#2 = (byte) main::k#1 [phi:main::@7->main::@7#1] -- register_copy 
    // main::@7
  __b7:
    // SCREEN[idx++] = k
    // [15] *((const byte*) SCREEN + (byte) idx#12) ← (byte) main::k#2 -- pbuc1_derefidx_vbuyy=vbuaa 
    sta SCREEN,y
    // SCREEN[idx++] = k;
    // [16] (byte) idx#13 ← ++ (byte) idx#12 -- vbuyy=_inc_vbuyy 
    iny
    // while(k--)
    // [17] (byte) main::k#1 ← -- (byte) main::k#2 -- vbuaa=_dec_vbuaa 
    sec
    sbc #1
    // [18] if((byte) 0!=(byte) main::k#1) goto main::@7 -- vbuc1_neq_vbuaa_then_la1 
    cmp #0
    bne __b7
    // main::@return
    // }
    // [19] return 
    rts
    // main::@5
  __b5:
    // SCREEN[idx++] = j
    // [20] *((const byte*) SCREEN + (byte) idx#10) ← (byte) main::j#1 -- pbuc1_derefidx_vbuyy=vbuaa 
    sta SCREEN,y
    // SCREEN[idx++] = j;
    // [21] (byte) idx#3 ← ++ (byte) idx#10 -- vbuyy=_inc_vbuyy 
    iny
    // [9] phi from main::@5 to main::@4 [phi:main::@5->main::@4]
    // [9] phi (byte) idx#10 = (byte) idx#3 [phi:main::@5->main::@4#0] -- register_copy 
    // [9] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@5->main::@4#1] -- register_copy 
    jmp __b4
    // main::@2
  __b2:
    // SCREEN[idx++] = i
    // [22] *((const byte*) SCREEN + (byte) idx#15) ← (byte) main::i#2 -- pbuc1_derefidx_vbuyy=vbuxx 
    txa
    sta SCREEN,y
    // SCREEN[idx++] = i;
    // [23] (byte) idx#1 ← ++ (byte) idx#15 -- vbuyy=_inc_vbuyy 
    iny
    // for( byte i=2;i;i--)
    // [24] (byte) main::i#1 ← -- (byte) main::i#2 -- vbuxx=_dec_vbuxx 
    dex
    // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
    // [5] phi (byte) idx#15 = (byte) idx#1 [phi:main::@2->main::@1#0] -- register_copy 
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#1] -- register_copy 
    jmp __b1
}
  // File Data

