Resolved forward reference fn1 to (void()) fn1()
Culled Empty Block (label) main::@4
Culled Empty Block (label) main::@3
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@6
Culled Empty Block (label) @1
Culled Empty Block (label) getfn::@1
Culled Empty Block (label) @2

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@3

(void()) main()
main: scope:[main]  from @3
  (byte) main::i#0 ← (byte) 0
  to:main::@1
main::@1: scope:[main]  from main main::@7
  (byte) main::i#3 ← phi( main/(byte) main::i#0 main::@7/(byte) main::i#4 )
  if(true) goto main::@2
  to:main::@return
main::@2: scope:[main]  from main::@1
  (byte) main::i#2 ← phi( main::@1/(byte) main::i#3 )
  (byte) main::i#1 ← ++ (byte) main::i#2
  (byte) getfn::b#0 ← (byte) main::i#1
  call getfn 
  (void()*) getfn::return#0 ← (void()*) getfn::return#2
  to:main::@7
main::@7: scope:[main]  from main::@2
  (byte) main::i#4 ← phi( main::@2/(byte) main::i#1 )
  (void()*) getfn::return#3 ← phi( main::@2/(void()*) getfn::return#0 )
  (void()*~) main::$1 ← (void()*) getfn::return#3
  call *((void()*~) main::$1) 
  to:main::@1
main::@return: scope:[main]  from main::@1
  return 
  to:@return

(void()*()) getfn((byte) getfn::b)
getfn: scope:[getfn]  from main::@2
  (void()*) getfn::return#1 ← &(void()) fn1()
  to:getfn::@return
getfn::@return: scope:[getfn]  from getfn
  (void()*) getfn::return#4 ← phi( getfn/(void()*) getfn::return#1 )
  (void()*) getfn::return#2 ← (void()*) getfn::return#4
  return 
  to:@return

(void()) fn1()
fn1: scope:[fn1]  from
  *((const byte*) fn1::BORDERCOL) ← ++ *((const byte*) fn1::BORDERCOL)
  to:fn1::@return
fn1::@return: scope:[fn1]  from fn1
  return 
  to:@return
@3: scope:[]  from @begin
  call main 
  to:@4
@4: scope:[]  from @3
  to:@end
@end: scope:[]  from @4

SYMBOL TABLE SSA
(label) @3
(label) @4
(label) @begin
(label) @end
(void()) fn1()
(label) fn1::@return
(const byte*) fn1::BORDERCOL = (byte*)(number) $d020
(void()*()) getfn((byte) getfn::b)
(label) getfn::@return
(byte) getfn::b
(byte) getfn::b#0
(void()*) getfn::return
(void()*) getfn::return#0
(void()*) getfn::return#1
(void()*) getfn::return#2
(void()*) getfn::return#3
(void()*) getfn::return#4
(void()) main()
(void()*~) main::$1
(label) main::@1
(label) main::@2
(label) main::@7
(label) main::@return
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(byte) main::i#3
(byte) main::i#4

Simplifying constant pointer cast (byte*) 53280
Successful SSA optimization PassNCastSimplification
Alias (byte) main::i#2 = (byte) main::i#3 
Alias (void()*) getfn::return#0 = (void()*) getfn::return#3 
Alias (byte) main::i#1 = (byte) main::i#4 
Alias (void()*) getfn::return#1 = (void()*) getfn::return#4 (void()*) getfn::return#2 
Successful SSA optimization Pass2AliasElimination
Constant (const byte) main::i#0 = 0
Constant (const void()*) getfn::return#1 = &fn1
Successful SSA optimization Pass2ConstantIdentification
Constant (const void()*) getfn::return#0 = getfn::return#1
Successful SSA optimization Pass2ConstantIdentification
Constant (const void()*) main::$1 = getfn::return#0
Successful SSA optimization Pass2ConstantIdentification
Replacing constant pointer function [10] call fn1 
Successful SSA optimization Pass2ConstantCallPointerIdentification
if() condition always true - replacing block destination [2] if(true) goto main::@2
Successful SSA optimization Pass2ConstantIfs
Eliminating unused variable (byte) getfn::b#0 and assignment [2] (byte) getfn::b#0 ← (byte) main::i#1
Eliminating unused constant (const void()*) main::$1
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused constant (const void()*) getfn::return#0
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused constant (const void()*) getfn::return#1
Successful SSA optimization PassNEliminateUnusedVars
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Inlining constant with var siblings (const byte) main::i#0
Constant inlined main::i#0 = (byte) 0
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @3
Adding NOP phi() at start of @4
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@7
Adding NOP phi() at start of getfn
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to getfn:8 fn1:10 

Created 1 initial phi equivalence classes
Coalesced [11] main::i#5 ← main::i#1
Coalesced down to 1 phi equivalence classes
Culled Empty Block (label) @4
Renumbering block @3 to @1
Renumbering block main::@7 to main::@3
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@3
Adding NOP phi() at start of getfn

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi()
  to:@1
@1: scope:[]  from @begin
  [1] phi()
  [2] call main 
  to:@end
@end: scope:[]  from @1
  [3] phi()

(void()) main()
main: scope:[main]  from @1
  [4] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@3
  [5] (byte) main::i#2 ← phi( main/(byte) 0 main::@3/(byte) main::i#1 )
  to:main::@2
main::@2: scope:[main]  from main::@1
  [6] (byte) main::i#1 ← ++ (byte) main::i#2
  [7] call getfn 
  to:main::@3
main::@3: scope:[main]  from main::@2
  [8] phi()
  [9] call fn1 
  to:main::@1

(void()) fn1()
fn1: scope:[fn1]  from main::@3
  [10] *((const byte*) fn1::BORDERCOL) ← ++ *((const byte*) fn1::BORDERCOL)
  to:fn1::@return
fn1::@return: scope:[fn1]  from fn1
  [11] return 
  to:@return

(void()*()) getfn((byte) getfn::b)
getfn: scope:[getfn]  from main::@2
  [12] phi()
  to:getfn::@return
getfn::@return: scope:[getfn]  from getfn
  [13] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) fn1()
(void()*()) getfn((byte) getfn::b)
(byte) getfn::b
(void()*) getfn::return
(void()) main()
(byte) main::i
(byte) main::i#1 5.5
(byte) main::i#2 22.0

Initial phi equivalence classes
[ main::i#2 main::i#1 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
Allocated zp[1]:2 [ main::i#2 main::i#1 ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// Tests creating, assigning returning and calling pointers to non-args no-return functions
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  // @begin
__bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
  jmp __b1
  // @1
__b1:
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
main_from___b1:
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
  jmp __bend
  // @end
__bend:
  // main
main: {
    .label i = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z i
    jmp __b1
    // main::@1
  __b1:
    jmp __b2
    // main::@2
  __b2:
    // [6] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 
    inc.z i
    // [7] call getfn 
    // [12] phi from main::@2 to getfn [phi:main::@2->getfn]
  getfn_from___b2:
    jsr getfn
    // [8] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
  __b3_from___b2:
    jmp __b3
    // main::@3
  __b3:
    // [9] call fn1 
    jsr fn1
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  __b1_from___b3:
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy 
    jmp __b1
}
  // fn1
fn1: {
    .label BORDERCOL = $d020
    // [10] *((const byte*) fn1::BORDERCOL) ← ++ *((const byte*) fn1::BORDERCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    jmp __breturn
    // fn1::@return
  __breturn:
    // [11] return 
    rts
}
  // getfn
getfn: {
    jmp __breturn
    // getfn::@return
  __breturn:
    // [13] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 27.5: zp[1]:2 [ main::i#2 main::i#1 ] 
Uplift Scope [getfn] 
Uplift Scope [fn1] 
Uplift Scope [] 

Uplifting [main] best 289 combination reg byte x [ main::i#2 main::i#1 ] 
Uplifting [getfn] best 289 combination 
Uplifting [fn1] best 289 combination 
Uplifting [] best 289 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests creating, assigning returning and calling pointers to non-args no-return functions
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  // @begin
__bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
  jmp __b1
  // @1
__b1:
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
main_from___b1:
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
  jmp __bend
  // @end
__bend:
  // main
main: {
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    jmp __b1
    // main::@1
  __b1:
    jmp __b2
    // main::@2
  __b2:
    // [6] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [7] call getfn 
    // [12] phi from main::@2 to getfn [phi:main::@2->getfn]
  getfn_from___b2:
    jsr getfn
    // [8] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
  __b3_from___b2:
    jmp __b3
    // main::@3
  __b3:
    // [9] call fn1 
    jsr fn1
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  __b1_from___b3:
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy 
    jmp __b1
}
  // fn1
fn1: {
    .label BORDERCOL = $d020
    // [10] *((const byte*) fn1::BORDERCOL) ← ++ *((const byte*) fn1::BORDERCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    jmp __breturn
    // fn1::@return
  __breturn:
    // [11] return 
    rts
}
  // getfn
getfn: {
    jmp __breturn
    // getfn::@return
  __breturn:
    // [13] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __b3
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __bbegin with __b1
Replacing label __b1 with __b2
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Removing instruction __b1:
Removing instruction __b3_from___b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __b1_from_main:
Removing instruction getfn_from___b2:
Removing instruction __b3:
Removing instruction __b1_from___b3:
Removing instruction __breturn:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction __b1:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) fn1()
(label) fn1::@return
(const byte*) fn1::BORDERCOL = (byte*) 53280
(void()*()) getfn((byte) getfn::b)
(label) getfn::@return
(byte) getfn::b
(void()*) getfn::return
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(byte) main::i
(byte) main::i#1 reg byte x 5.5
(byte) main::i#2 reg byte x 22.0

reg byte x [ main::i#2 main::i#1 ]


FINAL ASSEMBLER
Score: 154

  // File Comments
// Tests creating, assigning returning and calling pointers to non-args no-return functions
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  // @begin
  // [1] phi from @begin to @1 [phi:@begin->@1]
  // @1
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // main::@1
    // main::@2
  __b2:
    // (*getfn(++i))();
    // [6] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // getfn(++i)
    // [7] call getfn 
    // [12] phi from main::@2 to getfn [phi:main::@2->getfn]
    jsr getfn
    // [8] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
    // main::@3
    // (*getfn(++i))()
    // [9] call fn1 
    jsr fn1
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy 
    jmp __b2
}
  // fn1
fn1: {
    .label BORDERCOL = $d020
    // (*BORDERCOL)++;
    // [10] *((const byte*) fn1::BORDERCOL) ← ++ *((const byte*) fn1::BORDERCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    // fn1::@return
    // }
    // [11] return 
    rts
}
  // getfn
getfn: {
    // getfn::@return
    // [13] return 
    rts
}
  // File Data

