Identified constant variable (byte) STAR
Identified constant variable (byte) main::x0
Identified constant variable (byte) main::y0
Identified constant variable (byte) main::x1
Identified constant variable (byte) main::y1
Culled Empty Block (label) main::@4

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte) STAR#0 ← (number) $51
  (byte[$28*$19]) SCREEN#0 ← ((byte[$28*$19])) (number) $400
  to:@1
main: scope:[main]  from @1
  (byte) main::x0#0 ← (number) 4
  (byte) main::y0#0 ← (number) 4
  (byte) main::x1#0 ← (number) $27
  (byte) main::y1#0 ← (number) $18
  (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
  (number~) main::$2 ← (byte) main::yd#0 / (number) 2
  (byte) main::e#0 ← (number~) main::$2
  (number~) main::$3 ← (byte) main::y#0 * (number) $28
  (byte*~) main::$4 ← (byte[$28*$19]) SCREEN#0 + (number~) 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::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*) main::cursor#3) ← (byte) STAR#0
  (number~) main::$6 ← (byte) main::x#2 + (number) 1
  (byte) main::x#1 ← (number~) main::$6
  (byte*~) main::$7 ← (byte*) main::cursor#3 + (number) 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) main::x#3 ← phi( main::@1/(byte) main::x#1 main::@3/(byte) main::x#4 )
  (number~) main::$14 ← (byte) main::x1#0 + (number) 1
  (bool~) main::$15 ← (byte) main::x#3 < (number~) 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) main::x#4 ← phi( main::@1/(byte) main::x#1 )
  (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 )
  (number~) main::$11 ← (byte) main::y#2 + (number) 1
  (byte) main::y#1 ← (number~) main::$11
  (byte*~) main::$12 ← (byte*) main::cursor#4 + (number) $28
  (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
  call main 
  to:@2
@2: scope:[]  from @1
  to:@end
@end: scope:[]  from @2

SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(byte[$28*$19]) SCREEN
(byte[$28*$19]) SCREEN#0
(byte) STAR
(byte) STAR#0
(void()) main()
(byte~) main::$0
(byte~) main::$1
(bool~) main::$10
(number~) main::$11
(byte*~) main::$12
(byte~) main::$13
(number~) main::$14
(bool~) main::$15
(number~) main::$2
(number~) main::$3
(byte*~) main::$4
(byte*~) main::$5
(number~) 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::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

Adding number conversion cast (unumber) $51 in (byte) STAR#0 ← (number) $51
Adding number conversion cast (unumber) 4 in (byte) main::x0#0 ← (number) 4
Adding number conversion cast (unumber) 4 in (byte) main::y0#0 ← (number) 4
Adding number conversion cast (unumber) $27 in (byte) main::x1#0 ← (number) $27
Adding number conversion cast (unumber) $18 in (byte) main::y1#0 ← (number) $18
Adding number conversion cast (unumber) 2 in (number~) main::$2 ← (byte) main::yd#0 / (number) 2
Adding number conversion cast (unumber) main::$2 in (number~) main::$2 ← (byte) main::yd#0 / (unumber)(number) 2
Adding number conversion cast (unumber) $28 in (number~) main::$3 ← (byte) main::y#0 * (number) $28
Adding number conversion cast (unumber) main::$3 in (number~) main::$3 ← (byte) main::y#0 * (unumber)(number) $28
Adding number conversion cast (unumber) 1 in (number~) main::$6 ← (byte) main::x#2 + (number) 1
Adding number conversion cast (unumber) main::$6 in (number~) main::$6 ← (byte) main::x#2 + (unumber)(number) 1
Adding number conversion cast (unumber) 1 in (byte*~) main::$7 ← (byte*) main::cursor#3 + (number) 1
Adding number conversion cast (unumber) 1 in (number~) main::$14 ← (byte) main::x1#0 + (number) 1
Adding number conversion cast (unumber) main::$14 in (number~) main::$14 ← (byte) main::x1#0 + (unumber)(number) 1
Adding number conversion cast (unumber) 1 in (number~) main::$11 ← (byte) main::y#2 + (number) 1
Adding number conversion cast (unumber) main::$11 in (number~) main::$11 ← (byte) main::y#2 + (unumber)(number) 1
Adding number conversion cast (unumber) $28 in (byte*~) main::$12 ← (byte*) main::cursor#4 + (number) $28
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte) STAR#0 ← (unumber)(number) $51
Inlining cast (byte[$28*$19]) SCREEN#0 ← (byte[$28*$19])(number) $400
Inlining cast (byte) main::x0#0 ← (unumber)(number) 4
Inlining cast (byte) main::y0#0 ← (unumber)(number) 4
Inlining cast (byte) main::x1#0 ← (unumber)(number) $27
Inlining cast (byte) main::y1#0 ← (unumber)(number) $18
Successful SSA optimization Pass2InlineCast
Simplifying constant integer cast $51
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 4
Simplifying constant integer cast 4
Simplifying constant integer cast $27
Simplifying constant integer cast $18
Simplifying constant integer cast 2
Simplifying constant integer cast $28
Simplifying constant integer cast 1
Simplifying constant integer cast 1
Simplifying constant integer cast 1
Simplifying constant integer cast 1
Simplifying constant integer cast $28
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $51
Finalized unsigned number type (byte) 4
Finalized unsigned number type (byte) 4
Finalized unsigned number type (byte) $27
Finalized unsigned number type (byte) $18
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) $28
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) $28
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) main::$2 ← (byte) main::yd#0 / (byte) 2
Inferred type updated to byte in (unumber~) main::$3 ← (byte) main::y#0 * (byte) $28
Inferred type updated to byte in (unumber~) main::$6 ← (byte) main::x#2 + (byte) 1
Inferred type updated to byte in (unumber~) main::$14 ← (byte) main::x1#0 + (byte) 1
Inferred type updated to byte in (unumber~) main::$11 ← (byte) main::y#2 + (byte) 1
Inversing boolean not [27] (bool~) main::$10 ← (byte) main::xd#1 > (byte) main::e#1 from [26] (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::x0#0 = (byte) main::x#0 
Alias (byte) main::y0#0 = (byte) main::y#0 
Alias (byte) main::e#0 = (byte~) main::$2 
Alias (byte*) main::cursor#0 = (byte*~) main::$5 
Alias (byte) main::x#1 = (byte~) 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::yd#1 = (byte) main::yd#3 
Alias (byte) main::y#1 = (byte~) main::$11 
Alias (byte*) main::cursor#2 = (byte*~) main::$12 
Alias (byte) main::e#2 = (byte~) main::$13 
Successful SSA optimization Pass2AliasElimination
Alias (byte) main::x#1 = (byte) main::x#3 
Alias (byte) main::yd#1 = (byte) main::yd#2 
Alias (byte) main::xd#1 = (byte) main::xd#3 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) main::yd#1 (byte) main::yd#0
Identical Phi Values (byte) main::xd#1 (byte) main::xd#0
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$10 [28] if((byte) main::xd#0>(byte) main::e#1) goto main::@2
Simple Condition (bool~) main::$15 [32] if((byte) main::x#1<(byte~) main::$14) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) STAR#0 = $51
Constant (const byte[$28*$19]) SCREEN#0 = (byte*) 1024
Constant (const byte) main::x0#0 = 4
Constant (const byte) main::y0#0 = 4
Constant (const byte) main::x1#0 = $27
Constant (const byte) main::y1#0 = $18
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [0] (byte) main::xd#0 ← (const byte) main::x1#0 - (const byte) main::x0#0
Constant right-side identified [1] (byte) main::yd#0 ← (const byte) main::y1#0 - (const byte) main::y0#0
Constant right-side identified [3] (byte~) main::$3 ← (const byte) main::y0#0 * (byte) $28
Constant right-side identified [13] (byte~) main::$14 ← (const byte) main::x1#0 + (byte) 1
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::xd#0 = main::x1#0-main::x0#0
Constant (const byte) main::yd#0 = main::y1#0-main::y0#0
Constant (const byte) main::$3 = main::y0#0*$28
Constant (const byte) main::$14 = main::x1#0+1
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [0] (byte) main::e#0 ← (const byte) main::yd#0 / (byte) 2
Constant right-side identified [1] (byte*~) main::$4 ← (const byte[$28*$19]) SCREEN#0 + (const byte) main::$3
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::e#0 = main::yd#0/2
Constant (const byte*) main::$4 = SCREEN#0+main::$3
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [0] (byte*) main::cursor#0 ← (const byte*) main::$4 + (const byte) main::x0#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) main::cursor#0 = main::$4+main::x0#0
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with var siblings (const byte) main::e#0
Inlining constant with var siblings (const byte*) main::cursor#0
Constant inlined main::$3 = (const byte) main::y0#0*(byte) $28
Constant inlined main::$14 = (const byte) main::x1#0+(byte) 1
Constant inlined main::$4 = (const byte[$28*$19]) SCREEN#0+(const byte) main::y0#0*(byte) $28
Constant inlined main::e#0 = (const byte) main::yd#0/(byte) 2
Constant inlined main::cursor#0 = (const byte[$28*$19]) SCREEN#0+(const byte) main::y0#0*(byte) $28+(const byte) main::x0#0
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 @2
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 [15] main::cursor#8 ← main::cursor#2
Coalesced [16] main::e#8 ← main::e#2
Coalesced [17] main::y#7 ← main::y#1
Coalesced [21] main::cursor#6 ← main::cursor#5
Coalesced [22] main::x#5 ← main::x#1
Coalesced [23] main::e#6 ← main::e#5
Coalesced [24] main::y#5 ← main::y#4
Coalesced [25] main::cursor#7 ← main::cursor#1
Coalesced [26] main::e#7 ← main::e#1
Coalesced (already) [27] main::y#6 ← main::y#2
Coalesced down to 4 phi equivalence classes
Culled Empty Block (label) @2
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/(const byte) main::y0#0 main::@2/(byte) main::y#4 )
  [5] (byte) main::e#3 ← phi( main/(const byte) main::yd#0/(byte) 2 main::@2/(byte) main::e#5 )
  [5] (byte) main::x#2 ← phi( main/(const byte) main::x0#0 main::@2/(byte) main::x#1 )
  [5] (byte*) main::cursor#3 ← phi( main/(const byte[$28*$19]) SCREEN#0+(const byte) main::y0#0*(byte) $28+(const byte) main::x0#0 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) 1
  [8] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 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) 1
  [12] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) $28
  [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) 1) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@2
  [16] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte[$28*$19]) 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
Target platform is c64basic
  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .const STAR = $51
  .label SCREEN = $400
  // @begin
bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
  // @1
b1:
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
main_from_b1:
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
main: {
    .const x0 = 4
    .const y0 = 4
    .const x1 = $27
    .const y1 = $18
    .const xd = x1-x0
    .const yd = y1-y0
    .label x = 4
    .label cursor = 2
    .label e = 5
    .label y = 6
    // [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [5] phi (byte) main::y#2 = (const byte) main::y0#0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #y0
    sta.z y
    // [5] phi (byte) main::e#3 = (const byte) main::yd#0/(byte) 2 [phi:main->main::@1#1] -- vbuz1=vbuc1 
    lda #yd/2
    sta.z e
    // [5] phi (byte) main::x#2 = (const byte) main::x0#0 [phi:main->main::@1#2] -- vbuz1=vbuc1 
    lda #x0
    sta.z x
    // [5] phi (byte*) main::cursor#3 = (const byte[$28*$19]) SCREEN#0+(const byte) main::y0#0*(byte) $28+(const byte) main::x0#0 [phi:main->main::@1#3] -- pbuz1=pbuc1 
    lda #<SCREEN+y0*$28+x0
    sta.z cursor
    lda #>SCREEN+y0*$28+x0
    sta.z cursor+1
    jmp b1
    // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  b1_from_b2:
    // [5] phi (byte) main::y#2 = (byte) main::y#4 [phi:main::@2->main::@1#0] -- register_copy 
    // [5] phi (byte) main::e#3 = (byte) main::e#5 [phi:main::@2->main::@1#1] -- register_copy 
    // [5] phi (byte) main::x#2 = (byte) main::x#1 [phi:main::@2->main::@1#2] -- register_copy 
    // [5] phi (byte*) main::cursor#3 = (byte*) main::cursor#5 [phi:main::@2->main::@1#3] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] *((byte*) main::cursor#3) ← (const byte) STAR#0 -- _deref_pbuz1=vbuc1 
    lda #STAR
    ldy #0
    sta (cursor),y
    // [7] (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 -- vbuz1=vbuz1_plus_1 
    inc.z x
    // [8] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 -- pbuz1=pbuz1_plus_1 
    inc.z cursor
    bne !+
    inc.z cursor+1
  !:
    // [9] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::yd#0 -- vbuz1=vbuz1_plus_vbuc1 
    lax.z e
    axs #-[yd]
    stx.z e
    // [10] if((const byte) main::xd#0>(byte) main::e#1) goto main::@2 -- vbuc1_gt_vbuz1_then_la1 
    lda.z e
    cmp #xd
    bcc b2_from_b1
    jmp b3
    // main::@3
  b3:
    // [11] (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 -- vbuz1=vbuz1_plus_1 
    inc.z y
    // [12] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 
    lda #$28
    clc
    adc.z cursor
    sta.z cursor
    bcc !+
    inc.z cursor+1
  !:
    // [13] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#0 -- vbuz1=vbuz1_minus_vbuc1 
    lax.z e
    axs #xd
    stx.z e
    // [14] phi from main::@1 main::@3 to main::@2 [phi:main::@1/main::@3->main::@2]
  b2_from_b1:
  b2_from_b3:
    // [14] phi (byte) main::y#4 = (byte) main::y#2 [phi:main::@1/main::@3->main::@2#0] -- register_copy 
    // [14] phi (byte) main::e#5 = (byte) main::e#1 [phi:main::@1/main::@3->main::@2#1] -- register_copy 
    // [14] phi (byte*) main::cursor#5 = (byte*) main::cursor#1 [phi:main::@1/main::@3->main::@2#2] -- register_copy 
    jmp b2
    // main::@2
  b2:
    // [15] if((byte) main::x#1<(const byte) main::x1#0+(byte) 1) goto main::@1 -- vbuz1_lt_vbuc1_then_la1 
    lda.z x
    cmp #x1+1
    bcc b1_from_b2
    jmp breturn
    // main::@return
  breturn:
    // [16] return 
    rts
}
  // File Data

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 reg byte x 
Removing always clobbered register reg byte x as potential for zp ZP_BYTE:6 [ main::y#2 main::y#4 main::y#1 ]
Removing always clobbered register reg byte x as potential for zp ZP_BYTE:4 [ main::x#2 main::x#1 ]
Statement [12] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) $28 [ 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 reg byte x 
Statement [15] if((byte) main::x#1<(const byte) main::x1#0+(byte) 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 ] ) 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 reg byte x 
Statement [12] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) $28 [ 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 reg byte x 
Statement [15] if((byte) main::x#1<(const byte) main::x1#0+(byte) 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 ] ) 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 , 
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 , 

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 1088 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 1088 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:6 [ main::y#2 main::y#4 main::y#1 ]
Uplifting [main] best 1088 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 1088 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
  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .const STAR = $51
  .label SCREEN = $400
  // @begin
bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
  // @1
b1:
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
main_from_b1:
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
main: {
    .const x0 = 4
    .const y0 = 4
    .const x1 = $27
    .const y1 = $18
    .const xd = x1-x0
    .const yd = y1-y0
    .label x = 4
    .label cursor = 2
    .label y = 5
    // [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [5] phi (byte) main::y#2 = (const byte) main::y0#0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #y0
    sta.z y
    // [5] phi (byte) main::e#3 = (const byte) main::yd#0/(byte) 2 [phi:main->main::@1#1] -- vbuxx=vbuc1 
    ldx #yd/2
    // [5] phi (byte) main::x#2 = (const byte) main::x0#0 [phi:main->main::@1#2] -- vbuz1=vbuc1 
    lda #x0
    sta.z x
    // [5] phi (byte*) main::cursor#3 = (const byte[$28*$19]) SCREEN#0+(const byte) main::y0#0*(byte) $28+(const byte) main::x0#0 [phi:main->main::@1#3] -- pbuz1=pbuc1 
    lda #<SCREEN+y0*$28+x0
    sta.z cursor
    lda #>SCREEN+y0*$28+x0
    sta.z cursor+1
    jmp b1
    // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  b1_from_b2:
    // [5] phi (byte) main::y#2 = (byte) main::y#4 [phi:main::@2->main::@1#0] -- register_copy 
    // [5] phi (byte) main::e#3 = (byte) main::e#5 [phi:main::@2->main::@1#1] -- register_copy 
    // [5] phi (byte) main::x#2 = (byte) main::x#1 [phi:main::@2->main::@1#2] -- register_copy 
    // [5] phi (byte*) main::cursor#3 = (byte*) main::cursor#5 [phi:main::@2->main::@1#3] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] *((byte*) main::cursor#3) ← (const byte) STAR#0 -- _deref_pbuz1=vbuc1 
    lda #STAR
    ldy #0
    sta (cursor),y
    // [7] (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 -- vbuz1=vbuz1_plus_1 
    inc.z x
    // [8] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 -- pbuz1=pbuz1_plus_1 
    inc.z cursor
    bne !+
    inc.z cursor+1
  !:
    // [9] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::yd#0 -- vbuxx=vbuxx_plus_vbuc1 
    txa
    axs #-[yd]
    // [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
    // main::@3
  b3:
    // [11] (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 -- vbuz1=vbuz1_plus_1 
    inc.z y
    // [12] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 
    lda #$28
    clc
    adc.z cursor
    sta.z cursor
    bcc !+
    inc.z cursor+1
  !:
    // [13] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#0 -- vbuxx=vbuxx_minus_vbuc1 
    txa
    axs #xd
    // [14] phi from main::@1 main::@3 to main::@2 [phi:main::@1/main::@3->main::@2]
  b2_from_b1:
  b2_from_b3:
    // [14] phi (byte) main::y#4 = (byte) main::y#2 [phi:main::@1/main::@3->main::@2#0] -- register_copy 
    // [14] phi (byte) main::e#5 = (byte) main::e#1 [phi:main::@1/main::@3->main::@2#1] -- register_copy 
    // [14] phi (byte*) main::cursor#5 = (byte*) main::cursor#1 [phi:main::@1/main::@3->main::@2#2] -- register_copy 
    jmp b2
    // main::@2
  b2:
    // [15] if((byte) main::x#1<(const byte) main::x1#0+(byte) 1) goto main::@1 -- vbuz1_lt_vbuc1_then_la1 
    lda.z x
    cmp #x1+1
    bcc b1_from_b2
    jmp breturn
    // main::@return
  breturn:
    // [16] return 
    rts
}
  // File Data

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
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[$28*$19]) SCREEN
(const byte[$28*$19]) SCREEN#0 SCREEN = (byte*) 1024
(byte) STAR
(const byte) STAR#0 STAR = (byte) $51
(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
(const byte) main::x0#0 x0 = (byte) 4
(byte) main::x1
(const byte) main::x1#0 x1 = (byte) $27
(byte) main::xd
(const byte) main::xd#0 xd = (const byte) main::x1#0-(const byte) main::x0#0
(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
(const byte) main::y0#0 y0 = (byte) 4
(byte) main::y1
(const byte) main::y1#0 y1 = (byte) $18
(byte) main::yd
(const byte) main::yd#0 yd = (const byte) main::y1#0-(const byte) main::y0#0

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

  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .const STAR = $51
  .label SCREEN = $400
  // @begin
  // [1] phi from @begin to @1 [phi:@begin->@1]
  // @1
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    .const x0 = 4
    .const y0 = 4
    .const x1 = $27
    .const y1 = $18
    .const xd = x1-x0
    .const yd = y1-y0
    .label x = 4
    .label cursor = 2
    .label y = 5
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // [5] phi (byte) main::y#2 = (const byte) main::y0#0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #y0
    sta.z y
    // [5] phi (byte) main::e#3 = (const byte) main::yd#0/(byte) 2 [phi:main->main::@1#1] -- vbuxx=vbuc1 
    ldx #yd/2
    // [5] phi (byte) main::x#2 = (const byte) main::x0#0 [phi:main->main::@1#2] -- vbuz1=vbuc1 
    lda #x0
    sta.z x
    // [5] phi (byte*) main::cursor#3 = (const byte[$28*$19]) SCREEN#0+(const byte) main::y0#0*(byte) $28+(const byte) main::x0#0 [phi:main->main::@1#3] -- pbuz1=pbuc1 
    lda #<SCREEN+y0*$28+x0
    sta.z cursor
    lda #>SCREEN+y0*$28+x0
    sta.z cursor+1
    // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
    // [5] phi (byte) main::y#2 = (byte) main::y#4 [phi:main::@2->main::@1#0] -- register_copy 
    // [5] phi (byte) main::e#3 = (byte) main::e#5 [phi:main::@2->main::@1#1] -- register_copy 
    // [5] phi (byte) main::x#2 = (byte) main::x#1 [phi:main::@2->main::@1#2] -- register_copy 
    // [5] phi (byte*) main::cursor#3 = (byte*) main::cursor#5 [phi:main::@2->main::@1#3] -- register_copy 
    // main::@1
  b1:
    // *cursor = STAR
    // [6] *((byte*) main::cursor#3) ← (const byte) STAR#0 -- _deref_pbuz1=vbuc1 
    lda #STAR
    ldy #0
    sta (cursor),y
    // x = x + 1
    // [7] (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 -- vbuz1=vbuz1_plus_1 
    inc.z x
    // cursor = cursor + 1
    // [8] (byte*) main::cursor#1 ← (byte*) main::cursor#3 + (byte) 1 -- pbuz1=pbuz1_plus_1 
    inc.z cursor
    bne !+
    inc.z cursor+1
  !:
    // e = e+yd
    // [9] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::yd#0 -- vbuxx=vbuxx_plus_vbuc1 
    txa
    axs #-[yd]
    // if(xd<=e)
    // [10] if((const byte) main::xd#0>(byte) main::e#1) goto main::@2 -- vbuc1_gt_vbuxx_then_la1 
    cpx #xd
    bcc b2
    // main::@3
    // y = y+1
    // [11] (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 -- vbuz1=vbuz1_plus_1 
    inc.z y
    // cursor = cursor + 40
    // [12] (byte*) main::cursor#2 ← (byte*) main::cursor#1 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 
    lda #$28
    clc
    adc.z cursor
    sta.z cursor
    bcc !+
    inc.z cursor+1
  !:
    // e = e - xd
    // [13] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::xd#0 -- vbuxx=vbuxx_minus_vbuc1 
    txa
    axs #xd
    // [14] phi from main::@1 main::@3 to main::@2 [phi:main::@1/main::@3->main::@2]
    // [14] phi (byte) main::y#4 = (byte) main::y#2 [phi:main::@1/main::@3->main::@2#0] -- register_copy 
    // [14] phi (byte) main::e#5 = (byte) main::e#1 [phi:main::@1/main::@3->main::@2#1] -- register_copy 
    // [14] phi (byte*) main::cursor#5 = (byte*) main::cursor#1 [phi:main::@1/main::@3->main::@2#2] -- register_copy 
    // main::@2
  b2:
    // while (x<(x1+1))
    // [15] if((byte) main::x#1<(const byte) main::x1#0+(byte) 1) goto main::@1 -- vbuz1_lt_vbuc1_then_la1 
    lda.z x
    cmp #x1+1
    bcc b1
    // main::@return
    // }
    // [16] return 
    rts
}
  // File Data

