Identified constant variable (byte) main::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
main: scope:[main]  from @1
  (byte) main::STAR#0 ← (number) $51
  (byte[$28*$19]) main::screen#0 ← ((byte[$28*$19])) (number) $400
  (byte) main::x0#0 ← (number) 0
  (byte) main::y0#0 ← (number) 0
  (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
  (number~) main::$4 ← (byte) main::x#0 + (number~) main::$3
  (word) main::idx#0 ← (number~) main::$4
  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 )
  (word) main::idx#3 ← phi( main/(word) main::idx#0 main::@2/(word) main::idx#5 )
  *((byte[$28*$19]) main::screen#0 + (word) main::idx#3) ← (byte) main::STAR#0
  (number~) main::$5 ← (byte) main::x#2 + (number) 1
  (byte) main::x#1 ← (number~) main::$5
  (number~) main::$6 ← (word) main::idx#3 + (number) 1
  (word) main::idx#1 ← (number~) main::$6
  (byte~) main::$7 ← (byte) main::e#3 + (byte) main::yd#1
  (byte) main::e#1 ← (byte~) main::$7
  (bool~) main::$8 ← (byte) main::xd#1 < (byte) main::e#1
  (bool~) main::$9 ← ! (bool~) main::$8
  if((bool~) main::$9) 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 )
  (word) main::idx#5 ← phi( main::@1/(word) main::idx#1 main::@3/(word) main::idx#2 )
  (byte) main::x#3 ← phi( main::@1/(byte) main::x#1 main::@3/(byte) main::x#4 )
  (number~) main::$13 ← (byte) main::x1#0 + (number) 1
  (bool~) main::$14 ← (byte) main::x#3 < (number~) main::$13
  if((bool~) main::$14) 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 )
  (word) main::idx#4 ← phi( main::@1/(word) main::idx#1 )
  (byte) main::y#2 ← phi( main::@1/(byte) main::y#3 )
  (number~) main::$10 ← (byte) main::y#2 + (number) 1
  (byte) main::y#1 ← (number~) main::$10
  (number~) main::$11 ← (word) main::idx#4 + (number) $28
  (word) main::idx#2 ← (number~) main::$11
  (byte~) main::$12 ← (byte) main::e#4 - (byte) main::xd#2
  (byte) main::e#2 ← (byte~) main::$12
  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
(void()) main()
(byte~) main::$0
(byte~) main::$1
(number~) main::$10
(number~) main::$11
(byte~) main::$12
(number~) main::$13
(bool~) main::$14
(number~) main::$2
(number~) main::$3
(number~) main::$4
(number~) main::$5
(number~) main::$6
(byte~) main::$7
(bool~) main::$8
(bool~) main::$9
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte) main::STAR
(byte) main::STAR#0
(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
(word) main::idx
(word) main::idx#0
(word) main::idx#1
(word) main::idx#2
(word) main::idx#3
(word) main::idx#4
(word) main::idx#5
(byte[$28*$19]) main::screen
(byte[$28*$19]) main::screen#0
(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) main::STAR#0 ← (number) $51
Adding number conversion cast (unumber) 0 in (byte) main::x0#0 ← (number) 0
Adding number conversion cast (unumber) 0 in (byte) main::y0#0 ← (number) 0
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) main::$4 in (number~) main::$4 ← (byte) main::x#0 + (unumber~) main::$3
Adding number conversion cast (unumber) 1 in (number~) main::$5 ← (byte) main::x#2 + (number) 1
Adding number conversion cast (unumber) main::$5 in (number~) main::$5 ← (byte) main::x#2 + (unumber)(number) 1
Adding number conversion cast (unumber) 1 in (number~) main::$6 ← (word) main::idx#3 + (number) 1
Adding number conversion cast (unumber) main::$6 in (number~) main::$6 ← (word) main::idx#3 + (unumber)(number) 1
Adding number conversion cast (unumber) 1 in (number~) main::$13 ← (byte) main::x1#0 + (number) 1
Adding number conversion cast (unumber) main::$13 in (number~) main::$13 ← (byte) main::x1#0 + (unumber)(number) 1
Adding number conversion cast (unumber) 1 in (number~) main::$10 ← (byte) main::y#2 + (number) 1
Adding number conversion cast (unumber) main::$10 in (number~) main::$10 ← (byte) main::y#2 + (unumber)(number) 1
Adding number conversion cast (unumber) $28 in (number~) main::$11 ← (word) main::idx#4 + (number) $28
Adding number conversion cast (unumber) main::$11 in (number~) main::$11 ← (word) main::idx#4 + (unumber)(number) $28
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte) main::STAR#0 ← (unumber)(number) $51
Inlining cast (byte[$28*$19]) main::screen#0 ← (byte[$28*$19])(number) $400
Inlining cast (byte) main::x0#0 ← (unumber)(number) 0
Inlining cast (byte) main::y0#0 ← (unumber)(number) 0
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 0
Simplifying constant integer cast 0
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) 0
Finalized unsigned number type (byte) 0
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::$4 ← (byte) main::x#0 + (byte~) main::$3
Inferred type updated to byte in (unumber~) main::$5 ← (byte) main::x#2 + (byte) 1
Inferred type updated to word in (unumber~) main::$6 ← (word) main::idx#3 + (byte) 1
Inferred type updated to byte in (unumber~) main::$13 ← (byte) main::x1#0 + (byte) 1
Inferred type updated to byte in (unumber~) main::$10 ← (byte) main::y#2 + (byte) 1
Inferred type updated to word in (unumber~) main::$11 ← (word) main::idx#4 + (byte) $28
Inversing boolean not [26] (bool~) main::$9 ← (byte) main::xd#1 >= (byte) main::e#1 from [25] (bool~) main::$8 ← (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 (word) main::idx#0 = (byte~) main::$4 
Alias (byte) main::x#1 = (byte~) main::$5 (byte) main::x#4 
Alias (word) main::idx#1 = (word~) main::$6 (word) main::idx#4 
Alias (byte) main::e#1 = (byte~) main::$7 (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::$10 
Alias (word) main::idx#2 = (word~) main::$11 
Alias (byte) main::e#2 = (byte~) main::$12 
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::$9 [27] if((byte) main::xd#0>=(byte) main::e#1) goto main::@2
Simple Condition (bool~) main::$14 [31] if((byte) main::x#1<(byte~) main::$13) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) main::STAR#0 = $51
Constant (const byte[$28*$19]) main::screen#0 = (byte*) 1024
Constant (const byte) main::x0#0 = 0
Constant (const byte) main::y0#0 = 0
Constant (const byte) main::x1#0 = $27
Constant (const byte) main::y1#0 = $18
Successful SSA optimization Pass2ConstantIdentification
De-inlining pointer[w] to *(pointer+w)   [18] *((const byte[$28*$19]) main::screen#0 + (word) main::idx#3) ← (const byte) main::STAR#0
Successful SSA optimization Pass2DeInlineWordDerefIdx
Simplifying expression containing zero main::x1#0 in [6] (byte) main::xd#0 ← (const byte) main::x1#0 - (const byte) main::x0#0
Simplifying expression containing zero main::y1#0 in [8] (byte) main::yd#0 ← (const byte) main::y1#0 - (const byte) main::y0#0
Simplifying expression containing zero main::$3 in [15] (word) main::idx#0 ← (const byte) main::x0#0 + (byte~) main::$3
Successful SSA optimization PassNSimplifyExpressionWithZero
Alias (word) main::idx#0 = (byte~) main::$3 
Successful SSA optimization Pass2AliasElimination
Constant right-side identified [3] (word) main::idx#0 ← (const byte) main::y0#0 * (byte) $28
Constant right-side identified [13] (byte~) main::$13 ← (const byte) main::x1#0 + (byte) 1
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::xd#0 = main::x1#0
Constant (const byte) main::yd#0 = main::y1#0
Constant (const word) main::idx#0 = main::y0#0*$28
Constant (const byte) main::$13 = main::x1#0+1
Successful SSA optimization Pass2ConstantIdentification
Simplifying constant evaluating to zero (const byte) main::y0#0*(byte) $28 in 
Successful SSA optimization PassNSimplifyConstantZero
Constant right-side identified [0] (byte) main::e#0 ← (const byte) main::yd#0 / (byte) 2
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::e#0 = main::yd#0/2
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with var siblings (const word) main::idx#0
Inlining constant with var siblings (const byte) main::e#0
Constant inlined main::$13 = (const byte) main::x1#0+(byte) 1
Constant inlined main::idx#0 = (byte) 0
Constant inlined main::xd#0 = (const byte) main::x1#0
Constant inlined main::e#0 = (const byte) main::y1#0/(byte) 2
Constant inlined main::yd#0 = (const byte) main::y1#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 [16] main::idx#8 ← main::idx#2
Coalesced [17] main::e#8 ← main::e#2
Coalesced [18] main::y#7 ← main::y#1
Coalesced [22] main::idx#6 ← main::idx#5
Coalesced [23] main::x#5 ← main::x#1
Coalesced [24] main::e#6 ← main::e#5
Coalesced [25] main::y#5 ← main::y#4
Coalesced [26] main::idx#7 ← main::idx#1
Coalesced [27] main::e#7 ← main::e#1
Coalesced (already) [28] 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::y1#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] (word) main::idx#3 ← phi( main/(byte) 0 main::@2/(word) main::idx#5 )
  [6] (byte*~) main::$15 ← (const byte[$28*$19]) main::screen#0 + (word) main::idx#3
  [7] *((byte*~) main::$15) ← (const byte) main::STAR#0
  [8] (byte) main::x#1 ← (byte) main::x#2 + (byte) 1
  [9] (word) main::idx#1 ← (word) main::idx#3 + (byte) 1
  [10] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::y1#0
  [11] if((const byte) main::x1#0>=(byte) main::e#1) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@1
  [12] (byte) main::y#1 ← (byte) main::y#2 + (byte) 1
  [13] (word) main::idx#2 ← (word) main::idx#1 + (byte) $28
  [14] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::x1#0
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@3
  [15] (byte) main::y#4 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#1 )
  [15] (byte) main::e#5 ← phi( main::@1/(byte) main::e#1 main::@3/(byte) main::e#2 )
  [15] (word) main::idx#5 ← phi( main::@1/(word) main::idx#1 main::@3/(word) main::idx#2 )
  [16] 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
  [17] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(byte*~) main::$15 22.0
(byte) main::STAR
(byte) main::e
(byte) main::e#1 11.0
(byte) main::e#2 22.0
(byte) main::e#3 4.4
(byte) main::e#5 16.5
(word) main::idx
(word) main::idx#1 8.25
(word) main::idx#2 11.0
(word) main::idx#3 8.25
(word) main::idx#5 16.5
(byte[$28*$19]) main::screen
(byte) main::x
(byte) main::x#1 3.666666666666667
(byte) main::x#2 7.333333333333333
(byte) main::x0
(byte) main::x1
(byte) main::xd
(byte) main::y
(byte) main::y#1 7.333333333333333
(byte) main::y#2 4.714285714285714
(byte) main::y#4 16.5
(byte) main::y0
(byte) main::y1
(byte) main::yd

Initial phi equivalence classes
[ main::idx#3 main::idx#5 main::idx#1 main::idx#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 ]
Added variable main::$15 to zero page equivalence class [ main::$15 ]
Complete equivalence classes
[ main::idx#3 main::idx#5 main::idx#1 main::idx#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 ]
[ main::$15 ]
Allocated zp ZP_WORD:2 [ main::idx#3 main::idx#5 main::idx#1 main::idx#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 ]
Allocated zp ZP_WORD:7 [ main::$15 ]

INITIAL ASM
Target platform is c64basic
  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  // @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 STAR = $51
    .label screen = $400
    .const x0 = 0
    .const y0 = 0
    .const x1 = $27
    .const y1 = $18
    .label x = 4
    .label idx = 2
    .label e = 5
    .label y = 6
    .label _15 = 7
    // [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::y1#0/(byte) 2 [phi:main->main::@1#1] -- vbuz1=vbuc1 
    lda #y1/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 (word) main::idx#3 = (byte) 0 [phi:main->main::@1#3] -- vwuz1=vbuc1 
    lda #<0
    sta.z idx
    lda #>0
    sta.z idx+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 (word) main::idx#3 = (word) main::idx#5 [phi:main::@2->main::@1#3] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] (byte*~) main::$15 ← (const byte[$28*$19]) main::screen#0 + (word) main::idx#3 -- pbuz1=pbuc1_plus_vwuz2 
    lda.z idx
    clc
    adc #<screen
    sta.z _15
    lda.z idx+1
    adc #>screen
    sta.z _15+1
    // [7] *((byte*~) main::$15) ← (const byte) main::STAR#0 -- _deref_pbuz1=vbuc1 
    lda #STAR
    ldy #0
    sta (_15),y
    // [8] (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 -- vbuz1=vbuz1_plus_1 
    inc.z x
    // [9] (word) main::idx#1 ← (word) main::idx#3 + (byte) 1 -- vwuz1=vwuz1_plus_1 
    inc.z idx
    bne !+
    inc.z idx+1
  !:
    // [10] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::y1#0 -- vbuz1=vbuz1_plus_vbuc1 
    lax.z e
    axs #-[y1]
    stx.z e
    // [11] if((const byte) main::x1#0>=(byte) main::e#1) goto main::@2 -- vbuc1_ge_vbuz1_then_la1 
    lda #x1
    cmp.z e
    bcs b2_from_b1
    jmp b3
    // main::@3
  b3:
    // [12] (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 -- vbuz1=vbuz1_plus_1 
    inc.z y
    // [13] (word) main::idx#2 ← (word) main::idx#1 + (byte) $28 -- vwuz1=vwuz1_plus_vbuc1 
    lda #$28
    clc
    adc.z idx
    sta.z idx
    bcc !+
    inc.z idx+1
  !:
    // [14] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::x1#0 -- vbuz1=vbuz1_minus_vbuc1 
    lax.z e
    axs #x1
    stx.z e
    // [15] phi from main::@1 main::@3 to main::@2 [phi:main::@1/main::@3->main::@2]
  b2_from_b1:
  b2_from_b3:
    // [15] phi (byte) main::y#4 = (byte) main::y#2 [phi:main::@1/main::@3->main::@2#0] -- register_copy 
    // [15] phi (byte) main::e#5 = (byte) main::e#1 [phi:main::@1/main::@3->main::@2#1] -- register_copy 
    // [15] phi (word) main::idx#5 = (word) main::idx#1 [phi:main::@1/main::@3->main::@2#2] -- register_copy 
    jmp b2
    // main::@2
  b2:
    // [16] 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:
    // [17] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] (byte*~) main::$15 ← (const byte[$28*$19]) main::screen#0 + (word) main::idx#3 [ main::idx#3 main::x#2 main::e#3 main::y#2 main::$15 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 main::$15 ] ) always clobbers reg byte a 
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 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 a as potential for zp ZP_BYTE:6 [ main::y#2 main::y#4 main::y#1 ]
Statement [7] *((byte*~) main::$15) ← (const byte) main::STAR#0 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ) always clobbers reg byte a reg byte y 
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 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 y as potential for zp ZP_BYTE:6 [ main::y#2 main::y#4 main::y#1 ]
Statement [10] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::y1#0 [ main::y#2 main::x#1 main::idx#1 main::e#1 ] ( main:2 [ main::y#2 main::x#1 main::idx#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 [13] (word) main::idx#2 ← (word) main::idx#1 + (byte) $28 [ main::x#1 main::e#1 main::y#1 main::idx#2 ] ( main:2 [ main::x#1 main::e#1 main::y#1 main::idx#2 ] ) always clobbers reg byte a 
Statement [14] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::x1#0 [ main::x#1 main::y#1 main::idx#2 main::e#2 ] ( main:2 [ main::x#1 main::y#1 main::idx#2 main::e#2 ] ) always clobbers reg byte a reg byte x 
Statement [16] if((byte) main::x#1<(const byte) main::x1#0+(byte) 1) goto main::@1 [ main::idx#5 main::x#1 main::e#5 main::y#4 ] ( main:2 [ main::idx#5 main::x#1 main::e#5 main::y#4 ] ) always clobbers reg byte a 
Statement [6] (byte*~) main::$15 ← (const byte[$28*$19]) main::screen#0 + (word) main::idx#3 [ main::idx#3 main::x#2 main::e#3 main::y#2 main::$15 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 main::$15 ] ) always clobbers reg byte a 
Statement [7] *((byte*~) main::$15) ← (const byte) main::STAR#0 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ( main:2 [ main::idx#3 main::x#2 main::e#3 main::y#2 ] ) always clobbers reg byte a reg byte y 
Statement [10] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::y1#0 [ main::y#2 main::x#1 main::idx#1 main::e#1 ] ( main:2 [ main::y#2 main::x#1 main::idx#1 main::e#1 ] ) always clobbers reg byte a reg byte x 
Statement [13] (word) main::idx#2 ← (word) main::idx#1 + (byte) $28 [ main::x#1 main::e#1 main::y#1 main::idx#2 ] ( main:2 [ main::x#1 main::e#1 main::y#1 main::idx#2 ] ) always clobbers reg byte a 
Statement [14] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::x1#0 [ main::x#1 main::y#1 main::idx#2 main::e#2 ] ( main:2 [ main::x#1 main::y#1 main::idx#2 main::e#2 ] ) always clobbers reg byte a reg byte x 
Statement [16] if((byte) main::x#1<(const byte) main::x1#0+(byte) 1) goto main::@1 [ main::idx#5 main::x#1 main::e#5 main::y#4 ] ( main:2 [ main::idx#5 main::x#1 main::e#5 main::y#4 ] ) always clobbers reg byte a 
Potential registers zp ZP_WORD:2 [ main::idx#3 main::idx#5 main::idx#1 main::idx#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 , 
Potential registers zp ZP_WORD:7 [ main::$15 ] : zp ZP_WORD:7 , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 53.9: zp ZP_BYTE:5 [ main::e#3 main::e#5 main::e#1 main::e#2 ] 44: zp ZP_WORD:2 [ main::idx#3 main::idx#5 main::idx#1 main::idx#2 ] 28.55: zp ZP_BYTE:6 [ main::y#2 main::y#4 main::y#1 ] 22: zp ZP_WORD:7 [ main::$15 ] 11: zp ZP_BYTE:4 [ main::x#2 main::x#1 ] 
Uplift Scope [] 

Uplifting [main] best 1293 combination reg byte x [ main::e#3 main::e#5 main::e#1 main::e#2 ] zp ZP_WORD:2 [ main::idx#3 main::idx#5 main::idx#1 main::idx#2 ] zp ZP_BYTE:6 [ main::y#2 main::y#4 main::y#1 ] zp ZP_WORD:7 [ main::$15 ] zp ZP_BYTE:4 [ main::x#2 main::x#1 ] 
Uplifting [] best 1293 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:6 [ main::y#2 main::y#4 main::y#1 ]
Uplifting [main] best 1293 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 1293 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 ]
Allocated (was zp ZP_WORD:7) zp ZP_WORD:6 [ main::$15 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  // @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 STAR = $51
    .label screen = $400
    .const x0 = 0
    .const y0 = 0
    .const x1 = $27
    .const y1 = $18
    .label x = 4
    .label idx = 2
    .label y = 5
    .label _15 = 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::y1#0/(byte) 2 [phi:main->main::@1#1] -- vbuxx=vbuc1 
    ldx #y1/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 (word) main::idx#3 = (byte) 0 [phi:main->main::@1#3] -- vwuz1=vbuc1 
    lda #<0
    sta.z idx
    lda #>0
    sta.z idx+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 (word) main::idx#3 = (word) main::idx#5 [phi:main::@2->main::@1#3] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] (byte*~) main::$15 ← (const byte[$28*$19]) main::screen#0 + (word) main::idx#3 -- pbuz1=pbuc1_plus_vwuz2 
    lda.z idx
    clc
    adc #<screen
    sta.z _15
    lda.z idx+1
    adc #>screen
    sta.z _15+1
    // [7] *((byte*~) main::$15) ← (const byte) main::STAR#0 -- _deref_pbuz1=vbuc1 
    lda #STAR
    ldy #0
    sta (_15),y
    // [8] (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 -- vbuz1=vbuz1_plus_1 
    inc.z x
    // [9] (word) main::idx#1 ← (word) main::idx#3 + (byte) 1 -- vwuz1=vwuz1_plus_1 
    inc.z idx
    bne !+
    inc.z idx+1
  !:
    // [10] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::y1#0 -- vbuxx=vbuxx_plus_vbuc1 
    txa
    axs #-[y1]
    // [11] if((const byte) main::x1#0>=(byte) main::e#1) goto main::@2 -- vbuc1_ge_vbuxx_then_la1 
    cpx #x1
    bcc b2_from_b1
    beq b2_from_b1
    jmp b3
    // main::@3
  b3:
    // [12] (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 -- vbuz1=vbuz1_plus_1 
    inc.z y
    // [13] (word) main::idx#2 ← (word) main::idx#1 + (byte) $28 -- vwuz1=vwuz1_plus_vbuc1 
    lda #$28
    clc
    adc.z idx
    sta.z idx
    bcc !+
    inc.z idx+1
  !:
    // [14] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::x1#0 -- vbuxx=vbuxx_minus_vbuc1 
    txa
    axs #x1
    // [15] phi from main::@1 main::@3 to main::@2 [phi:main::@1/main::@3->main::@2]
  b2_from_b1:
  b2_from_b3:
    // [15] phi (byte) main::y#4 = (byte) main::y#2 [phi:main::@1/main::@3->main::@2#0] -- register_copy 
    // [15] phi (byte) main::e#5 = (byte) main::e#1 [phi:main::@1/main::@3->main::@2#1] -- register_copy 
    // [15] phi (word) main::idx#5 = (word) main::idx#1 [phi:main::@1/main::@3->main::@2#2] -- register_copy 
    jmp b2
    // main::@2
  b2:
    // [16] 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:
    // [17] 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
Removing instruction lda #>0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Replacing label b2_from_b1 with b2
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
(void()) main()
(byte*~) main::$15 $15 zp ZP_WORD:6 22.0
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte) main::STAR
(const byte) main::STAR#0 STAR = (byte) $51
(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 4.4
(byte) main::e#5 reg byte x 16.5
(word) main::idx
(word) main::idx#1 idx zp ZP_WORD:2 8.25
(word) main::idx#2 idx zp ZP_WORD:2 11.0
(word) main::idx#3 idx zp ZP_WORD:2 8.25
(word) main::idx#5 idx zp ZP_WORD:2 16.5
(byte[$28*$19]) main::screen
(const byte[$28*$19]) main::screen#0 screen = (byte*) 1024
(byte) main::x
(byte) main::x#1 x zp ZP_BYTE:4 3.666666666666667
(byte) main::x#2 x zp ZP_BYTE:4 7.333333333333333
(byte) main::x0
(const byte) main::x0#0 x0 = (byte) 0
(byte) main::x1
(const byte) main::x1#0 x1 = (byte) $27
(byte) main::xd
(byte) main::y
(byte) main::y#1 y zp ZP_BYTE:5 7.333333333333333
(byte) main::y#2 y zp ZP_BYTE:5 4.714285714285714
(byte) main::y#4 y zp ZP_BYTE:5 16.5
(byte) main::y0
(const byte) main::y0#0 y0 = (byte) 0
(byte) main::y1
(const byte) main::y1#0 y1 = (byte) $18
(byte) main::yd

zp ZP_WORD:2 [ main::idx#3 main::idx#5 main::idx#1 main::idx#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 ]
zp ZP_WORD:6 [ main::$15 ]


FINAL ASSEMBLER
Score: 1111

  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  // @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 STAR = $51
    .label screen = $400
    .const x0 = 0
    .const y0 = 0
    .const x1 = $27
    .const y1 = $18
    .label x = 4
    .label idx = 2
    .label y = 5
    .label _15 = 6
    // [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::y1#0/(byte) 2 [phi:main->main::@1#1] -- vbuxx=vbuc1 
    ldx #y1/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 (word) main::idx#3 = (byte) 0 [phi:main->main::@1#3] -- vwuz1=vbuc1 
    lda #<0
    sta.z idx
    sta.z idx+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 (word) main::idx#3 = (word) main::idx#5 [phi:main::@2->main::@1#3] -- register_copy 
    // main::@1
  b1:
    // screen[idx] = STAR
    // [6] (byte*~) main::$15 ← (const byte[$28*$19]) main::screen#0 + (word) main::idx#3 -- pbuz1=pbuc1_plus_vwuz2 
    lda.z idx
    clc
    adc #<screen
    sta.z _15
    lda.z idx+1
    adc #>screen
    sta.z _15+1
    // [7] *((byte*~) main::$15) ← (const byte) main::STAR#0 -- _deref_pbuz1=vbuc1 
    lda #STAR
    ldy #0
    sta (_15),y
    // x = x + 1
    // [8] (byte) main::x#1 ← (byte) main::x#2 + (byte) 1 -- vbuz1=vbuz1_plus_1 
    inc.z x
    // idx = idx + 1
    // [9] (word) main::idx#1 ← (word) main::idx#3 + (byte) 1 -- vwuz1=vwuz1_plus_1 
    inc.z idx
    bne !+
    inc.z idx+1
  !:
    // e = e+yd
    // [10] (byte) main::e#1 ← (byte) main::e#3 + (const byte) main::y1#0 -- vbuxx=vbuxx_plus_vbuc1 
    txa
    axs #-[y1]
    // if(xd<e)
    // [11] if((const byte) main::x1#0>=(byte) main::e#1) goto main::@2 -- vbuc1_ge_vbuxx_then_la1 
    cpx #x1
    bcc b2
    beq b2
    // main::@3
    // y = y+1
    // [12] (byte) main::y#1 ← (byte) main::y#2 + (byte) 1 -- vbuz1=vbuz1_plus_1 
    inc.z y
    // idx  = idx + 40
    // [13] (word) main::idx#2 ← (word) main::idx#1 + (byte) $28 -- vwuz1=vwuz1_plus_vbuc1 
    lda #$28
    clc
    adc.z idx
    sta.z idx
    bcc !+
    inc.z idx+1
  !:
    // e = e - xd
    // [14] (byte) main::e#2 ← (byte) main::e#1 - (const byte) main::x1#0 -- vbuxx=vbuxx_minus_vbuc1 
    txa
    axs #x1
    // [15] phi from main::@1 main::@3 to main::@2 [phi:main::@1/main::@3->main::@2]
    // [15] phi (byte) main::y#4 = (byte) main::y#2 [phi:main::@1/main::@3->main::@2#0] -- register_copy 
    // [15] phi (byte) main::e#5 = (byte) main::e#1 [phi:main::@1/main::@3->main::@2#1] -- register_copy 
    // [15] phi (word) main::idx#5 = (word) main::idx#1 [phi:main::@1/main::@3->main::@2#2] -- register_copy 
    // main::@2
  b2:
    // while (x<(x1+1))
    // [16] 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
    // }
    // [17] return 
    rts
}
  // File Data

