Setting inferred volatile on symbol affected by address-of main::$0 = call print((void *)&main::b)
Setting inferred volatile on symbol affected by address-of main::$1 = call print((void *)&main::w)
Setting inferred volatile on symbol affected by address-of main::$2 = call print((void *)&main::d)
Inlined call call __init

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start::@1
  idx#17 = phi( __start::@1/idx#18 )
  main::d = $12345678
  main::w = $1234
  main::b = $12
  print::ptr#0 = (void *)&main::b
  call print
  to:main::@1
main::@1: scope:[main]  from main
  idx#9 = phi( main/idx#5 )
  idx#0 = idx#9
  print::ptr#1 = (void *)&main::w
  call print
  to:main::@2
main::@2: scope:[main]  from main::@1
  idx#10 = phi( main::@1/idx#5 )
  idx#1 = idx#10
  print::ptr#2 = (void *)&main::d
  call print
  to:main::@3
main::@3: scope:[main]  from main::@2
  idx#11 = phi( main::@2/idx#5 )
  idx#2 = idx#11
  to:main::@return
main::@return: scope:[main]  from main::@3
  idx#12 = phi( main::@3/idx#2 )
  idx#3 = idx#12
  return 
  to:@return

void print(void *ptr)
print: scope:[print]  from main main::@1 main::@2
  idx#13 = phi( main/idx#17, main::@1/idx#0, main::@2/idx#1 )
  print::ptr#3 = phi( main/print::ptr#0, main::@1/print::ptr#1, main::@2/print::ptr#2 )
  SCREEN[idx#13] = *((char *)print::ptr#3)
  idx#4 = ++ idx#13
  to:print::@return
print::@return: scope:[print]  from print
  idx#14 = phi( print/idx#4 )
  idx#5 = idx#14
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  to:__start::__init1
__start::__init1: scope:[__start]  from __start
  idx#6 = 0
  to:__start::@1
__start::@1: scope:[__start]  from __start::__init1
  idx#18 = phi( __start::__init1/idx#6 )
  call main
  to:__start::@2
__start::@2: scope:[__start]  from __start::@1
  idx#15 = phi( __start::@1/idx#3 )
  idx#7 = idx#15
  to:__start::@return
__start::@return: scope:[__start]  from __start::@2
  idx#16 = phi( __start::@2/idx#7 )
  idx#8 = idx#16
  return 
  to:@return

SYMBOL TABLE SSA
__constant char * const SCREEN = (char *)$400
void __start()
char idx
char idx#0
char idx#1
char idx#10
char idx#11
char idx#12
char idx#13
char idx#14
char idx#15
char idx#16
char idx#17
char idx#18
char idx#2
char idx#3
char idx#4
char idx#5
char idx#6
char idx#7
char idx#8
char idx#9
void main()
__loadstore volatile char main::b
__loadstore volatile unsigned long main::d
__loadstore volatile unsigned int main::w
void print(void *ptr)
void *print::ptr
void *print::ptr#0
void *print::ptr#1
void *print::ptr#2
void *print::ptr#3

Simplifying constant pointer cast (char *) 1024
Successful SSA optimization PassNCastSimplification
Alias idx#0 = idx#9 
Alias idx#1 = idx#10 
Alias idx#11 = idx#2 idx#12 idx#3 
Alias idx#14 = idx#4 idx#5 
Alias idx#18 = idx#6 
Alias idx#15 = idx#7 idx#16 idx#8 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values idx#17 idx#18
Identical Phi Values idx#0 idx#14
Identical Phi Values idx#1 idx#14
Identical Phi Values idx#11 idx#14
Identical Phi Values idx#15 idx#11
Successful SSA optimization Pass2IdenticalPhiElimination
Constant print::ptr#0 = (void *)&main::b
Constant print::ptr#1 = (void *)&main::w
Constant print::ptr#2 = (void *)&main::d
Constant idx#18 = 0
Successful SSA optimization Pass2ConstantIdentification
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
Inlining constant with var siblings print::ptr#0
Inlining constant with var siblings print::ptr#1
Inlining constant with var siblings print::ptr#2
Inlining constant with var siblings idx#18
Constant inlined idx#18 = 0
Constant inlined print::ptr#2 = (void *)&main::d
Constant inlined print::ptr#0 = (void *)&main::b
Constant inlined print::ptr#1 = (void *)&main::w
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of main::@3
CALL GRAPH
Calls in [main] to print:3 print:5 print:7 

Created 2 initial phi equivalence classes
Coalesced [4] idx#19 = idx#14
Coalesced (already) [6] idx#20 = idx#14
Coalesced down to 2 phi equivalence classes
Culled Empty Block label main::@3
Adding NOP phi() at start of main::@1
Adding NOP phi() at start of main::@2

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] main::d = $12345678
  [1] main::w = $1234
  [2] main::b = $12
  [3] call print
  to:main::@1
main::@1: scope:[main]  from main
  [4] phi()
  [5] call print
  to:main::@2
main::@2: scope:[main]  from main::@1
  [6] phi()
  [7] call print
  to:main::@return
main::@return: scope:[main]  from main::@2
  [8] return 
  to:@return

void print(void *ptr)
print: scope:[print]  from main main::@1 main::@2
  [9] idx#13 = phi( main/0, main::@1/idx#14, main::@2/idx#14 )
  [9] print::ptr#3 = phi( main/(void *)&main::b, main::@1/(void *)&main::w, main::@2/(void *)&main::d )
  [10] SCREEN[idx#13] = *((char *)print::ptr#3)
  [11] idx#14 = ++ idx#13
  to:print::@return
print::@return: scope:[print]  from print
  [12] return 
  to:@return


VARIABLE REGISTER WEIGHTS
char idx
char idx#13 // 13.0
char idx#14 // 2.5
void main()
__loadstore volatile char main::b // 20.0
__loadstore volatile unsigned long main::d // 20.0
__loadstore volatile unsigned int main::w // 20.0
void print(void *ptr)
void *print::ptr
void *print::ptr#3

Initial phi equivalence classes
[ print::ptr#3 ]
[ idx#13 idx#14 ]
Added variable main::d to live range equivalence class [ main::d ]
Added variable main::w to live range equivalence class [ main::w ]
Added variable main::b to live range equivalence class [ main::b ]
Complete equivalence classes
[ print::ptr#3 ]
[ idx#13 idx#14 ]
[ main::d ]
[ main::w ]
[ main::b ]
Allocated zp[4]:2 [ main::d ]
Allocated zp[2]:6 [ main::w ]
Allocated zp[1]:8 [ main::b ]
Allocated zp[1]:9 [ idx#13 idx#14 ]
Allocated zp[2]:10 [ print::ptr#3 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] main::d = $12345678 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [1] main::w = $1234 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [2] main::b = $12 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [10] SCREEN[idx#13] = *((char *)print::ptr#3) [ idx#13 ] ( print:3 [ idx#13 ] { }  print:5 [ idx#13 ] { { idx#13 = idx#14 } }  print:7 [ idx#13 ] { { idx#13 = idx#14 } }  ) always clobbers reg byte a reg byte y 
Removing always clobbered register reg byte a as potential for zp[1]:9 [ idx#13 idx#14 ]
Removing always clobbered register reg byte y as potential for zp[1]:9 [ idx#13 idx#14 ]
Statement [0] main::d = $12345678 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [1] main::w = $1234 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [2] main::b = $12 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [10] SCREEN[idx#13] = *((char *)print::ptr#3) [ idx#13 ] ( print:3 [ idx#13 ] { }  print:5 [ idx#13 ] { { idx#13 = idx#14 } }  print:7 [ idx#13 ] { { idx#13 = idx#14 } }  ) always clobbers reg byte a reg byte y 
Potential registers zp[2]:10 [ print::ptr#3 ] : zp[2]:10 , 
Potential registers zp[1]:9 [ idx#13 idx#14 ] : zp[1]:9 , reg byte x , 
Potential registers zp[4]:2 [ main::d ] : zp[4]:2 , 
Potential registers zp[2]:6 [ main::w ] : zp[2]:6 , 
Potential registers zp[1]:8 [ main::b ] : zp[1]:8 , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 20: zp[4]:2 [ main::d ] 20: zp[2]:6 [ main::w ] 20: zp[1]:8 [ main::b ] 
Uplift Scope [] 15.5: zp[1]:9 [ idx#13 idx#14 ] 
Uplift Scope [print] 0: zp[2]:10 [ print::ptr#3 ] 

Uplifting [main] best 132 combination zp[4]:2 [ main::d ] zp[2]:6 [ main::w ] zp[1]:8 [ main::b ] 
Uplifting [] best 123 combination reg byte x [ idx#13 idx#14 ] 
Uplifting [print] best 123 combination zp[2]:10 [ print::ptr#3 ] 
Attempting to uplift remaining variables inzp[1]:8 [ main::b ]
Uplifting [main] best 123 combination zp[1]:8 [ main::b ] 
Allocated (was zp[2]:10) zp[2]:9 [ print::ptr#3 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test simple void pointer - void pointer function
  // Upstart
  // Commodore 64 PRG executable file
.file [name="pointer-void-2.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
  .label SCREEN = $400
.segment Code
  // main
main: {
    .label d = 2
    .label w = 6
    .label b = 8
    // [0] main::d = $12345678 -- vduz1=vduc1 
    lda #<$12345678
    sta.z d
    lda #>$12345678
    sta.z d+1
    lda #<$12345678>>$10
    sta.z d+2
    lda #>$12345678>>$10
    sta.z d+3
    // [1] main::w = $1234 -- vwuz1=vwuc1 
    lda #<$1234
    sta.z w
    lda #>$1234
    sta.z w+1
    // [2] main::b = $12 -- vbuz1=vbuc1 
    lda #$12
    sta.z b
    // [3] call print
    // [9] phi from main to print [phi:main->print]
  print_from_main:
    // [9] phi idx#13 = 0 [phi:main->print#0] -- vbuxx=vbuc1 
    ldx #0
    // [9] phi print::ptr#3 = (void *)&main::b [phi:main->print#1] -- pvoz1=pvoc1 
    lda #<b
    sta.z print.ptr
    lda #>b
    sta.z print.ptr+1
    jsr print
    // [4] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    jmp __b1
    // main::@1
  __b1:
    // [5] call print
    // [9] phi from main::@1 to print [phi:main::@1->print]
  print_from___b1:
    // [9] phi idx#13 = idx#14 [phi:main::@1->print#0] -- register_copy 
    // [9] phi print::ptr#3 = (void *)&main::w [phi:main::@1->print#1] -- pvoz1=pvoc1 
    lda #<w
    sta.z print.ptr
    lda #>w
    sta.z print.ptr+1
    jsr print
    // [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  __b2_from___b1:
    jmp __b2
    // main::@2
  __b2:
    // [7] call print
    // [9] phi from main::@2 to print [phi:main::@2->print]
  print_from___b2:
    // [9] phi idx#13 = idx#14 [phi:main::@2->print#0] -- register_copy 
    // [9] phi print::ptr#3 = (void *)&main::d [phi:main::@2->print#1] -- pvoz1=pvoc1 
    lda #<d
    sta.z print.ptr
    lda #>d
    sta.z print.ptr+1
    jsr print
    jmp __breturn
    // main::@return
  __breturn:
    // [8] return 
    rts
}
  // print
// void print(__zp(9) void *ptr)
print: {
    .label ptr = 9
    // [10] SCREEN[idx#13] = *((char *)print::ptr#3) -- pbuc1_derefidx_vbuxx=_deref_pbuz1 
    ldy #0
    lda (ptr),y
    sta SCREEN,x
    // [11] idx#14 = ++ idx#13 -- vbuxx=_inc_vbuxx 
    inx
    jmp __breturn
    // print::@return
  __breturn:
    // [12] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1_from_main:
Removing instruction print_from___b1:
Removing instruction __b2_from___b1:
Removing instruction print_from___b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction print_from_main:
Removing instruction __b1:
Removing instruction __b2:
Removing instruction __breturn:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
__constant char * const SCREEN = (char *) 1024
char idx
char idx#13 // reg byte x 13.0
char idx#14 // reg byte x 2.5
void main()
__loadstore volatile char main::b // zp[1]:8 20.0
__loadstore volatile unsigned long main::d // zp[4]:2 20.0
__loadstore volatile unsigned int main::w // zp[2]:6 20.0
void print(void *ptr)
void *print::ptr
void *print::ptr#3 // ptr zp[2]:9

zp[2]:9 [ print::ptr#3 ]
reg byte x [ idx#13 idx#14 ]
zp[4]:2 [ main::d ]
zp[2]:6 [ main::w ]
zp[1]:8 [ main::b ]


FINAL ASSEMBLER
Score: 111

  // File Comments
// Test simple void pointer - void pointer function
  // Upstart
  // Commodore 64 PRG executable file
.file [name="pointer-void-2.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
  .label SCREEN = $400
.segment Code
  // main
main: {
    .label d = 2
    .label w = 6
    .label b = 8
    // dword d = 0x12345678
    // [0] main::d = $12345678 -- vduz1=vduc1 
    lda #<$12345678
    sta.z d
    lda #>$12345678
    sta.z d+1
    lda #<$12345678>>$10
    sta.z d+2
    lda #>$12345678>>$10
    sta.z d+3
    // word w = 0x1234
    // [1] main::w = $1234 -- vwuz1=vwuc1 
    lda #<$1234
    sta.z w
    lda #>$1234
    sta.z w+1
    // byte b = 0x12
    // [2] main::b = $12 -- vbuz1=vbuc1 
    lda #$12
    sta.z b
    // print(&b)
    // [3] call print
    // [9] phi from main to print [phi:main->print]
    // [9] phi idx#13 = 0 [phi:main->print#0] -- vbuxx=vbuc1 
    ldx #0
    // [9] phi print::ptr#3 = (void *)&main::b [phi:main->print#1] -- pvoz1=pvoc1 
    lda #<b
    sta.z print.ptr
    lda #>b
    sta.z print.ptr+1
    jsr print
    // [4] phi from main to main::@1 [phi:main->main::@1]
    // main::@1
    // print(&w)
    // [5] call print
    // [9] phi from main::@1 to print [phi:main::@1->print]
    // [9] phi idx#13 = idx#14 [phi:main::@1->print#0] -- register_copy 
    // [9] phi print::ptr#3 = (void *)&main::w [phi:main::@1->print#1] -- pvoz1=pvoc1 
    lda #<w
    sta.z print.ptr
    lda #>w
    sta.z print.ptr+1
    jsr print
    // [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
    // main::@2
    // print(&d)
    // [7] call print
    // [9] phi from main::@2 to print [phi:main::@2->print]
    // [9] phi idx#13 = idx#14 [phi:main::@2->print#0] -- register_copy 
    // [9] phi print::ptr#3 = (void *)&main::d [phi:main::@2->print#1] -- pvoz1=pvoc1 
    lda #<d
    sta.z print.ptr
    lda #>d
    sta.z print.ptr+1
    jsr print
    // main::@return
    // }
    // [8] return 
    rts
}
  // print
// void print(__zp(9) void *ptr)
print: {
    .label ptr = 9
    // SCREEN[idx++] = *((byte*)ptr)
    // [10] SCREEN[idx#13] = *((char *)print::ptr#3) -- pbuc1_derefidx_vbuxx=_deref_pbuz1 
    ldy #0
    lda (ptr),y
    sta SCREEN,x
    // SCREEN[idx++] = *((byte*)ptr);
    // [11] idx#14 = ++ idx#13 -- vbuxx=_inc_vbuxx 
    inx
    // print::@return
    // }
    // [12] return 
    rts
}
  // File Data

