Identified constant variable (byte*) PROCPORT
Identified constant variable (byte*) CHARGEN
Identified constant variable (byte*) SCREEN

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@1

(void()) main()
main: scope:[main]  from @1
  asm { sei  }
  (byte*~) main::$0 ← (const byte*) CHARGEN + (number) 8
  (byte*) main::CHAR_A#0 ← (byte*~) main::$0
  *((const byte*) PROCPORT) ← (number) $32
  (byte*) main::sc#0 ← (const byte*) SCREEN
  (byte) main::y#0 ← (byte) 0
  to:main::@1
main::@1: scope:[main]  from main main::@5
  (byte*) main::sc#7 ← phi( main/(byte*) main::sc#0 main::@5/(byte*) main::sc#2 )
  (byte) main::y#2 ← phi( main/(byte) main::y#0 main::@5/(byte) main::y#1 )
  (byte*) main::CHAR_A#1 ← phi( main/(byte*) main::CHAR_A#0 main::@5/(byte*) main::CHAR_A#2 )
  (byte) main::bits#0 ← *((byte*) main::CHAR_A#1 + (byte) main::y#2)
  (byte) main::x#0 ← (byte) 0
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@3
  (byte*) main::CHAR_A#4 ← phi( main::@1/(byte*) main::CHAR_A#1 main::@3/(byte*) main::CHAR_A#3 )
  (byte) main::y#5 ← phi( main::@1/(byte) main::y#2 main::@3/(byte) main::y#4 )
  (byte) main::x#3 ← phi( main::@1/(byte) main::x#0 main::@3/(byte) main::x#1 )
  (byte*) main::sc#5 ← phi( main::@1/(byte*) main::sc#7 main::@3/(byte*) main::sc#1 )
  (byte) main::bits#2 ← phi( main::@1/(byte) main::bits#0 main::@3/(byte) main::bits#1 )
  (byte) main::c#0 ← (byte) '.'
  (number~) main::$1 ← (byte) main::bits#2 & (number) $80
  (bool~) main::$2 ← (number~) main::$1 != (number) 0
  (bool~) main::$3 ← ! (bool~) main::$2
  if((bool~) main::$3) goto main::@3
  to:main::@4
main::@3: scope:[main]  from main::@2 main::@4
  (byte*) main::CHAR_A#3 ← phi( main::@2/(byte*) main::CHAR_A#4 main::@4/(byte*) main::CHAR_A#5 )
  (byte) main::y#4 ← phi( main::@2/(byte) main::y#5 main::@4/(byte) main::y#6 )
  (byte) main::x#2 ← phi( main::@2/(byte) main::x#3 main::@4/(byte) main::x#4 )
  (byte) main::bits#3 ← phi( main::@2/(byte) main::bits#2 main::@4/(byte) main::bits#4 )
  (byte*) main::sc#3 ← phi( main::@2/(byte*) main::sc#5 main::@4/(byte*) main::sc#6 )
  (byte) main::c#2 ← phi( main::@2/(byte) main::c#0 main::@4/(byte) main::c#1 )
  *((byte*) main::sc#3) ← (byte) main::c#2
  (byte*) main::sc#1 ← ++ (byte*) main::sc#3
  (number~) main::$4 ← (byte) main::bits#3 * (number) 2
  (byte) main::bits#1 ← (number~) main::$4
  (byte) main::x#1 ← (byte) main::x#2 + rangenext(0,7)
  (bool~) main::$5 ← (byte) main::x#1 != rangelast(0,7)
  if((bool~) main::$5) goto main::@2
  to:main::@5
main::@4: scope:[main]  from main::@2
  (byte*) main::CHAR_A#5 ← phi( main::@2/(byte*) main::CHAR_A#4 )
  (byte) main::y#6 ← phi( main::@2/(byte) main::y#5 )
  (byte) main::x#4 ← phi( main::@2/(byte) main::x#3 )
  (byte) main::bits#4 ← phi( main::@2/(byte) main::bits#2 )
  (byte*) main::sc#6 ← phi( main::@2/(byte*) main::sc#5 )
  (byte) main::c#1 ← (byte) '*'
  to:main::@3
main::@5: scope:[main]  from main::@3
  (byte*) main::CHAR_A#2 ← phi( main::@3/(byte*) main::CHAR_A#3 )
  (byte) main::y#3 ← phi( main::@3/(byte) main::y#4 )
  (byte*) main::sc#4 ← phi( main::@3/(byte*) main::sc#1 )
  (byte*~) main::$6 ← (byte*) main::sc#4 + (number) $20
  (byte*) main::sc#2 ← (byte*~) main::$6
  (byte) main::y#1 ← (byte) main::y#3 + rangenext(0,7)
  (bool~) main::$7 ← (byte) main::y#1 != rangelast(0,7)
  if((bool~) main::$7) goto main::@1
  to:main::@6
main::@6: scope:[main]  from main::@5
  *((const byte*) PROCPORT) ← (number) $37
  asm { cli  }
  to:main::@return
main::@return: scope:[main]  from main::@6
  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*) CHARGEN = (byte*)(number) $d000
(const byte*) PROCPORT = (byte*)(number) 1
(const byte*) SCREEN = (byte*)(number) $400
(void()) main()
(byte*~) main::$0
(number~) main::$1
(bool~) main::$2
(bool~) main::$3
(number~) main::$4
(bool~) main::$5
(byte*~) main::$6
(bool~) main::$7
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@return
(byte*) main::CHAR_A
(byte*) main::CHAR_A#0
(byte*) main::CHAR_A#1
(byte*) main::CHAR_A#2
(byte*) main::CHAR_A#3
(byte*) main::CHAR_A#4
(byte*) main::CHAR_A#5
(byte) main::bits
(byte) main::bits#0
(byte) main::bits#1
(byte) main::bits#2
(byte) main::bits#3
(byte) main::bits#4
(byte) main::c
(byte) main::c#0
(byte) main::c#1
(byte) main::c#2
(byte*) main::sc
(byte*) main::sc#0
(byte*) main::sc#1
(byte*) main::sc#2
(byte*) main::sc#3
(byte*) main::sc#4
(byte*) main::sc#5
(byte*) main::sc#6
(byte*) main::sc#7
(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::y
(byte) main::y#0
(byte) main::y#1
(byte) main::y#2
(byte) main::y#3
(byte) main::y#4
(byte) main::y#5
(byte) main::y#6

Adding number conversion cast (unumber) 8 in (byte*~) main::$0 ← (const byte*) CHARGEN + (number) 8
Adding number conversion cast (unumber) $32 in *((const byte*) PROCPORT) ← (number) $32
Adding number conversion cast (unumber) $80 in (number~) main::$1 ← (byte) main::bits#2 & (number) $80
Adding number conversion cast (unumber) main::$1 in (number~) main::$1 ← (byte) main::bits#2 & (unumber)(number) $80
Adding number conversion cast (unumber) 0 in (bool~) main::$2 ← (unumber~) main::$1 != (number) 0
Adding number conversion cast (unumber) 2 in (number~) main::$4 ← (byte) main::bits#3 * (number) 2
Adding number conversion cast (unumber) main::$4 in (number~) main::$4 ← (byte) main::bits#3 * (unumber)(number) 2
Adding number conversion cast (unumber) $20 in (byte*~) main::$6 ← (byte*) main::sc#4 + (number) $20
Adding number conversion cast (unumber) $37 in *((const byte*) PROCPORT) ← (number) $37
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast *((const byte*) PROCPORT) ← (unumber)(number) $32
Inlining cast *((const byte*) PROCPORT) ← (unumber)(number) $37
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1
Simplifying constant pointer cast (byte*) 53248
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 8
Simplifying constant integer cast $32
Simplifying constant integer cast $80
Simplifying constant integer cast 0
Simplifying constant integer cast 2
Simplifying constant integer cast $20
Simplifying constant integer cast $37
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 8
Finalized unsigned number type (byte) $32
Finalized unsigned number type (byte) $80
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) $20
Finalized unsigned number type (byte) $37
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) main::$1 ← (byte) main::bits#2 & (byte) $80
Inferred type updated to byte in (unumber~) main::$4 ← (byte) main::bits#3 * (byte) 2
Inversing boolean not [13] (bool~) main::$3 ← (byte~) main::$1 == (byte) 0 from [12] (bool~) main::$2 ← (byte~) main::$1 != (byte) 0
Successful SSA optimization Pass2UnaryNotSimplification
Alias (byte*) main::CHAR_A#0 = (byte*~) main::$0 
Alias (byte) main::bits#1 = (byte~) main::$4 
Alias (byte*) main::sc#5 = (byte*) main::sc#6 
Alias (byte) main::bits#2 = (byte) main::bits#4 
Alias (byte) main::x#3 = (byte) main::x#4 
Alias (byte) main::y#5 = (byte) main::y#6 
Alias (byte*) main::CHAR_A#4 = (byte*) main::CHAR_A#5 
Alias (byte*) main::sc#1 = (byte*) main::sc#4 
Alias (byte) main::y#3 = (byte) main::y#4 
Alias (byte*) main::CHAR_A#2 = (byte*) main::CHAR_A#3 
Alias (byte*) main::sc#2 = (byte*~) main::$6 
Successful SSA optimization Pass2AliasElimination
Alias (byte*) main::sc#3 = (byte*) main::sc#5 
Alias (byte) main::bits#2 = (byte) main::bits#3 
Alias (byte) main::x#2 = (byte) main::x#3 
Alias (byte) main::y#3 = (byte) main::y#5 
Alias (byte*) main::CHAR_A#2 = (byte*) main::CHAR_A#4 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) main::y#3 (byte) main::y#2
Identical Phi Values (byte*) main::CHAR_A#2 (byte*) main::CHAR_A#1
Successful SSA optimization Pass2IdenticalPhiElimination
Identical Phi Values (byte*) main::CHAR_A#1 (byte*) main::CHAR_A#0
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$3 [14] if((byte~) main::$1==(byte) 0) goto main::@3
Simple Condition (bool~) main::$5 [22] if((byte) main::x#1!=rangelast(0,7)) goto main::@2
Simple Condition (bool~) main::$7 [30] if((byte) main::y#1!=rangelast(0,7)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant right-side identified [1] (byte*) main::CHAR_A#0 ← (const byte*) CHARGEN + (byte) 8
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) main::CHAR_A#0 = CHARGEN+8
Constant (const byte*) main::sc#0 = SCREEN
Constant (const byte) main::y#0 = 0
Constant (const byte) main::x#0 = 0
Constant (const byte) main::c#0 = '.'
Constant (const byte) main::c#1 = '*'
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [20] main::x#1 ← ++ main::x#2 to ++
Resolved ranged comparison value [22] if(main::x#1!=rangelast(0,7)) goto main::@2 to (number) 8
Resolved ranged next value [28] main::y#1 ← ++ main::y#2 to ++
Resolved ranged comparison value [30] if(main::y#1!=rangelast(0,7)) goto main::@1 to (number) 8
Adding number conversion cast (unumber) 8 in if((byte) main::x#1!=(number) 8) goto main::@2
Adding number conversion cast (unumber) 8 in if((byte) main::y#1!=(number) 8) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 8
Simplifying constant integer cast 8
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 8
Finalized unsigned number type (byte) 8
Successful SSA optimization PassNFinalizeNumberTypeConversions
Rewriting multiplication to use shift [10] (byte) main::bits#1 ← (byte) main::bits#2 * (byte) 2
Successful SSA optimization Pass2MultiplyToShiftRewriting
Inlining constant with var siblings (const byte*) main::sc#0
Inlining constant with var siblings (const byte) main::y#0
Inlining constant with var siblings (const byte) main::x#0
Inlining constant with var siblings (const byte) main::c#0
Inlining constant with var siblings (const byte) main::c#1
Constant inlined main::sc#0 = (const byte*) SCREEN
Constant inlined main::c#0 = (byte) '.'
Constant inlined main::x#0 = (byte) 0
Constant inlined main::y#0 = (byte) 0
Constant inlined main::c#1 = (byte) '*'
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@7(between main::@5 and main::@1)
Added new block during phi lifting main::@8(between main::@3 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::@4
CALL GRAPH
Calls in [] to main:2 

Created 6 initial phi equivalence classes
Coalesced [9] main::bits#5 ← main::bits#0
Coalesced [10] main::sc#9 ← main::sc#7
Coalesced [27] main::y#7 ← main::y#1
Coalesced [28] main::sc#8 ← main::sc#2
Coalesced [29] main::bits#6 ← main::bits#1
Coalesced [30] main::sc#10 ← main::sc#1
Coalesced [31] main::x#5 ← main::x#1
Coalesced down to 5 phi equivalence classes
Culled Empty Block (label) @2
Culled Empty Block (label) main::@7
Culled Empty Block (label) main::@8
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::@4

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
  asm { sei  }
  [5] *((const byte*) PROCPORT) ← (byte) $32
  to:main::@1
main::@1: scope:[main]  from main main::@5
  [6] (byte*) main::sc#7 ← phi( main/(const byte*) SCREEN main::@5/(byte*) main::sc#2 )
  [6] (byte) main::y#2 ← phi( main/(byte) 0 main::@5/(byte) main::y#1 )
  [7] (byte) main::bits#0 ← *((const byte*) main::CHAR_A#0 + (byte) main::y#2)
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@3
  [8] (byte) main::x#2 ← phi( main::@1/(byte) 0 main::@3/(byte) main::x#1 )
  [8] (byte*) main::sc#3 ← phi( main::@1/(byte*) main::sc#7 main::@3/(byte*) main::sc#1 )
  [8] (byte) main::bits#2 ← phi( main::@1/(byte) main::bits#0 main::@3/(byte) main::bits#1 )
  [9] (byte~) main::$1 ← (byte) main::bits#2 & (byte) $80
  [10] if((byte~) main::$1==(byte) 0) goto main::@3
  to:main::@4
main::@4: scope:[main]  from main::@2
  [11] phi()
  to:main::@3
main::@3: scope:[main]  from main::@2 main::@4
  [12] (byte) main::c#2 ← phi( main::@2/(byte) '.' main::@4/(byte) '*' )
  [13] *((byte*) main::sc#3) ← (byte) main::c#2
  [14] (byte*) main::sc#1 ← ++ (byte*) main::sc#3
  [15] (byte) main::bits#1 ← (byte) main::bits#2 << (byte) 1
  [16] (byte) main::x#1 ← ++ (byte) main::x#2
  [17] if((byte) main::x#1!=(byte) 8) goto main::@2
  to:main::@5
main::@5: scope:[main]  from main::@3
  [18] (byte*) main::sc#2 ← (byte*) main::sc#1 + (byte) $20
  [19] (byte) main::y#1 ← ++ (byte) main::y#2
  [20] if((byte) main::y#1!=(byte) 8) goto main::@1
  to:main::@6
main::@6: scope:[main]  from main::@5
  [21] *((const byte*) PROCPORT) ← (byte) $37
  asm { cli  }
  to:main::@return
main::@return: scope:[main]  from main::@6
  [23] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(byte~) main::$1 202.0
(byte*) main::CHAR_A
(byte) main::bits
(byte) main::bits#0 22.0
(byte) main::bits#1 67.33333333333333
(byte) main::bits#2 44.85714285714286
(byte) main::c
(byte) main::c#2 101.0
(byte*) main::sc
(byte*) main::sc#1 53.25
(byte*) main::sc#2 7.333333333333333
(byte*) main::sc#3 52.33333333333333
(byte*) main::sc#7 11.0
(byte) main::x
(byte) main::x#1 151.5
(byte) main::x#2 25.25
(byte) main::y
(byte) main::y#1 16.5
(byte) main::y#2 2.5384615384615383

Initial phi equivalence classes
[ main::y#2 main::y#1 ]
[ main::bits#2 main::bits#0 main::bits#1 ]
[ main::sc#3 main::sc#7 main::sc#2 main::sc#1 ]
[ main::x#2 main::x#1 ]
[ main::c#2 ]
Added variable main::$1 to live range equivalence class [ main::$1 ]
Complete equivalence classes
[ main::y#2 main::y#1 ]
[ main::bits#2 main::bits#0 main::bits#1 ]
[ main::sc#3 main::sc#7 main::sc#2 main::sc#1 ]
[ main::x#2 main::x#1 ]
[ main::c#2 ]
[ main::$1 ]
Allocated zp[1]:2 [ main::y#2 main::y#1 ]
Allocated zp[1]:3 [ main::bits#2 main::bits#0 main::bits#1 ]
Allocated zp[2]:4 [ main::sc#3 main::sc#7 main::sc#2 main::sc#1 ]
Allocated zp[1]:6 [ main::x#2 main::x#1 ]
Allocated zp[1]:7 [ main::c#2 ]
Allocated zp[1]:8 [ main::$1 ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label PROCPORT = 1
  .label CHARGEN = $d000
  .label SCREEN = $400
  // @begin
__bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
  jmp __b1
  // @1
__b1:
  // [2] call main 
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
  jmp __bend
  // @end
__bend:
  // main
main: {
    .label CHAR_A = CHARGEN+8
    .label __1 = 8
    .label bits = 3
    .label sc = 4
    .label x = 6
    .label y = 2
    .label c = 7
    // asm { sei  }
    sei
    // [5] *((const byte*) PROCPORT) ← (byte) $32 -- _deref_pbuc1=vbuc2 
    lda #$32
    sta PROCPORT
    // [6] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [6] phi (byte*) main::sc#7 = (const byte*) SCREEN [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<SCREEN
    sta.z sc
    lda #>SCREEN
    sta.z sc+1
    // [6] phi (byte) main::y#2 = (byte) 0 [phi:main->main::@1#1] -- vbuz1=vbuc1 
    lda #0
    sta.z y
    jmp __b1
    // [6] phi from main::@5 to main::@1 [phi:main::@5->main::@1]
  __b1_from___b5:
    // [6] phi (byte*) main::sc#7 = (byte*) main::sc#2 [phi:main::@5->main::@1#0] -- register_copy 
    // [6] phi (byte) main::y#2 = (byte) main::y#1 [phi:main::@5->main::@1#1] -- register_copy 
    jmp __b1
    // main::@1
  __b1:
    // [7] (byte) main::bits#0 ← *((const byte*) main::CHAR_A#0 + (byte) main::y#2) -- vbuz1=pbuc1_derefidx_vbuz2 
    ldy.z y
    lda CHAR_A,y
    sta.z bits
    // [8] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  __b2_from___b1:
    // [8] phi (byte) main::x#2 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuz1=vbuc1 
    lda #0
    sta.z x
    // [8] phi (byte*) main::sc#3 = (byte*) main::sc#7 [phi:main::@1->main::@2#1] -- register_copy 
    // [8] phi (byte) main::bits#2 = (byte) main::bits#0 [phi:main::@1->main::@2#2] -- register_copy 
    jmp __b2
    // [8] phi from main::@3 to main::@2 [phi:main::@3->main::@2]
  __b2_from___b3:
    // [8] phi (byte) main::x#2 = (byte) main::x#1 [phi:main::@3->main::@2#0] -- register_copy 
    // [8] phi (byte*) main::sc#3 = (byte*) main::sc#1 [phi:main::@3->main::@2#1] -- register_copy 
    // [8] phi (byte) main::bits#2 = (byte) main::bits#1 [phi:main::@3->main::@2#2] -- register_copy 
    jmp __b2
    // main::@2
  __b2:
    // [9] (byte~) main::$1 ← (byte) main::bits#2 & (byte) $80 -- vbuz1=vbuz2_band_vbuc1 
    lda #$80
    and.z bits
    sta.z __1
    // [10] if((byte~) main::$1==(byte) 0) goto main::@3 -- vbuz1_eq_0_then_la1 
    lda.z __1
    cmp #0
    beq __b3_from___b2
    // [11] phi from main::@2 to main::@4 [phi:main::@2->main::@4]
  __b4_from___b2:
    jmp __b4
    // main::@4
  __b4:
    // [12] phi from main::@4 to main::@3 [phi:main::@4->main::@3]
  __b3_from___b4:
    // [12] phi (byte) main::c#2 = (byte) '*' [phi:main::@4->main::@3#0] -- vbuz1=vbuc1 
    lda #'*'
    sta.z c
    jmp __b3
    // [12] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
  __b3_from___b2:
    // [12] phi (byte) main::c#2 = (byte) '.' [phi:main::@2->main::@3#0] -- vbuz1=vbuc1 
    lda #'.'
    sta.z c
    jmp __b3
    // main::@3
  __b3:
    // [13] *((byte*) main::sc#3) ← (byte) main::c#2 -- _deref_pbuz1=vbuz2 
    lda.z c
    ldy #0
    sta (sc),y
    // [14] (byte*) main::sc#1 ← ++ (byte*) main::sc#3 -- pbuz1=_inc_pbuz1 
    inc.z sc
    bne !+
    inc.z sc+1
  !:
    // [15] (byte) main::bits#1 ← (byte) main::bits#2 << (byte) 1 -- vbuz1=vbuz1_rol_1 
    asl.z bits
    // [16] (byte) main::x#1 ← ++ (byte) main::x#2 -- vbuz1=_inc_vbuz1 
    inc.z x
    // [17] if((byte) main::x#1!=(byte) 8) goto main::@2 -- vbuz1_neq_vbuc1_then_la1 
    lda #8
    cmp.z x
    bne __b2_from___b3
    jmp __b5
    // main::@5
  __b5:
    // [18] (byte*) main::sc#2 ← (byte*) main::sc#1 + (byte) $20 -- pbuz1=pbuz1_plus_vbuc1 
    lda #$20
    clc
    adc.z sc
    sta.z sc
    bcc !+
    inc.z sc+1
  !:
    // [19] (byte) main::y#1 ← ++ (byte) main::y#2 -- vbuz1=_inc_vbuz1 
    inc.z y
    // [20] if((byte) main::y#1!=(byte) 8) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #8
    cmp.z y
    bne __b1_from___b5
    jmp __b6
    // main::@6
  __b6:
    // [21] *((const byte*) PROCPORT) ← (byte) $37 -- _deref_pbuc1=vbuc2 
    lda #$37
    sta PROCPORT
    // asm { cli  }
    cli
    jmp __breturn
    // main::@return
  __breturn:
    // [23] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [5] *((const byte*) PROCPORT) ← (byte) $32 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [13] *((byte*) main::sc#3) ← (byte) main::c#2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ) always clobbers reg byte y 
Removing always clobbered register reg byte y as potential for zp[1]:2 [ main::y#2 main::y#1 ]
Removing always clobbered register reg byte y as potential for zp[1]:3 [ main::bits#2 main::bits#0 main::bits#1 ]
Removing always clobbered register reg byte y as potential for zp[1]:6 [ main::x#2 main::x#1 ]
Statement [18] (byte*) main::sc#2 ← (byte*) main::sc#1 + (byte) $20 [ main::y#2 main::sc#2 ] ( main:2 [ main::y#2 main::sc#2 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::y#2 main::y#1 ]
Statement [21] *((const byte*) PROCPORT) ← (byte) $37 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [5] *((const byte*) PROCPORT) ← (byte) $32 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [13] *((byte*) main::sc#3) ← (byte) main::c#2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ( main:2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] ) always clobbers reg byte y 
Statement [18] (byte*) main::sc#2 ← (byte*) main::sc#1 + (byte) $20 [ main::y#2 main::sc#2 ] ( main:2 [ main::y#2 main::sc#2 ] ) always clobbers reg byte a 
Statement [21] *((const byte*) PROCPORT) ← (byte) $37 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Potential registers zp[1]:2 [ main::y#2 main::y#1 ] : zp[1]:2 , reg byte x , 
Potential registers zp[1]:3 [ main::bits#2 main::bits#0 main::bits#1 ] : zp[1]:3 , reg byte a , reg byte x , 
Potential registers zp[2]:4 [ main::sc#3 main::sc#7 main::sc#2 main::sc#1 ] : zp[2]:4 , 
Potential registers zp[1]:6 [ main::x#2 main::x#1 ] : zp[1]:6 , reg byte a , reg byte x , 
Potential registers zp[1]:7 [ main::c#2 ] : zp[1]:7 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:8 [ main::$1 ] : zp[1]:8 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 202: zp[1]:8 [ main::$1 ] 176.75: zp[1]:6 [ main::x#2 main::x#1 ] 134.19: zp[1]:3 [ main::bits#2 main::bits#0 main::bits#1 ] 123.92: zp[2]:4 [ main::sc#3 main::sc#7 main::sc#2 main::sc#1 ] 101: zp[1]:7 [ main::c#2 ] 19.04: zp[1]:2 [ main::y#2 main::y#1 ] 
Uplift Scope [] 

Uplifting [main] best 7232 combination reg byte a [ main::$1 ] reg byte x [ main::x#2 main::x#1 ] zp[1]:3 [ main::bits#2 main::bits#0 main::bits#1 ] zp[2]:4 [ main::sc#3 main::sc#7 main::sc#2 main::sc#1 ] reg byte a [ main::c#2 ] zp[1]:2 [ main::y#2 main::y#1 ] 
Limited combination testing to 100 combinations of 288 possible.
Uplifting [] best 7232 combination 
Attempting to uplift remaining variables inzp[1]:3 [ main::bits#2 main::bits#0 main::bits#1 ]
Uplifting [main] best 7232 combination zp[1]:3 [ main::bits#2 main::bits#0 main::bits#1 ] 
Attempting to uplift remaining variables inzp[1]:2 [ main::y#2 main::y#1 ]
Uplifting [main] best 7232 combination zp[1]:2 [ main::y#2 main::y#1 ] 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label PROCPORT = 1
  .label CHARGEN = $d000
  .label SCREEN = $400
  // @begin
__bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
  jmp __b1
  // @1
__b1:
  // [2] call main 
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
  jmp __bend
  // @end
__bend:
  // main
main: {
    .label CHAR_A = CHARGEN+8
    .label bits = 3
    .label sc = 4
    .label y = 2
    // asm { sei  }
    sei
    // [5] *((const byte*) PROCPORT) ← (byte) $32 -- _deref_pbuc1=vbuc2 
    lda #$32
    sta PROCPORT
    // [6] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [6] phi (byte*) main::sc#7 = (const byte*) SCREEN [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<SCREEN
    sta.z sc
    lda #>SCREEN
    sta.z sc+1
    // [6] phi (byte) main::y#2 = (byte) 0 [phi:main->main::@1#1] -- vbuz1=vbuc1 
    lda #0
    sta.z y
    jmp __b1
    // [6] phi from main::@5 to main::@1 [phi:main::@5->main::@1]
  __b1_from___b5:
    // [6] phi (byte*) main::sc#7 = (byte*) main::sc#2 [phi:main::@5->main::@1#0] -- register_copy 
    // [6] phi (byte) main::y#2 = (byte) main::y#1 [phi:main::@5->main::@1#1] -- register_copy 
    jmp __b1
    // main::@1
  __b1:
    // [7] (byte) main::bits#0 ← *((const byte*) main::CHAR_A#0 + (byte) main::y#2) -- vbuz1=pbuc1_derefidx_vbuz2 
    ldy.z y
    lda CHAR_A,y
    sta.z bits
    // [8] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  __b2_from___b1:
    // [8] phi (byte) main::x#2 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuxx=vbuc1 
    ldx #0
    // [8] phi (byte*) main::sc#3 = (byte*) main::sc#7 [phi:main::@1->main::@2#1] -- register_copy 
    // [8] phi (byte) main::bits#2 = (byte) main::bits#0 [phi:main::@1->main::@2#2] -- register_copy 
    jmp __b2
    // [8] phi from main::@3 to main::@2 [phi:main::@3->main::@2]
  __b2_from___b3:
    // [8] phi (byte) main::x#2 = (byte) main::x#1 [phi:main::@3->main::@2#0] -- register_copy 
    // [8] phi (byte*) main::sc#3 = (byte*) main::sc#1 [phi:main::@3->main::@2#1] -- register_copy 
    // [8] phi (byte) main::bits#2 = (byte) main::bits#1 [phi:main::@3->main::@2#2] -- register_copy 
    jmp __b2
    // main::@2
  __b2:
    // [9] (byte~) main::$1 ← (byte) main::bits#2 & (byte) $80 -- vbuaa=vbuz1_band_vbuc1 
    lda #$80
    and.z bits
    // [10] if((byte~) main::$1==(byte) 0) goto main::@3 -- vbuaa_eq_0_then_la1 
    cmp #0
    beq __b3_from___b2
    // [11] phi from main::@2 to main::@4 [phi:main::@2->main::@4]
  __b4_from___b2:
    jmp __b4
    // main::@4
  __b4:
    // [12] phi from main::@4 to main::@3 [phi:main::@4->main::@3]
  __b3_from___b4:
    // [12] phi (byte) main::c#2 = (byte) '*' [phi:main::@4->main::@3#0] -- vbuaa=vbuc1 
    lda #'*'
    jmp __b3
    // [12] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
  __b3_from___b2:
    // [12] phi (byte) main::c#2 = (byte) '.' [phi:main::@2->main::@3#0] -- vbuaa=vbuc1 
    lda #'.'
    jmp __b3
    // main::@3
  __b3:
    // [13] *((byte*) main::sc#3) ← (byte) main::c#2 -- _deref_pbuz1=vbuaa 
    ldy #0
    sta (sc),y
    // [14] (byte*) main::sc#1 ← ++ (byte*) main::sc#3 -- pbuz1=_inc_pbuz1 
    inc.z sc
    bne !+
    inc.z sc+1
  !:
    // [15] (byte) main::bits#1 ← (byte) main::bits#2 << (byte) 1 -- vbuz1=vbuz1_rol_1 
    asl.z bits
    // [16] (byte) main::x#1 ← ++ (byte) main::x#2 -- vbuxx=_inc_vbuxx 
    inx
    // [17] if((byte) main::x#1!=(byte) 8) goto main::@2 -- vbuxx_neq_vbuc1_then_la1 
    cpx #8
    bne __b2_from___b3
    jmp __b5
    // main::@5
  __b5:
    // [18] (byte*) main::sc#2 ← (byte*) main::sc#1 + (byte) $20 -- pbuz1=pbuz1_plus_vbuc1 
    lda #$20
    clc
    adc.z sc
    sta.z sc
    bcc !+
    inc.z sc+1
  !:
    // [19] (byte) main::y#1 ← ++ (byte) main::y#2 -- vbuz1=_inc_vbuz1 
    inc.z y
    // [20] if((byte) main::y#1!=(byte) 8) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #8
    cmp.z y
    bne __b1_from___b5
    jmp __b6
    // main::@6
  __b6:
    // [21] *((const byte*) PROCPORT) ← (byte) $37 -- _deref_pbuc1=vbuc2 
    lda #$37
    sta PROCPORT
    // asm { cli  }
    cli
    jmp __breturn
    // main::@return
  __breturn:
    // [23] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __b4
Removing instruction jmp __b3
Removing instruction jmp __b5
Removing instruction jmp __b6
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __bbegin with __b1
Replacing label __b2_from___b3 with __b2
Replacing label __b1_from___b5 with __b1
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction __bend_from___b1:
Removing instruction __b1_from___b5:
Removing instruction __b2_from___b3:
Removing instruction __b4_from___b2:
Removing instruction __b3_from___b4:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __b1_from_main:
Removing instruction __b2_from___b1:
Removing instruction __b4:
Removing instruction __b5:
Removing instruction __b6:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Relabelling long label __b3_from___b2 to b1
Succesful ASM optimization Pass5RelabelLongLabels
Removing instruction jmp __b1
Removing instruction jmp __b2
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(const byte*) CHARGEN = (byte*) 53248
(const byte*) PROCPORT = (byte*) 1
(const byte*) SCREEN = (byte*) 1024
(void()) main()
(byte~) main::$1 reg byte a 202.0
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@return
(byte*) main::CHAR_A
(const byte*) main::CHAR_A#0 CHAR_A = (const byte*) CHARGEN+(byte) 8
(byte) main::bits
(byte) main::bits#0 bits zp[1]:3 22.0
(byte) main::bits#1 bits zp[1]:3 67.33333333333333
(byte) main::bits#2 bits zp[1]:3 44.85714285714286
(byte) main::c
(byte) main::c#2 reg byte a 101.0
(byte*) main::sc
(byte*) main::sc#1 sc zp[2]:4 53.25
(byte*) main::sc#2 sc zp[2]:4 7.333333333333333
(byte*) main::sc#3 sc zp[2]:4 52.33333333333333
(byte*) main::sc#7 sc zp[2]:4 11.0
(byte) main::x
(byte) main::x#1 reg byte x 151.5
(byte) main::x#2 reg byte x 25.25
(byte) main::y
(byte) main::y#1 y zp[1]:2 16.5
(byte) main::y#2 y zp[1]:2 2.5384615384615383

zp[1]:2 [ main::y#2 main::y#1 ]
zp[1]:3 [ main::bits#2 main::bits#0 main::bits#1 ]
zp[2]:4 [ main::sc#3 main::sc#7 main::sc#2 main::sc#1 ]
reg byte x [ main::x#2 main::x#1 ]
reg byte a [ main::c#2 ]
reg byte a [ main::$1 ]


FINAL ASSEMBLER
Score: 5627

  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .label PROCPORT = 1
  .label CHARGEN = $d000
  .label SCREEN = $400
  // @begin
  // [1] phi from @begin to @1 [phi:@begin->@1]
  // @1
  // [2] call main 
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    .label CHAR_A = CHARGEN+8
    .label bits = 3
    .label sc = 4
    .label y = 2
    // asm
    // asm { sei  }
    sei
    // *PROCPORT = $32
    // [5] *((const byte*) PROCPORT) ← (byte) $32 -- _deref_pbuc1=vbuc2 
    lda #$32
    sta PROCPORT
    // [6] phi from main to main::@1 [phi:main->main::@1]
    // [6] phi (byte*) main::sc#7 = (const byte*) SCREEN [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<SCREEN
    sta.z sc
    lda #>SCREEN
    sta.z sc+1
    // [6] phi (byte) main::y#2 = (byte) 0 [phi:main->main::@1#1] -- vbuz1=vbuc1 
    lda #0
    sta.z y
    // [6] phi from main::@5 to main::@1 [phi:main::@5->main::@1]
    // [6] phi (byte*) main::sc#7 = (byte*) main::sc#2 [phi:main::@5->main::@1#0] -- register_copy 
    // [6] phi (byte) main::y#2 = (byte) main::y#1 [phi:main::@5->main::@1#1] -- register_copy 
    // main::@1
  __b1:
    // bits = CHAR_A[y]
    // [7] (byte) main::bits#0 ← *((const byte*) main::CHAR_A#0 + (byte) main::y#2) -- vbuz1=pbuc1_derefidx_vbuz2 
    ldy.z y
    lda CHAR_A,y
    sta.z bits
    // [8] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
    // [8] phi (byte) main::x#2 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuxx=vbuc1 
    ldx #0
    // [8] phi (byte*) main::sc#3 = (byte*) main::sc#7 [phi:main::@1->main::@2#1] -- register_copy 
    // [8] phi (byte) main::bits#2 = (byte) main::bits#0 [phi:main::@1->main::@2#2] -- register_copy 
    // [8] phi from main::@3 to main::@2 [phi:main::@3->main::@2]
    // [8] phi (byte) main::x#2 = (byte) main::x#1 [phi:main::@3->main::@2#0] -- register_copy 
    // [8] phi (byte*) main::sc#3 = (byte*) main::sc#1 [phi:main::@3->main::@2#1] -- register_copy 
    // [8] phi (byte) main::bits#2 = (byte) main::bits#1 [phi:main::@3->main::@2#2] -- register_copy 
    // main::@2
  __b2:
    // bits & $80
    // [9] (byte~) main::$1 ← (byte) main::bits#2 & (byte) $80 -- vbuaa=vbuz1_band_vbuc1 
    lda #$80
    and.z bits
    // if((bits & $80) != 0)
    // [10] if((byte~) main::$1==(byte) 0) goto main::@3 -- vbuaa_eq_0_then_la1 
    cmp #0
    beq b1
    // [11] phi from main::@2 to main::@4 [phi:main::@2->main::@4]
    // main::@4
    // [12] phi from main::@4 to main::@3 [phi:main::@4->main::@3]
    // [12] phi (byte) main::c#2 = (byte) '*' [phi:main::@4->main::@3#0] -- vbuaa=vbuc1 
    lda #'*'
    jmp __b3
    // [12] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
  b1:
    // [12] phi (byte) main::c#2 = (byte) '.' [phi:main::@2->main::@3#0] -- vbuaa=vbuc1 
    lda #'.'
    // main::@3
  __b3:
    // *sc = c
    // [13] *((byte*) main::sc#3) ← (byte) main::c#2 -- _deref_pbuz1=vbuaa 
    ldy #0
    sta (sc),y
    // sc++;
    // [14] (byte*) main::sc#1 ← ++ (byte*) main::sc#3 -- pbuz1=_inc_pbuz1 
    inc.z sc
    bne !+
    inc.z sc+1
  !:
    // bits = bits*2
    // [15] (byte) main::bits#1 ← (byte) main::bits#2 << (byte) 1 -- vbuz1=vbuz1_rol_1 
    asl.z bits
    // for(byte x:0..7)
    // [16] (byte) main::x#1 ← ++ (byte) main::x#2 -- vbuxx=_inc_vbuxx 
    inx
    // [17] if((byte) main::x#1!=(byte) 8) goto main::@2 -- vbuxx_neq_vbuc1_then_la1 
    cpx #8
    bne __b2
    // main::@5
    // sc = sc+32
    // [18] (byte*) main::sc#2 ← (byte*) main::sc#1 + (byte) $20 -- pbuz1=pbuz1_plus_vbuc1 
    lda #$20
    clc
    adc.z sc
    sta.z sc
    bcc !+
    inc.z sc+1
  !:
    // for(byte y:0..7)
    // [19] (byte) main::y#1 ← ++ (byte) main::y#2 -- vbuz1=_inc_vbuz1 
    inc.z y
    // [20] if((byte) main::y#1!=(byte) 8) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #8
    cmp.z y
    bne __b1
    // main::@6
    // *PROCPORT = $37
    // [21] *((const byte*) PROCPORT) ← (byte) $37 -- _deref_pbuc1=vbuc2 
    lda #$37
    sta PROCPORT
    // asm
    // asm { cli  }
    cli
    // main::@return
    // }
    // [23] return 
    rts
}
  // File Data

