
CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte) STAR#0 ← (byte/signed byte/word/signed word/dword/signed dword) 81
  (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) 25
  (byte[$0]) 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~) main::$0 ← (byte) main::x1#0 - (byte) main::x0#0
  (byte) main::xd#0 ← (byte~) main::$0
  (byte~) main::$1 ← (byte) main::y1#0 - (byte) main::y0#0
  (byte) main::yd#0 ← (byte~) main::$1
  (byte) main::x#0 ← (byte) main::x0#0
  (byte) main::y#0 ← (byte) main::y0#0
  (byte/signed word/word/dword/signed dword~) main::$2 ← (byte) main::yd#0 / (byte/signed byte/word/signed word/dword/signed dword) 2
  (byte) main::e#0 ← (byte/signed word/word/dword/signed dword~) main::$2
  (byte/signed word/word/dword/signed dword~) main::$3 ← (byte) main::y#0 * (byte/signed byte/word/signed word/dword/signed dword) 40
  (byte*~) main::$4 ← (byte[$0]) SCREEN#0 + (byte/signed word/word/dword/signed dword~) 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/signed word/word/dword/signed dword~) main::$6 ← (byte) main::x#2 + (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte) main::x#1 ← (byte/signed word/word/dword/signed dword~) 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~) main::$8 ← (byte) main::e#3 + (byte) main::yd#1
  (byte) main::e#1 ← (byte~) main::$8
  (bool~) main::$9 ← (byte) main::xd#1 <= (byte) main::e#1
  (bool~) main::$10 ← ! (bool~) main::$9
  if((bool~) 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/signed word/word/dword/signed dword~) main::$14 ← (byte) main::x1#1 + (byte/signed byte/word/signed word/dword/signed dword) 1
  (bool~) main::$15 ← (byte) main::x#3 < (byte/signed word/word/dword/signed dword~) main::$14
  if((bool~) 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/signed word/word/dword/signed dword~) main::$11 ← (byte) main::y#2 + (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte) main::y#1 ← (byte/signed word/word/dword/signed dword~) 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~) main::$13 ← (byte) main::e#4 - (byte) main::xd#2
  (byte) main::e#2 ← (byte~) 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 
  to:@2
@2: scope:[]  from @1
  to:@end
@end: scope:[]  from @2

SYMBOL TABLE SSA
(word/signed word/dword/signed dword~) $0
(label) @1
(label) @2
(label) @begin
(label) @end
(byte[$0]) SCREEN
(byte[$0]) 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~) main::$0
(byte~) main::$1
(bool~) main::$10
(byte/signed word/word/dword/signed dword~) main::$11
(byte*~) main::$12
(byte~) main::$13
(byte/signed word/word/dword/signed dword~) main::$14
(bool~) main::$15
(byte/signed word/word/dword/signed dword~) main::$2
(byte/signed word/word/dword/signed dword~) main::$3
(byte*~) main::$4
(byte*~) main::$5
(byte/signed word/word/dword/signed dword~) main::$6
(byte*~) main::$7
(byte~) main::$8
(bool~) 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

Culled Empty Block (label) @2
Successful SSA optimization Pass2CullEmptyBlocks
Inversing boolean not [29] (bool~) main::$10 ← (byte) main::xd#1 > (byte) main::e#1 from [28] (bool~) main::$9 ← (byte) main::xd#1 <= (byte) main::e#1
Successful SSA optimization Pass2UnaryNotSimplification
Alias (byte) main::xd#0 = (byte~) main::$0 
Alias (byte) main::yd#0 = (byte~) 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/signed word/word/dword/signed dword~) main::$2 
Alias (byte*) main::cursor#0 = (byte*~) main::$5 
Alias (byte) main::x#1 = (byte/signed word/word/dword/signed dword~) main::$6 (byte) main::x#4 
Alias (byte*) main::cursor#1 = (byte*~) main::$7 (byte*) main::cursor#4 
Alias (byte) main::e#1 = (byte~) 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/signed word/word/dword/signed dword~) main::$11 
Alias (byte*) main::cursor#2 = (byte*~) main::$12 
Alias (byte) main::e#2 = (byte~) main::$13 
Alias (byte) STAR#0 = (byte) STAR#4 
Successful SSA optimization Pass2AliasElimination
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 
Successful SSA optimization Pass2AliasElimination
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
Successful 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
Successful SSA optimization Pass2RedundantPhiElimination
Simple Condition (bool~) main::$10 [30] if((byte) main::xd#0>(byte) main::e#1) goto main::@2
Simple Condition (bool~) main::$15 [34] if((byte) main::x#1<(byte/signed word/word/dword/signed dword~) main::$14) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) STAR#0 = 81
Constant (const word/signed word/dword/signed dword) $0 = 40*25
Constant (const byte[$0]) 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
Successful 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/signed word/word/dword/signed dword) main::$3 = main::y#0*40
Constant (const byte/signed word/word/dword/signed dword) main::$14 = main::x1#0+1
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte) main::e#0 = main::yd#0/2
Constant (const byte*) main::$4 = SCREEN#0+main::$3
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte*) main::cursor#0 = main::$4+main::x#0
Successful SSA optimization Pass2ConstantIdentification
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::e#0
Inlining constant with var siblings (const byte*) main::cursor#0
Constant inlined main::cursor#0 = (const byte[40*25]) 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[40*25]) 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 $0 = (byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 25
Constant inlined main::e#0 = (const byte) main::yd#0/(byte/signed byte/word/signed word/dword/signed dword) 2
Successful SSA optimization Pass2ConstantInlining
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)
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 

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
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

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi()
  to:@1
@1: scope:[]  from @begin
  [1] phi()
  [2] call main 
  to:@end
@end: scope:[]  from @1
  [3] phi()
main: scope:[main]  from @1
  [4] phi()
  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 )
  [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 )
  [5] (byte) main::x#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 4 main::@2/(byte) main::x#1 )
  [5] (byte*) main::cursor#3 ← phi( main/(const byte[40*25]) 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 )
  [6] *((byte*) main::cursor#3) ← (const byte) STAR#0
  [7] (byte) main::x#1 ← (byte) main::x#2 + (byte/signed byte/word/signed word/dword/signed dword) 1
  [8] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte/signed byte/word/signed word/dword/signed dword) 1
  [9] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::yd#0
  [10] if((const byte) main::xd#0>(byte) main::e#1) goto main::@2
  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
  [12] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte/signed byte/word/signed word/dword/signed dword) 40
  [13] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#0
  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 )
  [14] (byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 )
  [14] (byte*) main::cursor#5 ← phi( main::@1/(byte*) main::cursor#1 main::@3/(byte*) main::cursor#2 )
  [15] if((byte) main::x#1<(const byte) main::x1#0+(byte/signed byte/word/signed word/dword/signed dword) 1) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@2
  [16] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte[40*25]) 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 File Comments
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .const STAR = $51
  .label SCREEN = $400
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
//SEG5 @1
b1:
//SEG6 [2] call main 
//SEG7 [4] phi from @1 to main [phi:@1->main]
main_from_b1:
  jsr main
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
//SEG9 @end
bend:
//SEG10 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
  //SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
  //SEG12 [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
  //SEG13 [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
  //SEG14 [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
  //SEG15 [5] phi (byte*) main::cursor#3 = (const byte[40*25]) 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
  //SEG16 [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  b1_from_b2:
  //SEG17 [5] phi (byte) main::y#2 = (byte) main::y#4 [phi:main::@2->main::@1#0] -- register_copy 
  //SEG18 [5] phi (byte) main::e#3 = (byte) main::e#5 [phi:main::@2->main::@1#1] -- register_copy 
  //SEG19 [5] phi (byte) main::x#2 = (byte) main::x#1 [phi:main::@2->main::@1#2] -- register_copy 
  //SEG20 [5] phi (byte*) main::cursor#3 = (byte*) main::cursor#5 [phi:main::@2->main::@1#3] -- register_copy 
    jmp b1
  //SEG21 main::@1
  b1:
  //SEG22 [6] *((byte*) main::cursor#3) ← (const byte) STAR#0 -- _deref_pbuz1=vbuc1 
    lda #STAR
    ldy #0
    sta (cursor),y
  //SEG23 [7] (byte) main::x#1 ← (byte) main::x#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 -- vbuz1=vbuz1_plus_1 
    inc x
  //SEG24 [8] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte/signed byte/word/signed word/dword/signed dword) 1 -- pbuz1=pbuz1_plus_1 
    inc cursor
    bne !+
    inc cursor+1
  !:
  //SEG25 [9] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::yd#0 -- vbuz1=vbuz1_plus_vbuc1 
    lda #yd
    clc
    adc e
    sta e
  //SEG26 [10] if((const byte) main::xd#0>(byte) main::e#1) goto main::@2 -- vbuc1_gt_vbuz1_then_la1 
    lda e
    cmp #xd
    bcc b2_from_b1
    jmp b3
  //SEG27 main::@3
  b3:
  //SEG28 [11] (byte) main::y#1 ← (byte) main::y#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 -- vbuz1=vbuz1_plus_1 
    inc y
  //SEG29 [12] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte/signed byte/word/signed word/dword/signed dword) 40 -- pbuz1=pbuz1_plus_vbuc1 
    lda cursor
    clc
    adc #$28
    sta cursor
    bcc !+
    inc cursor+1
  !:
  //SEG30 [13] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#0 -- vbuz1=vbuz1_minus_vbuc1 
    lda e
    sec
    sbc #xd
    sta e
  //SEG31 [14] phi from main::@1 main::@3 to main::@2 [phi:main::@1/main::@3->main::@2]
  b2_from_b1:
  b2_from_b3:
  //SEG32 [14] phi (byte) main::y#4 = (byte) main::y#2 [phi:main::@1/main::@3->main::@2#0] -- register_copy 
  //SEG33 [14] phi (byte) main::e#5 = (byte) main::e#1 [phi:main::@1/main::@3->main::@2#1] -- register_copy 
  //SEG34 [14] phi (byte*) main::cursor#5 = (byte*) main::cursor#1 [phi:main::@1/main::@3->main::@2#2] -- register_copy 
    jmp b2
  //SEG35 main::@2
  b2:
  //SEG36 [15] if((byte) main::x#1<(const byte) main::x1#0+(byte/signed byte/word/signed word/dword/signed dword) 1) goto main::@1 -- vbuz1_lt_vbuc1_then_la1 
    lda x
    cmp #x1+1
    bcc b1_from_b2
    jmp breturn
  //SEG37 main::@return
  breturn:
  //SEG38 [16] return 
    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 File Comments
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .const STAR = $51
  .label SCREEN = $400
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
//SEG5 @1
b1:
//SEG6 [2] call main 
//SEG7 [4] phi from @1 to main [phi:@1->main]
main_from_b1:
  jsr main
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
//SEG9 @end
bend:
//SEG10 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
  //SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
  //SEG12 [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
  //SEG13 [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
  //SEG14 [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
  //SEG15 [5] phi (byte*) main::cursor#3 = (const byte[40*25]) 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
  //SEG16 [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  b1_from_b2:
  //SEG17 [5] phi (byte) main::y#2 = (byte) main::y#4 [phi:main::@2->main::@1#0] -- register_copy 
  //SEG18 [5] phi (byte) main::e#3 = (byte) main::e#5 [phi:main::@2->main::@1#1] -- register_copy 
  //SEG19 [5] phi (byte) main::x#2 = (byte) main::x#1 [phi:main::@2->main::@1#2] -- register_copy 
  //SEG20 [5] phi (byte*) main::cursor#3 = (byte*) main::cursor#5 [phi:main::@2->main::@1#3] -- register_copy 
    jmp b1
  //SEG21 main::@1
  b1:
  //SEG22 [6] *((byte*) main::cursor#3) ← (const byte) STAR#0 -- _deref_pbuz1=vbuc1 
    lda #STAR
    ldy #0
    sta (cursor),y
  //SEG23 [7] (byte) main::x#1 ← (byte) main::x#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 -- vbuz1=vbuz1_plus_1 
    inc x
  //SEG24 [8] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte/signed byte/word/signed word/dword/signed dword) 1 -- pbuz1=pbuz1_plus_1 
    inc cursor
    bne !+
    inc cursor+1
  !:
  //SEG25 [9] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::yd#0 -- vbuxx=vbuxx_plus_vbuc1 
    txa
    clc
    adc #yd
    tax
  //SEG26 [10] if((const byte) main::xd#0>(byte) main::e#1) goto main::@2 -- vbuc1_gt_vbuxx_then_la1 
    cpx #xd
    bcc b2_from_b1
    jmp b3
  //SEG27 main::@3
  b3:
  //SEG28 [11] (byte) main::y#1 ← (byte) main::y#2 + (byte/signed byte/word/signed word/dword/signed dword) 1 -- vbuz1=vbuz1_plus_1 
    inc y
  //SEG29 [12] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte/signed byte/word/signed word/dword/signed dword) 40 -- pbuz1=pbuz1_plus_vbuc1 
    lda cursor
    clc
    adc #$28
    sta cursor
    bcc !+
    inc cursor+1
  !:
  //SEG30 [13] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#0 -- vbuxx=vbuxx_minus_vbuc1 
    txa
    sec
    sbc #xd
    tax
  //SEG31 [14] phi from main::@1 main::@3 to main::@2 [phi:main::@1/main::@3->main::@2]
  b2_from_b1:
  b2_from_b3:
  //SEG32 [14] phi (byte) main::y#4 = (byte) main::y#2 [phi:main::@1/main::@3->main::@2#0] -- register_copy 
  //SEG33 [14] phi (byte) main::e#5 = (byte) main::e#1 [phi:main::@1/main::@3->main::@2#1] -- register_copy 
  //SEG34 [14] phi (byte*) main::cursor#5 = (byte*) main::cursor#1 [phi:main::@1/main::@3->main::@2#2] -- register_copy 
    jmp b2
  //SEG35 main::@2
  b2:
  //SEG36 [15] if((byte) main::x#1<(const byte) main::x1#0+(byte/signed byte/word/signed word/dword/signed dword) 1) goto main::@1 -- vbuz1_lt_vbuc1_then_la1 
    lda x
    cmp #x1+1
    bcc b1_from_b2
    jmp breturn
  //SEG37 main::@return
  breturn:
  //SEG38 [16] return 
    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 b1_from_bbegin:
Removing instruction b1:
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 bend:
Removing instruction b1_from_main:
Removing instruction b3:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction jmp b1
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte[40*25]) SCREEN
(const byte[40*25]) 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: 986

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

