Identified constant variable (byte*) SCREEN
Culled Empty Block (label) main::@6
Culled Empty Block (label) @1

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) SCREEN#0 ← ((byte*)) (number) $400
  to:@2
main: scope:[main]  from @2
  (byte) main::i#0 ← (byte) 0
  to:main::@1
main::@1: scope:[main]  from main main::@7
  (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@7/(byte) main::i#1 )
  (byte) plot::x#0 ← (byte) main::i#2
  call plot 
  to:main::@7
main::@7: scope:[main]  from main::@1
  (byte) main::i#3 ← phi( main::@1/(byte) main::i#2 )
  (byte) main::i#1 ← (byte) main::i#3 + rangenext(0,$a)
  (bool~) main::$1 ← (byte) main::i#1 != rangelast(0,$a)
  if((bool~) main::$1) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@7
  (byte) main::j#0 ← (byte) 0
  to:main::@3
main::@3: scope:[main]  from main::@2 main::@8
  (byte) main::j#2 ← phi( main::@2/(byte) main::j#0 main::@8/(byte) main::j#1 )
  (byte) plot::x#1 ← (byte) main::j#2
  call plot 
  to:main::@8
main::@8: scope:[main]  from main::@3
  (byte) main::j#3 ← phi( main::@3/(byte) main::j#2 )
  (byte) main::j#1 ← (byte) main::j#3 + rangenext(0,$a)
  (bool~) main::$3 ← (byte) main::j#1 != rangelast(0,$a)
  if((bool~) main::$3) goto main::@3
  to:main::@4
main::@4: scope:[main]  from main::@8
  (byte) main::k#0 ← (byte) 0
  to:main::@5
main::@5: scope:[main]  from main::@4 main::@9
  (byte) main::k#2 ← phi( main::@4/(byte) main::k#0 main::@9/(byte) main::k#1 )
  (byte) plot::x#2 ← (byte) main::k#2
  call plot 
  to:main::@9
main::@9: scope:[main]  from main::@5
  (byte) main::k#3 ← phi( main::@5/(byte) main::k#2 )
  (byte) main::k#1 ← (byte) main::k#3 + rangenext(0,$a)
  (bool~) main::$5 ← (byte) main::k#1 != rangelast(0,$a)
  if((bool~) main::$5) goto main::@5
  to:main::@return
main::@return: scope:[main]  from main::@9
  return 
  to:@return
plot: scope:[plot]  from main::@1 main::@3 main::@5
  (byte) plot::x#3 ← phi( main::@1/(byte) plot::x#0 main::@3/(byte) plot::x#1 main::@5/(byte) plot::x#2 )
  *((byte*) SCREEN#0 + (byte) plot::x#3) ← (byte) '*'
  to:plot::@return
plot::@return: scope:[plot]  from plot
  return 
  to:@return
@2: scope:[]  from @begin
  call main 
  to:@3
@3: scope:[]  from @2
  to:@end
@end: scope:[]  from @3

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

Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Successful SSA optimization PassNCastSimplification
Alias (byte) main::i#2 = (byte) main::i#3 
Alias (byte) main::j#2 = (byte) main::j#3 
Alias (byte) main::k#2 = (byte) main::k#3 
Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) main::$1 [8] if((byte) main::i#1!=rangelast(0,$a)) goto main::@1
Simple Condition (bool~) main::$3 [16] if((byte) main::j#1!=rangelast(0,$a)) goto main::@3
Simple Condition (bool~) main::$5 [24] if((byte) main::k#1!=rangelast(0,$a)) goto main::@5
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) SCREEN#0 = (byte*) 1024
Constant (const byte) main::i#0 = 0
Constant (const byte) main::j#0 = 0
Constant (const byte) main::k#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [6] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [8] if(main::i#1!=rangelast(0,$a)) goto main::@1 to (number) $b
Resolved ranged next value [14] main::j#1 ← ++ main::j#2 to ++
Resolved ranged comparison value [16] if(main::j#1!=rangelast(0,$a)) goto main::@3 to (number) $b
Resolved ranged next value [22] main::k#1 ← ++ main::k#2 to ++
Resolved ranged comparison value [24] if(main::k#1!=rangelast(0,$a)) goto main::@5 to (number) $b
Adding number conversion cast (unumber) $b in if((byte) main::i#1!=(number) $b) goto main::@1
Adding number conversion cast (unumber) $b in if((byte) main::j#1!=(number) $b) goto main::@3
Adding number conversion cast (unumber) $b in if((byte) main::k#1!=(number) $b) goto main::@5
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast $b
Simplifying constant integer cast $b
Simplifying constant integer cast $b
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $b
Finalized unsigned number type (byte) $b
Finalized unsigned number type (byte) $b
Successful SSA optimization PassNFinalizeNumberTypeConversions
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
Constant inlined main::i#0 = (byte) 0
Constant inlined main::k#0 = (byte) 0
Constant inlined main::j#0 = (byte) 0
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@10(between main::@7 and main::@1)
Added new block during phi lifting main::@11(between main::@8 and main::@3)
Added new block during phi lifting main::@12(between main::@9 and main::@5)
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @3
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@2
Adding NOP phi() at start of main::@4
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to plot:9 plot:16 plot:23 

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


VARIABLE REGISTER WEIGHTS
(byte*) SCREEN
(void()) main()
(byte) main::i
(byte) main::i#1 16.5
(byte) main::i#2 11.0
(byte) main::j
(byte) main::j#1 16.5
(byte) main::j#2 11.0
(byte) main::k
(byte) main::k#1 16.5
(byte) main::k#2 11.0
(void()) plot((byte) plot::x)
(byte) plot::x
(byte) plot::x#0 22.0
(byte) plot::x#1 22.0
(byte) plot::x#2 22.0
(byte) plot::x#3 35.0

Initial phi equivalence classes
[ main::i#2 main::i#1 ]
[ main::j#2 main::j#1 ]
[ main::k#2 main::k#1 ]
[ plot::x#3 plot::x#0 plot::x#1 plot::x#2 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ main::j#2 main::j#1 ]
[ main::k#2 main::k#1 ]
[ plot::x#3 plot::x#0 plot::x#1 plot::x#2 ]
Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Allocated zp ZP_BYTE:3 [ main::j#2 main::j#1 ]
Allocated zp ZP_BYTE:4 [ main::k#2 main::k#1 ]
Allocated zp ZP_BYTE:5 [ plot::x#3 plot::x#0 plot::x#1 plot::x#2 ]

INITIAL ASM
  // File Comments
// Allocates ZP to j/k-variables even though all of i, j, k could be allocates to x and be more efficient.
// Reason: Pass4RegisterUpliftCombinations.isAllocationOverlapping() believes i/j/k variables overlaps insode plot()
  // Basic 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 = 2
    .label j = 3
    .label k = 4
    // [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta i
    jmp b1
    // [5] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
  b1_from_b4:
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4->main::@1#0] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] (byte) plot::x#0 ← (byte) main::i#2 -- vbuz1=vbuz2 
    lda i
    sta plot.x
    // [7] call plot 
    // [21] phi from main::@1 to plot [phi:main::@1->plot]
  plot_from_b1:
    // [21] phi (byte) plot::x#3 = (byte) plot::x#0 [phi:main::@1->plot#0] -- register_copy 
    jsr plot
    jmp b4
    // main::@4
  b4:
    // [8] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 
    inc i
    // [9] if((byte) main::i#1!=(byte) $b) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #$b
    cmp i
    bne b1_from_b4
    // [10] phi from main::@4 to main::@2 [phi:main::@4->main::@2]
  b2_from_b4:
    // [10] phi (byte) main::j#2 = (byte) 0 [phi:main::@4->main::@2#0] -- vbuz1=vbuc1 
    lda #0
    sta j
    jmp b2
    // [10] phi from main::@5 to main::@2 [phi:main::@5->main::@2]
  b2_from_b5:
    // [10] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@5->main::@2#0] -- register_copy 
    jmp b2
    // main::@2
  b2:
    // [11] (byte) plot::x#1 ← (byte) main::j#2 -- vbuz1=vbuz2 
    lda j
    sta plot.x
    // [12] call plot 
    // [21] phi from main::@2 to plot [phi:main::@2->plot]
  plot_from_b2:
    // [21] phi (byte) plot::x#3 = (byte) plot::x#1 [phi:main::@2->plot#0] -- register_copy 
    jsr plot
    jmp b5
    // main::@5
  b5:
    // [13] (byte) main::j#1 ← ++ (byte) main::j#2 -- vbuz1=_inc_vbuz1 
    inc j
    // [14] if((byte) main::j#1!=(byte) $b) goto main::@2 -- vbuz1_neq_vbuc1_then_la1 
    lda #$b
    cmp j
    bne b2_from_b5
    // [15] phi from main::@5 to main::@3 [phi:main::@5->main::@3]
  b3_from_b5:
    // [15] phi (byte) main::k#2 = (byte) 0 [phi:main::@5->main::@3#0] -- vbuz1=vbuc1 
    lda #0
    sta k
    jmp b3
    // [15] phi from main::@6 to main::@3 [phi:main::@6->main::@3]
  b3_from_b6:
    // [15] phi (byte) main::k#2 = (byte) main::k#1 [phi:main::@6->main::@3#0] -- register_copy 
    jmp b3
    // main::@3
  b3:
    // [16] (byte) plot::x#2 ← (byte) main::k#2 -- vbuz1=vbuz2 
    lda k
    sta plot.x
    // [17] call plot 
    // [21] phi from main::@3 to plot [phi:main::@3->plot]
  plot_from_b3:
    // [21] phi (byte) plot::x#3 = (byte) plot::x#2 [phi:main::@3->plot#0] -- register_copy 
    jsr plot
    jmp b6
    // main::@6
  b6:
    // [18] (byte) main::k#1 ← ++ (byte) main::k#2 -- vbuz1=_inc_vbuz1 
    inc k
    // [19] if((byte) main::k#1!=(byte) $b) goto main::@3 -- vbuz1_neq_vbuc1_then_la1 
    lda #$b
    cmp k
    bne b3_from_b6
    jmp breturn
    // main::@return
  breturn:
    // [20] return 
    rts
}
  // plot
// plot(byte zeropage(5) x)
plot: {
    .label x = 5
    // [22] *((const byte*) SCREEN#0 + (byte) plot::x#3) ← (byte) '*' -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #'*'
    ldy x
    sta SCREEN,y
    jmp breturn
    // plot::@return
  breturn:
    // [23] return 
    rts
}
  // File Data

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

REGISTER UPLIFT SCOPES
Uplift Scope [plot] 101: zp ZP_BYTE:5 [ plot::x#3 plot::x#0 plot::x#1 plot::x#2 ] 
Uplift Scope [main] 27.5: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 27.5: zp ZP_BYTE:3 [ main::j#2 main::j#1 ] 27.5: zp ZP_BYTE:4 [ main::k#2 main::k#1 ] 
Uplift Scope [] 

Uplifting [plot] best 886 combination reg byte x [ plot::x#3 plot::x#0 plot::x#1 plot::x#2 ] 
Uplifting [main] best 526 combination reg byte x [ main::i#2 main::i#1 ] reg byte x [ main::j#2 main::j#1 ] reg byte x [ main::k#2 main::k#1 ] 
Uplifting [] best 526 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Allocates ZP to j/k-variables even though all of i, j, k could be allocates to x and be more efficient.
// Reason: Pass4RegisterUpliftCombinations.isAllocationOverlapping() believes i/j/k variables overlaps insode plot()
  // Basic 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) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    jmp b1
    // [5] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
  b1_from_b4:
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4->main::@1#0] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] (byte) plot::x#0 ← (byte) main::i#2
    // [7] call plot 
    // [21] phi from main::@1 to plot [phi:main::@1->plot]
  plot_from_b1:
    // [21] phi (byte) plot::x#3 = (byte) plot::x#0 [phi:main::@1->plot#0] -- register_copy 
    jsr plot
    jmp b4
    // main::@4
  b4:
    // [8] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [9] if((byte) main::i#1!=(byte) $b) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne b1_from_b4
    // [10] phi from main::@4 to main::@2 [phi:main::@4->main::@2]
  b2_from_b4:
    // [10] phi (byte) main::j#2 = (byte) 0 [phi:main::@4->main::@2#0] -- vbuxx=vbuc1 
    ldx #0
    jmp b2
    // [10] phi from main::@5 to main::@2 [phi:main::@5->main::@2]
  b2_from_b5:
    // [10] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@5->main::@2#0] -- register_copy 
    jmp b2
    // main::@2
  b2:
    // [11] (byte) plot::x#1 ← (byte) main::j#2
    // [12] call plot 
    // [21] phi from main::@2 to plot [phi:main::@2->plot]
  plot_from_b2:
    // [21] phi (byte) plot::x#3 = (byte) plot::x#1 [phi:main::@2->plot#0] -- register_copy 
    jsr plot
    jmp b5
    // main::@5
  b5:
    // [13] (byte) main::j#1 ← ++ (byte) main::j#2 -- vbuxx=_inc_vbuxx 
    inx
    // [14] if((byte) main::j#1!=(byte) $b) goto main::@2 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne b2_from_b5
    // [15] phi from main::@5 to main::@3 [phi:main::@5->main::@3]
  b3_from_b5:
    // [15] phi (byte) main::k#2 = (byte) 0 [phi:main::@5->main::@3#0] -- vbuxx=vbuc1 
    ldx #0
    jmp b3
    // [15] phi from main::@6 to main::@3 [phi:main::@6->main::@3]
  b3_from_b6:
    // [15] phi (byte) main::k#2 = (byte) main::k#1 [phi:main::@6->main::@3#0] -- register_copy 
    jmp b3
    // main::@3
  b3:
    // [16] (byte) plot::x#2 ← (byte) main::k#2
    // [17] call plot 
    // [21] phi from main::@3 to plot [phi:main::@3->plot]
  plot_from_b3:
    // [21] phi (byte) plot::x#3 = (byte) plot::x#2 [phi:main::@3->plot#0] -- register_copy 
    jsr plot
    jmp b6
    // main::@6
  b6:
    // [18] (byte) main::k#1 ← ++ (byte) main::k#2 -- vbuxx=_inc_vbuxx 
    inx
    // [19] if((byte) main::k#1!=(byte) $b) goto main::@3 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne b3_from_b6
    jmp breturn
    // main::@return
  breturn:
    // [20] return 
    rts
}
  // plot
// plot(byte register(X) x)
plot: {
    // [22] *((const byte*) SCREEN#0 + (byte) plot::x#3) ← (byte) '*' -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #'*'
    sta SCREEN,x
    jmp breturn
    // plot::@return
  breturn:
    // [23] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b4
Removing instruction jmp b2
Removing instruction jmp b5
Removing instruction jmp b3
Removing instruction jmp b6
Removing instruction jmp breturn
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b1_from_b4 with b1
Replacing label b2_from_b5 with b2
Replacing label b3_from_b6 with b3
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_b4:
Removing instruction plot_from_b1:
Removing instruction b2_from_b5:
Removing instruction plot_from_b2:
Removing instruction b3_from_b6:
Removing instruction plot_from_b3:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction b4:
Removing instruction b2_from_b4:
Removing instruction b5:
Removing instruction b3_from_b5:
Removing instruction b6:
Removing instruction breturn:
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 b3
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::@return
(byte) main::i
(byte) main::i#1 reg byte x 16.5
(byte) main::i#2 reg byte x 11.0
(byte) main::j
(byte) main::j#1 reg byte x 16.5
(byte) main::j#2 reg byte x 11.0
(byte) main::k
(byte) main::k#1 reg byte x 16.5
(byte) main::k#2 reg byte x 11.0
(void()) plot((byte) plot::x)
(label) plot::@return
(byte) plot::x
(byte) plot::x#0 reg byte x 22.0
(byte) plot::x#1 reg byte x 22.0
(byte) plot::x#2 reg byte x 22.0
(byte) plot::x#3 reg byte x 35.0

reg byte x [ main::i#2 main::i#1 ]
reg byte x [ main::j#2 main::j#1 ]
reg byte x [ main::k#2 main::k#1 ]
reg byte x [ plot::x#3 plot::x#0 plot::x#1 plot::x#2 ]


FINAL ASSEMBLER
Score: 292

  // File Comments
// Allocates ZP to j/k-variables even though all of i, j, k could be allocates to x and be more efficient.
// Reason: Pass4RegisterUpliftCombinations.isAllocationOverlapping() believes i/j/k variables overlaps insode plot()
  // Basic 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) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // [5] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4->main::@1#0] -- register_copy 
    // main::@1
  b1:
    // plot(i)
    // [6] (byte) plot::x#0 ← (byte) main::i#2
    // [7] call plot 
    // [21] phi from main::@1 to plot [phi:main::@1->plot]
    // [21] phi (byte) plot::x#3 = (byte) plot::x#0 [phi:main::@1->plot#0] -- register_copy 
    jsr plot
    // main::@4
    // for(byte i : 0..10)
    // [8] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [9] if((byte) main::i#1!=(byte) $b) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne b1
    // [10] phi from main::@4 to main::@2 [phi:main::@4->main::@2]
    // [10] phi (byte) main::j#2 = (byte) 0 [phi:main::@4->main::@2#0] -- vbuxx=vbuc1 
    ldx #0
    // [10] phi from main::@5 to main::@2 [phi:main::@5->main::@2]
    // [10] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@5->main::@2#0] -- register_copy 
    // main::@2
  b2:
    // plot(j)
    // [11] (byte) plot::x#1 ← (byte) main::j#2
    // [12] call plot 
    // [21] phi from main::@2 to plot [phi:main::@2->plot]
    // [21] phi (byte) plot::x#3 = (byte) plot::x#1 [phi:main::@2->plot#0] -- register_copy 
    jsr plot
    // main::@5
    // for(byte j : 0..10)
    // [13] (byte) main::j#1 ← ++ (byte) main::j#2 -- vbuxx=_inc_vbuxx 
    inx
    // [14] if((byte) main::j#1!=(byte) $b) goto main::@2 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne b2
    // [15] phi from main::@5 to main::@3 [phi:main::@5->main::@3]
    // [15] phi (byte) main::k#2 = (byte) 0 [phi:main::@5->main::@3#0] -- vbuxx=vbuc1 
    ldx #0
    // [15] phi from main::@6 to main::@3 [phi:main::@6->main::@3]
    // [15] phi (byte) main::k#2 = (byte) main::k#1 [phi:main::@6->main::@3#0] -- register_copy 
    // main::@3
  b3:
    // plot(k)
    // [16] (byte) plot::x#2 ← (byte) main::k#2
    // [17] call plot 
    // [21] phi from main::@3 to plot [phi:main::@3->plot]
    // [21] phi (byte) plot::x#3 = (byte) plot::x#2 [phi:main::@3->plot#0] -- register_copy 
    jsr plot
    // main::@6
    // for(byte k : 0..10)
    // [18] (byte) main::k#1 ← ++ (byte) main::k#2 -- vbuxx=_inc_vbuxx 
    inx
    // [19] if((byte) main::k#1!=(byte) $b) goto main::@3 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne b3
    // main::@return
    // }
    // [20] return 
    rts
}
  // plot
// plot(byte register(X) x)
plot: {
    // SCREEN[x] = '*'
    // [22] *((const byte*) SCREEN#0 + (byte) plot::x#3) ← (byte) '*' -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #'*'
    sta SCREEN,x
    // plot::@return
    // }
    // [23] return 
    rts
}
  // File Data

