Fixing struct type size struct Point to 3
Fixing struct type size struct Point to 3
Fixing struct type SIZE_OF struct Point to 3
Fixing struct type SIZE_OF struct Point to 3

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  SCREEN[0] = *((char *)&point1+OFFSET_STRUCT_POINT_X)
  SCREEN[1] = ((char *)&point1+OFFSET_STRUCT_POINT_INITIALS)[0]
  SCREEN[2] = ((char *)&point1+OFFSET_STRUCT_POINT_INITIALS)[1]
  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_POINT_INITIALS = 1
__constant char OFFSET_STRUCT_POINT_X = 0
__constant char * const SCREEN = (char *)$400
void __start()
void main()
__loadstore struct Point point1 = { x: 2, initials: "jg" }

Adding number conversion cast (unumber) 0 in SCREEN[0] = *((char *)&point1+OFFSET_STRUCT_POINT_X)
Adding number conversion cast (unumber) 0 in SCREEN[1] = ((char *)&point1+OFFSET_STRUCT_POINT_INITIALS)[0]
Adding number conversion cast (unumber) 1 in SCREEN[1] = ((char *)&point1+OFFSET_STRUCT_POINT_INITIALS)[(unumber)0]
Adding number conversion cast (unumber) 1 in SCREEN[2] = ((char *)&point1+OFFSET_STRUCT_POINT_INITIALS)[1]
Adding number conversion cast (unumber) 2 in SCREEN[2] = ((char *)&point1+OFFSET_STRUCT_POINT_INITIALS)[(unumber)1]
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 1
Simplifying constant integer cast 2
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simplifying expression containing zero (char *)&point1 in [0] SCREEN[0] = *((char *)&point1+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero SCREEN in [0] SCREEN[0] = *((char *)&point1)
Simplifying expression containing zero (char *)&point1+OFFSET_STRUCT_POINT_INITIALS in [1] SCREEN[1] = ((char *)&point1+OFFSET_STRUCT_POINT_INITIALS)[0]
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant OFFSET_STRUCT_POINT_X
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
Consolidated array index constant in *(SCREEN+1)
Consolidated array index constant in *((char *)&point1+OFFSET_STRUCT_POINT_INITIALS+1)
Consolidated array index constant in *(SCREEN+2)
Successful SSA optimization Pass2ConstantAdditionElimination
Finalized unsigned number type (char) 2
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] *SCREEN = *((char *)&point1)
  [1] *(SCREEN+1) = *((char *)&point1+OFFSET_STRUCT_POINT_INITIALS)
  [2] *(SCREEN+2) = *((char *)&point1+OFFSET_STRUCT_POINT_INITIALS+1)
  to:main::@return
main::@return: scope:[main]  from main
  [3] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
__loadstore struct Point point1 = { x: 2, initials: "jg" }

Initial phi equivalence classes
Added variable point1 to live range equivalence class [ point1 ]
Complete equivalence classes
[ point1 ]
Allocated mem[3] [ point1 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] *SCREEN = *((char *)&point1) [ point1 ] (  [ point1 ] { }  ) always clobbers reg byte a 
Statement [1] *(SCREEN+1) = *((char *)&point1+OFFSET_STRUCT_POINT_INITIALS) [ point1 ] (  [ point1 ] { }  ) always clobbers reg byte a 
Statement [2] *(SCREEN+2) = *((char *)&point1+OFFSET_STRUCT_POINT_INITIALS+1) [ ] (  [ ] { }  ) always clobbers reg byte a 
Potential registers mem[3] [ point1 ] : mem[3] , 

REGISTER UPLIFT SCOPES
Uplift Scope [Point] 
Uplift Scope [main] 
Uplift Scope [] 0: mem[3] [ point1 ] 

Uplifting [Point] best 33 combination 
Uplifting [main] best 33 combination 
Uplifting [] best 33 combination mem[3] [ point1 ] 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Minimal struct with C-Standard behavior - global main-mem struct should be initialized in data, not code
  // Upstart
  // Commodore 64 PRG executable file
.file [name="struct-36.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 OFFSET_STRUCT_POINT_INITIALS = 1
  .label SCREEN = $400
.segment Code
  // main
main: {
    // [0] *SCREEN = *((char *)&point1) -- _deref_pbuc1=_deref_pbuc2 
    lda point1
    sta SCREEN
    // [1] *(SCREEN+1) = *((char *)&point1+OFFSET_STRUCT_POINT_INITIALS) -- _deref_pbuc1=_deref_pbuc2 
    lda point1+OFFSET_STRUCT_POINT_INITIALS
    sta SCREEN+1
    // [2] *(SCREEN+2) = *((char *)&point1+OFFSET_STRUCT_POINT_INITIALS+1) -- _deref_pbuc1=_deref_pbuc2 
    lda point1+OFFSET_STRUCT_POINT_INITIALS+1
    sta SCREEN+2
    jmp __breturn
    // main::@return
  __breturn:
    // [3] return 
    rts
}
  // File Data
.segment Data
  point1: .byte 2
  .text "jg"
  .byte 0

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

FINAL SYMBOL TABLE
__constant char OFFSET_STRUCT_POINT_INITIALS = 1
__constant char * const SCREEN = (char *) 1024
void main()
__loadstore struct Point point1 = { x: 2, initials: "jg" } // mem[3]

mem[3] [ point1 ]


FINAL ASSEMBLER
Score: 30

  // File Comments
// Minimal struct with C-Standard behavior - global main-mem struct should be initialized in data, not code
  // Upstart
  // Commodore 64 PRG executable file
.file [name="struct-36.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 OFFSET_STRUCT_POINT_INITIALS = 1
  .label SCREEN = $400
.segment Code
  // main
main: {
    // SCREEN[0] = point1.x
    // [0] *SCREEN = *((char *)&point1) -- _deref_pbuc1=_deref_pbuc2 
    lda point1
    sta SCREEN
    // SCREEN[1] = point1.initials[0]
    // [1] *(SCREEN+1) = *((char *)&point1+OFFSET_STRUCT_POINT_INITIALS) -- _deref_pbuc1=_deref_pbuc2 
    lda point1+OFFSET_STRUCT_POINT_INITIALS
    sta SCREEN+1
    // SCREEN[2] = point1.initials[1]
    // [2] *(SCREEN+2) = *((char *)&point1+OFFSET_STRUCT_POINT_INITIALS+1) -- _deref_pbuc1=_deref_pbuc2 
    lda point1+OFFSET_STRUCT_POINT_INITIALS+1
    sta SCREEN+2
    // main::@return
    // }
    // [3] return 
    rts
}
  // File Data
.segment Data
  point1: .byte 2
  .text "jg"
  .byte 0

