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

Culled Empty Block (label) line::@7
Culled Empty Block (label) @4
Successful SSA optimization Pass2CullEmptyBlocks
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
Redundant Phi (byte) line::x0#1 (byte) line::x0#0
Redundant Phi (byte) line::x1#1 (byte) line::x1#0
Redundant Phi (byte) line::x1#2 (byte) line::x1#1
Successful SSA optimization Pass2RedundantPhiElimination
Simple Condition (bool~) main::$0 [8] if((byte) main::i#1!=rangelast(0,39)) 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::@3
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 = 10
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte) plot::x#0 = line::x0#0
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [6] if(true) goto main::@2
if() condition always true - replacing block destination [8] if((const byte) line::x0#0<(const byte) line::x1#0) goto line::@1
Successful SSA optimization Pass2ConstantIfs
Removing unused block main::@return
Removing PHI-reference to removed block (line::@4) in block plot
Removing unused block line::@4
Successful SSA optimization Pass2EliminateUnusedBlocks
Resolved ranged next value main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value if(main::i#1!=rangelast(0,39)) goto main::@1 to (byte/signed byte/word/signed word/dword/signed dword) 40
Culled Empty Block (label) main::@5
Culled Empty Block (label) line::@1
Successful SSA optimization Pass2CullEmptyBlocks
Redundant Phi (byte) plot::x#2 (byte) plot::x#1
Successful SSA optimization Pass2RedundantPhiElimination
Successful SSA optimization PassNEliminateUnusedVars
Inlining constant with var siblings (const byte) main::i#0
Constant inlined main::i#0 = (byte/signed byte/word/signed word/dword/signed dword) 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::@3)
Adding NOP phi() at start of @begin
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 line
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to line:11 
Calls in [line] to plot:16 

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

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi()
  to:@3
@3: scope:[]  from @begin
  [1] phi()
  [2] call main 
  to:@end
@end: scope:[]  from @3
  [3] phi()
main: scope:[main]  from @3
  [4] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@1
  [5] (byte) main::i#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 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/signed byte/word/signed word/dword/signed dword) 0
  [8] (byte) main::i#1 ← ++ (byte) main::i#2
  [9] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 40) 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::@3
line::@3: scope:[line]  from line line::@8
  [13] (byte) line::x#2 ← phi( line/(const byte) line::x0#0 line::@8/(byte) line::x#1 )
  [14] (byte) plot::x#1 ← (byte) line::x#2
  [15] call plot 
  to:line::@8
line::@8: scope:[line]  from line::@3
  [16] (byte) line::x#1 ← ++ (byte) line::x#2
  [17] if((byte) line::x#1<=(const byte) line::x1#0) goto line::@3
  to:line::@return
line::@return: scope:[line]  from line::@8
  [18] return 
  to:@return
plot: scope:[plot]  from line::@3
  [19] (byte) plot::idx#0 ← *((const byte*) plots#0 + (byte) plot::x#1)
  [20] (byte/signed word/word/dword/signed dword~) plot::$0 ← *((const byte*) SCREEN#0 + (byte) plot::idx#0) + (byte/signed byte/word/signed word/dword/signed dword) 1
  [21] *((const byte*) SCREEN#0 + (byte) plot::idx#0) ← (byte/signed word/word/dword/signed dword~) 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/signed word/word/dword/signed dword~) 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
//SEG0 File Comments
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label plots = $1000
  .label SCREEN = $400
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @3 [phi:@begin->@3]
b3_from_bbegin:
  jmp b3
//SEG5 @3
b3:
//SEG6 [2] call main 
//SEG7 [4] phi from @3 to main [phi:@3->main]
main_from_b3:
  jsr main
//SEG8 [3] phi from @3 to @end [phi:@3->@end]
bend_from_b3:
  jmp bend
//SEG9 @end
bend:
//SEG10 main
main: {
    .label i = 2
  //SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
  //SEG12 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta i
    jmp b1
  //SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
  //SEG14 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
  //SEG15 main::@1
  b1:
  //SEG16 [6] *((const byte*) plots#0 + (byte) main::i#2) ← (byte) main::i#2 -- pbuc1_derefidx_vbuz1=vbuz1 
    ldy i
    tya
    sta plots,y
  //SEG17 [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte/signed byte/word/signed word/dword/signed dword) 0 -- pbuc1_derefidx_vbuz1=vbuc2 
    ldy i
    lda #0
    sta SCREEN,y
  //SEG18 [8] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 
    inc i
  //SEG19 [9] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 40) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda i
    cmp #$28
    bne b1_from_b1
  //SEG20 [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
  //SEG21 main::@2
  b2:
  //SEG22 [11] call line 
  //SEG23 [12] phi from main::@2 to line [phi:main::@2->line]
  line_from_b2:
    jsr line
    jmp b2_from_b2
}
//SEG24 line
line: {
    .const x0 = 0
    .const x1 = $a
    .label x = 3
  //SEG25 [13] phi from line to line::@3 [phi:line->line::@3]
  b3_from_line:
  //SEG26 [13] phi (byte) line::x#2 = (const byte) line::x0#0 [phi:line->line::@3#0] -- vbuz1=vbuc1 
    lda #x0
    sta x
    jmp b3
  //SEG27 [13] phi from line::@8 to line::@3 [phi:line::@8->line::@3]
  b3_from_b8:
  //SEG28 [13] phi (byte) line::x#2 = (byte) line::x#1 [phi:line::@8->line::@3#0] -- register_copy 
    jmp b3
  //SEG29 line::@3
  b3:
  //SEG30 [14] (byte) plot::x#1 ← (byte) line::x#2 -- vbuz1=vbuz2 
    lda x
    sta plot.x
  //SEG31 [15] call plot 
    jsr plot
    jmp b8
  //SEG32 line::@8
  b8:
  //SEG33 [16] (byte) line::x#1 ← ++ (byte) line::x#2 -- vbuz1=_inc_vbuz1 
    inc x
  //SEG34 [17] if((byte) line::x#1<=(const byte) line::x1#0) goto line::@3 -- vbuz1_le_vbuc1_then_la1 
    lda #x1
    cmp x
    bcs b3_from_b8
    jmp breturn
  //SEG35 line::@return
  breturn:
  //SEG36 [18] return 
    rts
}
//SEG37 plot
// plot(byte zeropage(4) x)
plot: {
    .label _0 = 6
    .label x = 4
    .label idx = 5
  //SEG38 [19] (byte) plot::idx#0 ← *((const byte*) plots#0 + (byte) plot::x#1) -- vbuz1=pbuc1_derefidx_vbuz2 
    ldy x
    lda plots,y
    sta idx
  //SEG39 [20] (byte/signed word/word/dword/signed dword~) plot::$0 ← *((const byte*) SCREEN#0 + (byte) plot::idx#0) + (byte/signed byte/word/signed word/dword/signed dword) 1 -- vbuz1=pbuc1_derefidx_vbuz2_plus_1 
    ldy idx
    lda SCREEN,y
    clc
    adc #1
    sta _0
  //SEG40 [21] *((const byte*) SCREEN#0 + (byte) plot::idx#0) ← (byte/signed word/word/dword/signed dword~) plot::$0 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda _0
    ldy idx
    sta SCREEN,y
    jmp breturn
  //SEG41 plot::@return
  breturn:
  //SEG42 [22] return 
    rts
}

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte/signed byte/word/signed word/dword/signed dword) 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 [20] (byte/signed word/word/dword/signed dword~) plot::$0 ← *((const byte*) SCREEN#0 + (byte) plot::idx#0) + (byte/signed byte/word/signed word/dword/signed dword) 1 [ plot::idx#0 plot::$0 ] ( main:2::line:11::plot:15 [ line::x#2 plot::idx#0 plot::$0 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:3 [ line::x#2 line::x#1 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:5 [ plot::idx#0 ]
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/signed byte/word/signed word/dword/signed dword) 0 [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a 
Statement [20] (byte/signed word/word/dword/signed dword~) plot::$0 ← *((const byte*) SCREEN#0 + (byte) plot::idx#0) + (byte/signed byte/word/signed word/dword/signed dword) 1 [ plot::idx#0 plot::$0 ] ( main:2::line:11::plot:15 [ line::x#2 plot::idx#0 plot::$0 ] ) 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 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 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 3736 combination reg byte x [ line::x#2 line::x#1 ] 
Uplifting [plot] best 3418 combination reg byte x [ plot::x#1 ] reg byte a [ plot::$0 ] reg byte y [ plot::idx#0 ] 
Uplifting [main] best 3268 combination reg byte x [ main::i#2 main::i#1 ] 
Uplifting [] best 3268 combination 

ASSEMBLER BEFORE OPTIMIZATION
//SEG0 File Comments
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label plots = $1000
  .label SCREEN = $400
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @3 [phi:@begin->@3]
b3_from_bbegin:
  jmp b3
//SEG5 @3
b3:
//SEG6 [2] call main 
//SEG7 [4] phi from @3 to main [phi:@3->main]
main_from_b3:
  jsr main
//SEG8 [3] phi from @3 to @end [phi:@3->@end]
bend_from_b3:
  jmp bend
//SEG9 @end
bend:
//SEG10 main
main: {
  //SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
  //SEG12 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    jmp b1
  //SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
  //SEG14 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
  //SEG15 main::@1
  b1:
  //SEG16 [6] *((const byte*) plots#0 + (byte) main::i#2) ← (byte) main::i#2 -- pbuc1_derefidx_vbuxx=vbuxx 
    txa
    sta plots,x
  //SEG17 [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte/signed byte/word/signed word/dword/signed dword) 0 -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #0
    sta SCREEN,x
  //SEG18 [8] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
  //SEG19 [9] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 40) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$28
    bne b1_from_b1
  //SEG20 [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
  //SEG21 main::@2
  b2:
  //SEG22 [11] call line 
  //SEG23 [12] phi from main::@2 to line [phi:main::@2->line]
  line_from_b2:
    jsr line
    jmp b2_from_b2
}
//SEG24 line
line: {
    .const x0 = 0
    .const x1 = $a
  //SEG25 [13] phi from line to line::@3 [phi:line->line::@3]
  b3_from_line:
  //SEG26 [13] phi (byte) line::x#2 = (const byte) line::x0#0 [phi:line->line::@3#0] -- vbuxx=vbuc1 
    ldx #x0
    jmp b3
  //SEG27 [13] phi from line::@8 to line::@3 [phi:line::@8->line::@3]
  b3_from_b8:
  //SEG28 [13] phi (byte) line::x#2 = (byte) line::x#1 [phi:line::@8->line::@3#0] -- register_copy 
    jmp b3
  //SEG29 line::@3
  b3:
  //SEG30 [14] (byte) plot::x#1 ← (byte) line::x#2
  //SEG31 [15] call plot 
    jsr plot
    jmp b8
  //SEG32 line::@8
  b8:
  //SEG33 [16] (byte) line::x#1 ← ++ (byte) line::x#2 -- vbuxx=_inc_vbuxx 
    inx
  //SEG34 [17] if((byte) line::x#1<=(const byte) line::x1#0) goto line::@3 -- vbuxx_le_vbuc1_then_la1 
    cpx #x1
    bcc b3_from_b8
    beq b3_from_b8
    jmp breturn
  //SEG35 line::@return
  breturn:
  //SEG36 [18] return 
    rts
}
//SEG37 plot
// plot(byte register(X) x)
plot: {
  //SEG38 [19] (byte) plot::idx#0 ← *((const byte*) plots#0 + (byte) plot::x#1) -- vbuyy=pbuc1_derefidx_vbuxx 
    ldy plots,x
  //SEG39 [20] (byte/signed word/word/dword/signed dword~) plot::$0 ← *((const byte*) SCREEN#0 + (byte) plot::idx#0) + (byte/signed byte/word/signed word/dword/signed dword) 1 -- vbuaa=pbuc1_derefidx_vbuyy_plus_1 
    lda SCREEN,y
    clc
    adc #1
  //SEG40 [21] *((const byte*) SCREEN#0 + (byte) plot::idx#0) ← (byte/signed word/word/dword/signed dword~) plot::$0 -- pbuc1_derefidx_vbuyy=vbuaa 
    sta SCREEN,y
    jmp breturn
  //SEG41 plot::@return
  breturn:
  //SEG42 [22] return 
    rts
}

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b3
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp b3
Removing instruction jmp b8
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 b3_from_b8 with b3
Replacing label b3_from_b8 with b3
Removing instruction b3_from_bbegin:
Removing instruction b3:
Removing instruction main_from_b3:
Removing instruction bend_from_b3:
Removing instruction b1_from_b1:
Removing instruction b2_from_b1:
Removing instruction b2_from_b2:
Removing instruction line_from_b2:
Removing instruction b3_from_b8:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction b3_from_line:
Removing instruction b8:
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 b3
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @3
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) 1024
(void()) line((byte) line::x0 , (byte) line::x1)
(label) line::@3
(label) line::@8
(label) line::@return
(byte) line::x
(byte) line::x#1 reg byte x 151.5
(byte) line::x#2 reg byte x 101.0
(byte) line::x0
(const byte) line::x0#0 x0 = (byte/signed byte/word/signed word/dword/signed dword) 0
(byte) line::x1
(const byte) line::x1#0 x1 = (byte/signed byte/word/signed word/dword/signed dword) 10
(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/signed word/word/dword/signed dword~) plot::$0 reg byte a 4.0
(label) plot::@return
(byte) plot::idx
(byte) plot::idx#0 reg byte y 3.0
(byte) plot::x
(byte) plot::x#1 reg byte x 103.0
(byte*) plots
(const byte*) plots#0 plots = ((byte*))(word/signed word/dword/signed dword) 4096

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


FINAL ASSEMBLER
Score: 1963

//SEG0 File Comments
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label plots = $1000
  .label SCREEN = $400
//SEG3 @begin
//SEG4 [1] phi from @begin to @3 [phi:@begin->@3]
//SEG5 @3
//SEG6 [2] call main 
//SEG7 [4] phi from @3 to main [phi:@3->main]
//SEG8 [3] phi from @3 to @end [phi:@3->@end]
//SEG9 @end
//SEG10 main
main: {
  //SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
  //SEG12 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
  //SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  //SEG14 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
  //SEG15 main::@1
  b1:
  //SEG16 [6] *((const byte*) plots#0 + (byte) main::i#2) ← (byte) main::i#2 -- pbuc1_derefidx_vbuxx=vbuxx 
    txa
    sta plots,x
  //SEG17 [7] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte/signed byte/word/signed word/dword/signed dword) 0 -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #0
    sta SCREEN,x
  //SEG18 [8] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
  //SEG19 [9] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 40) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$28
    bne b1
  //SEG20 [10] phi from main::@1 main::@2 to main::@2 [phi:main::@1/main::@2->main::@2]
  //SEG21 main::@2
  b2:
  //SEG22 [11] call line 
  //SEG23 [12] phi from main::@2 to line [phi:main::@2->line]
    jsr line
    jmp b2
}
//SEG24 line
line: {
    .const x0 = 0
    .const x1 = $a
  //SEG25 [13] phi from line to line::@3 [phi:line->line::@3]
  //SEG26 [13] phi (byte) line::x#2 = (const byte) line::x0#0 [phi:line->line::@3#0] -- vbuxx=vbuc1 
    ldx #x0
  //SEG27 [13] phi from line::@8 to line::@3 [phi:line::@8->line::@3]
  //SEG28 [13] phi (byte) line::x#2 = (byte) line::x#1 [phi:line::@8->line::@3#0] -- register_copy 
  //SEG29 line::@3
  b3:
  //SEG30 [14] (byte) plot::x#1 ← (byte) line::x#2
  //SEG31 [15] call plot 
    jsr plot
  //SEG32 line::@8
  //SEG33 [16] (byte) line::x#1 ← ++ (byte) line::x#2 -- vbuxx=_inc_vbuxx 
    inx
  //SEG34 [17] if((byte) line::x#1<=(const byte) line::x1#0) goto line::@3 -- vbuxx_le_vbuc1_then_la1 
    cpx #x1
    bcc b3
    beq b3
  //SEG35 line::@return
  //SEG36 [18] return 
    rts
}
//SEG37 plot
// plot(byte register(X) x)
plot: {
  //SEG38 [19] (byte) plot::idx#0 ← *((const byte*) plots#0 + (byte) plot::x#1) -- vbuyy=pbuc1_derefidx_vbuxx 
    ldy plots,x
  //SEG39 [20] (byte/signed word/word/dword/signed dword~) plot::$0 ← *((const byte*) SCREEN#0 + (byte) plot::idx#0) + (byte/signed byte/word/signed word/dword/signed dword) 1 -- vbuaa=pbuc1_derefidx_vbuyy_plus_1 
    lda SCREEN,y
    clc
    adc #1
  //SEG40 [21] *((const byte*) SCREEN#0 + (byte) plot::idx#0) ← (byte/signed word/word/dword/signed dword~) plot::$0 -- pbuc1_derefidx_vbuyy=vbuaa 
    sta SCREEN,y
  //SEG41 plot::@return
  //SEG42 [22] return 
    rts
}

