Inlined call call __init
Eliminating unused variable with no statement main::$0

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start::@1
  asm { sei  }
  main::CHAR_A#0 = CHARGEN + 8
  *PROCPORT = $32
  main::sc#0 = SCREEN
  main::y#0 = 0
  to:main::@1
main::@1: scope:[main]  from main main::@5
  main::sc#7 = phi( main/main::sc#0, main::@5/main::sc#2 )
  main::y#2 = phi( main/main::y#0, main::@5/main::y#1 )
  main::CHAR_A#1 = phi( main/main::CHAR_A#0, main::@5/main::CHAR_A#2 )
  main::bits#0 = main::CHAR_A#1[main::y#2]
  main::x#0 = 0
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@3
  main::CHAR_A#4 = phi( main::@1/main::CHAR_A#1, main::@3/main::CHAR_A#3 )
  main::y#5 = phi( main::@1/main::y#2, main::@3/main::y#4 )
  main::x#3 = phi( main::@1/main::x#0, main::@3/main::x#1 )
  main::sc#5 = phi( main::@1/main::sc#7, main::@3/main::sc#1 )
  main::bits#2 = phi( main::@1/main::bits#0, main::@3/main::bits#1 )
  main::c#0 = '.'
  main::$1 = main::bits#2 & $80
  main::$2 = main::$1 != 0
  main::$3 = ! main::$2
  if(main::$3) goto main::@3
  to:main::@4
main::@3: scope:[main]  from main::@2 main::@4
  main::CHAR_A#3 = phi( main::@2/main::CHAR_A#4, main::@4/main::CHAR_A#5 )
  main::y#4 = phi( main::@2/main::y#5, main::@4/main::y#6 )
  main::x#2 = phi( main::@2/main::x#3, main::@4/main::x#4 )
  main::bits#3 = phi( main::@2/main::bits#2, main::@4/main::bits#4 )
  main::sc#3 = phi( main::@2/main::sc#5, main::@4/main::sc#6 )
  main::c#2 = phi( main::@2/main::c#0, main::@4/main::c#1 )
  *main::sc#3 = main::c#2
  main::sc#1 = ++ main::sc#3
  main::$4 = main::bits#3 * 2
  main::bits#1 = main::$4
  main::x#1 = main::x#2 + rangenext(0,7)
  main::$5 = main::x#1 != rangelast(0,7)
  if(main::$5) goto main::@2
  to:main::@5
main::@4: scope:[main]  from main::@2
  main::CHAR_A#5 = phi( main::@2/main::CHAR_A#4 )
  main::y#6 = phi( main::@2/main::y#5 )
  main::x#4 = phi( main::@2/main::x#3 )
  main::bits#4 = phi( main::@2/main::bits#2 )
  main::sc#6 = phi( main::@2/main::sc#5 )
  main::c#1 = '*'
  to:main::@3
main::@5: scope:[main]  from main::@3
  main::CHAR_A#2 = phi( main::@3/main::CHAR_A#3 )
  main::y#3 = phi( main::@3/main::y#4 )
  main::sc#4 = phi( main::@3/main::sc#1 )
  main::$6 = main::sc#4 + $20
  main::sc#2 = main::$6
  main::y#1 = main::y#3 + rangenext(0,7)
  main::$7 = main::y#1 != rangelast(0,7)
  if(main::$7) goto main::@1
  to:main::@6
main::@6: scope:[main]  from main::@5
  *PROCPORT = $37
  asm { cli  }
  to:main::@return
main::@return: scope:[main]  from main::@6
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  to:__start::__init1
__start::__init1: scope:[__start]  from __start
  to:__start::@1
__start::@1: scope:[__start]  from __start::__init1
  call main
  to:__start::@2
__start::@2: scope:[__start]  from __start::@1
  to:__start::@return
__start::@return: scope:[__start]  from __start::@2
  return 
  to:@return

SYMBOL TABLE SSA
__constant char *CHARGEN = (char *)$d000
__constant char *PROCPORT = (char *)1
__constant char *SCREEN = (char *)$400
void __start()
void main()
number main::$1
bool main::$2
bool main::$3
number main::$4
bool main::$5
char *main::$6
bool main::$7
char *main::CHAR_A
char *main::CHAR_A#0
char *main::CHAR_A#1
char *main::CHAR_A#2
char *main::CHAR_A#3
char *main::CHAR_A#4
char *main::CHAR_A#5
char main::bits
char main::bits#0
char main::bits#1
char main::bits#2
char main::bits#3
char main::bits#4
char main::c
char main::c#0
char main::c#1
char main::c#2
char *main::sc
char *main::sc#0
char *main::sc#1
char *main::sc#2
char *main::sc#3
char *main::sc#4
char *main::sc#5
char *main::sc#6
char *main::sc#7
char main::x
char main::x#0
char main::x#1
char main::x#2
char main::x#3
char main::x#4
char main::y
char main::y#0
char main::y#1
char main::y#2
char main::y#3
char main::y#4
char main::y#5
char main::y#6

Adding number conversion cast (unumber) 8 in main::CHAR_A#0 = CHARGEN + 8
Adding number conversion cast (unumber) $32 in *PROCPORT = $32
Adding number conversion cast (unumber) $80 in main::$1 = main::bits#2 & $80
Adding number conversion cast (unumber) main::$1 in main::$1 = main::bits#2 & (unumber)$80
Adding number conversion cast (unumber) 0 in main::$2 = main::$1 != 0
Adding number conversion cast (unumber) 2 in main::$4 = main::bits#3 * 2
Adding number conversion cast (unumber) main::$4 in main::$4 = main::bits#3 * (unumber)2
Adding number conversion cast (unumber) $20 in main::$6 = main::sc#4 + $20
Adding number conversion cast (unumber) $37 in *PROCPORT = $37
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast *PROCPORT = (unumber)$32
Inlining cast *PROCPORT = (unumber)$37
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (char *) 1
Simplifying constant pointer cast (char *) 53248
Simplifying constant pointer cast (char *) 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 (char) 8
Finalized unsigned number type (char) $32
Finalized unsigned number type (char) $80
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 2
Finalized unsigned number type (char) $20
Finalized unsigned number type (char) $37
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to char in main::$1 = main::bits#2 & $80
Inferred type updated to char in main::$4 = main::bits#3 * 2
Inversing boolean not [12] main::$3 = main::$1 == 0 from [11] main::$2 = main::$1 != 0
Successful SSA optimization Pass2UnaryNotSimplification
Alias main::bits#1 = main::$4 
Alias main::sc#5 = main::sc#6 
Alias main::bits#2 = main::bits#4 
Alias main::x#3 = main::x#4 
Alias main::y#5 = main::y#6 
Alias main::CHAR_A#4 = main::CHAR_A#5 
Alias main::sc#1 = main::sc#4 
Alias main::y#3 = main::y#4 
Alias main::CHAR_A#2 = main::CHAR_A#3 
Alias main::sc#2 = main::$6 
Successful SSA optimization Pass2AliasElimination
Alias main::sc#3 = main::sc#5 
Alias main::bits#2 = main::bits#3 
Alias main::x#2 = main::x#3 
Alias main::y#3 = main::y#5 
Alias main::CHAR_A#2 = main::CHAR_A#4 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values main::y#3 main::y#2
Identical Phi Values main::CHAR_A#2 main::CHAR_A#1
Successful SSA optimization Pass2IdenticalPhiElimination
Identical Phi Values main::CHAR_A#1 main::CHAR_A#0
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition main::$3 [12] if(main::$1==0) goto main::@3
Simple Condition main::$5 [19] if(main::x#1!=rangelast(0,7)) goto main::@2
Simple Condition main::$7 [24] if(main::y#1!=rangelast(0,7)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant right-side identified [1] main::CHAR_A#0 = CHARGEN + 8
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::CHAR_A#0 = CHARGEN+8
Constant main::sc#0 = SCREEN
Constant main::y#0 = 0
Constant main::x#0 = 0
Constant main::c#0 = '.'
Constant main::c#1 = '*'
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [17] main::x#1 = ++ main::x#2 to ++
Resolved ranged comparison value [19] if(main::x#1!=rangelast(0,7)) goto main::@2 to 8
Resolved ranged next value [22] main::y#1 = ++ main::y#2 to ++
Resolved ranged comparison value [24] if(main::y#1!=rangelast(0,7)) goto main::@1 to 8
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::__init1
Removing unused procedure block __start::@1
Removing unused procedure block __start::@2
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Adding number conversion cast (unumber) 8 in [12] if(main::x#1!=8) goto main::@2
Adding number conversion cast (unumber) 8 in [15] if(main::y#1!=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 (char) 8
Finalized unsigned number type (char) 8
Successful SSA optimization PassNFinalizeNumberTypeConversions
Rewriting multiplication to use shift [10] main::bits#1 = main::bits#2 * 2
Successful SSA optimization Pass2MultiplyToShiftRewriting
Inlining constant with var siblings main::sc#0
Inlining constant with var siblings main::y#0
Inlining constant with var siblings main::x#0
Inlining constant with var siblings main::c#0
Inlining constant with var siblings main::c#1
Constant inlined main::sc#0 = SCREEN
Constant inlined main::c#0 = '.'
Constant inlined main::x#0 = 0
Constant inlined main::y#0 = 0
Constant inlined main::c#1 = '*'
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 main::@4
CALL GRAPH

Created 6 initial phi equivalence classes
Coalesced [4] main::bits#5 = main::bits#0
Coalesced [5] main::sc#9 = main::sc#7
Coalesced [22] main::y#7 = main::y#1
Coalesced [23] main::sc#8 = main::sc#2
Coalesced [24] main::bits#6 = main::bits#1
Coalesced [25] main::sc#10 = main::sc#1
Coalesced [26] main::x#5 = main::x#1
Coalesced down to 5 phi equivalence classes
Culled Empty Block label main::@7
Culled Empty Block label main::@8
Adding NOP phi() at start of main::@4

FINAL CONTROL FLOW GRAPH

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


VARIABLE REGISTER WEIGHTS
void main()
char main::$1 // 202.0
char *main::CHAR_A
char main::bits
char main::bits#0 // 22.0
char main::bits#1 // 67.33333333333333
char main::bits#2 // 44.85714285714286
char main::c
char main::c#2 // 101.0
char *main::sc
char *main::sc#1 // 53.25
char *main::sc#2 // 7.333333333333333
char *main::sc#3 // 52.33333333333333
char *main::sc#7 // 11.0
char main::x
char main::x#1 // 151.5
char main::x#2 // 25.25
char main::y
char main::y#1 // 16.5
char 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::$1 ]
Allocated zp[1]:3 [ main::x#2 main::x#1 ]
Allocated zp[1]:4 [ main::bits#2 main::bits#0 main::bits#1 ]
Allocated zp[2]:5 [ main::sc#3 main::sc#7 main::sc#2 main::sc#1 ]
Allocated zp[1]:7 [ main::c#2 ]
Allocated zp[1]:8 [ main::y#2 main::y#1 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [1] *PROCPORT = $32 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [9] *main::sc#3 = main::c#2 [ main::y#2 main::bits#2 main::sc#3 main::x#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]:8 [ main::y#2 main::y#1 ]
Removing always clobbered register reg byte y as potential for zp[1]:4 [ main::bits#2 main::bits#0 main::bits#1 ]
Removing always clobbered register reg byte y as potential for zp[1]:3 [ main::x#2 main::x#1 ]
Statement [14] main::sc#2 = main::sc#1 + $20 [ main::y#2 main::sc#2 ] (  [ main::y#2 main::sc#2 ] { }  ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:8 [ main::y#2 main::y#1 ]
Statement [17] *PROCPORT = $37 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [1] *PROCPORT = $32 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [9] *main::sc#3 = main::c#2 [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] (  [ main::y#2 main::bits#2 main::sc#3 main::x#2 ] { }  ) always clobbers reg byte y 
Statement [14] main::sc#2 = main::sc#1 + $20 [ main::y#2 main::sc#2 ] (  [ main::y#2 main::sc#2 ] { }  ) always clobbers reg byte a 
Statement [17] *PROCPORT = $37 [ ] (  [ ] { }  ) always clobbers reg byte a 
Potential registers zp[1]:8 [ main::y#2 main::y#1 ] : zp[1]:8 , reg byte x , 
Potential registers zp[1]:4 [ main::bits#2 main::bits#0 main::bits#1 ] : zp[1]:4 , reg byte a , reg byte x , 
Potential registers zp[2]:5 [ main::sc#3 main::sc#7 main::sc#2 main::sc#1 ] : zp[2]:5 , 
Potential registers zp[1]:3 [ main::x#2 main::x#1 ] : zp[1]:3 , 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]:2 [ main::$1 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y , 

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

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

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

ASSEMBLER OPTIMIZATIONS
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___b5:
Removing instruction __b2_from___b3:
Removing instruction __b4_from___b2:
Removing instruction __b3_from___b4:
Succesful ASM optimization Pass5RedundantLabelElimination
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
Relabelling long label __b3_from___b2 to __b4
Succesful ASM optimization Pass5RelabelLongLabels
Removing instruction jmp __b1
Removing instruction jmp __b2
Succesful ASM optimization Pass5NextJumpElimination

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

zp[1]:5 [ main::y#2 main::y#1 ]
zp[1]:2 [ main::bits#2 main::bits#0 main::bits#1 ]
zp[2]:3 [ 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
  // Commodore 64 PRG executable file
.file [name="chargen.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
  // Global Constants & labels
  .label PROCPORT = 1
  .label CHARGEN = $d000
  .label SCREEN = $400
.segment Code
  // main
main: {
    .label CHAR_A = CHARGEN+8
    .label bits = 2
    .label sc = 3
    .label y = 5
    // asm
    // asm { sei  }
    sei
    // *PROCPORT = $32
    // [1] *PROCPORT = $32 -- _deref_pbuc1=vbuc2 
    lda #$32
    sta PROCPORT
    // [2] phi from main to main::@1 [phi:main->main::@1]
    // [2] phi main::sc#7 = SCREEN [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<SCREEN
    sta.z sc
    lda #>SCREEN
    sta.z sc+1
    // [2] phi main::y#2 = 0 [phi:main->main::@1#1] -- vbuz1=vbuc1 
    lda #0
    sta.z y
    // [2] phi from main::@5 to main::@1 [phi:main::@5->main::@1]
    // [2] phi main::sc#7 = main::sc#2 [phi:main::@5->main::@1#0] -- register_copy 
    // [2] phi main::y#2 = main::y#1 [phi:main::@5->main::@1#1] -- register_copy 
    // main::@1
  __b1:
    // byte bits = CHAR_A[y]
    // [3] main::bits#0 = main::CHAR_A#0[main::y#2] -- vbuz1=pbuc1_derefidx_vbuz2 
    ldy.z y
    lda CHAR_A,y
    sta.z bits
    // [4] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
    // [4] phi main::x#2 = 0 [phi:main::@1->main::@2#0] -- vbuxx=vbuc1 
    ldx #0
    // [4] phi main::sc#3 = main::sc#7 [phi:main::@1->main::@2#1] -- register_copy 
    // [4] phi main::bits#2 = main::bits#0 [phi:main::@1->main::@2#2] -- register_copy 
    // [4] phi from main::@3 to main::@2 [phi:main::@3->main::@2]
    // [4] phi main::x#2 = main::x#1 [phi:main::@3->main::@2#0] -- register_copy 
    // [4] phi main::sc#3 = main::sc#1 [phi:main::@3->main::@2#1] -- register_copy 
    // [4] phi main::bits#2 = main::bits#1 [phi:main::@3->main::@2#2] -- register_copy 
    // main::@2
  __b2:
    // bits & $80
    // [5] main::$1 = main::bits#2 & $80 -- vbuaa=vbuz1_band_vbuc1 
    lda #$80
    and.z bits
    // if((bits & $80) != 0)
    // [6] if(main::$1==0) goto main::@3 -- vbuaa_eq_0_then_la1 
    cmp #0
    beq __b4
    // [7] phi from main::@2 to main::@4 [phi:main::@2->main::@4]
    // main::@4
    // [8] phi from main::@4 to main::@3 [phi:main::@4->main::@3]
    // [8] phi main::c#2 = '*' [phi:main::@4->main::@3#0] -- vbuaa=vbuc1 
    lda #'*'
    jmp __b3
    // [8] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
  __b4:
    // [8] phi main::c#2 = '.' [phi:main::@2->main::@3#0] -- vbuaa=vbuc1 
    lda #'.'
    // main::@3
  __b3:
    // *sc = c
    // [9] *main::sc#3 = main::c#2 -- _deref_pbuz1=vbuaa 
    ldy #0
    sta (sc),y
    // sc++;
    // [10] main::sc#1 = ++ main::sc#3 -- pbuz1=_inc_pbuz1 
    inc.z sc
    bne !+
    inc.z sc+1
  !:
    // bits = bits*2
    // [11] main::bits#1 = main::bits#2 << 1 -- vbuz1=vbuz1_rol_1 
    asl.z bits
    // for(byte x:0..7)
    // [12] main::x#1 = ++ main::x#2 -- vbuxx=_inc_vbuxx 
    inx
    // [13] if(main::x#1!=8) goto main::@2 -- vbuxx_neq_vbuc1_then_la1 
    cpx #8
    bne __b2
    // main::@5
    // sc = sc+32
    // [14] main::sc#2 = main::sc#1 + $20 -- pbuz1=pbuz1_plus_vbuc1 
    lda #$20
    clc
    adc.z sc
    sta.z sc
    bcc !+
    inc.z sc+1
  !:
    // for(byte y:0..7)
    // [15] main::y#1 = ++ main::y#2 -- vbuz1=_inc_vbuz1 
    inc.z y
    // [16] if(main::y#1!=8) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #8
    cmp.z y
    bne __b1
    // main::@6
    // *PROCPORT = $37
    // [17] *PROCPORT = $37 -- _deref_pbuc1=vbuc2 
    lda #$37
    sta PROCPORT
    // asm
    // asm { cli  }
    cli
    // main::@return
    // }
    // [19] return 
    rts
}
  // File Data

