
CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  if(true) goto main::@1
  to:main::@2
main::@1: scope:[main]  from main
  main::$1 = 'a'
  to:main::@3
main::@2: scope:[main]  from main
  main::$0 = 'b'
  to:main::@3
main::@3: scope:[main]  from main::@1 main::@2
  main::$2 = phi( main::@1/main::$1, main::@2/main::$0 )
  main::SCREEN[0] = main::$2
  if(false) goto main::@4
  to:main::@5
main::@4: scope:[main]  from main::@3
  main::$4 = 'a'
  to:main::@6
main::@5: scope:[main]  from main::@3
  main::$3 = 'b'
  to:main::@6
main::@6: scope:[main]  from main::@4 main::@5
  main::$5 = phi( main::@4/main::$4, main::@5/main::$3 )
  main::SCREEN[1] = main::$5
  to:main::@return
main::@return: scope:[main]  from main::@6
  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()
char main::$0
char main::$1
char main::$2
char main::$3
char main::$4
char main::$5
__constant char * const main::SCREEN = (char *)$400

Adding number conversion cast (unumber) 0 in main::SCREEN[0] = main::$2
Adding number conversion cast (unumber) 1 in main::SCREEN[1] = main::$5
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant main::$1 = 'a'
Constant main::$0 = 'b'
Constant main::$4 = 'a'
Constant main::$3 = 'b'
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [0] if(true) goto main::@1
if() condition always false - eliminating [5] if(false) goto main::@4
Successful SSA optimization Pass2ConstantIfs
Simplifying expression containing zero main::SCREEN in [4] main::SCREEN[0] = main::$2
Successful SSA optimization PassNSimplifyExpressionWithZero
Removing PHI-reference to removed block (main::@2) in block main::@3
Removing unused block main::@2
Removing PHI-reference to removed block (main::@4) in block main::@6
Removing unused block main::@4
Successful SSA optimization Pass2EliminateUnusedBlocks
Eliminating unused constant main::$0
Eliminating unused constant main::$4
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::$2 main::$1
Identical Phi Values main::$5 main::$3
Successful SSA optimization Pass2IdenticalPhiElimination
Constant inlined main::$1 = 'a'
Constant inlined main::$3 = 'b'
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(main::SCREEN+1)
Successful SSA optimization Pass2ConstantAdditionElimination
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@1
Adding NOP phi() at start of main::@5
CALL GRAPH

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block label main::@1
Culled Empty Block label main::@5
Renumbering block main::@3 to main::@1
Renumbering block main::@6 to main::@2
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 = 'a'
  to:main::@2
main::@2: scope:[main]  from main::@1
  [2] *(main::SCREEN+1) = 'b'
  to:main::@return
main::@return: scope:[main]  from main::@2
  [3] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()

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

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

Uplifting [main] best 54 combination 
Uplifting [] best 54 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests the ternary operator - when the condition is constant
  // Upstart
  // Commodore 64 PRG executable file
.file [name="ternary-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: {
    .label SCREEN = $400
    jmp __b1
    // main::@1
  __b1:
    // [1] *main::SCREEN = 'a' -- _deref_pbuc1=vbuc2 
    lda #'a'
    sta SCREEN
    jmp __b2
    // main::@2
  __b2:
    // [2] *(main::SCREEN+1) = 'b' -- _deref_pbuc1=vbuc2 
    lda #'b'
    sta SCREEN+1
    jmp __breturn
    // main::@return
  __breturn:
    // [3] return 
    rts
}
  // File Data

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

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



FINAL ASSEMBLER
Score: 18

  // File Comments
// Tests the ternary operator - when the condition is constant
  // Upstart
  // Commodore 64 PRG executable file
.file [name="ternary-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: {
    .label SCREEN = $400
    // main::@1
    // SCREEN[0] = true?'a':'b'
    // [1] *main::SCREEN = 'a' -- _deref_pbuc1=vbuc2 
    lda #'a'
    sta SCREEN
    // main::@2
    // SCREEN[1] = false?'a':'b'
    // [2] *(main::SCREEN+1) = 'b' -- _deref_pbuc1=vbuc2 
    lda #'b'
    sta SCREEN+1
    // main::@return
    // }
    // [3] return 
    rts
}
  // File Data

