Removing C-classic struct-unwound assignment main::v = struct-unwound {*(&main::v)}

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  *(&main::v) = memset(struct Vector, SIZEOF_STRUCT_VECTOR)
  *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X) = 2
  *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y) = 3
  *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X) = 4
  *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_Y) = 5
  SCREEN[0] = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
  SCREEN[1] = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y)
  SCREEN[2] = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X)
  SCREEN[3] = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q+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 OFFSET_STRUCT_VECTOR_P = 0
__constant char OFFSET_STRUCT_VECTOR_Q = 2
__constant char * const SCREEN = (char *)$400
__constant char SIZEOF_STRUCT_VECTOR = 4
void __start()
void main()
__loadstore struct Vector main::v

Adding number conversion cast (unumber) 2 in *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X) = 2
Adding number conversion cast (unumber) 3 in *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y) = 3
Adding number conversion cast (unumber) 4 in *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X) = 4
Adding number conversion cast (unumber) 5 in *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_Y) = 5
Adding number conversion cast (unumber) 0 in SCREEN[0] = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
Adding number conversion cast (unumber) 1 in SCREEN[1] = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y)
Adding number conversion cast (unumber) 2 in SCREEN[2] = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X)
Adding number conversion cast (unumber) 3 in SCREEN[3] = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_Y)
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X) = (unumber)2
Inlining cast *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y) = (unumber)3
Inlining cast *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X) = (unumber)4
Inlining cast *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_Y) = (unumber)5
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 2
Simplifying constant integer cast 3
Simplifying constant integer cast 4
Simplifying constant integer cast 5
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 2
Simplifying constant integer cast 3
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 2
Finalized unsigned number type (char) 3
Finalized unsigned number type (char) 4
Finalized unsigned number type (char) 5
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 2
Finalized unsigned number type (char) 3
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simplifying expression containing zero (char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_P in [1] *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X) = 2
Simplifying expression containing zero (struct Point *)&main::v in [1] *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_P) = 2
Simplifying expression containing zero (struct Point *)&main::v in [2] *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y) = 3
Simplifying expression containing zero (char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q in [3] *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X) = 4
Simplifying expression containing zero (char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_P in [5] SCREEN[0] = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_X)
Simplifying expression containing zero (struct Point *)&main::v in [5] SCREEN[0] = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_P)
Simplifying expression containing zero SCREEN in [5] SCREEN[0] = *((char *)(struct Point *)&main::v)
Simplifying expression containing zero (struct Point *)&main::v in [6] SCREEN[1] = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_P+OFFSET_STRUCT_POINT_Y)
Simplifying expression containing zero (char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q in [7] SCREEN[2] = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_X)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant OFFSET_STRUCT_VECTOR_P
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 *(SCREEN+2)
Consolidated array index constant in *(SCREEN+3)
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::v) = memset(struct Vector, SIZEOF_STRUCT_VECTOR)
  [1] *((char *)(struct Point *)&main::v) = 2
  [2] *((char *)(struct Point *)&main::v+OFFSET_STRUCT_POINT_Y) = 3
  [3] *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q) = 4
  [4] *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_Y) = 5
  [5] *SCREEN = *((char *)(struct Point *)&main::v)
  [6] *(SCREEN+1) = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_POINT_Y)
  [7] *(SCREEN+2) = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q)
  [8] *(SCREEN+3) = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_Y)
  to:main::@return
main::@return: scope:[main]  from main
  [9] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
__loadstore struct Vector main::v

Initial phi equivalence classes
Added variable main::v to live range equivalence class [ main::v ]
Complete equivalence classes
[ main::v ]
Allocated zp[4]:2 [ main::v ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] *(&main::v) = memset(struct Vector, SIZEOF_STRUCT_VECTOR) [ main::v ] (  [ main::v ] { }  ) always clobbers reg byte a reg byte y 
Statement [1] *((char *)(struct Point *)&main::v) = 2 [ main::v ] (  [ main::v ] { }  ) always clobbers reg byte a 
Statement [2] *((char *)(struct Point *)&main::v+OFFSET_STRUCT_POINT_Y) = 3 [ main::v ] (  [ main::v ] { }  ) always clobbers reg byte a 
Statement [3] *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q) = 4 [ main::v ] (  [ main::v ] { }  ) always clobbers reg byte a 
Statement [4] *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_Y) = 5 [ main::v ] (  [ main::v ] { }  ) always clobbers reg byte a 
Statement [5] *SCREEN = *((char *)(struct Point *)&main::v) [ main::v ] (  [ main::v ] { }  ) always clobbers reg byte a 
Statement [6] *(SCREEN+1) = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_POINT_Y) [ main::v ] (  [ main::v ] { }  ) always clobbers reg byte a 
Statement [7] *(SCREEN+2) = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q) [ main::v ] (  [ main::v ] { }  ) always clobbers reg byte a 
Statement [8] *(SCREEN+3) = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_Y) [ ] (  [ ] { }  ) always clobbers reg byte a 
Potential registers zp[4]:2 [ main::v ] : zp[4]:2 , 

REGISTER UPLIFT SCOPES
Uplift Scope [Point] 
Uplift Scope [Vector] 
Uplift Scope [main] 0: zp[4]:2 [ main::v ] 
Uplift Scope [] 

Uplifting [Point] best 76 combination 
Uplifting [Vector] best 76 combination 
Uplifting [main] best 76 combination zp[4]:2 [ main::v ] 
Uplifting [] best 76 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Minimal struct with C-Standard behavior - struct containing struct
  // Upstart
  // Commodore 64 PRG executable file
.file [name="struct-17.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_VECTOR = 4
  .const OFFSET_STRUCT_POINT_Y = 1
  .const OFFSET_STRUCT_VECTOR_Q = 2
  .label SCREEN = $400
.segment Code
  // main
main: {
    .label v = 2
    // [0] *(&main::v) = memset(struct Vector, SIZEOF_STRUCT_VECTOR) -- _deref_pssc1=_memset_vbuc2 
    ldy #SIZEOF_STRUCT_VECTOR
    lda #0
  !:
    dey
    sta v,y
    bne !-
    // [1] *((char *)(struct Point *)&main::v) = 2 -- _deref_pbuc1=vbuc2 
    lda #2
    sta.z v
    // [2] *((char *)(struct Point *)&main::v+OFFSET_STRUCT_POINT_Y) = 3 -- _deref_pbuc1=vbuc2 
    lda #3
    sta v+OFFSET_STRUCT_POINT_Y
    // [3] *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q) = 4 -- _deref_pbuc1=vbuc2 
    lda #4
    sta v+OFFSET_STRUCT_VECTOR_Q
    // [4] *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_Y) = 5 -- _deref_pbuc1=vbuc2 
    lda #5
    sta v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_Y
    // [5] *SCREEN = *((char *)(struct Point *)&main::v) -- _deref_pbuc1=_deref_pbuc2 
    lda.z v
    sta SCREEN
    // [6] *(SCREEN+1) = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_POINT_Y) -- _deref_pbuc1=_deref_pbuc2 
    lda v+OFFSET_STRUCT_POINT_Y
    sta SCREEN+1
    // [7] *(SCREEN+2) = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q) -- _deref_pbuc1=_deref_pbuc2 
    lda v+OFFSET_STRUCT_VECTOR_Q
    sta SCREEN+2
    // [8] *(SCREEN+3) = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_Y) -- _deref_pbuc1=_deref_pbuc2 
    lda v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_Y
    sta SCREEN+3
    jmp __breturn
    // main::@return
  __breturn:
    // [9] 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 OFFSET_STRUCT_POINT_Y = 1
__constant char OFFSET_STRUCT_VECTOR_Q = 2
__constant char * const SCREEN = (char *) 1024
__constant char SIZEOF_STRUCT_VECTOR = 4
void main()
__loadstore struct Vector main::v // zp[4]:2

zp[4]:2 [ main::v ]


FINAL ASSEMBLER
Score: 73

  // File Comments
// Minimal struct with C-Standard behavior - struct containing struct
  // Upstart
  // Commodore 64 PRG executable file
.file [name="struct-17.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_VECTOR = 4
  .const OFFSET_STRUCT_POINT_Y = 1
  .const OFFSET_STRUCT_VECTOR_Q = 2
  .label SCREEN = $400
.segment Code
  // main
main: {
    .label v = 2
    // __ma struct Vector v
    // [0] *(&main::v) = memset(struct Vector, SIZEOF_STRUCT_VECTOR) -- _deref_pssc1=_memset_vbuc2 
    ldy #SIZEOF_STRUCT_VECTOR
    lda #0
  !:
    dey
    sta v,y
    bne !-
    // v.p.x = 2
    // [1] *((char *)(struct Point *)&main::v) = 2 -- _deref_pbuc1=vbuc2 
    lda #2
    sta.z v
    // v.p.y = 3
    // [2] *((char *)(struct Point *)&main::v+OFFSET_STRUCT_POINT_Y) = 3 -- _deref_pbuc1=vbuc2 
    lda #3
    sta v+OFFSET_STRUCT_POINT_Y
    // v.q.x = 4
    // [3] *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q) = 4 -- _deref_pbuc1=vbuc2 
    lda #4
    sta v+OFFSET_STRUCT_VECTOR_Q
    // v.q.y = 5
    // [4] *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_Y) = 5 -- _deref_pbuc1=vbuc2 
    lda #5
    sta v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_Y
    // SCREEN[0] = v.p.x
    // [5] *SCREEN = *((char *)(struct Point *)&main::v) -- _deref_pbuc1=_deref_pbuc2 
    lda.z v
    sta SCREEN
    // SCREEN[1] = v.p.y
    // [6] *(SCREEN+1) = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_POINT_Y) -- _deref_pbuc1=_deref_pbuc2 
    lda v+OFFSET_STRUCT_POINT_Y
    sta SCREEN+1
    // SCREEN[2] = v.q.x
    // [7] *(SCREEN+2) = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q) -- _deref_pbuc1=_deref_pbuc2 
    lda v+OFFSET_STRUCT_VECTOR_Q
    sta SCREEN+2
    // SCREEN[3] = v.q.y
    // [8] *(SCREEN+3) = *((char *)(struct Point *)&main::v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_Y) -- _deref_pbuc1=_deref_pbuc2 
    lda v+OFFSET_STRUCT_VECTOR_Q+OFFSET_STRUCT_POINT_Y
    sta SCREEN+3
    // main::@return
    // }
    // [9] return 
    rts
}
  // File Data

