Identified constant variable (byte*) SCREEN
Identified constant variable (byte*) RASTER
Identified constant variable (byte*) BGCOL
Identified constant variable (byte*) SCROLL
Identified constant variable (byte*) TEXT
Culled Empty Block (label) main::@1
Culled Empty Block (label) main::@3
Culled Empty Block (label) main::@12
Culled Empty Block (label) @1
Culled Empty Block (label) fillscreen::@2

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) SCREEN#0 ← ((byte*)) (number) $400
  (byte*) RASTER#0 ← ((byte*)) (number) $d012
  (byte*) BGCOL#0 ← ((byte*)) (number) $d020
  (byte*) SCROLL#0 ← ((byte*)) (number) $d016
  (byte*) TEXT#0 ← (const string) $0
  to:@2
main: scope:[main]  from @2
  (byte*) fillscreen::screen#0 ← (byte*) SCREEN#0
  (byte) fillscreen::fill#0 ← (number) $20
  call fillscreen 
  to:main::@13
main::@13: scope:[main]  from main
  (byte) main::scroll#0 ← (number) 7
  (byte*) main::nxt#0 ← (byte*) TEXT#0
  (byte*~) main::$1 ← (byte*) SCREEN#0 + (number) $28
  (byte[]) main::line#0 ← (byte*~) main::$1
  to:main::@2
main::@2: scope:[main]  from main::@13 main::@2 main::@7
  (byte*) main::nxt#9 ← phi( main::@13/(byte*) main::nxt#0 main::@2/(byte*) main::nxt#9 main::@7/(byte*) main::nxt#10 )
  (byte) main::scroll#7 ← phi( main::@13/(byte) main::scroll#0 main::@2/(byte) main::scroll#7 main::@7/(byte) main::scroll#4 )
  (bool~) main::$2 ← *((byte*) RASTER#0) != (number) $fe
  if((bool~) main::$2) goto main::@2
  to:main::@4
main::@4: scope:[main]  from main::@2 main::@4
  (byte*) main::nxt#8 ← phi( main::@2/(byte*) main::nxt#9 main::@4/(byte*) main::nxt#8 )
  (byte) main::scroll#5 ← phi( main::@2/(byte) main::scroll#7 main::@4/(byte) main::scroll#5 )
  (bool~) main::$3 ← *((byte*) RASTER#0) != (number) $ff
  if((bool~) main::$3) goto main::@4
  to:main::@5
main::@5: scope:[main]  from main::@4
  (byte*) main::nxt#7 ← phi( main::@4/(byte*) main::nxt#8 )
  (byte) main::scroll#3 ← phi( main::@4/(byte) main::scroll#5 )
  *((byte*) BGCOL#0) ← ++ *((byte*) BGCOL#0)
  (byte) main::scroll#1 ← -- (byte) main::scroll#3
  (bool~) main::$4 ← (byte) main::scroll#1 == (number) $ff
  (bool~) main::$5 ← ! (bool~) main::$4
  if((bool~) main::$5) goto main::@7
  to:main::@6
main::@7: scope:[main]  from main::@11 main::@5
  (byte*) main::nxt#10 ← phi( main::@11/(byte*) main::nxt#1 main::@5/(byte*) main::nxt#7 )
  (byte) main::scroll#4 ← phi( main::@11/(byte) main::scroll#6 main::@5/(byte) main::scroll#1 )
  *((byte*) SCROLL#0) ← (byte) main::scroll#4
  *((byte*) BGCOL#0) ← -- *((byte*) BGCOL#0)
  if(true) goto main::@2
  to:main::@return
main::@6: scope:[main]  from main::@5
  (byte*) main::nxt#6 ← phi( main::@5/(byte*) main::nxt#7 )
  (byte) main::scroll#2 ← (number) 7
  (byte) main::i#0 ← (number) 0
  to:main::@8
main::@8: scope:[main]  from main::@6 main::@8
  (byte) main::scroll#10 ← phi( main::@6/(byte) main::scroll#2 main::@8/(byte) main::scroll#10 )
  (byte*) main::nxt#5 ← phi( main::@6/(byte*) main::nxt#6 main::@8/(byte*) main::nxt#5 )
  (byte) main::i#2 ← phi( main::@6/(byte) main::i#0 main::@8/(byte) main::i#1 )
  (number~) main::$6 ← (byte) main::i#2 + (number) 1
  *((byte[]) main::line#0 + (byte) main::i#2) ← *((byte[]) main::line#0 + (number~) main::$6)
  (byte) main::i#1 ← ++ (byte) main::i#2
  (bool~) main::$7 ← (byte) main::i#1 != (number) $27
  if((bool~) main::$7) goto main::@8
  to:main::@9
main::@9: scope:[main]  from main::@8
  (byte) main::scroll#9 ← phi( main::@8/(byte) main::scroll#10 )
  (byte*) main::nxt#3 ← phi( main::@8/(byte*) main::nxt#5 )
  (byte) main::c#0 ← *((byte*) main::nxt#3)
  (bool~) main::$8 ← (byte) main::c#0 == (byte) '@'
  (bool~) main::$9 ← ! (bool~) main::$8
  if((bool~) main::$9) goto main::@11
  to:main::@10
main::@11: scope:[main]  from main::@10 main::@9
  (byte) main::scroll#6 ← phi( main::@10/(byte) main::scroll#8 main::@9/(byte) main::scroll#9 )
  (byte*) main::nxt#4 ← phi( main::@10/(byte*) main::nxt#2 main::@9/(byte*) main::nxt#3 )
  (byte) main::c#2 ← phi( main::@10/(byte) main::c#1 main::@9/(byte) main::c#0 )
  *((byte[]) main::line#0 + (number) $27) ← (byte) main::c#2
  (byte*) main::nxt#1 ← ++ (byte*) main::nxt#4
  to:main::@7
main::@10: scope:[main]  from main::@9
  (byte) main::scroll#8 ← phi( main::@9/(byte) main::scroll#9 )
  (byte*) main::nxt#2 ← (byte*) TEXT#0
  (byte) main::c#1 ← *((byte*) main::nxt#2)
  to:main::@11
main::@return: scope:[main]  from main::@7
  return 
  to:@return
fillscreen: scope:[fillscreen]  from main
  (byte) fillscreen::fill#2 ← phi( main/(byte) fillscreen::fill#0 )
  (byte*) fillscreen::screen#1 ← phi( main/(byte*) fillscreen::screen#0 )
  (byte*) fillscreen::cursor#0 ← (byte*) fillscreen::screen#1
  to:fillscreen::@1
fillscreen::@1: scope:[fillscreen]  from fillscreen fillscreen::@1
  (byte*) fillscreen::screen#2 ← phi( fillscreen/(byte*) fillscreen::screen#1 fillscreen::@1/(byte*) fillscreen::screen#2 )
  (byte*) fillscreen::cursor#2 ← phi( fillscreen/(byte*) fillscreen::cursor#0 fillscreen::@1/(byte*) fillscreen::cursor#1 )
  (byte) fillscreen::fill#1 ← phi( fillscreen/(byte) fillscreen::fill#2 fillscreen::@1/(byte) fillscreen::fill#1 )
  *((byte*) fillscreen::cursor#2) ← (byte) fillscreen::fill#1
  (byte*) fillscreen::cursor#1 ← ++ (byte*) fillscreen::cursor#2
  (byte*~) fillscreen::$0 ← (byte*) fillscreen::screen#2 + (number) $3e8
  (bool~) fillscreen::$1 ← (byte*) fillscreen::cursor#1 < (byte*~) fillscreen::$0
  if((bool~) fillscreen::$1) goto fillscreen::@1
  to:fillscreen::@return
fillscreen::@return: scope:[fillscreen]  from fillscreen::@1
  return 
  to:@return
@2: scope:[]  from @begin
  call main 
  to:@3
@3: scope:[]  from @2
  to:@end
@end: scope:[]  from @3

SYMBOL TABLE SSA
(const string) $0 = (string) "-= this is rex of camelot testing a scroller created in kickc. kickc is an optimizing c-compiler for 6502 assembler. =-     @"
(label) @2
(label) @3
(label) @begin
(label) @end
(byte*) BGCOL
(byte*) BGCOL#0
(byte*) RASTER
(byte*) RASTER#0
(byte*) SCREEN
(byte*) SCREEN#0
(byte*) SCROLL
(byte*) SCROLL#0
(byte*) TEXT
(byte*) TEXT#0
(void()) fillscreen((byte*) fillscreen::screen , (byte) fillscreen::fill)
(byte*~) fillscreen::$0
(bool~) fillscreen::$1
(label) fillscreen::@1
(label) fillscreen::@return
(byte*) fillscreen::cursor
(byte*) fillscreen::cursor#0
(byte*) fillscreen::cursor#1
(byte*) fillscreen::cursor#2
(byte) fillscreen::fill
(byte) fillscreen::fill#0
(byte) fillscreen::fill#1
(byte) fillscreen::fill#2
(byte*) fillscreen::screen
(byte*) fillscreen::screen#0
(byte*) fillscreen::screen#1
(byte*) fillscreen::screen#2
(void()) main()
(byte*~) main::$1
(bool~) main::$2
(bool~) main::$3
(bool~) main::$4
(bool~) main::$5
(number~) main::$6
(bool~) main::$7
(bool~) main::$8
(bool~) main::$9
(label) main::@10
(label) main::@11
(label) main::@13
(label) main::@2
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@7
(label) main::@8
(label) main::@9
(label) main::@return
(byte) main::c
(byte) main::c#0
(byte) main::c#1
(byte) main::c#2
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(byte[]) main::line
(byte[]) main::line#0
(byte*) main::nxt
(byte*) main::nxt#0
(byte*) main::nxt#1
(byte*) main::nxt#10
(byte*) main::nxt#2
(byte*) main::nxt#3
(byte*) main::nxt#4
(byte*) main::nxt#5
(byte*) main::nxt#6
(byte*) main::nxt#7
(byte*) main::nxt#8
(byte*) main::nxt#9
(byte) main::scroll
(byte) main::scroll#0
(byte) main::scroll#1
(byte) main::scroll#10
(byte) main::scroll#2
(byte) main::scroll#3
(byte) main::scroll#4
(byte) main::scroll#5
(byte) main::scroll#6
(byte) main::scroll#7
(byte) main::scroll#8
(byte) main::scroll#9

Adding number conversion cast (unumber) $20 in (byte) fillscreen::fill#0 ← (number) $20
Adding number conversion cast (unumber) 7 in (byte) main::scroll#0 ← (number) 7
Adding number conversion cast (unumber) $28 in (byte*~) main::$1 ← (byte*) SCREEN#0 + (number) $28
Adding number conversion cast (unumber) $fe in (bool~) main::$2 ← *((byte*) RASTER#0) != (number) $fe
Adding number conversion cast (unumber) $ff in (bool~) main::$3 ← *((byte*) RASTER#0) != (number) $ff
Adding number conversion cast (unumber) $ff in (bool~) main::$4 ← (byte) main::scroll#1 == (number) $ff
Adding number conversion cast (unumber) 7 in (byte) main::scroll#2 ← (number) 7
Adding number conversion cast (unumber) 0 in (byte) main::i#0 ← (number) 0
Adding number conversion cast (unumber) 1 in (number~) main::$6 ← (byte) main::i#2 + (number) 1
Adding number conversion cast (unumber) main::$6 in (number~) main::$6 ← (byte) main::i#2 + (unumber)(number) 1
Adding number conversion cast (unumber) $27 in (bool~) main::$7 ← (byte) main::i#1 != (number) $27
Adding number conversion cast (unumber) $27 in *((byte[]) main::line#0 + (number) $27) ← (byte) main::c#2
Adding number conversion cast (unumber) $3e8 in (byte*~) fillscreen::$0 ← (byte*) fillscreen::screen#2 + (number) $3e8
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
Inlining cast (byte*) RASTER#0 ← (byte*)(number) $d012
Inlining cast (byte*) BGCOL#0 ← (byte*)(number) $d020
Inlining cast (byte*) SCROLL#0 ← (byte*)(number) $d016
Inlining cast (byte) fillscreen::fill#0 ← (unumber)(number) $20
Inlining cast (byte) main::scroll#0 ← (unumber)(number) 7
Inlining cast (byte) main::scroll#2 ← (unumber)(number) 7
Inlining cast (byte) main::i#0 ← (unumber)(number) 0
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (byte*) 53266
Simplifying constant pointer cast (byte*) 53280
Simplifying constant pointer cast (byte*) 53270
Simplifying constant integer cast $20
Simplifying constant integer cast 7
Simplifying constant integer cast $28
Simplifying constant integer cast $fe
Simplifying constant integer cast $ff
Simplifying constant integer cast $ff
Simplifying constant integer cast 7
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast $27
Simplifying constant integer cast $27
Simplifying constant integer cast $3e8
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $20
Finalized unsigned number type (byte) 7
Finalized unsigned number type (byte) $28
Finalized unsigned number type (byte) $fe
Finalized unsigned number type (byte) $ff
Finalized unsigned number type (byte) $ff
Finalized unsigned number type (byte) 7
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) $27
Finalized unsigned number type (byte) $27
Finalized unsigned number type (word) $3e8
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) main::$6 ← (byte) main::i#2 + (byte) 1
Inversing boolean not [22] (bool~) main::$5 ← (byte) main::scroll#1 != (byte) $ff from [21] (bool~) main::$4 ← (byte) main::scroll#1 == (byte) $ff
Inversing boolean not [40] (bool~) main::$9 ← (byte) main::c#0 != (byte) '@' from [39] (bool~) main::$8 ← (byte) main::c#0 == (byte) '@'
Successful SSA optimization Pass2UnaryNotSimplification
Alias (byte[]) main::line#0 = (byte*~) main::$1 
Alias (byte) main::scroll#3 = (byte) main::scroll#5 
Alias (byte*) main::nxt#6 = (byte*) main::nxt#7 (byte*) main::nxt#8 
Alias (byte*) main::nxt#3 = (byte*) main::nxt#5 
Alias (byte) main::scroll#10 = (byte) main::scroll#9 (byte) main::scroll#8 
Alias (byte*) fillscreen::cursor#0 = (byte*) fillscreen::screen#1 
Successful SSA optimization Pass2AliasElimination
Alias (byte) main::scroll#10 = (byte) main::scroll#6 
Successful SSA optimization Pass2AliasElimination
Self Phi Eliminated (byte) main::scroll#7
Self Phi Eliminated (byte*) main::nxt#9
Self Phi Eliminated (byte) main::scroll#3
Self Phi Eliminated (byte*) main::nxt#6
Self Phi Eliminated (byte*) main::nxt#3
Self Phi Eliminated (byte) main::scroll#10
Self Phi Eliminated (byte) fillscreen::fill#1
Self Phi Eliminated (byte*) fillscreen::screen#2
Successful SSA optimization Pass2SelfPhiElimination
Identical Phi Values (byte) main::scroll#3 (byte) main::scroll#7
Identical Phi Values (byte*) main::nxt#6 (byte*) main::nxt#9
Identical Phi Values (byte*) main::nxt#3 (byte*) main::nxt#6
Identical Phi Values (byte) main::scroll#10 (byte) main::scroll#2
Identical Phi Values (byte*) fillscreen::cursor#0 (byte*) fillscreen::screen#0
Identical Phi Values (byte) fillscreen::fill#2 (byte) fillscreen::fill#0
Identical Phi Values (byte) fillscreen::fill#1 (byte) fillscreen::fill#2
Identical Phi Values (byte*) fillscreen::screen#2 (byte*) fillscreen::cursor#0
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$2 [14] if(*((byte*) RASTER#0)!=(byte) $fe) goto main::@2
Simple Condition (bool~) main::$3 [17] if(*((byte*) RASTER#0)!=(byte) $ff) goto main::@4
Simple Condition (bool~) main::$5 [23] if((byte) main::scroll#1!=(byte) $ff) goto main::@7
Simple Condition (bool~) main::$7 [36] if((byte) main::i#1!=(byte) $27) goto main::@8
Simple Condition (bool~) main::$9 [41] if((byte) main::c#0!=(byte) '@') goto main::@11
Simple Condition (bool~) fillscreen::$1 [56] if((byte*) fillscreen::cursor#1<(byte*~) fillscreen::$0) goto fillscreen::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) SCREEN#0 = (byte*) 1024
Constant (const byte*) RASTER#0 = (byte*) 53266
Constant (const byte*) BGCOL#0 = (byte*) 53280
Constant (const byte*) SCROLL#0 = (byte*) 53270
Constant (const byte*) TEXT#0 = $0
Constant (const byte) fillscreen::fill#0 = $20
Constant (const byte) main::scroll#0 = 7
Constant (const byte) main::scroll#2 = 7
Constant (const byte) main::i#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte*) fillscreen::screen#0 = SCREEN#0
Constant (const byte*) main::nxt#0 = TEXT#0
Constant (const byte*) main::nxt#2 = TEXT#0
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [27] if(true) goto main::@2
Successful SSA optimization Pass2ConstantIfs
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Constant right-side identified [1] (byte[]) main::line#0 ← (const byte*) SCREEN#0 + (byte) $28
Constant right-side identified [25] (byte*~) fillscreen::$0 ← (const byte*) fillscreen::screen#0 + (word) $3e8
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte[]) main::line#0 = SCREEN#0+$28
Constant (const byte*) fillscreen::$0 = fillscreen::screen#0+$3e8
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with var siblings (const byte) main::scroll#0
Inlining constant with var siblings (const byte) main::scroll#2
Inlining constant with var siblings (const byte) main::i#0
Inlining constant with var siblings (const byte*) main::nxt#0
Inlining constant with var siblings (const byte*) main::nxt#2
Constant inlined main::nxt#0 = (const byte*) TEXT#0
Constant inlined main::scroll#0 = (byte) 7
Constant inlined fillscreen::screen#0 = (const byte*) SCREEN#0
Constant inlined fillscreen::$0 = (const byte*) SCREEN#0+(word) $3e8
Constant inlined main::scroll#2 = (byte) 7
Constant inlined main::i#0 = (byte) 0
Constant inlined $0 = (const byte*) TEXT#0
Constant inlined main::nxt#2 = (const byte*) TEXT#0
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in assignment *(main::line#0+1 + main::$6)
Consolidated array index constant in *(main::line#0+$27)
Successful SSA optimization Pass2ConstantAdditionElimination
Alias (byte) main::i#2 = (byte~) main::$6 
Successful SSA optimization Pass2AliasElimination
Added new block during phi lifting main::@14(between main::@5 and main::@7)
Added new block during phi lifting main::@15(between main::@8 and main::@8)
Added new block during phi lifting main::@16(between main::@9 and main::@11)
Added new block during phi lifting fillscreen::@3(between fillscreen::@1 and fillscreen::@1)
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
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::@13
Adding NOP phi() at start of main::@6
Adding NOP phi() at start of fillscreen
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to fillscreen:6 

Created 8 initial phi equivalence classes
Coalesced [22] main::c#3 ← main::c#1
Coalesced [26] main::nxt#12 ← main::nxt#1
Coalesced [30] main::scroll#11 ← main::scroll#4
Coalesced [31] main::nxt#11 ← main::nxt#10
Coalesced [32] main::c#4 ← main::c#0
Coalesced [33] main::nxt#14 ← main::nxt#9
Coalesced [34] main::i#3 ← main::i#1
Coalesced [35] main::scroll#12 ← main::scroll#1
Coalesced (already) [36] main::nxt#13 ← main::nxt#9
Coalesced [43] fillscreen::cursor#3 ← fillscreen::cursor#1
Coalesced down to 5 phi equivalence classes
Culled Empty Block (label) @3
Culled Empty Block (label) main::@13
Culled Empty Block (label) main::@6
Culled Empty Block (label) main::@16
Culled Empty Block (label) main::@15
Culled Empty Block (label) main::@14
Culled Empty Block (label) fillscreen::@3
Renumbering block @2 to @1
Renumbering block main::@2 to main::@1
Renumbering block main::@4 to main::@2
Renumbering block main::@5 to main::@3
Renumbering block main::@7 to main::@4
Renumbering block main::@8 to main::@5
Renumbering block main::@9 to main::@6
Renumbering block main::@10 to main::@7
Renumbering block main::@11 to main::@8
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of fillscreen

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi()
  to:@1
@1: scope:[]  from @begin
  [1] phi()
  [2] call main 
  to:@end
@end: scope:[]  from @1
  [3] phi()
main: scope:[main]  from @1
  [4] phi()
  [5] call fillscreen 
  to:main::@1
main::@1: scope:[main]  from main main::@1 main::@4
  [6] (byte*) main::nxt#9 ← phi( main/(const byte*) TEXT#0 main::@4/(byte*) main::nxt#10 )
  [6] (byte) main::scroll#7 ← phi( main/(byte) 7 main::@4/(byte) main::scroll#4 )
  [7] if(*((const byte*) RASTER#0)!=(byte) $fe) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@2
  [8] if(*((const byte*) RASTER#0)!=(byte) $ff) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@2
  [9] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0)
  [10] (byte) main::scroll#1 ← -- (byte) main::scroll#7
  [11] if((byte) main::scroll#1!=(byte) $ff) goto main::@4
  to:main::@5
main::@5: scope:[main]  from main::@3 main::@5
  [12] (byte) main::i#2 ← phi( main::@3/(byte) 0 main::@5/(byte) main::i#1 )
  [13] *((const byte[]) main::line#0 + (byte) main::i#2) ← *((const byte[]) main::line#0+(byte) 1 + (byte) main::i#2)
  [14] (byte) main::i#1 ← ++ (byte) main::i#2
  [15] if((byte) main::i#1!=(byte) $27) goto main::@5
  to:main::@6
main::@6: scope:[main]  from main::@5
  [16] (byte) main::c#0 ← *((byte*) main::nxt#9)
  [17] if((byte) main::c#0!=(byte) '@') goto main::@8
  to:main::@7
main::@7: scope:[main]  from main::@6
  [18] (byte) main::c#1 ← *((const byte*) TEXT#0)
  to:main::@8
main::@8: scope:[main]  from main::@6 main::@7
  [19] (byte*) main::nxt#4 ← phi( main::@7/(const byte*) TEXT#0 main::@6/(byte*) main::nxt#9 )
  [19] (byte) main::c#2 ← phi( main::@7/(byte) main::c#1 main::@6/(byte) main::c#0 )
  [20] *((const byte[]) main::line#0+(byte) $27) ← (byte) main::c#2
  [21] (byte*) main::nxt#1 ← ++ (byte*) main::nxt#4
  to:main::@4
main::@4: scope:[main]  from main::@3 main::@8
  [22] (byte*) main::nxt#10 ← phi( main::@8/(byte*) main::nxt#1 main::@3/(byte*) main::nxt#9 )
  [22] (byte) main::scroll#4 ← phi( main::@8/(byte) 7 main::@3/(byte) main::scroll#1 )
  [23] *((const byte*) SCROLL#0) ← (byte) main::scroll#4
  [24] *((const byte*) BGCOL#0) ← -- *((const byte*) BGCOL#0)
  to:main::@1
fillscreen: scope:[fillscreen]  from main
  [25] phi()
  to:fillscreen::@1
fillscreen::@1: scope:[fillscreen]  from fillscreen fillscreen::@1
  [26] (byte*) fillscreen::cursor#2 ← phi( fillscreen/(const byte*) SCREEN#0 fillscreen::@1/(byte*) fillscreen::cursor#1 )
  [27] *((byte*) fillscreen::cursor#2) ← (const byte) fillscreen::fill#0
  [28] (byte*) fillscreen::cursor#1 ← ++ (byte*) fillscreen::cursor#2
  [29] if((byte*) fillscreen::cursor#1<(const byte*) SCREEN#0+(word) $3e8) goto fillscreen::@1
  to:fillscreen::@return
fillscreen::@return: scope:[fillscreen]  from fillscreen::@1
  [30] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte*) BGCOL
(byte*) RASTER
(byte*) SCREEN
(byte*) SCROLL
(byte*) TEXT
(void()) fillscreen((byte*) fillscreen::screen , (byte) fillscreen::fill)
(byte*) fillscreen::cursor
(byte*) fillscreen::cursor#1 16.5
(byte*) fillscreen::cursor#2 16.5
(byte) fillscreen::fill
(byte*) fillscreen::screen
(void()) main()
(byte) main::c
(byte) main::c#0 16.5
(byte) main::c#1 22.0
(byte) main::c#2 33.0
(byte) main::i
(byte) main::i#1 151.5
(byte) main::i#2 202.0
(byte[]) main::line
(byte*) main::nxt
(byte*) main::nxt#1 22.0
(byte*) main::nxt#10 11.0
(byte*) main::nxt#4 11.0
(byte*) main::nxt#9 3.6666666666666665
(byte) main::scroll
(byte) main::scroll#1 16.5
(byte) main::scroll#4 11.0
(byte) main::scroll#7 5.5

Initial phi equivalence classes
[ main::scroll#7 main::scroll#4 main::scroll#1 ]
[ main::i#2 main::i#1 ]
[ main::c#2 main::c#1 main::c#0 ]
[ main::nxt#4 main::nxt#9 main::nxt#10 main::nxt#1 ]
[ fillscreen::cursor#2 fillscreen::cursor#1 ]
Complete equivalence classes
[ main::scroll#7 main::scroll#4 main::scroll#1 ]
[ main::i#2 main::i#1 ]
[ main::c#2 main::c#1 main::c#0 ]
[ main::nxt#4 main::nxt#9 main::nxt#10 main::nxt#1 ]
[ fillscreen::cursor#2 fillscreen::cursor#1 ]
Allocated zp ZP_BYTE:2 [ main::scroll#7 main::scroll#4 main::scroll#1 ]
Allocated zp ZP_BYTE:3 [ main::i#2 main::i#1 ]
Allocated zp ZP_BYTE:4 [ main::c#2 main::c#1 main::c#0 ]
Allocated zp ZP_WORD:5 [ main::nxt#4 main::nxt#9 main::nxt#10 main::nxt#1 ]
Allocated zp ZP_WORD:7 [ fillscreen::cursor#2 fillscreen::cursor#1 ]

INITIAL ASM
  // File Comments
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  .label RASTER = $d012
  .label BGCOL = $d020
  .label SCROLL = $d016
  // @begin
bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
  // @1
b1:
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
main_from_b1:
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
main: {
    .label line = SCREEN+$28
    .label scroll = 2
    .label i = 3
    .label c = 4
    .label nxt = 5
    // [5] call fillscreen 
    // [25] phi from main to fillscreen [phi:main->fillscreen]
  fillscreen_from_main:
    jsr fillscreen
    // [6] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [6] phi (byte*) main::nxt#9 = (const byte*) TEXT#0 [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<TEXT
    sta nxt
    lda #>TEXT
    sta nxt+1
    // [6] phi (byte) main::scroll#7 = (byte) 7 [phi:main->main::@1#1] -- vbuz1=vbuc1 
    lda #7
    sta scroll
    jmp b1
  // Wait for raster
    // [6] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
    jmp b1
    // main::@1
  b1:
    // [7] if(*((const byte*) RASTER#0)!=(byte) $fe) goto main::@1 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$fe
    cmp RASTER
    bne b1_from_b1
    jmp b2
    // main::@2
  b2:
    // [8] if(*((const byte*) RASTER#0)!=(byte) $ff) goto main::@2 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$ff
    cmp RASTER
    bne b2
    jmp b3
    // main::@3
  b3:
    // [9] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
    // [10] (byte) main::scroll#1 ← -- (byte) main::scroll#7 -- vbuz1=_dec_vbuz1 
    dec scroll
    // [11] if((byte) main::scroll#1!=(byte) $ff) goto main::@4 -- vbuz1_neq_vbuc1_then_la1 
    lda #$ff
    cmp scroll
    bne b4_from_b3
    // [12] phi from main::@3 to main::@5 [phi:main::@3->main::@5]
  b5_from_b3:
    // [12] phi (byte) main::i#2 = (byte) 0 [phi:main::@3->main::@5#0] -- vbuz1=vbuc1 
    lda #0
    sta i
    jmp b5
  // Hard scroll
    // [12] phi from main::@5 to main::@5 [phi:main::@5->main::@5]
  b5_from_b5:
    // [12] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@5->main::@5#0] -- register_copy 
    jmp b5
    // main::@5
  b5:
    // [13] *((const byte[]) main::line#0 + (byte) main::i#2) ← *((const byte[]) main::line#0+(byte) 1 + (byte) main::i#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1 
    ldy i
    lda line+1,y
    sta line,y
    // [14] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 
    inc i
    // [15] if((byte) main::i#1!=(byte) $27) goto main::@5 -- vbuz1_neq_vbuc1_then_la1 
    lda #$27
    cmp i
    bne b5_from_b5
    jmp b6
    // main::@6
  b6:
    // [16] (byte) main::c#0 ← *((byte*) main::nxt#9) -- vbuz1=_deref_pbuz2 
    // Render next char
    ldy #0
    lda (nxt),y
    sta c
    // [17] if((byte) main::c#0!=(byte) '@') goto main::@8 -- vbuz1_neq_vbuc1_then_la1 
    lda #'@'
    cmp c
    bne b8_from_b6
    jmp b7
    // main::@7
  b7:
    // [18] (byte) main::c#1 ← *((const byte*) TEXT#0) -- vbuz1=_deref_pbuc1 
    lda TEXT
    sta c
    // [19] phi from main::@7 to main::@8 [phi:main::@7->main::@8]
  b8_from_b7:
    // [19] phi (byte*) main::nxt#4 = (const byte*) TEXT#0 [phi:main::@7->main::@8#0] -- pbuz1=pbuc1 
    lda #<TEXT
    sta nxt
    lda #>TEXT
    sta nxt+1
    // [19] phi (byte) main::c#2 = (byte) main::c#1 [phi:main::@7->main::@8#1] -- register_copy 
    jmp b8
    // [19] phi from main::@6 to main::@8 [phi:main::@6->main::@8]
  b8_from_b6:
    // [19] phi (byte*) main::nxt#4 = (byte*) main::nxt#9 [phi:main::@6->main::@8#0] -- register_copy 
    // [19] phi (byte) main::c#2 = (byte) main::c#0 [phi:main::@6->main::@8#1] -- register_copy 
    jmp b8
    // main::@8
  b8:
    // [20] *((const byte[]) main::line#0+(byte) $27) ← (byte) main::c#2 -- _deref_pbuc1=vbuz1 
    lda c
    sta line+$27
    // [21] (byte*) main::nxt#1 ← ++ (byte*) main::nxt#4 -- pbuz1=_inc_pbuz1 
    inc nxt
    bne !+
    inc nxt+1
  !:
    // [22] phi from main::@8 to main::@4 [phi:main::@8->main::@4]
  b4_from_b8:
    // [22] phi (byte*) main::nxt#10 = (byte*) main::nxt#1 [phi:main::@8->main::@4#0] -- register_copy 
    // [22] phi (byte) main::scroll#4 = (byte) 7 [phi:main::@8->main::@4#1] -- vbuz1=vbuc1 
    lda #7
    sta scroll
    jmp b4
    // [22] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
  b4_from_b3:
    // [22] phi (byte*) main::nxt#10 = (byte*) main::nxt#9 [phi:main::@3->main::@4#0] -- register_copy 
    // [22] phi (byte) main::scroll#4 = (byte) main::scroll#1 [phi:main::@3->main::@4#1] -- register_copy 
    jmp b4
    // main::@4
  b4:
    // [23] *((const byte*) SCROLL#0) ← (byte) main::scroll#4 -- _deref_pbuc1=vbuz1 
    lda scroll
    sta SCROLL
    // [24] *((const byte*) BGCOL#0) ← -- *((const byte*) BGCOL#0) -- _deref_pbuc1=_dec__deref_pbuc1 
    dec BGCOL
    // [6] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
  b1_from_b4:
    // [6] phi (byte*) main::nxt#9 = (byte*) main::nxt#10 [phi:main::@4->main::@1#0] -- register_copy 
    // [6] phi (byte) main::scroll#7 = (byte) main::scroll#4 [phi:main::@4->main::@1#1] -- register_copy 
    jmp b1
}
  // fillscreen
fillscreen: {
    .const fill = $20
    .label cursor = 7
    // [26] phi from fillscreen to fillscreen::@1 [phi:fillscreen->fillscreen::@1]
  b1_from_fillscreen:
    // [26] phi (byte*) fillscreen::cursor#2 = (const byte*) SCREEN#0 [phi:fillscreen->fillscreen::@1#0] -- pbuz1=pbuc1 
    lda #<SCREEN
    sta cursor
    lda #>SCREEN
    sta cursor+1
    jmp b1
    // [26] phi from fillscreen::@1 to fillscreen::@1 [phi:fillscreen::@1->fillscreen::@1]
  b1_from_b1:
    // [26] phi (byte*) fillscreen::cursor#2 = (byte*) fillscreen::cursor#1 [phi:fillscreen::@1->fillscreen::@1#0] -- register_copy 
    jmp b1
    // fillscreen::@1
  b1:
    // [27] *((byte*) fillscreen::cursor#2) ← (const byte) fillscreen::fill#0 -- _deref_pbuz1=vbuc1 
    lda #fill
    ldy #0
    sta (cursor),y
    // [28] (byte*) fillscreen::cursor#1 ← ++ (byte*) fillscreen::cursor#2 -- pbuz1=_inc_pbuz1 
    inc cursor
    bne !+
    inc cursor+1
  !:
    // [29] if((byte*) fillscreen::cursor#1<(const byte*) SCREEN#0+(word) $3e8) goto fillscreen::@1 -- pbuz1_lt_pbuc1_then_la1 
    lda cursor+1
    cmp #>SCREEN+$3e8
    bcc b1_from_b1
    bne !+
    lda cursor
    cmp #<SCREEN+$3e8
    bcc b1_from_b1
  !:
    jmp breturn
    // fillscreen::@return
  breturn:
    // [30] return 
    rts
}
  // File Data
  TEXT: .text "-= this is rex of camelot testing a scroller created in kickc. kickc is an optimizing c-compiler for 6502 assembler. =-     @"

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [7] if(*((const byte*) RASTER#0)!=(byte) $fe) goto main::@1 [ main::scroll#7 main::nxt#9 ] ( main:2 [ main::scroll#7 main::nxt#9 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::scroll#7 main::scroll#4 main::scroll#1 ]
Statement [8] if(*((const byte*) RASTER#0)!=(byte) $ff) goto main::@2 [ main::scroll#7 main::nxt#9 ] ( main:2 [ main::scroll#7 main::nxt#9 ] ) always clobbers reg byte a 
Statement [13] *((const byte[]) main::line#0 + (byte) main::i#2) ← *((const byte[]) main::line#0+(byte) 1 + (byte) main::i#2) [ main::nxt#9 main::i#2 ] ( main:2 [ main::nxt#9 main::i#2 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:3 [ main::i#2 main::i#1 ]
Statement [16] (byte) main::c#0 ← *((byte*) main::nxt#9) [ main::nxt#9 main::c#0 ] ( main:2 [ main::nxt#9 main::c#0 ] ) always clobbers reg byte a reg byte y 
Statement [27] *((byte*) fillscreen::cursor#2) ← (const byte) fillscreen::fill#0 [ fillscreen::cursor#2 ] ( main:2::fillscreen:5 [ fillscreen::cursor#2 ] ) always clobbers reg byte a reg byte y 
Statement [29] if((byte*) fillscreen::cursor#1<(const byte*) SCREEN#0+(word) $3e8) goto fillscreen::@1 [ fillscreen::cursor#1 ] ( main:2::fillscreen:5 [ fillscreen::cursor#1 ] ) always clobbers reg byte a 
Statement [7] if(*((const byte*) RASTER#0)!=(byte) $fe) goto main::@1 [ main::scroll#7 main::nxt#9 ] ( main:2 [ main::scroll#7 main::nxt#9 ] ) always clobbers reg byte a 
Statement [8] if(*((const byte*) RASTER#0)!=(byte) $ff) goto main::@2 [ main::scroll#7 main::nxt#9 ] ( main:2 [ main::scroll#7 main::nxt#9 ] ) always clobbers reg byte a 
Statement [13] *((const byte[]) main::line#0 + (byte) main::i#2) ← *((const byte[]) main::line#0+(byte) 1 + (byte) main::i#2) [ main::nxt#9 main::i#2 ] ( main:2 [ main::nxt#9 main::i#2 ] ) always clobbers reg byte a 
Statement [16] (byte) main::c#0 ← *((byte*) main::nxt#9) [ main::nxt#9 main::c#0 ] ( main:2 [ main::nxt#9 main::c#0 ] ) always clobbers reg byte a reg byte y 
Statement [27] *((byte*) fillscreen::cursor#2) ← (const byte) fillscreen::fill#0 [ fillscreen::cursor#2 ] ( main:2::fillscreen:5 [ fillscreen::cursor#2 ] ) always clobbers reg byte a reg byte y 
Statement [29] if((byte*) fillscreen::cursor#1<(const byte*) SCREEN#0+(word) $3e8) goto fillscreen::@1 [ fillscreen::cursor#1 ] ( main:2::fillscreen:5 [ fillscreen::cursor#1 ] ) always clobbers reg byte a 
Potential registers zp ZP_BYTE:2 [ main::scroll#7 main::scroll#4 main::scroll#1 ] : zp ZP_BYTE:2 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:3 [ main::i#2 main::i#1 ] : zp ZP_BYTE:3 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:4 [ main::c#2 main::c#1 main::c#0 ] : zp ZP_BYTE:4 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_WORD:5 [ main::nxt#4 main::nxt#9 main::nxt#10 main::nxt#1 ] : zp ZP_WORD:5 , 
Potential registers zp ZP_WORD:7 [ fillscreen::cursor#2 fillscreen::cursor#1 ] : zp ZP_WORD:7 , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 353.5: zp ZP_BYTE:3 [ main::i#2 main::i#1 ] 71.5: zp ZP_BYTE:4 [ main::c#2 main::c#1 main::c#0 ] 47.67: zp ZP_WORD:5 [ main::nxt#4 main::nxt#9 main::nxt#10 main::nxt#1 ] 33: zp ZP_BYTE:2 [ main::scroll#7 main::scroll#4 main::scroll#1 ] 
Uplift Scope [fillscreen] 33: zp ZP_WORD:7 [ fillscreen::cursor#2 fillscreen::cursor#1 ] 
Uplift Scope [] 

Uplifting [main] best 8554 combination reg byte x [ main::i#2 main::i#1 ] reg byte x [ main::c#2 main::c#1 main::c#0 ] zp ZP_WORD:5 [ main::nxt#4 main::nxt#9 main::nxt#10 main::nxt#1 ] reg byte x [ main::scroll#7 main::scroll#4 main::scroll#1 ] 
Uplifting [fillscreen] best 8554 combination zp ZP_WORD:7 [ fillscreen::cursor#2 fillscreen::cursor#1 ] 
Uplifting [] best 8554 combination 
Allocated (was zp ZP_WORD:5) zp ZP_WORD:2 [ main::nxt#4 main::nxt#9 main::nxt#10 main::nxt#1 ]
Allocated (was zp ZP_WORD:7) zp ZP_WORD:4 [ fillscreen::cursor#2 fillscreen::cursor#1 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  .label RASTER = $d012
  .label BGCOL = $d020
  .label SCROLL = $d016
  // @begin
bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
  // @1
b1:
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
main_from_b1:
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
main: {
    .label line = SCREEN+$28
    .label nxt = 2
    // [5] call fillscreen 
    // [25] phi from main to fillscreen [phi:main->fillscreen]
  fillscreen_from_main:
    jsr fillscreen
    // [6] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [6] phi (byte*) main::nxt#9 = (const byte*) TEXT#0 [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<TEXT
    sta nxt
    lda #>TEXT
    sta nxt+1
    // [6] phi (byte) main::scroll#7 = (byte) 7 [phi:main->main::@1#1] -- vbuxx=vbuc1 
    ldx #7
    jmp b1
  // Wait for raster
    // [6] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
    jmp b1
    // main::@1
  b1:
    // [7] if(*((const byte*) RASTER#0)!=(byte) $fe) goto main::@1 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$fe
    cmp RASTER
    bne b1_from_b1
    jmp b2
    // main::@2
  b2:
    // [8] if(*((const byte*) RASTER#0)!=(byte) $ff) goto main::@2 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$ff
    cmp RASTER
    bne b2
    jmp b3
    // main::@3
  b3:
    // [9] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
    // [10] (byte) main::scroll#1 ← -- (byte) main::scroll#7 -- vbuxx=_dec_vbuxx 
    dex
    // [11] if((byte) main::scroll#1!=(byte) $ff) goto main::@4 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$ff
    bne b4_from_b3
    // [12] phi from main::@3 to main::@5 [phi:main::@3->main::@5]
  b5_from_b3:
    // [12] phi (byte) main::i#2 = (byte) 0 [phi:main::@3->main::@5#0] -- vbuxx=vbuc1 
    ldx #0
    jmp b5
  // Hard scroll
    // [12] phi from main::@5 to main::@5 [phi:main::@5->main::@5]
  b5_from_b5:
    // [12] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@5->main::@5#0] -- register_copy 
    jmp b5
    // main::@5
  b5:
    // [13] *((const byte[]) main::line#0 + (byte) main::i#2) ← *((const byte[]) main::line#0+(byte) 1 + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx 
    lda line+1,x
    sta line,x
    // [14] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [15] if((byte) main::i#1!=(byte) $27) goto main::@5 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$27
    bne b5_from_b5
    jmp b6
    // main::@6
  b6:
    // [16] (byte) main::c#0 ← *((byte*) main::nxt#9) -- vbuxx=_deref_pbuz1 
    // Render next char
    ldy #0
    lda (nxt),y
    tax
    // [17] if((byte) main::c#0!=(byte) '@') goto main::@8 -- vbuxx_neq_vbuc1_then_la1 
    cpx #'@'
    bne b8_from_b6
    jmp b7
    // main::@7
  b7:
    // [18] (byte) main::c#1 ← *((const byte*) TEXT#0) -- vbuxx=_deref_pbuc1 
    ldx TEXT
    // [19] phi from main::@7 to main::@8 [phi:main::@7->main::@8]
  b8_from_b7:
    // [19] phi (byte*) main::nxt#4 = (const byte*) TEXT#0 [phi:main::@7->main::@8#0] -- pbuz1=pbuc1 
    lda #<TEXT
    sta nxt
    lda #>TEXT
    sta nxt+1
    // [19] phi (byte) main::c#2 = (byte) main::c#1 [phi:main::@7->main::@8#1] -- register_copy 
    jmp b8
    // [19] phi from main::@6 to main::@8 [phi:main::@6->main::@8]
  b8_from_b6:
    // [19] phi (byte*) main::nxt#4 = (byte*) main::nxt#9 [phi:main::@6->main::@8#0] -- register_copy 
    // [19] phi (byte) main::c#2 = (byte) main::c#0 [phi:main::@6->main::@8#1] -- register_copy 
    jmp b8
    // main::@8
  b8:
    // [20] *((const byte[]) main::line#0+(byte) $27) ← (byte) main::c#2 -- _deref_pbuc1=vbuxx 
    stx line+$27
    // [21] (byte*) main::nxt#1 ← ++ (byte*) main::nxt#4 -- pbuz1=_inc_pbuz1 
    inc nxt
    bne !+
    inc nxt+1
  !:
    // [22] phi from main::@8 to main::@4 [phi:main::@8->main::@4]
  b4_from_b8:
    // [22] phi (byte*) main::nxt#10 = (byte*) main::nxt#1 [phi:main::@8->main::@4#0] -- register_copy 
    // [22] phi (byte) main::scroll#4 = (byte) 7 [phi:main::@8->main::@4#1] -- vbuxx=vbuc1 
    ldx #7
    jmp b4
    // [22] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
  b4_from_b3:
    // [22] phi (byte*) main::nxt#10 = (byte*) main::nxt#9 [phi:main::@3->main::@4#0] -- register_copy 
    // [22] phi (byte) main::scroll#4 = (byte) main::scroll#1 [phi:main::@3->main::@4#1] -- register_copy 
    jmp b4
    // main::@4
  b4:
    // [23] *((const byte*) SCROLL#0) ← (byte) main::scroll#4 -- _deref_pbuc1=vbuxx 
    stx SCROLL
    // [24] *((const byte*) BGCOL#0) ← -- *((const byte*) BGCOL#0) -- _deref_pbuc1=_dec__deref_pbuc1 
    dec BGCOL
    // [6] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
  b1_from_b4:
    // [6] phi (byte*) main::nxt#9 = (byte*) main::nxt#10 [phi:main::@4->main::@1#0] -- register_copy 
    // [6] phi (byte) main::scroll#7 = (byte) main::scroll#4 [phi:main::@4->main::@1#1] -- register_copy 
    jmp b1
}
  // fillscreen
fillscreen: {
    .const fill = $20
    .label cursor = 4
    // [26] phi from fillscreen to fillscreen::@1 [phi:fillscreen->fillscreen::@1]
  b1_from_fillscreen:
    // [26] phi (byte*) fillscreen::cursor#2 = (const byte*) SCREEN#0 [phi:fillscreen->fillscreen::@1#0] -- pbuz1=pbuc1 
    lda #<SCREEN
    sta cursor
    lda #>SCREEN
    sta cursor+1
    jmp b1
    // [26] phi from fillscreen::@1 to fillscreen::@1 [phi:fillscreen::@1->fillscreen::@1]
  b1_from_b1:
    // [26] phi (byte*) fillscreen::cursor#2 = (byte*) fillscreen::cursor#1 [phi:fillscreen::@1->fillscreen::@1#0] -- register_copy 
    jmp b1
    // fillscreen::@1
  b1:
    // [27] *((byte*) fillscreen::cursor#2) ← (const byte) fillscreen::fill#0 -- _deref_pbuz1=vbuc1 
    lda #fill
    ldy #0
    sta (cursor),y
    // [28] (byte*) fillscreen::cursor#1 ← ++ (byte*) fillscreen::cursor#2 -- pbuz1=_inc_pbuz1 
    inc cursor
    bne !+
    inc cursor+1
  !:
    // [29] if((byte*) fillscreen::cursor#1<(const byte*) SCREEN#0+(word) $3e8) goto fillscreen::@1 -- pbuz1_lt_pbuc1_then_la1 
    lda cursor+1
    cmp #>SCREEN+$3e8
    bcc b1_from_b1
    bne !+
    lda cursor
    cmp #<SCREEN+$3e8
    bcc b1_from_b1
  !:
    jmp breturn
    // fillscreen::@return
  breturn:
    // [30] return 
    rts
}
  // File Data
  TEXT: .text "-= this is rex of camelot testing a scroller created in kickc. kickc is an optimizing c-compiler for 6502 assembler. =-     @"

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp b3
Removing instruction jmp b5
Removing instruction jmp b6
Removing instruction jmp b7
Removing instruction jmp b8
Removing instruction jmp b4
Removing instruction jmp b1
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b1_from_b1 with b1
Replacing label b4_from_b3 with b4
Replacing label b5_from_b5 with b5
Replacing label b8_from_b6 with b8
Replacing label b1_from_b1 with b1
Replacing label b1_from_b1 with b1
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_b1:
Removing instruction b5_from_b5:
Removing instruction b8_from_b6:
Removing instruction b4_from_b3:
Removing instruction b1_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction fillscreen_from_main:
Removing instruction b1_from_main:
Removing instruction b3:
Removing instruction b5_from_b3:
Removing instruction b6:
Removing instruction b7:
Removing instruction b8_from_b7:
Removing instruction b4_from_b8:
Removing instruction b1_from_b4:
Removing instruction b1_from_fillscreen:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction jmp b1
Removing instruction jmp b5
Removing instruction jmp b8
Removing instruction jmp b4
Removing instruction jmp b1
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte*) BGCOL
(const byte*) BGCOL#0 BGCOL = (byte*) 53280
(byte*) RASTER
(const byte*) RASTER#0 RASTER = (byte*) 53266
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
(byte*) SCROLL
(const byte*) SCROLL#0 SCROLL = (byte*) 53270
(byte*) TEXT
(const byte*) TEXT#0 TEXT = (string) "-= this is rex of camelot testing a scroller created in kickc. kickc is an optimizing c-compiler for 6502 assembler. =-     @"
(void()) fillscreen((byte*) fillscreen::screen , (byte) fillscreen::fill)
(label) fillscreen::@1
(label) fillscreen::@return
(byte*) fillscreen::cursor
(byte*) fillscreen::cursor#1 cursor zp ZP_WORD:4 16.5
(byte*) fillscreen::cursor#2 cursor zp ZP_WORD:4 16.5
(byte) fillscreen::fill
(const byte) fillscreen::fill#0 fill = (byte) $20
(byte*) fillscreen::screen
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@7
(label) main::@8
(byte) main::c
(byte) main::c#0 reg byte x 16.5
(byte) main::c#1 reg byte x 22.0
(byte) main::c#2 reg byte x 33.0
(byte) main::i
(byte) main::i#1 reg byte x 151.5
(byte) main::i#2 reg byte x 202.0
(byte[]) main::line
(const byte[]) main::line#0 line = (const byte*) SCREEN#0+(byte) $28
(byte*) main::nxt
(byte*) main::nxt#1 nxt zp ZP_WORD:2 22.0
(byte*) main::nxt#10 nxt zp ZP_WORD:2 11.0
(byte*) main::nxt#4 nxt zp ZP_WORD:2 11.0
(byte*) main::nxt#9 nxt zp ZP_WORD:2 3.6666666666666665
(byte) main::scroll
(byte) main::scroll#1 reg byte x 16.5
(byte) main::scroll#4 reg byte x 11.0
(byte) main::scroll#7 reg byte x 5.5

reg byte x [ main::scroll#7 main::scroll#4 main::scroll#1 ]
reg byte x [ main::i#2 main::i#1 ]
reg byte x [ main::c#2 main::c#1 main::c#0 ]
zp ZP_WORD:2 [ main::nxt#4 main::nxt#9 main::nxt#10 main::nxt#1 ]
zp ZP_WORD:4 [ fillscreen::cursor#2 fillscreen::cursor#1 ]


FINAL ASSEMBLER
Score: 6202

  // File Comments
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  .label RASTER = $d012
  .label BGCOL = $d020
  .label SCROLL = $d016
  // @begin
  // [1] phi from @begin to @1 [phi:@begin->@1]
  // @1
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    .label line = SCREEN+$28
    .label nxt = 2
    // fillscreen(SCREEN, $20)
    // [5] call fillscreen 
    // [25] phi from main to fillscreen [phi:main->fillscreen]
    jsr fillscreen
    // [6] phi from main to main::@1 [phi:main->main::@1]
    // [6] phi (byte*) main::nxt#9 = (const byte*) TEXT#0 [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<TEXT
    sta nxt
    lda #>TEXT
    sta nxt+1
    // [6] phi (byte) main::scroll#7 = (byte) 7 [phi:main->main::@1#1] -- vbuxx=vbuc1 
    ldx #7
  // Wait for raster
    // [6] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
    // main::@1
  b1:
    // while(*RASTER!=$fe)
    // [7] if(*((const byte*) RASTER#0)!=(byte) $fe) goto main::@1 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$fe
    cmp RASTER
    bne b1
    // main::@2
  b2:
    // while(*RASTER!=$ff)
    // [8] if(*((const byte*) RASTER#0)!=(byte) $ff) goto main::@2 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$ff
    cmp RASTER
    bne b2
    // main::@3
    // ++*BGCOL;
    // [9] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
    // if(--scroll==$ff)
    // [10] (byte) main::scroll#1 ← -- (byte) main::scroll#7 -- vbuxx=_dec_vbuxx 
    dex
    // [11] if((byte) main::scroll#1!=(byte) $ff) goto main::@4 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$ff
    bne b4
    // [12] phi from main::@3 to main::@5 [phi:main::@3->main::@5]
    // [12] phi (byte) main::i#2 = (byte) 0 [phi:main::@3->main::@5#0] -- vbuxx=vbuc1 
    ldx #0
  // Hard scroll
    // [12] phi from main::@5 to main::@5 [phi:main::@5->main::@5]
    // [12] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@5->main::@5#0] -- register_copy 
    // main::@5
  b5:
    // line[i]=line[i+1]
    // [13] *((const byte[]) main::line#0 + (byte) main::i#2) ← *((const byte[]) main::line#0+(byte) 1 + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx 
    lda line+1,x
    sta line,x
    // for(byte i=0;i!=39;i++)
    // [14] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [15] if((byte) main::i#1!=(byte) $27) goto main::@5 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$27
    bne b5
    // main::@6
    // c = *nxt
    // [16] (byte) main::c#0 ← *((byte*) main::nxt#9) -- vbuxx=_deref_pbuz1 
    // Render next char
    ldy #0
    lda (nxt),y
    tax
    // if(c=='@')
    // [17] if((byte) main::c#0!=(byte) '@') goto main::@8 -- vbuxx_neq_vbuc1_then_la1 
    cpx #'@'
    bne b8
    // main::@7
    // c = *nxt
    // [18] (byte) main::c#1 ← *((const byte*) TEXT#0) -- vbuxx=_deref_pbuc1 
    ldx TEXT
    // [19] phi from main::@7 to main::@8 [phi:main::@7->main::@8]
    // [19] phi (byte*) main::nxt#4 = (const byte*) TEXT#0 [phi:main::@7->main::@8#0] -- pbuz1=pbuc1 
    lda #<TEXT
    sta nxt
    lda #>TEXT
    sta nxt+1
    // [19] phi (byte) main::c#2 = (byte) main::c#1 [phi:main::@7->main::@8#1] -- register_copy 
    // [19] phi from main::@6 to main::@8 [phi:main::@6->main::@8]
    // [19] phi (byte*) main::nxt#4 = (byte*) main::nxt#9 [phi:main::@6->main::@8#0] -- register_copy 
    // [19] phi (byte) main::c#2 = (byte) main::c#0 [phi:main::@6->main::@8#1] -- register_copy 
    // main::@8
  b8:
    // line[39] = c
    // [20] *((const byte[]) main::line#0+(byte) $27) ← (byte) main::c#2 -- _deref_pbuc1=vbuxx 
    stx line+$27
    // nxt++;
    // [21] (byte*) main::nxt#1 ← ++ (byte*) main::nxt#4 -- pbuz1=_inc_pbuz1 
    inc nxt
    bne !+
    inc nxt+1
  !:
    // [22] phi from main::@8 to main::@4 [phi:main::@8->main::@4]
    // [22] phi (byte*) main::nxt#10 = (byte*) main::nxt#1 [phi:main::@8->main::@4#0] -- register_copy 
    // [22] phi (byte) main::scroll#4 = (byte) 7 [phi:main::@8->main::@4#1] -- vbuxx=vbuc1 
    ldx #7
    // [22] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
    // [22] phi (byte*) main::nxt#10 = (byte*) main::nxt#9 [phi:main::@3->main::@4#0] -- register_copy 
    // [22] phi (byte) main::scroll#4 = (byte) main::scroll#1 [phi:main::@3->main::@4#1] -- register_copy 
    // main::@4
  b4:
    // *SCROLL = scroll
    // [23] *((const byte*) SCROLL#0) ← (byte) main::scroll#4 -- _deref_pbuc1=vbuxx 
    stx SCROLL
    // --*BGCOL;
    // [24] *((const byte*) BGCOL#0) ← -- *((const byte*) BGCOL#0) -- _deref_pbuc1=_dec__deref_pbuc1 
    dec BGCOL
    // [6] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
    // [6] phi (byte*) main::nxt#9 = (byte*) main::nxt#10 [phi:main::@4->main::@1#0] -- register_copy 
    // [6] phi (byte) main::scroll#7 = (byte) main::scroll#4 [phi:main::@4->main::@1#1] -- register_copy 
    jmp b1
}
  // fillscreen
fillscreen: {
    .const fill = $20
    .label cursor = 4
    // [26] phi from fillscreen to fillscreen::@1 [phi:fillscreen->fillscreen::@1]
    // [26] phi (byte*) fillscreen::cursor#2 = (const byte*) SCREEN#0 [phi:fillscreen->fillscreen::@1#0] -- pbuz1=pbuc1 
    lda #<SCREEN
    sta cursor
    lda #>SCREEN
    sta cursor+1
    // [26] phi from fillscreen::@1 to fillscreen::@1 [phi:fillscreen::@1->fillscreen::@1]
    // [26] phi (byte*) fillscreen::cursor#2 = (byte*) fillscreen::cursor#1 [phi:fillscreen::@1->fillscreen::@1#0] -- register_copy 
    // fillscreen::@1
  b1:
    // *cursor = fill
    // [27] *((byte*) fillscreen::cursor#2) ← (const byte) fillscreen::fill#0 -- _deref_pbuz1=vbuc1 
    lda #fill
    ldy #0
    sta (cursor),y
    // for( byte* cursor = screen; cursor < screen+1000; cursor++)
    // [28] (byte*) fillscreen::cursor#1 ← ++ (byte*) fillscreen::cursor#2 -- pbuz1=_inc_pbuz1 
    inc cursor
    bne !+
    inc cursor+1
  !:
    // [29] if((byte*) fillscreen::cursor#1<(const byte*) SCREEN#0+(word) $3e8) goto fillscreen::@1 -- pbuz1_lt_pbuc1_then_la1 
    lda cursor+1
    cmp #>SCREEN+$3e8
    bcc b1
    bne !+
    lda cursor
    cmp #<SCREEN+$3e8
    bcc b1
  !:
    // fillscreen::@return
    // }
    // [30] return 
    rts
}
  // File Data
  TEXT: .text "-= this is rex of camelot testing a scroller created in kickc. kickc is an optimizing c-compiler for 6502 assembler. =-     @"

