PARSING src/test/java/dk/camelot64/kickc/test/kc/casting.kc
byte* SCREEN = $0400;
byte* SCREEN2 = SCREEN+40*3;
byte* SCREEN3 = SCREEN+40*6;
byte* SCREEN4 = SCREEN+40*9;

void main() {
    for( byte b: 0..100) {
        //Subtract unsigned byte from unsigned byte
        byte b2 = 200-b;
        SCREEN[b] = b2;
        // Cast unsigned byte to signed byte & negate
        signed byte sb = - (signed byte)b;
        SCREEN2[b] = (byte)sb;
    }
    w();
}


void w() {
    for(byte i : 0..10) {
        word w1 = 1300;
        word w2 = 1250;
        byte b = (byte)(w1-w2);
        byte b2 = 1400-1350+i;
        SCREEN3[i] = b;
        SCREEN4[i] = b2;
    }
}


STATEMENTS
  (byte*) SCREEN ← (word/signed word/dword/signed dword) 1024
  (byte/signed byte/word/signed word/dword/signed dword~) $0 ← (byte/signed byte/word/signed word/dword/signed dword) 40 * (byte/signed byte/word/signed word/dword/signed dword) 3
  (byte*~) $1 ← (byte*) SCREEN + (byte/signed byte/word/signed word/dword/signed dword~) $0
  (byte*) SCREEN2 ← (byte*~) $1
  (byte/word/signed word/dword/signed dword~) $2 ← (byte/signed byte/word/signed word/dword/signed dword) 40 * (byte/signed byte/word/signed word/dword/signed dword) 6
  (byte*~) $3 ← (byte*) SCREEN + (byte/word/signed word/dword/signed dword~) $2
  (byte*) SCREEN3 ← (byte*~) $3
  (word/signed word/dword/signed dword~) $4 ← (byte/signed byte/word/signed word/dword/signed dword) 40 * (byte/signed byte/word/signed word/dword/signed dword) 9
  (byte*~) $5 ← (byte*) SCREEN + (word/signed word/dword/signed dword~) $4
  (byte*) SCREEN4 ← (byte*~) $5
proc (void()) main()
  (byte) main::b ← (byte/signed byte/word/signed word/dword/signed dword) 0
main::@1:
  (byte/signed byte/word/signed word/dword/signed dword~) main::$0 ← (byte/word/signed word/dword/signed dword) 200 - (byte) main::b
  (byte) main::b2 ← (byte/signed byte/word/signed word/dword/signed dword~) main::$0
  *((byte*) SCREEN + (byte) main::b) ← (byte) main::b2
  (signed byte~) main::$1 ← ((signed byte)) (byte) main::b
  (signed byte~) main::$2 ← - (signed byte~) main::$1
  (signed byte) main::sb ← (signed byte~) main::$2
  (byte~) main::$3 ← ((byte)) (signed byte) main::sb
  *((byte*) SCREEN2 + (byte) main::b) ← (byte~) main::$3
  (byte) main::b ← ++ (byte) main::b
  (boolean~) main::$4 ← (byte) main::b != (byte/signed byte/word/signed word/dword/signed dword) 101
  if((boolean~) main::$4) goto main::@1
  (void~) main::$5 ← call w 
main::@return:
  return 
endproc // main()
proc (void()) w()
  (byte) w::i ← (byte/signed byte/word/signed word/dword/signed dword) 0
w::@1:
  (word) w::w1 ← (word/signed word/dword/signed dword) 1300
  (word) w::w2 ← (word/signed word/dword/signed dword) 1250
  (word~) w::$0 ← (word) w::w1 - (word) w::w2
  (byte~) w::$1 ← ((byte)) (word~) w::$0
  (byte) w::b ← (byte~) w::$1
  (byte/signed byte/word/signed word/dword/signed dword~) w::$2 ← (word/signed word/dword/signed dword) 1400 - (word/signed word/dword/signed dword) 1350
  (byte/word~) w::$3 ← (byte/signed byte/word/signed word/dword/signed dword~) w::$2 + (byte) w::i
  (byte) w::b2 ← (byte/word~) w::$3
  *((byte*) SCREEN3 + (byte) w::i) ← (byte) w::b
  *((byte*) SCREEN4 + (byte) w::i) ← (byte) w::b2
  (byte) w::i ← ++ (byte) w::i
  (boolean~) w::$4 ← (byte) w::i != (byte/signed byte/word/signed word/dword/signed dword) 11
  if((boolean~) w::$4) goto w::@1
w::@return:
  return 
endproc // w()
  call main 

SYMBOLS
(byte/signed byte/word/signed word/dword/signed dword~) $0
(byte*~) $1
(byte/word/signed word/dword/signed dword~) $2
(byte*~) $3
(word/signed word/dword/signed dword~) $4
(byte*~) $5
(byte*) SCREEN
(byte*) SCREEN2
(byte*) SCREEN3
(byte*) SCREEN4
(void()) main()
(byte/signed byte/word/signed word/dword/signed dword~) main::$0
(signed byte~) main::$1
(signed byte~) main::$2
(byte~) main::$3
(boolean~) main::$4
(void~) main::$5
(label) main::@1
(label) main::@return
(byte) main::b
(byte) main::b2
(signed byte) main::sb
(void()) w()
(word~) w::$0
(byte~) w::$1
(byte/signed byte/word/signed word/dword/signed dword~) w::$2
(byte/word~) w::$3
(boolean~) w::$4
(label) w::@1
(label) w::@return
(byte) w::b
(byte) w::b2
(byte) w::i
(word) w::w1
(word) w::w2

Promoting word/signed word/dword/signed dword to byte* in SCREEN ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  (byte*) SCREEN ← ((byte*)) (word/signed word/dword/signed dword) 1024
  (byte/signed byte/word/signed word/dword/signed dword~) $0 ← (byte/signed byte/word/signed word/dword/signed dword) 40 * (byte/signed byte/word/signed word/dword/signed dword) 3
  (byte*~) $1 ← (byte*) SCREEN + (byte/signed byte/word/signed word/dword/signed dword~) $0
  (byte*) SCREEN2 ← (byte*~) $1
  (byte/word/signed word/dword/signed dword~) $2 ← (byte/signed byte/word/signed word/dword/signed dword) 40 * (byte/signed byte/word/signed word/dword/signed dword) 6
  (byte*~) $3 ← (byte*) SCREEN + (byte/word/signed word/dword/signed dword~) $2
  (byte*) SCREEN3 ← (byte*~) $3
  (word/signed word/dword/signed dword~) $4 ← (byte/signed byte/word/signed word/dword/signed dword) 40 * (byte/signed byte/word/signed word/dword/signed dword) 9
  (byte*~) $5 ← (byte*) SCREEN + (word/signed word/dword/signed dword~) $4
  (byte*) SCREEN4 ← (byte*~) $5
  to:@1
main: scope:[main]  from
  (byte) main::b ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:main::@1
main::@1: scope:[main]  from main main::@1
  (byte/signed byte/word/signed word/dword/signed dword~) main::$0 ← (byte/word/signed word/dword/signed dword) 200 - (byte) main::b
  (byte) main::b2 ← (byte/signed byte/word/signed word/dword/signed dword~) main::$0
  *((byte*) SCREEN + (byte) main::b) ← (byte) main::b2
  (signed byte~) main::$1 ← ((signed byte)) (byte) main::b
  (signed byte~) main::$2 ← - (signed byte~) main::$1
  (signed byte) main::sb ← (signed byte~) main::$2
  (byte~) main::$3 ← ((byte)) (signed byte) main::sb
  *((byte*) SCREEN2 + (byte) main::b) ← (byte~) main::$3
  (byte) main::b ← ++ (byte) main::b
  (boolean~) main::$4 ← (byte) main::b != (byte/signed byte/word/signed word/dword/signed dword) 101
  if((boolean~) main::$4) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1
  (void~) main::$5 ← call w 
  to:main::@return
main::@return: scope:[main]  from main::@2
  return 
  to:@return
@1: scope:[]  from @begin
  to:@2
w: scope:[w]  from
  (byte) w::i ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:w::@1
w::@1: scope:[w]  from w w::@1
  (word) w::w1 ← (word/signed word/dword/signed dword) 1300
  (word) w::w2 ← (word/signed word/dword/signed dword) 1250
  (word~) w::$0 ← (word) w::w1 - (word) w::w2
  (byte~) w::$1 ← ((byte)) (word~) w::$0
  (byte) w::b ← (byte~) w::$1
  (byte/signed byte/word/signed word/dword/signed dword~) w::$2 ← (word/signed word/dword/signed dword) 1400 - (word/signed word/dword/signed dword) 1350
  (byte/word~) w::$3 ← (byte/signed byte/word/signed word/dword/signed dword~) w::$2 + (byte) w::i
  (byte) w::b2 ← (byte/word~) w::$3
  *((byte*) SCREEN3 + (byte) w::i) ← (byte) w::b
  *((byte*) SCREEN4 + (byte) w::i) ← (byte) w::b2
  (byte) w::i ← ++ (byte) w::i
  (boolean~) w::$4 ← (byte) w::i != (byte/signed byte/word/signed word/dword/signed dword) 11
  if((boolean~) w::$4) goto w::@1
  to:w::@2
w::@2: scope:[w]  from w::@1
  to:w::@return
w::@return: scope:[w]  from w::@2
  return 
  to:@return
@2: scope:[]  from @1
  call main 
  to:@end
@end: scope:[]  from @2

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

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

CONTROL FLOW GRAPH SSA WITH ASSIGNMENT CALL & RETURN
@begin: scope:[]  from
  (byte*) SCREEN#0 ← ((byte*)) (word/signed word/dword/signed dword) 1024
  (byte/signed byte/word/signed word/dword/signed dword~) $0 ← (byte/signed byte/word/signed word/dword/signed dword) 40 * (byte/signed byte/word/signed word/dword/signed dword) 3
  (byte*~) $1 ← (byte*) SCREEN#0 + (byte/signed byte/word/signed word/dword/signed dword~) $0
  (byte*) SCREEN2#0 ← (byte*~) $1
  (byte/word/signed word/dword/signed dword~) $2 ← (byte/signed byte/word/signed word/dword/signed dword) 40 * (byte/signed byte/word/signed word/dword/signed dword) 6
  (byte*~) $3 ← (byte*) SCREEN#0 + (byte/word/signed word/dword/signed dword~) $2
  (byte*) SCREEN3#0 ← (byte*~) $3
  (word/signed word/dword/signed dword~) $4 ← (byte/signed byte/word/signed word/dword/signed dword) 40 * (byte/signed byte/word/signed word/dword/signed dword) 9
  (byte*~) $5 ← (byte*) SCREEN#0 + (word/signed word/dword/signed dword~) $4
  (byte*) SCREEN4#0 ← (byte*~) $5
  to:@2
main: scope:[main]  from @2
  (byte*) SCREEN4#5 ← phi( @2/(byte*) SCREEN4#6 )
  (byte*) SCREEN3#5 ← phi( @2/(byte*) SCREEN3#6 )
  (byte*) SCREEN2#2 ← phi( @2/(byte*) SCREEN2#3 )
  (byte*) SCREEN#2 ← phi( @2/(byte*) SCREEN#3 )
  (byte) main::b#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:main::@1
main::@1: scope:[main]  from main main::@1
  (byte*) SCREEN4#4 ← phi( main/(byte*) SCREEN4#5 main::@1/(byte*) SCREEN4#4 )
  (byte*) SCREEN3#4 ← phi( main/(byte*) SCREEN3#5 main::@1/(byte*) SCREEN3#4 )
  (byte*) SCREEN2#1 ← phi( main/(byte*) SCREEN2#2 main::@1/(byte*) SCREEN2#1 )
  (byte*) SCREEN#1 ← phi( main/(byte*) SCREEN#2 main::@1/(byte*) SCREEN#1 )
  (byte) main::b#2 ← phi( main/(byte) main::b#0 main::@1/(byte) main::b#1 )
  (byte/signed byte/word/signed word/dword/signed dword~) main::$0 ← (byte/word/signed word/dword/signed dword) 200 - (byte) main::b#2
  (byte) main::b2#0 ← (byte/signed byte/word/signed word/dword/signed dword~) main::$0
  *((byte*) SCREEN#1 + (byte) main::b#2) ← (byte) main::b2#0
  (signed byte~) main::$1 ← ((signed byte)) (byte) main::b#2
  (signed byte~) main::$2 ← - (signed byte~) main::$1
  (signed byte) main::sb#0 ← (signed byte~) main::$2
  (byte~) main::$3 ← ((byte)) (signed byte) main::sb#0
  *((byte*) SCREEN2#1 + (byte) main::b#2) ← (byte~) main::$3
  (byte) main::b#1 ← ++ (byte) main::b#2
  (boolean~) main::$4 ← (byte) main::b#1 != (byte/signed byte/word/signed word/dword/signed dword) 101
  if((boolean~) main::$4) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1
  (byte*) SCREEN4#3 ← phi( main::@1/(byte*) SCREEN4#4 )
  (byte*) SCREEN3#3 ← phi( main::@1/(byte*) SCREEN3#4 )
  call w param-assignment
  to:main::@3
main::@3: scope:[main]  from main::@2
  to:main::@return
main::@return: scope:[main]  from main::@3
  return 
  to:@return
w: scope:[w]  from main::@2
  (byte*) SCREEN4#2 ← phi( main::@2/(byte*) SCREEN4#3 )
  (byte*) SCREEN3#2 ← phi( main::@2/(byte*) SCREEN3#3 )
  (byte) w::i#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:w::@1
w::@1: scope:[w]  from w w::@1
  (byte*) SCREEN4#1 ← phi( w/(byte*) SCREEN4#2 w::@1/(byte*) SCREEN4#1 )
  (byte*) SCREEN3#1 ← phi( w/(byte*) SCREEN3#2 w::@1/(byte*) SCREEN3#1 )
  (byte) w::i#2 ← phi( w/(byte) w::i#0 w::@1/(byte) w::i#1 )
  (word) w::w1#0 ← (word/signed word/dword/signed dword) 1300
  (word) w::w2#0 ← (word/signed word/dword/signed dword) 1250
  (word~) w::$0 ← (word) w::w1#0 - (word) w::w2#0
  (byte~) w::$1 ← ((byte)) (word~) w::$0
  (byte) w::b#0 ← (byte~) w::$1
  (byte/signed byte/word/signed word/dword/signed dword~) w::$2 ← (word/signed word/dword/signed dword) 1400 - (word/signed word/dword/signed dword) 1350
  (byte/word~) w::$3 ← (byte/signed byte/word/signed word/dword/signed dword~) w::$2 + (byte) w::i#2
  (byte) w::b2#0 ← (byte/word~) w::$3
  *((byte*) SCREEN3#1 + (byte) w::i#2) ← (byte) w::b#0
  *((byte*) SCREEN4#1 + (byte) w::i#2) ← (byte) w::b2#0
  (byte) w::i#1 ← ++ (byte) w::i#2
  (boolean~) w::$4 ← (byte) w::i#1 != (byte/signed byte/word/signed word/dword/signed dword) 11
  if((boolean~) w::$4) goto w::@1
  to:w::@return
w::@return: scope:[w]  from w::@1
  return 
  to:@return
@2: scope:[]  from @begin
  (byte*) SCREEN4#6 ← phi( @begin/(byte*) SCREEN4#0 )
  (byte*) SCREEN3#6 ← phi( @begin/(byte*) SCREEN3#0 )
  (byte*) SCREEN2#3 ← phi( @begin/(byte*) SCREEN2#0 )
  (byte*) SCREEN#3 ← phi( @begin/(byte*) SCREEN#0 )
  call main param-assignment
  to:@3
@3: scope:[]  from @2
  to:@end
@end: scope:[]  from @3

SYMBOL TABLE SSA
(byte/signed byte/word/signed word/dword/signed dword~) $0
(byte*~) $1
(byte/word/signed word/dword/signed dword~) $2
(byte*~) $3
(word/signed word/dword/signed dword~) $4
(byte*~) $5
(label) @2
(label) @3
(label) @begin
(label) @end
(byte*) SCREEN
(byte*) SCREEN#0
(byte*) SCREEN#1
(byte*) SCREEN#2
(byte*) SCREEN#3
(byte*) SCREEN2
(byte*) SCREEN2#0
(byte*) SCREEN2#1
(byte*) SCREEN2#2
(byte*) SCREEN2#3
(byte*) SCREEN3
(byte*) SCREEN3#0
(byte*) SCREEN3#1
(byte*) SCREEN3#2
(byte*) SCREEN3#3
(byte*) SCREEN3#4
(byte*) SCREEN3#5
(byte*) SCREEN3#6
(byte*) SCREEN4
(byte*) SCREEN4#0
(byte*) SCREEN4#1
(byte*) SCREEN4#2
(byte*) SCREEN4#3
(byte*) SCREEN4#4
(byte*) SCREEN4#5
(byte*) SCREEN4#6
(void()) main()
(byte/signed byte/word/signed word/dword/signed dword~) main::$0
(signed byte~) main::$1
(signed byte~) main::$2
(byte~) main::$3
(boolean~) main::$4
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte) main::b
(byte) main::b#0
(byte) main::b#1
(byte) main::b#2
(byte) main::b2
(byte) main::b2#0
(signed byte) main::sb
(signed byte) main::sb#0
(void()) w()
(word~) w::$0
(byte~) w::$1
(byte/signed byte/word/signed word/dword/signed dword~) w::$2
(byte/word~) w::$3
(boolean~) w::$4
(label) w::@1
(label) w::@return
(byte) w::b
(byte) w::b#0
(byte) w::b2
(byte) w::b2#0
(byte) w::i
(byte) w::i#0
(byte) w::i#1
(byte) w::i#2
(word) w::w1
(word) w::w1#0
(word) w::w2
(word) w::w2#0

OPTIMIZING CONTROL FLOW GRAPH
Culled Empty Block (label) main::@3
Culled Empty Block (label) @3
Succesful SSA optimization Pass2CullEmptyBlocks
Not aliassing across scopes: SCREEN#2 SCREEN#3
Not aliassing across scopes: SCREEN2#2 SCREEN2#3
Not aliassing across scopes: SCREEN3#5 SCREEN3#6
Not aliassing across scopes: SCREEN4#5 SCREEN4#6
Not aliassing across scopes: SCREEN3#2 SCREEN3#3
Not aliassing across scopes: SCREEN4#2 SCREEN4#3
Alias (byte*) SCREEN2#0 = (byte*~) $1 (byte*) SCREEN2#3 
Alias (byte*) SCREEN3#0 = (byte*~) $3 (byte*) SCREEN3#6 
Alias (byte*) SCREEN4#0 = (byte*~) $5 (byte*) SCREEN4#6 
Alias (byte) main::b2#0 = (byte/signed byte/word/signed word/dword/signed dword~) main::$0 
Alias (signed byte) main::sb#0 = (signed byte~) main::$2 
Alias (byte*) SCREEN3#3 = (byte*) SCREEN3#4 
Alias (byte*) SCREEN4#3 = (byte*) SCREEN4#4 
Alias (byte) w::b#0 = (byte~) w::$1 
Alias (byte) w::b2#0 = (byte/word~) w::$3 
Alias (byte*) SCREEN#0 = (byte*) SCREEN#3 
Succesful SSA optimization Pass2AliasElimination
Not aliassing across scopes: SCREEN#2 SCREEN#0
Not aliassing across scopes: SCREEN2#2 SCREEN2#0
Not aliassing across scopes: SCREEN3#5 SCREEN3#0
Not aliassing across scopes: SCREEN4#5 SCREEN4#0
Not aliassing across scopes: SCREEN3#2 SCREEN3#3
Not aliassing across scopes: SCREEN4#2 SCREEN4#3
Self Phi Eliminated (byte*) SCREEN#1
Self Phi Eliminated (byte*) SCREEN2#1
Self Phi Eliminated (byte*) SCREEN3#3
Self Phi Eliminated (byte*) SCREEN4#3
Self Phi Eliminated (byte*) SCREEN3#1
Self Phi Eliminated (byte*) SCREEN4#1
Succesful SSA optimization Pass2SelfPhiElimination
Redundant Phi (byte*) SCREEN#2 (byte*) SCREEN#0
Redundant Phi (byte*) SCREEN2#2 (byte*) SCREEN2#0
Redundant Phi (byte*) SCREEN3#5 (byte*) SCREEN3#0
Redundant Phi (byte*) SCREEN4#5 (byte*) SCREEN4#0
Redundant Phi (byte*) SCREEN#1 (byte*) SCREEN#2
Redundant Phi (byte*) SCREEN2#1 (byte*) SCREEN2#2
Redundant Phi (byte*) SCREEN3#3 (byte*) SCREEN3#5
Redundant Phi (byte*) SCREEN4#3 (byte*) SCREEN4#5
Redundant Phi (byte*) SCREEN3#2 (byte*) SCREEN3#3
Redundant Phi (byte*) SCREEN4#2 (byte*) SCREEN4#3
Redundant Phi (byte*) SCREEN3#1 (byte*) SCREEN3#2
Redundant Phi (byte*) SCREEN4#1 (byte*) SCREEN4#2
Succesful SSA optimization Pass2RedundantPhiElimination
Simple Condition (boolean~) main::$4 if((byte) main::b#1!=(byte/signed byte/word/signed word/dword/signed dword) 101) goto main::@1
Simple Condition (boolean~) w::$4 if((byte) w::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto w::@1
Succesful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) SCREEN#0 = ((byte*))1024
Constant (const byte/signed byte/word/signed word/dword/signed dword) $0 = 40*3
Constant (const byte/word/signed word/dword/signed dword) $2 = 40*6
Constant (const word/signed word/dword/signed dword) $4 = 40*9
Constant (const byte) main::b#0 = 0
Constant (const byte) w::i#0 = 0
Constant (const word) w::w1#0 = 1300
Constant (const word) w::w2#0 = 1250
Constant (const byte/signed byte/word/signed word/dword/signed dword) w::$2 = 1400-1350
Succesful SSA optimization Pass2ConstantIdentification
Constant (const byte*) SCREEN2#0 = SCREEN#0+$0
Constant (const byte*) SCREEN3#0 = SCREEN#0+$2
Constant (const byte*) SCREEN4#0 = SCREEN#0+$4
Constant (const word) w::$0 = w::w1#0-w::w2#0
Succesful SSA optimization Pass2ConstantIdentification
Constant (const byte) w::b#0 = ((byte))w::$0
Succesful SSA optimization Pass2ConstantIdentification
Multiple usages for variable. Not optimizing sub-constant (byte) main::b#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::b#2
Multiple usages for variable. Not optimizing sub-constant (byte) w::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) w::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) w::i#2
Eliminating Noop Cast (signed byte~) main::$1 ← ((signed byte)) (byte) main::b#2
Eliminating Noop Cast (byte~) main::$3 ← ((byte)) (signed byte) main::sb#0
Succesful SSA optimization Pass2NopCastElimination
Multiple usages for variable. Not optimizing sub-constant (byte) main::b#2
Multiple usages for variable. Not optimizing sub-constant (byte) main::b#2
Multiple usages for variable. Not optimizing sub-constant (byte) w::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) w::i#2
Multiple usages for variable. Not optimizing sub-constant (byte) w::i#2
OPTIMIZING CONTROL FLOW GRAPH
Inlining constant with var siblings (const byte) main::b#0
Inlining constant with var siblings (const byte) main::b#0
Inlining constant with var siblings (const byte) w::i#0
Inlining constant with var siblings (const byte) w::i#0
Constant inlined $4 = (byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 9
Constant inlined w::i#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Constant inlined main::b#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Constant inlined w::$0 = (const word) w::w1#0-(const word) w::w2#0
Constant inlined $0 = (byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 3
Constant inlined w::$2 = (word/signed word/dword/signed dword) 1400-(word/signed word/dword/signed dword) 1350
Constant inlined $2 = (byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 6
Succesful SSA optimization Pass2ConstantInlining
Block Sequence Planned @begin @2 @end main main::@1 main::@2 main::@return w w::@1 w::@return 
Added new block during phi lifting main::@4(between main::@1 and main::@1)
Added new block during phi lifting w::@3(between w::@1 and w::@1)
Block Sequence Planned @begin @2 @end main main::@1 main::@2 main::@return main::@4 w w::@1 w::@return w::@3 
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@2
Adding NOP phi() at start of w
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to w:13 

Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Created 2 initial phi equivalence classes
Coalesced [15] main::b#3 ← main::b#1
Coalesced [24] w::i#3 ← w::i#1
Coalesced down to 2 phi equivalence classes
Culled Empty Block (label) main::@4
Culled Empty Block (label) w::@3
Block Sequence Planned @begin @2 @end main main::@1 main::@2 main::@return w w::@1 w::@return 
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@2
Adding NOP phi() at start of w
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi() [ ] ( )
  to:@2
@2: scope:[]  from @begin
  [1] phi() [ ] ( )
  [2] call main param-assignment [ ] ( )
  to:@end
@end: scope:[]  from @2
  [3] phi() [ ] ( )
main: scope:[main]  from @2
  [4] phi() [ ] ( main:2 [ ] )
  to:main::@1
main::@1: scope:[main]  from main main::@1
  [5] (byte) main::b#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) main::b#1 ) [ main::b#2 ] ( main:2 [ main::b#2 ] )
  [6] (byte) main::b2#0 ← (byte/word/signed word/dword/signed dword) 200 - (byte) main::b#2 [ main::b#2 main::b2#0 ] ( main:2 [ main::b#2 main::b2#0 ] )
  [7] *((const byte*) SCREEN#0 + (byte) main::b#2) ← (byte) main::b2#0 [ main::b#2 ] ( main:2 [ main::b#2 ] )
  [8] (signed byte) main::sb#0 ← - (signed byte)(byte) main::b#2 [ main::b#2 main::sb#0 ] ( main:2 [ main::b#2 main::sb#0 ] )
  [9] *((const byte*) SCREEN2#0 + (byte) main::b#2) ← (byte)(signed byte) main::sb#0 [ main::b#2 ] ( main:2 [ main::b#2 ] )
  [10] (byte) main::b#1 ← ++ (byte) main::b#2 [ main::b#1 ] ( main:2 [ main::b#1 ] )
  [11] if((byte) main::b#1!=(byte/signed byte/word/signed word/dword/signed dword) 101) goto main::@1 [ main::b#1 ] ( main:2 [ main::b#1 ] )
  to:main::@2
main::@2: scope:[main]  from main::@1
  [12] phi() [ ] ( main:2 [ ] )
  [13] call w param-assignment [ ] ( main:2 [ ] )
  to:main::@return
main::@return: scope:[main]  from main::@2
  [14] return  [ ] ( main:2 [ ] )
  to:@return
w: scope:[w]  from main::@2
  [15] phi() [ ] ( main:2::w:13 [ ] )
  to:w::@1
w::@1: scope:[w]  from w w::@1
  [16] (byte) w::i#2 ← phi( w/(byte/signed byte/word/signed word/dword/signed dword) 0 w::@1/(byte) w::i#1 ) [ w::i#2 ] ( main:2::w:13 [ w::i#2 ] )
  [17] (byte) w::b2#0 ← (word/signed word/dword/signed dword) 1400-(word/signed word/dword/signed dword) 1350 + (byte) w::i#2 [ w::i#2 w::b2#0 ] ( main:2::w:13 [ w::i#2 w::b2#0 ] )
  [18] *((const byte*) SCREEN3#0 + (byte) w::i#2) ← (const byte) w::b#0 [ w::i#2 w::b2#0 ] ( main:2::w:13 [ w::i#2 w::b2#0 ] )
  [19] *((const byte*) SCREEN4#0 + (byte) w::i#2) ← (byte) w::b2#0 [ w::i#2 ] ( main:2::w:13 [ w::i#2 ] )
  [20] (byte) w::i#1 ← ++ (byte) w::i#2 [ w::i#1 ] ( main:2::w:13 [ w::i#1 ] )
  [21] if((byte) w::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto w::@1 [ w::i#1 ] ( main:2::w:13 [ w::i#1 ] )
  to:w::@return
w::@return: scope:[w]  from w::@1
  [22] return  [ ] ( main:2::w:13 [ ] )
  to:@return

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

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

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


VARIABLE REGISTER WEIGHTS
(byte*) SCREEN
(byte*) SCREEN2
(byte*) SCREEN3
(byte*) SCREEN4
(void()) main()
(byte) main::b
(byte) main::b#1 16.5
(byte) main::b#2 11.0
(byte) main::b2
(byte) main::b2#0 22.0
(signed byte) main::sb
(signed byte) main::sb#0 11.0
(void()) w()
(byte) w::b
(byte) w::b2
(byte) w::b2#0 11.0
(byte) w::i
(byte) w::i#1 16.5
(byte) w::i#2 13.75
(word) w::w1
(word) w::w2

Initial phi equivalence classes
[ main::b#2 main::b#1 ]
[ w::i#2 w::i#1 ]
Added variable main::b2#0 to zero page equivalence class [ main::b2#0 ]
Added variable main::sb#0 to zero page equivalence class [ main::sb#0 ]
Added variable w::b2#0 to zero page equivalence class [ w::b2#0 ]
Complete equivalence classes
[ main::b#2 main::b#1 ]
[ w::i#2 w::i#1 ]
[ main::b2#0 ]
[ main::sb#0 ]
[ w::b2#0 ]
Allocated zp ZP_BYTE:2 [ main::b#2 main::b#1 ]
Allocated zp ZP_BYTE:3 [ w::i#2 w::i#1 ]
Allocated zp ZP_BYTE:4 [ main::b2#0 ]
Allocated zp ZP_BYTE:5 [ main::sb#0 ]
Allocated zp ZP_BYTE:6 [ w::b2#0 ]

INITIAL ASM
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .label SCREEN = $400
  .label SCREEN2 = SCREEN+$28*3
  .label SCREEN3 = SCREEN+$28*6
  .label SCREEN4 = SCREEN+$28*9
//SEG2 @begin
bbegin:
//SEG3 [1] phi from @begin to @2 [phi:@begin->@2]
b2_from_bbegin:
  jmp b2
//SEG4 @2
b2:
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @2 to main [phi:@2->main]
main_from_b2:
  jsr main
//SEG7 [3] phi from @2 to @end [phi:@2->@end]
bend_from_b2:
  jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
    .label b2 = 4
    .label sb = 5
    .label b = 2
  //SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
  //SEG11 [5] phi (byte) main::b#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta b
    jmp b1
  //SEG12 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
  //SEG13 [5] phi (byte) main::b#2 = (byte) main::b#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
  //SEG14 main::@1
  b1:
  //SEG15 [6] (byte) main::b2#0 ← (byte/word/signed word/dword/signed dword) 200 - (byte) main::b#2 [ main::b#2 main::b2#0 ] ( main:2 [ main::b#2 main::b2#0 ] ) -- vbuz1=vbuc1_minus_vbuz2 
    lda #$c8
    sec
    sbc b
    sta b2
  //SEG16 [7] *((const byte*) SCREEN#0 + (byte) main::b#2) ← (byte) main::b2#0 [ main::b#2 ] ( main:2 [ main::b#2 ] ) -- pbuc1_derefidx_vbuz1=vbuz2 
    lda b2
    ldy b
    sta SCREEN,y
  //SEG17 [8] (signed byte) main::sb#0 ← - (signed byte)(byte) main::b#2 [ main::b#2 main::sb#0 ] ( main:2 [ main::b#2 main::sb#0 ] ) -- vbsz1=_neg_vbsz2 
    lda b
    eor #$ff
    clc
    adc #1
    sta sb
  //SEG18 [9] *((const byte*) SCREEN2#0 + (byte) main::b#2) ← (byte)(signed byte) main::sb#0 [ main::b#2 ] ( main:2 [ main::b#2 ] ) -- pbuc1_derefidx_vbuz1=vbuz2 
    lda sb
    ldy b
    sta SCREEN2,y
  //SEG19 [10] (byte) main::b#1 ← ++ (byte) main::b#2 [ main::b#1 ] ( main:2 [ main::b#1 ] ) -- vbuz1=_inc_vbuz1 
    inc b
  //SEG20 [11] if((byte) main::b#1!=(byte/signed byte/word/signed word/dword/signed dword) 101) goto main::@1 [ main::b#1 ] ( main:2 [ main::b#1 ] ) -- vbuz1_neq_vbuc1_then_la1 
    lda b
    cmp #$65
    bne b1_from_b1
  //SEG21 [12] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
    jmp b2
  //SEG22 main::@2
  b2:
  //SEG23 [13] call w param-assignment [ ] ( main:2 [ ] )
  //SEG24 [15] phi from main::@2 to w [phi:main::@2->w]
  w_from_b2:
    jsr w
    jmp breturn
  //SEG25 main::@return
  breturn:
  //SEG26 [14] return  [ ] ( main:2 [ ] )
    rts
}
//SEG27 w
w: {
    .const w1 = $514
    .const w2 = $4e2
    .const b = w1-w2
    .label b2 = 6
    .label i = 3
  //SEG28 [16] phi from w to w::@1 [phi:w->w::@1]
  b1_from_w:
  //SEG29 [16] phi (byte) w::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:w->w::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta i
    jmp b1
  //SEG30 [16] phi from w::@1 to w::@1 [phi:w::@1->w::@1]
  b1_from_b1:
  //SEG31 [16] phi (byte) w::i#2 = (byte) w::i#1 [phi:w::@1->w::@1#0] -- register_copy 
    jmp b1
  //SEG32 w::@1
  b1:
  //SEG33 [17] (byte) w::b2#0 ← (word/signed word/dword/signed dword) 1400-(word/signed word/dword/signed dword) 1350 + (byte) w::i#2 [ w::i#2 w::b2#0 ] ( main:2::w:13 [ w::i#2 w::b2#0 ] ) -- vbuz1=vbuc1_plus_vbuz2 
    lda #$578-$546
    clc
    adc i
    sta b2
  //SEG34 [18] *((const byte*) SCREEN3#0 + (byte) w::i#2) ← (const byte) w::b#0 [ w::i#2 w::b2#0 ] ( main:2::w:13 [ w::i#2 w::b2#0 ] ) -- pbuc1_derefidx_vbuz1=vbuc2 
    ldy i
    lda #b
    sta SCREEN3,y
  //SEG35 [19] *((const byte*) SCREEN4#0 + (byte) w::i#2) ← (byte) w::b2#0 [ w::i#2 ] ( main:2::w:13 [ w::i#2 ] ) -- pbuc1_derefidx_vbuz1=vbuz2 
    lda b2
    ldy i
    sta SCREEN4,y
  //SEG36 [20] (byte) w::i#1 ← ++ (byte) w::i#2 [ w::i#1 ] ( main:2::w:13 [ w::i#1 ] ) -- vbuz1=_inc_vbuz1 
    inc i
  //SEG37 [21] if((byte) w::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto w::@1 [ w::i#1 ] ( main:2::w:13 [ w::i#1 ] ) -- vbuz1_neq_vbuc1_then_la1 
    lda i
    cmp #$b
    bne b1_from_b1
    jmp breturn
  //SEG38 w::@return
  breturn:
  //SEG39 [22] return  [ ] ( main:2::w:13 [ ] )
    rts
}

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] (byte) main::b2#0 ← (byte/word/signed word/dword/signed dword) 200 - (byte) main::b#2 [ main::b#2 main::b2#0 ] ( main:2 [ main::b#2 main::b2#0 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::b#2 main::b#1 ]
Statement [8] (signed byte) main::sb#0 ← - (signed byte)(byte) main::b#2 [ main::b#2 main::sb#0 ] ( main:2 [ main::b#2 main::sb#0 ] ) always clobbers reg byte a 
Statement [17] (byte) w::b2#0 ← (word/signed word/dword/signed dword) 1400-(word/signed word/dword/signed dword) 1350 + (byte) w::i#2 [ w::i#2 w::b2#0 ] ( main:2::w:13 [ w::i#2 w::b2#0 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:3 [ w::i#2 w::i#1 ]
Statement [18] *((const byte*) SCREEN3#0 + (byte) w::i#2) ← (const byte) w::b#0 [ w::i#2 w::b2#0 ] ( main:2::w:13 [ w::i#2 w::b2#0 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:6 [ w::b2#0 ]
Statement [19] *((const byte*) SCREEN4#0 + (byte) w::i#2) ← (byte) w::b2#0 [ w::i#2 ] ( main:2::w:13 [ w::i#2 ] ) always clobbers reg byte a 
Statement [6] (byte) main::b2#0 ← (byte/word/signed word/dword/signed dword) 200 - (byte) main::b#2 [ main::b#2 main::b2#0 ] ( main:2 [ main::b#2 main::b2#0 ] ) always clobbers reg byte a 
Statement [8] (signed byte) main::sb#0 ← - (signed byte)(byte) main::b#2 [ main::b#2 main::sb#0 ] ( main:2 [ main::b#2 main::sb#0 ] ) always clobbers reg byte a 
Statement [17] (byte) w::b2#0 ← (word/signed word/dword/signed dword) 1400-(word/signed word/dword/signed dword) 1350 + (byte) w::i#2 [ w::i#2 w::b2#0 ] ( main:2::w:13 [ w::i#2 w::b2#0 ] ) always clobbers reg byte a 
Statement [18] *((const byte*) SCREEN3#0 + (byte) w::i#2) ← (const byte) w::b#0 [ w::i#2 w::b2#0 ] ( main:2::w:13 [ w::i#2 w::b2#0 ] ) always clobbers reg byte a 
Statement [19] *((const byte*) SCREEN4#0 + (byte) w::i#2) ← (byte) w::b2#0 [ w::i#2 ] ( main:2::w:13 [ w::i#2 ] ) always clobbers reg byte a 
Potential registers zp ZP_BYTE:2 [ main::b#2 main::b#1 ] : zp ZP_BYTE:2 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:3 [ w::i#2 w::i#1 ] : zp ZP_BYTE:3 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:4 [ main::b2#0 ] : zp ZP_BYTE:4 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:5 [ main::sb#0 ] : zp ZP_BYTE:5 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:6 [ w::b2#0 ] : zp ZP_BYTE:6 , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 27.5: zp ZP_BYTE:2 [ main::b#2 main::b#1 ] 22: zp ZP_BYTE:4 [ main::b2#0 ] 11: zp ZP_BYTE:5 [ main::sb#0 ] 
Uplift Scope [w] 30.25: zp ZP_BYTE:3 [ w::i#2 w::i#1 ] 11: zp ZP_BYTE:6 [ w::b2#0 ] 
Uplift Scope [] 

Uplifting [main] best 1016 combination reg byte x [ main::b#2 main::b#1 ] reg byte a [ main::b2#0 ] reg byte a [ main::sb#0 ] 
Uplifting [w] best 836 combination reg byte y [ w::i#2 w::i#1 ] reg byte x [ w::b2#0 ] 
Uplifting [] best 836 combination 

ASSEMBLER BEFORE OPTIMIZATION
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .label SCREEN = $400
  .label SCREEN2 = SCREEN+$28*3
  .label SCREEN3 = SCREEN+$28*6
  .label SCREEN4 = SCREEN+$28*9
//SEG2 @begin
bbegin:
//SEG3 [1] phi from @begin to @2 [phi:@begin->@2]
b2_from_bbegin:
  jmp b2
//SEG4 @2
b2:
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @2 to main [phi:@2->main]
main_from_b2:
  jsr main
//SEG7 [3] phi from @2 to @end [phi:@2->@end]
bend_from_b2:
  jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
  //SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
  //SEG11 [5] phi (byte) main::b#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::b#2 = (byte) main::b#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
  //SEG14 main::@1
  b1:
  //SEG15 [6] (byte) main::b2#0 ← (byte/word/signed word/dword/signed dword) 200 - (byte) main::b#2 [ main::b#2 main::b2#0 ] ( main:2 [ main::b#2 main::b2#0 ] ) -- vbuaa=vbuc1_minus_vbuxx 
    txa
    eor #$ff
    clc
    adc #$c8+1
  //SEG16 [7] *((const byte*) SCREEN#0 + (byte) main::b#2) ← (byte) main::b2#0 [ main::b#2 ] ( main:2 [ main::b#2 ] ) -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN,x
  //SEG17 [8] (signed byte) main::sb#0 ← - (signed byte)(byte) main::b#2 [ main::b#2 main::sb#0 ] ( main:2 [ main::b#2 main::sb#0 ] ) -- vbsaa=_neg_vbsxx 
    txa
    eor #$ff
    clc
    adc #1
  //SEG18 [9] *((const byte*) SCREEN2#0 + (byte) main::b#2) ← (byte)(signed byte) main::sb#0 [ main::b#2 ] ( main:2 [ main::b#2 ] ) -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN2,x
  //SEG19 [10] (byte) main::b#1 ← ++ (byte) main::b#2 [ main::b#1 ] ( main:2 [ main::b#1 ] ) -- vbuxx=_inc_vbuxx 
    inx
  //SEG20 [11] if((byte) main::b#1!=(byte/signed byte/word/signed word/dword/signed dword) 101) goto main::@1 [ main::b#1 ] ( main:2 [ main::b#1 ] ) -- vbuxx_neq_vbuc1_then_la1 
    cpx #$65
    bne b1_from_b1
  //SEG21 [12] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
    jmp b2
  //SEG22 main::@2
  b2:
  //SEG23 [13] call w param-assignment [ ] ( main:2 [ ] )
  //SEG24 [15] phi from main::@2 to w [phi:main::@2->w]
  w_from_b2:
    jsr w
    jmp breturn
  //SEG25 main::@return
  breturn:
  //SEG26 [14] return  [ ] ( main:2 [ ] )
    rts
}
//SEG27 w
w: {
    .const w1 = $514
    .const w2 = $4e2
    .const b = w1-w2
  //SEG28 [16] phi from w to w::@1 [phi:w->w::@1]
  b1_from_w:
  //SEG29 [16] phi (byte) w::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:w->w::@1#0] -- vbuyy=vbuc1 
    ldy #0
    jmp b1
  //SEG30 [16] phi from w::@1 to w::@1 [phi:w::@1->w::@1]
  b1_from_b1:
  //SEG31 [16] phi (byte) w::i#2 = (byte) w::i#1 [phi:w::@1->w::@1#0] -- register_copy 
    jmp b1
  //SEG32 w::@1
  b1:
  //SEG33 [17] (byte) w::b2#0 ← (word/signed word/dword/signed dword) 1400-(word/signed word/dword/signed dword) 1350 + (byte) w::i#2 [ w::i#2 w::b2#0 ] ( main:2::w:13 [ w::i#2 w::b2#0 ] ) -- vbuxx=vbuc1_plus_vbuyy 
    tya
    clc
    adc #$578-$546
    tax
  //SEG34 [18] *((const byte*) SCREEN3#0 + (byte) w::i#2) ← (const byte) w::b#0 [ w::i#2 w::b2#0 ] ( main:2::w:13 [ w::i#2 w::b2#0 ] ) -- pbuc1_derefidx_vbuyy=vbuc2 
    lda #b
    sta SCREEN3,y
  //SEG35 [19] *((const byte*) SCREEN4#0 + (byte) w::i#2) ← (byte) w::b2#0 [ w::i#2 ] ( main:2::w:13 [ w::i#2 ] ) -- pbuc1_derefidx_vbuyy=vbuxx 
    txa
    sta SCREEN4,y
  //SEG36 [20] (byte) w::i#1 ← ++ (byte) w::i#2 [ w::i#1 ] ( main:2::w:13 [ w::i#1 ] ) -- vbuyy=_inc_vbuyy 
    iny
  //SEG37 [21] if((byte) w::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto w::@1 [ w::i#1 ] ( main:2::w:13 [ w::i#1 ] ) -- vbuyy_neq_vbuc1_then_la1 
    cpy #$b
    bne b1_from_b1
    jmp breturn
  //SEG38 w::@return
  breturn:
  //SEG39 [22] return  [ ] ( main:2::w:13 [ ] )
    rts
}

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

FINAL SYMBOL TABLE
(label) @2
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) 1024
(byte*) SCREEN2
(const byte*) SCREEN2#0 SCREEN2 = (const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 3
(byte*) SCREEN3
(const byte*) SCREEN3#0 SCREEN3 = (const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 6
(byte*) SCREEN4
(const byte*) SCREEN4#0 SCREEN4 = (const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 9
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(byte) main::b
(byte) main::b#1 reg byte x 16.5
(byte) main::b#2 reg byte x 11.0
(byte) main::b2
(byte) main::b2#0 reg byte a 22.0
(signed byte) main::sb
(signed byte) main::sb#0 reg byte a 11.0
(void()) w()
(label) w::@1
(label) w::@return
(byte) w::b
(const byte) w::b#0 b = ((byte))(const word) w::w1#0-(const word) w::w2#0
(byte) w::b2
(byte) w::b2#0 reg byte x 11.0
(byte) w::i
(byte) w::i#1 reg byte y 16.5
(byte) w::i#2 reg byte y 13.75
(word) w::w1
(const word) w::w1#0 w1 = (word/signed word/dword/signed dword) 1300
(word) w::w2
(const word) w::w2#0 w2 = (word/signed word/dword/signed dword) 1250

reg byte x [ main::b#2 main::b#1 ]
reg byte y [ w::i#2 w::i#1 ]
reg byte a [ main::b2#0 ]
reg byte a [ main::sb#0 ]
reg byte x [ w::b2#0 ]


FINAL ASSEMBLER
Score: 674

//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .label SCREEN = $400
  .label SCREEN2 = SCREEN+$28*3
  .label SCREEN3 = SCREEN+$28*6
  .label SCREEN4 = SCREEN+$28*9
//SEG2 @begin
//SEG3 [1] phi from @begin to @2 [phi:@begin->@2]
//SEG4 @2
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @2 to main [phi:@2->main]
  jsr main
//SEG7 [3] phi from @2 to @end [phi:@2->@end]
//SEG8 @end
//SEG9 main
main: {
  //SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
  //SEG11 [5] phi (byte) main::b#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::b#2 = (byte) main::b#1 [phi:main::@1->main::@1#0] -- register_copy 
  //SEG14 main::@1
  b1:
  //SEG15 [6] (byte) main::b2#0 ← (byte/word/signed word/dword/signed dword) 200 - (byte) main::b#2 [ main::b#2 main::b2#0 ] ( main:2 [ main::b#2 main::b2#0 ] ) -- vbuaa=vbuc1_minus_vbuxx 
    txa
    eor #$ff
    clc
    adc #$c8+1
  //SEG16 [7] *((const byte*) SCREEN#0 + (byte) main::b#2) ← (byte) main::b2#0 [ main::b#2 ] ( main:2 [ main::b#2 ] ) -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN,x
  //SEG17 [8] (signed byte) main::sb#0 ← - (signed byte)(byte) main::b#2 [ main::b#2 main::sb#0 ] ( main:2 [ main::b#2 main::sb#0 ] ) -- vbsaa=_neg_vbsxx 
    txa
    eor #$ff
    clc
    adc #1
  //SEG18 [9] *((const byte*) SCREEN2#0 + (byte) main::b#2) ← (byte)(signed byte) main::sb#0 [ main::b#2 ] ( main:2 [ main::b#2 ] ) -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN2,x
  //SEG19 [10] (byte) main::b#1 ← ++ (byte) main::b#2 [ main::b#1 ] ( main:2 [ main::b#1 ] ) -- vbuxx=_inc_vbuxx 
    inx
  //SEG20 [11] if((byte) main::b#1!=(byte/signed byte/word/signed word/dword/signed dword) 101) goto main::@1 [ main::b#1 ] ( main:2 [ main::b#1 ] ) -- vbuxx_neq_vbuc1_then_la1 
    cpx #$65
    bne b1
  //SEG21 [12] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  //SEG22 main::@2
  //SEG23 [13] call w param-assignment [ ] ( main:2 [ ] )
  //SEG24 [15] phi from main::@2 to w [phi:main::@2->w]
    jsr w
  //SEG25 main::@return
  //SEG26 [14] return  [ ] ( main:2 [ ] )
    rts
}
//SEG27 w
w: {
    .const w1 = $514
    .const w2 = $4e2
    .const b = w1-w2
  //SEG28 [16] phi from w to w::@1 [phi:w->w::@1]
  //SEG29 [16] phi (byte) w::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:w->w::@1#0] -- vbuyy=vbuc1 
    ldy #0
  //SEG30 [16] phi from w::@1 to w::@1 [phi:w::@1->w::@1]
  //SEG31 [16] phi (byte) w::i#2 = (byte) w::i#1 [phi:w::@1->w::@1#0] -- register_copy 
  //SEG32 w::@1
  b1:
  //SEG33 [17] (byte) w::b2#0 ← (word/signed word/dword/signed dword) 1400-(word/signed word/dword/signed dword) 1350 + (byte) w::i#2 [ w::i#2 w::b2#0 ] ( main:2::w:13 [ w::i#2 w::b2#0 ] ) -- vbuxx=vbuc1_plus_vbuyy 
    tya
    clc
    adc #$578-$546
    tax
  //SEG34 [18] *((const byte*) SCREEN3#0 + (byte) w::i#2) ← (const byte) w::b#0 [ w::i#2 w::b2#0 ] ( main:2::w:13 [ w::i#2 w::b2#0 ] ) -- pbuc1_derefidx_vbuyy=vbuc2 
    lda #b
    sta SCREEN3,y
  //SEG35 [19] *((const byte*) SCREEN4#0 + (byte) w::i#2) ← (byte) w::b2#0 [ w::i#2 ] ( main:2::w:13 [ w::i#2 ] ) -- pbuc1_derefidx_vbuyy=vbuxx 
    txa
    sta SCREEN4,y
  //SEG36 [20] (byte) w::i#1 ← ++ (byte) w::i#2 [ w::i#1 ] ( main:2::w:13 [ w::i#1 ] ) -- vbuyy=_inc_vbuyy 
    iny
  //SEG37 [21] if((byte) w::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto w::@1 [ w::i#1 ] ( main:2::w:13 [ w::i#1 ] ) -- vbuyy_neq_vbuc1_then_la1 
    cpy #$b
    bne b1
  //SEG38 w::@return
  //SEG39 [22] return  [ ] ( main:2::w:13 [ ] )
    rts
}

