PARSING src/test/java/dk/camelot64/kickc/test/kc/chargen.kc
byte* PROCPORT = $01;
byte* CHARGEN = $d000;
byte* SCREEN = $0400;

void main() {
    asm { sei }
    byte* CHAR_A = CHARGEN+8;
    *PROCPORT = $32;
    byte* sc = SCREEN;
    for(byte y:0..7) {
      byte bits = CHAR_A[y];
      for(byte x:0..7) {
        byte c = '.';
        if((bits & $80) != 0) {
           c = '*';
        }
        *sc = c;
        sc++;
        bits = bits<<1;
      }
      sc = sc+32;
    }
    *PROCPORT = $37;
    asm { cli }
}

Adding pre/post-modifier (byte*) main::sc ← ++ (byte*) main::sc

STATEMENTS
  (byte*) PROCPORT ← (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte*) CHARGEN ← (word/dword/signed dword) 53248
  (byte*) SCREEN ← (word/signed word/dword/signed dword) 1024
proc (void()) main()
  asm { sei  }
  (byte*~) main::$0 ← (byte*) CHARGEN + (byte/signed byte/word/signed word/dword/signed dword) 8
  (byte*) main::CHAR_A ← (byte*~) main::$0
  *((byte*) PROCPORT) ← (byte/signed byte/word/signed word/dword/signed dword) 50
  (byte*) main::sc ← (byte*) SCREEN
  (byte) main::y ← (byte/signed byte/word/signed word/dword/signed dword) 0
main::@1:
  (byte) main::bits ← *((byte*) main::CHAR_A + (byte) main::y)
  (byte) main::x ← (byte/signed byte/word/signed word/dword/signed dword) 0
main::@2:
  (byte) main::c ← (byte) '.'
  (byte~) main::$1 ← (byte) main::bits & (byte/word/signed word/dword/signed dword) 128
  (boolean~) main::$2 ← (byte~) main::$1 != (byte/signed byte/word/signed word/dword/signed dword) 0
  (boolean~) main::$3 ← ! (boolean~) main::$2
  if((boolean~) main::$3) goto main::@3
  (byte) main::c ← (byte) '*'
main::@3:
  *((byte*) main::sc) ← (byte) main::c
  (byte*) main::sc ← ++ (byte*) main::sc
  (byte~) main::$4 ← (byte) main::bits << (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte) main::bits ← (byte~) main::$4
  (byte) main::x ← ++ (byte) main::x
  (boolean~) main::$5 ← (byte) main::x != (byte/signed byte/word/signed word/dword/signed dword) 8
  if((boolean~) main::$5) goto main::@2
  (byte*~) main::$6 ← (byte*) main::sc + (byte/signed byte/word/signed word/dword/signed dword) 32
  (byte*) main::sc ← (byte*~) main::$6
  (byte) main::y ← ++ (byte) main::y
  (boolean~) main::$7 ← (byte) main::y != (byte/signed byte/word/signed word/dword/signed dword) 8
  if((boolean~) main::$7) goto main::@1
  *((byte*) PROCPORT) ← (byte/signed byte/word/signed word/dword/signed dword) 55
  asm { cli  }
main::@return:
  return 
endproc // main()
  call main 

SYMBOLS
(byte*) CHARGEN
(byte*) PROCPORT
(byte*) SCREEN
(void()) main()
(byte*~) main::$0
(byte~) main::$1
(boolean~) main::$2
(boolean~) main::$3
(byte~) main::$4
(boolean~) main::$5
(byte*~) main::$6
(boolean~) main::$7
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte*) main::CHAR_A
(byte) main::bits
(byte) main::c
(byte*) main::sc
(byte) main::x
(byte) main::y

Promoting byte/signed byte/word/signed word/dword/signed dword to byte* in PROCPORT ← ((byte*)) 1
Promoting word/dword/signed dword to byte* in CHARGEN ← ((byte*)) 53248
Promoting word/signed word/dword/signed dword to byte* in SCREEN ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  (byte*) PROCPORT ← ((byte*)) (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte*) CHARGEN ← ((byte*)) (word/dword/signed dword) 53248
  (byte*) SCREEN ← ((byte*)) (word/signed word/dword/signed dword) 1024
  to:@1
main: scope:[main]  from
  asm { sei  }
  (byte*~) main::$0 ← (byte*) CHARGEN + (byte/signed byte/word/signed word/dword/signed dword) 8
  (byte*) main::CHAR_A ← (byte*~) main::$0
  *((byte*) PROCPORT) ← (byte/signed byte/word/signed word/dword/signed dword) 50
  (byte*) main::sc ← (byte*) SCREEN
  (byte) main::y ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:main::@1
main::@1: scope:[main]  from main main::@5
  (byte) main::bits ← *((byte*) main::CHAR_A + (byte) main::y)
  (byte) main::x ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@3
  (byte) main::c ← (byte) '.'
  (byte~) main::$1 ← (byte) main::bits & (byte/word/signed word/dword/signed dword) 128
  (boolean~) main::$2 ← (byte~) main::$1 != (byte/signed byte/word/signed word/dword/signed dword) 0
  (boolean~) main::$3 ← ! (boolean~) main::$2
  if((boolean~) main::$3) goto main::@3
  to:main::@4
main::@3: scope:[main]  from main::@2 main::@4
  *((byte*) main::sc) ← (byte) main::c
  (byte*) main::sc ← ++ (byte*) main::sc
  (byte~) main::$4 ← (byte) main::bits << (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte) main::bits ← (byte~) main::$4
  (byte) main::x ← ++ (byte) main::x
  (boolean~) main::$5 ← (byte) main::x != (byte/signed byte/word/signed word/dword/signed dword) 8
  if((boolean~) main::$5) goto main::@2
  to:main::@5
main::@4: scope:[main]  from main::@2
  (byte) main::c ← (byte) '*'
  to:main::@3
main::@5: scope:[main]  from main::@3
  (byte*~) main::$6 ← (byte*) main::sc + (byte/signed byte/word/signed word/dword/signed dword) 32
  (byte*) main::sc ← (byte*~) main::$6
  (byte) main::y ← ++ (byte) main::y
  (boolean~) main::$7 ← (byte) main::y != (byte/signed byte/word/signed word/dword/signed dword) 8
  if((boolean~) main::$7) goto main::@1
  to:main::@6
main::@6: scope:[main]  from main::@5
  *((byte*) PROCPORT) ← (byte/signed byte/word/signed word/dword/signed dword) 55
  asm { cli  }
  to:main::@return
main::@return: scope:[main]  from main::@6
  return 
  to:@return
@1: scope:[]  from @begin
  call main 
  to:@end
@end: scope:[]  from @1

PROCEDURE MODIFY VARIABLE ANALYSIS

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

CONTROL FLOW GRAPH SSA WITH ASSIGNMENT CALL & RETURN
@begin: scope:[]  from
  (byte*) PROCPORT#0 ← ((byte*)) (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte*) CHARGEN#0 ← ((byte*)) (word/dword/signed dword) 53248
  (byte*) SCREEN#0 ← ((byte*)) (word/signed word/dword/signed dword) 1024
  to:@1
main: scope:[main]  from @1
  (byte*) SCREEN#1 ← phi( @1/(byte*) SCREEN#2 )
  (byte*) PROCPORT#1 ← phi( @1/(byte*) PROCPORT#3 )
  (byte*) CHARGEN#1 ← phi( @1/(byte*) CHARGEN#2 )
  asm { sei  }
  (byte*~) main::$0 ← (byte*) CHARGEN#1 + (byte/signed byte/word/signed word/dword/signed dword) 8
  (byte*) main::CHAR_A#0 ← (byte*~) main::$0
  *((byte*) PROCPORT#1) ← (byte/signed byte/word/signed word/dword/signed dword) 50
  (byte*) main::sc#0 ← (byte*) SCREEN#1
  (byte) main::y#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:main::@1
main::@1: scope:[main]  from main main::@5
  (byte*) PROCPORT#8 ← phi( main/(byte*) PROCPORT#1 main::@5/(byte*) PROCPORT#4 )
  (byte*) main::sc#7 ← phi( main/(byte*) main::sc#0 main::@5/(byte*) main::sc#2 )
  (byte) main::y#2 ← phi( main/(byte) main::y#0 main::@5/(byte) main::y#1 )
  (byte*) main::CHAR_A#1 ← phi( main/(byte*) main::CHAR_A#0 main::@5/(byte*) main::CHAR_A#2 )
  (byte) main::bits#0 ← *((byte*) main::CHAR_A#1 + (byte) main::y#2)
  (byte) main::x#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@3
  (byte*) PROCPORT#6 ← phi( main::@1/(byte*) PROCPORT#8 main::@3/(byte*) PROCPORT#5 )
  (byte*) main::CHAR_A#4 ← phi( main::@1/(byte*) main::CHAR_A#1 main::@3/(byte*) main::CHAR_A#3 )
  (byte) main::y#5 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#4 )
  (byte) main::x#3 ← phi( main::@1/(byte) main::x#0 main::@3/(byte) main::x#1 )
  (byte*) main::sc#5 ← phi( main::@1/(byte*) main::sc#7 main::@3/(byte*) main::sc#1 )
  (byte) main::bits#2 ← phi( main::@1/(byte) main::bits#0 main::@3/(byte) main::bits#1 )
  (byte) main::c#0 ← (byte) '.'
  (byte~) main::$1 ← (byte) main::bits#2 & (byte/word/signed word/dword/signed dword) 128
  (boolean~) main::$2 ← (byte~) main::$1 != (byte/signed byte/word/signed word/dword/signed dword) 0
  (boolean~) main::$3 ← ! (boolean~) main::$2
  if((boolean~) main::$3) goto main::@3
  to:main::@4
main::@3: scope:[main]  from main::@2 main::@4
  (byte*) PROCPORT#5 ← phi( main::@2/(byte*) PROCPORT#6 main::@4/(byte*) PROCPORT#7 )
  (byte*) main::CHAR_A#3 ← phi( main::@2/(byte*) main::CHAR_A#4 main::@4/(byte*) main::CHAR_A#5 )
  (byte) main::y#4 ← phi( main::@2/(byte) main::y#5 main::@4/(byte) main::y#6 )
  (byte) main::x#2 ← phi( main::@2/(byte) main::x#3 main::@4/(byte) main::x#4 )
  (byte) main::bits#3 ← phi( main::@2/(byte) main::bits#2 main::@4/(byte) main::bits#4 )
  (byte*) main::sc#3 ← phi( main::@2/(byte*) main::sc#5 main::@4/(byte*) main::sc#6 )
  (byte) main::c#2 ← phi( main::@2/(byte) main::c#0 main::@4/(byte) main::c#1 )
  *((byte*) main::sc#3) ← (byte) main::c#2
  (byte*) main::sc#1 ← ++ (byte*) main::sc#3
  (byte~) main::$4 ← (byte) main::bits#3 << (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte) main::bits#1 ← (byte~) main::$4
  (byte) main::x#1 ← ++ (byte) main::x#2
  (boolean~) main::$5 ← (byte) main::x#1 != (byte/signed byte/word/signed word/dword/signed dword) 8
  if((boolean~) main::$5) goto main::@2
  to:main::@5
main::@4: scope:[main]  from main::@2
  (byte*) PROCPORT#7 ← phi( main::@2/(byte*) PROCPORT#6 )
  (byte*) main::CHAR_A#5 ← phi( main::@2/(byte*) main::CHAR_A#4 )
  (byte) main::y#6 ← phi( main::@2/(byte) main::y#5 )
  (byte) main::x#4 ← phi( main::@2/(byte) main::x#3 )
  (byte) main::bits#4 ← phi( main::@2/(byte) main::bits#2 )
  (byte*) main::sc#6 ← phi( main::@2/(byte*) main::sc#5 )
  (byte) main::c#1 ← (byte) '*'
  to:main::@3
main::@5: scope:[main]  from main::@3
  (byte*) PROCPORT#4 ← phi( main::@3/(byte*) PROCPORT#5 )
  (byte*) main::CHAR_A#2 ← phi( main::@3/(byte*) main::CHAR_A#3 )
  (byte) main::y#3 ← phi( main::@3/(byte) main::y#4 )
  (byte*) main::sc#4 ← phi( main::@3/(byte*) main::sc#1 )
  (byte*~) main::$6 ← (byte*) main::sc#4 + (byte/signed byte/word/signed word/dword/signed dword) 32
  (byte*) main::sc#2 ← (byte*~) main::$6
  (byte) main::y#1 ← ++ (byte) main::y#3
  (boolean~) main::$7 ← (byte) main::y#1 != (byte/signed byte/word/signed word/dword/signed dword) 8
  if((boolean~) main::$7) goto main::@1
  to:main::@6
main::@6: scope:[main]  from main::@5
  (byte*) PROCPORT#2 ← phi( main::@5/(byte*) PROCPORT#4 )
  *((byte*) PROCPORT#2) ← (byte/signed byte/word/signed word/dword/signed dword) 55
  asm { cli  }
  to:main::@return
main::@return: scope:[main]  from main::@6
  return 
  to:@return
@1: scope:[]  from @begin
  (byte*) SCREEN#2 ← phi( @begin/(byte*) SCREEN#0 )
  (byte*) PROCPORT#3 ← phi( @begin/(byte*) PROCPORT#0 )
  (byte*) CHARGEN#2 ← phi( @begin/(byte*) CHARGEN#0 )
  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
(byte*) CHARGEN
(byte*) CHARGEN#0
(byte*) CHARGEN#1
(byte*) CHARGEN#2
(byte*) PROCPORT
(byte*) PROCPORT#0
(byte*) PROCPORT#1
(byte*) PROCPORT#2
(byte*) PROCPORT#3
(byte*) PROCPORT#4
(byte*) PROCPORT#5
(byte*) PROCPORT#6
(byte*) PROCPORT#7
(byte*) PROCPORT#8
(byte*) SCREEN
(byte*) SCREEN#0
(byte*) SCREEN#1
(byte*) SCREEN#2
(void()) main()
(byte*~) main::$0
(byte~) main::$1
(boolean~) main::$2
(boolean~) main::$3
(byte~) main::$4
(boolean~) main::$5
(byte*~) main::$6
(boolean~) main::$7
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@return
(byte*) main::CHAR_A
(byte*) main::CHAR_A#0
(byte*) main::CHAR_A#1
(byte*) main::CHAR_A#2
(byte*) main::CHAR_A#3
(byte*) main::CHAR_A#4
(byte*) main::CHAR_A#5
(byte) main::bits
(byte) main::bits#0
(byte) main::bits#1
(byte) main::bits#2
(byte) main::bits#3
(byte) main::bits#4
(byte) main::c
(byte) main::c#0
(byte) main::c#1
(byte) main::c#2
(byte*) main::sc
(byte*) main::sc#0
(byte*) main::sc#1
(byte*) main::sc#2
(byte*) main::sc#3
(byte*) main::sc#4
(byte*) main::sc#5
(byte*) main::sc#6
(byte*) main::sc#7
(byte) main::x
(byte) main::x#0
(byte) main::x#1
(byte) main::x#2
(byte) main::x#3
(byte) main::x#4
(byte) main::y
(byte) main::y#0
(byte) main::y#1
(byte) main::y#2
(byte) main::y#3
(byte) main::y#4
(byte) main::y#5
(byte) main::y#6

OPTIMIZING CONTROL FLOW GRAPH
Culled Empty Block (label) @2
Succesful SSA optimization Pass2CullEmptyBlocks
Inversing boolean not (boolean~) main::$3 ← (byte~) main::$1 == (byte/signed byte/word/signed word/dword/signed dword) 0 from (boolean~) main::$2 ← (byte~) main::$1 != (byte/signed byte/word/signed word/dword/signed dword) 0
Succesful SSA optimization Pass2UnaryNotSimplification
Not aliassing across scopes: CHARGEN#1 CHARGEN#2
Not aliassing across scopes: PROCPORT#1 PROCPORT#3
Not aliassing across scopes: SCREEN#1 SCREEN#2
Not aliassing across scopes: main::sc#0 SCREEN#1
Alias (byte*) main::CHAR_A#0 = (byte*~) main::$0 
Alias (byte) main::bits#1 = (byte~) main::$4 
Alias (byte*) main::sc#5 = (byte*) main::sc#6 
Alias (byte) main::bits#2 = (byte) main::bits#4 
Alias (byte) main::x#3 = (byte) main::x#4 
Alias (byte) main::y#5 = (byte) main::y#6 
Alias (byte*) main::CHAR_A#4 = (byte*) main::CHAR_A#5 
Alias (byte*) PROCPORT#6 = (byte*) PROCPORT#7 
Alias (byte*) main::sc#1 = (byte*) main::sc#4 
Alias (byte) main::y#3 = (byte) main::y#4 
Alias (byte*) main::CHAR_A#2 = (byte*) main::CHAR_A#3 
Alias (byte*) PROCPORT#2 = (byte*) PROCPORT#4 (byte*) PROCPORT#5 
Alias (byte*) main::sc#2 = (byte*~) main::$6 
Alias (byte*) CHARGEN#0 = (byte*) CHARGEN#2 
Alias (byte*) PROCPORT#0 = (byte*) PROCPORT#3 
Alias (byte*) SCREEN#0 = (byte*) SCREEN#2 
Succesful SSA optimization Pass2AliasElimination
Not aliassing across scopes: CHARGEN#1 CHARGEN#0
Not aliassing across scopes: PROCPORT#1 PROCPORT#0
Not aliassing across scopes: SCREEN#1 SCREEN#0
Not aliassing across scopes: main::sc#0 SCREEN#1
Alias (byte*) main::sc#3 = (byte*) main::sc#5 
Alias (byte) main::bits#2 = (byte) main::bits#3 
Alias (byte) main::x#2 = (byte) main::x#3 
Alias (byte) main::y#3 = (byte) main::y#5 
Alias (byte*) main::CHAR_A#2 = (byte*) main::CHAR_A#4 
Alias (byte*) PROCPORT#2 = (byte*) PROCPORT#6 
Succesful SSA optimization Pass2AliasElimination
Not aliassing across scopes: CHARGEN#1 CHARGEN#0
Not aliassing across scopes: PROCPORT#1 PROCPORT#0
Not aliassing across scopes: SCREEN#1 SCREEN#0
Not aliassing across scopes: main::sc#0 SCREEN#1
Self Phi Eliminated (byte) main::y#3
Self Phi Eliminated (byte*) main::CHAR_A#2
Self Phi Eliminated (byte*) PROCPORT#2
Succesful SSA optimization Pass2SelfPhiElimination
Redundant Phi (byte*) CHARGEN#1 (byte*) CHARGEN#0
Redundant Phi (byte*) PROCPORT#1 (byte*) PROCPORT#0
Redundant Phi (byte*) SCREEN#1 (byte*) SCREEN#0
Redundant Phi (byte) main::y#3 (byte) main::y#2
Redundant Phi (byte*) main::CHAR_A#2 (byte*) main::CHAR_A#1
Redundant Phi (byte*) PROCPORT#2 (byte*) PROCPORT#8
Succesful SSA optimization Pass2RedundantPhiElimination
Simple Condition (boolean~) main::$3 if((byte~) main::$1==(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@3
Simple Condition (boolean~) main::$5 if((byte) main::x#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@2
Simple Condition (boolean~) main::$7 if((byte) main::y#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@1
Succesful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) PROCPORT#0 = ((byte*))1
Constant (const byte*) CHARGEN#0 = ((byte*))53248
Constant (const byte*) SCREEN#0 = ((byte*))1024
Constant (const byte) main::y#0 = 0
Constant (const byte) main::x#0 = 0
Constant (const byte) main::c#0 = '.'
Constant (const byte) main::c#1 = '*'
Succesful SSA optimization Pass2ConstantIdentification
Constant (const byte*) main::CHAR_A#0 = CHARGEN#0+8
Constant (const byte*) main::sc#0 = SCREEN#0
Succesful SSA optimization Pass2ConstantIdentification
Multiple usages for variable. Not optimizing sub-constant (byte*) main::sc#1
Not culling empty block because it shares successor with its predecessor. (label) main::@4
Self Phi Eliminated (byte*) main::CHAR_A#1
Self Phi Eliminated (byte*) PROCPORT#8
Succesful SSA optimization Pass2SelfPhiElimination
Redundant Phi (byte*) main::CHAR_A#1 (const byte*) main::CHAR_A#0
Redundant Phi (byte*) PROCPORT#8 (const byte*) PROCPORT#0
Succesful SSA optimization Pass2RedundantPhiElimination
Multiple usages for variable. Not optimizing sub-constant (byte*) main::sc#1
Not culling empty block because it shares successor with its predecessor. (label) main::@4
Multiple usages for variable. Not optimizing sub-constant (byte*) main::sc#1
OPTIMIZING CONTROL FLOW GRAPH
Inlining constant with var siblings (const byte) main::y#0
Inlining constant with var siblings (const byte) main::y#0
Inlining constant with var siblings (const byte) main::x#0
Inlining constant with var siblings (const byte) main::x#0
Inlining constant with var siblings (const byte) main::c#0
Inlining constant with different constant siblings (const byte) main::c#0
Inlining constant with var siblings (const byte) main::c#1
Inlining constant with different constant siblings (const byte) main::c#1
Inlining constant with var siblings (const byte*) main::sc#0
Inlining constant with var siblings (const byte*) main::sc#0
Inlining constant with var siblings (const byte*) main::sc#0
Inlining constant with var siblings (const byte*) main::sc#0
Constant inlined main::sc#0 = (const byte*) SCREEN#0
Constant inlined main::c#0 = (byte) '.'
Constant inlined main::x#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Constant inlined main::y#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Constant inlined main::c#1 = (byte) '*'
Succesful SSA optimization Pass2ConstantInlining
Block Sequence Planned @begin @1 @end main main::@1 main::@2 main::@4 main::@3 main::@5 main::@6 main::@return 
Added new block during phi lifting main::@7(between main::@5 and main::@1)
Added new block during phi lifting main::@8(between main::@3 and main::@2)
Block Sequence Planned @begin @1 @end main main::@1 main::@2 main::@4 main::@3 main::@5 main::@6 main::@return main::@7 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::@4
CALL GRAPH
Calls in [] to main:2 

Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Created 6 initial phi equivalence classes
Coalesced [8] main::bits#5 ← main::bits#0
Coalesced [9] main::sc#9 ← main::sc#7
Coalesced [26] main::y#7 ← main::y#1
Coalesced [27] main::sc#8 ← main::sc#2
Coalesced [28] main::bits#6 ← main::bits#1
Coalesced [29] main::sc#10 ← main::sc#1
Coalesced [30] main::x#5 ← main::x#1
Coalesced down to 5 phi equivalence classes
Not culling empty block because it shares successor with its predecessor. (label) main::@4
Culled Empty Block (label) main::@7
Culled Empty Block (label) main::@8
Block Sequence Planned @begin @1 @end main main::@1 main::@2 main::@4 main::@3 main::@5 main::@6 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::@4
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi() [ ] ( )
  to:@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
  asm { sei  }
  [5] *((const byte*) PROCPORT#0) ← (byte/signed byte/word/signed word/dword/signed dword) 50 [ ] ( main:2 [ ] )
  to:main::@1
main::@1: scope:[main]  from main main::@5
  [6] (byte*) main::sc#7 ← phi( main/(const byte*) SCREEN#0 main::@5/(byte*) main::sc#2 ) [ main::y#2 main::sc#7 ] ( main:2 [ main::y#2 main::sc#7 ] )
  [6] (byte) main::y#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@5/(byte) main::y#1 ) [ main::y#2 main::sc#7 ] ( main:2 [ main::y#2 main::sc#7 ] )
  [7] (byte) main::bits#0 ← *((const byte*) main::CHAR_A#0 + (byte) main::y#2) [ main::y#2 main::sc#7 main::bits#0 ] ( main:2 [ main::y#2 main::sc#7 main::bits#0 ] )
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@3
  [8] (byte) main::x#2 ← phi( main::@1/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@3/(byte) main::x#1 ) [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] )
  [8] (byte*) main::sc#3 ← phi( main::@1/(byte*) main::sc#7 main::@3/(byte*) main::sc#1 ) [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] )
  [8] (byte) main::bits#2 ← phi( main::@1/(byte) main::bits#0 main::@3/(byte) main::bits#1 ) [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] )
  [9] (byte~) main::$1 ← (byte) main::bits#2 & (byte/word/signed word/dword/signed dword) 128 [ main::y#2 main::bits#2 main::sc#3 main::x#2 main::$1 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 main::$1 ] )
  [10] if((byte~) main::$1==(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@3 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] )
  to:main::@4
main::@4: scope:[main]  from main::@2
  [11] phi() [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] )
  to:main::@3
main::@3: scope:[main]  from main::@2 main::@4
  [12] (byte) main::c#2 ← phi( main::@2/(byte) '.' main::@4/(byte) '*' ) [ main::y#2 main::bits#2 main::sc#3 main::x#2 main::c#2 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 main::c#2 ] )
  [13] *((byte*) main::sc#3) ← (byte) main::c#2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] )
  [14] (byte*) main::sc#1 ← ++ (byte*) main::sc#3 [ main::y#2 main::bits#2 main::x#2 main::sc#1 ] ( main:2 [ main::y#2 main::bits#2 main::x#2 main::sc#1 ] )
  [15] (byte) main::bits#1 ← (byte) main::bits#2 << (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::y#2 main::x#2 main::bits#1 main::sc#1 ] ( main:2 [ main::y#2 main::x#2 main::bits#1 main::sc#1 ] )
  [16] (byte) main::x#1 ← ++ (byte) main::x#2 [ main::y#2 main::bits#1 main::sc#1 main::x#1 ] ( main:2 [ main::y#2 main::bits#1 main::sc#1 main::x#1 ] )
  [17] if((byte) main::x#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@2 [ main::y#2 main::bits#1 main::sc#1 main::x#1 ] ( main:2 [ main::y#2 main::bits#1 main::sc#1 main::x#1 ] )
  to:main::@5
main::@5: scope:[main]  from main::@3
  [18] (byte*) main::sc#2 ← (byte*) main::sc#1 + (byte/signed byte/word/signed word/dword/signed dword) 32 [ main::y#2 main::sc#2 ] ( main:2 [ main::y#2 main::sc#2 ] )
  [19] (byte) main::y#1 ← ++ (byte) main::y#2 [ main::y#1 main::sc#2 ] ( main:2 [ main::y#1 main::sc#2 ] )
  [20] if((byte) main::y#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@1 [ main::y#1 main::sc#2 ] ( main:2 [ main::y#1 main::sc#2 ] )
  to:main::@6
main::@6: scope:[main]  from main::@5
  [21] *((const byte*) PROCPORT#0) ← (byte/signed byte/word/signed word/dword/signed dword) 55 [ ] ( main:2 [ ] )
  asm { cli  }
  to:main::@return
main::@return: scope:[main]  from main::@6
  [23] 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::@2 dominated by  @1 @begin main::@1 main::@2 main 
main::@4 dominated by  @1 @begin main::@1 main::@2 main main::@4 
main::@3 dominated by  @1 @begin main::@1 main::@2 main main::@3 
main::@5 dominated by  @1 @begin main::@1 main::@2 main main::@5 main::@3 
main::@6 dominated by  @1 @begin main::@1 main::@2 main main::@5 main::@6 main::@3 
main::@return dominated by  main::@return @1 @begin main::@1 main::@2 main main::@5 main::@6 main::@3 

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

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


VARIABLE REGISTER WEIGHTS
(byte*) CHARGEN
(byte*) PROCPORT
(byte*) SCREEN
(void()) main()
(byte~) main::$1 202.0
(byte*) main::CHAR_A
(byte) main::bits
(byte) main::bits#0 22.0
(byte) main::bits#1 67.33333333333333
(byte) main::bits#2 44.85714285714286
(byte) main::c
(byte) main::c#2 101.0
(byte*) main::sc
(byte*) main::sc#1 53.25
(byte*) main::sc#2 7.333333333333333
(byte*) main::sc#3 52.33333333333333
(byte*) main::sc#7 11.0
(byte) main::x
(byte) main::x#1 151.5
(byte) main::x#2 25.25
(byte) main::y
(byte) main::y#1 16.5
(byte) main::y#2 2.5384615384615383

Initial phi equivalence classes
[ main::y#2 main::y#1 ]
[ main::bits#2 main::bits#0 main::bits#1 ]
[ main::sc#3 main::sc#7 main::sc#2 main::sc#1 ]
[ main::x#2 main::x#1 ]
[ main::c#2 ]
Added variable main::$1 to zero page equivalence class [ main::$1 ]
Complete equivalence classes
[ main::y#2 main::y#1 ]
[ main::bits#2 main::bits#0 main::bits#1 ]
[ main::sc#3 main::sc#7 main::sc#2 main::sc#1 ]
[ main::x#2 main::x#1 ]
[ main::c#2 ]
[ main::$1 ]
Allocated zp ZP_BYTE:2 [ main::y#2 main::y#1 ]
Allocated zp ZP_BYTE:3 [ main::bits#2 main::bits#0 main::bits#1 ]
Allocated zp ZP_WORD:4 [ main::sc#3 main::sc#7 main::sc#2 main::sc#1 ]
Allocated zp ZP_BYTE:6 [ main::x#2 main::x#1 ]
Allocated zp ZP_BYTE:7 [ main::c#2 ]
Allocated zp ZP_BYTE:8 [ main::$1 ]

INITIAL ASM
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .label PROCPORT = 1
  .label CHARGEN = $d000
  .label SCREEN = $400
//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 [ ] ( )
  jsr main
//SEG6 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
//SEG7 @end
bend:
//SEG8 main
main: {
    .label CHAR_A = CHARGEN+8
    .label _1 = 8
    .label bits = 3
    .label sc = 4
    .label x = 6
    .label y = 2
    .label c = 7
  //SEG9 asm { sei  }
    sei
  //SEG10 [5] *((const byte*) PROCPORT#0) ← (byte/signed byte/word/signed word/dword/signed dword) 50 [ ] ( main:2 [ ] ) -- _deref_pbuc1=vbuc2 
    lda #$32
    sta PROCPORT
  //SEG11 [6] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
  //SEG12 [6] phi (byte*) main::sc#7 = (const byte*) SCREEN#0 [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<SCREEN
    sta sc
    lda #>SCREEN
    sta sc+1
  //SEG13 [6] phi (byte) main::y#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#1] -- vbuz1=vbuc1 
    lda #0
    sta y
    jmp b1
  //SEG14 [6] phi from main::@5 to main::@1 [phi:main::@5->main::@1]
  b1_from_b5:
  //SEG15 [6] phi (byte*) main::sc#7 = (byte*) main::sc#2 [phi:main::@5->main::@1#0] -- register_copy 
  //SEG16 [6] phi (byte) main::y#2 = (byte) main::y#1 [phi:main::@5->main::@1#1] -- register_copy 
    jmp b1
  //SEG17 main::@1
  b1:
  //SEG18 [7] (byte) main::bits#0 ← *((const byte*) main::CHAR_A#0 + (byte) main::y#2) [ main::y#2 main::sc#7 main::bits#0 ] ( main:2 [ main::y#2 main::sc#7 main::bits#0 ] ) -- vbuz1=pbuc1_derefidx_vbuz2 
    ldy y
    lda CHAR_A,y
    sta bits
  //SEG19 [8] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
  //SEG20 [8] phi (byte) main::x#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@1->main::@2#0] -- vbuz1=vbuc1 
    lda #0
    sta x
  //SEG21 [8] phi (byte*) main::sc#3 = (byte*) main::sc#7 [phi:main::@1->main::@2#1] -- register_copy 
  //SEG22 [8] phi (byte) main::bits#2 = (byte) main::bits#0 [phi:main::@1->main::@2#2] -- register_copy 
    jmp b2
  //SEG23 [8] phi from main::@3 to main::@2 [phi:main::@3->main::@2]
  b2_from_b3:
  //SEG24 [8] phi (byte) main::x#2 = (byte) main::x#1 [phi:main::@3->main::@2#0] -- register_copy 
  //SEG25 [8] phi (byte*) main::sc#3 = (byte*) main::sc#1 [phi:main::@3->main::@2#1] -- register_copy 
  //SEG26 [8] phi (byte) main::bits#2 = (byte) main::bits#1 [phi:main::@3->main::@2#2] -- register_copy 
    jmp b2
  //SEG27 main::@2
  b2:
  //SEG28 [9] (byte~) main::$1 ← (byte) main::bits#2 & (byte/word/signed word/dword/signed dword) 128 [ main::y#2 main::bits#2 main::sc#3 main::x#2 main::$1 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 main::$1 ] ) -- vbuz1=vbuz2_band_vbuc1 
    lda #$80
    and bits
    sta _1
  //SEG29 [10] if((byte~) main::$1==(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@3 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ) -- vbuz1_eq_0_then_la1 
    lda _1
    beq b3_from_b2
  //SEG30 [11] phi from main::@2 to main::@4 [phi:main::@2->main::@4]
  b4_from_b2:
    jmp b4
  //SEG31 main::@4
  b4:
  //SEG32 [12] phi from main::@4 to main::@3 [phi:main::@4->main::@3]
  b3_from_b4:
  //SEG33 [12] phi (byte) main::c#2 = (byte) '*' [phi:main::@4->main::@3#0] -- vbuz1=vbuc1 
    lda #'*'
    sta c
    jmp b3
  //SEG34 [12] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
  b3_from_b2:
  //SEG35 [12] phi (byte) main::c#2 = (byte) '.' [phi:main::@2->main::@3#0] -- vbuz1=vbuc1 
    lda #'.'
    sta c
    jmp b3
  //SEG36 main::@3
  b3:
  //SEG37 [13] *((byte*) main::sc#3) ← (byte) main::c#2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ) -- _deref_pbuz1=vbuz2 
    lda c
    ldy #0
    sta (sc),y
  //SEG38 [14] (byte*) main::sc#1 ← ++ (byte*) main::sc#3 [ main::y#2 main::bits#2 main::x#2 main::sc#1 ] ( main:2 [ main::y#2 main::bits#2 main::x#2 main::sc#1 ] ) -- pbuz1=_inc_pbuz1 
    inc sc
    bne !+
    inc sc+1
  !:
  //SEG39 [15] (byte) main::bits#1 ← (byte) main::bits#2 << (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::y#2 main::x#2 main::bits#1 main::sc#1 ] ( main:2 [ main::y#2 main::x#2 main::bits#1 main::sc#1 ] ) -- vbuz1=vbuz1_rol_1 
    asl bits
  //SEG40 [16] (byte) main::x#1 ← ++ (byte) main::x#2 [ main::y#2 main::bits#1 main::sc#1 main::x#1 ] ( main:2 [ main::y#2 main::bits#1 main::sc#1 main::x#1 ] ) -- vbuz1=_inc_vbuz1 
    inc x
  //SEG41 [17] if((byte) main::x#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@2 [ main::y#2 main::bits#1 main::sc#1 main::x#1 ] ( main:2 [ main::y#2 main::bits#1 main::sc#1 main::x#1 ] ) -- vbuz1_neq_vbuc1_then_la1 
    lda x
    cmp #8
    bne b2_from_b3
    jmp b5
  //SEG42 main::@5
  b5:
  //SEG43 [18] (byte*) main::sc#2 ← (byte*) main::sc#1 + (byte/signed byte/word/signed word/dword/signed dword) 32 [ main::y#2 main::sc#2 ] ( main:2 [ main::y#2 main::sc#2 ] ) -- pbuz1=pbuz1_plus_vbuc1 
    lda sc
    clc
    adc #$20
    sta sc
    bcc !+
    inc sc+1
  !:
  //SEG44 [19] (byte) main::y#1 ← ++ (byte) main::y#2 [ main::y#1 main::sc#2 ] ( main:2 [ main::y#1 main::sc#2 ] ) -- vbuz1=_inc_vbuz1 
    inc y
  //SEG45 [20] if((byte) main::y#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@1 [ main::y#1 main::sc#2 ] ( main:2 [ main::y#1 main::sc#2 ] ) -- vbuz1_neq_vbuc1_then_la1 
    lda y
    cmp #8
    bne b1_from_b5
    jmp b6
  //SEG46 main::@6
  b6:
  //SEG47 [21] *((const byte*) PROCPORT#0) ← (byte/signed byte/word/signed word/dword/signed dword) 55 [ ] ( main:2 [ ] ) -- _deref_pbuc1=vbuc2 
    lda #$37
    sta PROCPORT
  //SEG48 asm { cli  }
    cli
    jmp breturn
  //SEG49 main::@return
  breturn:
  //SEG50 [23] return  [ ] ( main:2 [ ] )
    rts
}

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [5] *((const byte*) PROCPORT#0) ← (byte/signed byte/word/signed word/dword/signed dword) 50 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [9] (byte~) main::$1 ← (byte) main::bits#2 & (byte/word/signed word/dword/signed dword) 128 [ main::y#2 main::bits#2 main::sc#3 main::x#2 main::$1 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 main::$1 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::y#2 main::y#1 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:3 [ main::bits#2 main::bits#0 main::bits#1 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:6 [ main::x#2 main::x#1 ]
Statement [13] *((byte*) main::sc#3) ← (byte) main::c#2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ) always clobbers reg byte y 
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:2 [ main::y#2 main::y#1 ]
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:3 [ main::bits#2 main::bits#0 main::bits#1 ]
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:6 [ main::x#2 main::x#1 ]
Statement [18] (byte*) main::sc#2 ← (byte*) main::sc#1 + (byte/signed byte/word/signed word/dword/signed dword) 32 [ main::y#2 main::sc#2 ] ( main:2 [ main::y#2 main::sc#2 ] ) always clobbers reg byte a 
Statement [21] *((const byte*) PROCPORT#0) ← (byte/signed byte/word/signed word/dword/signed dword) 55 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [5] *((const byte*) PROCPORT#0) ← (byte/signed byte/word/signed word/dword/signed dword) 50 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [7] (byte) main::bits#0 ← *((const byte*) main::CHAR_A#0 + (byte) main::y#2) [ main::y#2 main::sc#7 main::bits#0 ] ( main:2 [ main::y#2 main::sc#7 main::bits#0 ] ) always clobbers reg byte a 
Statement [9] (byte~) main::$1 ← (byte) main::bits#2 & (byte/word/signed word/dword/signed dword) 128 [ main::y#2 main::bits#2 main::sc#3 main::x#2 main::$1 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 main::$1 ] ) always clobbers reg byte a 
Statement [13] *((byte*) main::sc#3) ← (byte) main::c#2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ) always clobbers reg byte y 
Statement [18] (byte*) main::sc#2 ← (byte*) main::sc#1 + (byte/signed byte/word/signed word/dword/signed dword) 32 [ main::y#2 main::sc#2 ] ( main:2 [ main::y#2 main::sc#2 ] ) always clobbers reg byte a 
Statement [21] *((const byte*) PROCPORT#0) ← (byte/signed byte/word/signed word/dword/signed dword) 55 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Potential registers zp ZP_BYTE:2 [ main::y#2 main::y#1 ] : zp ZP_BYTE:2 , reg byte x , 
Potential registers zp ZP_BYTE:3 [ main::bits#2 main::bits#0 main::bits#1 ] : zp ZP_BYTE:3 , reg byte x , 
Potential registers zp ZP_WORD:4 [ main::sc#3 main::sc#7 main::sc#2 main::sc#1 ] : zp ZP_WORD:4 , 
Potential registers zp ZP_BYTE:6 [ main::x#2 main::x#1 ] : zp ZP_BYTE:6 , reg byte x , 
Potential registers zp ZP_BYTE:7 [ main::c#2 ] : zp ZP_BYTE:7 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:8 [ main::$1 ] : zp ZP_BYTE:8 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 202: zp ZP_BYTE:8 [ main::$1 ] 176.75: zp ZP_BYTE:6 [ main::x#2 main::x#1 ] 134.19: zp ZP_BYTE:3 [ main::bits#2 main::bits#0 main::bits#1 ] 123.92: zp ZP_WORD:4 [ main::sc#3 main::sc#7 main::sc#2 main::sc#1 ] 101: zp ZP_BYTE:7 [ main::c#2 ] 19.04: zp ZP_BYTE:2 [ main::y#2 main::y#1 ] 
Uplift Scope [] 

Uplifting [main] best 7232 combination reg byte a [ main::$1 ] reg byte x [ main::x#2 main::x#1 ] zp ZP_BYTE:3 [ main::bits#2 main::bits#0 main::bits#1 ] zp ZP_WORD:4 [ main::sc#3 main::sc#7 main::sc#2 main::sc#1 ] reg byte a [ main::c#2 ] zp ZP_BYTE:2 [ main::y#2 main::y#1 ] 
Uplifting [] best 7232 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:3 [ main::bits#2 main::bits#0 main::bits#1 ]
Uplifting [main] best 7232 combination zp ZP_BYTE:3 [ main::bits#2 main::bits#0 main::bits#1 ] 
Attempting to uplift remaining variables inzp ZP_BYTE:2 [ main::y#2 main::y#1 ]
Uplifting [main] best 7232 combination zp ZP_BYTE:2 [ main::y#2 main::y#1 ] 

ASSEMBLER BEFORE OPTIMIZATION
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .label PROCPORT = 1
  .label CHARGEN = $d000
  .label SCREEN = $400
//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 [ ] ( )
  jsr main
//SEG6 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
//SEG7 @end
bend:
//SEG8 main
main: {
    .label CHAR_A = CHARGEN+8
    .label bits = 3
    .label sc = 4
    .label y = 2
  //SEG9 asm { sei  }
    sei
  //SEG10 [5] *((const byte*) PROCPORT#0) ← (byte/signed byte/word/signed word/dword/signed dword) 50 [ ] ( main:2 [ ] ) -- _deref_pbuc1=vbuc2 
    lda #$32
    sta PROCPORT
  //SEG11 [6] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
  //SEG12 [6] phi (byte*) main::sc#7 = (const byte*) SCREEN#0 [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<SCREEN
    sta sc
    lda #>SCREEN
    sta sc+1
  //SEG13 [6] phi (byte) main::y#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#1] -- vbuz1=vbuc1 
    lda #0
    sta y
    jmp b1
  //SEG14 [6] phi from main::@5 to main::@1 [phi:main::@5->main::@1]
  b1_from_b5:
  //SEG15 [6] phi (byte*) main::sc#7 = (byte*) main::sc#2 [phi:main::@5->main::@1#0] -- register_copy 
  //SEG16 [6] phi (byte) main::y#2 = (byte) main::y#1 [phi:main::@5->main::@1#1] -- register_copy 
    jmp b1
  //SEG17 main::@1
  b1:
  //SEG18 [7] (byte) main::bits#0 ← *((const byte*) main::CHAR_A#0 + (byte) main::y#2) [ main::y#2 main::sc#7 main::bits#0 ] ( main:2 [ main::y#2 main::sc#7 main::bits#0 ] ) -- vbuz1=pbuc1_derefidx_vbuz2 
    ldy y
    lda CHAR_A,y
    sta bits
  //SEG19 [8] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
  //SEG20 [8] phi (byte) main::x#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@1->main::@2#0] -- vbuxx=vbuc1 
    ldx #0
  //SEG21 [8] phi (byte*) main::sc#3 = (byte*) main::sc#7 [phi:main::@1->main::@2#1] -- register_copy 
  //SEG22 [8] phi (byte) main::bits#2 = (byte) main::bits#0 [phi:main::@1->main::@2#2] -- register_copy 
    jmp b2
  //SEG23 [8] phi from main::@3 to main::@2 [phi:main::@3->main::@2]
  b2_from_b3:
  //SEG24 [8] phi (byte) main::x#2 = (byte) main::x#1 [phi:main::@3->main::@2#0] -- register_copy 
  //SEG25 [8] phi (byte*) main::sc#3 = (byte*) main::sc#1 [phi:main::@3->main::@2#1] -- register_copy 
  //SEG26 [8] phi (byte) main::bits#2 = (byte) main::bits#1 [phi:main::@3->main::@2#2] -- register_copy 
    jmp b2
  //SEG27 main::@2
  b2:
  //SEG28 [9] (byte~) main::$1 ← (byte) main::bits#2 & (byte/word/signed word/dword/signed dword) 128 [ main::y#2 main::bits#2 main::sc#3 main::x#2 main::$1 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 main::$1 ] ) -- vbuaa=vbuz1_band_vbuc1 
    lda #$80
    and bits
  //SEG29 [10] if((byte~) main::$1==(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@3 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ) -- vbuaa_eq_0_then_la1 
    cmp #0
    beq b3_from_b2
  //SEG30 [11] phi from main::@2 to main::@4 [phi:main::@2->main::@4]
  b4_from_b2:
    jmp b4
  //SEG31 main::@4
  b4:
  //SEG32 [12] phi from main::@4 to main::@3 [phi:main::@4->main::@3]
  b3_from_b4:
  //SEG33 [12] phi (byte) main::c#2 = (byte) '*' [phi:main::@4->main::@3#0] -- vbuaa=vbuc1 
    lda #'*'
    jmp b3
  //SEG34 [12] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
  b3_from_b2:
  //SEG35 [12] phi (byte) main::c#2 = (byte) '.' [phi:main::@2->main::@3#0] -- vbuaa=vbuc1 
    lda #'.'
    jmp b3
  //SEG36 main::@3
  b3:
  //SEG37 [13] *((byte*) main::sc#3) ← (byte) main::c#2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ) -- _deref_pbuz1=vbuaa 
    ldy #0
    sta (sc),y
  //SEG38 [14] (byte*) main::sc#1 ← ++ (byte*) main::sc#3 [ main::y#2 main::bits#2 main::x#2 main::sc#1 ] ( main:2 [ main::y#2 main::bits#2 main::x#2 main::sc#1 ] ) -- pbuz1=_inc_pbuz1 
    inc sc
    bne !+
    inc sc+1
  !:
  //SEG39 [15] (byte) main::bits#1 ← (byte) main::bits#2 << (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::y#2 main::x#2 main::bits#1 main::sc#1 ] ( main:2 [ main::y#2 main::x#2 main::bits#1 main::sc#1 ] ) -- vbuz1=vbuz1_rol_1 
    asl bits
  //SEG40 [16] (byte) main::x#1 ← ++ (byte) main::x#2 [ main::y#2 main::bits#1 main::sc#1 main::x#1 ] ( main:2 [ main::y#2 main::bits#1 main::sc#1 main::x#1 ] ) -- vbuxx=_inc_vbuxx 
    inx
  //SEG41 [17] if((byte) main::x#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@2 [ main::y#2 main::bits#1 main::sc#1 main::x#1 ] ( main:2 [ main::y#2 main::bits#1 main::sc#1 main::x#1 ] ) -- vbuxx_neq_vbuc1_then_la1 
    cpx #8
    bne b2_from_b3
    jmp b5
  //SEG42 main::@5
  b5:
  //SEG43 [18] (byte*) main::sc#2 ← (byte*) main::sc#1 + (byte/signed byte/word/signed word/dword/signed dword) 32 [ main::y#2 main::sc#2 ] ( main:2 [ main::y#2 main::sc#2 ] ) -- pbuz1=pbuz1_plus_vbuc1 
    lda sc
    clc
    adc #$20
    sta sc
    bcc !+
    inc sc+1
  !:
  //SEG44 [19] (byte) main::y#1 ← ++ (byte) main::y#2 [ main::y#1 main::sc#2 ] ( main:2 [ main::y#1 main::sc#2 ] ) -- vbuz1=_inc_vbuz1 
    inc y
  //SEG45 [20] if((byte) main::y#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@1 [ main::y#1 main::sc#2 ] ( main:2 [ main::y#1 main::sc#2 ] ) -- vbuz1_neq_vbuc1_then_la1 
    lda y
    cmp #8
    bne b1_from_b5
    jmp b6
  //SEG46 main::@6
  b6:
  //SEG47 [21] *((const byte*) PROCPORT#0) ← (byte/signed byte/word/signed word/dword/signed dword) 55 [ ] ( main:2 [ ] ) -- _deref_pbuc1=vbuc2 
    lda #$37
    sta PROCPORT
  //SEG48 asm { cli  }
    cli
    jmp breturn
  //SEG49 main::@return
  breturn:
  //SEG50 [23] return  [ ] ( main:2 [ ] )
    rts
}

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp b4
Removing instruction jmp b3
Removing instruction jmp b5
Removing instruction jmp b6
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b2_from_b3 with b2
Replacing label b1_from_b5 with b1
Removing instruction bbegin:
Removing instruction b1_from_bbegin:
Removing instruction bend_from_b1:
Removing instruction b1_from_b5:
Removing instruction b2_from_b3:
Removing instruction b4_from_b2:
Removing instruction b3_from_b4:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction b1:
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction b2_from_b1:
Removing instruction b4:
Removing instruction b5:
Removing instruction b6:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Relabelling long label b3_from_b2 to b4
Succesful ASM optimization Pass5RelabelLongLabels
Removing instruction jmp b1
Removing instruction jmp b2
Succesful ASM optimization Pass5NextJumpElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte*) CHARGEN
(const byte*) CHARGEN#0 CHARGEN = ((byte*))(word/dword/signed dword) 53248
(byte*) PROCPORT
(const byte*) PROCPORT#0 PROCPORT = ((byte*))(byte/signed byte/word/signed word/dword/signed dword) 1
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) 1024
(void()) main()
(byte~) main::$1 reg byte a 202.0
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@return
(byte*) main::CHAR_A
(const byte*) main::CHAR_A#0 CHAR_A = (const byte*) CHARGEN#0+(byte/signed byte/word/signed word/dword/signed dword) 8
(byte) main::bits
(byte) main::bits#0 bits zp ZP_BYTE:3 22.0
(byte) main::bits#1 bits zp ZP_BYTE:3 67.33333333333333
(byte) main::bits#2 bits zp ZP_BYTE:3 44.85714285714286
(byte) main::c
(byte) main::c#2 reg byte a 101.0
(byte*) main::sc
(byte*) main::sc#1 sc zp ZP_WORD:4 53.25
(byte*) main::sc#2 sc zp ZP_WORD:4 7.333333333333333
(byte*) main::sc#3 sc zp ZP_WORD:4 52.33333333333333
(byte*) main::sc#7 sc zp ZP_WORD:4 11.0
(byte) main::x
(byte) main::x#1 reg byte x 151.5
(byte) main::x#2 reg byte x 25.25
(byte) main::y
(byte) main::y#1 y zp ZP_BYTE:2 16.5
(byte) main::y#2 y zp ZP_BYTE:2 2.5384615384615383

zp ZP_BYTE:2 [ main::y#2 main::y#1 ]
zp ZP_BYTE:3 [ main::bits#2 main::bits#0 main::bits#1 ]
zp ZP_WORD:4 [ main::sc#3 main::sc#7 main::sc#2 main::sc#1 ]
reg byte x [ main::x#2 main::x#1 ]
reg byte a [ main::c#2 ]
reg byte a [ main::$1 ]


FINAL ASSEMBLER
Score: 5633

//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .label PROCPORT = 1
  .label CHARGEN = $d000
  .label SCREEN = $400
//SEG2 @begin
//SEG3 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG4 @1
//SEG5 [2] call main param-assignment [ ] ( )
  jsr main
//SEG6 [3] phi from @1 to @end [phi:@1->@end]
//SEG7 @end
//SEG8 main
main: {
    .label CHAR_A = CHARGEN+8
    .label bits = 3
    .label sc = 4
    .label y = 2
  //SEG9 asm { sei  }
    sei
  //SEG10 [5] *((const byte*) PROCPORT#0) ← (byte/signed byte/word/signed word/dword/signed dword) 50 [ ] ( main:2 [ ] ) -- _deref_pbuc1=vbuc2 
    lda #$32
    sta PROCPORT
  //SEG11 [6] phi from main to main::@1 [phi:main->main::@1]
  //SEG12 [6] phi (byte*) main::sc#7 = (const byte*) SCREEN#0 [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<SCREEN
    sta sc
    lda #>SCREEN
    sta sc+1
  //SEG13 [6] phi (byte) main::y#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#1] -- vbuz1=vbuc1 
    lda #0
    sta y
  //SEG14 [6] phi from main::@5 to main::@1 [phi:main::@5->main::@1]
  //SEG15 [6] phi (byte*) main::sc#7 = (byte*) main::sc#2 [phi:main::@5->main::@1#0] -- register_copy 
  //SEG16 [6] phi (byte) main::y#2 = (byte) main::y#1 [phi:main::@5->main::@1#1] -- register_copy 
  //SEG17 main::@1
  b1:
  //SEG18 [7] (byte) main::bits#0 ← *((const byte*) main::CHAR_A#0 + (byte) main::y#2) [ main::y#2 main::sc#7 main::bits#0 ] ( main:2 [ main::y#2 main::sc#7 main::bits#0 ] ) -- vbuz1=pbuc1_derefidx_vbuz2 
    ldy y
    lda CHAR_A,y
    sta bits
  //SEG19 [8] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  //SEG20 [8] phi (byte) main::x#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@1->main::@2#0] -- vbuxx=vbuc1 
    ldx #0
  //SEG21 [8] phi (byte*) main::sc#3 = (byte*) main::sc#7 [phi:main::@1->main::@2#1] -- register_copy 
  //SEG22 [8] phi (byte) main::bits#2 = (byte) main::bits#0 [phi:main::@1->main::@2#2] -- register_copy 
  //SEG23 [8] phi from main::@3 to main::@2 [phi:main::@3->main::@2]
  //SEG24 [8] phi (byte) main::x#2 = (byte) main::x#1 [phi:main::@3->main::@2#0] -- register_copy 
  //SEG25 [8] phi (byte*) main::sc#3 = (byte*) main::sc#1 [phi:main::@3->main::@2#1] -- register_copy 
  //SEG26 [8] phi (byte) main::bits#2 = (byte) main::bits#1 [phi:main::@3->main::@2#2] -- register_copy 
  //SEG27 main::@2
  b2:
  //SEG28 [9] (byte~) main::$1 ← (byte) main::bits#2 & (byte/word/signed word/dword/signed dword) 128 [ main::y#2 main::bits#2 main::sc#3 main::x#2 main::$1 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 main::$1 ] ) -- vbuaa=vbuz1_band_vbuc1 
    lda #$80
    and bits
  //SEG29 [10] if((byte~) main::$1==(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@3 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ) -- vbuaa_eq_0_then_la1 
    cmp #0
    beq b4
  //SEG30 [11] phi from main::@2 to main::@4 [phi:main::@2->main::@4]
  //SEG31 main::@4
  //SEG32 [12] phi from main::@4 to main::@3 [phi:main::@4->main::@3]
  //SEG33 [12] phi (byte) main::c#2 = (byte) '*' [phi:main::@4->main::@3#0] -- vbuaa=vbuc1 
    lda #'*'
    jmp b3
  //SEG34 [12] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
  b4:
  //SEG35 [12] phi (byte) main::c#2 = (byte) '.' [phi:main::@2->main::@3#0] -- vbuaa=vbuc1 
    lda #'.'
  //SEG36 main::@3
  b3:
  //SEG37 [13] *((byte*) main::sc#3) ← (byte) main::c#2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ) -- _deref_pbuz1=vbuaa 
    ldy #0
    sta (sc),y
  //SEG38 [14] (byte*) main::sc#1 ← ++ (byte*) main::sc#3 [ main::y#2 main::bits#2 main::x#2 main::sc#1 ] ( main:2 [ main::y#2 main::bits#2 main::x#2 main::sc#1 ] ) -- pbuz1=_inc_pbuz1 
    inc sc
    bne !+
    inc sc+1
  !:
  //SEG39 [15] (byte) main::bits#1 ← (byte) main::bits#2 << (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::y#2 main::x#2 main::bits#1 main::sc#1 ] ( main:2 [ main::y#2 main::x#2 main::bits#1 main::sc#1 ] ) -- vbuz1=vbuz1_rol_1 
    asl bits
  //SEG40 [16] (byte) main::x#1 ← ++ (byte) main::x#2 [ main::y#2 main::bits#1 main::sc#1 main::x#1 ] ( main:2 [ main::y#2 main::bits#1 main::sc#1 main::x#1 ] ) -- vbuxx=_inc_vbuxx 
    inx
  //SEG41 [17] if((byte) main::x#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@2 [ main::y#2 main::bits#1 main::sc#1 main::x#1 ] ( main:2 [ main::y#2 main::bits#1 main::sc#1 main::x#1 ] ) -- vbuxx_neq_vbuc1_then_la1 
    cpx #8
    bne b2
  //SEG42 main::@5
  //SEG43 [18] (byte*) main::sc#2 ← (byte*) main::sc#1 + (byte/signed byte/word/signed word/dword/signed dword) 32 [ main::y#2 main::sc#2 ] ( main:2 [ main::y#2 main::sc#2 ] ) -- pbuz1=pbuz1_plus_vbuc1 
    lda sc
    clc
    adc #$20
    sta sc
    bcc !+
    inc sc+1
  !:
  //SEG44 [19] (byte) main::y#1 ← ++ (byte) main::y#2 [ main::y#1 main::sc#2 ] ( main:2 [ main::y#1 main::sc#2 ] ) -- vbuz1=_inc_vbuz1 
    inc y
  //SEG45 [20] if((byte) main::y#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@1 [ main::y#1 main::sc#2 ] ( main:2 [ main::y#1 main::sc#2 ] ) -- vbuz1_neq_vbuc1_then_la1 
    lda y
    cmp #8
    bne b1
  //SEG46 main::@6
  //SEG47 [21] *((const byte*) PROCPORT#0) ← (byte/signed byte/word/signed word/dword/signed dword) 55 [ ] ( main:2 [ ] ) -- _deref_pbuc1=vbuc2 
    lda #$37
    sta PROCPORT
  //SEG48 asm { cli  }
    cli
  //SEG49 main::@return
  //SEG50 [23] return  [ ] ( main:2 [ ] )
    rts
}

