Inlined call call __init
Calling convention STACK_CALL adding prepare/execute/finalize for call *main::f 
Calling convention STACK_CALL adding prepare/execute/finalize for call *main::f 

CONTROL FLOW GRAPH SSA

void fn1()
fn1: scope:[fn1]  from
  idx = ++ idx
  to:fn1::@return
fn1::@return: scope:[fn1]  from fn1
  return 
  to:@return

void main()
main: scope:[main]  from __start::@1
  callexecute *main::f 
  to:main::@1
main::@1: scope:[main]  from main
  SCREEN[idx] = 'a'
  callexecute *main::f 
  to:main::@2
main::@2: scope:[main]  from main::@1
  SCREEN[idx] = 'a'
  to:main::@return
main::@return: scope:[main]  from main::@2
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  to:__start::__init1
__start::__init1: scope:[__start]  from __start
  idx = 0
  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 * const SCREEN = (char *)$400
void __start()
void fn1()
__loadstore volatile char idx
void main()
__constant void (*main::f)() = &fn1

Simplifying constant pointer cast (char *) 1024
Successful SSA optimization PassNCastSimplification
Replacing constant pointer function [2] callexecute fn1 
Replacing constant pointer function [4] callexecute fn1 
Successful SSA optimization Pass2ConstantCallPointerIdentification
Eliminating unused constant main::f
Successful SSA optimization PassNEliminateUnusedVars
Adding NOP phi() at start of __start
Adding NOP phi() at start of __start::@1
Adding NOP phi() at start of __start::@2
Adding NOP phi() at start of main
CALL GRAPH
Calls in [__start] to main:3 
Calls in [main] to fn1:9 fn1:11 

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block label __start::@2
Adding NOP phi() at start of __start
Adding NOP phi() at start of __start::@1
Adding NOP phi() at start of main

FINAL CONTROL FLOW GRAPH

void __start()
__start: scope:[__start]  from
  [0] phi()
  to:__start::__init1
__start::__init1: scope:[__start]  from __start
  [1] idx = 0
  to:__start::@1
__start::@1: scope:[__start]  from __start::__init1
  [2] phi()
  [3] call main
  to:__start::@return
__start::@return: scope:[__start]  from __start::@1
  [4] return 
  to:@return

__stackcall void fn1()
fn1: scope:[fn1]  from main main::@1
  [5] idx = ++ idx
  to:fn1::@return
fn1::@return: scope:[fn1]  from fn1
  [6] return 
  to:@return

void main()
main: scope:[main]  from __start::@1
  [7] phi()
  [8] callexecute fn1 
  to:main::@1
main::@1: scope:[main]  from main
  [9] SCREEN[idx] = 'a'
  [10] callexecute fn1 
  to:main::@2
main::@2: scope:[main]  from main::@1
  [11] SCREEN[idx] = 'a'
  to:main::@return
main::@return: scope:[main]  from main::@2
  [12] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void __start()
__stackcall void fn1()
__loadstore volatile char idx // 28.25
void main()

Initial phi equivalence classes
Added variable idx to live range equivalence class [ idx ]
Complete equivalence classes
[ idx ]
Allocated zp[1]:2 [ idx ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [1] idx = 0 [ idx ] (  [ idx ] { }  ) always clobbers reg byte a 
Statement [9] SCREEN[idx] = 'a' [ idx ] ( main:3 [ idx ] { }  ) always clobbers reg byte a reg byte y 
Statement [11] SCREEN[idx] = 'a' [ ] ( main:3 [ ] { }  ) always clobbers reg byte a reg byte y 
Potential registers zp[1]:2 [ idx ] : zp[1]:2 , 

REGISTER UPLIFT SCOPES
Uplift Scope [] 28.25: zp[1]:2 [ idx ] 
Uplift Scope [fn1] 
Uplift Scope [main] 
Uplift Scope [__start] 

Uplifting [] best 114 combination zp[1]:2 [ idx ] 
Uplifting [fn1] best 114 combination 
Uplifting [main] best 114 combination 
Uplifting [__start] best 114 combination 
Attempting to uplift remaining variables inzp[1]:2 [ idx ]
Uplifting [] best 114 combination zp[1]:2 [ idx ] 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests calling into a function pointer which modifies global volatile
  // Upstart
  // Commodore 64 PRG executable file
.file [name="function-pointer-noarg-call-9.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(__start)
  // Global Constants & labels
  .label SCREEN = $400
  .label idx = 2
.segment Code
  // __start
__start: {
    jmp __init1
    // __start::__init1
  __init1:
    // [1] idx = 0 -- vbuz1=vbuc1 
    lda #0
    sta.z idx
    // [2] phi from __start::__init1 to __start::@1 [phi:__start::__init1->__start::@1]
  __b1_from___init1:
    jmp __b1
    // __start::@1
  __b1:
    // [3] call main
    // [7] phi from __start::@1 to main [phi:__start::@1->main]
  main_from___b1:
    jsr main
    jmp __breturn
    // __start::@return
  __breturn:
    // [4] return 
    rts
}
  // fn1
fn1: {
    // [5] idx = ++ idx -- vbuz1=_inc_vbuz1 
    inc.z idx
    jmp __breturn
    // fn1::@return
  __breturn:
    // [6] return 
    rts
}
  // main
main: {
    // [8] callexecute fn1  -- call_vprc1 
    jsr fn1
    jmp __b1
    // main::@1
  __b1:
    // [9] SCREEN[idx] = 'a' -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #'a'
    ldy.z idx
    sta SCREEN,y
    // [10] callexecute fn1  -- call_vprc1 
    jsr fn1
    jmp __b2
    // main::@2
  __b2:
    // [11] SCREEN[idx] = 'a' -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #'a'
    ldy.z idx
    sta SCREEN,y
    jmp __breturn
    // main::@return
  __breturn:
    // [12] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __init1
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1_from___init1:
Removing instruction main_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __init1:
Removing instruction __b1:
Removing instruction __breturn:
Removing instruction __breturn:
Removing instruction __b1:
Removing instruction __b2:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
__constant char * const SCREEN = (char *) 1024
void __start()
__stackcall void fn1()
__loadstore volatile char idx // zp[1]:2 28.25
void main()

zp[1]:2 [ idx ]


FINAL ASSEMBLER
Score: 66

  // File Comments
// Tests calling into a function pointer which modifies global volatile
  // Upstart
  // Commodore 64 PRG executable file
.file [name="function-pointer-noarg-call-9.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(__start)
  // Global Constants & labels
  .label SCREEN = $400
  .label idx = 2
.segment Code
  // __start
__start: {
    // __start::__init1
    // volatile byte idx = 0
    // [1] idx = 0 -- vbuz1=vbuc1 
    lda #0
    sta.z idx
    // [2] phi from __start::__init1 to __start::@1 [phi:__start::__init1->__start::@1]
    // __start::@1
    // [3] call main
    // [7] phi from __start::@1 to main [phi:__start::@1->main]
    jsr main
    // __start::@return
    // [4] return 
    rts
}
  // fn1
fn1: {
    // idx++;
    // [5] idx = ++ idx -- vbuz1=_inc_vbuz1 
    inc.z idx
    // fn1::@return
    // }
    // [6] return 
    rts
}
  // main
main: {
    // (*f)()
    // [8] callexecute fn1  -- call_vprc1 
    jsr fn1
    // main::@1
    // SCREEN[idx] = 'a'
    // [9] SCREEN[idx] = 'a' -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #'a'
    ldy.z idx
    sta SCREEN,y
    // (*f)()
    // [10] callexecute fn1  -- call_vprc1 
    jsr fn1
    // main::@2
    // SCREEN[idx] = 'a'
    // [11] SCREEN[idx] = 'a' -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #'a'
    ldy.z idx
    sta SCREEN,y
    // main::@return
    // }
    // [12] return 
    rts
}
  // File Data

