
CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  main::b#0 = 0
  if(main::v64==0) goto main::@1
  to:main::@2
main::@1: scope:[main]  from main
  main::b#1 = 1
  to:main::@2
main::@2: scope:[main]  from main main::@1
  main::b#2 = phi( main/main::b#0, main::@1/main::b#1 )
  main::SCREEN[0] = main::b#2
  to:main::@return
main::@return: scope:[main]  from main::@2
  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()
__constant char *main::SCREEN = (char *)$400
char main::b
char main::b#0
char main::b#1
char main::b#2
__constant char main::v64 = 0

Adding number conversion cast (unumber) 0 in if(main::v64==0) goto main::@1
Adding number conversion cast (unumber) 1 in main::b#1 = 1
Adding number conversion cast (unumber) 0 in main::SCREEN[0] = main::b#2
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast main::b#1 = (unumber)1
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Negating conditional jump and destination [1] if(main::v64!=0) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSequenceImprovement
Constant main::b#0 = 0
Constant main::b#1 = 1
Successful SSA optimization Pass2ConstantIdentification
Removing PHI-reference to removed block (main) in block main::@2
if() condition always false - eliminating [1] if(main::v64!=0) goto main::@2
Successful SSA optimization Pass2ConstantIfs
Simplifying expression containing zero main::SCREEN in [4] main::SCREEN[0] = main::b#2
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant main::v64
Eliminating unused constant main::b#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
Identical Phi Values main::b#2 main::b#1
Successful SSA optimization Pass2IdenticalPhiElimination
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
  [1] *main::SCREEN = main::b#1
  to:main::@return
main::@return: scope:[main]  from main::@1
  [2] return 
  to:@return


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

Initial phi equivalence classes
Complete equivalence classes
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [1] *main::SCREEN = main::b#1 [ ] (  [ ] { }  ) always clobbers reg byte a 

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

Uplifting [main] best 45 combination 
Uplifting [] best 45 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests simple switch()-statement - not inside a loop
  // Upstart
  // Commodore 64 PRG executable file
.file [name="switch-2.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: {
    .const b = 1
    .label SCREEN = $400
    jmp __b1
    // main::@1
  __b1:
    // [1] *main::SCREEN = main::b#1 -- _deref_pbuc1=vbuc2 
    lda #b
    sta SCREEN
    jmp __breturn
    // main::@return
  __breturn:
    // [2] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
void main()
__constant char *main::SCREEN = (char *) 1024
char main::b
__constant char main::b#1 = 1 // b



FINAL ASSEMBLER
Score: 12

  // File Comments
// Tests simple switch()-statement - not inside a loop
  // Upstart
  // Commodore 64 PRG executable file
.file [name="switch-2.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: {
    .const b = 1
    .label SCREEN = $400
    // main::@1
    // SCREEN[0] = b
    // [1] *main::SCREEN = main::b#1 -- _deref_pbuc1=vbuc2 
    lda #b
    sta SCREEN
    // main::@return
    // }
    // [2] return 
    rts
}
  // File Data

