Culled Empty Block (label) main::@2
Culled Empty Block (label) main::@4
Culled Empty Block (label) @1
Culled Empty Block (label) line::@2
Culled Empty Block (label) line::@4
Culled Empty Block (label) line::@6
Culled Empty Block (label) @2

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) plots#0 ← ((byte*)) (number) $1000
  (byte*) SCREEN#0 ← ((byte*)) (number) $400
  to:@3
main: scope:[main]  from @3
  (byte) main::i#0 ← (byte) 0
  to:main::@1
main::@1: scope:[main]  from main main::@1
  (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
  *((byte*) plots#0 + (byte) main::i#2) ← (byte) main::i#2
  *((byte*) SCREEN#0 + (byte) main::i#2) ← (number) 0
  (byte) main::i#1 ← (byte) main::i#2 + rangenext(0,$27)
  (bool~) main::$0 ← (byte) main::i#1 != rangelast(0,$27)
  if((bool~) main::$0) goto main::@1
  to:main::@3
main::@3: scope:[main]  from main::@1 main::@5
  (byte) line::x0#0 ← (number) 0
  (byte) line::x1#0 ← (number) $a
  call line 
  to:main::@5
main::@5: scope:[main]  from main::@3
  if(true) goto main::@3
  to:main::@return
main::@return: scope:[main]  from main::@5
  return 
  to:@return
line: scope:[line]  from main::@3
  (byte) line::x1#1 ← phi( main::@3/(byte) line::x1#0 )
  (byte) line::x0#1 ← phi( main::@3/(byte) line::x0#0 )
  (bool~) line::$0 ← (byte) line::x0#1 < (byte) line::x1#1
  if((bool~) line::$0) goto line::@1
  to:line::@3
line::@1: scope:[line]  from line
  (byte) line::x1#4 ← phi( line/(byte) line::x1#1 )
  (byte) line::x0#2 ← phi( line/(byte) line::x0#1 )
  (byte) line::x#0 ← (byte) line::x0#2
  to:line::@5
line::@3: scope:[line]  from line
  (byte) line::x0#3 ← phi( line/(byte) line::x0#1 )
  (byte) plot::x#0 ← (byte) line::x0#3
  call plot 
  to:line::@7
line::@7: scope:[line]  from line::@3
  to:line::@return
line::@5: scope:[line]  from line::@1 line::@8
  (byte) line::x1#3 ← phi( line::@1/(byte) line::x1#4 line::@8/(byte) line::x1#2 )
  (byte) line::x#2 ← phi( line::@1/(byte) line::x#0 line::@8/(byte) line::x#1 )
  (byte) plot::x#1 ← (byte) line::x#2
  call plot 
  to:line::@8
line::@8: scope:[line]  from line::@5
  (byte) line::x1#2 ← phi( line::@5/(byte) line::x1#3 )
  (byte) line::x#3 ← phi( line::@5/(byte) line::x#2 )
  (byte) line::x#1 ← ++ (byte) line::x#3
  (bool~) line::$3 ← (byte) line::x#1 <= (byte) line::x1#2
  if((bool~) line::$3) goto line::@5
  to:line::@return
line::@return: scope:[line]  from line::@7 line::@8
  return 
  to:@return
plot: scope:[plot]  from line::@3 line::@5
  (byte) plot::x#2 ← phi( line::@3/(byte) plot::x#0 line::@5/(byte) plot::x#1 )
  (byte) plot::idx#0 ← *((byte*) plots#0 + (byte) plot::x#2)
  (number~) plot::$0 ← *((byte*) SCREEN#0 + (byte) plot::idx#0) + (number) 1
  *((byte*) SCREEN#0 + (byte) plot::idx#0) ← (number~) plot::$0
  to:plot::@return
plot::@return: scope:[plot]  from plot
  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()) line((byte) line::x0 , (byte) line::x1)
(bool~) line::$0
(bool~) line::$3
(label) line::@1
(label) line::@3
(label) line::@5
(label) line::@7
(label) line::@8
(label) line::@return
(byte) line::x
(byte) line::x#0
(byte) line::x#1
(byte) line::x#2
(byte) line::x#3
(byte) line::x0
(byte) line::x0#0
(byte) line::x0#1
(byte) line::x0#2
(byte) line::x0#3
(byte) line::x1
(byte) line::x1#0
(byte) line::x1#1
(byte) line::x1#2
(byte) line::x1#3
(byte) line::x1#4
(void()) main()
(bool~) main::$0
(label) main::@1
(label) main::@3
(label) main::@5
(label) main::@return
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(void()) plot((byte) plot::x)
(number~) plot::$0
(label) plot::@return
(byte) plot::idx
(byte) plot::idx#0
(byte) plot::x
(byte) plot::x#0
(byte) plot::x#1
(byte) plot::x#2
(byte*) plots
(byte*) plots#0

Adding number conversion cast (unumber) 0 in *((byte*) SCREEN#0 + (byte) main::i#2) ← (number) 0
Adding number conversion cast (unumber) 0 in (byte) line::x0#0 ← (number) 0
Adding number conversion cast (unumber) $a in (byte) line::x1#0 ← (number) $a
Adding number conversion cast (unumber) 1 in (number~) plot::$0 ← *((byte*) SCREEN#0 + (byte) plot::idx#0) + (number) 1
Adding number conversion cast (unumber) plot::$0 in (number~) plot::$0 ← *((byte*) SCREEN#0 + (byte) plot::idx#0) + (unumber)(number) 1
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) plots#0 ← (byte*)(number) $1000
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
Inlining cast *((byte*) SCREEN#0 + (byte) main::i#2) ← (unumber)(number) 0
Inlining cast (byte) line::x0#0 ← (unumber)(number) 0
Inlining cast (byte) line::x1#0 ← (unumber)(number) $a
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 4096
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast $a
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $a
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) plot::$0 ← *((byte*) SCREEN#0 + (byte) plot::idx#0) + (byte) 1
Alias (byte) line::x0#1 = (byte) line::x0#2 (byte) line::x#0 (byte) line::x0#3 
Alias (byte) line::x1#1 = (byte) line::x1#4 
Alias (byte) line::x#2 = (byte) line::x#3 
Alias (byte) line::x1#2 = (byte) line::x1#3 
Successful SSA optimization Pass2AliasElimination
Self Phi Eliminated (byte) line::x1#2
Successful SSA optimization Pass2SelfPhiElimination
Identical Phi Values (byte) line::x0#1 (byte) line::x0#0
Identical Phi Values (byte) line::x1#1 (byte) line::x1#0
Identical Phi Values (byte) line::x1#2 (byte) line::x1#1
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$0 [8] if((byte) main::i#1!=rangelast(0,$27)) goto main::@1
Simple Condition (bool~) line::$0 [16] if((byte) line::x0#0<(byte) line::x1#0) goto line::@1
Simple Condition (bool~) line::$3 [28] if((byte) line::x#1<=(byte) line::x1#0) goto line::@5
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) plots#0 = (byte*) 4096
Constant (const byte*) SCREEN#0 = (byte*) 1024
Constant (const byte) main::i#0 = 0
Constant (const byte) line::x0#0 = 0
Constant (const byte) line::x1#0 = $a
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte) plot::x#0 = line::x0#0
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [12] if(true) goto main::@3
if() condition always true - replacing block destination [16] if((const byte) line::x0#0<(const byte) line::x1#0) goto line::@1
Successful SSA optimization Pass2ConstantIfs
Resolved ranged next value [6] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [8] if(main::i#1!=rangelast(0,$27)) goto main::@1 to (number) $28
Rewriting conditional comparison [28] if((byte) line::x#1<=(const byte) line::x1#0) goto line::@5
Removing unused block main::@return
Removing PHI-reference to removed block (line::@3) in block plot
Removing unused block line::@3
Removing unused block line::@7
Successful SSA optimization Pass2EliminateUnusedBlocks
Adding number conversion cast (unumber) $28 in if((byte) main::i#1!=(number) $28) goto main::@1
Adding number conversion cast (unumber) line::x1#0+1 in if((byte) line::x#1<(const byte) line::x1#0+(number) 1) goto line::@5
Adding number conversion cast (unumber) 1 in if((byte) line::x#1<(unumber)(const byte) line::x1#0+(number) 1) goto line::@5
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast $28
Simplifying constant integer cast (const byte) line::x1#0+(unumber)(number) 1
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $28
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Identical Phi Values (byte) plot::x#2 (byte) plot::x#1
Successful SSA optimization Pass2IdenticalPhiElimination
Eliminating unused constant (const byte) plot::x#0
Successful SSA optimization PassNEliminateUnusedVars
Inlining constant with var siblings (const byte) main::i#0
Constant inlined main::i#0 = (byte) 0
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@6(between main::@1 and main::@1)
Added new block during phi lifting line::@9(between line::@8 and line::@5)
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 main::@3
Adding NOP phi() at start of main::@5
Adding NOP phi() at start of line
Adding NOP phi() at start of line::@1
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to line:12 
Calls in [line] to plot:19 

Created 2 initial phi equivalence classes
Coalesced [14] main::i#3 ← main::i#1
Coalesced [23] line::x#4 ← line::x#1
Coalesced down to 2 phi equivalence classes
Culled Empty Block (label) @4
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@6
Culled Empty Block (label) line::@1
Culled Empty Block (label) line::@9
Renumbering block @3 to @1
Renumbering block main::@3 to main::@2
Renumbering block line::@5 to line::@1
Renumbering block line::@8 to line::@2
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 main::@2
Adding NOP phi() at start of line

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::@1
  [5] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
  [6] *((const byte*) plots#0 + (byte) main::i#2) ← (byte) main::i#2
  [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte) 0
  [8] (byte) main::i#1 ← ++ (byte) main::i#2
  [9] if((byte) main::i#1!=(byte) $28) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@2
  [10] phi()
  [11] call line 
  to:main::@2
line: scope:[line]  from main::@2
  [12] phi()
  to:line::@1
line::@1: scope:[line]  from line line::@2
  [13] (byte) line::x#2 ← phi( line/(const byte) line::x0#0 line::@2/(byte) line::x#1 )
  [14] (byte) plot::x#1 ← (byte) line::x#2
  [15] call plot 
  to:line::@2
line::@2: scope:[line]  from line::@1
  [16] (byte) line::x#1 ← ++ (byte) line::x#2
  [17] if((byte) line::x#1<(const byte) line::x1#0+(byte) 1) goto line::@1
  to:line::@return
line::@return: scope:[line]  from line::@2
  [18] return 
  to:@return
plot: scope:[plot]  from line::@1
  [19] (byte) plot::idx#0 ← *((const byte*) plots#0 + (byte) plot::x#1)
  [20] (byte~) plot::$0 ← *((const byte*) SCREEN#0 + (byte) plot::idx#0) + (byte) 1
  [21] *((const byte*) SCREEN#0 + (byte) plot::idx#0) ← (byte~) plot::$0
  to:plot::@return
plot::@return: scope:[plot]  from plot
  [22] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte*) SCREEN
(void()) line((byte) line::x0 , (byte) line::x1)
(byte) line::x
(byte) line::x#1 151.5
(byte) line::x#2 101.0
(byte) line::x0
(byte) line::x1
(void()) main()
(byte) main::i
(byte) main::i#1 16.5
(byte) main::i#2 18.333333333333332
(void()) plot((byte) plot::x)
(byte~) plot::$0 4.0
(byte) plot::idx
(byte) plot::idx#0 3.0
(byte) plot::x
(byte) plot::x#1 103.0
(byte*) plots

Initial phi equivalence classes
[ main::i#2 main::i#1 ]
[ line::x#2 line::x#1 ]
Added variable plot::x#1 to zero page equivalence class [ plot::x#1 ]
Added variable plot::idx#0 to zero page equivalence class [ plot::idx#0 ]
Added variable plot::$0 to zero page equivalence class [ plot::$0 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ line::x#2 line::x#1 ]
[ plot::x#1 ]
[ plot::idx#0 ]
[ plot::$0 ]
Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Allocated zp ZP_BYTE:3 [ line::x#2 line::x#1 ]
Allocated zp ZP_BYTE:4 [ plot::x#1 ]
Allocated zp ZP_BYTE:5 [ plot::idx#0 ]
Allocated zp ZP_BYTE:6 [ plot::$0 ]

INITIAL ASM
  // File Comments
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label plots = $1000
  .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
    // [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::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] *((const byte*) plots#0 + (byte) main::i#2) ← (byte) main::i#2 -- pbuc1_derefidx_vbuz1=vbuz1 
    ldy i
    tya
    sta plots,y
    // [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte) 0 -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #0
    ldy i
    sta SCREEN,y
    // [8] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 
    inc i
    // [9] if((byte) main::i#1!=(byte) $28) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #$28
    cmp i
    bne b1_from_b1
    // [10] phi from main::@1 main::@2 to main::@2 [phi:main::@1/main::@2->main::@2]
  b2_from_b1:
  b2_from_b2:
    jmp b2
    // main::@2
  b2:
    // [11] call line 
    // [12] phi from main::@2 to line [phi:main::@2->line]
  line_from_b2:
    jsr line
    jmp b2_from_b2
}
  // line
line: {
    .const x0 = 0
    .const x1 = $a
    .label x = 3
    // [13] phi from line to line::@1 [phi:line->line::@1]
  b1_from_line:
    // [13] phi (byte) line::x#2 = (const byte) line::x0#0 [phi:line->line::@1#0] -- vbuz1=vbuc1 
    lda #x0
    sta x
    jmp b1
    // [13] phi from line::@2 to line::@1 [phi:line::@2->line::@1]
  b1_from_b2:
    // [13] phi (byte) line::x#2 = (byte) line::x#1 [phi:line::@2->line::@1#0] -- register_copy 
    jmp b1
    // line::@1
  b1:
    // [14] (byte) plot::x#1 ← (byte) line::x#2 -- vbuz1=vbuz2 
    lda x
    sta plot.x
    // [15] call plot 
    jsr plot
    jmp b2
    // line::@2
  b2:
    // [16] (byte) line::x#1 ← ++ (byte) line::x#2 -- vbuz1=_inc_vbuz1 
    inc x
    // [17] if((byte) line::x#1<(const byte) line::x1#0+(byte) 1) goto line::@1 -- vbuz1_lt_vbuc1_then_la1 
    lda x
    cmp #x1+1
    bcc b1_from_b2
    jmp breturn
    // line::@return
  breturn:
    // [18] return 
    rts
}
  // plot
// plot(byte zeropage(4) x)
plot: {
    .label _0 = 6
    .label x = 4
    .label idx = 5
    // [19] (byte) plot::idx#0 ← *((const byte*) plots#0 + (byte) plot::x#1) -- vbuz1=pbuc1_derefidx_vbuz2 
    ldy x
    lda plots,y
    sta idx
    // [20] (byte~) plot::$0 ← *((const byte*) SCREEN#0 + (byte) plot::idx#0) + (byte) 1 -- vbuz1=pbuc1_derefidx_vbuz2_plus_1 
    ldx idx
    ldy SCREEN,x
    iny
    sty _0
    // [21] *((const byte*) SCREEN#0 + (byte) plot::idx#0) ← (byte~) plot::$0 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda _0
    ldy idx
    sta SCREEN,y
    jmp breturn
    // plot::@return
  breturn:
    // [22] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte) 0 [ main::i#2 ] ( main:2 [ main::i#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 ]
Statement [6] *((const byte*) plots#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a 
Statement [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte) 0 [ main::i#2 ] ( main:2 [ main::i#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 [ line::x#2 line::x#1 ] : zp ZP_BYTE:3 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:4 [ plot::x#1 ] : zp ZP_BYTE:4 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:5 [ plot::idx#0 ] : zp ZP_BYTE:5 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:6 [ plot::$0 ] : zp ZP_BYTE:6 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [line] 252.5: zp ZP_BYTE:3 [ line::x#2 line::x#1 ] 
Uplift Scope [plot] 103: zp ZP_BYTE:4 [ plot::x#1 ] 4: zp ZP_BYTE:6 [ plot::$0 ] 3: zp ZP_BYTE:5 [ plot::idx#0 ] 
Uplift Scope [main] 34.83: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 
Uplift Scope [] 

Uplifting [line] best 4684 combination zp ZP_BYTE:3 [ line::x#2 line::x#1 ] 
Uplifting [plot] best 4368 combination reg byte y [ plot::x#1 ] reg byte a [ plot::$0 ] reg byte x [ plot::idx#0 ] 
Uplifting [main] best 4218 combination reg byte x [ main::i#2 main::i#1 ] 
Uplifting [] best 4218 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:3 [ line::x#2 line::x#1 ]
Uplifting [line] best 3018 combination reg byte y [ line::x#2 line::x#1 ] 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label plots = $1000
  .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::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] *((const byte*) plots#0 + (byte) main::i#2) ← (byte) main::i#2 -- pbuc1_derefidx_vbuxx=vbuxx 
    txa
    sta plots,x
    // [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte) 0 -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #0
    sta SCREEN,x
    // [8] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [9] if((byte) main::i#1!=(byte) $28) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$28
    bne b1_from_b1
    // [10] phi from main::@1 main::@2 to main::@2 [phi:main::@1/main::@2->main::@2]
  b2_from_b1:
  b2_from_b2:
    jmp b2
    // main::@2
  b2:
    // [11] call line 
    // [12] phi from main::@2 to line [phi:main::@2->line]
  line_from_b2:
    jsr line
    jmp b2_from_b2
}
  // line
line: {
    .const x0 = 0
    .const x1 = $a
    // [13] phi from line to line::@1 [phi:line->line::@1]
  b1_from_line:
    // [13] phi (byte) line::x#2 = (const byte) line::x0#0 [phi:line->line::@1#0] -- vbuyy=vbuc1 
    ldy #x0
    jmp b1
    // [13] phi from line::@2 to line::@1 [phi:line::@2->line::@1]
  b1_from_b2:
    // [13] phi (byte) line::x#2 = (byte) line::x#1 [phi:line::@2->line::@1#0] -- register_copy 
    jmp b1
    // line::@1
  b1:
    // [14] (byte) plot::x#1 ← (byte) line::x#2
    // [15] call plot 
    jsr plot
    jmp b2
    // line::@2
  b2:
    // [16] (byte) line::x#1 ← ++ (byte) line::x#2 -- vbuyy=_inc_vbuyy 
    iny
    // [17] if((byte) line::x#1<(const byte) line::x1#0+(byte) 1) goto line::@1 -- vbuyy_lt_vbuc1_then_la1 
    cpy #x1+1
    bcc b1_from_b2
    jmp breturn
    // line::@return
  breturn:
    // [18] return 
    rts
}
  // plot
// plot(byte register(Y) x)
plot: {
    // [19] (byte) plot::idx#0 ← *((const byte*) plots#0 + (byte) plot::x#1) -- vbuxx=pbuc1_derefidx_vbuyy 
    ldx plots,y
    // [20] (byte~) plot::$0 ← *((const byte*) SCREEN#0 + (byte) plot::idx#0) + (byte) 1 -- vbuaa=pbuc1_derefidx_vbuxx_plus_1 
    lda SCREEN,x
    clc
    adc #1
    // [21] *((const byte*) SCREEN#0 + (byte) plot::idx#0) ← (byte~) plot::$0 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN,x
    jmp breturn
    // plot::@return
  breturn:
    // [22] 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 b1
Removing instruction jmp b2
Removing instruction jmp breturn
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b1_from_b1 with b1
Replacing label b2_from_b2 with b2
Replacing label b1_from_b2 with b1
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_b1:
Removing instruction b2_from_b1:
Removing instruction b2_from_b2:
Removing instruction line_from_b2:
Removing instruction b1_from_b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction b1_from_line:
Removing instruction b2:
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 b1
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()) line((byte) line::x0 , (byte) line::x1)
(label) line::@1
(label) line::@2
(label) line::@return
(byte) line::x
(byte) line::x#1 reg byte y 151.5
(byte) line::x#2 reg byte y 101.0
(byte) line::x0
(const byte) line::x0#0 x0 = (byte) 0
(byte) line::x1
(const byte) line::x1#0 x1 = (byte) $a
(void()) main()
(label) main::@1
(label) main::@2
(byte) main::i
(byte) main::i#1 reg byte x 16.5
(byte) main::i#2 reg byte x 18.333333333333332
(void()) plot((byte) plot::x)
(byte~) plot::$0 reg byte a 4.0
(label) plot::@return
(byte) plot::idx
(byte) plot::idx#0 reg byte x 3.0
(byte) plot::x
(byte) plot::x#1 reg byte y 103.0
(byte*) plots
(const byte*) plots#0 plots = (byte*) 4096

reg byte x [ main::i#2 main::i#1 ]
reg byte y [ line::x#2 line::x#1 ]
reg byte y [ plot::x#1 ]
reg byte x [ plot::idx#0 ]
reg byte a [ plot::$0 ]


FINAL ASSEMBLER
Score: 1713

  // File Comments
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .label plots = $1000
  .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::@1 to main::@1 [phi:main::@1->main::@1]
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    // main::@1
  b1:
    // plots[i] = i
    // [6] *((const byte*) plots#0 + (byte) main::i#2) ← (byte) main::i#2 -- pbuc1_derefidx_vbuxx=vbuxx 
    txa
    sta plots,x
    // SCREEN[i] = 0
    // [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte) 0 -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #0
    sta SCREEN,x
    // for(byte i : 0..39)
    // [8] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [9] if((byte) main::i#1!=(byte) $28) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$28
    bne b1
    // [10] phi from main::@1 main::@2 to main::@2 [phi:main::@1/main::@2->main::@2]
    // main::@2
  b2:
    // line(0, 10)
    // [11] call line 
    // [12] phi from main::@2 to line [phi:main::@2->line]
    jsr line
    jmp b2
}
  // line
line: {
    .const x0 = 0
    .const x1 = $a
    // [13] phi from line to line::@1 [phi:line->line::@1]
    // [13] phi (byte) line::x#2 = (const byte) line::x0#0 [phi:line->line::@1#0] -- vbuyy=vbuc1 
    ldy #x0
    // [13] phi from line::@2 to line::@1 [phi:line::@2->line::@1]
    // [13] phi (byte) line::x#2 = (byte) line::x#1 [phi:line::@2->line::@1#0] -- register_copy 
    // line::@1
  b1:
    // plot(x)
    // [14] (byte) plot::x#1 ← (byte) line::x#2
    // [15] call plot 
    jsr plot
    // line::@2
    // for(byte x = x0; x<=x1; x++)
    // [16] (byte) line::x#1 ← ++ (byte) line::x#2 -- vbuyy=_inc_vbuyy 
    iny
    // [17] if((byte) line::x#1<(const byte) line::x1#0+(byte) 1) goto line::@1 -- vbuyy_lt_vbuc1_then_la1 
    cpy #x1+1
    bcc b1
    // line::@return
    // }
    // [18] return 
    rts
}
  // plot
// plot(byte register(Y) x)
plot: {
    // idx = plots[x]
    // [19] (byte) plot::idx#0 ← *((const byte*) plots#0 + (byte) plot::x#1) -- vbuxx=pbuc1_derefidx_vbuyy 
    ldx plots,y
    // SCREEN[idx]+1
    // [20] (byte~) plot::$0 ← *((const byte*) SCREEN#0 + (byte) plot::idx#0) + (byte) 1 -- vbuaa=pbuc1_derefidx_vbuxx_plus_1 
    lda SCREEN,x
    clc
    adc #1
    // SCREEN[idx] = SCREEN[idx]+1
    // [21] *((const byte*) SCREEN#0 + (byte) plot::idx#0) ← (byte~) plot::$0 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN,x
    // plot::@return
    // }
    // [22] return 
    rts
}
  // File Data

