PARSING src/test/java/dk/camelot64/kickc/test/kc/zpparammin.kc
byte* SCREEN = $0400;
byte* SCREEN2 = $0400+40;

void main() {
    for(byte i : 0..10) {
        SCREEN[i] = sum(i,i+1,i+2);
        SCREEN2[i] = sum2(i,i+1,i+2);
    }
}

byte sum(byte a, byte b, byte c) {
  return a+b+c;
}


byte sum2(byte a, byte b, byte c) {
  return a+b+c;
}

STATEMENTS
  (byte*) SCREEN ← (word/signed word/dword/signed dword) 1024
  (word/signed word/dword/signed dword~) $0 ← (word/signed word/dword/signed dword) 1024 + (byte/signed byte/word/signed word/dword/signed dword) 40
  (byte*) SCREEN2 ← (word/signed word/dword/signed dword~) $0
proc (void()) main()
  (byte) main::i ← (byte/signed byte/word/signed word/dword/signed dword) 0
main::@1:
  (byte/word~) main::$0 ← (byte) main::i + (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte/word~) main::$1 ← (byte) main::i + (byte/signed byte/word/signed word/dword/signed dword) 2
  (byte~) main::$2 ← call sum (byte) main::i (byte/word~) main::$0 (byte/word~) main::$1 
  *((byte*) SCREEN + (byte) main::i) ← (byte~) main::$2
  (byte/word~) main::$3 ← (byte) main::i + (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte/word~) main::$4 ← (byte) main::i + (byte/signed byte/word/signed word/dword/signed dword) 2
  (byte~) main::$5 ← call sum2 (byte) main::i (byte/word~) main::$3 (byte/word~) main::$4 
  *((byte*) SCREEN2 + (byte) main::i) ← (byte~) main::$5
  (byte) main::i ← ++ (byte) main::i
  (boolean~) main::$6 ← (byte) main::i != (byte/signed byte/word/signed word/dword/signed dword) 11
  if((boolean~) main::$6) goto main::@1
main::@return:
  return 
endproc // main()
proc (byte()) sum((byte) sum::a , (byte) sum::b , (byte) sum::c)
  (byte/word~) sum::$0 ← (byte) sum::a + (byte) sum::b
  (byte/word~) sum::$1 ← (byte/word~) sum::$0 + (byte) sum::c
  (byte) sum::return ← (byte/word~) sum::$1
  goto sum::@return
sum::@return:
  (byte) sum::return ← (byte) sum::return
  return (byte) sum::return
endproc // sum()
proc (byte()) sum2((byte) sum2::a , (byte) sum2::b , (byte) sum2::c)
  (byte/word~) sum2::$0 ← (byte) sum2::a + (byte) sum2::b
  (byte/word~) sum2::$1 ← (byte/word~) sum2::$0 + (byte) sum2::c
  (byte) sum2::return ← (byte/word~) sum2::$1
  goto sum2::@return
sum2::@return:
  (byte) sum2::return ← (byte) sum2::return
  return (byte) sum2::return
endproc // sum2()
  call main 

SYMBOLS
(word/signed word/dword/signed dword~) $0
(byte*) SCREEN
(byte*) SCREEN2
(void()) main()
(byte/word~) main::$0
(byte/word~) main::$1
(byte~) main::$2
(byte/word~) main::$3
(byte/word~) main::$4
(byte~) main::$5
(boolean~) main::$6
(label) main::@1
(label) main::@return
(byte) main::i
(byte()) sum((byte) sum::a , (byte) sum::b , (byte) sum::c)
(byte/word~) sum::$0
(byte/word~) sum::$1
(label) sum::@return
(byte) sum::a
(byte) sum::b
(byte) sum::c
(byte) sum::return
(byte()) sum2((byte) sum2::a , (byte) sum2::b , (byte) sum2::c)
(byte/word~) sum2::$0
(byte/word~) sum2::$1
(label) sum2::@return
(byte) sum2::a
(byte) sum2::b
(byte) sum2::c
(byte) sum2::return

Promoting word/signed word/dword/signed dword to byte* in SCREEN ← ((byte*)) 1024
Promoting word/signed word/dword/signed dword to byte* in SCREEN2 ← ((byte*)) $0
INITIAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  (byte*) SCREEN ← ((byte*)) (word/signed word/dword/signed dword) 1024
  (word/signed word/dword/signed dword~) $0 ← (word/signed word/dword/signed dword) 1024 + (byte/signed byte/word/signed word/dword/signed dword) 40
  (byte*) SCREEN2 ← ((byte*)) (word/signed word/dword/signed dword~) $0
  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/word~) main::$0 ← (byte) main::i + (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte/word~) main::$1 ← (byte) main::i + (byte/signed byte/word/signed word/dword/signed dword) 2
  (byte~) main::$2 ← call sum (byte) main::i (byte/word~) main::$0 (byte/word~) main::$1 
  *((byte*) SCREEN + (byte) main::i) ← (byte~) main::$2
  (byte/word~) main::$3 ← (byte) main::i + (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte/word~) main::$4 ← (byte) main::i + (byte/signed byte/word/signed word/dword/signed dword) 2
  (byte~) main::$5 ← call sum2 (byte) main::i (byte/word~) main::$3 (byte/word~) main::$4 
  *((byte*) SCREEN2 + (byte) main::i) ← (byte~) main::$5
  (byte) main::i ← ++ (byte) main::i
  (boolean~) main::$6 ← (byte) main::i != (byte/signed byte/word/signed word/dword/signed dword) 11
  if((boolean~) main::$6) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1
  to:main::@return
main::@return: scope:[main]  from main::@2
  return 
  to:@return
@1: scope:[]  from @begin
  to:@2
sum: scope:[sum]  from
  (byte/word~) sum::$0 ← (byte) sum::a + (byte) sum::b
  (byte/word~) sum::$1 ← (byte/word~) sum::$0 + (byte) sum::c
  (byte) sum::return ← (byte/word~) sum::$1
  to:sum::@return
sum::@return: scope:[sum]  from sum sum::@1
  (byte) sum::return ← (byte) sum::return
  return (byte) sum::return
  to:@return
sum::@1: scope:[sum]  from
  to:sum::@return
@2: scope:[]  from @1
  to:@3
sum2: scope:[sum2]  from
  (byte/word~) sum2::$0 ← (byte) sum2::a + (byte) sum2::b
  (byte/word~) sum2::$1 ← (byte/word~) sum2::$0 + (byte) sum2::c
  (byte) sum2::return ← (byte/word~) sum2::$1
  to:sum2::@return
sum2::@return: scope:[sum2]  from sum2 sum2::@1
  (byte) sum2::return ← (byte) sum2::return
  return (byte) sum2::return
  to:@return
sum2::@1: scope:[sum2]  from
  to:sum2::@return
@3: scope:[]  from @2
  call main 
  to:@end
@end: scope:[]  from @3

Removing empty block main::@2
Removing empty block @1
Removing empty block sum::@1
Removing empty block @2
Removing empty block sum2::@1
PROCEDURE MODIFY VARIABLE ANALYSIS

Completing Phi functions...
Completing Phi functions...
Completing Phi functions...
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
  (word/signed word/dword/signed dword~) $0 ← (word/signed word/dword/signed dword) 1024 + (byte/signed byte/word/signed word/dword/signed dword) 40
  (byte*) SCREEN2#0 ← ((byte*)) (word/signed word/dword/signed dword~) $0
  to:@3
main: scope:[main]  from @3
  (byte*) SCREEN2#4 ← phi( @3/(byte*) SCREEN2#5 )
  (byte*) SCREEN#3 ← phi( @3/(byte*) SCREEN#5 )
  (byte) main::i#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:main::@1
main::@1: scope:[main]  from main main::@4
  (byte*) SCREEN2#3 ← phi( main/(byte*) SCREEN2#4 main::@4/(byte*) SCREEN2#1 )
  (byte*) SCREEN#2 ← phi( main/(byte*) SCREEN#3 main::@4/(byte*) SCREEN#4 )
  (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@4/(byte) main::i#1 )
  (byte/word~) main::$0 ← (byte) main::i#2 + (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte/word~) main::$1 ← (byte) main::i#2 + (byte/signed byte/word/signed word/dword/signed dword) 2
  (byte) sum::a#0 ← (byte) main::i#2
  (byte) sum::b#0 ← (byte/word~) main::$0
  (byte) sum::c#0 ← (byte/word~) main::$1
  call sum param-assignment
  (byte) sum::return#0 ← (byte) sum::return#2
  to:main::@3
main::@3: scope:[main]  from main::@1
  (byte*) SCREEN2#2 ← phi( main::@1/(byte*) SCREEN2#3 )
  (byte) main::i#3 ← phi( main::@1/(byte) main::i#2 )
  (byte*) SCREEN#1 ← phi( main::@1/(byte*) SCREEN#2 )
  (byte) sum::return#3 ← phi( main::@1/(byte) sum::return#0 )
  (byte~) main::$2 ← (byte) sum::return#3
  *((byte*) SCREEN#1 + (byte) main::i#3) ← (byte~) main::$2
  (byte/word~) main::$3 ← (byte) main::i#3 + (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte/word~) main::$4 ← (byte) main::i#3 + (byte/signed byte/word/signed word/dword/signed dword) 2
  (byte) sum2::a#0 ← (byte) main::i#3
  (byte) sum2::b#0 ← (byte/word~) main::$3
  (byte) sum2::c#0 ← (byte/word~) main::$4
  call sum2 param-assignment
  (byte) sum2::return#0 ← (byte) sum2::return#2
  to:main::@4
main::@4: scope:[main]  from main::@3
  (byte*) SCREEN#4 ← phi( main::@3/(byte*) SCREEN#1 )
  (byte) main::i#4 ← phi( main::@3/(byte) main::i#3 )
  (byte*) SCREEN2#1 ← phi( main::@3/(byte*) SCREEN2#2 )
  (byte) sum2::return#3 ← phi( main::@3/(byte) sum2::return#0 )
  (byte~) main::$5 ← (byte) sum2::return#3
  *((byte*) SCREEN2#1 + (byte) main::i#4) ← (byte~) main::$5
  (byte) main::i#1 ← ++ (byte) main::i#4
  (boolean~) main::$6 ← (byte) main::i#1 != (byte/signed byte/word/signed word/dword/signed dword) 11
  if((boolean~) main::$6) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@4
  return 
  to:@return
sum: scope:[sum]  from main::@1
  (byte) sum::c#1 ← phi( main::@1/(byte) sum::c#0 )
  (byte) sum::b#1 ← phi( main::@1/(byte) sum::b#0 )
  (byte) sum::a#1 ← phi( main::@1/(byte) sum::a#0 )
  (byte/word~) sum::$0 ← (byte) sum::a#1 + (byte) sum::b#1
  (byte/word~) sum::$1 ← (byte/word~) sum::$0 + (byte) sum::c#1
  (byte) sum::return#1 ← (byte/word~) sum::$1
  to:sum::@return
sum::@return: scope:[sum]  from sum
  (byte) sum::return#4 ← phi( sum/(byte) sum::return#1 )
  (byte) sum::return#2 ← (byte) sum::return#4
  return 
  to:@return
sum2: scope:[sum2]  from main::@3
  (byte) sum2::c#1 ← phi( main::@3/(byte) sum2::c#0 )
  (byte) sum2::b#1 ← phi( main::@3/(byte) sum2::b#0 )
  (byte) sum2::a#1 ← phi( main::@3/(byte) sum2::a#0 )
  (byte/word~) sum2::$0 ← (byte) sum2::a#1 + (byte) sum2::b#1
  (byte/word~) sum2::$1 ← (byte/word~) sum2::$0 + (byte) sum2::c#1
  (byte) sum2::return#1 ← (byte/word~) sum2::$1
  to:sum2::@return
sum2::@return: scope:[sum2]  from sum2
  (byte) sum2::return#4 ← phi( sum2/(byte) sum2::return#1 )
  (byte) sum2::return#2 ← (byte) sum2::return#4
  return 
  to:@return
@3: scope:[]  from @begin
  (byte*) SCREEN2#5 ← phi( @begin/(byte*) SCREEN2#0 )
  (byte*) SCREEN#5 ← phi( @begin/(byte*) SCREEN#0 )
  call main param-assignment
  to:@4
@4: scope:[]  from @3
  to:@end
@end: scope:[]  from @4

SYMBOL TABLE SSA
(word/signed word/dword/signed dword~) $0
(label) @3
(label) @4
(label) @begin
(label) @end
(byte*) SCREEN
(byte*) SCREEN#0
(byte*) SCREEN#1
(byte*) SCREEN#2
(byte*) SCREEN#3
(byte*) SCREEN#4
(byte*) SCREEN#5
(byte*) SCREEN2
(byte*) SCREEN2#0
(byte*) SCREEN2#1
(byte*) SCREEN2#2
(byte*) SCREEN2#3
(byte*) SCREEN2#4
(byte*) SCREEN2#5
(void()) main()
(byte/word~) main::$0
(byte/word~) main::$1
(byte~) main::$2
(byte/word~) main::$3
(byte/word~) main::$4
(byte~) main::$5
(boolean~) main::$6
(label) main::@1
(label) main::@3
(label) main::@4
(label) main::@return
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(byte) main::i#3
(byte) main::i#4
(byte()) sum((byte) sum::a , (byte) sum::b , (byte) sum::c)
(byte/word~) sum::$0
(byte/word~) sum::$1
(label) sum::@return
(byte) sum::a
(byte) sum::a#0
(byte) sum::a#1
(byte) sum::b
(byte) sum::b#0
(byte) sum::b#1
(byte) sum::c
(byte) sum::c#0
(byte) sum::c#1
(byte) sum::return
(byte) sum::return#0
(byte) sum::return#1
(byte) sum::return#2
(byte) sum::return#3
(byte) sum::return#4
(byte()) sum2((byte) sum2::a , (byte) sum2::b , (byte) sum2::c)
(byte/word~) sum2::$0
(byte/word~) sum2::$1
(label) sum2::@return
(byte) sum2::a
(byte) sum2::a#0
(byte) sum2::a#1
(byte) sum2::b
(byte) sum2::b#0
(byte) sum2::b#1
(byte) sum2::c
(byte) sum2::c#0
(byte) sum2::c#1
(byte) sum2::return
(byte) sum2::return#0
(byte) sum2::return#1
(byte) sum2::return#2
(byte) sum2::return#3
(byte) sum2::return#4

OPTIMIZING CONTROL FLOW GRAPH
Culled Empty Block (label) @4
Succesful SSA optimization Pass2CullEmptyBlocks
Not aliassing across scopes: SCREEN#3 SCREEN#5
Not aliassing across scopes: SCREEN2#4 SCREEN2#5
Not aliassing across scopes: sum::a#0 main::i#2
Not aliassing across scopes: sum::return#0 sum::return#2
Not aliassing across scopes: main::$2 sum::return#3
Not aliassing across scopes: sum2::a#0 main::i#3
Not aliassing across scopes: sum2::return#0 sum2::return#2
Not aliassing across scopes: main::$5 sum2::return#3
Not aliassing across scopes: sum::a#1 sum::a#0
Not aliassing across scopes: sum::b#1 sum::b#0
Not aliassing across scopes: sum::c#1 sum::c#0
Not aliassing across scopes: sum2::a#1 sum2::a#0
Not aliassing across scopes: sum2::b#1 sum2::b#0
Not aliassing across scopes: sum2::c#1 sum2::c#0
Alias (byte) sum::b#0 = (byte/word~) main::$0 
Alias (byte) sum::c#0 = (byte/word~) main::$1 
Alias (byte) sum::return#0 = (byte) sum::return#3 
Alias (byte*) SCREEN#1 = (byte*) SCREEN#2 (byte*) SCREEN#4 
Alias (byte) main::i#2 = (byte) main::i#3 (byte) main::i#4 
Alias (byte*) SCREEN2#1 = (byte*) SCREEN2#2 (byte*) SCREEN2#3 
Alias (byte) sum2::b#0 = (byte/word~) main::$3 
Alias (byte) sum2::c#0 = (byte/word~) main::$4 
Alias (byte) sum2::return#0 = (byte) sum2::return#3 
Alias (byte) sum::return#1 = (byte/word~) sum::$1 (byte) sum::return#4 (byte) sum::return#2 
Alias (byte) sum2::return#1 = (byte/word~) sum2::$1 (byte) sum2::return#4 (byte) sum2::return#2 
Alias (byte*) SCREEN#0 = (byte*) SCREEN#5 
Alias (byte*) SCREEN2#0 = (byte*) SCREEN2#5 
Succesful SSA optimization Pass2AliasElimination
Not aliassing across scopes: SCREEN#3 SCREEN#0
Not aliassing across scopes: SCREEN2#4 SCREEN2#0
Not aliassing across scopes: sum::a#0 main::i#2
Not aliassing across scopes: sum::return#0 sum::return#1
Not aliassing across scopes: main::$2 sum::return#0
Not aliassing across scopes: sum2::a#0 main::i#2
Not aliassing across scopes: sum2::return#0 sum2::return#1
Not aliassing across scopes: main::$5 sum2::return#0
Not aliassing across scopes: sum::a#1 sum::a#0
Not aliassing across scopes: sum::b#1 sum::b#0
Not aliassing across scopes: sum::c#1 sum::c#0
Not aliassing across scopes: sum2::a#1 sum2::a#0
Not aliassing across scopes: sum2::b#1 sum2::b#0
Not aliassing across scopes: sum2::c#1 sum2::c#0
Self Phi Eliminated (byte*) SCREEN#1
Self Phi Eliminated (byte*) SCREEN2#1
Succesful SSA optimization Pass2SelfPhiElimination
Redundant Phi (byte*) SCREEN#3 (byte*) SCREEN#0
Redundant Phi (byte*) SCREEN2#4 (byte*) SCREEN2#0
Redundant Phi (byte*) SCREEN#1 (byte*) SCREEN#3
Redundant Phi (byte*) SCREEN2#1 (byte*) SCREEN2#4
Redundant Phi (byte) sum::a#1 (byte) sum::a#0
Redundant Phi (byte) sum::b#1 (byte) sum::b#0
Redundant Phi (byte) sum::c#1 (byte) sum::c#0
Redundant Phi (byte) sum2::a#1 (byte) sum2::a#0
Redundant Phi (byte) sum2::b#1 (byte) sum2::b#0
Redundant Phi (byte) sum2::c#1 (byte) sum2::c#0
Succesful SSA optimization Pass2RedundantPhiElimination
Simple Condition (boolean~) main::$6 if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto main::@1
Succesful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) SCREEN#0 = ((byte*))1024
Constant (const word/signed word/dword/signed dword) $0 = 1024+40
Constant (const byte) main::i#0 = 0
Succesful SSA optimization Pass2ConstantIdentification
Constant (const byte*) SCREEN2#0 = ((byte*))$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
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#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
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#2
Not aliassing across scopes: sum::a#0 main::i#2
Not aliassing across scopes: sum::return#0 sum::return#1
Not aliassing across scopes: main::$2 sum::return#0
Not aliassing across scopes: sum2::a#0 main::i#2
Not aliassing across scopes: sum2::return#0 sum2::return#1
Not aliassing across scopes: main::$5 sum2::return#0
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#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
Multiple usages for variable. Not optimizing sub-constant (byte) main::i#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
Constant inlined $0 = (word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 40
Constant inlined main::i#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Succesful SSA optimization Pass2ConstantInlining
Block Sequence Planned @begin @3 @end main main::@1 main::@3 main::@4 main::@return sum2 sum2::@return sum sum::@return 
Added new block during phi lifting main::@5(between main::@4 and main::@1)
Block Sequence Planned @begin @3 @end main main::@1 main::@3 main::@4 main::@return main::@5 sum2 sum2::@return sum sum::@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
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to sum:9 sum2:16 

Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Created 1 initial phi equivalence classes
Coalesced [23] main::i#5 ← main::i#1
Coalesced down to 1 phi equivalence classes
Culled Empty Block (label) main::@5
Block Sequence Planned @begin @3 @end main main::@1 main::@3 main::@4 main::@return sum2 sum2::@return sum sum::@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
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:@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::@4
  [5] (byte) main::i#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@4/(byte) main::i#1 ) [ main::i#2 ] ( main:2 [ main::i#2 ] )
  [6] (byte) sum::b#0 ← (byte) main::i#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::i#2 sum::b#0 ] ( main:2 [ main::i#2 sum::b#0 ] )
  [7] (byte) sum::c#0 ← (byte) main::i#2 + (byte/signed byte/word/signed word/dword/signed dword) 2 [ main::i#2 sum::b#0 sum::c#0 ] ( main:2 [ main::i#2 sum::b#0 sum::c#0 ] )
  [8] (byte) sum::a#0 ← (byte) main::i#2 [ main::i#2 sum::b#0 sum::c#0 sum::a#0 ] ( main:2 [ main::i#2 sum::b#0 sum::c#0 sum::a#0 ] )
  [9] call sum param-assignment [ main::i#2 sum::return#1 ] ( main:2 [ main::i#2 sum::return#1 ] )
  [10] (byte) sum::return#0 ← (byte) sum::return#1 [ main::i#2 sum::return#0 ] ( main:2 [ main::i#2 sum::return#0 ] )
  to:main::@3
main::@3: scope:[main]  from main::@1
  [11] (byte~) main::$2 ← (byte) sum::return#0 [ main::i#2 main::$2 ] ( main:2 [ main::i#2 main::$2 ] )
  [12] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte~) main::$2 [ main::i#2 ] ( main:2 [ main::i#2 ] )
  [13] (byte) sum2::b#0 ← (byte) main::i#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::i#2 sum2::b#0 ] ( main:2 [ main::i#2 sum2::b#0 ] )
  [14] (byte) sum2::c#0 ← (byte) main::i#2 + (byte/signed byte/word/signed word/dword/signed dword) 2 [ main::i#2 sum2::b#0 sum2::c#0 ] ( main:2 [ main::i#2 sum2::b#0 sum2::c#0 ] )
  [15] (byte) sum2::a#0 ← (byte) main::i#2 [ main::i#2 sum2::b#0 sum2::c#0 sum2::a#0 ] ( main:2 [ main::i#2 sum2::b#0 sum2::c#0 sum2::a#0 ] )
  [16] call sum2 param-assignment [ main::i#2 sum2::return#1 ] ( main:2 [ main::i#2 sum2::return#1 ] )
  [17] (byte) sum2::return#0 ← (byte) sum2::return#1 [ main::i#2 sum2::return#0 ] ( main:2 [ main::i#2 sum2::return#0 ] )
  to:main::@4
main::@4: scope:[main]  from main::@3
  [18] (byte~) main::$5 ← (byte) sum2::return#0 [ main::i#2 main::$5 ] ( main:2 [ main::i#2 main::$5 ] )
  [19] *((const byte*) SCREEN2#0 + (byte) main::i#2) ← (byte~) main::$5 [ main::i#2 ] ( main:2 [ main::i#2 ] )
  [20] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] )
  [21] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] )
  to:main::@return
main::@return: scope:[main]  from main::@4
  [22] return  [ ] ( main:2 [ ] )
  to:@return
sum2: scope:[sum2]  from main::@3
  [23] (byte/word~) sum2::$0 ← (byte) sum2::a#0 + (byte) sum2::b#0 [ sum2::c#0 sum2::$0 ] ( main:2::sum2:16 [ main::i#2 sum2::c#0 sum2::$0 ] )
  [24] (byte) sum2::return#1 ← (byte/word~) sum2::$0 + (byte) sum2::c#0 [ sum2::return#1 ] ( main:2::sum2:16 [ main::i#2 sum2::return#1 ] )
  to:sum2::@return
sum2::@return: scope:[sum2]  from sum2
  [25] return  [ sum2::return#1 ] ( main:2::sum2:16 [ main::i#2 sum2::return#1 ] )
  to:@return
sum: scope:[sum]  from main::@1
  [26] (byte/word~) sum::$0 ← (byte) sum::a#0 + (byte) sum::b#0 [ sum::c#0 sum::$0 ] ( main:2::sum:9 [ main::i#2 sum::c#0 sum::$0 ] )
  [27] (byte) sum::return#1 ← (byte/word~) sum::$0 + (byte) sum::c#0 [ sum::return#1 ] ( main:2::sum:9 [ main::i#2 sum::return#1 ] )
  to:sum::@return
sum::@return: scope:[sum]  from sum
  [28] return  [ sum::return#1 ] ( main:2::sum:9 [ main::i#2 sum::return#1 ] )
  to:@return

DOMINATORS
@begin dominated by  @begin 
@3 dominated by  @begin @3 
@end dominated by  @begin @3 @end 
main dominated by  @begin @3 main 
main::@1 dominated by  @begin @3 main::@1 main 
main::@3 dominated by  @begin @3 main::@1 main main::@3 
main::@4 dominated by  @begin @3 main::@1 main main::@3 main::@4 
main::@return dominated by  main::@return @begin @3 main::@1 main main::@3 main::@4 
sum2 dominated by  sum2 @begin @3 main::@1 main main::@3 
sum2::@return dominated by  sum2 @begin @3 main::@1 main main::@3 sum2::@return 
sum dominated by  @begin @3 main::@1 main sum 
sum::@return dominated by  @begin @3 main::@1 main sum sum::@return 

NATURAL LOOPS
Found back edge: Loop head: main::@1 tails: main::@4 blocks: null
Populated: Loop head: main::@1 tails: main::@4 blocks: main::@4 main::@3 main::@1 
Loop head: main::@1 tails: main::@4 blocks: main::@4 main::@3 main::@1 

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


VARIABLE REGISTER WEIGHTS
(byte*) SCREEN
(byte*) SCREEN2
(void()) main()
(byte~) main::$2 22.0
(byte~) main::$5 22.0
(byte) main::i
(byte) main::i#1 16.5
(byte) main::i#2 7.333333333333333
(byte()) sum((byte) sum::a , (byte) sum::b , (byte) sum::c)
(byte/word~) sum::$0 4.0
(byte) sum::a
(byte) sum::a#0 13.0
(byte) sum::b
(byte) sum::b#0 4.333333333333333
(byte) sum::c
(byte) sum::c#0 4.333333333333333
(byte) sum::return
(byte) sum::return#0 22.0
(byte) sum::return#1 4.333333333333333
(byte()) sum2((byte) sum2::a , (byte) sum2::b , (byte) sum2::c)
(byte/word~) sum2::$0 4.0
(byte) sum2::a
(byte) sum2::a#0 13.0
(byte) sum2::b
(byte) sum2::b#0 4.333333333333333
(byte) sum2::c
(byte) sum2::c#0 4.333333333333333
(byte) sum2::return
(byte) sum2::return#0 22.0
(byte) sum2::return#1 4.333333333333333

Initial phi equivalence classes
[ main::i#2 main::i#1 ]
Added variable sum::b#0 to zero page equivalence class [ sum::b#0 ]
Added variable sum::c#0 to zero page equivalence class [ sum::c#0 ]
Added variable sum::a#0 to zero page equivalence class [ sum::a#0 ]
Added variable sum::return#0 to zero page equivalence class [ sum::return#0 ]
Added variable main::$2 to zero page equivalence class [ main::$2 ]
Added variable sum2::b#0 to zero page equivalence class [ sum2::b#0 ]
Added variable sum2::c#0 to zero page equivalence class [ sum2::c#0 ]
Added variable sum2::a#0 to zero page equivalence class [ sum2::a#0 ]
Added variable sum2::return#0 to zero page equivalence class [ sum2::return#0 ]
Added variable main::$5 to zero page equivalence class [ main::$5 ]
Added variable sum2::$0 to zero page equivalence class [ sum2::$0 ]
Added variable sum2::return#1 to zero page equivalence class [ sum2::return#1 ]
Added variable sum::$0 to zero page equivalence class [ sum::$0 ]
Added variable sum::return#1 to zero page equivalence class [ sum::return#1 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ sum::b#0 ]
[ sum::c#0 ]
[ sum::a#0 ]
[ sum::return#0 ]
[ main::$2 ]
[ sum2::b#0 ]
[ sum2::c#0 ]
[ sum2::a#0 ]
[ sum2::return#0 ]
[ main::$5 ]
[ sum2::$0 ]
[ sum2::return#1 ]
[ sum::$0 ]
[ sum::return#1 ]
Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Allocated zp ZP_BYTE:3 [ sum::b#0 ]
Allocated zp ZP_BYTE:4 [ sum::c#0 ]
Allocated zp ZP_BYTE:5 [ sum::a#0 ]
Allocated zp ZP_BYTE:6 [ sum::return#0 ]
Allocated zp ZP_BYTE:7 [ main::$2 ]
Allocated zp ZP_BYTE:8 [ sum2::b#0 ]
Allocated zp ZP_BYTE:9 [ sum2::c#0 ]
Allocated zp ZP_BYTE:10 [ sum2::a#0 ]
Allocated zp ZP_BYTE:11 [ sum2::return#0 ]
Allocated zp ZP_BYTE:12 [ main::$5 ]
Allocated zp ZP_BYTE:13 [ sum2::$0 ]
Allocated zp ZP_BYTE:14 [ sum2::return#1 ]
Allocated zp ZP_BYTE:15 [ sum::$0 ]
Allocated zp ZP_BYTE:16 [ sum::return#1 ]

INITIAL ASM
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .label SCREEN = $400
  .label SCREEN2 = $400+$28
//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 _2 = 7
    .label _5 = $c
    .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::@4 to main::@1 [phi:main::@4->main::@1]
  b1_from_b4:
  //SEG13 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4->main::@1#0] -- register_copy 
    jmp b1
  //SEG14 main::@1
  b1:
  //SEG15 [6] (byte) sum::b#0 ← (byte) main::i#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::i#2 sum::b#0 ] ( main:2 [ main::i#2 sum::b#0 ] ) -- vbuz1=vbuz2_plus_1 
    ldy i
    iny
    sty sum.b
  //SEG16 [7] (byte) sum::c#0 ← (byte) main::i#2 + (byte/signed byte/word/signed word/dword/signed dword) 2 [ main::i#2 sum::b#0 sum::c#0 ] ( main:2 [ main::i#2 sum::b#0 sum::c#0 ] ) -- vbuz1=vbuz2_plus_vbuc1 
    lda #2
    clc
    adc i
    sta sum.c
  //SEG17 [8] (byte) sum::a#0 ← (byte) main::i#2 [ main::i#2 sum::b#0 sum::c#0 sum::a#0 ] ( main:2 [ main::i#2 sum::b#0 sum::c#0 sum::a#0 ] ) -- vbuz1=vbuz2 
    lda i
    sta sum.a
  //SEG18 [9] call sum param-assignment [ main::i#2 sum::return#1 ] ( main:2 [ main::i#2 sum::return#1 ] )
    jsr sum
  //SEG19 [10] (byte) sum::return#0 ← (byte) sum::return#1 [ main::i#2 sum::return#0 ] ( main:2 [ main::i#2 sum::return#0 ] ) -- vbuz1=vbuz2 
    lda sum.return_1
    sta sum.return
    jmp b3
  //SEG20 main::@3
  b3:
  //SEG21 [11] (byte~) main::$2 ← (byte) sum::return#0 [ main::i#2 main::$2 ] ( main:2 [ main::i#2 main::$2 ] ) -- vbuz1=vbuz2 
    lda sum.return
    sta _2
  //SEG22 [12] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte~) main::$2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- pbuc1_derefidx_vbuz1=vbuz2 
    lda _2
    ldy i
    sta SCREEN,y
  //SEG23 [13] (byte) sum2::b#0 ← (byte) main::i#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::i#2 sum2::b#0 ] ( main:2 [ main::i#2 sum2::b#0 ] ) -- vbuz1=vbuz2_plus_1 
    ldy i
    iny
    sty sum2.b
  //SEG24 [14] (byte) sum2::c#0 ← (byte) main::i#2 + (byte/signed byte/word/signed word/dword/signed dword) 2 [ main::i#2 sum2::b#0 sum2::c#0 ] ( main:2 [ main::i#2 sum2::b#0 sum2::c#0 ] ) -- vbuz1=vbuz2_plus_vbuc1 
    lda #2
    clc
    adc i
    sta sum2.c
  //SEG25 [15] (byte) sum2::a#0 ← (byte) main::i#2 [ main::i#2 sum2::b#0 sum2::c#0 sum2::a#0 ] ( main:2 [ main::i#2 sum2::b#0 sum2::c#0 sum2::a#0 ] ) -- vbuz1=vbuz2 
    lda i
    sta sum2.a
  //SEG26 [16] call sum2 param-assignment [ main::i#2 sum2::return#1 ] ( main:2 [ main::i#2 sum2::return#1 ] )
    jsr sum2
  //SEG27 [17] (byte) sum2::return#0 ← (byte) sum2::return#1 [ main::i#2 sum2::return#0 ] ( main:2 [ main::i#2 sum2::return#0 ] ) -- vbuz1=vbuz2 
    lda sum2.return_1
    sta sum2.return
    jmp b4
  //SEG28 main::@4
  b4:
  //SEG29 [18] (byte~) main::$5 ← (byte) sum2::return#0 [ main::i#2 main::$5 ] ( main:2 [ main::i#2 main::$5 ] ) -- vbuz1=vbuz2 
    lda sum2.return
    sta _5
  //SEG30 [19] *((const byte*) SCREEN2#0 + (byte) main::i#2) ← (byte~) main::$5 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- pbuc1_derefidx_vbuz1=vbuz2 
    lda _5
    ldy i
    sta SCREEN2,y
  //SEG31 [20] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuz1=_inc_vbuz1 
    inc i
  //SEG32 [21] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuz1_neq_vbuc1_then_la1 
    lda i
    cmp #$b
    bne b1_from_b4
    jmp breturn
  //SEG33 main::@return
  breturn:
  //SEG34 [22] return  [ ] ( main:2 [ ] )
    rts
}
//SEG35 sum2
sum2: {
    .label _0 = $d
    .label a = $a
    .label b = 8
    .label c = 9
    .label return = $b
    .label return_1 = $e
  //SEG36 [23] (byte/word~) sum2::$0 ← (byte) sum2::a#0 + (byte) sum2::b#0 [ sum2::c#0 sum2::$0 ] ( main:2::sum2:16 [ main::i#2 sum2::c#0 sum2::$0 ] ) -- vbuz1=vbuz2_plus_vbuz3 
    lda a
    clc
    adc b
    sta _0
  //SEG37 [24] (byte) sum2::return#1 ← (byte/word~) sum2::$0 + (byte) sum2::c#0 [ sum2::return#1 ] ( main:2::sum2:16 [ main::i#2 sum2::return#1 ] ) -- vbuz1=vbuz2_plus_vbuz3 
    lda _0
    clc
    adc c
    sta return_1
    jmp breturn
  //SEG38 sum2::@return
  breturn:
  //SEG39 [25] return  [ sum2::return#1 ] ( main:2::sum2:16 [ main::i#2 sum2::return#1 ] )
    rts
}
//SEG40 sum
sum: {
    .label _0 = $f
    .label a = 5
    .label b = 3
    .label c = 4
    .label return = 6
    .label return_1 = $10
  //SEG41 [26] (byte/word~) sum::$0 ← (byte) sum::a#0 + (byte) sum::b#0 [ sum::c#0 sum::$0 ] ( main:2::sum:9 [ main::i#2 sum::c#0 sum::$0 ] ) -- vbuz1=vbuz2_plus_vbuz3 
    lda a
    clc
    adc b
    sta _0
  //SEG42 [27] (byte) sum::return#1 ← (byte/word~) sum::$0 + (byte) sum::c#0 [ sum::return#1 ] ( main:2::sum:9 [ main::i#2 sum::return#1 ] ) -- vbuz1=vbuz2_plus_vbuz3 
    lda _0
    clc
    adc c
    sta return_1
    jmp breturn
  //SEG43 sum::@return
  breturn:
  //SEG44 [28] return  [ sum::return#1 ] ( main:2::sum:9 [ main::i#2 sum::return#1 ] )
    rts
}

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [7] (byte) sum::c#0 ← (byte) main::i#2 + (byte/signed byte/word/signed word/dword/signed dword) 2 [ main::i#2 sum::b#0 sum::c#0 ] ( main:2 [ main::i#2 sum::b#0 sum::c#0 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:3 [ sum::b#0 ]
Statement [14] (byte) sum2::c#0 ← (byte) main::i#2 + (byte/signed byte/word/signed word/dword/signed dword) 2 [ main::i#2 sum2::b#0 sum2::c#0 ] ( main:2 [ main::i#2 sum2::b#0 sum2::c#0 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:8 [ sum2::b#0 ]
Statement [23] (byte/word~) sum2::$0 ← (byte) sum2::a#0 + (byte) sum2::b#0 [ sum2::c#0 sum2::$0 ] ( main:2::sum2:16 [ main::i#2 sum2::c#0 sum2::$0 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:9 [ sum2::c#0 ]
Statement [24] (byte) sum2::return#1 ← (byte/word~) sum2::$0 + (byte) sum2::c#0 [ sum2::return#1 ] ( main:2::sum2:16 [ main::i#2 sum2::return#1 ] ) always clobbers reg byte a 
Statement [26] (byte/word~) sum::$0 ← (byte) sum::a#0 + (byte) sum::b#0 [ sum::c#0 sum::$0 ] ( main:2::sum:9 [ main::i#2 sum::c#0 sum::$0 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:4 [ sum::c#0 ]
Statement [27] (byte) sum::return#1 ← (byte/word~) sum::$0 + (byte) sum::c#0 [ sum::return#1 ] ( main:2::sum:9 [ main::i#2 sum::return#1 ] ) always clobbers reg byte a 
Statement [7] (byte) sum::c#0 ← (byte) main::i#2 + (byte/signed byte/word/signed word/dword/signed dword) 2 [ main::i#2 sum::b#0 sum::c#0 ] ( main:2 [ main::i#2 sum::b#0 sum::c#0 ] ) always clobbers reg byte a 
Statement [14] (byte) sum2::c#0 ← (byte) main::i#2 + (byte/signed byte/word/signed word/dword/signed dword) 2 [ main::i#2 sum2::b#0 sum2::c#0 ] ( main:2 [ main::i#2 sum2::b#0 sum2::c#0 ] ) always clobbers reg byte a 
Statement [23] (byte/word~) sum2::$0 ← (byte) sum2::a#0 + (byte) sum2::b#0 [ sum2::c#0 sum2::$0 ] ( main:2::sum2:16 [ main::i#2 sum2::c#0 sum2::$0 ] ) always clobbers reg byte a 
Statement [24] (byte) sum2::return#1 ← (byte/word~) sum2::$0 + (byte) sum2::c#0 [ sum2::return#1 ] ( main:2::sum2:16 [ main::i#2 sum2::return#1 ] ) always clobbers reg byte a 
Statement [26] (byte/word~) sum::$0 ← (byte) sum::a#0 + (byte) sum::b#0 [ sum::c#0 sum::$0 ] ( main:2::sum:9 [ main::i#2 sum::c#0 sum::$0 ] ) always clobbers reg byte a 
Statement [27] (byte) sum::return#1 ← (byte/word~) sum::$0 + (byte) sum::c#0 [ sum::return#1 ] ( main:2::sum:9 [ main::i#2 sum::return#1 ] ) 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 [ sum::b#0 ] : zp ZP_BYTE:3 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:4 [ sum::c#0 ] : zp ZP_BYTE:4 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:5 [ sum::a#0 ] : zp ZP_BYTE:5 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:6 [ sum::return#0 ] : zp ZP_BYTE:6 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:7 [ main::$2 ] : zp ZP_BYTE:7 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:8 [ sum2::b#0 ] : zp ZP_BYTE:8 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:9 [ sum2::c#0 ] : zp ZP_BYTE:9 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:10 [ sum2::a#0 ] : zp ZP_BYTE:10 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:11 [ sum2::return#0 ] : zp ZP_BYTE:11 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:12 [ main::$5 ] : zp ZP_BYTE:12 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:13 [ sum2::$0 ] : zp ZP_BYTE:13 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:14 [ sum2::return#1 ] : zp ZP_BYTE:14 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:15 [ sum::$0 ] : zp ZP_BYTE:15 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:16 [ sum::return#1 ] : zp ZP_BYTE:16 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 23.83: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 22: zp ZP_BYTE:7 [ main::$2 ] 22: zp ZP_BYTE:12 [ main::$5 ] 
Uplift Scope [sum] 22: zp ZP_BYTE:6 [ sum::return#0 ] 13: zp ZP_BYTE:5 [ sum::a#0 ] 4.33: zp ZP_BYTE:3 [ sum::b#0 ] 4.33: zp ZP_BYTE:4 [ sum::c#0 ] 4.33: zp ZP_BYTE:16 [ sum::return#1 ] 4: zp ZP_BYTE:15 [ sum::$0 ] 
Uplift Scope [sum2] 22: zp ZP_BYTE:11 [ sum2::return#0 ] 13: zp ZP_BYTE:10 [ sum2::a#0 ] 4.33: zp ZP_BYTE:8 [ sum2::b#0 ] 4.33: zp ZP_BYTE:9 [ sum2::c#0 ] 4.33: zp ZP_BYTE:14 [ sum2::return#1 ] 4: zp ZP_BYTE:13 [ sum2::$0 ] 
Uplift Scope [] 

Uplifting [main] best 1345 combination zp ZP_BYTE:2 [ main::i#2 main::i#1 ] reg byte a [ main::$2 ] reg byte a [ main::$5 ] 
Uplifting [sum] best 1179 combination reg byte a [ sum::return#0 ] reg byte a [ sum::a#0 ] reg byte y [ sum::b#0 ] reg byte x [ sum::c#0 ] reg byte a [ sum::return#1 ] reg byte a [ sum::$0 ] 
Uplifting [sum2] best 1013 combination reg byte a [ sum2::return#0 ] reg byte a [ sum2::a#0 ] reg byte y [ sum2::b#0 ] reg byte x [ sum2::c#0 ] reg byte a [ sum2::return#1 ] reg byte a [ sum2::$0 ] 
Uplifting [] best 1013 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Uplifting [main] best 1013 combination zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 

ASSEMBLER BEFORE OPTIMIZATION
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .label SCREEN = $400
  .label SCREEN2 = $400+$28
//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::@4 to main::@1 [phi:main::@4->main::@1]
  b1_from_b4:
  //SEG13 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4->main::@1#0] -- register_copy 
    jmp b1
  //SEG14 main::@1
  b1:
  //SEG15 [6] (byte) sum::b#0 ← (byte) main::i#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::i#2 sum::b#0 ] ( main:2 [ main::i#2 sum::b#0 ] ) -- vbuyy=vbuz1_plus_1 
    ldy i
    iny
  //SEG16 [7] (byte) sum::c#0 ← (byte) main::i#2 + (byte/signed byte/word/signed word/dword/signed dword) 2 [ main::i#2 sum::b#0 sum::c#0 ] ( main:2 [ main::i#2 sum::b#0 sum::c#0 ] ) -- vbuxx=vbuz1_plus_vbuc1 
    lda #2
    clc
    adc i
    tax
  //SEG17 [8] (byte) sum::a#0 ← (byte) main::i#2 [ main::i#2 sum::b#0 sum::c#0 sum::a#0 ] ( main:2 [ main::i#2 sum::b#0 sum::c#0 sum::a#0 ] ) -- vbuaa=vbuz1 
    lda i
  //SEG18 [9] call sum param-assignment [ main::i#2 sum::return#1 ] ( main:2 [ main::i#2 sum::return#1 ] )
    jsr sum
  //SEG19 [10] (byte) sum::return#0 ← (byte) sum::return#1 [ main::i#2 sum::return#0 ] ( main:2 [ main::i#2 sum::return#0 ] )
    // (byte) sum::return#0 = (byte) sum::return#1  // register copy reg byte a
    jmp b3
  //SEG20 main::@3
  b3:
  //SEG21 [11] (byte~) main::$2 ← (byte) sum::return#0 [ main::i#2 main::$2 ] ( main:2 [ main::i#2 main::$2 ] )
    // (byte~) main::$2 = (byte) sum::return#0  // register copy reg byte a
  //SEG22 [12] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte~) main::$2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- pbuc1_derefidx_vbuz1=vbuaa 
    ldy i
    sta SCREEN,y
  //SEG23 [13] (byte) sum2::b#0 ← (byte) main::i#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::i#2 sum2::b#0 ] ( main:2 [ main::i#2 sum2::b#0 ] ) -- vbuyy=vbuz1_plus_1 
    ldy i
    iny
  //SEG24 [14] (byte) sum2::c#0 ← (byte) main::i#2 + (byte/signed byte/word/signed word/dword/signed dword) 2 [ main::i#2 sum2::b#0 sum2::c#0 ] ( main:2 [ main::i#2 sum2::b#0 sum2::c#0 ] ) -- vbuxx=vbuz1_plus_vbuc1 
    lda #2
    clc
    adc i
    tax
  //SEG25 [15] (byte) sum2::a#0 ← (byte) main::i#2 [ main::i#2 sum2::b#0 sum2::c#0 sum2::a#0 ] ( main:2 [ main::i#2 sum2::b#0 sum2::c#0 sum2::a#0 ] ) -- vbuaa=vbuz1 
    lda i
  //SEG26 [16] call sum2 param-assignment [ main::i#2 sum2::return#1 ] ( main:2 [ main::i#2 sum2::return#1 ] )
    jsr sum2
  //SEG27 [17] (byte) sum2::return#0 ← (byte) sum2::return#1 [ main::i#2 sum2::return#0 ] ( main:2 [ main::i#2 sum2::return#0 ] )
    // (byte) sum2::return#0 = (byte) sum2::return#1  // register copy reg byte a
    jmp b4
  //SEG28 main::@4
  b4:
  //SEG29 [18] (byte~) main::$5 ← (byte) sum2::return#0 [ main::i#2 main::$5 ] ( main:2 [ main::i#2 main::$5 ] )
    // (byte~) main::$5 = (byte) sum2::return#0  // register copy reg byte a
  //SEG30 [19] *((const byte*) SCREEN2#0 + (byte) main::i#2) ← (byte~) main::$5 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- pbuc1_derefidx_vbuz1=vbuaa 
    ldy i
    sta SCREEN2,y
  //SEG31 [20] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuz1=_inc_vbuz1 
    inc i
  //SEG32 [21] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuz1_neq_vbuc1_then_la1 
    lda i
    cmp #$b
    bne b1_from_b4
    jmp breturn
  //SEG33 main::@return
  breturn:
  //SEG34 [22] return  [ ] ( main:2 [ ] )
    rts
}
//SEG35 sum2
sum2: {
  //SEG36 [23] (byte/word~) sum2::$0 ← (byte) sum2::a#0 + (byte) sum2::b#0 [ sum2::c#0 sum2::$0 ] ( main:2::sum2:16 [ main::i#2 sum2::c#0 sum2::$0 ] ) -- vbuaa=vbuaa_plus_vbuyy 
    sty $ff
    clc
    adc $ff
  //SEG37 [24] (byte) sum2::return#1 ← (byte/word~) sum2::$0 + (byte) sum2::c#0 [ sum2::return#1 ] ( main:2::sum2:16 [ main::i#2 sum2::return#1 ] ) -- vbuaa=vbuaa_plus_vbuxx 
    stx $ff
    clc
    adc $ff
    jmp breturn
  //SEG38 sum2::@return
  breturn:
  //SEG39 [25] return  [ sum2::return#1 ] ( main:2::sum2:16 [ main::i#2 sum2::return#1 ] )
    rts
}
//SEG40 sum
sum: {
  //SEG41 [26] (byte/word~) sum::$0 ← (byte) sum::a#0 + (byte) sum::b#0 [ sum::c#0 sum::$0 ] ( main:2::sum:9 [ main::i#2 sum::c#0 sum::$0 ] ) -- vbuaa=vbuaa_plus_vbuyy 
    sty $ff
    clc
    adc $ff
  //SEG42 [27] (byte) sum::return#1 ← (byte/word~) sum::$0 + (byte) sum::c#0 [ sum::return#1 ] ( main:2::sum:9 [ main::i#2 sum::return#1 ] ) -- vbuaa=vbuaa_plus_vbuxx 
    stx $ff
    clc
    adc $ff
    jmp breturn
  //SEG43 sum::@return
  breturn:
  //SEG44 [28] return  [ sum::return#1 ] ( main:2::sum:9 [ main::i#2 sum::return#1 ] )
    rts
}

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b3
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b3
Removing instruction jmp b4
Removing instruction jmp breturn
Removing instruction jmp breturn
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction ldy i
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Replacing label b1_from_b4 with b1
Removing instruction bbegin:
Removing instruction b3_from_bbegin:
Removing instruction main_from_b3:
Removing instruction bend_from_b3:
Removing instruction b1_from_b4:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction b3:
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction b3:
Removing instruction b4:
Removing instruction breturn:
Removing instruction breturn:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jmp b1
Succesful ASM optimization Pass5NextJumpElimination

FINAL SYMBOL TABLE
(label) @3
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) 1024
(byte*) SCREEN2
(const byte*) SCREEN2#0 SCREEN2 = ((byte*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 40
(void()) main()
(byte~) main::$2 reg byte a 22.0
(byte~) main::$5 reg byte a 22.0
(label) main::@1
(label) main::@3
(label) main::@4
(label) main::@return
(byte) main::i
(byte) main::i#1 i zp ZP_BYTE:2 16.5
(byte) main::i#2 i zp ZP_BYTE:2 7.333333333333333
(byte()) sum((byte) sum::a , (byte) sum::b , (byte) sum::c)
(byte/word~) sum::$0 reg byte a 4.0
(label) sum::@return
(byte) sum::a
(byte) sum::a#0 reg byte a 13.0
(byte) sum::b
(byte) sum::b#0 reg byte y 4.333333333333333
(byte) sum::c
(byte) sum::c#0 reg byte x 4.333333333333333
(byte) sum::return
(byte) sum::return#0 reg byte a 22.0
(byte) sum::return#1 reg byte a 4.333333333333333
(byte()) sum2((byte) sum2::a , (byte) sum2::b , (byte) sum2::c)
(byte/word~) sum2::$0 reg byte a 4.0
(label) sum2::@return
(byte) sum2::a
(byte) sum2::a#0 reg byte a 13.0
(byte) sum2::b
(byte) sum2::b#0 reg byte y 4.333333333333333
(byte) sum2::c
(byte) sum2::c#0 reg byte x 4.333333333333333
(byte) sum2::return
(byte) sum2::return#0 reg byte a 22.0
(byte) sum2::return#1 reg byte a 4.333333333333333

zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
reg byte y [ sum::b#0 ]
reg byte x [ sum::c#0 ]
reg byte a [ sum::a#0 ]
reg byte a [ sum::return#0 ]
reg byte a [ main::$2 ]
reg byte y [ sum2::b#0 ]
reg byte x [ sum2::c#0 ]
reg byte a [ sum2::a#0 ]
reg byte a [ sum2::return#0 ]
reg byte a [ main::$5 ]
reg byte a [ sum2::$0 ]
reg byte a [ sum2::return#1 ]
reg byte a [ sum::$0 ]
reg byte a [ sum::return#1 ]


FINAL ASSEMBLER
Score: 821

//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .label SCREEN = $400
  .label SCREEN2 = $400+$28
//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: {
    .label i = 2
  //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] -- vbuz1=vbuc1 
    lda #0
    sta i
  //SEG12 [5] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
  //SEG13 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4->main::@1#0] -- register_copy 
  //SEG14 main::@1
  b1:
  //SEG15 [6] (byte) sum::b#0 ← (byte) main::i#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::i#2 sum::b#0 ] ( main:2 [ main::i#2 sum::b#0 ] ) -- vbuyy=vbuz1_plus_1 
    ldy i
    iny
  //SEG16 [7] (byte) sum::c#0 ← (byte) main::i#2 + (byte/signed byte/word/signed word/dword/signed dword) 2 [ main::i#2 sum::b#0 sum::c#0 ] ( main:2 [ main::i#2 sum::b#0 sum::c#0 ] ) -- vbuxx=vbuz1_plus_vbuc1 
    lda #2
    clc
    adc i
    tax
  //SEG17 [8] (byte) sum::a#0 ← (byte) main::i#2 [ main::i#2 sum::b#0 sum::c#0 sum::a#0 ] ( main:2 [ main::i#2 sum::b#0 sum::c#0 sum::a#0 ] ) -- vbuaa=vbuz1 
    lda i
  //SEG18 [9] call sum param-assignment [ main::i#2 sum::return#1 ] ( main:2 [ main::i#2 sum::return#1 ] )
    jsr sum
  //SEG19 [10] (byte) sum::return#0 ← (byte) sum::return#1 [ main::i#2 sum::return#0 ] ( main:2 [ main::i#2 sum::return#0 ] )
    // (byte) sum::return#0 = (byte) sum::return#1  // register copy reg byte a
  //SEG20 main::@3
  //SEG21 [11] (byte~) main::$2 ← (byte) sum::return#0 [ main::i#2 main::$2 ] ( main:2 [ main::i#2 main::$2 ] )
    // (byte~) main::$2 = (byte) sum::return#0  // register copy reg byte a
  //SEG22 [12] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte~) main::$2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- pbuc1_derefidx_vbuz1=vbuaa 
    ldy i
    sta SCREEN,y
  //SEG23 [13] (byte) sum2::b#0 ← (byte) main::i#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::i#2 sum2::b#0 ] ( main:2 [ main::i#2 sum2::b#0 ] ) -- vbuyy=vbuz1_plus_1 
    iny
  //SEG24 [14] (byte) sum2::c#0 ← (byte) main::i#2 + (byte/signed byte/word/signed word/dword/signed dword) 2 [ main::i#2 sum2::b#0 sum2::c#0 ] ( main:2 [ main::i#2 sum2::b#0 sum2::c#0 ] ) -- vbuxx=vbuz1_plus_vbuc1 
    lda #2
    clc
    adc i
    tax
  //SEG25 [15] (byte) sum2::a#0 ← (byte) main::i#2 [ main::i#2 sum2::b#0 sum2::c#0 sum2::a#0 ] ( main:2 [ main::i#2 sum2::b#0 sum2::c#0 sum2::a#0 ] ) -- vbuaa=vbuz1 
    lda i
  //SEG26 [16] call sum2 param-assignment [ main::i#2 sum2::return#1 ] ( main:2 [ main::i#2 sum2::return#1 ] )
    jsr sum2
  //SEG27 [17] (byte) sum2::return#0 ← (byte) sum2::return#1 [ main::i#2 sum2::return#0 ] ( main:2 [ main::i#2 sum2::return#0 ] )
    // (byte) sum2::return#0 = (byte) sum2::return#1  // register copy reg byte a
  //SEG28 main::@4
  //SEG29 [18] (byte~) main::$5 ← (byte) sum2::return#0 [ main::i#2 main::$5 ] ( main:2 [ main::i#2 main::$5 ] )
    // (byte~) main::$5 = (byte) sum2::return#0  // register copy reg byte a
  //SEG30 [19] *((const byte*) SCREEN2#0 + (byte) main::i#2) ← (byte~) main::$5 [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- pbuc1_derefidx_vbuz1=vbuaa 
    ldy i
    sta SCREEN2,y
  //SEG31 [20] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuz1=_inc_vbuz1 
    inc i
  //SEG32 [21] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuz1_neq_vbuc1_then_la1 
    lda i
    cmp #$b
    bne b1
  //SEG33 main::@return
  //SEG34 [22] return  [ ] ( main:2 [ ] )
    rts
}
//SEG35 sum2
sum2: {
  //SEG36 [23] (byte/word~) sum2::$0 ← (byte) sum2::a#0 + (byte) sum2::b#0 [ sum2::c#0 sum2::$0 ] ( main:2::sum2:16 [ main::i#2 sum2::c#0 sum2::$0 ] ) -- vbuaa=vbuaa_plus_vbuyy 
    sty $ff
    clc
    adc $ff
  //SEG37 [24] (byte) sum2::return#1 ← (byte/word~) sum2::$0 + (byte) sum2::c#0 [ sum2::return#1 ] ( main:2::sum2:16 [ main::i#2 sum2::return#1 ] ) -- vbuaa=vbuaa_plus_vbuxx 
    stx $ff
    clc
    adc $ff
  //SEG38 sum2::@return
  //SEG39 [25] return  [ sum2::return#1 ] ( main:2::sum2:16 [ main::i#2 sum2::return#1 ] )
    rts
}
//SEG40 sum
sum: {
  //SEG41 [26] (byte/word~) sum::$0 ← (byte) sum::a#0 + (byte) sum::b#0 [ sum::c#0 sum::$0 ] ( main:2::sum:9 [ main::i#2 sum::c#0 sum::$0 ] ) -- vbuaa=vbuaa_plus_vbuyy 
    sty $ff
    clc
    adc $ff
  //SEG42 [27] (byte) sum::return#1 ← (byte/word~) sum::$0 + (byte) sum::c#0 [ sum::return#1 ] ( main:2::sum:9 [ main::i#2 sum::return#1 ] ) -- vbuaa=vbuaa_plus_vbuxx 
    stx $ff
    clc
    adc $ff
  //SEG43 sum::@return
  //SEG44 [28] return  [ sum::return#1 ] ( main:2::sum:9 [ main::i#2 sum::return#1 ] )
    rts
}

