
CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  main::$0 = 1 * SIZEOF_UNSIGNED_INT
  main::$1 = 0 * SIZEOF_UNSIGNED_INT
  main::SCREEN[main::$1] = main::info_values[main::$0]
  main::$2 = 1 * SIZEOF_UNSIGNED_INT
  main::SCREEN[main::$2] = RADIX_DECIMAL_VALUES[main::$2]
  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 unsigned int RADIX_DECIMAL_VALUES[] = { $2710, $3e8, $64, $a }
__constant char SIZEOF_UNSIGNED_INT = 2
void __start()
void main()
number main::$0
number main::$1
number main::$2
__constant unsigned int * const main::SCREEN = (unsigned int *)$400
__constant unsigned int *main::info_values = RADIX_DECIMAL_VALUES

Adding number conversion cast (unumber) 1 in main::$0 = 1 * SIZEOF_UNSIGNED_INT
Adding number conversion cast (unumber) main::$0 in main::$0 = (unumber)1 * SIZEOF_UNSIGNED_INT
Adding number conversion cast (unumber) 0 in main::$1 = 0 * SIZEOF_UNSIGNED_INT
Adding number conversion cast (unumber) main::$1 in main::$1 = (unumber)0 * SIZEOF_UNSIGNED_INT
Adding number conversion cast (unumber) 1 in main::$2 = 1 * SIZEOF_UNSIGNED_INT
Adding number conversion cast (unumber) main::$2 in main::$2 = (unumber)1 * SIZEOF_UNSIGNED_INT
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (unsigned int *) 1024
Simplifying constant integer cast 1
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
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 = 1 * SIZEOF_UNSIGNED_INT
Inferred type updated to char in main::$1 = 0 * SIZEOF_UNSIGNED_INT
Inferred type updated to char in main::$2 = 1 * SIZEOF_UNSIGNED_INT
Constant right-side identified [0] main::$0 = 1 * SIZEOF_UNSIGNED_INT
Constant right-side identified [1] main::$1 = 0 * SIZEOF_UNSIGNED_INT
Constant right-side identified [3] main::$2 = 1 * SIZEOF_UNSIGNED_INT
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::$0 = 1*SIZEOF_UNSIGNED_INT
Constant main::$1 = 0*SIZEOF_UNSIGNED_INT
Constant main::$2 = 1*SIZEOF_UNSIGNED_INT
Successful SSA optimization Pass2ConstantIdentification
Simplifying constant evaluating to zero 0*SIZEOF_UNSIGNED_INT in 
Successful SSA optimization PassNSimplifyConstantZero
Simplifying expression containing zero main::SCREEN in [2] main::SCREEN[main::$1] = main::info_values[main::$0]
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant main::$1
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::info_values = RADIX_DECIMAL_VALUES
Constant inlined main::$2 = 1*SIZEOF_UNSIGNED_INT
Constant inlined main::$0 = 1*SIZEOF_UNSIGNED_INT
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(RADIX_DECIMAL_VALUES+1*SIZEOF_UNSIGNED_INT)
Consolidated array index constant in *(RADIX_DECIMAL_VALUES+1*SIZEOF_UNSIGNED_INT)
Consolidated array index constant in *(main::SCREEN+1*SIZEOF_UNSIGNED_INT)
Successful SSA optimization Pass2ConstantAdditionElimination
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 = *(RADIX_DECIMAL_VALUES+1*SIZEOF_UNSIGNED_INT)
  [1] *(main::SCREEN+1*SIZEOF_UNSIGNED_INT) = *(RADIX_DECIMAL_VALUES+1*SIZEOF_UNSIGNED_INT)
  to:main::@return
main::@return: scope:[main]  from main
  [2] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()

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

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

Uplifting [RadixInfo] best 41 combination 
Uplifting [main] best 41 combination 
Uplifting [] best 41 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Illustrates a problem with pointer sizeof()-rewriting for pointers inside structs
  // Upstart
  // Commodore 64 PRG executable file
.file [name="struct-10.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_UNSIGNED_INT = 2
.segment Code
  // main
main: {
    .label SCREEN = $400
    // [0] *main::SCREEN = *(RADIX_DECIMAL_VALUES+1*SIZEOF_UNSIGNED_INT) -- _deref_pwuc1=_deref_pwuc2 
    lda RADIX_DECIMAL_VALUES+1*SIZEOF_UNSIGNED_INT
    sta SCREEN
    lda RADIX_DECIMAL_VALUES+1*SIZEOF_UNSIGNED_INT+1
    sta SCREEN+1
    // [1] *(main::SCREEN+1*SIZEOF_UNSIGNED_INT) = *(RADIX_DECIMAL_VALUES+1*SIZEOF_UNSIGNED_INT) -- _deref_pwuc1=_deref_pwuc2 
    lda RADIX_DECIMAL_VALUES+1*SIZEOF_UNSIGNED_INT
    sta SCREEN+1*SIZEOF_UNSIGNED_INT
    lda RADIX_DECIMAL_VALUES+1*SIZEOF_UNSIGNED_INT+1
    sta SCREEN+1*SIZEOF_UNSIGNED_INT+1
    jmp __breturn
    // main::@return
  __breturn:
    // [2] return 
    rts
}
  // File Data
.segment Data
  RADIX_DECIMAL_VALUES: .word $2710, $3e8, $64, $a

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

FINAL SYMBOL TABLE
__constant unsigned int RADIX_DECIMAL_VALUES[] = { $2710, $3e8, $64, $a }
__constant char SIZEOF_UNSIGNED_INT = 2
void main()
__constant unsigned int * const main::SCREEN = (unsigned int *) 1024



FINAL ASSEMBLER
Score: 38

  // File Comments
// Illustrates a problem with pointer sizeof()-rewriting for pointers inside structs
  // Upstart
  // Commodore 64 PRG executable file
.file [name="struct-10.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_UNSIGNED_INT = 2
.segment Code
  // main
main: {
    .label SCREEN = $400
    // SCREEN[0] = info.values[1]
    // [0] *main::SCREEN = *(RADIX_DECIMAL_VALUES+1*SIZEOF_UNSIGNED_INT) -- _deref_pwuc1=_deref_pwuc2 
    lda RADIX_DECIMAL_VALUES+1*SIZEOF_UNSIGNED_INT
    sta SCREEN
    lda RADIX_DECIMAL_VALUES+1*SIZEOF_UNSIGNED_INT+1
    sta SCREEN+1
    // SCREEN[1] = RADIX_DECIMAL_VALUES[1]
    // [1] *(main::SCREEN+1*SIZEOF_UNSIGNED_INT) = *(RADIX_DECIMAL_VALUES+1*SIZEOF_UNSIGNED_INT) -- _deref_pwuc1=_deref_pwuc2 
    lda RADIX_DECIMAL_VALUES+1*SIZEOF_UNSIGNED_INT
    sta SCREEN+1*SIZEOF_UNSIGNED_INT
    lda RADIX_DECIMAL_VALUES+1*SIZEOF_UNSIGNED_INT+1
    sta SCREEN+1*SIZEOF_UNSIGNED_INT+1
    // main::@return
    // }
    // [2] return 
    rts
}
  // File Data
.segment Data
  RADIX_DECIMAL_VALUES: .word $2710, $3e8, $64, $a

