PARSING src/test/java/dk/camelot64/kickc/test/kc/bresenham.kc
byte STAR = 81;
byte[40*25] SCREEN = $0400;

void main() {
  byte x0 = 4;
  byte y0 = 4;
  byte x1 = 39;
  byte y1 = 24;
  byte xd = x1-x0;
  byte yd = y1-y0;
  byte x = x0;
  byte y = y0;
  byte e = yd/2;
  byte *cursor = SCREEN+y*40+x;
  do  {
      *cursor = STAR;
      x = x + 1;
      cursor = cursor + 1;
      e = e+yd;
      if(xd<=e) {
          y = y+1;
          cursor = cursor + 40;
          e = e - xd;
      }
  } while (x<(x1+1));
}

STATEMENTS
  (byte) STAR ← (byte/signed byte/word/signed word/dword/signed dword) 81
  (byte[1000]) SCREEN ← (word/signed word/dword/signed dword) 1024
proc (void()) main()
  (byte) main::x0 ← (byte/signed byte/word/signed word/dword/signed dword) 4
  (byte) main::y0 ← (byte/signed byte/word/signed word/dword/signed dword) 4
  (byte) main::x1 ← (byte/signed byte/word/signed word/dword/signed dword) 39
  (byte) main::y1 ← (byte/signed byte/word/signed word/dword/signed dword) 24
  (byte/signed byte/word/signed word/dword/signed dword~) main::$0 ← (byte) main::x1 - (byte) main::x0
  (byte) main::xd ← (byte/signed byte/word/signed word/dword/signed dword~) main::$0
  (byte/signed byte/word/signed word/dword/signed dword~) main::$1 ← (byte) main::y1 - (byte) main::y0
  (byte) main::yd ← (byte/signed byte/word/signed word/dword/signed dword~) main::$1
  (byte) main::x ← (byte) main::x0
  (byte) main::y ← (byte) main::y0
  (byte~) main::$2 ← (byte) main::yd / (byte/signed byte/word/signed word/dword/signed dword) 2
  (byte) main::e ← (byte~) main::$2
  (byte~) main::$3 ← (byte) main::y * (byte/signed byte/word/signed word/dword/signed dword) 40
  (byte*~) main::$4 ← (byte[1000]) SCREEN + (byte~) main::$3
  (byte*~) main::$5 ← (byte*~) main::$4 + (byte) main::x
  (byte*) main::cursor ← (byte*~) main::$5
main::@1:
  *((byte*) main::cursor) ← (byte) STAR
  (byte/word~) main::$6 ← (byte) main::x + (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte) main::x ← (byte/word~) main::$6
  (byte*~) main::$7 ← (byte*) main::cursor + (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte*) main::cursor ← (byte*~) main::$7
  (byte/word~) main::$8 ← (byte) main::e + (byte) main::yd
  (byte) main::e ← (byte/word~) main::$8
  (boolean~) main::$9 ← (byte) main::xd <= (byte) main::e
  (boolean~) main::$10 ← ! (boolean~) main::$9
  if((boolean~) main::$10) goto main::@2
  (byte/word~) main::$11 ← (byte) main::y + (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte) main::y ← (byte/word~) main::$11
  (byte*~) main::$12 ← (byte*) main::cursor + (byte/signed byte/word/signed word/dword/signed dword) 40
  (byte*) main::cursor ← (byte*~) main::$12
  (byte/signed byte/word/signed word/dword/signed dword~) main::$13 ← (byte) main::e - (byte) main::xd
  (byte) main::e ← (byte/signed byte/word/signed word/dword/signed dword~) main::$13
main::@2:
  (byte/word~) main::$14 ← (byte) main::x1 + (byte/signed byte/word/signed word/dword/signed dword) 1
  (boolean~) main::$15 ← (byte) main::x < (byte/word~) main::$14
  if((boolean~) main::$15) goto main::@1
main::@return:
  return 
endproc // main()
  call main 

SYMBOLS
(byte[1000]) SCREEN
(byte) STAR
(void()) main()
(byte/signed byte/word/signed word/dword/signed dword~) main::$0
(byte/signed byte/word/signed word/dword/signed dword~) main::$1
(boolean~) main::$10
(byte/word~) main::$11
(byte*~) main::$12
(byte/signed byte/word/signed word/dword/signed dword~) main::$13
(byte/word~) main::$14
(boolean~) main::$15
(byte~) main::$2
(byte~) main::$3
(byte*~) main::$4
(byte*~) main::$5
(byte/word~) main::$6
(byte*~) main::$7
(byte/word~) main::$8
(boolean~) main::$9
(label) main::@1
(label) main::@2
(label) main::@return
(byte*) main::cursor
(byte) main::e
(byte) main::x
(byte) main::x0
(byte) main::x1
(byte) main::xd
(byte) main::y
(byte) main::y0
(byte) main::y1
(byte) main::yd

Promoting word/signed word/dword/signed dword to byte[1000] in SCREEN ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  (byte) STAR ← (byte/signed byte/word/signed word/dword/signed dword) 81
  (byte[1000]) SCREEN ← ((byte*)) (word/signed word/dword/signed dword) 1024
  to:@1
main: scope:[main]  from
  (byte) main::x0 ← (byte/signed byte/word/signed word/dword/signed dword) 4
  (byte) main::y0 ← (byte/signed byte/word/signed word/dword/signed dword) 4
  (byte) main::x1 ← (byte/signed byte/word/signed word/dword/signed dword) 39
  (byte) main::y1 ← (byte/signed byte/word/signed word/dword/signed dword) 24
  (byte/signed byte/word/signed word/dword/signed dword~) main::$0 ← (byte) main::x1 - (byte) main::x0
  (byte) main::xd ← (byte/signed byte/word/signed word/dword/signed dword~) main::$0
  (byte/signed byte/word/signed word/dword/signed dword~) main::$1 ← (byte) main::y1 - (byte) main::y0
  (byte) main::yd ← (byte/signed byte/word/signed word/dword/signed dword~) main::$1
  (byte) main::x ← (byte) main::x0
  (byte) main::y ← (byte) main::y0
  (byte~) main::$2 ← (byte) main::yd / (byte/signed byte/word/signed word/dword/signed dword) 2
  (byte) main::e ← (byte~) main::$2
  (byte~) main::$3 ← (byte) main::y * (byte/signed byte/word/signed word/dword/signed dword) 40
  (byte*~) main::$4 ← (byte[1000]) SCREEN + (byte~) main::$3
  (byte*~) main::$5 ← (byte*~) main::$4 + (byte) main::x
  (byte*) main::cursor ← (byte*~) main::$5
  to:main::@1
main::@1: scope:[main]  from main main::@2
  *((byte*) main::cursor) ← (byte) STAR
  (byte/word~) main::$6 ← (byte) main::x + (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte) main::x ← (byte/word~) main::$6
  (byte*~) main::$7 ← (byte*) main::cursor + (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte*) main::cursor ← (byte*~) main::$7
  (byte/word~) main::$8 ← (byte) main::e + (byte) main::yd
  (byte) main::e ← (byte/word~) main::$8
  (boolean~) main::$9 ← (byte) main::xd <= (byte) main::e
  (boolean~) main::$10 ← ! (boolean~) main::$9
  if((boolean~) main::$10) goto main::@2
  to:main::@3
main::@2: scope:[main]  from main::@1 main::@3
  (byte/word~) main::$14 ← (byte) main::x1 + (byte/signed byte/word/signed word/dword/signed dword) 1
  (boolean~) main::$15 ← (byte) main::x < (byte/word~) main::$14
  if((boolean~) main::$15) goto main::@1
  to:main::@4
main::@3: scope:[main]  from main::@1
  (byte/word~) main::$11 ← (byte) main::y + (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte) main::y ← (byte/word~) main::$11
  (byte*~) main::$12 ← (byte*) main::cursor + (byte/signed byte/word/signed word/dword/signed dword) 40
  (byte*) main::cursor ← (byte*~) main::$12
  (byte/signed byte/word/signed word/dword/signed dword~) main::$13 ← (byte) main::e - (byte) main::xd
  (byte) main::e ← (byte/signed byte/word/signed word/dword/signed dword~) main::$13
  to:main::@2
main::@4: scope:[main]  from main::@2
  to:main::@return
main::@return: scope:[main]  from main::@4
  return 
  to:@return
@1: scope:[]  from @begin
  call main 
  to:@end
@end: scope:[]  from @1

Removing empty block main::@4
PROCEDURE MODIFY VARIABLE ANALYSIS

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

CONTROL FLOW GRAPH SSA WITH ASSIGNMENT CALL & RETURN
@begin: scope:[]  from
  (byte) STAR#0 ← (byte/signed byte/word/signed word/dword/signed dword) 81
  (byte[1000]) SCREEN#0 ← ((byte*)) (word/signed word/dword/signed dword) 1024
  to:@1
main: scope:[main]  from @1
  (byte) STAR#2 ← phi( @1/(byte) STAR#4 )
  (byte) main::x0#0 ← (byte/signed byte/word/signed word/dword/signed dword) 4
  (byte) main::y0#0 ← (byte/signed byte/word/signed word/dword/signed dword) 4
  (byte) main::x1#0 ← (byte/signed byte/word/signed word/dword/signed dword) 39
  (byte) main::y1#0 ← (byte/signed byte/word/signed word/dword/signed dword) 24
  (byte/signed byte/word/signed word/dword/signed dword~) main::$0 ← (byte) main::x1#0 - (byte) main::x0#0
  (byte) main::xd#0 ← (byte/signed byte/word/signed word/dword/signed dword~) main::$0
  (byte/signed byte/word/signed word/dword/signed dword~) main::$1 ← (byte) main::y1#0 - (byte) main::y0#0
  (byte) main::yd#0 ← (byte/signed byte/word/signed word/dword/signed dword~) main::$1
  (byte) main::x#0 ← (byte) main::x0#0
  (byte) main::y#0 ← (byte) main::y0#0
  (byte~) main::$2 ← (byte) main::yd#0 / (byte/signed byte/word/signed word/dword/signed dword) 2
  (byte) main::e#0 ← (byte~) main::$2
  (byte~) main::$3 ← (byte) main::y#0 * (byte/signed byte/word/signed word/dword/signed dword) 40
  (byte*~) main::$4 ← (byte[1000]) SCREEN#0 + (byte~) main::$3
  (byte*~) main::$5 ← (byte*~) main::$4 + (byte) main::x#0
  (byte*) main::cursor#0 ← (byte*~) main::$5
  to:main::@1
main::@1: scope:[main]  from main main::@2
  (byte) main::y#3 ← phi( main/(byte) main::y#0 main::@2/(byte) main::y#4 )
  (byte) main::x1#2 ← phi( main/(byte) main::x1#0 main::@2/(byte) main::x1#1 )
  (byte) main::xd#1 ← phi( main/(byte) main::xd#0 main::@2/(byte) main::xd#3 )
  (byte) main::yd#1 ← phi( main/(byte) main::yd#0 main::@2/(byte) main::yd#2 )
  (byte) main::e#3 ← phi( main/(byte) main::e#0 main::@2/(byte) main::e#5 )
  (byte) main::x#2 ← phi( main/(byte) main::x#0 main::@2/(byte) main::x#3 )
  (byte*) main::cursor#3 ← phi( main/(byte*) main::cursor#0 main::@2/(byte*) main::cursor#5 )
  (byte) STAR#1 ← phi( main/(byte) STAR#2 main::@2/(byte) STAR#3 )
  *((byte*) main::cursor#3) ← (byte) STAR#1
  (byte/word~) main::$6 ← (byte) main::x#2 + (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte) main::x#1 ← (byte/word~) main::$6
  (byte*~) main::$7 ← (byte*) main::cursor#3 + (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte*) main::cursor#1 ← (byte*~) main::$7
  (byte/word~) main::$8 ← (byte) main::e#3 + (byte) main::yd#1
  (byte) main::e#1 ← (byte/word~) main::$8
  (boolean~) main::$9 ← (byte) main::xd#1 <= (byte) main::e#1
  (boolean~) main::$10 ← ! (boolean~) main::$9
  if((boolean~) main::$10) goto main::@2
  to:main::@3
main::@2: scope:[main]  from main::@1 main::@3
  (byte) main::y#4 ← phi( main::@1/(byte) main::y#3 main::@3/(byte) main::y#1 )
  (byte) main::xd#3 ← phi( main::@1/(byte) main::xd#1 main::@3/(byte) main::xd#2 )
  (byte) main::yd#2 ← phi( main::@1/(byte) main::yd#1 main::@3/(byte) main::yd#3 )
  (byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 )
  (byte*) main::cursor#5 ← phi( main::@1/(byte*) main::cursor#1 main::@3/(byte*) main::cursor#2 )
  (byte) STAR#3 ← phi( main::@1/(byte) STAR#1 main::@3/(byte) STAR#5 )
  (byte) main::x#3 ← phi( main::@1/(byte) main::x#1 main::@3/(byte) main::x#4 )
  (byte) main::x1#1 ← phi( main::@1/(byte) main::x1#2 main::@3/(byte) main::x1#3 )
  (byte/word~) main::$14 ← (byte) main::x1#1 + (byte/signed byte/word/signed word/dword/signed dword) 1
  (boolean~) main::$15 ← (byte) main::x#3 < (byte/word~) main::$14
  if((boolean~) main::$15) goto main::@1
  to:main::@return
main::@3: scope:[main]  from main::@1
  (byte) main::yd#3 ← phi( main::@1/(byte) main::yd#1 )
  (byte) STAR#5 ← phi( main::@1/(byte) STAR#1 )
  (byte) main::x#4 ← phi( main::@1/(byte) main::x#1 )
  (byte) main::x1#3 ← phi( main::@1/(byte) main::x1#2 )
  (byte) main::xd#2 ← phi( main::@1/(byte) main::xd#1 )
  (byte) main::e#4 ← phi( main::@1/(byte) main::e#1 )
  (byte*) main::cursor#4 ← phi( main::@1/(byte*) main::cursor#1 )
  (byte) main::y#2 ← phi( main::@1/(byte) main::y#3 )
  (byte/word~) main::$11 ← (byte) main::y#2 + (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte) main::y#1 ← (byte/word~) main::$11
  (byte*~) main::$12 ← (byte*) main::cursor#4 + (byte/signed byte/word/signed word/dword/signed dword) 40
  (byte*) main::cursor#2 ← (byte*~) main::$12
  (byte/signed byte/word/signed word/dword/signed dword~) main::$13 ← (byte) main::e#4 - (byte) main::xd#2
  (byte) main::e#2 ← (byte/signed byte/word/signed word/dword/signed dword~) main::$13
  to:main::@2
main::@return: scope:[main]  from main::@2
  return 
  to:@return
@1: scope:[]  from @begin
  (byte) STAR#4 ← phi( @begin/(byte) STAR#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[1000]) SCREEN
(byte[1000]) SCREEN#0
(byte) STAR
(byte) STAR#0
(byte) STAR#1
(byte) STAR#2
(byte) STAR#3
(byte) STAR#4
(byte) STAR#5
(void()) main()
(byte/signed byte/word/signed word/dword/signed dword~) main::$0
(byte/signed byte/word/signed word/dword/signed dword~) main::$1
(boolean~) main::$10
(byte/word~) main::$11
(byte*~) main::$12
(byte/signed byte/word/signed word/dword/signed dword~) main::$13
(byte/word~) main::$14
(boolean~) main::$15
(byte~) main::$2
(byte~) main::$3
(byte*~) main::$4
(byte*~) main::$5
(byte/word~) main::$6
(byte*~) main::$7
(byte/word~) main::$8
(boolean~) main::$9
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte*) main::cursor
(byte*) main::cursor#0
(byte*) main::cursor#1
(byte*) main::cursor#2
(byte*) main::cursor#3
(byte*) main::cursor#4
(byte*) main::cursor#5
(byte) main::e
(byte) main::e#0
(byte) main::e#1
(byte) main::e#2
(byte) main::e#3
(byte) main::e#4
(byte) main::e#5
(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::x0
(byte) main::x0#0
(byte) main::x1
(byte) main::x1#0
(byte) main::x1#1
(byte) main::x1#2
(byte) main::x1#3
(byte) main::xd
(byte) main::xd#0
(byte) main::xd#1
(byte) main::xd#2
(byte) main::xd#3
(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::y0
(byte) main::y0#0
(byte) main::y1
(byte) main::y1#0
(byte) main::yd
(byte) main::yd#0
(byte) main::yd#1
(byte) main::yd#2
(byte) main::yd#3

OPTIMIZING CONTROL FLOW GRAPH
Culled Empty Block (label) @2
Succesful SSA optimization Pass2CullEmptyBlocks
Inversing boolean not (boolean~) main::$10 ← (byte) main::xd#1 > (byte) main::e#1 from (boolean~) main::$9 ← (byte) main::xd#1 <= (byte) main::e#1
Succesful SSA optimization Pass2UnaryNotSimplification
Not aliassing across scopes: STAR#2 STAR#4
Alias (byte) main::xd#0 = (byte/signed byte/word/signed word/dword/signed dword~) main::$0 
Alias (byte) main::yd#0 = (byte/signed byte/word/signed word/dword/signed dword~) main::$1 
Alias (byte) main::x#0 = (byte) main::x0#0 
Alias (byte) main::y#0 = (byte) main::y0#0 
Alias (byte) main::e#0 = (byte~) main::$2 
Alias (byte*) main::cursor#0 = (byte*~) main::$5 
Alias (byte) main::x#1 = (byte/word~) main::$6 (byte) main::x#4 
Alias (byte*) main::cursor#1 = (byte*~) main::$7 (byte*) main::cursor#4 
Alias (byte) main::e#1 = (byte/word~) main::$8 (byte) main::e#4 
Alias (byte) main::y#2 = (byte) main::y#3 
Alias (byte) main::xd#1 = (byte) main::xd#2 
Alias (byte) main::x1#2 = (byte) main::x1#3 
Alias (byte) STAR#1 = (byte) STAR#5 
Alias (byte) main::yd#1 = (byte) main::yd#3 
Alias (byte) main::y#1 = (byte/word~) main::$11 
Alias (byte*) main::cursor#2 = (byte*~) main::$12 
Alias (byte) main::e#2 = (byte/signed byte/word/signed word/dword/signed dword~) main::$13 
Alias (byte) STAR#0 = (byte) STAR#4 
Succesful SSA optimization Pass2AliasElimination
Not aliassing across scopes: STAR#2 STAR#0
Alias (byte) main::x1#1 = (byte) main::x1#2 
Alias (byte) main::x#1 = (byte) main::x#3 
Alias (byte) STAR#1 = (byte) STAR#3 
Alias (byte) main::yd#1 = (byte) main::yd#2 
Alias (byte) main::xd#1 = (byte) main::xd#3 
Succesful SSA optimization Pass2AliasElimination
Not aliassing across scopes: STAR#2 STAR#0
Self Phi Eliminated (byte) STAR#1
Self Phi Eliminated (byte) main::yd#1
Self Phi Eliminated (byte) main::xd#1
Self Phi Eliminated (byte) main::x1#1
Succesful SSA optimization Pass2SelfPhiElimination
Redundant Phi (byte) STAR#2 (byte) STAR#0
Redundant Phi (byte) STAR#1 (byte) STAR#2
Redundant Phi (byte) main::yd#1 (byte) main::yd#0
Redundant Phi (byte) main::xd#1 (byte) main::xd#0
Redundant Phi (byte) main::x1#1 (byte) main::x1#0
Succesful SSA optimization Pass2RedundantPhiElimination
Simple Condition (boolean~) main::$10 if((byte) main::xd#0>(byte) main::e#1) goto main::@2
Simple Condition (boolean~) main::$15 if((byte) main::x#1<(byte/word~) main::$14) goto main::@1
Succesful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) STAR#0 = 81
Constant (const byte*) SCREEN#0 = ((byte*))1024
Constant (const byte) main::x#0 = 4
Constant (const byte) main::y#0 = 4
Constant (const byte) main::x1#0 = 39
Constant (const byte) main::y1#0 = 24
Succesful SSA optimization Pass2ConstantIdentification
Constant (const byte) main::xd#0 = main::x1#0-main::x#0
Constant (const byte) main::yd#0 = main::y1#0-main::y#0
Constant (const byte) main::$3 = main::y#0*40
Constant (const byte/word) main::$14 = main::x1#0+1
Succesful SSA optimization Pass2ConstantIdentification
Constant (const byte) main::e#0 = main::yd#0/2
Constant (const byte*) main::$4 = SCREEN#0+main::$3
Succesful SSA optimization Pass2ConstantIdentification
Constant (const byte*) main::cursor#0 = main::$4+main::x#0
Succesful SSA optimization Pass2ConstantIdentification
Multiple usages for variable. Not optimizing sub-constant (byte) main::y#2
Multiple usages for variable. Not optimizing sub-constant (byte*) main::cursor#1
Multiple usages for variable. Not optimizing sub-constant (byte) main::y#2
Multiple usages for variable. Not optimizing sub-constant (byte*) main::cursor#1
OPTIMIZING CONTROL FLOW GRAPH
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::y#0
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::e#0
Inlining constant with var siblings (const byte) main::e#0
Inlining constant with var siblings (const byte) main::e#0
Inlining constant with var siblings (const byte) main::e#0
Inlining constant with var siblings (const byte*) main::cursor#0
Inlining constant with var siblings (const byte*) main::cursor#0
Inlining constant with var siblings (const byte*) main::cursor#0
Inlining constant with var siblings (const byte*) main::cursor#0
Constant inlined main::cursor#0 = (const byte*) SCREEN#0+(byte/signed byte/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) 4
Constant inlined main::$3 = (byte/signed byte/word/signed word/dword/signed dword) 4*(byte/signed byte/word/signed word/dword/signed dword) 40
Constant inlined main::$14 = (const byte) main::x1#0+(byte/signed byte/word/signed word/dword/signed dword) 1
Constant inlined main::x#0 = (byte/signed byte/word/signed word/dword/signed dword) 4
Constant inlined main::$4 = (const byte*) SCREEN#0+(byte/signed byte/word/signed word/dword/signed dword) 4*(byte/signed byte/word/signed word/dword/signed dword) 40
Constant inlined main::y#0 = (byte/signed byte/word/signed word/dword/signed dword) 4
Constant inlined main::e#0 = (const byte) main::yd#0/(byte/signed byte/word/signed word/dword/signed dword) 2
Succesful SSA optimization Pass2ConstantInlining
Block Sequence Planned @begin @1 @end main main::@1 main::@3 main::@2 main::@return 
Added new block during phi lifting main::@5(between main::@2 and main::@1)
Added new block during phi lifting main::@6(between main::@1 and main::@2)
Block Sequence Planned @begin @1 @end main main::@1 main::@3 main::@2 main::@return main::@5 main::@6 
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
CALL GRAPH
Calls in [] to main:2 

Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
Created 7 initial phi equivalence classes
Coalesced [14] main::cursor#8 ← main::cursor#2
Coalesced [15] main::e#8 ← main::e#2
Coalesced [16] main::y#7 ← main::y#1
Coalesced [20] main::cursor#6 ← main::cursor#5
Coalesced [21] main::x#5 ← main::x#1
Coalesced [22] main::e#6 ← main::e#5
Coalesced [23] main::y#5 ← main::y#4
Coalesced [24] main::cursor#7 ← main::cursor#1
Coalesced [25] main::e#7 ← main::e#1
Coalesced (already) [26] main::y#6 ← main::y#2
Coalesced down to 4 phi equivalence classes
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@6
Block Sequence Planned @begin @1 @end main main::@1 main::@3 main::@2 main::@return 
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Propagating live ranges...
Propagating live ranges...
Propagating live ranges...
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
  [4] phi() [ ] ( main:2 [ ] )
  to:main::@1
main::@1: scope:[main]  from main main::@2
  [5] (byte) main::y#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 4 main::@2/(byte) main::y#4 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] )
  [5] (byte) main::e#3 ← phi( main/(const byte) main::yd#0/(byte/signed byte/word/signed word/dword/signed dword) 2 main::@2/(byte) main::e#5 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] )
  [5] (byte) main::x#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 4 main::@2/(byte) main::x#1 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] )
  [5] (byte*) main::cursor#3 ← phi( main/(const byte*) SCREEN#0+(byte/signed byte/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) 4 main::@2/(byte*) main::cursor#5 ) [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] )
  [6] *((byte*) main::cursor#3) ← (const byte) STAR#0 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] )
  [7] (byte) main::x#1 ← (byte) main::x#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::cursor#3 main::e#3 main::y#2 main::x#1 ] ( main:2 [ main::cursor#3 main::e#3 main::y#2 main::x#1 ] )
  [8] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::e#3 main::y#2 main::x#1 main::cursor#1 ] ( main:2 [ main::e#3 main::y#2 main::x#1 main::cursor#1 ] )
  [9] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::yd#0 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ] ( main:2 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ] )
  [10] if((const byte) main::xd#0>(byte) main::e#1) goto main::@2 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ] ( main:2 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ] )
  to:main::@3
main::@3: scope:[main]  from main::@1
  [11] (byte) main::y#1 ← (byte) main::y#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::x#1 main::cursor#1 main::e#1 main::y#1 ] ( main:2 [ main::x#1 main::cursor#1 main::e#1 main::y#1 ] )
  [12] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::x#1 main::e#1 main::y#1 main::cursor#2 ] ( main:2 [ main::x#1 main::e#1 main::y#1 main::cursor#2 ] )
  [13] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#0 [ main::x#1 main::y#1 main::cursor#2 main::e#2 ] ( main:2 [ main::x#1 main::y#1 main::cursor#2 main::e#2 ] )
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@3
  [14] (byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 ) [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] ( main:2 [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] )
  [14] (byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 ) [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] ( main:2 [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] )
  [14] (byte*) main::cursor#5 ← phi( main::@1/(byte*) main::cursor#1 main::@3/(byte*) main::cursor#2 ) [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] ( main:2 [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] )
  [15] if((byte) main::x#1<(const byte) main::x1#0+(byte/signed byte/word/signed word/dword/signed dword) 1) goto main::@1 [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] ( main:2 [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] )
  to:main::@return
main::@return: scope:[main]  from main::@2
  [16] return  [ ] ( main:2 [ ] )
  to:@return

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

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

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


VARIABLE REGISTER WEIGHTS
(byte[1000]) SCREEN
(byte) STAR
(void()) main()
(byte*) main::cursor
(byte*) main::cursor#1 8.25
(byte*) main::cursor#2 11.0
(byte*) main::cursor#3 11.0
(byte*) main::cursor#5 16.5
(byte) main::e
(byte) main::e#1 11.0
(byte) main::e#2 22.0
(byte) main::e#3 5.5
(byte) main::e#5 16.5
(byte) main::x
(byte) main::x#1 3.666666666666667
(byte) main::x#2 11.0
(byte) main::x0
(byte) main::x1
(byte) main::xd
(byte) main::y
(byte) main::y#1 7.333333333333333
(byte) main::y#2 5.5
(byte) main::y#4 16.5
(byte) main::y0
(byte) main::y1
(byte) main::yd

Initial phi equivalence classes
[ main::cursor#3 main::cursor#5 main::cursor#1 main::cursor#2 ]
[ main::x#2 main::x#1 ]
[ main::e#3 main::e#5 main::e#1 main::e#2 ]
[ main::y#2 main::y#4 main::y#1 ]
Complete equivalence classes
[ main::cursor#3 main::cursor#5 main::cursor#1 main::cursor#2 ]
[ main::x#2 main::x#1 ]
[ main::e#3 main::e#5 main::e#1 main::e#2 ]
[ main::y#2 main::y#4 main::y#1 ]
Allocated zp ZP_WORD:2 [ main::cursor#3 main::cursor#5 main::cursor#1 main::cursor#2 ]
Allocated zp ZP_BYTE:4 [ main::x#2 main::x#1 ]
Allocated zp ZP_BYTE:5 [ main::e#3 main::e#5 main::e#1 main::e#2 ]
Allocated zp ZP_BYTE:6 [ main::y#2 main::y#4 main::y#1 ]

INITIAL ASM
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .const STAR = $51
  .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 [ ] ( )
//SEG6 [4] phi from @1 to main [phi:@1->main]
main_from_b1:
  jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
    .const x1 = $27
    .const y1 = $18
    .const xd = x1-4
    .const yd = y1-4
    .label x = 4
    .label cursor = 2
    .label e = 5
    .label y = 6
  //SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
  //SEG11 [5] phi (byte) main::y#2 = (byte/signed byte/word/signed word/dword/signed dword) 4 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #4
    sta y
  //SEG12 [5] phi (byte) main::e#3 = (const byte) main::yd#0/(byte/signed byte/word/signed word/dword/signed dword) 2 [phi:main->main::@1#1] -- vbuz1=vbuc1 
    lda #yd/2
    sta e
  //SEG13 [5] phi (byte) main::x#2 = (byte/signed byte/word/signed word/dword/signed dword) 4 [phi:main->main::@1#2] -- vbuz1=vbuc1 
    lda #4
    sta x
  //SEG14 [5] phi (byte*) main::cursor#3 = (const byte*) SCREEN#0+(byte/signed byte/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) 4 [phi:main->main::@1#3] -- pbuz1=pbuc1 
    lda #<SCREEN+4*$28+4
    sta cursor
    lda #>SCREEN+4*$28+4
    sta cursor+1
    jmp b1
  //SEG15 [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  b1_from_b2:
  //SEG16 [5] phi (byte) main::y#2 = (byte) main::y#4 [phi:main::@2->main::@1#0] -- register_copy 
  //SEG17 [5] phi (byte) main::e#3 = (byte) main::e#5 [phi:main::@2->main::@1#1] -- register_copy 
  //SEG18 [5] phi (byte) main::x#2 = (byte) main::x#1 [phi:main::@2->main::@1#2] -- register_copy 
  //SEG19 [5] phi (byte*) main::cursor#3 = (byte*) main::cursor#5 [phi:main::@2->main::@1#3] -- register_copy 
    jmp b1
  //SEG20 main::@1
  b1:
  //SEG21 [6] *((byte*) main::cursor#3) ← (const byte) STAR#0 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ) -- _deref_pbuz1=vbuc1 
    lda #STAR
    ldy #0
    sta (cursor),y
  //SEG22 [7] (byte) main::x#1 ← (byte) main::x#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::cursor#3 main::e#3 main::y#2 main::x#1 ] ( main:2 [ main::cursor#3 main::e#3 main::y#2 main::x#1 ] ) -- vbuz1=vbuz1_plus_1 
    inc x
  //SEG23 [8] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::e#3 main::y#2 main::x#1 main::cursor#1 ] ( main:2 [ main::e#3 main::y#2 main::x#1 main::cursor#1 ] ) -- pbuz1=pbuz1_plus_1 
    inc cursor
    bne !+
    inc cursor+1
  !:
  //SEG24 [9] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::yd#0 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ] ( main:2 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ] ) -- vbuz1=vbuz1_plus_vbuc1 
    lda #yd
    clc
    adc e
    sta e
  //SEG25 [10] if((const byte) main::xd#0>(byte) main::e#1) goto main::@2 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ] ( main:2 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ] ) -- vbuc1_gt_vbuz1_then_la1 
    lda e
    cmp #xd
    bcc b2_from_b1
    jmp b3
  //SEG26 main::@3
  b3:
  //SEG27 [11] (byte) main::y#1 ← (byte) main::y#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::x#1 main::cursor#1 main::e#1 main::y#1 ] ( main:2 [ main::x#1 main::cursor#1 main::e#1 main::y#1 ] ) -- vbuz1=vbuz1_plus_1 
    inc y
  //SEG28 [12] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::x#1 main::e#1 main::y#1 main::cursor#2 ] ( main:2 [ main::x#1 main::e#1 main::y#1 main::cursor#2 ] ) -- pbuz1=pbuz1_plus_vbuc1 
    lda cursor
    clc
    adc #$28
    sta cursor
    bcc !+
    inc cursor+1
  !:
  //SEG29 [13] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#0 [ main::x#1 main::y#1 main::cursor#2 main::e#2 ] ( main:2 [ main::x#1 main::y#1 main::cursor#2 main::e#2 ] ) -- vbuz1=vbuz1_minus_vbuc1 
    lda e
    sec
    sbc #xd
    sta e
  //SEG30 [14] phi from main::@1 main::@3 to main::@2 [phi:main::@1/main::@3->main::@2]
  b2_from_b1:
  b2_from_b3:
  //SEG31 [14] phi (byte) main::y#4 = (byte) main::y#2 [phi:main::@1/main::@3->main::@2#0] -- register_copy 
  //SEG32 [14] phi (byte) main::e#5 = (byte) main::e#1 [phi:main::@1/main::@3->main::@2#1] -- register_copy 
  //SEG33 [14] phi (byte*) main::cursor#5 = (byte*) main::cursor#1 [phi:main::@1/main::@3->main::@2#2] -- register_copy 
    jmp b2
  //SEG34 main::@2
  b2:
  //SEG35 [15] if((byte) main::x#1<(const byte) main::x1#0+(byte/signed byte/word/signed word/dword/signed dword) 1) goto main::@1 [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] ( main:2 [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] ) -- vbuz1_lt_vbuc1_then_la1 
    lda x
    cmp #x1+1
    bcc b1_from_b2
    jmp breturn
  //SEG36 main::@return
  breturn:
  //SEG37 [16] return  [ ] ( main:2 [ ] )
    rts
}

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] *((byte*) main::cursor#3) ← (const byte) STAR#0 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ) always clobbers reg byte a reg byte y 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:4 [ main::x#2 main::x#1 ]
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:4 [ main::x#2 main::x#1 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:5 [ main::e#3 main::e#5 main::e#1 main::e#2 ]
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:5 [ main::e#3 main::e#5 main::e#1 main::e#2 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:6 [ main::y#2 main::y#4 main::y#1 ]
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:6 [ main::y#2 main::y#4 main::y#1 ]
Statement [9] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::yd#0 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ] ( main:2 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ] ) always clobbers reg byte a 
Statement [12] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::x#1 main::e#1 main::y#1 main::cursor#2 ] ( main:2 [ main::x#1 main::e#1 main::y#1 main::cursor#2 ] ) always clobbers reg byte a 
Statement [13] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#0 [ main::x#1 main::y#1 main::cursor#2 main::e#2 ] ( main:2 [ main::x#1 main::y#1 main::cursor#2 main::e#2 ] ) always clobbers reg byte a 
Statement [6] *((byte*) main::cursor#3) ← (const byte) STAR#0 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ) always clobbers reg byte a reg byte y 
Statement [9] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::yd#0 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ] ( main:2 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ] ) always clobbers reg byte a 
Statement [12] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::x#1 main::e#1 main::y#1 main::cursor#2 ] ( main:2 [ main::x#1 main::e#1 main::y#1 main::cursor#2 ] ) always clobbers reg byte a 
Statement [13] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#0 [ main::x#1 main::y#1 main::cursor#2 main::e#2 ] ( main:2 [ main::x#1 main::y#1 main::cursor#2 main::e#2 ] ) always clobbers reg byte a 
Potential registers zp ZP_WORD:2 [ main::cursor#3 main::cursor#5 main::cursor#1 main::cursor#2 ] : zp ZP_WORD:2 , 
Potential registers zp ZP_BYTE:4 [ main::x#2 main::x#1 ] : zp ZP_BYTE:4 , reg byte x , 
Potential registers zp ZP_BYTE:5 [ main::e#3 main::e#5 main::e#1 main::e#2 ] : zp ZP_BYTE:5 , reg byte x , 
Potential registers zp ZP_BYTE:6 [ main::y#2 main::y#4 main::y#1 ] : zp ZP_BYTE:6 , reg byte x , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 55: zp ZP_BYTE:5 [ main::e#3 main::e#5 main::e#1 main::e#2 ] 46.75: zp ZP_WORD:2 [ main::cursor#3 main::cursor#5 main::cursor#1 main::cursor#2 ] 29.33: zp ZP_BYTE:6 [ main::y#2 main::y#4 main::y#1 ] 14.67: zp ZP_BYTE:4 [ main::x#2 main::x#1 ] 
Uplift Scope [] 

Uplifting [main] best 1168 combination reg byte x [ main::e#3 main::e#5 main::e#1 main::e#2 ] zp ZP_WORD:2 [ main::cursor#3 main::cursor#5 main::cursor#1 main::cursor#2 ] zp ZP_BYTE:6 [ main::y#2 main::y#4 main::y#1 ] zp ZP_BYTE:4 [ main::x#2 main::x#1 ] 
Uplifting [] best 1168 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:6 [ main::y#2 main::y#4 main::y#1 ]
Uplifting [main] best 1168 combination zp ZP_BYTE:6 [ main::y#2 main::y#4 main::y#1 ] 
Attempting to uplift remaining variables inzp ZP_BYTE:4 [ main::x#2 main::x#1 ]
Uplifting [main] best 1168 combination zp ZP_BYTE:4 [ main::x#2 main::x#1 ] 
Allocated (was zp ZP_BYTE:6) zp ZP_BYTE:5 [ main::y#2 main::y#4 main::y#1 ]

ASSEMBLER BEFORE OPTIMIZATION
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .const STAR = $51
  .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 [ ] ( )
//SEG6 [4] phi from @1 to main [phi:@1->main]
main_from_b1:
  jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
    .const x1 = $27
    .const y1 = $18
    .const xd = x1-4
    .const yd = y1-4
    .label x = 4
    .label cursor = 2
    .label y = 5
  //SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
  //SEG11 [5] phi (byte) main::y#2 = (byte/signed byte/word/signed word/dword/signed dword) 4 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #4
    sta y
  //SEG12 [5] phi (byte) main::e#3 = (const byte) main::yd#0/(byte/signed byte/word/signed word/dword/signed dword) 2 [phi:main->main::@1#1] -- vbuxx=vbuc1 
    ldx #yd/2
  //SEG13 [5] phi (byte) main::x#2 = (byte/signed byte/word/signed word/dword/signed dword) 4 [phi:main->main::@1#2] -- vbuz1=vbuc1 
    lda #4
    sta x
  //SEG14 [5] phi (byte*) main::cursor#3 = (const byte*) SCREEN#0+(byte/signed byte/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) 4 [phi:main->main::@1#3] -- pbuz1=pbuc1 
    lda #<SCREEN+4*$28+4
    sta cursor
    lda #>SCREEN+4*$28+4
    sta cursor+1
    jmp b1
  //SEG15 [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  b1_from_b2:
  //SEG16 [5] phi (byte) main::y#2 = (byte) main::y#4 [phi:main::@2->main::@1#0] -- register_copy 
  //SEG17 [5] phi (byte) main::e#3 = (byte) main::e#5 [phi:main::@2->main::@1#1] -- register_copy 
  //SEG18 [5] phi (byte) main::x#2 = (byte) main::x#1 [phi:main::@2->main::@1#2] -- register_copy 
  //SEG19 [5] phi (byte*) main::cursor#3 = (byte*) main::cursor#5 [phi:main::@2->main::@1#3] -- register_copy 
    jmp b1
  //SEG20 main::@1
  b1:
  //SEG21 [6] *((byte*) main::cursor#3) ← (const byte) STAR#0 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ) -- _deref_pbuz1=vbuc1 
    lda #STAR
    ldy #0
    sta (cursor),y
  //SEG22 [7] (byte) main::x#1 ← (byte) main::x#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::cursor#3 main::e#3 main::y#2 main::x#1 ] ( main:2 [ main::cursor#3 main::e#3 main::y#2 main::x#1 ] ) -- vbuz1=vbuz1_plus_1 
    inc x
  //SEG23 [8] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::e#3 main::y#2 main::x#1 main::cursor#1 ] ( main:2 [ main::e#3 main::y#2 main::x#1 main::cursor#1 ] ) -- pbuz1=pbuz1_plus_1 
    inc cursor
    bne !+
    inc cursor+1
  !:
  //SEG24 [9] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::yd#0 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ] ( main:2 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ] ) -- vbuxx=vbuxx_plus_vbuc1 
    txa
    clc
    adc #yd
    tax
  //SEG25 [10] if((const byte) main::xd#0>(byte) main::e#1) goto main::@2 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ] ( main:2 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ] ) -- vbuc1_gt_vbuxx_then_la1 
    cpx #xd
    bcc b2_from_b1
    jmp b3
  //SEG26 main::@3
  b3:
  //SEG27 [11] (byte) main::y#1 ← (byte) main::y#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::x#1 main::cursor#1 main::e#1 main::y#1 ] ( main:2 [ main::x#1 main::cursor#1 main::e#1 main::y#1 ] ) -- vbuz1=vbuz1_plus_1 
    inc y
  //SEG28 [12] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::x#1 main::e#1 main::y#1 main::cursor#2 ] ( main:2 [ main::x#1 main::e#1 main::y#1 main::cursor#2 ] ) -- pbuz1=pbuz1_plus_vbuc1 
    lda cursor
    clc
    adc #$28
    sta cursor
    bcc !+
    inc cursor+1
  !:
  //SEG29 [13] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#0 [ main::x#1 main::y#1 main::cursor#2 main::e#2 ] ( main:2 [ main::x#1 main::y#1 main::cursor#2 main::e#2 ] ) -- vbuxx=vbuxx_minus_vbuc1 
    txa
    sec
    sbc #xd
    tax
  //SEG30 [14] phi from main::@1 main::@3 to main::@2 [phi:main::@1/main::@3->main::@2]
  b2_from_b1:
  b2_from_b3:
  //SEG31 [14] phi (byte) main::y#4 = (byte) main::y#2 [phi:main::@1/main::@3->main::@2#0] -- register_copy 
  //SEG32 [14] phi (byte) main::e#5 = (byte) main::e#1 [phi:main::@1/main::@3->main::@2#1] -- register_copy 
  //SEG33 [14] phi (byte*) main::cursor#5 = (byte*) main::cursor#1 [phi:main::@1/main::@3->main::@2#2] -- register_copy 
    jmp b2
  //SEG34 main::@2
  b2:
  //SEG35 [15] if((byte) main::x#1<(const byte) main::x1#0+(byte/signed byte/word/signed word/dword/signed dword) 1) goto main::@1 [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] ( main:2 [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] ) -- vbuz1_lt_vbuc1_then_la1 
    lda x
    cmp #x1+1
    bcc b1_from_b2
    jmp breturn
  //SEG36 main::@return
  breturn:
  //SEG37 [16] return  [ ] ( main:2 [ ] )
    rts
}

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b3
Removing instruction jmp b2
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda #4
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Replacing label b2_from_b1 with b2
Replacing label b1_from_b2 with b1
Removing instruction bbegin:
Removing instruction b1_from_bbegin:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_b2:
Removing instruction b2_from_b1:
Removing instruction b2_from_b3:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction b1:
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction b3:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jmp b1
Succesful ASM optimization Pass5NextJumpElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte[1000]) SCREEN
(const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) 1024
(byte) STAR
(const byte) STAR#0 STAR = (byte/signed byte/word/signed word/dword/signed dword) 81
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte*) main::cursor
(byte*) main::cursor#1 cursor zp ZP_WORD:2 8.25
(byte*) main::cursor#2 cursor zp ZP_WORD:2 11.0
(byte*) main::cursor#3 cursor zp ZP_WORD:2 11.0
(byte*) main::cursor#5 cursor zp ZP_WORD:2 16.5
(byte) main::e
(byte) main::e#1 reg byte x 11.0
(byte) main::e#2 reg byte x 22.0
(byte) main::e#3 reg byte x 5.5
(byte) main::e#5 reg byte x 16.5
(byte) main::x
(byte) main::x#1 x zp ZP_BYTE:4 3.666666666666667
(byte) main::x#2 x zp ZP_BYTE:4 11.0
(byte) main::x0
(byte) main::x1
(const byte) main::x1#0 x1 = (byte/signed byte/word/signed word/dword/signed dword) 39
(byte) main::xd
(const byte) main::xd#0 xd = (const byte) main::x1#0-(byte/signed byte/word/signed word/dword/signed dword) 4
(byte) main::y
(byte) main::y#1 y zp ZP_BYTE:5 7.333333333333333
(byte) main::y#2 y zp ZP_BYTE:5 5.5
(byte) main::y#4 y zp ZP_BYTE:5 16.5
(byte) main::y0
(byte) main::y1
(const byte) main::y1#0 y1 = (byte/signed byte/word/signed word/dword/signed dword) 24
(byte) main::yd
(const byte) main::yd#0 yd = (const byte) main::y1#0-(byte/signed byte/word/signed word/dword/signed dword) 4

zp ZP_WORD:2 [ main::cursor#3 main::cursor#5 main::cursor#1 main::cursor#2 ]
zp ZP_BYTE:4 [ main::x#2 main::x#1 ]
reg byte x [ main::e#3 main::e#5 main::e#1 main::e#2 ]
zp ZP_BYTE:5 [ main::y#2 main::y#4 main::y#1 ]


FINAL ASSEMBLER
Score: 992

//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
  .const STAR = $51
  .label SCREEN = $400
//SEG2 @begin
//SEG3 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG4 @1
//SEG5 [2] call main param-assignment [ ] ( )
//SEG6 [4] phi from @1 to main [phi:@1->main]
  jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
//SEG8 @end
//SEG9 main
main: {
    .const x1 = $27
    .const y1 = $18
    .const xd = x1-4
    .const yd = y1-4
    .label x = 4
    .label cursor = 2
    .label y = 5
  //SEG10 [5] phi from main to main::@1 [phi:main->main::@1]
  //SEG11 [5] phi (byte) main::y#2 = (byte/signed byte/word/signed word/dword/signed dword) 4 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #4
    sta y
  //SEG12 [5] phi (byte) main::e#3 = (const byte) main::yd#0/(byte/signed byte/word/signed word/dword/signed dword) 2 [phi:main->main::@1#1] -- vbuxx=vbuc1 
    ldx #yd/2
  //SEG13 [5] phi (byte) main::x#2 = (byte/signed byte/word/signed word/dword/signed dword) 4 [phi:main->main::@1#2] -- vbuz1=vbuc1 
    sta x
  //SEG14 [5] phi (byte*) main::cursor#3 = (const byte*) SCREEN#0+(byte/signed byte/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) 4 [phi:main->main::@1#3] -- pbuz1=pbuc1 
    lda #<SCREEN+4*$28+4
    sta cursor
    lda #>SCREEN+4*$28+4
    sta cursor+1
  //SEG15 [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  //SEG16 [5] phi (byte) main::y#2 = (byte) main::y#4 [phi:main::@2->main::@1#0] -- register_copy 
  //SEG17 [5] phi (byte) main::e#3 = (byte) main::e#5 [phi:main::@2->main::@1#1] -- register_copy 
  //SEG18 [5] phi (byte) main::x#2 = (byte) main::x#1 [phi:main::@2->main::@1#2] -- register_copy 
  //SEG19 [5] phi (byte*) main::cursor#3 = (byte*) main::cursor#5 [phi:main::@2->main::@1#3] -- register_copy 
  //SEG20 main::@1
  b1:
  //SEG21 [6] *((byte*) main::cursor#3) ← (const byte) STAR#0 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::cursor#3 main::x#2 main::e#3 main::y#2 ] ) -- _deref_pbuz1=vbuc1 
    lda #STAR
    ldy #0
    sta (cursor),y
  //SEG22 [7] (byte) main::x#1 ← (byte) main::x#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::cursor#3 main::e#3 main::y#2 main::x#1 ] ( main:2 [ main::cursor#3 main::e#3 main::y#2 main::x#1 ] ) -- vbuz1=vbuz1_plus_1 
    inc x
  //SEG23 [8] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::e#3 main::y#2 main::x#1 main::cursor#1 ] ( main:2 [ main::e#3 main::y#2 main::x#1 main::cursor#1 ] ) -- pbuz1=pbuz1_plus_1 
    inc cursor
    bne !+
    inc cursor+1
  !:
  //SEG24 [9] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::yd#0 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ] ( main:2 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ] ) -- vbuxx=vbuxx_plus_vbuc1 
    txa
    clc
    adc #yd
    tax
  //SEG25 [10] if((const byte) main::xd#0>(byte) main::e#1) goto main::@2 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ] ( main:2 [ main::y#2 main::x#1 main::cursor#1 main::e#1 ] ) -- vbuc1_gt_vbuxx_then_la1 
    cpx #xd
    bcc b2
  //SEG26 main::@3
  //SEG27 [11] (byte) main::y#1 ← (byte) main::y#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 [ main::x#1 main::cursor#1 main::e#1 main::y#1 ] ( main:2 [ main::x#1 main::cursor#1 main::e#1 main::y#1 ] ) -- vbuz1=vbuz1_plus_1 
    inc y
  //SEG28 [12] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::x#1 main::e#1 main::y#1 main::cursor#2 ] ( main:2 [ main::x#1 main::e#1 main::y#1 main::cursor#2 ] ) -- pbuz1=pbuz1_plus_vbuc1 
    lda cursor
    clc
    adc #$28
    sta cursor
    bcc !+
    inc cursor+1
  !:
  //SEG29 [13] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#0 [ main::x#1 main::y#1 main::cursor#2 main::e#2 ] ( main:2 [ main::x#1 main::y#1 main::cursor#2 main::e#2 ] ) -- vbuxx=vbuxx_minus_vbuc1 
    txa
    sec
    sbc #xd
    tax
  //SEG30 [14] phi from main::@1 main::@3 to main::@2 [phi:main::@1/main::@3->main::@2]
  //SEG31 [14] phi (byte) main::y#4 = (byte) main::y#2 [phi:main::@1/main::@3->main::@2#0] -- register_copy 
  //SEG32 [14] phi (byte) main::e#5 = (byte) main::e#1 [phi:main::@1/main::@3->main::@2#1] -- register_copy 
  //SEG33 [14] phi (byte*) main::cursor#5 = (byte*) main::cursor#1 [phi:main::@1/main::@3->main::@2#2] -- register_copy 
  //SEG34 main::@2
  b2:
  //SEG35 [15] if((byte) main::x#1<(const byte) main::x1#0+(byte/signed byte/word/signed word/dword/signed dword) 1) goto main::@1 [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] ( main:2 [ main::cursor#5 main::x#1 main::e#5 main::y#4 ] ) -- vbuz1_lt_vbuc1_then_la1 
    lda x
    cmp #x1+1
    bcc b1
  //SEG36 main::@return
  //SEG37 [16] return  [ ] ( main:2 [ ] )
    rts
}

