
CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  main::SCREEN[0] = main::i
  main::SCREEN[1] = +3
  main::$0 = 0 * SIZEOF_INT
  main::SCREEN2[main::$0] = main::j
  main::$1 = 1 * SIZEOF_INT
  main::SCREEN2[main::$1] = +3
  to:main::@return
main::@return: scope:[main]  from main
  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
__constant char SIZEOF_INT = 2
void __start()
void main()
number main::$0
number main::$1
__constant char *main::SCREEN = (char *)$400
__constant int *main::SCREEN2 = (int *)$428
__constant char main::i = (char)+3
__constant int main::j = (int)+3

Adding number conversion cast (unumber) 0 in main::SCREEN[0] = main::i
Adding number conversion cast (unumber) +3 in main::SCREEN[1] = +3
Adding number conversion cast (unumber) 1 in main::SCREEN[1] = ((unumber)) +3
Adding number conversion cast (unumber) 0 in main::$0 = 0 * SIZEOF_INT
Adding number conversion cast (unumber) main::$0 in main::$0 = (unumber)0 * SIZEOF_INT
Adding number conversion cast (unumber) 1 in main::$1 = 1 * SIZEOF_INT
Adding number conversion cast (unumber) main::$1 in main::$1 = (unumber)1 * SIZEOF_INT
Adding number conversion cast (snumber) +3 in main::SCREEN2[main::$1] = +3
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast main::SCREEN[(unumber)1] = (unumber)+3
Inlining cast main::SCREEN2[main::$1] = (snumber)+3
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (char *) 1024
Simplifying constant pointer cast (int *) 1064
Simplifying constant integer cast 0
Simplifying constant integer cast 1
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
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to char in main::$0 = 0 * SIZEOF_INT
Inferred type updated to char in main::$1 = 1 * SIZEOF_INT
Constant right-side identified [1] main::SCREEN[1] = (unumber)+3
Constant right-side identified [2] main::$0 = 0 * SIZEOF_INT
Constant right-side identified [4] main::$1 = 1 * SIZEOF_INT
Constant right-side identified [5] main::SCREEN2[main::$1] = (snumber)+3
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::$0 = 0*SIZEOF_INT
Constant main::$1 = 1*SIZEOF_INT
Successful SSA optimization Pass2ConstantIdentification
Simplifying constant evaluating to zero 0*SIZEOF_INT in 
Successful SSA optimization PassNSimplifyConstantZero
Simplifying expression containing zero main::SCREEN in [0] main::SCREEN[0] = main::i
Simplifying expression containing zero main::SCREEN2 in [3] main::SCREEN2[main::$0] = main::j
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant main::$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
Constant inlined main::$1 = 1*SIZEOF_INT
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(main::SCREEN+1)
Consolidated array index constant in *(main::SCREEN2+1*SIZEOF_INT)
Successful SSA optimization Pass2ConstantAdditionElimination
Finalized unsigned number type (char) 3
Finalized unsigned number type (char) 3
Finalized unsigned number type (char) 3
Finalized unsigned number type (char) 3
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simplifying constant integer cast +3
Simplifying constant integer cast +3
Successful SSA optimization PassNCastSimplification
CALL GRAPH

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] *main::SCREEN = main::i
  [1] *(main::SCREEN+1) = +3
  [2] *main::SCREEN2 = main::j
  [3] *(main::SCREEN2+1*SIZEOF_INT) = (signed char)+3
  to:main::@return
main::@return: scope:[main]  from main
  [4] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()

Initial phi equivalence classes
Complete equivalence classes
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] *main::SCREEN = main::i [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [1] *(main::SCREEN+1) = +3 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [2] *main::SCREEN2 = main::j [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [3] *(main::SCREEN2+1*SIZEOF_INT) = (signed char)+3 [ ] (  [ ] { }  ) 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
// Test unary plus
  // Upstart
  // Commodore 64 PRG executable file
.file [name="unary-plus.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
  .const SIZEOF_INT = 2
.segment Code
  // main
main: {
    .const i = 3
    .const j = 3
    .label SCREEN = $400
    .label SCREEN2 = $428
    // [0] *main::SCREEN = main::i -- _deref_pbuc1=vbuc2 
    lda #i
    sta SCREEN
    // [1] *(main::SCREEN+1) = +3 -- _deref_pbuc1=vbuc2 
    lda #3
    sta SCREEN+1
    // [2] *main::SCREEN2 = main::j -- _deref_pwsc1=vwsc2 
    lda #<j
    sta SCREEN2
    lda #>j
    sta SCREEN2+1
    // [3] *(main::SCREEN2+1*SIZEOF_INT) = (signed char)+3 -- _deref_pwsc1=vbsc2 
    lda #<3
    sta SCREEN2+1*SIZEOF_INT
    lda #>3
    sta SCREEN2+1*SIZEOF_INT+1
    jmp __breturn
    // main::@return
  __breturn:
    // [4] return 
    rts
}
  // File Data

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

FINAL SYMBOL TABLE
__constant char SIZEOF_INT = 2
void main()
__constant char *main::SCREEN = (char *) 1024
__constant int *main::SCREEN2 = (int *) 1064
__constant char main::i = +3
__constant int main::j = (int)+3



FINAL ASSEMBLER
Score: 42

  // File Comments
// Test unary plus
  // Upstart
  // Commodore 64 PRG executable file
.file [name="unary-plus.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
  .const SIZEOF_INT = 2
.segment Code
  // main
main: {
    .const i = 3
    .const j = 3
    .label SCREEN = $400
    .label SCREEN2 = $428
    // SCREEN[0] = i
    // [0] *main::SCREEN = main::i -- _deref_pbuc1=vbuc2 
    lda #i
    sta SCREEN
    // SCREEN[1] = +3
    // [1] *(main::SCREEN+1) = +3 -- _deref_pbuc1=vbuc2 
    lda #3
    sta SCREEN+1
    // SCREEN2[0] = j
    // [2] *main::SCREEN2 = main::j -- _deref_pwsc1=vwsc2 
    lda #<j
    sta SCREEN2
    lda #>j
    sta SCREEN2+1
    // SCREEN2[1] = +3
    // [3] *(main::SCREEN2+1*SIZEOF_INT) = (signed char)+3 -- _deref_pwsc1=vbsc2 
    lda #<3
    sta SCREEN2+1*SIZEOF_INT
    lda #>3
    sta SCREEN2+1*SIZEOF_INT+1
    // main::@return
    // }
    // [4] return 
    rts
}
  // File Data

