
CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  *((char *)&point+OFFSET_STRUCT_POINT_X) = 2
  *((char *)&point+OFFSET_STRUCT_POINT_Y) = 3
  SCREEN[0] = *((char *)&point+OFFSET_STRUCT_POINT_X)
  SCREEN[1] = *((char *)&point+OFFSET_STRUCT_POINT_Y)
  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_X = 0
__constant char OFFSET_STRUCT_POINT_Y = 1
__constant char * const SCREEN = (char *)$400
void __start()
void main()
__loadstore struct Point point = {}

Adding number conversion cast (unumber) 2 in *((char *)&point+OFFSET_STRUCT_POINT_X) = 2
Adding number conversion cast (unumber) 3 in *((char *)&point+OFFSET_STRUCT_POINT_Y) = 3
Adding number conversion cast (unumber) 0 in SCREEN[0] = *((char *)&point+OFFSET_STRUCT_POINT_X)
Adding number conversion cast (unumber) 1 in SCREEN[1] = *((char *)&point+OFFSET_STRUCT_POINT_Y)
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast *((char *)&point+OFFSET_STRUCT_POINT_X) = (unumber)2
Inlining cast *((char *)&point+OFFSET_STRUCT_POINT_Y) = (unumber)3
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 2
Simplifying constant integer cast 3
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 2
Finalized unsigned number type (char) 3
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simplifying expression containing zero (char *)&point in [0] *((char *)&point+OFFSET_STRUCT_POINT_X) = 2
Simplifying expression containing zero (char *)&point in [2] SCREEN[0] = *((char *)&point+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero SCREEN in [2] SCREEN[0] = *((char *)&point)
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)
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] *((char *)&point) = 2
  [1] *((char *)&point+OFFSET_STRUCT_POINT_Y) = 3
  [2] *SCREEN = *((char *)&point)
  [3] *(SCREEN+1) = *((char *)&point+OFFSET_STRUCT_POINT_Y)
  to:main::@return
main::@return: scope:[main]  from main
  [4] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
__loadstore struct Point point = {}

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

REGISTER UPLIFT SCOPES
Uplift Scope [Point] 
Uplift Scope [main] 
Uplift Scope [] 0: mem[2] [ point ] 

Uplifting [Point] best 37 combination 
Uplifting [main] best 37 combination 
Uplifting [] best 37 combination mem[2] [ point ] 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Minimal struct with C-Standard behavior - declaration, instantiation and usage
  // Upstart
  // Commodore 64 PRG executable file
.file [name="struct-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 OFFSET_STRUCT_POINT_Y = 1
  .const SIZEOF_STRUCT_POINT = 2
  .label SCREEN = $400
.segment Code
  // main
main: {
    // [0] *((char *)&point) = 2 -- _deref_pbuc1=vbuc2 
    lda #2
    sta point
    // [1] *((char *)&point+OFFSET_STRUCT_POINT_Y) = 3 -- _deref_pbuc1=vbuc2 
    lda #3
    sta point+OFFSET_STRUCT_POINT_Y
    // [2] *SCREEN = *((char *)&point) -- _deref_pbuc1=_deref_pbuc2 
    lda point
    sta SCREEN
    // [3] *(SCREEN+1) = *((char *)&point+OFFSET_STRUCT_POINT_Y) -- _deref_pbuc1=_deref_pbuc2 
    lda point+OFFSET_STRUCT_POINT_Y
    sta SCREEN+1
    jmp __breturn
    // main::@return
  __breturn:
    // [4] return 
    rts
}
  // File Data
.segment Data
  point: .fill SIZEOF_STRUCT_POINT, 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_Y = 1
__constant char * const SCREEN = (char *) 1024
__constant char SIZEOF_STRUCT_POINT = 2
void main()
__loadstore struct Point point = {} // mem[2]

mem[2] [ point ]


FINAL ASSEMBLER
Score: 34

  // File Comments
// Minimal struct with C-Standard behavior - declaration, instantiation and usage
  // Upstart
  // Commodore 64 PRG executable file
.file [name="struct-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 OFFSET_STRUCT_POINT_Y = 1
  .const SIZEOF_STRUCT_POINT = 2
  .label SCREEN = $400
.segment Code
  // main
main: {
    // point.x = 2
    // [0] *((char *)&point) = 2 -- _deref_pbuc1=vbuc2 
    lda #2
    sta point
    // point.y = 3
    // [1] *((char *)&point+OFFSET_STRUCT_POINT_Y) = 3 -- _deref_pbuc1=vbuc2 
    lda #3
    sta point+OFFSET_STRUCT_POINT_Y
    // SCREEN[0] = point.x
    // [2] *SCREEN = *((char *)&point) -- _deref_pbuc1=_deref_pbuc2 
    lda point
    sta SCREEN
    // SCREEN[1] = point.y
    // [3] *(SCREEN+1) = *((char *)&point+OFFSET_STRUCT_POINT_Y) -- _deref_pbuc1=_deref_pbuc2 
    lda point+OFFSET_STRUCT_POINT_Y
    sta SCREEN+1
    // main::@return
    // }
    // [4] return 
    rts
}
  // File Data
.segment Data
  point: .fill SIZEOF_STRUCT_POINT, 0

