
CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  to:main::@1
main::@1: scope:[main]  from main main::@2
  if(true) goto main::@2
  to:main::@3
main::@2: scope:[main]  from main::@1
  *main::SCREEN = ++ *main::SCREEN
  to:main::@1
main::@3: scope:[main]  from main::@1
  main::line#0 = 0
  to:main::@4
main::@4: scope:[main]  from main::@3 main::@4
  main::line#2 = phi( main::@3/main::line#0, main::@4/main::line#1 )
  main::SCREEN[main::line#2] = main::line#2
  main::line#1 = main::line#2 + rangenext(0,$18)
  main::$1 = main::line#1 != rangelast(0,$18)
  if(main::$1) goto main::@4
  to:main::@return
main::@return: scope:[main]  from main::@4
  return 
  to:@return

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

SYMBOL TABLE SSA
void __start()
void main()
bool main::$1
__constant char *main::SCREEN = (char *)$400
char main::line
char main::line#0
char main::line#1
char main::line#2

Simplifying constant pointer cast (char *) 1024
Successful SSA optimization PassNCastSimplification
Simple Condition main::$1 [7] if(main::line#1!=rangelast(0,$18)) goto main::@4
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant main::line#0 = 0
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [0] if(true) goto main::@2
Successful SSA optimization Pass2ConstantIfs
Resolved ranged next value [5] main::line#1 = ++ main::line#2 to ++
Resolved ranged comparison value [7] if(main::line#1!=rangelast(0,$18)) goto main::@4 to $19
Eliminating variable main::line#2 from unused block main::@4
Eliminating variable main::line#1 from unused block main::@4
Removing PHI-reference to removed block (main::@3) in block main::@4
Removing unused block main::@3
Removing unused block main::@4
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Eliminating unused constant main::line#0
Successful SSA optimization PassNEliminateUnusedVars
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::@1
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@1
CALL GRAPH

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block label main::@1
Renumbering block main::@2 to main::@1
Adding NOP phi() at start of main

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@1
  [1] *main::SCREEN = ++ *main::SCREEN
  to:main::@1


VARIABLE REGISTER WEIGHTS
void main()
char main::line

Initial phi equivalence classes
Complete equivalence classes
REGISTER UPLIFT POTENTIAL REGISTERS

REGISTER UPLIFT SCOPES
Uplift Scope [main] 
Uplift Scope [] 

Uplifting [main] best 120 combination 
Uplifting [] best 120 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Problem with eliminating unused blocks/vars after the infinite loop (symbol line#2 not removed from symbol table)
  // Upstart
  // Commodore 64 PRG executable file
.file [name="unusedblockproblem.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
.segment Code
  // main
main: {
    .label SCREEN = $400
    jmp __b1
    // main::@1
  __b1:
    // [1] *main::SCREEN = ++ *main::SCREEN -- _deref_pbuc1=_inc__deref_pbuc1 
    inc SCREEN
    jmp __b1
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Succesful ASM optimization Pass5NextJumpElimination

FINAL SYMBOL TABLE
void main()
__constant char *main::SCREEN = (char *) 1024
char main::line



FINAL ASSEMBLER
Score: 90

  // File Comments
// Problem with eliminating unused blocks/vars after the infinite loop (symbol line#2 not removed from symbol table)
  // Upstart
  // Commodore 64 PRG executable file
.file [name="unusedblockproblem.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
.segment Code
  // main
main: {
    .label SCREEN = $400
    // main::@1
  __b1:
    // (*SCREEN)++;
    // [1] *main::SCREEN = ++ *main::SCREEN -- _deref_pbuc1=_inc__deref_pbuc1 
    inc SCREEN
    jmp __b1
}
  // File Data

