Fixing struct type size struct Person to 16
Fixing struct type size struct Person to 16
Fixing struct type size struct Person to 16
Fixing struct type size struct Person to 16
Fixing struct type SIZE_OF struct Person to 16
Fixing struct type SIZE_OF struct Person to 16

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  main::person#0 = persons
  main::$2 = (char *)main::person#0
  main::$0 = main::$2 + OFFSET_STRUCT_PERSON_NAME
  main::SCREEN[0] = main::$0[2]
  main::person#1 = main::person#0 + SIZEOF_STRUCT_PERSON
  main::$3 = (char *)main::person#1
  main::$1 = main::$3 + OFFSET_STRUCT_PERSON_NAME
  main::SCREEN[1] = main::$1[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 char OFFSET_STRUCT_PERSON_NAME = 1
__constant char SIZEOF_STRUCT_PERSON = $10
void __start()
void main()
char *main::$0
char *main::$1
char *main::$2
char *main::$3
__constant char * const main::SCREEN = (char *)$400
struct Person *main::person
struct Person *main::person#0
struct Person *main::person#1
__constant struct Person persons[2] = { { id: 7, name: "jesper", age: $141 }, { id: 9, name: "henry", age: $7b } }

Adding number conversion cast (unumber) 2 in main::SCREEN[0] = main::$0[2]
Adding number conversion cast (unumber) 0 in main::SCREEN[0] = main::$0[(unumber)2]
Adding number conversion cast (unumber) 2 in main::SCREEN[1] = main::$1[2]
Adding number conversion cast (unumber) 1 in main::SCREEN[1] = main::$1[(unumber)2]
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 2
Simplifying constant integer cast 0
Simplifying constant integer cast 2
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 2
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 2
Finalized unsigned number type (char) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant main::person#0 = persons
Successful SSA optimization Pass2ConstantIdentification
Constant main::$2 = (char *)main::person#0
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero main::SCREEN in [3] main::SCREEN[0] = main::$0[2]
Successful SSA optimization PassNSimplifyExpressionWithZero
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 right-side identified [0] main::$0 = main::$2 + OFFSET_STRUCT_PERSON_NAME
Constant right-side identified [2] main::person#1 = main::person#0 + SIZEOF_STRUCT_PERSON
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::$0 = main::$2+OFFSET_STRUCT_PERSON_NAME
Constant main::person#1 = main::person#0+SIZEOF_STRUCT_PERSON
Successful SSA optimization Pass2ConstantIdentification
Constant main::$3 = (char *)main::person#1
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [1] main::$1 = main::$3 + OFFSET_STRUCT_PERSON_NAME
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::$1 = main::$3+OFFSET_STRUCT_PERSON_NAME
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with different constant siblings main::person#0
Constant inlined main::$3 = (char *)main::person#1
Constant inlined main::$1 = (char *)main::person#1+OFFSET_STRUCT_PERSON_NAME
Constant inlined main::$2 = (char *)persons
Constant inlined main::person#0 = persons
Constant inlined main::$0 = (char *)persons+OFFSET_STRUCT_PERSON_NAME
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *((char *)persons+OFFSET_STRUCT_PERSON_NAME+2)
Consolidated array index constant in *((char *)main::person#1+OFFSET_STRUCT_PERSON_NAME+2)
Consolidated array index constant in *(main::SCREEN+1)
Successful SSA optimization Pass2ConstantAdditionElimination
Finalized unsigned number type (char) $d
Finalized unsigned number type (char) $d
Finalized unsigned number type (char) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
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 = *((char *)persons+OFFSET_STRUCT_PERSON_NAME+2)
  [1] *(main::SCREEN+1) = *((char *)main::person#1+OFFSET_STRUCT_PERSON_NAME+2)
  to:main::@return
main::@return: scope:[main]  from main
  [2] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
struct Person *main::person

Initial phi equivalence classes
Complete equivalence classes
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] *main::SCREEN = *((char *)persons+OFFSET_STRUCT_PERSON_NAME+2) [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [1] *(main::SCREEN+1) = *((char *)main::person#1+OFFSET_STRUCT_PERSON_NAME+2) [ ] (  [ ] { }  ) always clobbers reg byte a 

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

Uplifting [Person] best 25 combination 
Uplifting [main] best 25 combination 
Uplifting [] best 25 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Example of a struct containing an array
  // Upstart
  // Commodore 64 PRG executable file
.file [name="struct-ptr-33.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_STRUCT_PERSON = $10
  .const OFFSET_STRUCT_PERSON_NAME = 1
.segment Code
  // main
main: {
    .label SCREEN = $400
    .label person = persons+SIZEOF_STRUCT_PERSON
    // [0] *main::SCREEN = *((char *)persons+OFFSET_STRUCT_PERSON_NAME+2) -- _deref_pbuc1=_deref_pbuc2 
    lda persons+OFFSET_STRUCT_PERSON_NAME+2
    sta SCREEN
    // [1] *(main::SCREEN+1) = *((char *)main::person#1+OFFSET_STRUCT_PERSON_NAME+2) -- _deref_pbuc1=_deref_pbuc2 
    lda person+OFFSET_STRUCT_PERSON_NAME+2
    sta SCREEN+1
    jmp __breturn
    // main::@return
  __breturn:
    // [2] return 
    rts
}
  // File Data
.segment Data
  persons: .byte 7
  .text "jesper"
  .byte 0
  .fill 6, 0
  .word $141
  .byte 9
  .text "henry"
  .byte 0
  .fill 7, 0
  .word $7b

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

FINAL SYMBOL TABLE
__constant char OFFSET_STRUCT_PERSON_NAME = 1
__constant char SIZEOF_STRUCT_PERSON = $10
void main()
__constant char * const main::SCREEN = (char *) 1024
struct Person *main::person
__constant struct Person *main::person#1 = persons+SIZEOF_STRUCT_PERSON // person
__constant struct Person persons[2] = { { id: 7, name: "jesper", age: $141 }, { id: 9, name: "henry", age: $7b } }



FINAL ASSEMBLER
Score: 22

  // File Comments
// Example of a struct containing an array
  // Upstart
  // Commodore 64 PRG executable file
.file [name="struct-ptr-33.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_STRUCT_PERSON = $10
  .const OFFSET_STRUCT_PERSON_NAME = 1
.segment Code
  // main
main: {
    .label SCREEN = $400
    .label person = persons+SIZEOF_STRUCT_PERSON
    // SCREEN[0] = person->name[2]
    // [0] *main::SCREEN = *((char *)persons+OFFSET_STRUCT_PERSON_NAME+2) -- _deref_pbuc1=_deref_pbuc2 
    lda persons+OFFSET_STRUCT_PERSON_NAME+2
    sta SCREEN
    // SCREEN[1] = person->name[2]
    // [1] *(main::SCREEN+1) = *((char *)main::person#1+OFFSET_STRUCT_PERSON_NAME+2) -- _deref_pbuc1=_deref_pbuc2 
    lda person+OFFSET_STRUCT_PERSON_NAME+2
    sta SCREEN+1
    // main::@return
    // }
    // [2] return 
    rts
}
  // File Data
.segment Data
  persons: .byte 7
  .text "jesper"
  .byte 0
  .fill 6, 0
  .word $141
  .byte 9
  .text "henry"
  .byte 0
  .fill 7, 0
  .word $7b

