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
  to:@1

(void()) main()
main: scope:[main]  from @1
  (byte~) main::$0 ← (const byte) main::x1 - (const byte) main::x0
  (byte) main::xd#0 ← (byte~) main::$0
  (byte~) main::$1 ← (const byte) main::y1 - (const byte) main::y0
  (byte) main::yd#0 ← (byte~) main::$1
  (byte) main::x#0 ← (const byte) main::x0
  (byte) main::y#0 ← (const byte) main::y0
  (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 ← (const byte*) SCREEN + (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) ← (const byte) STAR
  (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 ← (const byte) main::x1 + (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
(const byte*) SCREEN[(number) $28*(number) $19]  = (byte*)(number) $400
(const byte) STAR = (byte) $51
(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
(const byte) main::x0 = (byte) 4
(const byte) main::x1 = (byte) $27
(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
(const byte) main::y0 = (byte) 4
(const byte) main::y1 = (byte) $18
(byte) main::yd
(byte) main::yd#0
(byte) main::yd#1
(byte) main::yd#2
(byte) main::yd#3

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 ← (const byte) main::x1 + (number) 1
Adding number conversion cast (unumber) main::$14 in (number~) main::$14 ← (const byte) main::x1 + (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
Simplifying constant pointer cast (byte*) 1024
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) 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 ← (const byte) main::x1 + (byte) 1
Inferred type updated to byte in (unumber~) main::$11 ← (byte) main::y#2 + (byte) 1
Inversing boolean not [21] (bool~) main::$10 ← (byte) main::xd#1 > (byte) main::e#1 from [20] (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::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 [14] if((byte) main::xd#0>(byte) main::e#1) goto main::@2
Simple Condition (bool~) main::$15 [18] if((byte) main::x#1<(byte~) main::$14) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant right-side identified [0] (byte) main::xd#0 ← (const byte) main::x1 - (const byte) main::x0
Constant right-side identified [1] (byte) main::yd#0 ← (const byte) main::y1 - (const byte) main::y0
Constant right-side identified [16] (byte~) main::$14 ← (const byte) main::x1 + (byte) 1
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::xd#0 = main::x1-main::x0
Constant (const byte) main::yd#0 = main::y1-main::y0
Constant (const byte) main::x#0 = main::x0
Constant (const byte) main::y#0 = main::y0
Constant (const byte) main::$14 = main::x1+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::$3 ← (const byte) main::y#0 * (byte) $28
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::e#0 = main::yd#0/2
Constant (const byte) main::$3 = main::y#0*$28
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [0] (byte*~) main::$4 ← (const byte*) SCREEN + (const byte) main::$3
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) main::$4 = SCREEN+main::$3
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [0] (byte*) main::cursor#0 ← (const byte*) main::$4 + (const byte) main::x#0
Successful SSA optimization Pass2ConstantRValueConsolidation
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*) SCREEN+(const byte) main::y0*(byte) $28+(const byte) main::x0
Constant inlined main::x#0 = (const byte) main::x0
Constant inlined main::$14 = (const byte) main::x1+(byte) 1
Constant inlined main::$3 = (const byte) main::y0*(byte) $28
Constant inlined main::y#0 = (const byte) main::y0
Constant inlined main::$4 = (const byte*) SCREEN+(const byte) main::y0*(byte) $28
Constant inlined main::e#0 = (const byte) main::yd#0/(byte) 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 @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()

(void()) main()
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 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 main::@2/(byte) main::x#1 )
  [5] (byte*) main::cursor#3 ← phi( main/(const byte*) SCREEN+(const byte) main::y0*(byte) $28+(const byte) main::x0 main::@2/(byte*) main::cursor#5 )
  [6] *((byte*) main::cursor#3) ← (const byte) STAR
  [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+(byte) 1) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@2
  [16] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(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::xd
(byte) main::y
(byte) main::y#1 7.333333333333333
(byte) main::y#2 5.5
(byte) main::y#4 16.5
(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[2]:2 [ main::cursor#3 main::cursor#5 main::cursor#1 main::cursor#2 ]
Allocated zp[1]:4 [ main::x#2 main::x#1 ]
Allocated zp[1]:5 [ main::e#3 main::e#5 main::e#1 main::e#2 ]
Allocated zp[1]:6 [ main::y#2 main::y#4 main::y#1 ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  .const STAR = $51
  // @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 [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 [phi:main->main::@1#2] -- vbuz1=vbuc1 
    lda #x0
    sta.z x
    // [5] phi (byte*) main::cursor#3 = (const byte*) SCREEN+(const byte) main::y0*(byte) $28+(const byte) main::x0 [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 -- _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+(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 [ 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[1]:4 [ main::x#2 main::x#1 ]
Removing always clobbered register reg byte y as potential for zp[1]:4 [ main::x#2 main::x#1 ]
Removing always clobbered register reg byte a as potential for zp[1]:5 [ main::e#3 main::e#5 main::e#1 main::e#2 ]
Removing always clobbered register reg byte y as potential for zp[1]:5 [ main::e#3 main::e#5 main::e#1 main::e#2 ]
Removing always clobbered register reg byte a as potential for zp[1]:6 [ main::y#2 main::y#4 main::y#1 ]
Removing always clobbered register reg byte y as potential for zp[1]: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[1]:6 [ main::y#2 main::y#4 main::y#1 ]
Removing always clobbered register reg byte x as potential for zp[1]: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+(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 [ 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+(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[2]:2 [ main::cursor#3 main::cursor#5 main::cursor#1 main::cursor#2 ] : zp[2]:2 , 
Potential registers zp[1]:4 [ main::x#2 main::x#1 ] : zp[1]:4 , 
Potential registers zp[1]:5 [ main::e#3 main::e#5 main::e#1 main::e#2 ] : zp[1]:5 , reg byte x , 
Potential registers zp[1]:6 [ main::y#2 main::y#4 main::y#1 ] : zp[1]:6 , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 55: zp[1]:5 [ main::e#3 main::e#5 main::e#1 main::e#2 ] 46.75: zp[2]:2 [ main::cursor#3 main::cursor#5 main::cursor#1 main::cursor#2 ] 29.33: zp[1]:6 [ main::y#2 main::y#4 main::y#1 ] 14.67: zp[1]: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[2]:2 [ main::cursor#3 main::cursor#5 main::cursor#1 main::cursor#2 ] zp[1]:6 [ main::y#2 main::y#4 main::y#1 ] zp[1]:4 [ main::x#2 main::x#1 ] 
Uplifting [] best 1088 combination 
Attempting to uplift remaining variables inzp[1]:6 [ main::y#2 main::y#4 main::y#1 ]
Uplifting [main] best 1088 combination zp[1]:6 [ main::y#2 main::y#4 main::y#1 ] 
Attempting to uplift remaining variables inzp[1]:4 [ main::x#2 main::x#1 ]
Uplifting [main] best 1088 combination zp[1]:4 [ main::x#2 main::x#1 ] 
Allocated (was zp[1]:6) zp[1]: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
  .label SCREEN = $400
  .const STAR = $51
  // @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 [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 [phi:main->main::@1#2] -- vbuz1=vbuc1 
    lda #x0
    sta.z x
    // [5] phi (byte*) main::cursor#3 = (const byte*) SCREEN+(const byte) main::y0*(byte) $28+(const byte) main::x0 [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 -- _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+(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 __bbegin with __b1
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 __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 __b1:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(const byte*) SCREEN[(number) $28*(number) $19]  = (byte*) 1024
(const byte) 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[2]:2 8.25
(byte*) main::cursor#2 cursor zp[2]:2 11.0
(byte*) main::cursor#3 cursor zp[2]:2 11.0
(byte*) main::cursor#5 cursor zp[2]: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[1]:4 3.666666666666667
(byte) main::x#2 x zp[1]:4 11.0
(const byte) main::x0 = (byte) 4
(const byte) main::x1 = (byte) $27
(byte) main::xd
(const byte) main::xd#0 xd = (const byte) main::x1-(const byte) main::x0
(byte) main::y
(byte) main::y#1 y zp[1]:5 7.333333333333333
(byte) main::y#2 y zp[1]:5 5.5
(byte) main::y#4 y zp[1]:5 16.5
(const byte) main::y0 = (byte) 4
(const byte) main::y1 = (byte) $18
(byte) main::yd
(const byte) main::yd#0 yd = (const byte) main::y1-(const byte) main::y0

zp[2]:2 [ main::cursor#3 main::cursor#5 main::cursor#1 main::cursor#2 ]
zp[1]:4 [ main::x#2 main::x#1 ]
reg byte x [ main::e#3 main::e#5 main::e#1 main::e#2 ]
zp[1]: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
  .label SCREEN = $400
  .const STAR = $51
  // @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 [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 [phi:main->main::@1#2] -- vbuz1=vbuc1 
    lda #x0
    sta.z x
    // [5] phi (byte*) main::cursor#3 = (const byte*) SCREEN+(const byte) main::y0*(byte) $28+(const byte) main::x0 [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 -- _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+(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

