PARSING src/test/java/dk/camelot64/kickc/test/kc/ptr-complex.kc
// Test some complex pointers

void main() {

    // RValue pointer expression (constant)
    byte* screen = $0400;
    byte a = *(screen+80);

    // RValue pointer expression (variable)
    for(byte i : 0..10) {
        screen[i] = *(screen+40+i);
    }

    // LValue pointer expression (constant - through tmp variable)
    byte* sc2 = screen+81;
    *sc2 = *(screen+121);

    // LValue pointer expression (constant - directly)
    *(screen+82) = *(screen+122);

    // LValue pointer expression (variable - directly)
    for(byte j : 0..10) {
        *(screen+160+j) = *(screen+200+j);
    }

    // Incrementing directly on a word
    ++*(byte*)$d020;
    --*(byte*)($d000+$21);

    // Increment on a const named pointer
    byte* BGCOL = $d020;
    ++*BGCOL;


}
Adding pre/post-modifier *((var) main::$13) ← ++ *((var) main::$13)
Adding pre/post-modifier *((var) main::$17) ← -- *((var) main::$17)
Adding pre/post-modifier *((byte*) main::BGCOL) ← ++ *((byte*) main::BGCOL)

STATEMENTS
proc (void()) main()
  (byte*) main::screen ← (word/signed word/dword/signed dword) 1024
  (byte*~) main::$0 ← (byte*) main::screen + (byte/signed byte/word/signed word/dword/signed dword) 80
  (byte) main::a ← *((byte*~) main::$0)
  (byte) main::i ← (byte/signed byte/word/signed word/dword/signed dword) 0
main::@1:
  (byte*~) main::$1 ← (byte*) main::screen + (byte/signed byte/word/signed word/dword/signed dword) 40
  (byte*~) main::$2 ← (byte*~) main::$1 + (byte) main::i
  *((byte*) main::screen + (byte) main::i) ← *((byte*~) main::$2)
  (byte) main::i ← ++ (byte) main::i
  (boolean~) main::$3 ← (byte) main::i != (byte/signed byte/word/signed word/dword/signed dword) 11
  if((boolean~) main::$3) goto main::@1
  (byte*~) main::$4 ← (byte*) main::screen + (byte/signed byte/word/signed word/dword/signed dword) 81
  (byte*) main::sc2 ← (byte*~) main::$4
  (byte*~) main::$5 ← (byte*) main::screen + (byte/signed byte/word/signed word/dword/signed dword) 121
  *((byte*) main::sc2) ← *((byte*~) main::$5)
  (byte*~) main::$6 ← (byte*) main::screen + (byte/signed byte/word/signed word/dword/signed dword) 82
  (byte*~) main::$7 ← (byte*) main::screen + (byte/signed byte/word/signed word/dword/signed dword) 122
  *((byte*~) main::$6) ← *((byte*~) main::$7)
  (byte) main::j ← (byte/signed byte/word/signed word/dword/signed dword) 0
main::@2:
  (byte*~) main::$8 ← (byte*) main::screen + (byte/word/signed word/dword/signed dword) 160
  (byte*~) main::$9 ← (byte*~) main::$8 + (byte) main::j
  (byte*~) main::$10 ← (byte*) main::screen + (byte/word/signed word/dword/signed dword) 200
  (byte*~) main::$11 ← (byte*~) main::$10 + (byte) main::j
  *((byte*~) main::$9) ← *((byte*~) main::$11)
  (byte) main::j ← ++ (byte) main::j
  (boolean~) main::$12 ← (byte) main::j != (byte/signed byte/word/signed word/dword/signed dword) 11
  if((boolean~) main::$12) goto main::@2
  (byte*~) main::$13 ← ((byte*)) (word/dword/signed dword) 53280
  *((byte*~) main::$13) ← ++ *((byte*~) main::$13)
  (byte*~) main::$14 ← ((byte*)) (word/dword/signed dword) 53280
  (byte*~) main::$15 ← ((byte*)) (word/dword/signed dword) 53280
  (word/dword/signed dword~) main::$16 ← (word/dword/signed dword) 53248 + (byte/signed byte/word/signed word/dword/signed dword) 33
  (byte*~) main::$17 ← ((byte*)) (word/dword/signed dword~) main::$16
  *((byte*~) main::$17) ← -- *((byte*~) main::$17)
  (word/dword/signed dword~) main::$18 ← (word/dword/signed dword) 53248 + (byte/signed byte/word/signed word/dword/signed dword) 33
  (byte*~) main::$19 ← ((byte*)) (word/dword/signed dword~) main::$18
  (word/dword/signed dword~) main::$20 ← (word/dword/signed dword) 53248 + (byte/signed byte/word/signed word/dword/signed dword) 33
  (byte*~) main::$21 ← ((byte*)) (word/dword/signed dword~) main::$20
  (byte*) main::BGCOL ← (word/dword/signed dword) 53280
  *((byte*) main::BGCOL) ← ++ *((byte*) main::BGCOL)
main::@return:
  return 
endproc // main()
  call main 

SYMBOLS
(void()) main()
(byte*~) main::$0
(byte*~) main::$1
(byte*~) main::$10
(byte*~) main::$11
(boolean~) main::$12
(byte*~) main::$13
(byte*~) main::$14
(byte*~) main::$15
(word/dword/signed dword~) main::$16
(byte*~) main::$17
(word/dword/signed dword~) main::$18
(byte*~) main::$19
(byte*~) main::$2
(word/dword/signed dword~) main::$20
(byte*~) main::$21
(boolean~) main::$3
(byte*~) main::$4
(byte*~) main::$5
(byte*~) main::$6
(byte*~) main::$7
(byte*~) main::$8
(byte*~) main::$9
(label) main::@1
(label) main::@2
(label) main::@return
(byte*) main::BGCOL
(byte) main::a
(byte) main::i
(byte) main::j
(byte*) main::sc2
(byte*) main::screen

Promoting word/signed word/dword/signed dword to byte* in main::screen ← ((byte*)) 1024
Promoting word/dword/signed dword to byte* in main::BGCOL ← ((byte*)) 53280
INITIAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  to:@1
main: scope:[main]  from
  (byte*) main::screen ← ((byte*)) (word/signed word/dword/signed dword) 1024
  (byte*~) main::$0 ← (byte*) main::screen + (byte/signed byte/word/signed word/dword/signed dword) 80
  (byte) main::a ← *((byte*~) main::$0)
  (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*~) main::$1 ← (byte*) main::screen + (byte/signed byte/word/signed word/dword/signed dword) 40
  (byte*~) main::$2 ← (byte*~) main::$1 + (byte) main::i
  *((byte*) main::screen + (byte) main::i) ← *((byte*~) main::$2)
  (byte) main::i ← ++ (byte) main::i
  (boolean~) main::$3 ← (byte) main::i != (byte/signed byte/word/signed word/dword/signed dword) 11
  if((boolean~) main::$3) goto main::@1
  to:main::@3
main::@3: scope:[main]  from main::@1
  (byte*~) main::$4 ← (byte*) main::screen + (byte/signed byte/word/signed word/dword/signed dword) 81
  (byte*) main::sc2 ← (byte*~) main::$4
  (byte*~) main::$5 ← (byte*) main::screen + (byte/signed byte/word/signed word/dword/signed dword) 121
  *((byte*) main::sc2) ← *((byte*~) main::$5)
  (byte*~) main::$6 ← (byte*) main::screen + (byte/signed byte/word/signed word/dword/signed dword) 82
  (byte*~) main::$7 ← (byte*) main::screen + (byte/signed byte/word/signed word/dword/signed dword) 122
  *((byte*~) main::$6) ← *((byte*~) main::$7)
  (byte) main::j ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:main::@2
main::@2: scope:[main]  from main::@2 main::@3
  (byte*~) main::$8 ← (byte*) main::screen + (byte/word/signed word/dword/signed dword) 160
  (byte*~) main::$9 ← (byte*~) main::$8 + (byte) main::j
  (byte*~) main::$10 ← (byte*) main::screen + (byte/word/signed word/dword/signed dword) 200
  (byte*~) main::$11 ← (byte*~) main::$10 + (byte) main::j
  *((byte*~) main::$9) ← *((byte*~) main::$11)
  (byte) main::j ← ++ (byte) main::j
  (boolean~) main::$12 ← (byte) main::j != (byte/signed byte/word/signed word/dword/signed dword) 11
  if((boolean~) main::$12) goto main::@2
  to:main::@4
main::@4: scope:[main]  from main::@2
  (byte*~) main::$13 ← ((byte*)) (word/dword/signed dword) 53280
  *((byte*~) main::$13) ← ++ *((byte*~) main::$13)
  (byte*~) main::$14 ← ((byte*)) (word/dword/signed dword) 53280
  (byte*~) main::$15 ← ((byte*)) (word/dword/signed dword) 53280
  (word/dword/signed dword~) main::$16 ← (word/dword/signed dword) 53248 + (byte/signed byte/word/signed word/dword/signed dword) 33
  (byte*~) main::$17 ← ((byte*)) (word/dword/signed dword~) main::$16
  *((byte*~) main::$17) ← -- *((byte*~) main::$17)
  (word/dword/signed dword~) main::$18 ← (word/dword/signed dword) 53248 + (byte/signed byte/word/signed word/dword/signed dword) 33
  (byte*~) main::$19 ← ((byte*)) (word/dword/signed dword~) main::$18
  (word/dword/signed dword~) main::$20 ← (word/dword/signed dword) 53248 + (byte/signed byte/word/signed word/dword/signed dword) 33
  (byte*~) main::$21 ← ((byte*)) (word/dword/signed dword~) main::$20
  (byte*) main::BGCOL ← ((byte*)) (word/dword/signed dword) 53280
  *((byte*) main::BGCOL) ← ++ *((byte*) main::BGCOL)
  to:main::@return
main::@return: scope:[main]  from main::@4
  return 
  to:@return
@1: scope:[]  from @begin
  call main 
  to:@end
@end: scope:[]  from @1

Eliminating unused variable (byte) main::a and assignment [2] (byte) main::a ← *((byte*~) main::$0)
Eliminating unused variable (byte*~) main::$14 and assignment [28] (byte*~) main::$14 ← ((byte*)) (word/dword/signed dword) 53280
Eliminating unused variable (byte*~) main::$15 and assignment [29] (byte*~) main::$15 ← ((byte*)) (word/dword/signed dword) 53280
Eliminating unused variable (byte*~) main::$19 and assignment [34] (byte*~) main::$19 ← ((byte*)) (word/dword/signed dword~) main::$18
Eliminating unused variable (byte*~) main::$21 and assignment [36] (byte*~) main::$21 ← ((byte*)) (word/dword/signed dword~) main::$20
Eliminating unused variable (byte*~) main::$0 and assignment [1] (byte*~) main::$0 ← (byte*) main::screen + (byte/signed byte/word/signed word/dword/signed dword) 80
Eliminating unused variable (word/dword/signed dword~) main::$18 and assignment [30] (word/dword/signed dword~) main::$18 ← (word/dword/signed dword) 53248 + (byte/signed byte/word/signed word/dword/signed dword) 33
Eliminating unused variable (word/dword/signed dword~) main::$20 and assignment [31] (word/dword/signed dword~) main::$20 ← (word/dword/signed dword) 53248 + (byte/signed byte/word/signed word/dword/signed dword) 33
PROCEDURE MODIFY VARIABLE ANALYSIS

Completing Phi functions...

CONTROL FLOW GRAPH SSA WITH ASSIGNMENT CALL & RETURN
@begin: scope:[]  from
  to:@1
main: scope:[main]  from @1
  (byte*) main::screen#0 ← ((byte*)) (word/signed word/dword/signed dword) 1024
  (byte) main::i#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:main::@1
main::@1: scope:[main]  from main main::@1
  (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
  (byte*) main::screen#1 ← phi( main/(byte*) main::screen#0 main::@1/(byte*) main::screen#1 )
  (byte*~) main::$1 ← (byte*) main::screen#1 + (byte/signed byte/word/signed word/dword/signed dword) 40
  (byte*~) main::$2 ← (byte*~) main::$1 + (byte) main::i#2
  *((byte*) main::screen#1 + (byte) main::i#2) ← *((byte*~) main::$2)
  (byte) main::i#1 ← ++ (byte) main::i#2
  (boolean~) main::$3 ← (byte) main::i#1 != (byte/signed byte/word/signed word/dword/signed dword) 11
  if((boolean~) main::$3) goto main::@1
  to:main::@3
main::@3: scope:[main]  from main::@1
  (byte*) main::screen#2 ← phi( main::@1/(byte*) main::screen#1 )
  (byte*~) main::$4 ← (byte*) main::screen#2 + (byte/signed byte/word/signed word/dword/signed dword) 81
  (byte*) main::sc2#0 ← (byte*~) main::$4
  (byte*~) main::$5 ← (byte*) main::screen#2 + (byte/signed byte/word/signed word/dword/signed dword) 121
  *((byte*) main::sc2#0) ← *((byte*~) main::$5)
  (byte*~) main::$6 ← (byte*) main::screen#2 + (byte/signed byte/word/signed word/dword/signed dword) 82
  (byte*~) main::$7 ← (byte*) main::screen#2 + (byte/signed byte/word/signed word/dword/signed dword) 122
  *((byte*~) main::$6) ← *((byte*~) main::$7)
  (byte) main::j#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:main::@2
main::@2: scope:[main]  from main::@2 main::@3
  (byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@3/(byte) main::j#0 )
  (byte*) main::screen#3 ← phi( main::@2/(byte*) main::screen#3 main::@3/(byte*) main::screen#2 )
  (byte*~) main::$8 ← (byte*) main::screen#3 + (byte/word/signed word/dword/signed dword) 160
  (byte*~) main::$9 ← (byte*~) main::$8 + (byte) main::j#2
  (byte*~) main::$10 ← (byte*) main::screen#3 + (byte/word/signed word/dword/signed dword) 200
  (byte*~) main::$11 ← (byte*~) main::$10 + (byte) main::j#2
  *((byte*~) main::$9) ← *((byte*~) main::$11)
  (byte) main::j#1 ← ++ (byte) main::j#2
  (boolean~) main::$12 ← (byte) main::j#1 != (byte/signed byte/word/signed word/dword/signed dword) 11
  if((boolean~) main::$12) goto main::@2
  to:main::@4
main::@4: scope:[main]  from main::@2
  (byte*~) main::$13 ← ((byte*)) (word/dword/signed dword) 53280
  *((byte*~) main::$13) ← ++ *((byte*~) main::$13)
  (word/dword/signed dword~) main::$16 ← (word/dword/signed dword) 53248 + (byte/signed byte/word/signed word/dword/signed dword) 33
  (byte*~) main::$17 ← ((byte*)) (word/dword/signed dword~) main::$16
  *((byte*~) main::$17) ← -- *((byte*~) main::$17)
  (byte*) main::BGCOL#0 ← ((byte*)) (word/dword/signed dword) 53280
  *((byte*) main::BGCOL#0) ← ++ *((byte*) main::BGCOL#0)
  to:main::@return
main::@return: scope:[main]  from main::@4
  return 
  to:@return
@1: scope:[]  from @begin
  call main param-assignment
  to:@2
@2: scope:[]  from @1
  to:@end
@end: scope:[]  from @2

SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(void()) main()
(byte*~) main::$1
(byte*~) main::$10
(byte*~) main::$11
(boolean~) main::$12
(byte*~) main::$13
(word/dword/signed dword~) main::$16
(byte*~) main::$17
(byte*~) main::$2
(boolean~) main::$3
(byte*~) main::$4
(byte*~) main::$5
(byte*~) main::$6
(byte*~) main::$7
(byte*~) main::$8
(byte*~) main::$9
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@return
(byte*) main::BGCOL
(byte*) main::BGCOL#0
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(byte) main::j
(byte) main::j#0
(byte) main::j#1
(byte) main::j#2
(byte*) main::sc2
(byte*) main::sc2#0
(byte*) main::screen
(byte*) main::screen#0
(byte*) main::screen#1
(byte*) main::screen#2
(byte*) main::screen#3

OPTIMIZING CONTROL FLOW GRAPH
Culled Empty Block (label) @2
Succesful SSA optimization Pass2CullEmptyBlocks
Not aliassing identity: main::screen#3 main::screen#3
Alias (byte*) main::screen#1 = (byte*) main::screen#2 
Alias (byte*) main::sc2#0 = (byte*~) main::$4 
Succesful SSA optimization Pass2AliasElimination
Not aliassing identity: main::screen#3 main::screen#3
Self Phi Eliminated (byte*) main::screen#1
Self Phi Eliminated (byte*) main::screen#3
Succesful SSA optimization Pass2SelfPhiElimination
Redundant Phi (byte*) main::screen#1 (byte*) main::screen#0
Redundant Phi (byte*) main::screen#3 (byte*) main::screen#1
Succesful SSA optimization Pass2RedundantPhiElimination
Simple Condition (boolean~) main::$3 if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto main::@1
Simple Condition (boolean~) main::$12 if((byte) main::j#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto main::@2
Succesful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) main::screen#0 = ((byte*))1024
Constant (const byte) main::i#0 = 0
Constant (const byte) main::j#0 = 0
Constant (const byte*) main::$13 = ((byte*))53280
Constant (const word/dword/signed dword) main::$16 = 53248+33
Constant (const byte*) main::BGCOL#0 = ((byte*))53280
Succesful SSA optimization Pass2ConstantIdentification
Constant (const byte*) main::$1 = main::screen#0+40
Constant (const byte*) main::sc2#0 = main::screen#0+81
Constant (const byte*) main::$5 = main::screen#0+121
Constant (const byte*) main::$6 = main::screen#0+82
Constant (const byte*) main::$7 = main::screen#0+122
Constant (const byte*) main::$8 = main::screen#0+160
Constant (const byte*) main::$10 = main::screen#0+200
Constant (const byte*) main::$17 = ((byte*))main::$16
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::j#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::j#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::j#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::j#2
OPTIMIZING CONTROL FLOW GRAPH
Inlining constant with var siblings (const byte) main::i#0
Inlining constant with var siblings (const byte) main::i#0
Inlining constant with var siblings (const byte) main::j#0
Inlining constant with var siblings (const byte) main::j#0
Constant inlined main::$16 = (word/dword/signed dword) 53248+(byte/signed byte/word/signed word/dword/signed dword) 33
Constant inlined main::$1 = (const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40
Constant inlined main::$17 = ((byte*))(word/dword/signed dword) 53248+(byte/signed byte/word/signed word/dword/signed dword) 33
Constant inlined main::$5 = (const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 121
Constant inlined main::i#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Constant inlined main::$13 = ((byte*))(word/dword/signed dword) 53280
Constant inlined main::$6 = (const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 82
Constant inlined main::j#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Constant inlined main::$7 = (const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 122
Constant inlined main::$10 = (const byte*) main::screen#0+(byte/word/signed word/dword/signed dword) 200
Constant inlined main::$8 = (const byte*) main::screen#0+(byte/word/signed word/dword/signed dword) 160
Succesful SSA optimization Pass2ConstantInlining
Block Sequence Planned @begin @1 @end main main::@1 main::@3 main::@2 main::@4 main::@return 
Added new block during phi lifting main::@5(between main::@1 and main::@1)
Added new block during phi lifting main::@6(between main::@2 and main::@2)
Block Sequence Planned @begin @1 @end main main::@1 main::@3 main::@2 main::@4 main::@return main::@6 main::@5 
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
CALL GRAPH
Calls in [] to main:2 

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

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi() [ ] ( )
  to:@1
@1: scope:[]  from @begin
  [1] phi() [ ] ( )
  [2] call main param-assignment [ ] ( )
  to:@end
@end: scope:[]  from @1
  [3] phi() [ ] ( )
main: scope:[main]  from @1
  [4] phi() [ ] ( main:2 [ ] )
  to:main::@1
main::@1: scope:[main]  from main main::@1
  [5] (byte) main::i#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) main::i#1 ) [ main::i#2 ] ( main:2 [ main::i#2 ] )
  [6] (byte*~) main::$2 ← (const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 + (byte) main::i#2 [ main::i#2 main::$2 ] ( main:2 [ main::i#2 main::$2 ] )
  [7] *((const byte*) main::screen#0 + (byte) main::i#2) ← *((byte*~) main::$2) [ main::i#2 ] ( main:2 [ main::i#2 ] )
  [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] )
  [9] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] )
  to:main::@3
main::@3: scope:[main]  from main::@1
  [10] *((const byte*) main::sc2#0) ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 121) [ ] ( main:2 [ ] )
  [11] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 82) ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 122) [ ] ( main:2 [ ] )
  to:main::@2
main::@2: scope:[main]  from main::@2 main::@3
  [12] (byte) main::j#2 ← phi( main::@2/(byte) main::j#1 main::@3/(byte/signed byte/word/signed word/dword/signed dword) 0 ) [ main::j#2 ] ( main:2 [ main::j#2 ] )
  [13] (byte*~) main::$9 ← (const byte*) main::screen#0+(byte/word/signed word/dword/signed dword) 160 + (byte) main::j#2 [ main::j#2 main::$9 ] ( main:2 [ main::j#2 main::$9 ] )
  [14] (byte*~) main::$11 ← (const byte*) main::screen#0+(byte/word/signed word/dword/signed dword) 200 + (byte) main::j#2 [ main::j#2 main::$9 main::$11 ] ( main:2 [ main::j#2 main::$9 main::$11 ] )
  [15] *((byte*~) main::$9) ← *((byte*~) main::$11) [ main::j#2 ] ( main:2 [ main::j#2 ] )
  [16] (byte) main::j#1 ← ++ (byte) main::j#2 [ main::j#1 ] ( main:2 [ main::j#1 ] )
  [17] if((byte) main::j#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto main::@2 [ main::j#1 ] ( main:2 [ main::j#1 ] )
  to:main::@4
main::@4: scope:[main]  from main::@2
  [18] *(((byte*))(word/dword/signed dword) 53280) ← ++ *(((byte*))(word/dword/signed dword) 53280) [ ] ( main:2 [ ] )
  [19] *(((byte*))(word/dword/signed dword) 53248+(byte/signed byte/word/signed word/dword/signed dword) 33) ← -- *(((byte*))(word/dword/signed dword) 53248+(byte/signed byte/word/signed word/dword/signed dword) 33) [ ] ( main:2 [ ] )
  [20] *((const byte*) main::BGCOL#0) ← ++ *((const byte*) main::BGCOL#0) [ ] ( main:2 [ ] )
  to:main::@return
main::@return: scope:[main]  from main::@4
  [21] return  [ ] ( main:2 [ ] )
  to:@return

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

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

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


VARIABLE REGISTER WEIGHTS
(void()) main()
(byte*~) main::$11 22.0
(byte*~) main::$2 22.0
(byte*~) main::$9 11.0
(byte*) main::BGCOL
(byte) main::i
(byte) main::i#1 16.5
(byte) main::i#2 14.666666666666666
(byte) main::j
(byte) main::j#1 16.5
(byte) main::j#2 11.0
(byte*) main::sc2
(byte*) main::screen

Initial phi equivalence classes
[ main::i#2 main::i#1 ]
[ main::j#2 main::j#1 ]
Added variable main::$2 to zero page equivalence class [ main::$2 ]
Added variable main::$9 to zero page equivalence class [ main::$9 ]
Added variable main::$11 to zero page equivalence class [ main::$11 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ main::j#2 main::j#1 ]
[ main::$2 ]
[ main::$9 ]
[ main::$11 ]
Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Allocated zp ZP_BYTE:3 [ main::j#2 main::j#1 ]
Allocated zp ZP_WORD:4 [ main::$2 ]
Allocated zp ZP_WORD:6 [ main::$9 ]
Allocated zp ZP_WORD:8 [ main::$11 ]

INITIAL ASM
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
//SEG2 @begin
bbegin:
//SEG3 [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
//SEG4 @1
b1:
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @1 to main [phi:@1->main]
main_from_b1:
  jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
    .label screen = $400
    .label BGCOL = $d020
    .label sc2 = screen+$51
    .label _2 = 4
    .label _9 = 6
    .label _11 = 8
    .label i = 2
    .label j = 3
  //SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
  //SEG11 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta i
    jmp b1
  //SEG12 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
  //SEG13 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
  //SEG14 main::@1
  b1:
  //SEG15 [6] (byte*~) main::$2 ← (const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 + (byte) main::i#2 [ main::i#2 main::$2 ] ( main:2 [ main::i#2 main::$2 ] ) -- pbuz1=pbuc1_plus_vbuz2 
    lda i
    clc
    adc #<screen+$28
    sta _2
    lda #>screen+$28
    adc #0
    sta _2+1
  //SEG16 [7] *((const byte*) main::screen#0 + (byte) main::i#2) ← *((byte*~) main::$2) [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- pbuc1_derefidx_vbuz1=_deref_pbuz2 
    ldx i
    ldy #0
    lda (_2),y
    sta screen,x
  //SEG17 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuz1=_inc_vbuz1 
    inc i
  //SEG18 [9] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuz1_neq_vbuc1_then_la1 
    lda i
    cmp #$b
    bne b1_from_b1
    jmp b3
  //SEG19 main::@3
  b3:
  //SEG20 [10] *((const byte*) main::sc2#0) ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 121) [ ] ( main:2 [ ] ) -- _deref_pbuc1=_deref_pbuc2 
    lda screen+$79
    sta sc2
  //SEG21 [11] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 82) ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 122) [ ] ( main:2 [ ] ) -- _deref_pbuc1=_deref_pbuc2 
    lda screen+$7a
    sta screen+$52
  //SEG22 [12] phi from main::@3 to main::@2 [phi:main::@3->main::@2]
  b2_from_b3:
  //SEG23 [12] phi (byte) main::j#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@3->main::@2#0] -- vbuz1=vbuc1 
    lda #0
    sta j
    jmp b2
  //SEG24 [12] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
  b2_from_b2:
  //SEG25 [12] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@2->main::@2#0] -- register_copy 
    jmp b2
  //SEG26 main::@2
  b2:
  //SEG27 [13] (byte*~) main::$9 ← (const byte*) main::screen#0+(byte/word/signed word/dword/signed dword) 160 + (byte) main::j#2 [ main::j#2 main::$9 ] ( main:2 [ main::j#2 main::$9 ] ) -- pbuz1=pbuc1_plus_vbuz2 
    lda j
    clc
    adc #<screen+$a0
    sta _9
    lda #>screen+$a0
    adc #0
    sta _9+1
  //SEG28 [14] (byte*~) main::$11 ← (const byte*) main::screen#0+(byte/word/signed word/dword/signed dword) 200 + (byte) main::j#2 [ main::j#2 main::$9 main::$11 ] ( main:2 [ main::j#2 main::$9 main::$11 ] ) -- pbuz1=pbuc1_plus_vbuz2 
    lda j
    clc
    adc #<screen+$c8
    sta _11
    lda #>screen+$c8
    adc #0
    sta _11+1
  //SEG29 [15] *((byte*~) main::$9) ← *((byte*~) main::$11) [ main::j#2 ] ( main:2 [ main::j#2 ] ) -- _deref_pbuz1=_deref_pbuz2 
    ldy #0
    lda (_11),y
    ldy #0
    sta (_9),y
  //SEG30 [16] (byte) main::j#1 ← ++ (byte) main::j#2 [ main::j#1 ] ( main:2 [ main::j#1 ] ) -- vbuz1=_inc_vbuz1 
    inc j
  //SEG31 [17] if((byte) main::j#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto main::@2 [ main::j#1 ] ( main:2 [ main::j#1 ] ) -- vbuz1_neq_vbuc1_then_la1 
    lda j
    cmp #$b
    bne b2_from_b2
    jmp b4
  //SEG32 main::@4
  b4:
  //SEG33 [18] *(((byte*))(word/dword/signed dword) 53280) ← ++ *(((byte*))(word/dword/signed dword) 53280) [ ] ( main:2 [ ] ) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc $d020
  //SEG34 [19] *(((byte*))(word/dword/signed dword) 53248+(byte/signed byte/word/signed word/dword/signed dword) 33) ← -- *(((byte*))(word/dword/signed dword) 53248+(byte/signed byte/word/signed word/dword/signed dword) 33) [ ] ( main:2 [ ] ) -- _deref_pbuc1=_dec__deref_pbuc1 
    dec $d000+$21
  //SEG35 [20] *((const byte*) main::BGCOL#0) ← ++ *((const byte*) main::BGCOL#0) [ ] ( main:2 [ ] ) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
    jmp breturn
  //SEG36 main::@return
  breturn:
  //SEG37 [21] return  [ ] ( main:2 [ ] )
    rts
}

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] (byte*~) main::$2 ← (const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 + (byte) main::i#2 [ main::i#2 main::$2 ] ( main:2 [ main::i#2 main::$2 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Statement [7] *((const byte*) main::screen#0 + (byte) main::i#2) ← *((byte*~) main::$2) [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a reg byte y 
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Statement [10] *((const byte*) main::sc2#0) ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 121) [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [11] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 82) ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 122) [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [13] (byte*~) main::$9 ← (const byte*) main::screen#0+(byte/word/signed word/dword/signed dword) 160 + (byte) main::j#2 [ main::j#2 main::$9 ] ( main:2 [ main::j#2 main::$9 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:3 [ main::j#2 main::j#1 ]
Statement [14] (byte*~) main::$11 ← (const byte*) main::screen#0+(byte/word/signed word/dword/signed dword) 200 + (byte) main::j#2 [ main::j#2 main::$9 main::$11 ] ( main:2 [ main::j#2 main::$9 main::$11 ] ) always clobbers reg byte a 
Statement [15] *((byte*~) main::$9) ← *((byte*~) main::$11) [ main::j#2 ] ( main:2 [ main::j#2 ] ) always clobbers reg byte a reg byte y 
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:3 [ main::j#2 main::j#1 ]
Statement [6] (byte*~) main::$2 ← (const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 + (byte) main::i#2 [ main::i#2 main::$2 ] ( main:2 [ main::i#2 main::$2 ] ) always clobbers reg byte a 
Statement [7] *((const byte*) main::screen#0 + (byte) main::i#2) ← *((byte*~) main::$2) [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a reg byte y 
Statement [10] *((const byte*) main::sc2#0) ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 121) [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [11] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 82) ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 122) [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [13] (byte*~) main::$9 ← (const byte*) main::screen#0+(byte/word/signed word/dword/signed dword) 160 + (byte) main::j#2 [ main::j#2 main::$9 ] ( main:2 [ main::j#2 main::$9 ] ) always clobbers reg byte a 
Statement [14] (byte*~) main::$11 ← (const byte*) main::screen#0+(byte/word/signed word/dword/signed dword) 200 + (byte) main::j#2 [ main::j#2 main::$9 main::$11 ] ( main:2 [ main::j#2 main::$9 main::$11 ] ) always clobbers reg byte a 
Statement [15] *((byte*~) main::$9) ← *((byte*~) main::$11) [ main::j#2 ] ( main:2 [ main::j#2 ] ) always clobbers reg byte a reg byte y 
Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte x , 
Potential registers zp ZP_BYTE:3 [ main::j#2 main::j#1 ] : zp ZP_BYTE:3 , reg byte x , 
Potential registers zp ZP_WORD:4 [ main::$2 ] : zp ZP_WORD:4 , 
Potential registers zp ZP_WORD:6 [ main::$9 ] : zp ZP_WORD:6 , 
Potential registers zp ZP_WORD:8 [ main::$11 ] : zp ZP_WORD:8 , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 31.17: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 27.5: zp ZP_BYTE:3 [ main::j#2 main::j#1 ] 22: zp ZP_WORD:4 [ main::$2 ] 22: zp ZP_WORD:8 [ main::$11 ] 11: zp ZP_WORD:6 [ main::$9 ] 
Uplift Scope [] 

Uplifting [main] best 1165 combination reg byte x [ main::i#2 main::i#1 ] reg byte x [ main::j#2 main::j#1 ] zp ZP_WORD:4 [ main::$2 ] zp ZP_WORD:8 [ main::$11 ] zp ZP_WORD:6 [ main::$9 ] 
Uplifting [] best 1165 combination 
Allocated (was zp ZP_WORD:4) zp ZP_WORD:2 [ main::$2 ]
Allocated (was zp ZP_WORD:6) zp ZP_WORD:4 [ main::$9 ]
Allocated (was zp ZP_WORD:8) zp ZP_WORD:6 [ main::$11 ]

ASSEMBLER BEFORE OPTIMIZATION
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
//SEG2 @begin
bbegin:
//SEG3 [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
//SEG4 @1
b1:
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @1 to main [phi:@1->main]
main_from_b1:
  jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
    .label screen = $400
    .label BGCOL = $d020
    .label sc2 = screen+$51
    .label _2 = 2
    .label _9 = 4
    .label _11 = 6
  //SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
  //SEG11 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    jmp b1
  //SEG12 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
  //SEG13 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
  //SEG14 main::@1
  b1:
  //SEG15 [6] (byte*~) main::$2 ← (const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 + (byte) main::i#2 [ main::i#2 main::$2 ] ( main:2 [ main::i#2 main::$2 ] ) -- pbuz1=pbuc1_plus_vbuxx 
    txa
    clc
    adc #<screen+$28
    sta _2
    lda #>screen+$28
    adc #0
    sta _2+1
  //SEG16 [7] *((const byte*) main::screen#0 + (byte) main::i#2) ← *((byte*~) main::$2) [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- pbuc1_derefidx_vbuxx=_deref_pbuz1 
    ldy #0
    lda (_2),y
    sta screen,x
  //SEG17 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuxx=_inc_vbuxx 
    inx
  //SEG18 [9] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne b1_from_b1
    jmp b3
  //SEG19 main::@3
  b3:
  //SEG20 [10] *((const byte*) main::sc2#0) ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 121) [ ] ( main:2 [ ] ) -- _deref_pbuc1=_deref_pbuc2 
    lda screen+$79
    sta sc2
  //SEG21 [11] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 82) ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 122) [ ] ( main:2 [ ] ) -- _deref_pbuc1=_deref_pbuc2 
    lda screen+$7a
    sta screen+$52
  //SEG22 [12] phi from main::@3 to main::@2 [phi:main::@3->main::@2]
  b2_from_b3:
  //SEG23 [12] phi (byte) main::j#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@3->main::@2#0] -- vbuxx=vbuc1 
    ldx #0
    jmp b2
  //SEG24 [12] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
  b2_from_b2:
  //SEG25 [12] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@2->main::@2#0] -- register_copy 
    jmp b2
  //SEG26 main::@2
  b2:
  //SEG27 [13] (byte*~) main::$9 ← (const byte*) main::screen#0+(byte/word/signed word/dword/signed dword) 160 + (byte) main::j#2 [ main::j#2 main::$9 ] ( main:2 [ main::j#2 main::$9 ] ) -- pbuz1=pbuc1_plus_vbuxx 
    txa
    clc
    adc #<screen+$a0
    sta _9
    lda #>screen+$a0
    adc #0
    sta _9+1
  //SEG28 [14] (byte*~) main::$11 ← (const byte*) main::screen#0+(byte/word/signed word/dword/signed dword) 200 + (byte) main::j#2 [ main::j#2 main::$9 main::$11 ] ( main:2 [ main::j#2 main::$9 main::$11 ] ) -- pbuz1=pbuc1_plus_vbuxx 
    txa
    clc
    adc #<screen+$c8
    sta _11
    lda #>screen+$c8
    adc #0
    sta _11+1
  //SEG29 [15] *((byte*~) main::$9) ← *((byte*~) main::$11) [ main::j#2 ] ( main:2 [ main::j#2 ] ) -- _deref_pbuz1=_deref_pbuz2 
    ldy #0
    lda (_11),y
    ldy #0
    sta (_9),y
  //SEG30 [16] (byte) main::j#1 ← ++ (byte) main::j#2 [ main::j#1 ] ( main:2 [ main::j#1 ] ) -- vbuxx=_inc_vbuxx 
    inx
  //SEG31 [17] if((byte) main::j#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto main::@2 [ main::j#1 ] ( main:2 [ main::j#1 ] ) -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne b2_from_b2
    jmp b4
  //SEG32 main::@4
  b4:
  //SEG33 [18] *(((byte*))(word/dword/signed dword) 53280) ← ++ *(((byte*))(word/dword/signed dword) 53280) [ ] ( main:2 [ ] ) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc $d020
  //SEG34 [19] *(((byte*))(word/dword/signed dword) 53248+(byte/signed byte/word/signed word/dword/signed dword) 33) ← -- *(((byte*))(word/dword/signed dword) 53248+(byte/signed byte/word/signed word/dword/signed dword) 33) [ ] ( main:2 [ ] ) -- _deref_pbuc1=_dec__deref_pbuc1 
    dec $d000+$21
  //SEG35 [20] *((const byte*) main::BGCOL#0) ← ++ *((const byte*) main::BGCOL#0) [ ] ( main:2 [ ] ) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
    jmp breturn
  //SEG36 main::@return
  breturn:
  //SEG37 [21] return  [ ] ( main:2 [ ] )
    rts
}

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b3
Removing instruction jmp b2
Removing instruction jmp b4
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction ldy #0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Replacing label b1_from_b1 with b1
Replacing label b2_from_b2 with b2
Removing instruction bbegin:
Removing instruction b1_from_bbegin:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_b1:
Removing instruction b2_from_b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction b1:
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction b3:
Removing instruction b2_from_b3:
Removing instruction b4:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jmp b1
Removing instruction jmp b2
Succesful ASM optimization Pass5NextJumpElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(byte*~) main::$11 $11 zp ZP_WORD:6 22.0
(byte*~) main::$2 $2 zp ZP_WORD:2 22.0
(byte*~) main::$9 $9 zp ZP_WORD:4 11.0
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@return
(byte*) main::BGCOL
(const byte*) main::BGCOL#0 BGCOL = ((byte*))(word/dword/signed dword) 53280
(byte) main::i
(byte) main::i#1 reg byte x 16.5
(byte) main::i#2 reg byte x 14.666666666666666
(byte) main::j
(byte) main::j#1 reg byte x 16.5
(byte) main::j#2 reg byte x 11.0
(byte*) main::sc2
(const byte*) main::sc2#0 sc2 = (const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 81
(byte*) main::screen
(const byte*) main::screen#0 screen = ((byte*))(word/signed word/dword/signed dword) 1024

reg byte x [ main::i#2 main::i#1 ]
reg byte x [ main::j#2 main::j#1 ]
zp ZP_WORD:2 [ main::$2 ]
zp ZP_WORD:4 [ main::$9 ]
zp ZP_WORD:6 [ main::$11 ]


FINAL ASSEMBLER
Score: 956

//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
//SEG2 @begin
//SEG3 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG4 @1
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @1 to main [phi:@1->main]
  jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
//SEG8 @end
//SEG9 main
main: {
    .label screen = $400
    .label BGCOL = $d020
    .label sc2 = screen+$51
    .label _2 = 2
    .label _9 = 4
    .label _11 = 6
  //SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
  //SEG11 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
  //SEG12 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  //SEG13 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
  //SEG14 main::@1
  b1:
  //SEG15 [6] (byte*~) main::$2 ← (const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 + (byte) main::i#2 [ main::i#2 main::$2 ] ( main:2 [ main::i#2 main::$2 ] ) -- pbuz1=pbuc1_plus_vbuxx 
    txa
    clc
    adc #<screen+$28
    sta _2
    lda #>screen+$28
    adc #0
    sta _2+1
  //SEG16 [7] *((const byte*) main::screen#0 + (byte) main::i#2) ← *((byte*~) main::$2) [ main::i#2 ] ( main:2 [ main::i#2 ] ) -- pbuc1_derefidx_vbuxx=_deref_pbuz1 
    ldy #0
    lda (_2),y
    sta screen,x
  //SEG17 [8] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuxx=_inc_vbuxx 
    inx
  //SEG18 [9] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne b1
  //SEG19 main::@3
  //SEG20 [10] *((const byte*) main::sc2#0) ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 121) [ ] ( main:2 [ ] ) -- _deref_pbuc1=_deref_pbuc2 
    lda screen+$79
    sta sc2
  //SEG21 [11] *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 82) ← *((const byte*) main::screen#0+(byte/signed byte/word/signed word/dword/signed dword) 122) [ ] ( main:2 [ ] ) -- _deref_pbuc1=_deref_pbuc2 
    lda screen+$7a
    sta screen+$52
  //SEG22 [12] phi from main::@3 to main::@2 [phi:main::@3->main::@2]
  //SEG23 [12] phi (byte) main::j#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@3->main::@2#0] -- vbuxx=vbuc1 
    ldx #0
  //SEG24 [12] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
  //SEG25 [12] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@2->main::@2#0] -- register_copy 
  //SEG26 main::@2
  b2:
  //SEG27 [13] (byte*~) main::$9 ← (const byte*) main::screen#0+(byte/word/signed word/dword/signed dword) 160 + (byte) main::j#2 [ main::j#2 main::$9 ] ( main:2 [ main::j#2 main::$9 ] ) -- pbuz1=pbuc1_plus_vbuxx 
    txa
    clc
    adc #<screen+$a0
    sta _9
    lda #>screen+$a0
    adc #0
    sta _9+1
  //SEG28 [14] (byte*~) main::$11 ← (const byte*) main::screen#0+(byte/word/signed word/dword/signed dword) 200 + (byte) main::j#2 [ main::j#2 main::$9 main::$11 ] ( main:2 [ main::j#2 main::$9 main::$11 ] ) -- pbuz1=pbuc1_plus_vbuxx 
    txa
    clc
    adc #<screen+$c8
    sta _11
    lda #>screen+$c8
    adc #0
    sta _11+1
  //SEG29 [15] *((byte*~) main::$9) ← *((byte*~) main::$11) [ main::j#2 ] ( main:2 [ main::j#2 ] ) -- _deref_pbuz1=_deref_pbuz2 
    ldy #0
    lda (_11),y
    sta (_9),y
  //SEG30 [16] (byte) main::j#1 ← ++ (byte) main::j#2 [ main::j#1 ] ( main:2 [ main::j#1 ] ) -- vbuxx=_inc_vbuxx 
    inx
  //SEG31 [17] if((byte) main::j#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto main::@2 [ main::j#1 ] ( main:2 [ main::j#1 ] ) -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne b2
  //SEG32 main::@4
  //SEG33 [18] *(((byte*))(word/dword/signed dword) 53280) ← ++ *(((byte*))(word/dword/signed dword) 53280) [ ] ( main:2 [ ] ) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc $d020
  //SEG34 [19] *(((byte*))(word/dword/signed dword) 53248+(byte/signed byte/word/signed word/dword/signed dword) 33) ← -- *(((byte*))(word/dword/signed dword) 53248+(byte/signed byte/word/signed word/dword/signed dword) 33) [ ] ( main:2 [ ] ) -- _deref_pbuc1=_dec__deref_pbuc1 
    dec $d000+$21
  //SEG35 [20] *((const byte*) main::BGCOL#0) ← ++ *((const byte*) main::BGCOL#0) [ ] ( main:2 [ ] ) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
  //SEG36 main::@return
  //SEG37 [21] return  [ ] ( main:2 [ ] )
    rts
}

