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
main: scope:[main]  from @3
  (byte) main::i#0 ← (number) 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
getfn: scope:[getfn]  from main::@2
  (void()*~) getfn::$0 ← & (void()) fn1()
  (void()*) getfn::return#1 ← (void()*~) getfn::$0
  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
fn1: scope:[fn1]  from
  (byte*) fn1::BORDERCOL#0 ← ((byte*)) (number) $d020
  *((byte*) fn1::BORDERCOL#0) ← ++ *((byte*) fn1::BORDERCOL#0)
  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
(byte*) fn1::BORDERCOL
(byte*) fn1::BORDERCOL#0
(void()*()) getfn((byte) getfn::b)
(void()*~) getfn::$0
(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

Adding number conversion cast (unumber) 0 in (byte) main::i#0 ← (number) 0
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte) main::i#0 ← (unumber)(number) 0
Inlining cast (byte*) fn1::BORDERCOL#0 ← (byte*)(number) $d020
Successful SSA optimization Pass2InlineCast
Simplifying constant integer cast 0
Simplifying constant pointer cast (byte*) 53280
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
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::$0 (void()*) getfn::return#4 (void()*) getfn::return#2 
Successful SSA optimization Pass2AliasElimination
Constant right-side identified [12] (void()*) getfn::return#1 ← & (void()) fn1()
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::i#0 = 0
Constant (const void()*) getfn::return#1 = &fn1
Constant (const byte*) fn1::BORDERCOL#0 = (byte*) 53280
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()
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
fn1: scope:[fn1]  from main::@3
  [10] *((const byte*) fn1::BORDERCOL#0) ← ++ *((const byte*) fn1::BORDERCOL#0)
  to:fn1::@return
fn1::@return: scope:[fn1]  from fn1
  [11] return 
  to:@return
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()
(byte*) fn1::BORDERCOL
(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 ZP_BYTE:2 [ main::i#2 main::i#1 ]

INITIAL ASM
Target platform is c64basic
  // 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#0) ← ++ *((const byte*) fn1::BORDERCOL#0) -- _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 ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 27.5: zp ZP_BYTE: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#0) ← ++ *((const byte*) fn1::BORDERCOL#0) -- _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 b1 with b2
Removing instruction b1_from_bbegin:
Removing instruction b1:
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 bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) fn1()
(label) fn1::@return
(byte*) fn1::BORDERCOL
(const byte*) fn1::BORDERCOL#0 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#0) ← ++ *((const byte*) fn1::BORDERCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    // fn1::@return
    // }
    // [11] return 
    rts
}
  // getfn
getfn: {
    // getfn::@return
    // [13] return 
    rts
}
  // File Data

