Calling convention STACK_CALL adding prepare/execute/finalize for call *main::fn 
Calling convention STACK_CALL adding prepare/execute/finalize for call *main::fn 

CONTROL FLOW GRAPH SSA

void myFunc()
myFunc: scope:[myFunc]  from
  *myFunc::BORDER_COLOR = ++ *myFunc::BORDER_COLOR
  to:myFunc::@return
myFunc::@return: scope:[myFunc]  from myFunc
  return 
  to:@return

void myFunc2()
myFunc2: scope:[myFunc2]  from
  *myFunc2::BG_COLOR = ++ *myFunc2::BG_COLOR
  to:myFunc2::@return
myFunc2::@return: scope:[myFunc2]  from myFunc2
  return 
  to:@return

void main()
main: scope:[main]  from __start
  main::$2 = 0 * SIZEOF_POINTER
  addrtable[main::$2] = &myFunc
  main::$3 = 1 * SIZEOF_POINTER
  addrtable[main::$3] = &myFunc2
  main::$4 = 0 * SIZEOF_POINTER
  main::fn#0 = addrtable[main::$4]
  callexecute *main::fn#0 
  to:main::@1
main::@1: scope:[main]  from main
  main::$5 = 1 * SIZEOF_POINTER
  main::fn#1 = addrtable[main::$5]
  callexecute *main::fn#1 
  to:main::@return
main::@return: scope:[main]  from main::@1
  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 SIZEOF_POINTER = 2
void __start()
__constant void (*addrtable[$100])() = { fill( $100, 0) }
void main()
number main::$2
number main::$3
number main::$4
number main::$5
void (*main::fn)()
void (*main::fn#0)()
void (*main::fn#1)()
void myFunc()
__constant char * const myFunc::BORDER_COLOR = (char *)$d020
void myFunc2()
__constant char * const myFunc2::BG_COLOR = (char *)$d021

Adding number conversion cast (unumber) 0 in main::$2 = 0 * SIZEOF_POINTER
Adding number conversion cast (unumber) main::$2 in main::$2 = (unumber)0 * SIZEOF_POINTER
Adding number conversion cast (unumber) 1 in main::$3 = 1 * SIZEOF_POINTER
Adding number conversion cast (unumber) main::$3 in main::$3 = (unumber)1 * SIZEOF_POINTER
Adding number conversion cast (unumber) 0 in main::$4 = 0 * SIZEOF_POINTER
Adding number conversion cast (unumber) main::$4 in main::$4 = (unumber)0 * SIZEOF_POINTER
Adding number conversion cast (unumber) 1 in main::$5 = 1 * SIZEOF_POINTER
Adding number conversion cast (unumber) main::$5 in main::$5 = (unumber)1 * SIZEOF_POINTER
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (char *) 53280
Simplifying constant pointer cast (char *) 53281
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to char in main::$2 = 0 * SIZEOF_POINTER
Inferred type updated to char in main::$3 = 1 * SIZEOF_POINTER
Inferred type updated to char in main::$4 = 0 * SIZEOF_POINTER
Inferred type updated to char in main::$5 = 1 * SIZEOF_POINTER
Constant right-side identified [4] main::$2 = 0 * SIZEOF_POINTER
Constant right-side identified [6] main::$3 = 1 * SIZEOF_POINTER
Constant right-side identified [8] main::$4 = 0 * SIZEOF_POINTER
Constant right-side identified [11] main::$5 = 1 * SIZEOF_POINTER
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::$2 = 0*SIZEOF_POINTER
Constant main::$3 = 1*SIZEOF_POINTER
Constant main::$4 = 0*SIZEOF_POINTER
Constant main::$5 = 1*SIZEOF_POINTER
Successful SSA optimization Pass2ConstantIdentification
Simplifying constant evaluating to zero 0*SIZEOF_POINTER in 
Simplifying constant evaluating to zero 0*SIZEOF_POINTER in 
Successful SSA optimization PassNSimplifyConstantZero
Simplifying expression containing zero addrtable in [5] addrtable[main::$2] = &myFunc
Simplifying expression containing zero addrtable in [9] main::fn#0 = addrtable[main::$4]
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant main::$2
Eliminating unused constant main::$4
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
Constant inlined main::$5 = 1*SIZEOF_POINTER
Constant inlined main::$3 = 1*SIZEOF_POINTER
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(addrtable+1*SIZEOF_POINTER)
Consolidated array index constant in *(addrtable+1*SIZEOF_POINTER)
Successful SSA optimization Pass2ConstantAdditionElimination
Finalized unsigned number type (unsigned int) $100
Finalized unsigned number type (unsigned int) $100
Successful SSA optimization PassNFinalizeNumberTypeConversions
CALL GRAPH
Calls in [main] to null:3 null:5 

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] *addrtable = &myFunc
  [1] *(addrtable+1*SIZEOF_POINTER) = &myFunc2
  [2] main::fn#0 = *addrtable
  [3] callexecute *main::fn#0 
  to:main::@1
main::@1: scope:[main]  from main
  [4] main::fn#1 = *(addrtable+1*SIZEOF_POINTER)
  [5] callexecute *main::fn#1 
  to:main::@return
main::@return: scope:[main]  from main::@1
  [6] return 
  to:@return

void myFunc2()
myFunc2: scope:[myFunc2]  from
  [7] *myFunc2::BG_COLOR = ++ *myFunc2::BG_COLOR
  to:myFunc2::@return
myFunc2::@return: scope:[myFunc2]  from myFunc2
  [8] return 
  to:@return

void myFunc()
myFunc: scope:[myFunc]  from
  [9] *myFunc::BORDER_COLOR = ++ *myFunc::BORDER_COLOR
  to:myFunc::@return
myFunc::@return: scope:[myFunc]  from myFunc
  [10] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
void (*main::fn)()
void (*main::fn#0)() // 20.0
void (*main::fn#1)() // 20.0
void myFunc()
void myFunc2()

Initial phi equivalence classes
Added variable main::fn#0 to live range equivalence class [ main::fn#0 ]
Added variable main::fn#1 to live range equivalence class [ main::fn#1 ]
Complete equivalence classes
[ main::fn#0 ]
[ main::fn#1 ]
Allocated zp[2]:2 [ main::fn#0 ]
Allocated zp[2]:4 [ main::fn#1 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] *addrtable = &myFunc [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [1] *(addrtable+1*SIZEOF_POINTER) = &myFunc2 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [2] main::fn#0 = *addrtable [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [3] callexecute *main::fn#0  [ ] (  [ ] { }  ) always clobbers reg byte a reg byte x reg byte y 
Statement [4] main::fn#1 = *(addrtable+1*SIZEOF_POINTER) [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [5] callexecute *main::fn#1  [ ] (  [ ] { }  ) always clobbers reg byte a reg byte x reg byte y 
Potential registers zp[2]:2 [ main::fn#0 ] : zp[2]:2 , 
Potential registers zp[2]:4 [ main::fn#1 ] : zp[2]:4 , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 20: zp[2]:2 [ main::fn#0 ] 20: zp[2]:4 [ main::fn#1 ] 
Uplift Scope [myFunc] 
Uplift Scope [myFunc2] 
Uplift Scope [] 

Uplifting [main] best 206 combination zp[2]:2 [ main::fn#0 ] zp[2]:4 [ main::fn#1 ] 
Uplifting [myFunc] best 206 combination 
Uplifting [myFunc2] best 206 combination 
Uplifting [] best 206 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests calling through pointers to non-args no-return functions
  // Upstart
  // Commodore 64 PRG executable file
.file [name="function-pointer-noarg-call-12.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_POINTER = 2
.segment Code
  // main
main: {
    .label fn = 2
    .label fn_1 = 4
    // [0] *addrtable = &myFunc -- _deref_qprc1=pprc2 
    lda #<myFunc
    sta addrtable
    lda #>myFunc
    sta addrtable+1
    // [1] *(addrtable+1*SIZEOF_POINTER) = &myFunc2 -- _deref_qprc1=pprc2 
    lda #<myFunc2
    sta addrtable+1*SIZEOF_POINTER
    lda #>myFunc2
    sta addrtable+1*SIZEOF_POINTER+1
    // [2] main::fn#0 = *addrtable -- pprz1=_deref_qprc1 
    lda addrtable
    sta.z fn
    lda addrtable+1
    sta.z fn+1
    // [3] callexecute *main::fn#0  -- call__deref_pprz1 
    jsr icall1
    jmp __b1
    // main::@1
  __b1:
    // [4] main::fn#1 = *(addrtable+1*SIZEOF_POINTER) -- pprz1=_deref_qprc1 
    lda addrtable+1*SIZEOF_POINTER
    sta.z fn_1
    lda addrtable+1*SIZEOF_POINTER+1
    sta.z fn_1+1
    // [5] callexecute *main::fn#1  -- call__deref_pprz1 
    jsr icall2
    jmp __breturn
    // main::@return
  __breturn:
    // [6] return 
    rts
    // Outside Flow
  icall1:
    jmp (fn)
  icall2:
    jmp (fn_1)
}
  // myFunc2
myFunc2: {
    .label BG_COLOR = $d021
    // [7] *myFunc2::BG_COLOR = ++ *myFunc2::BG_COLOR -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BG_COLOR
    jmp __breturn
    // myFunc2::@return
  __breturn:
    // [8] return 
    rts
}
  // myFunc
myFunc: {
    .label BORDER_COLOR = $d020
    // [9] *myFunc::BORDER_COLOR = ++ *myFunc::BORDER_COLOR -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDER_COLOR
    jmp __breturn
    // myFunc::@return
  __breturn:
    // [10] return 
    rts
}
  // File Data
.segment Data
  addrtable: .fill 2*$100, 0

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1:
Removing instruction __breturn:
Removing instruction __breturn:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
__constant char SIZEOF_POINTER = 2
__constant void (*addrtable[$100])() = { fill( $100, 0) }
void main()
void (*main::fn)()
void (*main::fn#0)() // fn zp[2]:2 20.0
void (*main::fn#1)() // fn_1 zp[2]:4 20.0
void myFunc()
__constant char * const myFunc::BORDER_COLOR = (char *) 53280
void myFunc2()
__constant char * const myFunc2::BG_COLOR = (char *) 53281

zp[2]:2 [ main::fn#0 ]
zp[2]:4 [ main::fn#1 ]


FINAL ASSEMBLER
Score: 194

  // File Comments
// Tests calling through pointers to non-args no-return functions
  // Upstart
  // Commodore 64 PRG executable file
.file [name="function-pointer-noarg-call-12.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_POINTER = 2
.segment Code
  // main
main: {
    .label fn = 2
    .label fn_1 = 4
    // addrtable[0] = &myFunc
    // [0] *addrtable = &myFunc -- _deref_qprc1=pprc2 
    lda #<myFunc
    sta addrtable
    lda #>myFunc
    sta addrtable+1
    // addrtable[1] = &myFunc2
    // [1] *(addrtable+1*SIZEOF_POINTER) = &myFunc2 -- _deref_qprc1=pprc2 
    lda #<myFunc2
    sta addrtable+1*SIZEOF_POINTER
    lda #>myFunc2
    sta addrtable+1*SIZEOF_POINTER+1
    // void(*fn)() = addrtable[0]
    // [2] main::fn#0 = *addrtable -- pprz1=_deref_qprc1 
    lda addrtable
    sta.z fn
    lda addrtable+1
    sta.z fn+1
    // (*fn)()
    // [3] callexecute *main::fn#0  -- call__deref_pprz1 
    jsr icall1
    // main::@1
    // fn = addrtable[1]
    // [4] main::fn#1 = *(addrtable+1*SIZEOF_POINTER) -- pprz1=_deref_qprc1 
    lda addrtable+1*SIZEOF_POINTER
    sta.z fn_1
    lda addrtable+1*SIZEOF_POINTER+1
    sta.z fn_1+1
    // (*fn)()
    // [5] callexecute *main::fn#1  -- call__deref_pprz1 
    jsr icall2
    // main::@return
    // }
    // [6] return 
    rts
    // Outside Flow
  icall1:
    jmp (fn)
  icall2:
    jmp (fn_1)
}
  // myFunc2
myFunc2: {
    .label BG_COLOR = $d021
    // (*BG_COLOR)++;
    // [7] *myFunc2::BG_COLOR = ++ *myFunc2::BG_COLOR -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BG_COLOR
    // myFunc2::@return
    // }
    // [8] return 
    rts
}
  // myFunc
myFunc: {
    .label BORDER_COLOR = $d020
    // (*BORDER_COLOR)++;
    // [9] *myFunc::BORDER_COLOR = ++ *myFunc::BORDER_COLOR -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDER_COLOR
    // myFunc::@return
    // }
    // [10] return 
    rts
}
  // File Data
.segment Data
  addrtable: .fill 2*$100, 0

