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

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) PROCPORT#0 ← ((byte*)) (number) 1
  (byte*) CHARGEN#0 ← ((byte*)) (number) $d000
  (byte*) SCREEN#0 ← ((byte*)) (number) $400
  to:@1
main: scope:[main]  from @1
  asm { sei  }
  (byte*~) main::$0 ← (byte*) CHARGEN#0 + (number) 8
  (byte*) main::CHAR_A#0 ← (byte*~) main::$0
  *((byte*) PROCPORT#0) ← (number) $32
  (byte*) main::sc#0 ← (byte*) SCREEN#0
  (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
  *((byte*) PROCPORT#0) ← (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
(byte*) CHARGEN
(byte*) CHARGEN#0
(byte*) PROCPORT
(byte*) PROCPORT#0
(byte*) SCREEN
(byte*) SCREEN#0
(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 ← (byte*) CHARGEN#0 + (number) 8
Adding number conversion cast (unumber) $32 in *((byte*) PROCPORT#0) ← (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 *((byte*) PROCPORT#0) ← (number) $37
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) PROCPORT#0 ← (byte*)(number) 1
Inlining cast (byte*) CHARGEN#0 ← (byte*)(number) $d000
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
Inlining cast *((byte*) PROCPORT#0) ← (unumber)(number) $32
Inlining cast *((byte*) PROCPORT#0) ← (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 [16] (bool~) main::$3 ← (byte~) main::$1 == (byte) 0 from [15] (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 [17] if((byte~) main::$1==(byte) 0) goto main::@3
Simple Condition (bool~) main::$5 [25] if((byte) main::x#1!=rangelast(0,7)) goto main::@2
Simple Condition (bool~) main::$7 [33] if((byte) main::y#1!=rangelast(0,7)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) PROCPORT#0 = (byte*) 1
Constant (const byte*) CHARGEN#0 = (byte*) 53248
Constant (const byte*) SCREEN#0 = (byte*) 1024
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
Constant (const byte*) main::sc#0 = SCREEN#0
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [23] main::x#1 ← ++ main::x#2 to ++
Resolved ranged comparison value [25] if(main::x#1!=rangelast(0,7)) goto main::@2 to (number) 8
Resolved ranged next value [31] main::y#1 ← ++ main::y#2 to ++
Resolved ranged comparison value [33] 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
Constant right-side identified [1] (byte*) main::CHAR_A#0 ← (const byte*) CHARGEN#0 + (byte) 8
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) main::CHAR_A#0 = CHARGEN#0+8
Successful SSA optimization Pass2ConstantIdentification
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::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
Inlining constant with var siblings (const byte*) main::sc#0
Constant inlined main::sc#0 = (const byte*) SCREEN#0
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()
main: scope:[main]  from @1
  asm { sei  }
  [5] *((const byte*) PROCPORT#0) ← (byte) $32
  to:main::@1
main::@1: scope:[main]  from main main::@5
  [6] (byte*) main::sc#7 ← phi( main/(const byte*) SCREEN#0 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#0) ← (byte) $37
  asm { cli  }
  to:main::@return
main::@return: scope:[main]  from main::@6
  [23] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte*) CHARGEN
(byte*) PROCPORT
(byte*) SCREEN
(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 zero page 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 ZP_BYTE:2 [ main::y#2 main::y#1 ]
Allocated zp ZP_BYTE:3 [ main::bits#2 main::bits#0 main::bits#1 ]
Allocated zp ZP_WORD:4 [ main::sc#3 main::sc#7 main::sc#2 main::sc#1 ]
Allocated zp ZP_BYTE:6 [ main::x#2 main::x#1 ]
Allocated zp ZP_BYTE:7 [ main::c#2 ]
Allocated zp ZP_BYTE:8 [ main::$1 ]

INITIAL ASM
Target platform is c64basic
  // 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#0) ← (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#0 [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#0) ← (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#0) ← (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 ZP_BYTE:2 [ main::y#2 main::y#1 ]
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:3 [ main::bits#2 main::bits#0 main::bits#1 ]
Removing always clobbered register reg byte y as potential for zp ZP_BYTE: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 ZP_BYTE:2 [ main::y#2 main::y#1 ]
Statement [21] *((const byte*) PROCPORT#0) ← (byte) $37 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [5] *((const byte*) PROCPORT#0) ← (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#0) ← (byte) $37 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Potential registers zp ZP_BYTE:2 [ main::y#2 main::y#1 ] : zp ZP_BYTE:2 , reg byte x , 
Potential registers zp ZP_BYTE:3 [ main::bits#2 main::bits#0 main::bits#1 ] : zp ZP_BYTE:3 , reg byte a , reg byte x , 
Potential registers zp ZP_WORD:4 [ main::sc#3 main::sc#7 main::sc#2 main::sc#1 ] : zp ZP_WORD:4 , 
Potential registers zp ZP_BYTE:6 [ main::x#2 main::x#1 ] : zp ZP_BYTE:6 , reg byte a , reg byte x , 
Potential registers zp ZP_BYTE:7 [ main::c#2 ] : zp ZP_BYTE:7 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:8 [ main::$1 ] : zp ZP_BYTE:8 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 202: zp ZP_BYTE:8 [ main::$1 ] 176.75: zp ZP_BYTE:6 [ main::x#2 main::x#1 ] 134.19: zp ZP_BYTE:3 [ main::bits#2 main::bits#0 main::bits#1 ] 123.92: zp ZP_WORD:4 [ main::sc#3 main::sc#7 main::sc#2 main::sc#1 ] 101: zp ZP_BYTE:7 [ main::c#2 ] 19.04: zp ZP_BYTE: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 ZP_BYTE:3 [ main::bits#2 main::bits#0 main::bits#1 ] zp ZP_WORD:4 [ main::sc#3 main::sc#7 main::sc#2 main::sc#1 ] reg byte a [ main::c#2 ] zp ZP_BYTE: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 ZP_BYTE:3 [ main::bits#2 main::bits#0 main::bits#1 ]
Uplifting [main] best 7232 combination zp ZP_BYTE:3 [ main::bits#2 main::bits#0 main::bits#1 ] 
Attempting to uplift remaining variables inzp ZP_BYTE:2 [ main::y#2 main::y#1 ]
Uplifting [main] best 7232 combination zp ZP_BYTE: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#0) ← (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#0 [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#0) ← (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 b2_from_b3 with b2
Replacing label b1_from_b5 with b1
Removing instruction b1_from_bbegin:
Removing instruction b1:
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 b4
Succesful ASM optimization Pass5RelabelLongLabels
Removing instruction jmp b1
Removing instruction jmp b2
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte*) CHARGEN
(const byte*) CHARGEN#0 CHARGEN = (byte*) 53248
(byte*) PROCPORT
(const byte*) PROCPORT#0 PROCPORT = (byte*) 1
(byte*) SCREEN
(const byte*) SCREEN#0 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#0+(byte) 8
(byte) main::bits
(byte) main::bits#0 bits zp ZP_BYTE:3 22.0
(byte) main::bits#1 bits zp ZP_BYTE:3 67.33333333333333
(byte) main::bits#2 bits zp ZP_BYTE:3 44.85714285714286
(byte) main::c
(byte) main::c#2 reg byte a 101.0
(byte*) main::sc
(byte*) main::sc#1 sc zp ZP_WORD:4 53.25
(byte*) main::sc#2 sc zp ZP_WORD:4 7.333333333333333
(byte*) main::sc#3 sc zp ZP_WORD:4 52.33333333333333
(byte*) main::sc#7 sc zp ZP_WORD: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 ZP_BYTE:2 16.5
(byte) main::y#2 y zp ZP_BYTE:2 2.5384615384615383

zp ZP_BYTE:2 [ main::y#2 main::y#1 ]
zp ZP_BYTE:3 [ main::bits#2 main::bits#0 main::bits#1 ]
zp ZP_WORD: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#0) ← (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#0 [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 b4
    // [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]
  b4:
    // [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#0) ← (byte) $37 -- _deref_pbuc1=vbuc2 
    lda #$37
    sta PROCPORT
    // asm
    // asm { cli  }
    cli
    // main::@return
    // }
    // [23] return 
    rts
}
  // File Data

