Identified constant variable (byte*) SCREEN
Culled Empty Block (label) main::@4
Culled Empty Block (label) @1
Culled Empty Block (label) nest1::@4
Culled Empty Block (label) @2
Culled Empty Block (label) nest2::@4

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) SCREEN#0 ← ((byte*)) (number) $400
  to:@3
main: scope:[main]  from @3
  (byte) main::i#0 ← (number) $64
  to:main::@1
main::@1: scope:[main]  from main main::@3
  (byte) main::i#5 ← phi( main/(byte) main::i#0 main::@3/(byte) main::i#1 )
  (byte) main::j#0 ← (number) $64
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@5
  (byte) main::i#4 ← phi( main::@1/(byte) main::i#5 main::@5/(byte) main::i#3 )
  (byte) main::j#3 ← phi( main::@1/(byte) main::j#0 main::@5/(byte) main::j#1 )
  call nest1 
  to:main::@5
main::@5: scope:[main]  from main::@2
  (byte) main::i#3 ← phi( main::@2/(byte) main::i#4 )
  (byte) main::j#2 ← phi( main::@2/(byte) main::j#3 )
  (byte) main::j#1 ← -- (byte) main::j#2
  (bool~) main::$1 ← (byte) main::j#1 > (number) 0
  if((bool~) main::$1) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@5
  (byte) main::i#2 ← phi( main::@5/(byte) main::i#3 )
  (byte) main::i#1 ← -- (byte) main::i#2
  (bool~) main::$2 ← (byte) main::i#1 > (number) 0
  if((bool~) main::$2) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@3
  return 
  to:@return
nest1: scope:[nest1]  from main::@2
  (byte) nest1::i#0 ← (number) $64
  to:nest1::@1
nest1::@1: scope:[nest1]  from nest1 nest1::@3
  (byte) nest1::i#5 ← phi( nest1/(byte) nest1::i#0 nest1::@3/(byte) nest1::i#1 )
  (byte) nest1::j#0 ← (number) $64
  to:nest1::@2
nest1::@2: scope:[nest1]  from nest1::@1 nest1::@5
  (byte) nest1::i#4 ← phi( nest1::@1/(byte) nest1::i#5 nest1::@5/(byte) nest1::i#3 )
  (byte) nest1::j#3 ← phi( nest1::@1/(byte) nest1::j#0 nest1::@5/(byte) nest1::j#1 )
  call nest2 
  to:nest1::@5
nest1::@5: scope:[nest1]  from nest1::@2
  (byte) nest1::i#3 ← phi( nest1::@2/(byte) nest1::i#4 )
  (byte) nest1::j#2 ← phi( nest1::@2/(byte) nest1::j#3 )
  (byte) nest1::j#1 ← -- (byte) nest1::j#2
  (bool~) nest1::$1 ← (byte) nest1::j#1 > (number) 0
  if((bool~) nest1::$1) goto nest1::@2
  to:nest1::@3
nest1::@3: scope:[nest1]  from nest1::@5
  (byte) nest1::i#2 ← phi( nest1::@5/(byte) nest1::i#3 )
  (byte) nest1::i#1 ← -- (byte) nest1::i#2
  (bool~) nest1::$2 ← (byte) nest1::i#1 > (number) 0
  if((bool~) nest1::$2) goto nest1::@1
  to:nest1::@return
nest1::@return: scope:[nest1]  from nest1::@3
  return 
  to:@return
nest2: scope:[nest2]  from nest1::@2
  (byte) nest2::i#0 ← (number) $64
  to:nest2::@1
nest2::@1: scope:[nest2]  from nest2 nest2::@3
  (byte) nest2::i#4 ← phi( nest2/(byte) nest2::i#0 nest2::@3/(byte) nest2::i#1 )
  (byte) nest2::j#0 ← (number) $64
  to:nest2::@2
nest2::@2: scope:[nest2]  from nest2::@1 nest2::@2
  (byte) nest2::i#3 ← phi( nest2::@1/(byte) nest2::i#4 nest2::@2/(byte) nest2::i#3 )
  (byte) nest2::j#2 ← phi( nest2::@1/(byte) nest2::j#0 nest2::@2/(byte) nest2::j#1 )
  *((byte*) SCREEN#0) ← (byte) nest2::j#2
  (byte) nest2::j#1 ← -- (byte) nest2::j#2
  (bool~) nest2::$0 ← (byte) nest2::j#1 > (number) 0
  if((bool~) nest2::$0) goto nest2::@2
  to:nest2::@3
nest2::@3: scope:[nest2]  from nest2::@2
  (byte) nest2::i#2 ← phi( nest2::@2/(byte) nest2::i#3 )
  (byte) nest2::i#1 ← -- (byte) nest2::i#2
  (bool~) nest2::$1 ← (byte) nest2::i#1 > (number) 0
  if((bool~) nest2::$1) goto nest2::@1
  to:nest2::@return
nest2::@return: scope:[nest2]  from nest2::@3
  return 
  to:@return
@3: scope:[]  from @begin
  call main 
  to:@4
@4: scope:[]  from @3
  to:@end
@end: scope:[]  from @4

SYMBOL TABLE SSA
(label) @3
(label) @4
(label) @begin
(label) @end
(byte*) SCREEN
(byte*) SCREEN#0
(void()) main()
(bool~) main::$1
(bool~) main::$2
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@5
(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
(byte) main::i#5
(byte) main::j
(byte) main::j#0
(byte) main::j#1
(byte) main::j#2
(byte) main::j#3
(void()) nest1()
(bool~) nest1::$1
(bool~) nest1::$2
(label) nest1::@1
(label) nest1::@2
(label) nest1::@3
(label) nest1::@5
(label) nest1::@return
(byte) nest1::i
(byte) nest1::i#0
(byte) nest1::i#1
(byte) nest1::i#2
(byte) nest1::i#3
(byte) nest1::i#4
(byte) nest1::i#5
(byte) nest1::j
(byte) nest1::j#0
(byte) nest1::j#1
(byte) nest1::j#2
(byte) nest1::j#3
(void()) nest2()
(bool~) nest2::$0
(bool~) nest2::$1
(label) nest2::@1
(label) nest2::@2
(label) nest2::@3
(label) nest2::@return
(byte) nest2::i
(byte) nest2::i#0
(byte) nest2::i#1
(byte) nest2::i#2
(byte) nest2::i#3
(byte) nest2::i#4
(byte) nest2::j
(byte) nest2::j#0
(byte) nest2::j#1
(byte) nest2::j#2

Adding number conversion cast (unumber) $64 in (byte) main::i#0 ← (number) $64
Adding number conversion cast (unumber) $64 in (byte) main::j#0 ← (number) $64
Adding number conversion cast (unumber) 0 in (bool~) main::$1 ← (byte) main::j#1 > (number) 0
Adding number conversion cast (unumber) 0 in (bool~) main::$2 ← (byte) main::i#1 > (number) 0
Adding number conversion cast (unumber) $64 in (byte) nest1::i#0 ← (number) $64
Adding number conversion cast (unumber) $64 in (byte) nest1::j#0 ← (number) $64
Adding number conversion cast (unumber) 0 in (bool~) nest1::$1 ← (byte) nest1::j#1 > (number) 0
Adding number conversion cast (unumber) 0 in (bool~) nest1::$2 ← (byte) nest1::i#1 > (number) 0
Adding number conversion cast (unumber) $64 in (byte) nest2::i#0 ← (number) $64
Adding number conversion cast (unumber) $64 in (byte) nest2::j#0 ← (number) $64
Adding number conversion cast (unumber) 0 in (bool~) nest2::$0 ← (byte) nest2::j#1 > (number) 0
Adding number conversion cast (unumber) 0 in (bool~) nest2::$1 ← (byte) nest2::i#1 > (number) 0
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
Inlining cast (byte) main::i#0 ← (unumber)(number) $64
Inlining cast (byte) main::j#0 ← (unumber)(number) $64
Inlining cast (byte) nest1::i#0 ← (unumber)(number) $64
Inlining cast (byte) nest1::j#0 ← (unumber)(number) $64
Inlining cast (byte) nest2::i#0 ← (unumber)(number) $64
Inlining cast (byte) nest2::j#0 ← (unumber)(number) $64
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast $64
Simplifying constant integer cast $64
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast $64
Simplifying constant integer cast $64
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast $64
Simplifying constant integer cast $64
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $64
Finalized unsigned number type (byte) $64
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $64
Finalized unsigned number type (byte) $64
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $64
Finalized unsigned number type (byte) $64
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte) main::j#2 = (byte) main::j#3 
Alias (byte) main::i#2 = (byte) main::i#3 (byte) main::i#4 
Alias (byte) nest1::j#2 = (byte) nest1::j#3 
Alias (byte) nest1::i#2 = (byte) nest1::i#3 (byte) nest1::i#4 
Alias (byte) nest2::i#2 = (byte) nest2::i#3 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) main::i#2 (byte) main::i#5
Identical Phi Values (byte) nest1::i#2 (byte) nest1::i#5
Identical Phi Values (byte) nest2::i#2 (byte) nest2::i#4
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$1 [9] if((byte) main::j#1>(byte) 0) goto main::@2
Simple Condition (bool~) main::$2 [13] if((byte) main::i#1>(byte) 0) goto main::@1
Simple Condition (bool~) nest1::$1 [23] if((byte) nest1::j#1>(byte) 0) goto nest1::@2
Simple Condition (bool~) nest1::$2 [27] if((byte) nest1::i#1>(byte) 0) goto nest1::@1
Simple Condition (bool~) nest2::$0 [36] if((byte) nest2::j#1>(byte) 0) goto nest2::@2
Simple Condition (bool~) nest2::$1 [40] if((byte) nest2::i#1>(byte) 0) goto nest2::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) SCREEN#0 = (byte*) 1024
Constant (const byte) main::i#0 = $64
Constant (const byte) main::j#0 = $64
Constant (const byte) nest1::i#0 = $64
Constant (const byte) nest1::j#0 = $64
Constant (const byte) nest2::i#0 = $64
Constant (const byte) nest2::j#0 = $64
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) nest1::i#0
Inlining constant with var siblings (const byte) nest1::j#0
Inlining constant with var siblings (const byte) nest2::i#0
Inlining constant with var siblings (const byte) nest2::j#0
Constant inlined main::i#0 = (byte) $64
Constant inlined nest2::j#0 = (byte) $64
Constant inlined main::j#0 = (byte) $64
Constant inlined nest2::i#0 = (byte) $64
Constant inlined nest1::j#0 = (byte) $64
Constant inlined nest1::i#0 = (byte) $64
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@6(between main::@3 and main::@1)
Added new block during phi lifting main::@7(between main::@5 and main::@2)
Added new block during phi lifting nest1::@6(between nest1::@3 and nest1::@1)
Added new block during phi lifting nest1::@7(between nest1::@5 and nest1::@2)
Added new block during phi lifting nest2::@5(between nest2::@3 and nest2::@1)
Added new block during phi lifting nest2::@6(between nest2::@2 and nest2::@2)
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @3
Adding NOP phi() at start of @4
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of nest1
Adding NOP phi() at start of nest2
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to nest1:8 
Calls in [nest1] to nest2:19 

Created 6 initial phi equivalence classes
Coalesced [14] main::i#6 ← main::i#1
Coalesced [15] main::j#4 ← main::j#1
Coalesced [25] nest1::i#6 ← nest1::i#1
Coalesced [26] nest1::j#4 ← nest1::j#1
Coalesced [36] nest2::i#5 ← nest2::i#1
Coalesced [37] nest2::j#3 ← nest2::j#1
Coalesced down to 6 phi equivalence classes
Culled Empty Block (label) @4
Culled Empty Block (label) main::@6
Culled Empty Block (label) main::@7
Culled Empty Block (label) nest1::@6
Culled Empty Block (label) nest1::@7
Culled Empty Block (label) nest2::@5
Culled Empty Block (label) nest2::@6
Renumbering block @3 to @1
Renumbering block main::@5 to main::@4
Renumbering block nest1::@5 to nest1::@4
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of nest1
Adding NOP phi() at start of nest2

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi()
  to:@1
@1: scope:[]  from @begin
  [1] phi()
  [2] call main 
  to:@end
@end: scope:[]  from @1
  [3] phi()
main: scope:[main]  from @1
  [4] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@3
  [5] (byte) main::i#5 ← phi( main/(byte) $64 main::@3/(byte) main::i#1 )
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@4
  [6] (byte) main::j#2 ← phi( main::@1/(byte) $64 main::@4/(byte) main::j#1 )
  [7] call nest1 
  to:main::@4
main::@4: scope:[main]  from main::@2
  [8] (byte) main::j#1 ← -- (byte) main::j#2
  [9] if((byte) main::j#1>(byte) 0) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@4
  [10] (byte) main::i#1 ← -- (byte) main::i#5
  [11] if((byte) main::i#1>(byte) 0) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@3
  [12] return 
  to:@return
nest1: scope:[nest1]  from main::@2
  [13] phi()
  to:nest1::@1
nest1::@1: scope:[nest1]  from nest1 nest1::@3
  [14] (byte) nest1::i#5 ← phi( nest1/(byte) $64 nest1::@3/(byte) nest1::i#1 )
  to:nest1::@2
nest1::@2: scope:[nest1]  from nest1::@1 nest1::@4
  [15] (byte) nest1::j#2 ← phi( nest1::@1/(byte) $64 nest1::@4/(byte) nest1::j#1 )
  [16] call nest2 
  to:nest1::@4
nest1::@4: scope:[nest1]  from nest1::@2
  [17] (byte) nest1::j#1 ← -- (byte) nest1::j#2
  [18] if((byte) nest1::j#1>(byte) 0) goto nest1::@2
  to:nest1::@3
nest1::@3: scope:[nest1]  from nest1::@4
  [19] (byte) nest1::i#1 ← -- (byte) nest1::i#5
  [20] if((byte) nest1::i#1>(byte) 0) goto nest1::@1
  to:nest1::@return
nest1::@return: scope:[nest1]  from nest1::@3
  [21] return 
  to:@return
nest2: scope:[nest2]  from nest1::@2
  [22] phi()
  to:nest2::@1
nest2::@1: scope:[nest2]  from nest2 nest2::@3
  [23] (byte) nest2::i#4 ← phi( nest2/(byte) $64 nest2::@3/(byte) nest2::i#1 )
  to:nest2::@2
nest2::@2: scope:[nest2]  from nest2::@1 nest2::@2
  [24] (byte) nest2::j#2 ← phi( nest2::@1/(byte) $64 nest2::@2/(byte) nest2::j#1 )
  [25] *((const byte*) SCREEN#0) ← (byte) nest2::j#2
  [26] (byte) nest2::j#1 ← -- (byte) nest2::j#2
  [27] if((byte) nest2::j#1>(byte) 0) goto nest2::@2
  to:nest2::@3
nest2::@3: scope:[nest2]  from nest2::@2
  [28] (byte) nest2::i#1 ← -- (byte) nest2::i#4
  [29] if((byte) nest2::i#1>(byte) 0) goto nest2::@1
  to:nest2::@return
nest2::@return: scope:[nest2]  from nest2::@3
  [30] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte*) SCREEN
(void()) main()
(byte) main::i
(byte) main::i#1 16.5
(byte) main::i#5 4.4
(byte) main::j
(byte) main::j#1 151.5
(byte) main::j#2 101.0
(void()) nest1()
(byte) nest1::i
(byte) nest1::i#1 1501.5
(byte) nest1::i#5 400.4
(byte) nest1::j
(byte) nest1::j#1 15001.5
(byte) nest1::j#2 10001.0
(void()) nest2()
(byte) nest2::i
(byte) nest2::i#1 150001.5
(byte) nest2::i#4 40000.4
(byte) nest2::j
(byte) nest2::j#1 1500001.5
(byte) nest2::j#2 1500001.5

Initial phi equivalence classes
[ main::i#5 main::i#1 ]
[ main::j#2 main::j#1 ]
[ nest1::i#5 nest1::i#1 ]
[ nest1::j#2 nest1::j#1 ]
[ nest2::i#4 nest2::i#1 ]
[ nest2::j#2 nest2::j#1 ]
Complete equivalence classes
[ main::i#5 main::i#1 ]
[ main::j#2 main::j#1 ]
[ nest1::i#5 nest1::i#1 ]
[ nest1::j#2 nest1::j#1 ]
[ nest2::i#4 nest2::i#1 ]
[ nest2::j#2 nest2::j#1 ]
Allocated zp ZP_BYTE:2 [ main::i#5 main::i#1 ]
Allocated zp ZP_BYTE:3 [ main::j#2 main::j#1 ]
Allocated zp ZP_BYTE:4 [ nest1::i#5 nest1::i#1 ]
Allocated zp ZP_BYTE:5 [ nest1::j#2 nest1::j#1 ]
Allocated zp ZP_BYTE:6 [ nest2::i#4 nest2::i#1 ]
Allocated zp ZP_BYTE:7 [ nest2::j#2 nest2::j#1 ]

INITIAL ASM
Target platform is c64basic
  // File Comments
  // 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 j = 3
    .label i = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [5] phi (byte) main::i#5 = (byte) $64 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #$64
    sta.z i
    jmp b1
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  b1_from_b3:
    // [5] phi (byte) main::i#5 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
    // [6] phi (byte) main::j#2 = (byte) $64 [phi:main::@1->main::@2#0] -- vbuz1=vbuc1 
    lda #$64
    sta.z j
    jmp b2
    // [6] phi from main::@4 to main::@2 [phi:main::@4->main::@2]
  b2_from_b4:
    // [6] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@4->main::@2#0] -- register_copy 
    jmp b2
    // main::@2
  b2:
    // [7] call nest1 
    // [13] phi from main::@2 to nest1 [phi:main::@2->nest1]
  nest1_from_b2:
    jsr nest1
    jmp b4
    // main::@4
  b4:
    // [8] (byte) main::j#1 ← -- (byte) main::j#2 -- vbuz1=_dec_vbuz1 
    dec.z j
    // [9] if((byte) main::j#1>(byte) 0) goto main::@2 -- vbuz1_gt_0_then_la1 
    lda.z j
    bne b2_from_b4
    jmp b3
    // main::@3
  b3:
    // [10] (byte) main::i#1 ← -- (byte) main::i#5 -- vbuz1=_dec_vbuz1 
    dec.z i
    // [11] if((byte) main::i#1>(byte) 0) goto main::@1 -- vbuz1_gt_0_then_la1 
    lda.z i
    bne b1_from_b3
    jmp breturn
    // main::@return
  breturn:
    // [12] return 
    rts
}
  // nest1
nest1: {
    .label j = 5
    .label i = 4
    // [14] phi from nest1 to nest1::@1 [phi:nest1->nest1::@1]
  b1_from_nest1:
    // [14] phi (byte) nest1::i#5 = (byte) $64 [phi:nest1->nest1::@1#0] -- vbuz1=vbuc1 
    lda #$64
    sta.z i
    jmp b1
    // [14] phi from nest1::@3 to nest1::@1 [phi:nest1::@3->nest1::@1]
  b1_from_b3:
    // [14] phi (byte) nest1::i#5 = (byte) nest1::i#1 [phi:nest1::@3->nest1::@1#0] -- register_copy 
    jmp b1
    // nest1::@1
  b1:
    // [15] phi from nest1::@1 to nest1::@2 [phi:nest1::@1->nest1::@2]
  b2_from_b1:
    // [15] phi (byte) nest1::j#2 = (byte) $64 [phi:nest1::@1->nest1::@2#0] -- vbuz1=vbuc1 
    lda #$64
    sta.z j
    jmp b2
    // [15] phi from nest1::@4 to nest1::@2 [phi:nest1::@4->nest1::@2]
  b2_from_b4:
    // [15] phi (byte) nest1::j#2 = (byte) nest1::j#1 [phi:nest1::@4->nest1::@2#0] -- register_copy 
    jmp b2
    // nest1::@2
  b2:
    // [16] call nest2 
    // [22] phi from nest1::@2 to nest2 [phi:nest1::@2->nest2]
  nest2_from_b2:
    jsr nest2
    jmp b4
    // nest1::@4
  b4:
    // [17] (byte) nest1::j#1 ← -- (byte) nest1::j#2 -- vbuz1=_dec_vbuz1 
    dec.z j
    // [18] if((byte) nest1::j#1>(byte) 0) goto nest1::@2 -- vbuz1_gt_0_then_la1 
    lda.z j
    bne b2_from_b4
    jmp b3
    // nest1::@3
  b3:
    // [19] (byte) nest1::i#1 ← -- (byte) nest1::i#5 -- vbuz1=_dec_vbuz1 
    dec.z i
    // [20] if((byte) nest1::i#1>(byte) 0) goto nest1::@1 -- vbuz1_gt_0_then_la1 
    lda.z i
    bne b1_from_b3
    jmp breturn
    // nest1::@return
  breturn:
    // [21] return 
    rts
}
  // nest2
nest2: {
    .label j = 7
    .label i = 6
    // [23] phi from nest2 to nest2::@1 [phi:nest2->nest2::@1]
  b1_from_nest2:
    // [23] phi (byte) nest2::i#4 = (byte) $64 [phi:nest2->nest2::@1#0] -- vbuz1=vbuc1 
    lda #$64
    sta.z i
    jmp b1
    // [23] phi from nest2::@3 to nest2::@1 [phi:nest2::@3->nest2::@1]
  b1_from_b3:
    // [23] phi (byte) nest2::i#4 = (byte) nest2::i#1 [phi:nest2::@3->nest2::@1#0] -- register_copy 
    jmp b1
    // nest2::@1
  b1:
    // [24] phi from nest2::@1 to nest2::@2 [phi:nest2::@1->nest2::@2]
  b2_from_b1:
    // [24] phi (byte) nest2::j#2 = (byte) $64 [phi:nest2::@1->nest2::@2#0] -- vbuz1=vbuc1 
    lda #$64
    sta.z j
    jmp b2
    // [24] phi from nest2::@2 to nest2::@2 [phi:nest2::@2->nest2::@2]
  b2_from_b2:
    // [24] phi (byte) nest2::j#2 = (byte) nest2::j#1 [phi:nest2::@2->nest2::@2#0] -- register_copy 
    jmp b2
    // nest2::@2
  b2:
    // [25] *((const byte*) SCREEN#0) ← (byte) nest2::j#2 -- _deref_pbuc1=vbuz1 
    lda.z j
    sta SCREEN
    // [26] (byte) nest2::j#1 ← -- (byte) nest2::j#2 -- vbuz1=_dec_vbuz1 
    dec.z j
    // [27] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 -- vbuz1_gt_0_then_la1 
    lda.z j
    bne b2_from_b2
    jmp b3
    // nest2::@3
  b3:
    // [28] (byte) nest2::i#1 ← -- (byte) nest2::i#4 -- vbuz1=_dec_vbuz1 
    dec.z i
    // [29] if((byte) nest2::i#1>(byte) 0) goto nest2::@1 -- vbuz1_gt_0_then_la1 
    lda.z i
    bne b1_from_b3
    jmp breturn
    // nest2::@return
  breturn:
    // [30] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Potential registers zp ZP_BYTE:2 [ main::i#5 main::i#1 ] : zp ZP_BYTE:2 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:3 [ main::j#2 main::j#1 ] : zp ZP_BYTE:3 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:4 [ nest1::i#5 nest1::i#1 ] : zp ZP_BYTE:4 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:5 [ nest1::j#2 nest1::j#1 ] : zp ZP_BYTE:5 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:6 [ nest2::i#4 nest2::i#1 ] : zp ZP_BYTE:6 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:7 [ nest2::j#2 nest2::j#1 ] : zp ZP_BYTE:7 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [nest2] 3,000,003: zp ZP_BYTE:7 [ nest2::j#2 nest2::j#1 ] 190,001.9: zp ZP_BYTE:6 [ nest2::i#4 nest2::i#1 ] 
Uplift Scope [nest1] 25,002.5: zp ZP_BYTE:5 [ nest1::j#2 nest1::j#1 ] 1,901.9: zp ZP_BYTE:4 [ nest1::i#5 nest1::i#1 ] 
Uplift Scope [main] 252.5: zp ZP_BYTE:3 [ main::j#2 main::j#1 ] 20.9: zp ZP_BYTE:2 [ main::i#5 main::i#1 ] 
Uplift Scope [] 

Uplifting [nest2] best 23522243 combination reg byte y [ nest2::j#2 nest2::j#1 ] reg byte x [ nest2::i#4 nest2::i#1 ] 
Uplifting [nest1] best 23472243 combination reg byte a [ nest1::j#2 nest1::j#1 ] zp ZP_BYTE:4 [ nest1::i#5 nest1::i#1 ] 
Uplifting [main] best 23472243 combination zp ZP_BYTE:3 [ main::j#2 main::j#1 ] zp ZP_BYTE:2 [ main::i#5 main::i#1 ] 
Uplifting [] best 23472243 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:4 [ nest1::i#5 nest1::i#1 ]
Uplifting [nest1] best 23472243 combination zp ZP_BYTE:4 [ nest1::i#5 nest1::i#1 ] 
Attempting to uplift remaining variables inzp ZP_BYTE:3 [ main::j#2 main::j#1 ]
Uplifting [main] best 23472243 combination zp ZP_BYTE:3 [ main::j#2 main::j#1 ] 
Attempting to uplift remaining variables inzp ZP_BYTE:2 [ main::i#5 main::i#1 ]
Uplifting [main] best 23472243 combination zp ZP_BYTE:2 [ main::i#5 main::i#1 ] 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
  // 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 j = 3
    .label i = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [5] phi (byte) main::i#5 = (byte) $64 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #$64
    sta.z i
    jmp b1
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  b1_from_b3:
    // [5] phi (byte) main::i#5 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
    // [6] phi (byte) main::j#2 = (byte) $64 [phi:main::@1->main::@2#0] -- vbuz1=vbuc1 
    lda #$64
    sta.z j
    jmp b2
    // [6] phi from main::@4 to main::@2 [phi:main::@4->main::@2]
  b2_from_b4:
    // [6] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@4->main::@2#0] -- register_copy 
    jmp b2
    // main::@2
  b2:
    // [7] call nest1 
    // [13] phi from main::@2 to nest1 [phi:main::@2->nest1]
  nest1_from_b2:
    jsr nest1
    jmp b4
    // main::@4
  b4:
    // [8] (byte) main::j#1 ← -- (byte) main::j#2 -- vbuz1=_dec_vbuz1 
    dec.z j
    // [9] if((byte) main::j#1>(byte) 0) goto main::@2 -- vbuz1_gt_0_then_la1 
    lda.z j
    bne b2_from_b4
    jmp b3
    // main::@3
  b3:
    // [10] (byte) main::i#1 ← -- (byte) main::i#5 -- vbuz1=_dec_vbuz1 
    dec.z i
    // [11] if((byte) main::i#1>(byte) 0) goto main::@1 -- vbuz1_gt_0_then_la1 
    lda.z i
    bne b1_from_b3
    jmp breturn
    // main::@return
  breturn:
    // [12] return 
    rts
}
  // nest1
nest1: {
    .label i = 4
    // [14] phi from nest1 to nest1::@1 [phi:nest1->nest1::@1]
  b1_from_nest1:
    // [14] phi (byte) nest1::i#5 = (byte) $64 [phi:nest1->nest1::@1#0] -- vbuz1=vbuc1 
    lda #$64
    sta.z i
    jmp b1
    // [14] phi from nest1::@3 to nest1::@1 [phi:nest1::@3->nest1::@1]
  b1_from_b3:
    // [14] phi (byte) nest1::i#5 = (byte) nest1::i#1 [phi:nest1::@3->nest1::@1#0] -- register_copy 
    jmp b1
    // nest1::@1
  b1:
    // [15] phi from nest1::@1 to nest1::@2 [phi:nest1::@1->nest1::@2]
  b2_from_b1:
    // [15] phi (byte) nest1::j#2 = (byte) $64 [phi:nest1::@1->nest1::@2#0] -- vbuaa=vbuc1 
    lda #$64
    jmp b2
    // [15] phi from nest1::@4 to nest1::@2 [phi:nest1::@4->nest1::@2]
  b2_from_b4:
    // [15] phi (byte) nest1::j#2 = (byte) nest1::j#1 [phi:nest1::@4->nest1::@2#0] -- register_copy 
    jmp b2
    // nest1::@2
  b2:
    // [16] call nest2 
    // [22] phi from nest1::@2 to nest2 [phi:nest1::@2->nest2]
  nest2_from_b2:
    jsr nest2
    jmp b4
    // nest1::@4
  b4:
    // [17] (byte) nest1::j#1 ← -- (byte) nest1::j#2 -- vbuaa=_dec_vbuaa 
    sec
    sbc #1
    // [18] if((byte) nest1::j#1>(byte) 0) goto nest1::@2 -- vbuaa_gt_0_then_la1 
    cmp #0
    bne b2_from_b4
    jmp b3
    // nest1::@3
  b3:
    // [19] (byte) nest1::i#1 ← -- (byte) nest1::i#5 -- vbuz1=_dec_vbuz1 
    dec.z i
    // [20] if((byte) nest1::i#1>(byte) 0) goto nest1::@1 -- vbuz1_gt_0_then_la1 
    lda.z i
    bne b1_from_b3
    jmp breturn
    // nest1::@return
  breturn:
    // [21] return 
    rts
}
  // nest2
nest2: {
    // [23] phi from nest2 to nest2::@1 [phi:nest2->nest2::@1]
  b1_from_nest2:
    // [23] phi (byte) nest2::i#4 = (byte) $64 [phi:nest2->nest2::@1#0] -- vbuxx=vbuc1 
    ldx #$64
    jmp b1
    // [23] phi from nest2::@3 to nest2::@1 [phi:nest2::@3->nest2::@1]
  b1_from_b3:
    // [23] phi (byte) nest2::i#4 = (byte) nest2::i#1 [phi:nest2::@3->nest2::@1#0] -- register_copy 
    jmp b1
    // nest2::@1
  b1:
    // [24] phi from nest2::@1 to nest2::@2 [phi:nest2::@1->nest2::@2]
  b2_from_b1:
    // [24] phi (byte) nest2::j#2 = (byte) $64 [phi:nest2::@1->nest2::@2#0] -- vbuyy=vbuc1 
    ldy #$64
    jmp b2
    // [24] phi from nest2::@2 to nest2::@2 [phi:nest2::@2->nest2::@2]
  b2_from_b2:
    // [24] phi (byte) nest2::j#2 = (byte) nest2::j#1 [phi:nest2::@2->nest2::@2#0] -- register_copy 
    jmp b2
    // nest2::@2
  b2:
    // [25] *((const byte*) SCREEN#0) ← (byte) nest2::j#2 -- _deref_pbuc1=vbuyy 
    sty SCREEN
    // [26] (byte) nest2::j#1 ← -- (byte) nest2::j#2 -- vbuyy=_dec_vbuyy 
    dey
    // [27] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 -- vbuyy_gt_0_then_la1 
    cpy #0
    bne b2_from_b2
    jmp b3
    // nest2::@3
  b3:
    // [28] (byte) nest2::i#1 ← -- (byte) nest2::i#4 -- vbuxx=_dec_vbuxx 
    dex
    // [29] if((byte) nest2::i#1>(byte) 0) goto nest2::@1 -- vbuxx_gt_0_then_la1 
    cpx #0
    bne b1_from_b3
    jmp breturn
    // nest2::@return
  breturn:
    // [30] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp b4
Removing instruction jmp b3
Removing instruction jmp breturn
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp b4
Removing instruction jmp b3
Removing instruction jmp breturn
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp b3
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b2_from_b4 with b2
Replacing label b1_from_b3 with b1
Replacing label b2_from_b4 with b2
Replacing label b1_from_b3 with b1
Replacing label b2_from_b2 with b2
Replacing label b1_from_b3 with b1
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_b3:
Removing instruction b2_from_b1:
Removing instruction b2_from_b4:
Removing instruction nest1_from_b2:
Removing instruction b1_from_b3:
Removing instruction b2_from_b1:
Removing instruction b2_from_b4:
Removing instruction nest2_from_b2:
Removing instruction b1_from_b3:
Removing instruction b2_from_b1:
Removing instruction b2_from_b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction b4:
Removing instruction b3:
Removing instruction breturn:
Removing instruction b1_from_nest1:
Removing instruction b4:
Removing instruction b3:
Removing instruction breturn:
Removing instruction b1_from_nest2:
Removing instruction b3:
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 b2
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp b1
Removing instruction jmp b2
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::@return
(byte) main::i
(byte) main::i#1 i zp ZP_BYTE:2 16.5
(byte) main::i#5 i zp ZP_BYTE:2 4.4
(byte) main::j
(byte) main::j#1 j zp ZP_BYTE:3 151.5
(byte) main::j#2 j zp ZP_BYTE:3 101.0
(void()) nest1()
(label) nest1::@1
(label) nest1::@2
(label) nest1::@3
(label) nest1::@4
(label) nest1::@return
(byte) nest1::i
(byte) nest1::i#1 i zp ZP_BYTE:4 1501.5
(byte) nest1::i#5 i zp ZP_BYTE:4 400.4
(byte) nest1::j
(byte) nest1::j#1 reg byte a 15001.5
(byte) nest1::j#2 reg byte a 10001.0
(void()) nest2()
(label) nest2::@1
(label) nest2::@2
(label) nest2::@3
(label) nest2::@return
(byte) nest2::i
(byte) nest2::i#1 reg byte x 150001.5
(byte) nest2::i#4 reg byte x 40000.4
(byte) nest2::j
(byte) nest2::j#1 reg byte y 1500001.5
(byte) nest2::j#2 reg byte y 1500001.5

zp ZP_BYTE:2 [ main::i#5 main::i#1 ]
zp ZP_BYTE:3 [ main::j#2 main::j#1 ]
zp ZP_BYTE:4 [ nest1::i#5 nest1::i#1 ]
reg byte a [ nest1::j#2 nest1::j#1 ]
reg byte x [ nest2::i#4 nest2::i#1 ]
reg byte y [ nest2::j#2 nest2::j#1 ]


FINAL ASSEMBLER
Score: 13472235

  // File Comments
  // 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 j = 3
    .label i = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // [5] phi (byte) main::i#5 = (byte) $64 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #$64
    sta.z i
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
    // [5] phi (byte) main::i#5 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy 
    // main::@1
  b1:
    // [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
    // [6] phi (byte) main::j#2 = (byte) $64 [phi:main::@1->main::@2#0] -- vbuz1=vbuc1 
    lda #$64
    sta.z j
    // [6] phi from main::@4 to main::@2 [phi:main::@4->main::@2]
    // [6] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@4->main::@2#0] -- register_copy 
    // main::@2
  b2:
    // nest1()
    // [7] call nest1 
    // [13] phi from main::@2 to nest1 [phi:main::@2->nest1]
    jsr nest1
    // main::@4
    // while (--j>0)
    // [8] (byte) main::j#1 ← -- (byte) main::j#2 -- vbuz1=_dec_vbuz1 
    dec.z j
    // [9] if((byte) main::j#1>(byte) 0) goto main::@2 -- vbuz1_gt_0_then_la1 
    lda.z j
    bne b2
    // main::@3
    // while (--i>0)
    // [10] (byte) main::i#1 ← -- (byte) main::i#5 -- vbuz1=_dec_vbuz1 
    dec.z i
    // [11] if((byte) main::i#1>(byte) 0) goto main::@1 -- vbuz1_gt_0_then_la1 
    lda.z i
    bne b1
    // main::@return
    // }
    // [12] return 
    rts
}
  // nest1
nest1: {
    .label i = 4
    // [14] phi from nest1 to nest1::@1 [phi:nest1->nest1::@1]
    // [14] phi (byte) nest1::i#5 = (byte) $64 [phi:nest1->nest1::@1#0] -- vbuz1=vbuc1 
    lda #$64
    sta.z i
    // [14] phi from nest1::@3 to nest1::@1 [phi:nest1::@3->nest1::@1]
    // [14] phi (byte) nest1::i#5 = (byte) nest1::i#1 [phi:nest1::@3->nest1::@1#0] -- register_copy 
    // nest1::@1
  b1:
    // [15] phi from nest1::@1 to nest1::@2 [phi:nest1::@1->nest1::@2]
    // [15] phi (byte) nest1::j#2 = (byte) $64 [phi:nest1::@1->nest1::@2#0] -- vbuaa=vbuc1 
    lda #$64
    // [15] phi from nest1::@4 to nest1::@2 [phi:nest1::@4->nest1::@2]
    // [15] phi (byte) nest1::j#2 = (byte) nest1::j#1 [phi:nest1::@4->nest1::@2#0] -- register_copy 
    // nest1::@2
  b2:
    // nest2()
    // [16] call nest2 
    // [22] phi from nest1::@2 to nest2 [phi:nest1::@2->nest2]
    jsr nest2
    // nest1::@4
    // while (--j>0)
    // [17] (byte) nest1::j#1 ← -- (byte) nest1::j#2 -- vbuaa=_dec_vbuaa 
    sec
    sbc #1
    // [18] if((byte) nest1::j#1>(byte) 0) goto nest1::@2 -- vbuaa_gt_0_then_la1 
    cmp #0
    bne b2
    // nest1::@3
    // while (--i>0)
    // [19] (byte) nest1::i#1 ← -- (byte) nest1::i#5 -- vbuz1=_dec_vbuz1 
    dec.z i
    // [20] if((byte) nest1::i#1>(byte) 0) goto nest1::@1 -- vbuz1_gt_0_then_la1 
    lda.z i
    bne b1
    // nest1::@return
    // }
    // [21] return 
    rts
}
  // nest2
nest2: {
    // [23] phi from nest2 to nest2::@1 [phi:nest2->nest2::@1]
    // [23] phi (byte) nest2::i#4 = (byte) $64 [phi:nest2->nest2::@1#0] -- vbuxx=vbuc1 
    ldx #$64
    // [23] phi from nest2::@3 to nest2::@1 [phi:nest2::@3->nest2::@1]
    // [23] phi (byte) nest2::i#4 = (byte) nest2::i#1 [phi:nest2::@3->nest2::@1#0] -- register_copy 
    // nest2::@1
  b1:
    // [24] phi from nest2::@1 to nest2::@2 [phi:nest2::@1->nest2::@2]
    // [24] phi (byte) nest2::j#2 = (byte) $64 [phi:nest2::@1->nest2::@2#0] -- vbuyy=vbuc1 
    ldy #$64
    // [24] phi from nest2::@2 to nest2::@2 [phi:nest2::@2->nest2::@2]
    // [24] phi (byte) nest2::j#2 = (byte) nest2::j#1 [phi:nest2::@2->nest2::@2#0] -- register_copy 
    // nest2::@2
  b2:
    // *SCREEN = j
    // [25] *((const byte*) SCREEN#0) ← (byte) nest2::j#2 -- _deref_pbuc1=vbuyy 
    sty SCREEN
    // while (--j>0)
    // [26] (byte) nest2::j#1 ← -- (byte) nest2::j#2 -- vbuyy=_dec_vbuyy 
    dey
    // [27] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 -- vbuyy_gt_0_then_la1 
    cpy #0
    bne b2
    // nest2::@3
    // while (--i>0)
    // [28] (byte) nest2::i#1 ← -- (byte) nest2::i#4 -- vbuxx=_dec_vbuxx 
    dex
    // [29] if((byte) nest2::i#1>(byte) 0) goto nest2::@1 -- vbuxx_gt_0_then_la1 
    cpx #0
    bne b1
    // nest2::@return
    // }
    // [30] return 
    rts
}
  // File Data

