Inlined call call __init

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start::@1
  main::points#0 = POINTS
  main::i#0 = 0
  to:main::@1
main::@1: scope:[main]  from main main::@1
  main::i#2 = phi( main/main::i#0, main::@1/main::i#1 )
  main::points#4 = phi( main/main::points#0, main::@1/main::points#1 )
  main::$7 = (char *)main::points#4
  main::$3 = main::$7 + OFFSET_STRUCT_POINT_X
  *main::$3 = main::i#2
  main::$0 = main::i#2 + 5
  main::$8 = (char *)main::points#4
  main::$4 = main::$8 + OFFSET_STRUCT_POINT_Y
  *main::$4 = main::$0
  main::points#1 = main::points#4 + SIZEOF_STRUCT_POINT
  main::i#1 = main::i#2 + rangenext(0,3)
  main::$1 = main::i#1 != rangelast(0,3)
  if(main::$1) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1
  main::idx#0 = 0
  main::points#2 = POINTS
  main::i1#0 = 0
  to:main::@3
main::@3: scope:[main]  from main::@2 main::@3
  main::i1#2 = phi( main::@2/main::i1#0, main::@3/main::i1#1 )
  main::idx#4 = phi( main::@2/main::idx#0, main::@3/main::idx#3 )
  main::points#5 = phi( main::@2/main::points#2, main::@3/main::points#3 )
  main::$9 = (char *)main::points#5
  main::$5 = main::$9 + OFFSET_STRUCT_POINT_X
  main::SCREEN[main::idx#4] = *main::$5
  main::idx#1 = ++ main::idx#4
  main::$10 = (char *)main::points#5
  main::$6 = main::$10 + OFFSET_STRUCT_POINT_Y
  main::SCREEN[main::idx#1] = *main::$6
  main::idx#2 = ++ main::idx#1
  main::SCREEN[main::idx#2] = ' '
  main::idx#3 = ++ main::idx#2
  main::points#3 = main::points#5 + SIZEOF_STRUCT_POINT
  main::i1#1 = main::i1#2 + rangenext(0,3)
  main::$2 = main::i1#1 != rangelast(0,3)
  if(main::$2) goto main::@3
  to:main::@return
main::@return: scope:[main]  from main::@3
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  to:__start::__init1
__start::__init1: scope:[__start]  from __start
  to:__start::@1
__start::@1: scope:[__start]  from __start::__init1
  call main
  to:__start::@2
__start::@2: scope:[__start]  from __start::@1
  to:__start::@return
__start::@return: scope:[__start]  from __start::@2
  return 
  to:@return

SYMBOL TABLE SSA
__constant char OFFSET_STRUCT_POINT_X = 0
__constant char OFFSET_STRUCT_POINT_Y = 1
__constant struct Point *POINTS = (struct Point *)$1000
__constant char SIZEOF_STRUCT_POINT = 2
void __start()
void main()
number main::$0
bool main::$1
char *main::$10
bool main::$2
char *main::$3
char *main::$4
char *main::$5
char *main::$6
char *main::$7
char *main::$8
char *main::$9
__constant char * const main::SCREEN = (char *)$400
char main::i
char main::i#0
char main::i#1
char main::i#2
char main::i1
char main::i1#0
char main::i1#1
char main::i1#2
char main::idx
char main::idx#0
char main::idx#1
char main::idx#2
char main::idx#3
char main::idx#4
struct Point *main::points
struct Point *main::points#0
struct Point *main::points#1
struct Point *main::points#2
struct Point *main::points#3
struct Point *main::points#4
struct Point *main::points#5

Adding number conversion cast (unumber) 5 in main::$0 = main::i#2 + 5
Adding number conversion cast (unumber) main::$0 in main::$0 = main::i#2 + (unumber)5
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (char *) 1024
Simplifying constant pointer cast (struct Point *) 4096
Simplifying constant integer cast 5
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 5
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to char in main::$0 = main::i#2 + 5
Simple Condition main::$1 [13] if(main::i#1!=rangelast(0,3)) goto main::@1
Simple Condition main::$2 [31] if(main::i1#1!=rangelast(0,3)) goto main::@3
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant main::points#0 = POINTS
Constant main::i#0 = 0
Constant main::idx#0 = 0
Constant main::points#2 = POINTS
Constant main::i1#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [11] main::i#1 = ++ main::i#2 to ++
Resolved ranged comparison value [13] if(main::i#1!=rangelast(0,3)) goto main::@1 to 4
Resolved ranged next value [29] main::i1#1 = ++ main::i1#2 to ++
Resolved ranged comparison value [31] if(main::i1#1!=rangelast(0,3)) goto main::@3 to 4
Converting *(pointer+n) to pointer[n] [5] *main::$3 = main::i#2  -- main::$7[OFFSET_STRUCT_POINT_X]
Converting *(pointer+n) to pointer[n] [9] *main::$4 = main::$0  -- main::$8[OFFSET_STRUCT_POINT_Y]
Converting *(pointer+n) to pointer[n] [20] main::SCREEN[main::idx#4] = *main::$5  -- main::$9[OFFSET_STRUCT_POINT_X]
Converting *(pointer+n) to pointer[n] [24] main::SCREEN[main::idx#1] = *main::$6  -- main::$10[OFFSET_STRUCT_POINT_Y]
Successful SSA optimization Pass2InlineDerefIdx
Simplifying expression containing zero main::$7 in [4] main::$3 = main::$7 + OFFSET_STRUCT_POINT_X
Simplifying expression containing zero main::$7 in [5] main::$7[OFFSET_STRUCT_POINT_X] = main::i#2
Simplifying expression containing zero main::$9 in [19] main::$5 = main::$9 + OFFSET_STRUCT_POINT_X
Simplifying expression containing zero main::$9 in [20] main::SCREEN[main::idx#4] = main::$9[OFFSET_STRUCT_POINT_X]
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable main::$3 and assignment [2] main::$3 = main::$7
Eliminating unused variable main::$4 and assignment [6] main::$4 = main::$8 + OFFSET_STRUCT_POINT_Y
Eliminating unused variable main::$5 and assignment [13] main::$5 = main::$9
Eliminating unused variable main::$6 and assignment [17] main::$6 = main::$10 + OFFSET_STRUCT_POINT_Y
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::__init1
Removing unused procedure block __start::@1
Removing unused procedure block __start::@2
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Adding number conversion cast (unumber) 4 in [8] if(main::i#1!=4) goto main::@1
Adding number conversion cast (unumber) 4 in [20] if(main::i1#1!=4) goto main::@3
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 4
Simplifying constant integer cast 4
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 4
Finalized unsigned number type (char) 4
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inlining Noop Cast [1] main::$7 = (char *)main::points#4 keeping main::points#4
Inlining Noop Cast [4] main::$8 = (char *)main::points#4 keeping main::points#4
Inlining Noop Cast [10] main::$9 = (char *)main::points#5 keeping main::points#5
Inlining Noop Cast [13] main::$10 = (char *)main::points#5 keeping main::points#5
Successful SSA optimization Pass2NopCastInlining
Inlining constant with var siblings main::points#0
Inlining constant with var siblings main::i#0
Inlining constant with var siblings main::idx#0
Inlining constant with var siblings main::points#2
Inlining constant with var siblings main::i1#0
Constant inlined main::points#2 = POINTS
Constant inlined main::i#0 = 0
Constant inlined main::i1#0 = 0
Constant inlined main::idx#0 = 0
Constant inlined main::points#0 = POINTS
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@4(between main::@1 and main::@1)
Added new block during phi lifting main::@5(between main::@3 and main::@3)
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@2
CALL GRAPH

Created 5 initial phi equivalence classes
Coalesced [20] main::points#7 = main::points#3
Coalesced [21] main::idx#5 = main::idx#3
Coalesced [22] main::i1#3 = main::i1#1
Coalesced [23] main::points#6 = main::points#1
Coalesced [24] main::i#3 = main::i#1
Coalesced down to 5 phi equivalence classes
Culled Empty Block label main::@2
Culled Empty Block label main::@5
Culled Empty Block label main::@4
Renumbering block main::@3 to main::@2
Adding NOP phi() at start of main

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@1
  [1] main::i#2 = phi( main/0, main::@1/main::i#1 )
  [1] main::points#4 = phi( main/POINTS, main::@1/main::points#1 )
  [2] *((char *)main::points#4) = main::i#2
  [3] main::$0 = main::i#2 + 5
  [4] ((char *)main::points#4)[OFFSET_STRUCT_POINT_Y] = main::$0
  [5] main::points#1 = main::points#4 + SIZEOF_STRUCT_POINT
  [6] main::i#1 = ++ main::i#2
  [7] if(main::i#1!=4) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@2
  [8] main::i1#2 = phi( main::@1/0, main::@2/main::i1#1 )
  [8] main::idx#4 = phi( main::@1/0, main::@2/main::idx#3 )
  [8] main::points#5 = phi( main::@1/POINTS, main::@2/main::points#3 )
  [9] main::SCREEN[main::idx#4] = *((char *)main::points#5)
  [10] main::idx#1 = ++ main::idx#4
  [11] main::SCREEN[main::idx#1] = ((char *)main::points#5)[OFFSET_STRUCT_POINT_Y]
  [12] main::idx#2 = ++ main::idx#1
  [13] main::SCREEN[main::idx#2] = ' '
  [14] main::idx#3 = ++ main::idx#2
  [15] main::points#3 = main::points#5 + SIZEOF_STRUCT_POINT
  [16] main::i1#1 = ++ main::i1#2
  [17] if(main::i1#1!=4) goto main::@2
  to:main::@return
main::@return: scope:[main]  from main::@2
  [18] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
char main::$0 // 22.0
char main::i
char main::i#1 // 16.5
char main::i#2 // 8.8
char main::i1
char main::i1#1 // 16.5
char main::i1#2 // 2.75
char main::idx
char main::idx#1 // 16.5
char main::idx#2 // 16.5
char main::idx#3 // 5.5
char main::idx#4 // 16.5
struct Point *main::points
struct Point *main::points#1 // 7.333333333333333
struct Point *main::points#3 // 7.333333333333333
struct Point *main::points#4 // 5.5
struct Point *main::points#5 // 3.142857142857143

Initial phi equivalence classes
[ main::points#4 main::points#1 ]
[ main::i#2 main::i#1 ]
[ main::points#5 main::points#3 ]
[ main::idx#4 main::idx#3 ]
[ main::i1#2 main::i1#1 ]
Added variable main::$0 to live range equivalence class [ main::$0 ]
Added variable main::idx#1 to live range equivalence class [ main::idx#1 ]
Added variable main::idx#2 to live range equivalence class [ main::idx#2 ]
Complete equivalence classes
[ main::points#4 main::points#1 ]
[ main::i#2 main::i#1 ]
[ main::points#5 main::points#3 ]
[ main::idx#4 main::idx#3 ]
[ main::i1#2 main::i1#1 ]
[ main::$0 ]
[ main::idx#1 ]
[ main::idx#2 ]
Allocated zp[1]:2 [ main::i#2 main::i#1 ]
Allocated zp[1]:3 [ main::idx#4 main::idx#3 ]
Allocated zp[1]:4 [ main::$0 ]
Allocated zp[1]:5 [ main::i1#2 main::i1#1 ]
Allocated zp[1]:6 [ main::idx#1 ]
Allocated zp[1]:7 [ main::idx#2 ]
Allocated zp[2]:8 [ main::points#4 main::points#1 ]
Allocated zp[2]:10 [ main::points#5 main::points#3 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [2] *((char *)main::points#4) = main::i#2 [ main::points#4 main::i#2 ] (  [ main::points#4 main::i#2 ] { }  ) always clobbers reg byte y 
Removing always clobbered register reg byte y as potential for zp[1]:2 [ main::i#2 main::i#1 ]
Statement [4] ((char *)main::points#4)[OFFSET_STRUCT_POINT_Y] = main::$0 [ main::points#4 main::i#2 ] (  [ main::points#4 main::i#2 ] { }  ) always clobbers reg byte y 
Statement [5] main::points#1 = main::points#4 + SIZEOF_STRUCT_POINT [ main::i#2 main::points#1 ] (  [ main::i#2 main::points#1 ] { }  ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::i#2 main::i#1 ]
Statement [9] main::SCREEN[main::idx#4] = *((char *)main::points#5) [ main::points#5 main::idx#4 main::i1#2 ] (  [ main::points#5 main::idx#4 main::i1#2 ] { }  ) always clobbers reg byte a reg byte y 
Removing always clobbered register reg byte a as potential for zp[1]:3 [ main::idx#4 main::idx#3 ]
Removing always clobbered register reg byte y as potential for zp[1]:3 [ main::idx#4 main::idx#3 ]
Removing always clobbered register reg byte a as potential for zp[1]:5 [ main::i1#2 main::i1#1 ]
Removing always clobbered register reg byte y as potential for zp[1]:5 [ main::i1#2 main::i1#1 ]
Statement [11] main::SCREEN[main::idx#1] = ((char *)main::points#5)[OFFSET_STRUCT_POINT_Y] [ main::points#5 main::i1#2 main::idx#1 ] (  [ main::points#5 main::i1#2 main::idx#1 ] { }  ) always clobbers reg byte a reg byte y 
Removing always clobbered register reg byte a as potential for zp[1]:6 [ main::idx#1 ]
Removing always clobbered register reg byte y as potential for zp[1]:6 [ main::idx#1 ]
Statement [13] main::SCREEN[main::idx#2] = ' ' [ main::points#5 main::i1#2 main::idx#2 ] (  [ main::points#5 main::i1#2 main::idx#2 ] { }  ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:7 [ main::idx#2 ]
Statement [15] main::points#3 = main::points#5 + SIZEOF_STRUCT_POINT [ main::i1#2 main::points#3 main::idx#3 ] (  [ main::i1#2 main::points#3 main::idx#3 ] { }  ) always clobbers reg byte a 
Statement [2] *((char *)main::points#4) = main::i#2 [ main::points#4 main::i#2 ] (  [ main::points#4 main::i#2 ] { }  ) always clobbers reg byte a reg byte y 
Statement [3] main::$0 = main::i#2 + 5 [ main::points#4 main::i#2 main::$0 ] (  [ main::points#4 main::i#2 main::$0 ] { }  ) always clobbers reg byte a 
Statement [4] ((char *)main::points#4)[OFFSET_STRUCT_POINT_Y] = main::$0 [ main::points#4 main::i#2 ] (  [ main::points#4 main::i#2 ] { }  ) always clobbers reg byte y 
Statement [5] main::points#1 = main::points#4 + SIZEOF_STRUCT_POINT [ main::i#2 main::points#1 ] (  [ main::i#2 main::points#1 ] { }  ) always clobbers reg byte a 
Statement [9] main::SCREEN[main::idx#4] = *((char *)main::points#5) [ main::points#5 main::idx#4 main::i1#2 ] (  [ main::points#5 main::idx#4 main::i1#2 ] { }  ) always clobbers reg byte a reg byte y 
Statement [11] main::SCREEN[main::idx#1] = ((char *)main::points#5)[OFFSET_STRUCT_POINT_Y] [ main::points#5 main::i1#2 main::idx#1 ] (  [ main::points#5 main::i1#2 main::idx#1 ] { }  ) always clobbers reg byte a reg byte y 
Statement [13] main::SCREEN[main::idx#2] = ' ' [ main::points#5 main::i1#2 main::idx#2 ] (  [ main::points#5 main::i1#2 main::idx#2 ] { }  ) always clobbers reg byte a 
Statement [15] main::points#3 = main::points#5 + SIZEOF_STRUCT_POINT [ main::i1#2 main::points#3 main::idx#3 ] (  [ main::i1#2 main::points#3 main::idx#3 ] { }  ) always clobbers reg byte a 
Potential registers zp[2]:8 [ main::points#4 main::points#1 ] : zp[2]:8 , 
Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte x , 
Potential registers zp[2]:10 [ main::points#5 main::points#3 ] : zp[2]:10 , 
Potential registers zp[1]:3 [ main::idx#4 main::idx#3 ] : zp[1]:3 , reg byte x , 
Potential registers zp[1]:5 [ main::i1#2 main::i1#1 ] : zp[1]:5 , reg byte x , 
Potential registers zp[1]:4 [ main::$0 ] : zp[1]:4 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:6 [ main::idx#1 ] : zp[1]:6 , reg byte x , 
Potential registers zp[1]:7 [ main::idx#2 ] : zp[1]:7 , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 25.3: zp[1]:2 [ main::i#2 main::i#1 ] 22: zp[1]:3 [ main::idx#4 main::idx#3 ] 22: zp[1]:4 [ main::$0 ] 19.25: zp[1]:5 [ main::i1#2 main::i1#1 ] 16.5: zp[1]:6 [ main::idx#1 ] 16.5: zp[1]:7 [ main::idx#2 ] 12.83: zp[2]:8 [ main::points#4 main::points#1 ] 10.48: zp[2]:10 [ main::points#5 main::points#3 ] 
Uplift Scope [Point] 
Uplift Scope [] 

Uplifting [main] best 1696 combination reg byte x [ main::i#2 main::i#1 ] reg byte x [ main::idx#4 main::idx#3 ] reg byte a [ main::$0 ] zp[1]:5 [ main::i1#2 main::i1#1 ] reg byte x [ main::idx#1 ] zp[1]:7 [ main::idx#2 ] zp[2]:8 [ main::points#4 main::points#1 ] zp[2]:10 [ main::points#5 main::points#3 ] 
Limited combination testing to 100 combinations of 192 possible.
Uplifting [Point] best 1696 combination 
Uplifting [] best 1696 combination 
Attempting to uplift remaining variables inzp[1]:5 [ main::i1#2 main::i1#1 ]
Uplifting [main] best 1696 combination zp[1]:5 [ main::i1#2 main::i1#1 ] 
Attempting to uplift remaining variables inzp[1]:7 [ main::idx#2 ]
Uplifting [main] best 1606 combination reg byte x [ main::idx#2 ] 
Allocated (was zp[1]:5) zp[1]:2 [ main::i1#2 main::i1#1 ]
Allocated (was zp[2]:8) zp[2]:3 [ main::points#4 main::points#1 ]
Allocated (was zp[2]:10) zp[2]:5 [ main::points#5 main::points#3 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Minimal struct - accessing pointer to struct  in memory in a loop
  // Upstart
  // Commodore 64 PRG executable file
.file [name="struct-ptr-4.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_POINT = 2
  .const OFFSET_STRUCT_POINT_Y = 1
  .label POINTS = $1000
.segment Code
  // main
main: {
    // Print points
    .label SCREEN = $400
    // Fill points
    .label points = 3
    // Fill points
    .label points_1 = 5
    .label i1 = 2
    // [1] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [1] phi main::i#2 = 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // [1] phi main::points#4 = POINTS [phi:main->main::@1#1] -- pssz1=pssc1 
    lda #<POINTS
    sta.z points
    lda #>POINTS
    sta.z points+1
    jmp __b1
    // [1] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  __b1_from___b1:
    // [1] phi main::i#2 = main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    // [1] phi main::points#4 = main::points#1 [phi:main::@1->main::@1#1] -- register_copy 
    jmp __b1
    // main::@1
  __b1:
    // [2] *((char *)main::points#4) = main::i#2 -- _deref_pbuz1=vbuxx 
    txa
    ldy #0
    sta (points),y
    // [3] main::$0 = main::i#2 + 5 -- vbuaa=vbuxx_plus_vbuc1 
    txa
    clc
    adc #5
    // [4] ((char *)main::points#4)[OFFSET_STRUCT_POINT_Y] = main::$0 -- pbuz1_derefidx_vbuc1=vbuaa 
    ldy #OFFSET_STRUCT_POINT_Y
    sta (points),y
    // [5] main::points#1 = main::points#4 + SIZEOF_STRUCT_POINT -- pssz1=pssz1_plus_vbuc1 
    lda #SIZEOF_STRUCT_POINT
    clc
    adc.z points
    sta.z points
    bcc !+
    inc.z points+1
  !:
    // [6] main::i#1 = ++ main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [7] if(main::i#1!=4) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #4
    bne __b1_from___b1
    // [8] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  __b2_from___b1:
    // [8] phi main::i1#2 = 0 [phi:main::@1->main::@2#0] -- vbuz1=vbuc1 
    lda #0
    sta.z i1
    // [8] phi main::idx#4 = 0 [phi:main::@1->main::@2#1] -- vbuxx=vbuc1 
    ldx #0
    // [8] phi main::points#5 = POINTS [phi:main::@1->main::@2#2] -- pssz1=pssc1 
    lda #<POINTS
    sta.z points_1
    lda #>POINTS
    sta.z points_1+1
    jmp __b2
    // [8] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
  __b2_from___b2:
    // [8] phi main::i1#2 = main::i1#1 [phi:main::@2->main::@2#0] -- register_copy 
    // [8] phi main::idx#4 = main::idx#3 [phi:main::@2->main::@2#1] -- register_copy 
    // [8] phi main::points#5 = main::points#3 [phi:main::@2->main::@2#2] -- register_copy 
    jmp __b2
    // main::@2
  __b2:
    // [9] main::SCREEN[main::idx#4] = *((char *)main::points#5) -- pbuc1_derefidx_vbuxx=_deref_pbuz1 
    ldy #0
    lda (points_1),y
    sta SCREEN,x
    // [10] main::idx#1 = ++ main::idx#4 -- vbuxx=_inc_vbuxx 
    inx
    // [11] main::SCREEN[main::idx#1] = ((char *)main::points#5)[OFFSET_STRUCT_POINT_Y] -- pbuc1_derefidx_vbuxx=pbuz1_derefidx_vbuc2 
    ldy #OFFSET_STRUCT_POINT_Y
    lda (points_1),y
    sta SCREEN,x
    // [12] main::idx#2 = ++ main::idx#1 -- vbuxx=_inc_vbuxx 
    inx
    // [13] main::SCREEN[main::idx#2] = ' ' -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #' '
    sta SCREEN,x
    // [14] main::idx#3 = ++ main::idx#2 -- vbuxx=_inc_vbuxx 
    inx
    // [15] main::points#3 = main::points#5 + SIZEOF_STRUCT_POINT -- pssz1=pssz1_plus_vbuc1 
    lda #SIZEOF_STRUCT_POINT
    clc
    adc.z points_1
    sta.z points_1
    bcc !+
    inc.z points_1+1
  !:
    // [16] main::i1#1 = ++ main::i1#2 -- vbuz1=_inc_vbuz1 
    inc.z i1
    // [17] if(main::i1#1!=4) goto main::@2 -- vbuz1_neq_vbuc1_then_la1 
    lda #4
    cmp.z i1
    bne __b2_from___b2
    jmp __breturn
    // main::@return
  __breturn:
    // [18] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing instruction ldx #0 with TAX
Replacing label __b1_from___b1 with __b1
Replacing label __b2_from___b2 with __b2
Removing instruction __b1_from___b1:
Removing instruction __b2_from___b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1_from_main:
Removing instruction __b2_from___b1:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jmp __b1
Removing instruction jmp __b2
Succesful ASM optimization Pass5NextJumpElimination

FINAL SYMBOL TABLE
__constant char OFFSET_STRUCT_POINT_Y = 1
__constant struct Point *POINTS = (struct Point *) 4096
__constant char SIZEOF_STRUCT_POINT = 2
void main()
char main::$0 // reg byte a 22.0
__constant char * const main::SCREEN = (char *) 1024
char main::i
char main::i#1 // reg byte x 16.5
char main::i#2 // reg byte x 8.8
char main::i1
char main::i1#1 // i1 zp[1]:2 16.5
char main::i1#2 // i1 zp[1]:2 2.75
char main::idx
char main::idx#1 // reg byte x 16.5
char main::idx#2 // reg byte x 16.5
char main::idx#3 // reg byte x 5.5
char main::idx#4 // reg byte x 16.5
struct Point *main::points
struct Point *main::points#1 // points zp[2]:3 7.333333333333333
struct Point *main::points#3 // points_1 zp[2]:5 7.333333333333333
struct Point *main::points#4 // points zp[2]:3 5.5
struct Point *main::points#5 // points_1 zp[2]:5 3.142857142857143

zp[2]:3 [ main::points#4 main::points#1 ]
reg byte x [ main::i#2 main::i#1 ]
zp[2]:5 [ main::points#5 main::points#3 ]
reg byte x [ main::idx#4 main::idx#3 ]
zp[1]:2 [ main::i1#2 main::i1#1 ]
reg byte a [ main::$0 ]
reg byte x [ main::idx#1 ]
reg byte x [ main::idx#2 ]


FINAL ASSEMBLER
Score: 1456

  // File Comments
// Minimal struct - accessing pointer to struct  in memory in a loop
  // Upstart
  // Commodore 64 PRG executable file
.file [name="struct-ptr-4.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_POINT = 2
  .const OFFSET_STRUCT_POINT_Y = 1
  .label POINTS = $1000
.segment Code
  // main
main: {
    // Print points
    .label SCREEN = $400
    // Fill points
    .label points = 3
    // Fill points
    .label points_1 = 5
    .label i1 = 2
    // [1] phi from main to main::@1 [phi:main->main::@1]
    // [1] phi main::i#2 = 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // [1] phi main::points#4 = POINTS [phi:main->main::@1#1] -- pssz1=pssc1 
    lda #<POINTS
    sta.z points
    lda #>POINTS
    sta.z points+1
    // [1] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
    // [1] phi main::i#2 = main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    // [1] phi main::points#4 = main::points#1 [phi:main::@1->main::@1#1] -- register_copy 
    // main::@1
  __b1:
    // (*points).x = i
    // [2] *((char *)main::points#4) = main::i#2 -- _deref_pbuz1=vbuxx 
    txa
    ldy #0
    sta (points),y
    // i+5
    // [3] main::$0 = main::i#2 + 5 -- vbuaa=vbuxx_plus_vbuc1 
    txa
    clc
    adc #5
    // (*points).y = i+5
    // [4] ((char *)main::points#4)[OFFSET_STRUCT_POINT_Y] = main::$0 -- pbuz1_derefidx_vbuc1=vbuaa 
    ldy #OFFSET_STRUCT_POINT_Y
    sta (points),y
    // points++;
    // [5] main::points#1 = main::points#4 + SIZEOF_STRUCT_POINT -- pssz1=pssz1_plus_vbuc1 
    lda #SIZEOF_STRUCT_POINT
    clc
    adc.z points
    sta.z points
    bcc !+
    inc.z points+1
  !:
    // for( byte i: 0..3)
    // [6] main::i#1 = ++ main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [7] if(main::i#1!=4) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #4
    bne __b1
    // [8] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
    // [8] phi main::i1#2 = 0 [phi:main::@1->main::@2#0] -- vbuz1=vbuc1 
    lda #0
    sta.z i1
    // [8] phi main::idx#4 = 0 [phi:main::@1->main::@2#1] -- vbuxx=vbuc1 
    tax
    // [8] phi main::points#5 = POINTS [phi:main::@1->main::@2#2] -- pssz1=pssc1 
    lda #<POINTS
    sta.z points_1
    lda #>POINTS
    sta.z points_1+1
    // [8] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
    // [8] phi main::i1#2 = main::i1#1 [phi:main::@2->main::@2#0] -- register_copy 
    // [8] phi main::idx#4 = main::idx#3 [phi:main::@2->main::@2#1] -- register_copy 
    // [8] phi main::points#5 = main::points#3 [phi:main::@2->main::@2#2] -- register_copy 
    // main::@2
  __b2:
    // SCREEN[idx++] = (*points).x
    // [9] main::SCREEN[main::idx#4] = *((char *)main::points#5) -- pbuc1_derefidx_vbuxx=_deref_pbuz1 
    ldy #0
    lda (points_1),y
    sta SCREEN,x
    // SCREEN[idx++] = (*points).x;
    // [10] main::idx#1 = ++ main::idx#4 -- vbuxx=_inc_vbuxx 
    inx
    // SCREEN[idx++] = (*points).y
    // [11] main::SCREEN[main::idx#1] = ((char *)main::points#5)[OFFSET_STRUCT_POINT_Y] -- pbuc1_derefidx_vbuxx=pbuz1_derefidx_vbuc2 
    ldy #OFFSET_STRUCT_POINT_Y
    lda (points_1),y
    sta SCREEN,x
    // SCREEN[idx++] = (*points).y;
    // [12] main::idx#2 = ++ main::idx#1 -- vbuxx=_inc_vbuxx 
    inx
    // SCREEN[idx++] = ' '
    // [13] main::SCREEN[main::idx#2] = ' ' -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #' '
    sta SCREEN,x
    // SCREEN[idx++] = ' ';
    // [14] main::idx#3 = ++ main::idx#2 -- vbuxx=_inc_vbuxx 
    inx
    // points++;
    // [15] main::points#3 = main::points#5 + SIZEOF_STRUCT_POINT -- pssz1=pssz1_plus_vbuc1 
    lda #SIZEOF_STRUCT_POINT
    clc
    adc.z points_1
    sta.z points_1
    bcc !+
    inc.z points_1+1
  !:
    // for( byte i: 0..3)
    // [16] main::i1#1 = ++ main::i1#2 -- vbuz1=_inc_vbuz1 
    inc.z i1
    // [17] if(main::i1#1!=4) goto main::@2 -- vbuz1_neq_vbuc1_then_la1 
    lda #4
    cmp.z i1
    bne __b2
    // main::@return
    // }
    // [18] return 
    rts
}
  // File Data

