PARSING src/test/java/dk/camelot64/kickc/test/kc/callconstparam.kc
// Multiple calls with different (constant?) parameters should yield different values at runtime
// Currently the same constant parameter is passed on every call.
// Reason: Multiple versioned parameter constants x0#0, x0#1 are only output as a single constant in the ASM .const x0 = 0

byte* screen = $0400;

void main() {
    line(1,2);
    line(3,5);
}

void line(byte x0, byte x1) {
  for(byte x  = x0; x<x1; x++) {
     *screen = x;
     screen++;
  }

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

STATEMENTS
  (byte*) screen ← (word/signed word/dword/signed dword) 1024
proc (void()) main()
  (void~) main::$0 ← call line (byte/signed byte/word/signed word/dword/signed dword) 1 (byte/signed byte/word/signed word/dword/signed dword) 2 
  (void~) main::$1 ← call line (byte/signed byte/word/signed word/dword/signed dword) 3 (byte/signed byte/word/signed word/dword/signed dword) 5 
main::@return:
  return 
endproc // main()
proc (void()) line((byte) line::x0 , (byte) line::x1)
  (byte) line::x ← (byte) line::x0
line::@1:
  *((byte*) screen) ← (byte) line::x
  (byte*) screen ← ++ (byte*) screen
  (byte) line::x ← ++ (byte) line::x
  (boolean~) line::$0 ← (byte) line::x < (byte) line::x1
  if((boolean~) line::$0) goto line::@1
line::@return:
  return 
endproc // line()
  call main 

SYMBOLS
(void()) line((byte) line::x0 , (byte) line::x1)
(boolean~) line::$0
(label) line::@1
(label) line::@return
(byte) line::x
(byte) line::x0
(byte) line::x1
(void()) main()
(void~) main::$0
(void~) main::$1
(label) main::@return
(byte*) screen

Promoting word/signed word/dword/signed dword to byte* in screen ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  (byte*) screen ← ((byte*)) (word/signed word/dword/signed dword) 1024
  to:@1
main: scope:[main]  from
  (void~) main::$0 ← call line (byte/signed byte/word/signed word/dword/signed dword) 1 (byte/signed byte/word/signed word/dword/signed dword) 2 
  (void~) main::$1 ← call line (byte/signed byte/word/signed word/dword/signed dword) 3 (byte/signed byte/word/signed word/dword/signed dword) 5 
  to:main::@return
main::@return: scope:[main]  from main
  return 
  to:@return
@1: scope:[]  from @begin
  to:@2
line: scope:[line]  from
  (byte) line::x ← (byte) line::x0
  to:line::@1
line::@1: scope:[line]  from line line::@1
  *((byte*) screen) ← (byte) line::x
  (byte*) screen ← ++ (byte*) screen
  (byte) line::x ← ++ (byte) line::x
  (boolean~) line::$0 ← (byte) line::x < (byte) line::x1
  if((boolean~) line::$0) goto line::@1
  to:line::@2
line::@2: scope:[line]  from line::@1
  to:line::@return
line::@return: scope:[line]  from line::@2
  return 
  to:@return
@2: scope:[]  from @1
  call main 
  to:@end
@end: scope:[]  from @2

Eliminating unused variable - keeping the call (void~) main::$0
Eliminating unused variable - keeping the call (void~) main::$1
Removing empty block @1
Removing empty block line::@2
PROCEDURE MODIFY VARIABLE ANALYSIS
main modifies screen
line modifies screen

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

CONTROL FLOW GRAPH SSA WITH ASSIGNMENT CALL & RETURN
@begin: scope:[]  from
  (byte*) screen#0 ← ((byte*)) (word/signed word/dword/signed dword) 1024
  to:@2
main: scope:[main]  from @2
  (byte*) screen#13 ← phi( @2/(byte*) screen#15 )
  (byte) line::x0#0 ← (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte) line::x1#0 ← (byte/signed byte/word/signed word/dword/signed dword) 2
  call line param-assignment
  to:main::@1
main::@1: scope:[main]  from main
  (byte*) screen#7 ← phi( main/(byte*) screen#5 )
  (byte*) screen#1 ← (byte*) screen#7
  (byte) line::x0#1 ← (byte/signed byte/word/signed word/dword/signed dword) 3
  (byte) line::x1#1 ← (byte/signed byte/word/signed word/dword/signed dword) 5
  call line param-assignment
  to:main::@2
main::@2: scope:[main]  from main::@1
  (byte*) screen#8 ← phi( main::@1/(byte*) screen#5 )
  (byte*) screen#2 ← (byte*) screen#8
  to:main::@return
main::@return: scope:[main]  from main::@2
  (byte*) screen#9 ← phi( main::@2/(byte*) screen#2 )
  (byte*) screen#3 ← (byte*) screen#9
  return 
  to:@return
line: scope:[line]  from main main::@1
  (byte) line::x1#3 ← phi( main/(byte) line::x1#0 main::@1/(byte) line::x1#1 )
  (byte*) screen#14 ← phi( main/(byte*) screen#13 main::@1/(byte*) screen#1 )
  (byte) line::x0#2 ← phi( main/(byte) line::x0#0 main::@1/(byte) line::x0#1 )
  (byte) line::x#0 ← (byte) line::x0#2
  to:line::@1
line::@1: scope:[line]  from line line::@1
  (byte) line::x1#2 ← phi( line/(byte) line::x1#3 line::@1/(byte) line::x1#2 )
  (byte*) screen#10 ← phi( line/(byte*) screen#14 line::@1/(byte*) screen#4 )
  (byte) line::x#2 ← phi( line/(byte) line::x#0 line::@1/(byte) line::x#1 )
  *((byte*) screen#10) ← (byte) line::x#2
  (byte*) screen#4 ← ++ (byte*) screen#10
  (byte) line::x#1 ← ++ (byte) line::x#2
  (boolean~) line::$0 ← (byte) line::x#1 < (byte) line::x1#2
  if((boolean~) line::$0) goto line::@1
  to:line::@return
line::@return: scope:[line]  from line::@1
  (byte*) screen#11 ← phi( line::@1/(byte*) screen#4 )
  (byte*) screen#5 ← (byte*) screen#11
  return 
  to:@return
@2: scope:[]  from @begin
  (byte*) screen#15 ← phi( @begin/(byte*) screen#0 )
  call main param-assignment
  to:@3
@3: scope:[]  from @2
  (byte*) screen#12 ← phi( @2/(byte*) screen#3 )
  (byte*) screen#6 ← (byte*) screen#12
  to:@end
@end: scope:[]  from @3

SYMBOL TABLE SSA
(label) @2
(label) @3
(label) @begin
(label) @end
(void()) line((byte) line::x0 , (byte) line::x1)
(boolean~) line::$0
(label) line::@1
(label) line::@return
(byte) line::x
(byte) line::x#0
(byte) line::x#1
(byte) line::x#2
(byte) line::x0
(byte) line::x0#0
(byte) line::x0#1
(byte) line::x0#2
(byte) line::x1
(byte) line::x1#0
(byte) line::x1#1
(byte) line::x1#2
(byte) line::x1#3
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(byte*) screen
(byte*) screen#0
(byte*) screen#1
(byte*) screen#10
(byte*) screen#11
(byte*) screen#12
(byte*) screen#13
(byte*) screen#14
(byte*) screen#15
(byte*) screen#2
(byte*) screen#3
(byte*) screen#4
(byte*) screen#5
(byte*) screen#6
(byte*) screen#7
(byte*) screen#8
(byte*) screen#9

OPTIMIZING CONTROL FLOW GRAPH
Not aliassing across scopes: screen#13 screen#15
Not aliassing across scopes: screen#7 screen#5
Not aliassing across scopes: screen#8 screen#5
Not aliassing across scopes: line::x0#2 line::x0#0
Not aliassing across scopes: screen#14 screen#13
Not aliassing across scopes: line::x1#3 line::x1#0
Not aliassing across scopes: screen#12 screen#3
Alias (byte*) screen#1 = (byte*) screen#7 
Alias (byte*) screen#2 = (byte*) screen#8 (byte*) screen#9 (byte*) screen#3 
Alias (byte) line::x#0 = (byte) line::x0#2 
Alias (byte*) screen#11 = (byte*) screen#4 (byte*) screen#5 
Alias (byte*) screen#0 = (byte*) screen#15 
Alias (byte*) screen#12 = (byte*) screen#6 
Succesful SSA optimization Pass2AliasElimination
Not aliassing across scopes: screen#13 screen#0
Not aliassing across scopes: screen#1 screen#11
Not aliassing across scopes: screen#2 screen#11
Not aliassing across scopes: line::x#0 line::x0#0
Not aliassing across scopes: screen#14 screen#13
Not aliassing across scopes: line::x1#3 line::x1#0
Not aliassing across scopes: screen#12 screen#2
Self Phi Eliminated (byte) line::x1#2
Succesful SSA optimization Pass2SelfPhiElimination
Redundant Phi (byte*) screen#13 (byte*) screen#0
Redundant Phi (byte*) screen#1 (byte*) screen#11
Redundant Phi (byte*) screen#2 (byte*) screen#11
Redundant Phi (byte) line::x1#2 (byte) line::x1#3
Redundant Phi (byte*) screen#12 (byte*) screen#2
Succesful SSA optimization Pass2RedundantPhiElimination
Simple Condition (boolean~) line::$0 if((byte) line::x#1<(byte) line::x1#3) goto line::@1
Succesful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) screen#0 = ((byte*))1024
Constant (const byte) line::x0#0 = 1
Constant (const byte) line::x1#0 = 2
Constant (const byte) line::x0#1 = 3
Constant (const byte) line::x1#1 = 5
Succesful SSA optimization Pass2ConstantIdentification
Culled Empty Block (label) main::@2
Culled Empty Block (label) @3
Succesful SSA optimization Pass2CullEmptyBlocks
OPTIMIZING CONTROL FLOW GRAPH
Inlining constant with different constant siblings (const byte) line::x0#0
Inlining constant with var siblings (const byte) line::x1#0
Inlining constant with different constant siblings (const byte) line::x1#0
Inlining constant with different constant siblings (const byte) line::x0#1
Inlining constant with var siblings (const byte) line::x1#1
Inlining constant with different constant siblings (const byte) line::x1#1
Inlining constant with var siblings (const byte*) screen#0
Inlining constant with var siblings (const byte*) screen#0
Inlining constant with var siblings (const byte*) screen#0
Constant inlined line::x0#0 = (byte/signed byte/word/signed word/dword/signed dword) 1
Constant inlined line::x1#1 = (byte/signed byte/word/signed word/dword/signed dword) 5
Constant inlined screen#0 = ((byte*))(word/signed word/dword/signed dword) 1024
Constant inlined line::x1#0 = (byte/signed byte/word/signed word/dword/signed dword) 2
Constant inlined line::x0#1 = (byte/signed byte/word/signed word/dword/signed dword) 3
Succesful SSA optimization Pass2ConstantInlining
Block Sequence Planned @begin @2 @end main main::@1 main::@return line line::@1 line::@return 
Added new block during phi lifting line::@3(between line::@1 and line::@1)
Block Sequence Planned @begin @2 @end main main::@1 main::@return line line::@1 line::@return line::@3 
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to line:5 line:7 

Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Created 5 initial phi equivalence classes
Coalesced [6] screen#16 ← screen#11
Coalesced [10] line::x#3 ← line::x#0
Coalesced [11] screen#17 ← screen#14
Coalesced [18] line::x#4 ← line::x#1
Coalesced (already) [19] screen#18 ← screen#11
Coalesced down to 3 phi equivalence classes
Culled Empty Block (label) line::@3
Block Sequence Planned @begin @2 @end main main::@1 main::@return line line::@1 line::@return 
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@1
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi() [ ] ( )
  to:@2
@2: scope:[]  from @begin
  [1] phi() [ ] ( )
  [2] call main param-assignment [ ] ( )
  to:@end
@end: scope:[]  from @2
  [3] phi() [ ] ( )
main: scope:[main]  from @2
  [4] phi() [ ] ( main:2 [ ] )
  [5] call line param-assignment [ screen#11 ] ( main:2 [ screen#11 ] )
  to:main::@1
main::@1: scope:[main]  from main
  [6] phi() [ screen#11 ] ( main:2 [ screen#11 ] )
  [7] call line param-assignment [ ] ( main:2 [ ] )
  to:main::@return
main::@return: scope:[main]  from main::@1
  [8] return  [ ] ( main:2 [ ] )
  to:@return
line: scope:[line]  from main main::@1
  [9] (byte) line::x1#3 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 2 main::@1/(byte/signed byte/word/signed word/dword/signed dword) 5 ) [ line::x#0 screen#14 line::x1#3 ] ( main:2::line:5 [ line::x#0 screen#14 line::x1#3 ] main:2::line:7 [ line::x#0 screen#14 line::x1#3 ] )
  [9] (byte*) screen#14 ← phi( main/((byte*))(word/signed word/dword/signed dword) 1024 main::@1/(byte*) screen#11 ) [ line::x#0 screen#14 line::x1#3 ] ( main:2::line:5 [ line::x#0 screen#14 line::x1#3 ] main:2::line:7 [ line::x#0 screen#14 line::x1#3 ] )
  [9] (byte) line::x#0 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 1 main::@1/(byte/signed byte/word/signed word/dword/signed dword) 3 ) [ line::x#0 screen#14 line::x1#3 ] ( main:2::line:5 [ line::x#0 screen#14 line::x1#3 ] main:2::line:7 [ line::x#0 screen#14 line::x1#3 ] )
  to:line::@1
line::@1: scope:[line]  from line line::@1
  [10] (byte*) screen#10 ← phi( line/(byte*) screen#14 line::@1/(byte*) screen#11 ) [ line::x1#3 line::x#2 screen#10 ] ( main:2::line:5 [ line::x1#3 line::x#2 screen#10 ] main:2::line:7 [ line::x1#3 line::x#2 screen#10 ] )
  [10] (byte) line::x#2 ← phi( line/(byte) line::x#0 line::@1/(byte) line::x#1 ) [ line::x1#3 line::x#2 screen#10 ] ( main:2::line:5 [ line::x1#3 line::x#2 screen#10 ] main:2::line:7 [ line::x1#3 line::x#2 screen#10 ] )
  [11] *((byte*) screen#10) ← (byte) line::x#2 [ line::x1#3 line::x#2 screen#10 ] ( main:2::line:5 [ line::x1#3 line::x#2 screen#10 ] main:2::line:7 [ line::x1#3 line::x#2 screen#10 ] )
  [12] (byte*) screen#11 ← ++ (byte*) screen#10 [ line::x1#3 screen#11 line::x#2 ] ( main:2::line:5 [ line::x1#3 screen#11 line::x#2 ] main:2::line:7 [ line::x1#3 screen#11 line::x#2 ] )
  [13] (byte) line::x#1 ← ++ (byte) line::x#2 [ line::x1#3 screen#11 line::x#1 ] ( main:2::line:5 [ line::x1#3 screen#11 line::x#1 ] main:2::line:7 [ line::x1#3 screen#11 line::x#1 ] )
  [14] if((byte) line::x#1<(byte) line::x1#3) goto line::@1 [ line::x1#3 screen#11 line::x#1 ] ( main:2::line:5 [ line::x1#3 screen#11 line::x#1 ] main:2::line:7 [ line::x1#3 screen#11 line::x#1 ] )
  to:line::@return
line::@return: scope:[line]  from line::@1
  [15] return  [ screen#11 ] ( main:2::line:5 [ screen#11 ] main:2::line:7 [ screen#11 ] )
  to:@return

DOMINATORS
@begin dominated by  @begin 
@2 dominated by  @2 @begin 
@end dominated by  @2 @begin @end 
main dominated by  @2 @begin main 
main::@1 dominated by  @2 @begin main::@1 main 
main::@return dominated by  main::@return @2 @begin main::@1 main 
line dominated by  @2 @begin line main 
line::@1 dominated by  @2 @begin line line::@1 main 
line::@return dominated by  @2 @begin line line::@return line::@1 main 

NATURAL LOOPS
Found back edge: Loop head: line::@1 tails: line::@1 blocks: null
Populated: Loop head: line::@1 tails: line::@1 blocks: line::@1 
Loop head: line::@1 tails: line::@1 blocks: line::@1 

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


VARIABLE REGISTER WEIGHTS
(void()) line((byte) line::x0 , (byte) line::x1)
(byte) line::x
(byte) line::x#0 2.0
(byte) line::x#1 16.5
(byte) line::x#2 11.666666666666666
(byte) line::x0
(byte) line::x1
(byte) line::x1#3 1.8333333333333333
(void()) main()
(byte*) screen
(byte*) screen#10 17.5
(byte*) screen#11 4.0
(byte*) screen#14 4.0

Initial phi equivalence classes
[ line::x1#3 ]
[ line::x#2 line::x#0 line::x#1 ]
[ screen#10 screen#14 screen#11 ]
Complete equivalence classes
[ line::x1#3 ]
[ line::x#2 line::x#0 line::x#1 ]
[ screen#10 screen#14 screen#11 ]
Allocated zp ZP_BYTE:2 [ line::x1#3 ]
Allocated zp ZP_BYTE:3 [ line::x#2 line::x#0 line::x#1 ]
Allocated zp ZP_WORD:4 [ screen#10 screen#14 screen#11 ]

INITIAL ASM
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .label screen = 4
//SEG2 @begin
bbegin:
//SEG3 [1] phi from @begin to @2 [phi:@begin->@2]
b2_from_bbegin:
  jmp b2
//SEG4 @2
b2:
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @2 to main [phi:@2->main]
main_from_b2:
  jsr main
//SEG7 [3] phi from @2 to @end [phi:@2->@end]
bend_from_b2:
  jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
  //SEG10 [5] call line param-assignment [ screen#11 ] ( main:2 [ screen#11 ] )
  //SEG11 [9] phi from main to line [phi:main->line]
  line_from_main:
  //SEG12 [9] phi (byte) line::x1#3 = (byte/signed byte/word/signed word/dword/signed dword) 2 [phi:main->line#0] -- vbuz1=vbuc1 
    lda #2
    sta line.x1
  //SEG13 [9] phi (byte*) screen#14 = ((byte*))(word/signed word/dword/signed dword) 1024 [phi:main->line#1] -- pbuz1=pbuc1 
    lda #<$400
    sta screen
    lda #>$400
    sta screen+1
  //SEG14 [9] phi (byte) line::x#0 = (byte/signed byte/word/signed word/dword/signed dword) 1 [phi:main->line#2] -- vbuz1=vbuc1 
    lda #1
    sta line.x
    jsr line
  //SEG15 [6] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    jmp b1
  //SEG16 main::@1
  b1:
  //SEG17 [7] call line param-assignment [ ] ( main:2 [ ] )
  //SEG18 [9] phi from main::@1 to line [phi:main::@1->line]
  line_from_b1:
  //SEG19 [9] phi (byte) line::x1#3 = (byte/signed byte/word/signed word/dword/signed dword) 5 [phi:main::@1->line#0] -- vbuz1=vbuc1 
    lda #5
    sta line.x1
  //SEG20 [9] phi (byte*) screen#14 = (byte*) screen#11 [phi:main::@1->line#1] -- register_copy 
  //SEG21 [9] phi (byte) line::x#0 = (byte/signed byte/word/signed word/dword/signed dword) 3 [phi:main::@1->line#2] -- vbuz1=vbuc1 
    lda #3
    sta line.x
    jsr line
    jmp breturn
  //SEG22 main::@return
  breturn:
  //SEG23 [8] return  [ ] ( main:2 [ ] )
    rts
}
//SEG24 line
line: {
    .label x = 3
    .label x1 = 2
  //SEG25 [10] phi from line line::@1 to line::@1 [phi:line/line::@1->line::@1]
  b1_from_line:
  b1_from_b1:
  //SEG26 [10] phi (byte*) screen#10 = (byte*) screen#14 [phi:line/line::@1->line::@1#0] -- register_copy 
  //SEG27 [10] phi (byte) line::x#2 = (byte) line::x#0 [phi:line/line::@1->line::@1#1] -- register_copy 
    jmp b1
  //SEG28 line::@1
  b1:
  //SEG29 [11] *((byte*) screen#10) ← (byte) line::x#2 [ line::x1#3 line::x#2 screen#10 ] ( main:2::line:5 [ line::x1#3 line::x#2 screen#10 ] main:2::line:7 [ line::x1#3 line::x#2 screen#10 ] ) -- _deref_pbuz1=vbuz2 
    lda x
    ldy #0
    sta (screen),y
  //SEG30 [12] (byte*) screen#11 ← ++ (byte*) screen#10 [ line::x1#3 screen#11 line::x#2 ] ( main:2::line:5 [ line::x1#3 screen#11 line::x#2 ] main:2::line:7 [ line::x1#3 screen#11 line::x#2 ] ) -- pbuz1=_inc_pbuz1 
    inc screen
    bne !+
    inc screen+1
  !:
  //SEG31 [13] (byte) line::x#1 ← ++ (byte) line::x#2 [ line::x1#3 screen#11 line::x#1 ] ( main:2::line:5 [ line::x1#3 screen#11 line::x#1 ] main:2::line:7 [ line::x1#3 screen#11 line::x#1 ] ) -- vbuz1=_inc_vbuz1 
    inc x
  //SEG32 [14] if((byte) line::x#1<(byte) line::x1#3) goto line::@1 [ line::x1#3 screen#11 line::x#1 ] ( main:2::line:5 [ line::x1#3 screen#11 line::x#1 ] main:2::line:7 [ line::x1#3 screen#11 line::x#1 ] ) -- vbuz1_lt_vbuz2_then_la1 
    lda x
    cmp x1
    bcc b1_from_b1
    jmp breturn
  //SEG33 line::@return
  breturn:
  //SEG34 [15] return  [ screen#11 ] ( main:2::line:5 [ screen#11 ] main:2::line:7 [ screen#11 ] )
    rts
}

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [11] *((byte*) screen#10) ← (byte) line::x#2 [ line::x1#3 line::x#2 screen#10 ] ( main:2::line:5 [ line::x1#3 line::x#2 screen#10 ] main:2::line:7 [ line::x1#3 line::x#2 screen#10 ] ) always clobbers reg byte y 
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:2 [ line::x1#3 ]
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:3 [ line::x#2 line::x#0 line::x#1 ]
Statement [11] *((byte*) screen#10) ← (byte) line::x#2 [ line::x1#3 line::x#2 screen#10 ] ( main:2::line:5 [ line::x1#3 line::x#2 screen#10 ] main:2::line:7 [ line::x1#3 line::x#2 screen#10 ] ) always clobbers reg byte y 
Potential registers zp ZP_BYTE:2 [ line::x1#3 ] : zp ZP_BYTE:2 , reg byte a , reg byte x , 
Potential registers zp ZP_BYTE:3 [ line::x#2 line::x#0 line::x#1 ] : zp ZP_BYTE:3 , reg byte a , reg byte x , 
Potential registers zp ZP_WORD:4 [ screen#10 screen#14 screen#11 ] : zp ZP_WORD:4 , 

REGISTER UPLIFT SCOPES
Uplift Scope [line] 30.17: zp ZP_BYTE:3 [ line::x#2 line::x#0 line::x#1 ] 1.83: zp ZP_BYTE:2 [ line::x1#3 ] 
Uplift Scope [] 25.5: zp ZP_WORD:4 [ screen#10 screen#14 screen#11 ] 
Uplift Scope [main] 

Uplifting [line] best 426 combination reg byte x [ line::x#2 line::x#0 line::x#1 ] zp ZP_BYTE:2 [ line::x1#3 ] 
Uplifting [] best 426 combination zp ZP_WORD:4 [ screen#10 screen#14 screen#11 ] 
Uplifting [main] best 426 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:2 [ line::x1#3 ]
Uplifting [line] best 426 combination zp ZP_BYTE:2 [ line::x1#3 ] 
Allocated (was zp ZP_WORD:4) zp ZP_WORD:3 [ screen#10 screen#14 screen#11 ]

ASSEMBLER BEFORE OPTIMIZATION
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .label screen = 3
//SEG2 @begin
bbegin:
//SEG3 [1] phi from @begin to @2 [phi:@begin->@2]
b2_from_bbegin:
  jmp b2
//SEG4 @2
b2:
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @2 to main [phi:@2->main]
main_from_b2:
  jsr main
//SEG7 [3] phi from @2 to @end [phi:@2->@end]
bend_from_b2:
  jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
  //SEG10 [5] call line param-assignment [ screen#11 ] ( main:2 [ screen#11 ] )
  //SEG11 [9] phi from main to line [phi:main->line]
  line_from_main:
  //SEG12 [9] phi (byte) line::x1#3 = (byte/signed byte/word/signed word/dword/signed dword) 2 [phi:main->line#0] -- vbuz1=vbuc1 
    lda #2
    sta line.x1
  //SEG13 [9] phi (byte*) screen#14 = ((byte*))(word/signed word/dword/signed dword) 1024 [phi:main->line#1] -- pbuz1=pbuc1 
    lda #<$400
    sta screen
    lda #>$400
    sta screen+1
  //SEG14 [9] phi (byte) line::x#0 = (byte/signed byte/word/signed word/dword/signed dword) 1 [phi:main->line#2] -- vbuxx=vbuc1 
    ldx #1
    jsr line
  //SEG15 [6] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    jmp b1
  //SEG16 main::@1
  b1:
  //SEG17 [7] call line param-assignment [ ] ( main:2 [ ] )
  //SEG18 [9] phi from main::@1 to line [phi:main::@1->line]
  line_from_b1:
  //SEG19 [9] phi (byte) line::x1#3 = (byte/signed byte/word/signed word/dword/signed dword) 5 [phi:main::@1->line#0] -- vbuz1=vbuc1 
    lda #5
    sta line.x1
  //SEG20 [9] phi (byte*) screen#14 = (byte*) screen#11 [phi:main::@1->line#1] -- register_copy 
  //SEG21 [9] phi (byte) line::x#0 = (byte/signed byte/word/signed word/dword/signed dword) 3 [phi:main::@1->line#2] -- vbuxx=vbuc1 
    ldx #3
    jsr line
    jmp breturn
  //SEG22 main::@return
  breturn:
  //SEG23 [8] return  [ ] ( main:2 [ ] )
    rts
}
//SEG24 line
line: {
    .label x1 = 2
  //SEG25 [10] phi from line line::@1 to line::@1 [phi:line/line::@1->line::@1]
  b1_from_line:
  b1_from_b1:
  //SEG26 [10] phi (byte*) screen#10 = (byte*) screen#14 [phi:line/line::@1->line::@1#0] -- register_copy 
  //SEG27 [10] phi (byte) line::x#2 = (byte) line::x#0 [phi:line/line::@1->line::@1#1] -- register_copy 
    jmp b1
  //SEG28 line::@1
  b1:
  //SEG29 [11] *((byte*) screen#10) ← (byte) line::x#2 [ line::x1#3 line::x#2 screen#10 ] ( main:2::line:5 [ line::x1#3 line::x#2 screen#10 ] main:2::line:7 [ line::x1#3 line::x#2 screen#10 ] ) -- _deref_pbuz1=vbuxx 
    txa
    ldy #0
    sta (screen),y
  //SEG30 [12] (byte*) screen#11 ← ++ (byte*) screen#10 [ line::x1#3 screen#11 line::x#2 ] ( main:2::line:5 [ line::x1#3 screen#11 line::x#2 ] main:2::line:7 [ line::x1#3 screen#11 line::x#2 ] ) -- pbuz1=_inc_pbuz1 
    inc screen
    bne !+
    inc screen+1
  !:
  //SEG31 [13] (byte) line::x#1 ← ++ (byte) line::x#2 [ line::x1#3 screen#11 line::x#1 ] ( main:2::line:5 [ line::x1#3 screen#11 line::x#1 ] main:2::line:7 [ line::x1#3 screen#11 line::x#1 ] ) -- vbuxx=_inc_vbuxx 
    inx
  //SEG32 [14] if((byte) line::x#1<(byte) line::x1#3) goto line::@1 [ line::x1#3 screen#11 line::x#1 ] ( main:2::line:5 [ line::x1#3 screen#11 line::x#1 ] main:2::line:7 [ line::x1#3 screen#11 line::x#1 ] ) -- vbuxx_lt_vbuz1_then_la1 
    cpx x1
    bcc b1_from_b1
    jmp breturn
  //SEG33 line::@return
  breturn:
  //SEG34 [15] return  [ screen#11 ] ( main:2::line:5 [ screen#11 ] main:2::line:7 [ screen#11 ] )
    rts
}

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b2
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp breturn
Removing instruction jmp b1
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b1_from_b1 with b1
Removing instruction bbegin:
Removing instruction b2_from_bbegin:
Removing instruction main_from_b2:
Removing instruction bend_from_b2:
Removing instruction b1_from_main:
Removing instruction line_from_b1:
Removing instruction b1_from_line:
Removing instruction b1_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction b2:
Removing instruction bend:
Removing instruction line_from_main:
Removing instruction b1:
Removing instruction breturn:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @2
(label) @begin
(label) @end
(void()) line((byte) line::x0 , (byte) line::x1)
(label) line::@1
(label) line::@return
(byte) line::x
(byte) line::x#0 reg byte x 2.0
(byte) line::x#1 reg byte x 16.5
(byte) line::x#2 reg byte x 11.666666666666666
(byte) line::x0
(byte) line::x1
(byte) line::x1#3 x1 zp ZP_BYTE:2 1.8333333333333333
(void()) main()
(label) main::@1
(label) main::@return
(byte*) screen
(byte*) screen#10 screen zp ZP_WORD:3 17.5
(byte*) screen#11 screen zp ZP_WORD:3 4.0
(byte*) screen#14 screen zp ZP_WORD:3 4.0

zp ZP_BYTE:2 [ line::x1#3 ]
reg byte x [ line::x#2 line::x#0 line::x#1 ]
zp ZP_WORD:3 [ screen#10 screen#14 screen#11 ]


FINAL ASSEMBLER
Score: 354

//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .label screen = 3
//SEG2 @begin
//SEG3 [1] phi from @begin to @2 [phi:@begin->@2]
//SEG4 @2
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @2 to main [phi:@2->main]
  jsr main
//SEG7 [3] phi from @2 to @end [phi:@2->@end]
//SEG8 @end
//SEG9 main
main: {
  //SEG10 [5] call line param-assignment [ screen#11 ] ( main:2 [ screen#11 ] )
  //SEG11 [9] phi from main to line [phi:main->line]
  //SEG12 [9] phi (byte) line::x1#3 = (byte/signed byte/word/signed word/dword/signed dword) 2 [phi:main->line#0] -- vbuz1=vbuc1 
    lda #2
    sta line.x1
  //SEG13 [9] phi (byte*) screen#14 = ((byte*))(word/signed word/dword/signed dword) 1024 [phi:main->line#1] -- pbuz1=pbuc1 
    lda #<$400
    sta screen
    lda #>$400
    sta screen+1
  //SEG14 [9] phi (byte) line::x#0 = (byte/signed byte/word/signed word/dword/signed dword) 1 [phi:main->line#2] -- vbuxx=vbuc1 
    ldx #1
    jsr line
  //SEG15 [6] phi from main to main::@1 [phi:main->main::@1]
  //SEG16 main::@1
  //SEG17 [7] call line param-assignment [ ] ( main:2 [ ] )
  //SEG18 [9] phi from main::@1 to line [phi:main::@1->line]
  //SEG19 [9] phi (byte) line::x1#3 = (byte/signed byte/word/signed word/dword/signed dword) 5 [phi:main::@1->line#0] -- vbuz1=vbuc1 
    lda #5
    sta line.x1
  //SEG20 [9] phi (byte*) screen#14 = (byte*) screen#11 [phi:main::@1->line#1] -- register_copy 
  //SEG21 [9] phi (byte) line::x#0 = (byte/signed byte/word/signed word/dword/signed dword) 3 [phi:main::@1->line#2] -- vbuxx=vbuc1 
    ldx #3
    jsr line
  //SEG22 main::@return
  //SEG23 [8] return  [ ] ( main:2 [ ] )
    rts
}
//SEG24 line
line: {
    .label x1 = 2
  //SEG25 [10] phi from line line::@1 to line::@1 [phi:line/line::@1->line::@1]
  //SEG26 [10] phi (byte*) screen#10 = (byte*) screen#14 [phi:line/line::@1->line::@1#0] -- register_copy 
  //SEG27 [10] phi (byte) line::x#2 = (byte) line::x#0 [phi:line/line::@1->line::@1#1] -- register_copy 
  //SEG28 line::@1
  b1:
  //SEG29 [11] *((byte*) screen#10) ← (byte) line::x#2 [ line::x1#3 line::x#2 screen#10 ] ( main:2::line:5 [ line::x1#3 line::x#2 screen#10 ] main:2::line:7 [ line::x1#3 line::x#2 screen#10 ] ) -- _deref_pbuz1=vbuxx 
    txa
    ldy #0
    sta (screen),y
  //SEG30 [12] (byte*) screen#11 ← ++ (byte*) screen#10 [ line::x1#3 screen#11 line::x#2 ] ( main:2::line:5 [ line::x1#3 screen#11 line::x#2 ] main:2::line:7 [ line::x1#3 screen#11 line::x#2 ] ) -- pbuz1=_inc_pbuz1 
    inc screen
    bne !+
    inc screen+1
  !:
  //SEG31 [13] (byte) line::x#1 ← ++ (byte) line::x#2 [ line::x1#3 screen#11 line::x#1 ] ( main:2::line:5 [ line::x1#3 screen#11 line::x#1 ] main:2::line:7 [ line::x1#3 screen#11 line::x#1 ] ) -- vbuxx=_inc_vbuxx 
    inx
  //SEG32 [14] if((byte) line::x#1<(byte) line::x1#3) goto line::@1 [ line::x1#3 screen#11 line::x#1 ] ( main:2::line:5 [ line::x1#3 screen#11 line::x#1 ] main:2::line:7 [ line::x1#3 screen#11 line::x#1 ] ) -- vbuxx_lt_vbuz1_then_la1 
    cpx x1
    bcc b1
  //SEG33 line::@return
  //SEG34 [15] return  [ screen#11 ] ( main:2::line:5 [ screen#11 ] main:2::line:7 [ screen#11 ] )
    rts
}

