Warning! Adding boolean cast to non-boolean sub-expression (number) 0
Warning! Adding boolean cast to non-boolean sub-expression (number) $3e7
Warning! Adding boolean cast to non-boolean sub-expression (byte) main::i
Warning! Adding boolean cast to non-boolean sub-expression (word) main::i1
Culled Empty Block (label) main::@12

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

SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(byte*) SCREEN
(byte*) SCREEN#0
(void()) main()
(bool~) main::$0
(bool~) main::$1
(bool~) main::$2
(bool~) main::$3
(bool~) main::$4
(bool~) main::$5
(bool~) main::$6
(bool~) main::$7
(label) main::@1
(label) main::@10
(label) main::@11
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@6
(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::i#4
(word) main::i1
(word) main::i1#0
(word) main::i1#1
(word) main::i1#2
(word) main::i1#3
(word) main::i1#4
(byte) main::idx
(byte) main::idx#0
(byte) main::idx#1
(byte) main::idx#10
(byte) main::idx#11
(byte) main::idx#12
(byte) main::idx#13
(byte) main::idx#14
(byte) main::idx#15
(byte) main::idx#16
(byte) main::idx#17
(byte) main::idx#2
(byte) main::idx#3
(byte) main::idx#4
(byte) main::idx#5
(byte) main::idx#6
(byte) main::idx#7
(byte) main::idx#8
(byte) main::idx#9

Adding number conversion cast (unumber) 0 in (byte) main::idx#0 ← (number) 0
Adding number conversion cast (unumber) 0 in (bool~) main::$6 ← (number) 0 != (byte) main::i#2
Adding number conversion cast (unumber) 0 in (bool~) main::$7 ← (number) 0 != (word) main::i1#2
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
Inlining cast (byte) main::idx#0 ← (unumber)(number) 0
Successful SSA optimization Pass2InlineCast
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
Inversing boolean not [19] (bool~) main::$2 ← (byte) 0 == (byte) main::i#2 from [18] (bool~) main::$6 ← (byte) 0 != (byte) main::i#2
Inversing boolean not [34] (bool~) main::$4 ← (byte) 0 == (word) main::i1#2 from [33] (bool~) main::$7 ← (byte) 0 != (word) main::i1#2
Successful SSA optimization Pass2UnaryNotSimplification
Alias (byte) main::idx#0 = (byte) main::idx#7 
Alias (byte) main::idx#13 = (byte) main::idx#9 
Alias (byte) main::idx#10 = (byte) main::idx#14 
Alias (byte) main::i#2 = (byte) main::i#4 
Alias (byte) main::idx#11 = (byte) main::idx#15 
Alias (byte) main::idx#12 = (byte) main::idx#16 
Alias (word) main::i1#2 = (word) main::i1#4 
Successful SSA optimization Pass2AliasElimination
Alias (byte) main::i#2 = (byte) main::i#3 
Alias (word) main::i1#2 = (word) main::i1#3 
Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) main::$2 [20] if((byte) 0==(byte) main::i#2) goto main::@6
Simple Condition (bool~) main::$3 [24] if((byte) main::i#1!=rangelast(0,2)) goto main::@5
Simple Condition (bool~) main::$4 [35] if((byte) 0==(word) main::i1#2) goto main::@10
Simple Condition (bool~) main::$5 [39] if((word) main::i1#1!=rangelast(0,2)) goto main::@9
Successful SSA optimization Pass2ConditionalJumpSimplification
Rewriting ! if()-condition to reversed if() [2] (bool~) main::$0 ← ! (number) 0!=(number) 0
Successful SSA optimization Pass2ConditionalAndOrRewriting
Rewriting ! if()-condition to reversed if() [5] (bool~) main::$1 ← ! (number) 0!=(number) $3e7
Successful SSA optimization Pass2ConditionalAndOrRewriting
Constant (const byte*) SCREEN#0 = (byte*) 1024
Constant (const byte) main::idx#0 = 0
Constant (const byte) main::i#0 = 0
Constant (const word) main::i1#0 = 0
Successful SSA optimization Pass2ConstantIdentification
if() condition always false - eliminating [3] if((number) 0!=(number) 0) goto main::@3
Removing PHI-reference to removed block (main::@1) in block main::@2
if() condition always true - replacing block destination [6] if((number) 0!=(number) $3e7) goto main::@4
Successful SSA optimization Pass2ConstantIfs
Resolved ranged next value [22] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [24] if(main::i#1!=rangelast(0,2)) goto main::@5 to (number) 3
Resolved ranged next value [37] main::i1#1 ← ++ main::i1#2 to ++
Resolved ranged comparison value [39] if(main::i1#1!=rangelast(0,2)) goto main::@9 to (number) 3
Simplifying expression containing zero SCREEN#0 in [8] *((const byte*) SCREEN#0 + (const byte) main::idx#0) ← (byte) '0'
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating variable (byte) main::idx#1 from unused block main::@3
Removing PHI-reference to removed block (main::@3) in block main::@1
Removing unused block main::@3
Successful SSA optimization Pass2EliminateUnusedBlocks
Successful SSA optimization Pass2LoopHeadConstantIdentification
Successful SSA optimization Pass2LoopHeadConstantIdentification
Adding number conversion cast (unumber) 3 in if((byte) main::i#1!=(number) 3) goto main::@5
Adding number conversion cast (unumber) 3 in if((word) main::i1#1!=(number) 3) goto main::@9
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 3
Simplifying constant integer cast 3
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 3
Finalized unsigned number type (byte) 3
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte) main::idx#3 = (byte) main::idx#8 
Alias (byte) main::i#1 = (byte) main::i#2 
Alias (byte) main::idx#10 = (byte) main::idx#11 
Alias (word) main::i1#1 = (word) main::i1#2 
Alias (byte) main::idx#12 = (byte) main::idx#17 
Alias (byte) main::idx#19 = (byte) main::idx#2 
Alias (byte) main::idx#21 = (byte) main::idx#5 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) main::idx#13 (const byte) main::idx#0
Identical Phi Values (byte) main::i#7 (const byte) main::i#0
Identical Phi Values (word) main::i1#7 (const word) main::i1#0
Successful SSA optimization Pass2IdenticalPhiElimination
Constant right-side identified [5] (byte) main::idx#3 ← ++ (const byte) main::idx#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#3 = ++main::idx#0
Successful SSA optimization Pass2ConstantIdentification
Removing PHI-reference to removed block (main::@5_1) in block main::@7
Removing PHI-reference to removed block (main::@5_1) in block main::@7
if() condition always true - replacing block destination [27] if((byte) 0==(const byte) main::i#0) goto main::@6
Removing PHI-reference to removed block (main::@9_1) in block main::@11
Removing PHI-reference to removed block (main::@9_1) in block main::@11
if() condition always true - replacing block destination [29] if((byte) 0==(const word) main::i1#0) goto main::@10
Successful SSA optimization Pass2ConstantIfs
Simplifying expression containing zero SCREEN#0 in [4] *((const byte*) SCREEN#0 + (const byte) main::idx#0) ← (byte) '+'
Successful SSA optimization PassNSimplifyExpressionWithZero
Alias (byte) main::i#1 = (byte) main::i#6 
Alias (byte) main::idx#10 = (byte) main::idx#18 
Alias (word) main::i1#1 = (word) main::i1#6 
Alias (byte) main::idx#12 = (byte) main::idx#20 
Successful SSA optimization Pass2AliasElimination
Constant right-side identified [1] (byte) main::idx#19 ← ++ (const byte) main::idx#3
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#19 = ++main::idx#3
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with var siblings (const byte) main::idx#0
Inlining constant with var siblings (const byte) main::i#0
Inlining constant with var siblings (const word) main::i1#0
Inlining constant with var siblings (const byte) main::idx#3
Inlining constant with var siblings (const byte) main::idx#19
Constant inlined main::i#0 = (byte) 0
Constant inlined main::i1#0 = (word) 0
Constant inlined main::idx#0 = (byte) 0
Constant inlined main::idx#19 = ++++(byte) 0
Constant inlined main::idx#3 = ++(byte) 0
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(SCREEN#0+++0)
Successful SSA optimization Pass2ConstantAdditionElimination
Simplifying constant integer increment ++0
Simplifying constant integer increment ++0
Successful SSA optimization Pass2ConstantSimplification
Simplifying constant integer increment ++1
Successful SSA optimization Pass2ConstantSimplification
Added new block during phi lifting main::@13(between main::@5 and main::@6)
Added new block during phi lifting main::@14(between main::@9 and main::@10)
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
Adding NOP phi() at start of main::@5_1
CALL GRAPH
Calls in [] to main:2 

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


VARIABLE REGISTER WEIGHTS
(byte*) SCREEN
(void()) main()
(byte) main::i
(byte) main::i#1 83.0
(byte) main::i#5 213.0
(word) main::i1
(word) main::i1#1 83.0
(word) main::i1#5 213.0
(byte) main::idx
(byte) main::idx#10 39.83333333333334
(byte) main::idx#12 47.400000000000006
(byte) main::idx#21 4.0
(byte) main::idx#4 22.0
(byte) main::idx#6 22.0

Initial phi equivalence classes
[ main::idx#10 main::idx#4 ]
[ main::i#5 main::i#1 ]
[ main::idx#12 main::idx#6 main::idx#21 ]
[ main::i1#5 main::i1#1 ]
Complete equivalence classes
[ main::idx#10 main::idx#4 ]
[ main::i#5 main::i#1 ]
[ main::idx#12 main::idx#6 main::idx#21 ]
[ main::i1#5 main::i1#1 ]
Allocated zp ZP_BYTE:2 [ main::idx#10 main::idx#4 ]
Allocated zp ZP_BYTE:3 [ main::i#5 main::i#1 ]
Allocated zp ZP_BYTE:4 [ main::idx#12 main::idx#6 main::idx#21 ]
Allocated zp ZP_WORD:5 [ main::i1#5 main::i1#1 ]

INITIAL ASM
Target platform is c64basic
  // File Comments
// Tests using integer conditions in if()
// This should produce '+ ++ ++' 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: {
    .label i = 3
    .label idx = 2
    .label i1 = 5
    .label idx_6 = 4
    .label idx_12 = 4
    .label idx_21 = 4
    jmp b2
    // main::@2
  b2:
    // [5] *((const byte*) SCREEN#0) ← (byte) '+' -- _deref_pbuc1=vbuc2 
    lda #'+'
    sta SCREEN
    jmp b1
    // main::@1
  b1:
    // [6] *((const byte*) SCREEN#0+(byte) 1) ← (byte) ' ' -- _deref_pbuc1=vbuc2 
    lda #' '
    sta SCREEN+1
    // [7] phi from main::@1 to main::@4 [phi:main::@1->main::@4]
  b4_from_b1:
    // [7] phi (byte) main::i#5 = (byte) 0 [phi:main::@1->main::@4#0] -- vbuz1=vbuc1 
    lda #0
    sta.z i
    // [7] phi (byte) main::idx#10 = (byte) 2 [phi:main::@1->main::@4#1] -- vbuz1=vbuc1 
    lda #2
    sta.z idx
    jmp b4
    // [7] phi from main::@3 main::@5 to main::@4 [phi:main::@3/main::@5->main::@4]
  b4_from_b3:
  b4_from_b5:
    // [7] phi (byte) main::i#5 = (byte) main::i#1 [phi:main::@3/main::@5->main::@4#0] -- register_copy 
    // [7] phi (byte) main::idx#10 = (byte) main::idx#10 [phi:main::@3/main::@5->main::@4#1] -- register_copy 
    jmp b4
    // main::@4
  b4:
    // [8] (byte) main::i#1 ← ++ (byte) main::i#5 -- vbuz1=_inc_vbuz1 
    inc.z i
    // [9] if((byte) main::i#1!=(byte) 3) goto main::@3 -- vbuz1_neq_vbuc1_then_la1 
    lda #3
    cmp.z i
    bne b3
    jmp b6
    // main::@6
  b6:
    // [10] *((const byte*) SCREEN#0 + (byte) main::idx#10) ← (byte) ' ' -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #' '
    ldy.z idx
    sta SCREEN,y
    // [11] (byte) main::idx#21 ← ++ (byte) main::idx#10 -- vbuz1=_inc_vbuz2 
    ldy.z idx
    iny
    sty.z idx_21
    // [12] phi from main::@6 to main::@8 [phi:main::@6->main::@8]
  b8_from_b6:
    // [12] phi (word) main::i1#5 = (word) 0 [phi:main::@6->main::@8#0] -- vwuz1=vwuc1 
    lda #<0
    sta.z i1
    lda #>0
    sta.z i1+1
    // [12] phi (byte) main::idx#12 = (byte) main::idx#21 [phi:main::@6->main::@8#1] -- register_copy 
    jmp b8
    // [12] phi from main::@7 main::@9 to main::@8 [phi:main::@7/main::@9->main::@8]
  b8_from_b7:
  b8_from_b9:
    // [12] phi (word) main::i1#5 = (word) main::i1#1 [phi:main::@7/main::@9->main::@8#0] -- register_copy 
    // [12] phi (byte) main::idx#12 = (byte) main::idx#12 [phi:main::@7/main::@9->main::@8#1] -- register_copy 
    jmp b8
    // main::@8
  b8:
    // [13] (word) main::i1#1 ← ++ (word) main::i1#5 -- vwuz1=_inc_vwuz1 
    inc.z i1
    bne !+
    inc.z i1+1
  !:
    // [14] if((word) main::i1#1!=(byte) 3) goto main::@7 -- vwuz1_neq_vwuc1_then_la1 
    lda.z i1+1
    cmp #>3
    bne b7
    lda.z i1
    cmp #<3
    bne b7
    jmp breturn
    // main::@return
  breturn:
    // [15] return 
    rts
  // loop word
    // main::@7
  b7:
    // [16] if((byte) 0==(word) main::i1#1) goto main::@8 -- vwuc1_eq_vwuz1_then_la1 
    lda.z i1
    cmp #<0
    bne !+
    lda.z i1+1
    cmp #>0
    beq b8_from_b7
  !:
    jmp b9
    // main::@9
  b9:
    // [17] *((const byte*) SCREEN#0 + (byte) main::idx#12) ← (byte) '+' -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #'+'
    ldy.z idx_12
    sta SCREEN,y
    // [18] (byte) main::idx#6 ← ++ (byte) main::idx#12 -- vbuz1=_inc_vbuz1 
    inc.z idx_6
    jmp b8_from_b9
  // loop byte
    // main::@3
  b3:
    // [19] if((byte) 0==(byte) main::i#1) goto main::@4 -- vbuc1_eq_vbuz1_then_la1 
    lda #0
    cmp.z i
    beq b4_from_b3
    jmp b5
    // main::@5
  b5:
    // [20] *((const byte*) SCREEN#0 + (byte) main::idx#10) ← (byte) '+' -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #'+'
    ldy.z idx
    sta SCREEN,y
    // [21] (byte) main::idx#4 ← ++ (byte) main::idx#10 -- vbuz1=_inc_vbuz1 
    inc.z idx
    jmp b4_from_b5
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [5] *((const byte*) SCREEN#0) ← (byte) '+' [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [6] *((const byte*) SCREEN#0+(byte) 1) ← (byte) ' ' [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [10] *((const byte*) SCREEN#0 + (byte) main::idx#10) ← (byte) ' ' [ main::idx#10 ] ( main:2 [ main::idx#10 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::idx#10 main::idx#4 ]
Statement [14] if((word) main::i1#1!=(byte) 3) goto main::@7 [ main::idx#12 main::i1#1 ] ( main:2 [ main::idx#12 main::i1#1 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:4 [ main::idx#12 main::idx#6 main::idx#21 ]
Statement [16] if((byte) 0==(word) main::i1#1) goto main::@8 [ main::idx#12 main::i1#1 ] ( main:2 [ main::idx#12 main::i1#1 ] ) always clobbers reg byte a 
Statement [17] *((const byte*) SCREEN#0 + (byte) main::idx#12) ← (byte) '+' [ main::idx#12 main::i1#1 ] ( main:2 [ main::idx#12 main::i1#1 ] ) always clobbers reg byte a 
Statement [20] *((const byte*) SCREEN#0 + (byte) main::idx#10) ← (byte) '+' [ main::idx#10 main::i#1 ] ( main:2 [ main::idx#10 main::i#1 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:3 [ main::i#5 main::i#1 ]
Statement [5] *((const byte*) SCREEN#0) ← (byte) '+' [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [6] *((const byte*) SCREEN#0+(byte) 1) ← (byte) ' ' [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [10] *((const byte*) SCREEN#0 + (byte) main::idx#10) ← (byte) ' ' [ main::idx#10 ] ( main:2 [ main::idx#10 ] ) always clobbers reg byte a 
Statement [14] if((word) main::i1#1!=(byte) 3) goto main::@7 [ main::idx#12 main::i1#1 ] ( main:2 [ main::idx#12 main::i1#1 ] ) always clobbers reg byte a 
Statement [16] if((byte) 0==(word) main::i1#1) goto main::@8 [ main::idx#12 main::i1#1 ] ( main:2 [ main::idx#12 main::i1#1 ] ) always clobbers reg byte a 
Statement [17] *((const byte*) SCREEN#0 + (byte) main::idx#12) ← (byte) '+' [ main::idx#12 main::i1#1 ] ( main:2 [ main::idx#12 main::i1#1 ] ) always clobbers reg byte a 
Statement [20] *((const byte*) SCREEN#0 + (byte) main::idx#10) ← (byte) '+' [ main::idx#10 main::i#1 ] ( main:2 [ main::idx#10 main::i#1 ] ) always clobbers reg byte a 
Potential registers zp ZP_BYTE:2 [ main::idx#10 main::idx#4 ] : zp ZP_BYTE:2 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:3 [ main::i#5 main::i#1 ] : zp ZP_BYTE:3 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:4 [ main::idx#12 main::idx#6 main::idx#21 ] : zp ZP_BYTE:4 , reg byte x , reg byte y , 
Potential registers zp ZP_WORD:5 [ main::i1#5 main::i1#1 ] : zp ZP_WORD:5 , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 296: zp ZP_BYTE:3 [ main::i#5 main::i#1 ] 296: zp ZP_WORD:5 [ main::i1#5 main::i1#1 ] 73.4: zp ZP_BYTE:4 [ main::idx#12 main::idx#6 main::idx#21 ] 61.83: zp ZP_BYTE:2 [ main::idx#10 main::idx#4 ] 
Uplift Scope [] 

Uplifting [main] best 9462 combination reg byte y [ main::i#5 main::i#1 ] zp ZP_WORD:5 [ main::i1#5 main::i1#1 ] reg byte x [ main::idx#12 main::idx#6 main::idx#21 ] reg byte x [ main::idx#10 main::idx#4 ] 
Uplifting [] best 9462 combination 
Allocated (was zp ZP_WORD:5) zp ZP_WORD:2 [ main::i1#5 main::i1#1 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests using integer conditions in if()
// This should produce '+ ++ ++' 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: {
    .label i1 = 2
    jmp b2
    // main::@2
  b2:
    // [5] *((const byte*) SCREEN#0) ← (byte) '+' -- _deref_pbuc1=vbuc2 
    lda #'+'
    sta SCREEN
    jmp b1
    // main::@1
  b1:
    // [6] *((const byte*) SCREEN#0+(byte) 1) ← (byte) ' ' -- _deref_pbuc1=vbuc2 
    lda #' '
    sta SCREEN+1
    // [7] phi from main::@1 to main::@4 [phi:main::@1->main::@4]
  b4_from_b1:
    // [7] phi (byte) main::i#5 = (byte) 0 [phi:main::@1->main::@4#0] -- vbuyy=vbuc1 
    ldy #0
    // [7] phi (byte) main::idx#10 = (byte) 2 [phi:main::@1->main::@4#1] -- vbuxx=vbuc1 
    ldx #2
    jmp b4
    // [7] phi from main::@3 main::@5 to main::@4 [phi:main::@3/main::@5->main::@4]
  b4_from_b3:
  b4_from_b5:
    // [7] phi (byte) main::i#5 = (byte) main::i#1 [phi:main::@3/main::@5->main::@4#0] -- register_copy 
    // [7] phi (byte) main::idx#10 = (byte) main::idx#10 [phi:main::@3/main::@5->main::@4#1] -- register_copy 
    jmp b4
    // main::@4
  b4:
    // [8] (byte) main::i#1 ← ++ (byte) main::i#5 -- vbuyy=_inc_vbuyy 
    iny
    // [9] if((byte) main::i#1!=(byte) 3) goto main::@3 -- vbuyy_neq_vbuc1_then_la1 
    cpy #3
    bne b3
    jmp b6
    // main::@6
  b6:
    // [10] *((const byte*) SCREEN#0 + (byte) main::idx#10) ← (byte) ' ' -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #' '
    sta SCREEN,x
    // [11] (byte) main::idx#21 ← ++ (byte) main::idx#10 -- vbuxx=_inc_vbuxx 
    inx
    // [12] phi from main::@6 to main::@8 [phi:main::@6->main::@8]
  b8_from_b6:
    // [12] phi (word) main::i1#5 = (word) 0 [phi:main::@6->main::@8#0] -- vwuz1=vwuc1 
    lda #<0
    sta.z i1
    lda #>0
    sta.z i1+1
    // [12] phi (byte) main::idx#12 = (byte) main::idx#21 [phi:main::@6->main::@8#1] -- register_copy 
    jmp b8
    // [12] phi from main::@7 main::@9 to main::@8 [phi:main::@7/main::@9->main::@8]
  b8_from_b7:
  b8_from_b9:
    // [12] phi (word) main::i1#5 = (word) main::i1#1 [phi:main::@7/main::@9->main::@8#0] -- register_copy 
    // [12] phi (byte) main::idx#12 = (byte) main::idx#12 [phi:main::@7/main::@9->main::@8#1] -- register_copy 
    jmp b8
    // main::@8
  b8:
    // [13] (word) main::i1#1 ← ++ (word) main::i1#5 -- vwuz1=_inc_vwuz1 
    inc.z i1
    bne !+
    inc.z i1+1
  !:
    // [14] if((word) main::i1#1!=(byte) 3) goto main::@7 -- vwuz1_neq_vwuc1_then_la1 
    lda.z i1+1
    cmp #>3
    bne b7
    lda.z i1
    cmp #<3
    bne b7
    jmp breturn
    // main::@return
  breturn:
    // [15] return 
    rts
  // loop word
    // main::@7
  b7:
    // [16] if((byte) 0==(word) main::i1#1) goto main::@8 -- vwuc1_eq_vwuz1_then_la1 
    lda.z i1
    cmp #<0
    bne !+
    lda.z i1+1
    cmp #>0
    beq b8_from_b7
  !:
    jmp b9
    // main::@9
  b9:
    // [17] *((const byte*) SCREEN#0 + (byte) main::idx#12) ← (byte) '+' -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #'+'
    sta SCREEN,x
    // [18] (byte) main::idx#6 ← ++ (byte) main::idx#12 -- vbuxx=_inc_vbuxx 
    inx
    jmp b8_from_b9
  // loop byte
    // main::@3
  b3:
    // [19] if((byte) 0==(byte) main::i#1) goto main::@4 -- vbuc1_eq_vbuyy_then_la1 
    cpy #0
    beq b4_from_b3
    jmp b5
    // main::@5
  b5:
    // [20] *((const byte*) SCREEN#0 + (byte) main::idx#10) ← (byte) '+' -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #'+'
    sta SCREEN,x
    // [21] (byte) main::idx#4 ← ++ (byte) main::idx#10 -- vbuxx=_inc_vbuxx 
    inx
    jmp b4_from_b5
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b2
Removing instruction jmp b1
Removing instruction jmp b4
Removing instruction jmp b6
Removing instruction jmp b8
Removing instruction jmp breturn
Removing instruction jmp b9
Removing instruction jmp b5
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda #>0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Replacing label b8_from_b7 with b8
Replacing label b8_from_b9 with b8
Replacing label b4_from_b3 with b4
Replacing label b4_from_b5 with b4
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b4_from_b3:
Removing instruction b4_from_b5:
Removing instruction b8_from_b7:
Removing instruction b8_from_b9:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b2:
Removing instruction b1:
Removing instruction b4_from_b1:
Removing instruction b6:
Removing instruction b8_from_b6:
Removing instruction breturn:
Removing instruction b9:
Removing instruction b5:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction jmp b4
Removing instruction jmp b8
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
(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::@8
(label) main::@9
(label) main::@return
(byte) main::i
(byte) main::i#1 reg byte y 83.0
(byte) main::i#5 reg byte y 213.0
(word) main::i1
(word) main::i1#1 i1 zp ZP_WORD:2 83.0
(word) main::i1#5 i1 zp ZP_WORD:2 213.0
(byte) main::idx
(byte) main::idx#10 reg byte x 39.83333333333334
(byte) main::idx#12 reg byte x 47.400000000000006
(byte) main::idx#21 reg byte x 4.0
(byte) main::idx#4 reg byte x 22.0
(byte) main::idx#6 reg byte x 22.0

reg byte x [ main::idx#10 main::idx#4 ]
reg byte y [ main::i#5 main::i#1 ]
reg byte x [ main::idx#12 main::idx#6 main::idx#21 ]
zp ZP_WORD:2 [ main::i1#5 main::i1#1 ]


FINAL ASSEMBLER
Score: 6817

  // File Comments
// Tests using integer conditions in if()
// This should produce '+ ++ ++' 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: {
    .label i1 = 2
    // main::@2
    // SCREEN[idx++] = '+'
    // [5] *((const byte*) SCREEN#0) ← (byte) '+' -- _deref_pbuc1=vbuc2 
    lda #'+'
    sta SCREEN
    // main::@1
    // SCREEN[idx++] = ' '
    // [6] *((const byte*) SCREEN#0+(byte) 1) ← (byte) ' ' -- _deref_pbuc1=vbuc2 
    lda #' '
    sta SCREEN+1
    // [7] phi from main::@1 to main::@4 [phi:main::@1->main::@4]
    // [7] phi (byte) main::i#5 = (byte) 0 [phi:main::@1->main::@4#0] -- vbuyy=vbuc1 
    ldy #0
    // [7] phi (byte) main::idx#10 = (byte) 2 [phi:main::@1->main::@4#1] -- vbuxx=vbuc1 
    ldx #2
    // [7] phi from main::@3 main::@5 to main::@4 [phi:main::@3/main::@5->main::@4]
    // [7] phi (byte) main::i#5 = (byte) main::i#1 [phi:main::@3/main::@5->main::@4#0] -- register_copy 
    // [7] phi (byte) main::idx#10 = (byte) main::idx#10 [phi:main::@3/main::@5->main::@4#1] -- register_copy 
    // main::@4
  b4:
    // for( byte i:0..2)
    // [8] (byte) main::i#1 ← ++ (byte) main::i#5 -- vbuyy=_inc_vbuyy 
    iny
    // [9] if((byte) main::i#1!=(byte) 3) goto main::@3 -- vbuyy_neq_vbuc1_then_la1 
    cpy #3
    bne b3
    // main::@6
    // SCREEN[idx++] = ' '
    // [10] *((const byte*) SCREEN#0 + (byte) main::idx#10) ← (byte) ' ' -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #' '
    sta SCREEN,x
    // SCREEN[idx++] = ' ';
    // [11] (byte) main::idx#21 ← ++ (byte) main::idx#10 -- vbuxx=_inc_vbuxx 
    inx
    // [12] phi from main::@6 to main::@8 [phi:main::@6->main::@8]
    // [12] phi (word) main::i1#5 = (word) 0 [phi:main::@6->main::@8#0] -- vwuz1=vwuc1 
    lda #<0
    sta.z i1
    sta.z i1+1
    // [12] phi (byte) main::idx#12 = (byte) main::idx#21 [phi:main::@6->main::@8#1] -- register_copy 
    // [12] phi from main::@7 main::@9 to main::@8 [phi:main::@7/main::@9->main::@8]
    // [12] phi (word) main::i1#5 = (word) main::i1#1 [phi:main::@7/main::@9->main::@8#0] -- register_copy 
    // [12] phi (byte) main::idx#12 = (byte) main::idx#12 [phi:main::@7/main::@9->main::@8#1] -- register_copy 
    // main::@8
  b8:
    // for( word i:0..2)
    // [13] (word) main::i1#1 ← ++ (word) main::i1#5 -- vwuz1=_inc_vwuz1 
    inc.z i1
    bne !+
    inc.z i1+1
  !:
    // [14] if((word) main::i1#1!=(byte) 3) goto main::@7 -- vwuz1_neq_vwuc1_then_la1 
    lda.z i1+1
    cmp #>3
    bne b7
    lda.z i1
    cmp #<3
    bne b7
    // main::@return
    // }
    // [15] return 
    rts
  // loop word
    // main::@7
  b7:
    // if(i)
    // [16] if((byte) 0==(word) main::i1#1) goto main::@8 -- vwuc1_eq_vwuz1_then_la1 
    lda.z i1
    cmp #<0
    bne !+
    lda.z i1+1
    cmp #>0
    beq b8
  !:
    // main::@9
    // SCREEN[idx++] = '+'
    // [17] *((const byte*) SCREEN#0 + (byte) main::idx#12) ← (byte) '+' -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #'+'
    sta SCREEN,x
    // SCREEN[idx++] = '+';
    // [18] (byte) main::idx#6 ← ++ (byte) main::idx#12 -- vbuxx=_inc_vbuxx 
    inx
    jmp b8
  // loop byte
    // main::@3
  b3:
    // if(i)
    // [19] if((byte) 0==(byte) main::i#1) goto main::@4 -- vbuc1_eq_vbuyy_then_la1 
    cpy #0
    beq b4
    // main::@5
    // SCREEN[idx++] = '+'
    // [20] *((const byte*) SCREEN#0 + (byte) main::idx#10) ← (byte) '+' -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #'+'
    sta SCREEN,x
    // SCREEN[idx++] = '+';
    // [21] (byte) main::idx#4 ← ++ (byte) main::idx#10 -- vbuxx=_inc_vbuxx 
    inx
    jmp b4
}
  // File Data

