PARSING src/test/java/dk/camelot64/kickc/test/kc/const-identification.kc
const byte* plots = $1000;
const byte* SCREEN = $0400;

void main() {
    for(byte i : 0..39) {
       plots[i] = i;
       SCREEN[i] = 0;
    }
    do {
        line(0, 10);
    } while (true);
}

void line(byte x0, byte x1) {
    if(x0<x1) {
        for(byte x = x0; x<=x1; x++) {
            plot(x);
        }
    } else {
        plot(x0);
    }
}

void plot(byte x) {
    byte idx = plots[x];
    SCREEN[idx] = SCREEN[idx]+1;
}

Adding pre/post-modifier (byte) line::x ← ++ (byte) line::x

STATEMENTS
  (byte*) plots ← (word/signed word/dword/signed dword) 4096
  (byte*) SCREEN ← (word/signed word/dword/signed dword) 1024
proc (void()) main()
  (byte) main::i ← (byte/signed byte/word/signed word/dword/signed dword) 0
main::@1:
  *((byte*) plots + (byte) main::i) ← (byte) main::i
  *((byte*) SCREEN + (byte) main::i) ← (byte/signed byte/word/signed word/dword/signed dword) 0
  (byte) main::i ← ++ (byte) main::i
  (boolean~) main::$0 ← (byte) main::i != (byte/signed byte/word/signed word/dword/signed dword) 40
  if((boolean~) main::$0) goto main::@1
main::@2:
  (void~) main::$1 ← call line (byte/signed byte/word/signed word/dword/signed dword) 0 (byte/signed byte/word/signed word/dword/signed dword) 10 
  if(true) goto main::@2
main::@return:
  return 
endproc // main()
proc (void()) line((byte) line::x0 , (byte) line::x1)
  (boolean~) line::$0 ← (byte) line::x0 < (byte) line::x1
  (boolean~) line::$1 ← ! (boolean~) line::$0
  if((boolean~) line::$1) goto line::@1
  (byte) line::x ← (byte) line::x0
line::@2:
  (void~) line::$2 ← call plot (byte) line::x 
  (byte) line::x ← ++ (byte) line::x
  (boolean~) line::$3 ← (byte) line::x <= (byte) line::x1
  if((boolean~) line::$3) goto line::@2
  goto line::@3
line::@1:
  (void~) line::$4 ← call plot (byte) line::x0 
line::@3:
line::@return:
  return 
endproc // line()
proc (void()) plot((byte) plot::x)
  (byte) plot::idx ← *((byte*) plots + (byte) plot::x)
  (byte/word~) plot::$0 ← *((byte*) SCREEN + (byte) plot::idx) + (byte/signed byte/word/signed word/dword/signed dword) 1
  *((byte*) SCREEN + (byte) plot::idx) ← (byte/word~) plot::$0
plot::@return:
  return 
endproc // plot()
  call main 

SYMBOLS
(byte*) SCREEN
(void()) line((byte) line::x0 , (byte) line::x1)
(boolean~) line::$0
(boolean~) line::$1
(void~) line::$2
(boolean~) line::$3
(void~) line::$4
(label) line::@1
(label) line::@2
(label) line::@3
(label) line::@return
(byte) line::x
(byte) line::x0
(byte) line::x1
(void()) main()
(boolean~) main::$0
(void~) main::$1
(label) main::@1
(label) main::@2
(label) main::@return
(byte) main::i
(void()) plot((byte) plot::x)
(byte/word~) plot::$0
(label) plot::@return
(byte) plot::idx
(byte) plot::x
(byte*) plots

Promoting word/signed word/dword/signed dword to byte* in plots ← ((byte*)) 4096
Promoting word/signed word/dword/signed dword to byte* in SCREEN ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  (byte*) plots ← ((byte*)) (word/signed word/dword/signed dword) 4096
  (byte*) SCREEN ← ((byte*)) (word/signed word/dword/signed dword) 1024
  to:@1
main: scope:[main]  from
  (byte) main::i ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:main::@1
main::@1: scope:[main]  from main main::@1
  *((byte*) plots + (byte) main::i) ← (byte) main::i
  *((byte*) SCREEN + (byte) main::i) ← (byte/signed byte/word/signed word/dword/signed dword) 0
  (byte) main::i ← ++ (byte) main::i
  (boolean~) main::$0 ← (byte) main::i != (byte/signed byte/word/signed word/dword/signed dword) 40
  if((boolean~) main::$0) goto main::@1
  to:main::@3
main::@3: scope:[main]  from main::@1
  to:main::@2
main::@2: scope:[main]  from main::@2 main::@3
  (void~) main::$1 ← call line (byte/signed byte/word/signed word/dword/signed dword) 0 (byte/signed byte/word/signed word/dword/signed dword) 10 
  if(true) goto main::@2
  to:main::@4
main::@4: scope:[main]  from main::@2
  to:main::@return
main::@return: scope:[main]  from main::@4
  return 
  to:@return
@1: scope:[]  from @begin
  to:@2
line: scope:[line]  from
  (boolean~) line::$0 ← (byte) line::x0 < (byte) line::x1
  (boolean~) line::$1 ← ! (boolean~) line::$0
  if((boolean~) line::$1) goto line::@1
  to:line::@4
line::@1: scope:[line]  from line line::@6
  (void~) line::$4 ← call plot (byte) line::x0 
  to:line::@3
line::@4: scope:[line]  from line
  (byte) line::x ← (byte) line::x0
  to:line::@2
line::@2: scope:[line]  from line::@2 line::@4
  (void~) line::$2 ← call plot (byte) line::x 
  (byte) line::x ← ++ (byte) line::x
  (boolean~) line::$3 ← (byte) line::x <= (byte) line::x1
  if((boolean~) line::$3) goto line::@2
  to:line::@5
line::@5: scope:[line]  from line::@2
  to:line::@3
line::@3: scope:[line]  from line::@1 line::@5
  to:line::@return
line::@6: scope:[line]  from
  to:line::@1
line::@return: scope:[line]  from line::@3
  return 
  to:@return
@2: scope:[]  from @1
  to:@3
plot: scope:[plot]  from
  (byte) plot::idx ← *((byte*) plots + (byte) plot::x)
  (byte/word~) plot::$0 ← *((byte*) SCREEN + (byte) plot::idx) + (byte/signed byte/word/signed word/dword/signed dword) 1
  *((byte*) SCREEN + (byte) plot::idx) ← (byte/word~) plot::$0
  to:plot::@return
plot::@return: scope:[plot]  from plot
  return 
  to:@return
@3: scope:[]  from @2
  call main 
  to:@end
@end: scope:[]  from @3

Eliminating unused variable - keeping the call (void~) main::$1
Eliminating unused variable - keeping the call (void~) line::$4
Eliminating unused variable - keeping the call (void~) line::$2
Removing empty block main::@3
Removing empty block main::@4
Removing empty block @1
Removing empty block line::@5
Removing empty block line::@3
Removing empty block line::@6
Removing empty block @2
PROCEDURE MODIFY VARIABLE ANALYSIS

Completing Phi functions...
Completing Phi functions...
Completing Phi functions...

CONTROL FLOW GRAPH SSA WITH ASSIGNMENT CALL & RETURN
@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
  (boolean~) main::$0 ← (byte) main::i#1 != (byte/signed byte/word/signed word/dword/signed dword) 40
  if((boolean~) 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 param-assignment
  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 )
  (boolean~) line::$0 ← (byte) line::x0#1 < (byte) line::x1#1
  (boolean~) line::$1 ← ! (boolean~) line::$0
  if((boolean~) line::$1) goto line::@1
  to:line::@4
line::@1: scope:[line]  from line
  (byte) line::x0#2 ← phi( line/(byte) line::x0#1 )
  (byte) plot::x#0 ← (byte) line::x0#2
  call plot param-assignment
  to:line::@7
line::@7: scope:[line]  from line::@1
  to:line::@return
line::@4: scope:[line]  from line
  (byte) line::x1#4 ← phi( line/(byte) line::x1#1 )
  (byte) line::x0#3 ← phi( line/(byte) line::x0#1 )
  (byte) line::x#0 ← (byte) line::x0#3
  to:line::@2
line::@2: scope:[line]  from line::@4 line::@8
  (byte) line::x1#3 ← phi( line::@4/(byte) line::x1#4 line::@8/(byte) line::x1#2 )
  (byte) line::x#2 ← phi( line::@4/(byte) line::x#0 line::@8/(byte) line::x#1 )
  (byte) plot::x#1 ← (byte) line::x#2
  call plot param-assignment
  to:line::@8
line::@8: scope:[line]  from line::@2
  (byte) line::x1#2 ← phi( line::@2/(byte) line::x1#3 )
  (byte) line::x#3 ← phi( line::@2/(byte) line::x#2 )
  (byte) line::x#1 ← ++ (byte) line::x#3
  (boolean~) line::$3 ← (byte) line::x#1 <= (byte) line::x1#2
  if((boolean~) line::$3) goto line::@2
  to:line::@return
line::@return: scope:[line]  from line::@7 line::@8
  return 
  to:@return
plot: scope:[plot]  from line::@1 line::@2
  (byte) plot::x#2 ← phi( line::@1/(byte) plot::x#0 line::@2/(byte) plot::x#1 )
  (byte) plot::idx#0 ← *((byte*) plots#0 + (byte) plot::x#2)
  (byte/word~) 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/word~) plot::$0
  to:plot::@return
plot::@return: scope:[plot]  from plot
  return 
  to:@return
@3: scope:[]  from @begin
  call main param-assignment
  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)
(boolean~) line::$0
(boolean~) line::$1
(boolean~) line::$3
(label) line::@1
(label) line::@2
(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()
(boolean~) 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/word~) 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

OPTIMIZING CONTROL FLOW GRAPH
Culled Empty Block (label) line::@7
Culled Empty Block (label) @4
Succesful SSA optimization Pass2CullEmptyBlocks
Inversing boolean not (boolean~) line::$1 ← (byte) line::x0#1 >= (byte) line::x1#1 from (boolean~) line::$0 ← (byte) line::x0#1 < (byte) line::x1#1
Succesful SSA optimization Pass2UnaryNotSimplification
Not aliassing across scopes: line::x0#1 line::x0#0
Not aliassing across scopes: line::x1#1 line::x1#0
Not aliassing across scopes: plot::x#0 line::x0#2
Not aliassing across scopes: plot::x#1 line::x#2
Not aliassing across scopes: plot::x#2 plot::x#0
Alias (byte) line::x0#1 = (byte) line::x0#2 (byte) line::x0#3 (byte) line::x#0 
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 
Succesful SSA optimization Pass2AliasElimination
Not aliassing across scopes: line::x0#1 line::x0#0
Not aliassing across scopes: line::x1#1 line::x1#0
Not aliassing across scopes: plot::x#0 line::x0#1
Not aliassing across scopes: plot::x#1 line::x#2
Not aliassing across scopes: plot::x#2 plot::x#0
Self Phi Eliminated (byte) line::x1#2
Succesful 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
Succesful SSA optimization Pass2RedundantPhiElimination
Simple Condition (boolean~) main::$0 if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 40) goto main::@1
Simple Condition (boolean~) line::$1 if((byte) line::x0#0>=(byte) line::x1#0) goto line::@1
Simple Condition (boolean~) line::$3 if((byte) line::x#1<=(byte) line::x1#0) goto line::@2
Succesful 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
Succesful SSA optimization Pass2ConstantIdentification
Constant (const byte) plot::x#0 = line::x0#0
Succesful SSA optimization Pass2ConstantIdentification
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Culled Empty Block (label) line::@4
Succesful SSA optimization Pass2CullEmptyBlocks
Not aliassing across scopes: plot::x#1 line::x#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Not aliassing across scopes: plot::x#1 line::x#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
OPTIMIZING CONTROL FLOW GRAPH
Inlining constant with var siblings (const byte) main::i#0
Inlining constant with var siblings (const byte) main::i#0
Inlining constant with var siblings (const byte) plot::x#0
Inlining constant with var siblings (const byte) plot::x#0
Constant inlined main::i#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Constant inlined plot::x#0 = (const byte) line::x0#0
Succesful SSA optimization Pass2ConstantInlining
Block Sequence Planned @begin @3 @end main main::@1 main::@2 main::@5 main::@return line line::@2 line::@8 line::@return line::@1 plot plot::@return 
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::@2)
Block Sequence Planned @begin @3 @end main main::@1 main::@2 main::@5 main::@return main::@6 line line::@2 line::@8 line::@return line::@9 line::@1 plot plot::@return 
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::@1
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to line:11 
Calls in [line] to plot:19 plot:25 

Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Created 3 initial phi equivalence classes
Coalesced [14] main::i#3 ← main::i#1
Coalesced [18] plot::x#3 ← plot::x#1
Coalesced [23] line::x#4 ← line::x#1
Coalesced down to 3 phi equivalence classes
Culled Empty Block (label) main::@6
Culled Empty Block (label) line::@9
Block Sequence Planned @begin @3 @end main main::@1 main::@2 main::@5 main::@return line line::@2 line::@8 line::@return line::@1 plot plot::@return 
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::@1
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi() [ ] ( )
  to:@3
@3: scope:[]  from @begin
  [1] phi() [ ] ( )
  [2] call main param-assignment [ ] ( )
  to:@end
@end: scope:[]  from @3
  [3] phi() [ ] ( )
main: scope:[main]  from @3
  [4] phi() [ ] ( main:2 [ ] )
  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 ) [ main::i#2 ] ( main:2 [ main::i#2 ] )
  [6] *((const byte*) plots#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] ( main:2 [ main::i#2 ] )
  [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 ] )
  [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] )
  [9] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 40) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] )
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@5
  [10] phi() [ ] ( main:2 [ ] )
  [11] call line param-assignment [ ] ( main:2 [ ] )
  to:main::@5
main::@5: scope:[main]  from main::@2
  [12] if(true) goto main::@2 [ ] ( main:2 [ ] )
  to:main::@return
main::@return: scope:[main]  from main::@5
  [13] return  [ ] ( main:2 [ ] )
  to:@return
line: scope:[line]  from main::@2
  [14] if((const byte) line::x0#0>=(const byte) line::x1#0) goto line::@1 [ ] ( main:2::line:11 [ ] )
  to:line::@2
line::@2: scope:[line]  from line line::@8
  [15] (byte) line::x#2 ← phi( line/(const byte) line::x0#0 line::@8/(byte) line::x#1 ) [ line::x#2 ] ( main:2::line:11 [ line::x#2 ] )
  [16] (byte) plot::x#1 ← (byte) line::x#2 [ line::x#2 plot::x#1 ] ( main:2::line:11 [ line::x#2 plot::x#1 ] )
  [17] call plot param-assignment [ line::x#2 ] ( main:2::line:11 [ line::x#2 ] )
  to:line::@8
line::@8: scope:[line]  from line::@2
  [18] (byte) line::x#1 ← ++ (byte) line::x#2 [ line::x#1 ] ( main:2::line:11 [ line::x#1 ] )
  [19] if((byte) line::x#1<=(const byte) line::x1#0) goto line::@2 [ line::x#1 ] ( main:2::line:11 [ line::x#1 ] )
  to:line::@return
line::@return: scope:[line]  from line::@1 line::@8
  [20] return  [ ] ( main:2::line:11 [ ] )
  to:@return
line::@1: scope:[line]  from line
  [21] phi() [ ] ( main:2::line:11 [ ] )
  [22] call plot param-assignment [ ] ( main:2::line:11 [ ] )
  to:line::@return
plot: scope:[plot]  from line::@1 line::@2
  [23] (byte) plot::x#2 ← phi( line::@1/(const byte) line::x0#0 line::@2/(byte) plot::x#1 ) [ plot::x#2 ] ( main:2::line:11::plot:17 [ line::x#2 plot::x#2 ] main:2::line:11::plot:22 [ plot::x#2 ] )
  [24] (byte) plot::idx#0 ← *((const byte*) plots#0 + (byte) plot::x#2) [ plot::idx#0 ] ( main:2::line:11::plot:17 [ line::x#2 plot::idx#0 ] main:2::line:11::plot:22 [ plot::idx#0 ] )
  [25] (byte/word~) 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:17 [ line::x#2 plot::idx#0 plot::$0 ] main:2::line:11::plot:22 [ plot::idx#0 plot::$0 ] )
  [26] *((const byte*) SCREEN#0 + (byte) plot::idx#0) ← (byte/word~) plot::$0 [ ] ( main:2::line:11::plot:17 [ line::x#2 ] main:2::line:11::plot:22 [ ] )
  to:plot::@return
plot::@return: scope:[plot]  from plot
  [27] return  [ ] ( main:2::line:11::plot:17 [ line::x#2 ] main:2::line:11::plot:22 [ ] )
  to:@return

DOMINATORS
@begin dominated by  @begin 
@3 dominated by  @begin @3 
@end dominated by  @begin @end @3 
main dominated by  @begin main @3 
main::@1 dominated by  @begin main @3 main::@1 
main::@2 dominated by  @begin main @3 main::@1 main::@2 
main::@5 dominated by  @begin main @3 main::@1 main::@2 main::@5 
main::@return dominated by  main::@return @begin main @3 main::@1 main::@2 main::@5 
line dominated by  @begin line main @3 main::@1 main::@2 
line::@2 dominated by  @begin line main line::@2 @3 main::@1 main::@2 
line::@8 dominated by  line::@8 @begin line main line::@2 @3 main::@1 main::@2 
line::@return dominated by  @begin line main @3 main::@1 line::@return main::@2 
line::@1 dominated by  @begin line line::@1 main @3 main::@1 main::@2 
plot dominated by  @begin line main @3 plot main::@1 main::@2 
plot::@return dominated by  @begin line main @3 plot main::@1 plot::@return main::@2 

NATURAL LOOPS
Found back edge: Loop head: main::@1 tails: main::@1 blocks: null
Found back edge: Loop head: main::@2 tails: main::@5 blocks: null
Found back edge: Loop head: line::@2 tails: line::@8 blocks: null
Populated: Loop head: main::@1 tails: main::@1 blocks: main::@1 
Populated: Loop head: main::@2 tails: main::@5 blocks: main::@5 main::@2 
Populated: Loop head: line::@2 tails: line::@8 blocks: line::@8 line::@2 
Loop head: main::@1 tails: main::@1 blocks: main::@1 
Loop head: main::@2 tails: main::@5 blocks: main::@5 main::@2 
Loop head: line::@2 tails: line::@8 blocks: line::@8 line::@2 

NATURAL LOOPS WITH DEPTH
Found 0 loops in scope []
Found 2 loops in scope [main]
  Loop head: main::@1 tails: main::@1 blocks: main::@1 
  Loop head: main::@2 tails: main::@5 blocks: main::@5 main::@2 
Found 1 loops in scope [line]
  Loop head: line::@2 tails: line::@8 blocks: line::@8 line::@2 
Found 0 loops in scope [plot]
Loop head: main::@1 tails: main::@1 blocks: main::@1  depth: 1
Loop head: main::@2 tails: main::@5 blocks: main::@5 main::@2  depth: 1
Loop head: line::@2 tails: line::@8 blocks: line::@8 line::@2  depth: 2


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/word~) plot::$0 4.0
(byte) plot::idx
(byte) plot::idx#0 3.0
(byte) plot::x
(byte) plot::x#1 202.0
(byte) plot::x#2 103.0
(byte*) plots

Initial phi equivalence classes
[ main::i#2 main::i#1 ]
[ line::x#2 line::x#1 ]
[ plot::x#2 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#2 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#2 plot::x#1 ]
Allocated zp ZP_BYTE:5 [ plot::idx#0 ]
Allocated zp ZP_BYTE:6 [ plot::$0 ]

INITIAL ASM
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .label plots = $1000
  .label SCREEN = $400
//SEG2 @begin
bbegin:
//SEG3 [1] phi from @begin to @3 [phi:@begin->@3]
b3_from_bbegin:
  jmp b3
//SEG4 @3
b3:
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @3 to main [phi:@3->main]
main_from_b3:
  jsr main
//SEG7 [3] phi from @3 to @end [phi:@3->@end]
bend_from_b3:
  jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
    .label i = 2
  //SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
  //SEG11 [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
  //SEG12 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
  //SEG13 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
  //SEG14 main::@1
  b1:
  //SEG15 [6] *((const byte*) plots#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- pbuc1_derefidx_vbuz1=vbuz1 
    ldy i
    tya
    sta plots,y
  //SEG16 [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 ] ) -- pbuc1_derefidx_vbuz1=vbuc2 
    ldy i
    lda #0
    sta SCREEN,y
  //SEG17 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuz1=_inc_vbuz1 
    inc i
  //SEG18 [9] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 40) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuz1_neq_vbuc1_then_la1 
    lda i
    cmp #$28
    bne b1_from_b1
  //SEG19 [10] phi from main::@1 main::@5 to main::@2 [phi:main::@1/main::@5->main::@2]
  b2_from_b1:
  b2_from_b5:
    jmp b2
  //SEG20 main::@2
  b2:
  //SEG21 [11] call line param-assignment [ ] ( main:2 [ ] )
    jsr line
    jmp b5
  //SEG22 main::@5
  b5:
  //SEG23 [12] if(true) goto main::@2 [ ] ( main:2 [ ] ) -- true_then_la1 
    jmp b2_from_b5
    jmp breturn
  //SEG24 main::@return
  breturn:
  //SEG25 [13] return  [ ] ( main:2 [ ] )
    rts
}
//SEG26 line
line: {
    .const x0 = 0
    .const x1 = $a
    .label x = 3
  //SEG27 [14] if((const byte) line::x0#0>=(const byte) line::x1#0) goto line::@1 [ ] ( main:2::line:11 [ ] ) -- vbuc1_ge_vbuc2_then_la1 
    lda #x0
    cmp #x1
    bcs b1_from_line
  //SEG28 [15] phi from line to line::@2 [phi:line->line::@2]
  b2_from_line:
  //SEG29 [15] phi (byte) line::x#2 = (const byte) line::x0#0 [phi:line->line::@2#0] -- vbuz1=vbuc1 
    lda #x0
    sta x
    jmp b2
  //SEG30 [15] phi from line::@8 to line::@2 [phi:line::@8->line::@2]
  b2_from_b8:
  //SEG31 [15] phi (byte) line::x#2 = (byte) line::x#1 [phi:line::@8->line::@2#0] -- register_copy 
    jmp b2
  //SEG32 line::@2
  b2:
  //SEG33 [16] (byte) plot::x#1 ← (byte) line::x#2 [ line::x#2 plot::x#1 ] ( main:2::line:11 [ line::x#2 plot::x#1 ] ) -- vbuz1=vbuz2 
    lda x
    sta plot.x
  //SEG34 [17] call plot param-assignment [ line::x#2 ] ( main:2::line:11 [ line::x#2 ] )
  //SEG35 [23] phi from line::@2 to plot [phi:line::@2->plot]
  plot_from_b2:
  //SEG36 [23] phi (byte) plot::x#2 = (byte) plot::x#1 [phi:line::@2->plot#0] -- register_copy 
    jsr plot
    jmp b8
  //SEG37 line::@8
  b8:
  //SEG38 [18] (byte) line::x#1 ← ++ (byte) line::x#2 [ line::x#1 ] ( main:2::line:11 [ line::x#1 ] ) -- vbuz1=_inc_vbuz1 
    inc x
  //SEG39 [19] if((byte) line::x#1<=(const byte) line::x1#0) goto line::@2 [ line::x#1 ] ( main:2::line:11 [ line::x#1 ] ) -- vbuz1_le_vbuc1_then_la1 
    lda #x1
    cmp x
    bcs b2_from_b8
    jmp breturn
  //SEG40 line::@return
  breturn:
  //SEG41 [20] return  [ ] ( main:2::line:11 [ ] )
    rts
  //SEG42 [21] phi from line to line::@1 [phi:line->line::@1]
  b1_from_line:
    jmp b1
  //SEG43 line::@1
  b1:
  //SEG44 [22] call plot param-assignment [ ] ( main:2::line:11 [ ] )
  //SEG45 [23] phi from line::@1 to plot [phi:line::@1->plot]
  plot_from_b1:
  //SEG46 [23] phi (byte) plot::x#2 = (const byte) line::x0#0 [phi:line::@1->plot#0] -- vbuz1=vbuc1 
    lda #x0
    sta plot.x
    jsr plot
    jmp breturn
}
//SEG47 plot
plot: {
    .label _0 = 6
    .label x = 4
    .label idx = 5
  //SEG48 [24] (byte) plot::idx#0 ← *((const byte*) plots#0 + (byte) plot::x#2) [ plot::idx#0 ] ( main:2::line:11::plot:17 [ line::x#2 plot::idx#0 ] main:2::line:11::plot:22 [ plot::idx#0 ] ) -- vbuz1=pbuc1_derefidx_vbuz2 
    ldy x
    lda plots,y
    sta idx
  //SEG49 [25] (byte/word~) 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:17 [ line::x#2 plot::idx#0 plot::$0 ] main:2::line:11::plot:22 [ plot::idx#0 plot::$0 ] ) -- vbuz1=pbuc1_derefidx_vbuz2_plus_1 
    ldy idx
    lda SCREEN,y
    clc
    adc #1
    sta _0
  //SEG50 [26] *((const byte*) SCREEN#0 + (byte) plot::idx#0) ← (byte/word~) plot::$0 [ ] ( main:2::line:11::plot:17 [ line::x#2 ] main:2::line:11::plot:22 [ ] ) -- pbuc1_derefidx_vbuz1=vbuz2 
    lda _0
    ldy idx
    sta SCREEN,y
    jmp breturn
  //SEG51 plot::@return
  breturn:
  //SEG52 [27] return  [ ] ( main:2::line:11::plot:17 [ line::x#2 ] main:2::line:11::plot:22 [ ] )
    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 [14] if((const byte) line::x0#0>=(const byte) line::x1#0) goto line::@1 [ ] ( main:2::line:11 [ ] ) always clobbers reg byte a 
Statement [25] (byte/word~) 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:17 [ line::x#2 plot::idx#0 plot::$0 ] main:2::line:11::plot:22 [ 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 [14] if((const byte) line::x0#0>=(const byte) line::x1#0) goto line::@1 [ ] ( main:2::line:11 [ ] ) always clobbers reg byte a 
Statement [25] (byte/word~) 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:17 [ line::x#2 plot::idx#0 plot::$0 ] main:2::line:11::plot:22 [ 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#2 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 [plot] 305: zp ZP_BYTE:4 [ plot::x#2 plot::x#1 ] 4: zp ZP_BYTE:6 [ plot::$0 ] 3: zp ZP_BYTE:5 [ plot::idx#0 ] 
Uplift Scope [line] 252.5: zp ZP_BYTE:3 [ line::x#2 line::x#1 ] 
Uplift Scope [main] 34.83: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 
Uplift Scope [] 

Uplifting [plot] best 3644 combination reg byte x [ plot::x#2 plot::x#1 ] reg byte a [ plot::$0 ] reg byte y [ plot::idx#0 ] 
Uplifting [line] best 3644 combination zp ZP_BYTE:3 [ line::x#2 line::x#1 ] 
Uplifting [main] best 3494 combination reg byte x [ main::i#2 main::i#1 ] 
Uplifting [] best 3494 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:3 [ line::x#2 line::x#1 ]
Uplifting [line] best 3494 combination zp ZP_BYTE:3 [ line::x#2 line::x#1 ] 
Allocated (was zp ZP_BYTE:3) zp ZP_BYTE:2 [ line::x#2 line::x#1 ]

ASSEMBLER BEFORE OPTIMIZATION
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .label plots = $1000
  .label SCREEN = $400
//SEG2 @begin
bbegin:
//SEG3 [1] phi from @begin to @3 [phi:@begin->@3]
b3_from_bbegin:
  jmp b3
//SEG4 @3
b3:
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @3 to main [phi:@3->main]
main_from_b3:
  jsr main
//SEG7 [3] phi from @3 to @end [phi:@3->@end]
bend_from_b3:
  jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
  //SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
  //SEG11 [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
  //SEG12 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
  //SEG13 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
  //SEG14 main::@1
  b1:
  //SEG15 [6] *((const byte*) plots#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- pbuc1_derefidx_vbuxx=vbuxx 
    txa
    sta plots,x
  //SEG16 [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 ] ) -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #0
    sta SCREEN,x
  //SEG17 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuxx=_inc_vbuxx 
    inx
  //SEG18 [9] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 40) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuxx_neq_vbuc1_then_la1 
    cpx #$28
    bne b1_from_b1
  //SEG19 [10] phi from main::@1 main::@5 to main::@2 [phi:main::@1/main::@5->main::@2]
  b2_from_b1:
  b2_from_b5:
    jmp b2
  //SEG20 main::@2
  b2:
  //SEG21 [11] call line param-assignment [ ] ( main:2 [ ] )
    jsr line
    jmp b5
  //SEG22 main::@5
  b5:
  //SEG23 [12] if(true) goto main::@2 [ ] ( main:2 [ ] ) -- true_then_la1 
    jmp b2_from_b5
    jmp breturn
  //SEG24 main::@return
  breturn:
  //SEG25 [13] return  [ ] ( main:2 [ ] )
    rts
}
//SEG26 line
line: {
    .const x0 = 0
    .const x1 = $a
    .label x = 2
  //SEG27 [14] if((const byte) line::x0#0>=(const byte) line::x1#0) goto line::@1 [ ] ( main:2::line:11 [ ] ) -- vbuc1_ge_vbuc2_then_la1 
    lda #x0
    cmp #x1
    bcs b1_from_line
  //SEG28 [15] phi from line to line::@2 [phi:line->line::@2]
  b2_from_line:
  //SEG29 [15] phi (byte) line::x#2 = (const byte) line::x0#0 [phi:line->line::@2#0] -- vbuz1=vbuc1 
    lda #x0
    sta x
    jmp b2
  //SEG30 [15] phi from line::@8 to line::@2 [phi:line::@8->line::@2]
  b2_from_b8:
  //SEG31 [15] phi (byte) line::x#2 = (byte) line::x#1 [phi:line::@8->line::@2#0] -- register_copy 
    jmp b2
  //SEG32 line::@2
  b2:
  //SEG33 [16] (byte) plot::x#1 ← (byte) line::x#2 [ line::x#2 plot::x#1 ] ( main:2::line:11 [ line::x#2 plot::x#1 ] ) -- vbuxx=vbuz1 
    ldx x
  //SEG34 [17] call plot param-assignment [ line::x#2 ] ( main:2::line:11 [ line::x#2 ] )
  //SEG35 [23] phi from line::@2 to plot [phi:line::@2->plot]
  plot_from_b2:
  //SEG36 [23] phi (byte) plot::x#2 = (byte) plot::x#1 [phi:line::@2->plot#0] -- register_copy 
    jsr plot
    jmp b8
  //SEG37 line::@8
  b8:
  //SEG38 [18] (byte) line::x#1 ← ++ (byte) line::x#2 [ line::x#1 ] ( main:2::line:11 [ line::x#1 ] ) -- vbuz1=_inc_vbuz1 
    inc x
  //SEG39 [19] if((byte) line::x#1<=(const byte) line::x1#0) goto line::@2 [ line::x#1 ] ( main:2::line:11 [ line::x#1 ] ) -- vbuz1_le_vbuc1_then_la1 
    lda #x1
    cmp x
    bcs b2_from_b8
    jmp breturn
  //SEG40 line::@return
  breturn:
  //SEG41 [20] return  [ ] ( main:2::line:11 [ ] )
    rts
  //SEG42 [21] phi from line to line::@1 [phi:line->line::@1]
  b1_from_line:
    jmp b1
  //SEG43 line::@1
  b1:
  //SEG44 [22] call plot param-assignment [ ] ( main:2::line:11 [ ] )
  //SEG45 [23] phi from line::@1 to plot [phi:line::@1->plot]
  plot_from_b1:
  //SEG46 [23] phi (byte) plot::x#2 = (const byte) line::x0#0 [phi:line::@1->plot#0] -- vbuxx=vbuc1 
    ldx #x0
    jsr plot
    jmp breturn
}
//SEG47 plot
plot: {
  //SEG48 [24] (byte) plot::idx#0 ← *((const byte*) plots#0 + (byte) plot::x#2) [ plot::idx#0 ] ( main:2::line:11::plot:17 [ line::x#2 plot::idx#0 ] main:2::line:11::plot:22 [ plot::idx#0 ] ) -- vbuyy=pbuc1_derefidx_vbuxx 
    ldy plots,x
  //SEG49 [25] (byte/word~) 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:17 [ line::x#2 plot::idx#0 plot::$0 ] main:2::line:11::plot:22 [ plot::idx#0 plot::$0 ] ) -- vbuaa=pbuc1_derefidx_vbuyy_plus_1 
    lda SCREEN,y
    clc
    adc #1
  //SEG50 [26] *((const byte*) SCREEN#0 + (byte) plot::idx#0) ← (byte/word~) plot::$0 [ ] ( main:2::line:11::plot:17 [ line::x#2 ] main:2::line:11::plot:22 [ ] ) -- pbuc1_derefidx_vbuyy=vbuaa 
    sta SCREEN,y
    jmp breturn
  //SEG51 plot::@return
  breturn:
  //SEG52 [27] return  [ ] ( main:2::line:11::plot:17 [ line::x#2 ] main:2::line:11::plot:22 [ ] )
    rts
}

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b3
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp b5
Removing instruction jmp breturn
Removing instruction jmp b2
Removing instruction jmp b8
Removing instruction jmp breturn
Removing instruction jmp b1
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b1_from_b1 with b1
Replacing label b2_from_b5 with b2
Replacing label b1_from_line with b1
Replacing label b2_from_b8 with b2
Removing instruction bbegin:
Removing instruction b3_from_bbegin:
Removing instruction main_from_b3:
Removing instruction bend_from_b3:
Removing instruction b1_from_b1:
Removing instruction b2_from_b1:
Removing instruction b2_from_b5:
Removing instruction b2_from_b8:
Removing instruction b1_from_line:
Removing instruction plot_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction b3:
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction b5:
Removing instruction breturn:
Removing instruction b2_from_line:
Removing instruction plot_from_b2:
Removing instruction b8:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing unreachable instruction rts
Succesful ASM optimization Pass5UnreachableCodeElimination
Removing instruction jmp b1
Removing instruction jmp b2
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda #x0
Succesful ASM optimization Pass5UnnecesaryLoadElimination

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::@1
(label) line::@2
(label) line::@8
(label) line::@return
(byte) line::x
(byte) line::x#1 x zp ZP_BYTE:2 151.5
(byte) line::x#2 x zp ZP_BYTE:2 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
(label) main::@5
(label) main::@return
(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/word~) 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 202.0
(byte) plot::x#2 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 ]
zp ZP_BYTE:2 [ line::x#2 line::x#1 ]
reg byte x [ plot::x#2 plot::x#1 ]
reg byte y [ plot::idx#0 ]
reg byte a [ plot::$0 ]


FINAL ASSEMBLER
Score: 2223

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

