Resolved forward reference fn1 to (void()) fn1()
Resolved forward reference fn2 to (void()) fn2()
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::@4
Culled Empty Block (label) getfn::@2
Culled Empty Block (label) getfn::@5
Culled Empty Block (label) getfn::@6
Culled Empty Block (label) @2
Culled Empty Block (label) @3

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

(void()) main()
main: scope:[main]  from @4
  (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#3
  to:main::@7
main::@7: scope:[main]  from main::@2
  (byte) main::i#4 ← phi( main::@2/(byte) main::i#1 )
  (void()*) getfn::return#4 ← phi( main::@2/(void()*) getfn::return#0 )
  (void()*~) main::$1 ← (void()*) getfn::return#4
  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
  (byte) getfn::b#1 ← phi( main::@2/(byte) getfn::b#0 )
  (number~) getfn::$0 ← (byte) getfn::b#1 & (number) 1
  (bool~) getfn::$1 ← (number~) getfn::$0 == (number) 0
  if((bool~) getfn::$1) goto getfn::@1
  to:getfn::@3
getfn::@1: scope:[getfn]  from getfn
  (void()*) getfn::return#1 ← &(void()) fn1()
  to:getfn::@return
getfn::@3: scope:[getfn]  from getfn
  (void()*) getfn::return#2 ← &(void()) fn2()
  to:getfn::@return
getfn::@return: scope:[getfn]  from getfn::@1 getfn::@3
  (void()*) getfn::return#5 ← phi( getfn::@1/(void()*) getfn::return#1 getfn::@3/(void()*) getfn::return#2 )
  (void()*) getfn::return#3 ← (void()*) getfn::return#5
  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

(void()) fn2()
fn2: scope:[fn2]  from
  *((const byte*) fn2::BGCOL) ← ++ *((const byte*) fn2::BGCOL)
  to:fn2::@return
fn2::@return: scope:[fn2]  from fn2
  return 
  to:@return
@4: scope:[]  from @begin
  call main 
  to:@5
@5: scope:[]  from @4
  to:@end
@end: scope:[]  from @5

SYMBOL TABLE SSA
(label) @4
(label) @5
(label) @begin
(label) @end
(void()) fn1()
(label) fn1::@return
(const byte*) fn1::BORDERCOL = (byte*)(number) $d020
(void()) fn2()
(label) fn2::@return
(const byte*) fn2::BGCOL = (byte*)(number) $d021
(void()*()) getfn((byte) getfn::b)
(number~) getfn::$0
(bool~) getfn::$1
(label) getfn::@1
(label) getfn::@3
(label) getfn::@return
(byte) getfn::b
(byte) getfn::b#0
(byte) getfn::b#1
(void()*) getfn::return
(void()*) getfn::return#0
(void()*) getfn::return#1
(void()*) getfn::return#2
(void()*) getfn::return#3
(void()*) getfn::return#4
(void()*) getfn::return#5
(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) 1 in (number~) getfn::$0 ← (byte) getfn::b#1 & (number) 1
Adding number conversion cast (unumber) getfn::$0 in (number~) getfn::$0 ← (byte) getfn::b#1 & (unumber)(number) 1
Adding number conversion cast (unumber) 0 in (bool~) getfn::$1 ← (unumber~) getfn::$0 == (number) 0
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 53280
Simplifying constant pointer cast (byte*) 53281
Simplifying constant integer cast 1
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) getfn::$0 ← (byte) getfn::b#1 & (byte) 1
Alias (byte) main::i#2 = (byte) main::i#3 
Alias (void()*) getfn::return#0 = (void()*) getfn::return#4 
Alias (byte) main::i#1 = (byte) main::i#4 
Alias (void()*) getfn::return#3 = (void()*) getfn::return#5 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) getfn::b#1 (byte) getfn::b#0
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) getfn::$1 [15] if((byte~) getfn::$0==(byte) 0) goto getfn::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) main::i#0 = 0
Constant (const void()*) getfn::return#1 = &fn1
Constant (const void()*) getfn::return#2 = &fn2
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [2] if(true) goto main::@2
Successful SSA optimization Pass2ConstantIfs
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Inlining constant with var siblings (const byte) main::i#0
Inlining constant with var siblings (const void()*) getfn::return#1
Inlining constant with var siblings (const void()*) getfn::return#2
Constant inlined getfn::return#1 = &(void()) fn1()
Constant inlined main::i#0 = (byte) 0
Constant inlined getfn::return#2 = &(void()) fn2()
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @4
Adding NOP phi() at start of @5
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of getfn::@3
Adding NOP phi() at start of getfn::@1
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to getfn:9 

Created 2 initial phi equivalence classes
Coalesced [13] main::i#5 ← main::i#1
Coalesced down to 2 phi equivalence classes
Culled Empty Block (label) @5
Culled Empty Block (label) getfn::@3
Renumbering block @4 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 getfn::@1

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] (byte) getfn::b#0 ← (byte) main::i#1
  [8] call getfn 
  [9] (void()*) getfn::return#0 ← (void()*) getfn::return#3
  to:main::@3
main::@3: scope:[main]  from main::@2
  [10] (void()*~) main::$1 ← (void()*) getfn::return#0
  [11] call *((void()*~) main::$1) 
  to:main::@1

(void()*()) getfn((byte) getfn::b)
getfn: scope:[getfn]  from main::@2
  [12] (byte~) getfn::$0 ← (byte) getfn::b#0 & (byte) 1
  [13] if((byte~) getfn::$0==(byte) 0) goto getfn::@1
  to:getfn::@return
getfn::@1: scope:[getfn]  from getfn
  [14] phi()
  to:getfn::@return
getfn::@return: scope:[getfn]  from getfn getfn::@1
  [15] (void()*) getfn::return#3 ← phi( getfn::@1/&(void()) fn1() getfn/&(void()) fn2() )
  [16] return 
  to:@return

(void()) fn2()
fn2: scope:[fn2]  from
  [17] *((const byte*) fn2::BGCOL) ← ++ *((const byte*) fn2::BGCOL)
  to:fn2::@return
fn2::@return: scope:[fn2]  from fn2
  [18] return 
  to:@return

(void()) fn1()
fn1: scope:[fn1]  from
  [19] *((const byte*) fn1::BORDERCOL) ← ++ *((const byte*) fn1::BORDERCOL)
  to:fn1::@return
fn1::@return: scope:[fn1]  from fn1
  [20] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) fn1()
(void()) fn2()
(void()*()) getfn((byte) getfn::b)
(byte~) getfn::$0 4.0
(byte) getfn::b
(byte) getfn::b#0 13.0
(void()*) getfn::return
(void()*) getfn::return#0 22.0
(void()*) getfn::return#3 3.6666666666666665
(void()) main()
(void()*~) main::$1 11.0
(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 ]
[ getfn::return#3 ]
Added variable getfn::b#0 to live range equivalence class [ getfn::b#0 ]
Added variable getfn::return#0 to live range equivalence class [ getfn::return#0 ]
Added variable main::$1 to live range equivalence class [ main::$1 ]
Added variable getfn::$0 to live range equivalence class [ getfn::$0 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ getfn::return#3 ]
[ getfn::b#0 ]
[ getfn::return#0 ]
[ main::$1 ]
[ getfn::$0 ]
Allocated zp[1]:2 [ main::i#2 main::i#1 ]
Allocated zp[2]:3 [ getfn::return#3 ]
Allocated zp[1]:5 [ getfn::b#0 ]
Allocated zp[2]:6 [ getfn::return#0 ]
Allocated zp[2]:8 [ main::$1 ]
Allocated zp[1]:10 [ getfn::$0 ]

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 __1 = 8
    .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] (byte) getfn::b#0 ← (byte) main::i#1 -- vbuz1=vbuz2 
    lda.z i
    sta.z getfn.b
    // [8] call getfn 
    jsr getfn
    // [9] (void()*) getfn::return#0 ← (void()*) getfn::return#3 -- pprz1=pprz2 
    lda.z getfn.return_1
    sta.z getfn.return
    lda.z getfn.return_1+1
    sta.z getfn.return+1
    jmp __b3
    // main::@3
  __b3:
    // [10] (void()*~) main::$1 ← (void()*) getfn::return#0 -- pprz1=pprz2 
    lda.z getfn.return
    sta.z __1
    lda.z getfn.return+1
    sta.z __1+1
    // [11] call *((void()*~) main::$1) 
    jsr bi___1
    // [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
  bi___1:
    jmp (__1)
}
  // getfn
// getfn(byte zp(5) b)
getfn: {
    .label __0 = $a
    .label b = 5
    .label return = 6
    .label return_1 = 3
    // [12] (byte~) getfn::$0 ← (byte) getfn::b#0 & (byte) 1 -- vbuz1=vbuz2_band_vbuc1 
    lda #1
    and.z b
    sta.z __0
    // [13] if((byte~) getfn::$0==(byte) 0) goto getfn::@1 -- vbuz1_eq_0_then_la1 
    lda.z __0
    cmp #0
    beq __b1_from_getfn
    // [15] phi from getfn to getfn::@return [phi:getfn->getfn::@return]
  __breturn_from_getfn:
    // [15] phi (void()*) getfn::return#3 = &(void()) fn2() [phi:getfn->getfn::@return#0] -- pprz1=pprc1 
    lda #<fn2
    sta.z return_1
    lda #>fn2
    sta.z return_1+1
    jmp __breturn
    // [14] phi from getfn to getfn::@1 [phi:getfn->getfn::@1]
  __b1_from_getfn:
    jmp __b1
    // getfn::@1
  __b1:
    // [15] phi from getfn::@1 to getfn::@return [phi:getfn::@1->getfn::@return]
  __breturn_from___b1:
    // [15] phi (void()*) getfn::return#3 = &(void()) fn1() [phi:getfn::@1->getfn::@return#0] -- pprz1=pprc1 
    lda #<fn1
    sta.z return_1
    lda #>fn1
    sta.z return_1+1
    jmp __breturn
    // getfn::@return
  __breturn:
    // [16] return 
    rts
}
  // fn2
fn2: {
    .label BGCOL = $d021
    // [17] *((const byte*) fn2::BGCOL) ← ++ *((const byte*) fn2::BGCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
    jmp __breturn
    // fn2::@return
  __breturn:
    // [18] return 
    rts
}
  // fn1
fn1: {
    .label BORDERCOL = $d020
    // [19] *((const byte*) fn1::BORDERCOL) ← ++ *((const byte*) fn1::BORDERCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    jmp __breturn
    // fn1::@return
  __breturn:
    // [20] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [9] (void()*) getfn::return#0 ← (void()*) getfn::return#3 [ main::i#1 getfn::return#0 ] ( main:2 [ main::i#1 getfn::return#0 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::i#2 main::i#1 ]
Statement [10] (void()*~) main::$1 ← (void()*) getfn::return#0 [ main::i#1 main::$1 ] ( main:2 [ main::i#1 main::$1 ] ) always clobbers reg byte a 
Statement [11] call *((void()*~) main::$1)  [ main::i#1 ] ( main:2 [ main::i#1 ] ) always clobbers reg byte a reg byte x reg byte y 
Removing always clobbered register reg byte x as potential for zp[1]:2 [ main::i#2 main::i#1 ]
Removing always clobbered register reg byte y as potential for zp[1]:2 [ main::i#2 main::i#1 ]
Statement [9] (void()*) getfn::return#0 ← (void()*) getfn::return#3 [ main::i#1 getfn::return#0 ] ( main:2 [ main::i#1 getfn::return#0 ] ) always clobbers reg byte a 
Statement [10] (void()*~) main::$1 ← (void()*) getfn::return#0 [ main::i#1 main::$1 ] ( main:2 [ main::i#1 main::$1 ] ) always clobbers reg byte a 
Statement [11] call *((void()*~) main::$1)  [ main::i#1 ] ( main:2 [ main::i#1 ] ) always clobbers reg byte a reg byte x reg byte y 
Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , 
Potential registers zp[2]:3 [ getfn::return#3 ] : zp[2]:3 , 
Potential registers zp[1]:5 [ getfn::b#0 ] : zp[1]:5 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[2]:6 [ getfn::return#0 ] : zp[2]:6 , 
Potential registers zp[2]:8 [ main::$1 ] : zp[2]:8 , 
Potential registers zp[1]:10 [ getfn::$0 ] : zp[1]:10 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [getfn] 22: zp[2]:6 [ getfn::return#0 ] 13: zp[1]:5 [ getfn::b#0 ] 4: zp[1]:10 [ getfn::$0 ] 3.67: zp[2]:3 [ getfn::return#3 ] 
Uplift Scope [main] 27.5: zp[1]:2 [ main::i#2 main::i#1 ] 11: zp[2]:8 [ main::$1 ] 
Uplift Scope [fn1] 
Uplift Scope [fn2] 
Uplift Scope [] 

Uplifting [getfn] best 743 combination zp[2]:6 [ getfn::return#0 ] reg byte a [ getfn::b#0 ] reg byte a [ getfn::$0 ] zp[2]:3 [ getfn::return#3 ] 
Uplifting [main] best 743 combination zp[1]:2 [ main::i#2 main::i#1 ] zp[2]:8 [ main::$1 ] 
Uplifting [fn1] best 743 combination 
Uplifting [fn2] best 743 combination 
Uplifting [] best 743 combination 
Attempting to uplift remaining variables inzp[1]:2 [ main::i#2 main::i#1 ]
Uplifting [main] best 743 combination zp[1]:2 [ main::i#2 main::i#1 ] 
Coalescing zero page register [ zp[2]:3 [ getfn::return#3 ] ] with [ zp[2]:6 [ getfn::return#0 ] ] - score: 1
Coalescing zero page register [ zp[2]:3 [ getfn::return#3 getfn::return#0 ] ] with [ zp[2]:8 [ main::$1 ] ] - score: 1

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: {
    .label __1 = 3
    .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] (byte) getfn::b#0 ← (byte) main::i#1 -- vbuaa=vbuz1 
    lda.z i
    // [8] call getfn 
    jsr getfn
    // [9] (void()*) getfn::return#0 ← (void()*) getfn::return#3
    jmp __b3
    // main::@3
  __b3:
    // [10] (void()*~) main::$1 ← (void()*) getfn::return#0
    // [11] call *((void()*~) main::$1) 
    jsr bi___1
    // [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
  bi___1:
    jmp (__1)
}
  // getfn
// getfn(byte register(A) b)
getfn: {
    .label return = 3
    // [12] (byte~) getfn::$0 ← (byte) getfn::b#0 & (byte) 1 -- vbuaa=vbuaa_band_vbuc1 
    and #1
    // [13] if((byte~) getfn::$0==(byte) 0) goto getfn::@1 -- vbuaa_eq_0_then_la1 
    cmp #0
    beq __b1_from_getfn
    // [15] phi from getfn to getfn::@return [phi:getfn->getfn::@return]
  __breturn_from_getfn:
    // [15] phi (void()*) getfn::return#3 = &(void()) fn2() [phi:getfn->getfn::@return#0] -- pprz1=pprc1 
    lda #<fn2
    sta.z return
    lda #>fn2
    sta.z return+1
    jmp __breturn
    // [14] phi from getfn to getfn::@1 [phi:getfn->getfn::@1]
  __b1_from_getfn:
    jmp __b1
    // getfn::@1
  __b1:
    // [15] phi from getfn::@1 to getfn::@return [phi:getfn::@1->getfn::@return]
  __breturn_from___b1:
    // [15] phi (void()*) getfn::return#3 = &(void()) fn1() [phi:getfn::@1->getfn::@return#0] -- pprz1=pprc1 
    lda #<fn1
    sta.z return
    lda #>fn1
    sta.z return+1
    jmp __breturn
    // getfn::@return
  __breturn:
    // [16] return 
    rts
}
  // fn2
fn2: {
    .label BGCOL = $d021
    // [17] *((const byte*) fn2::BGCOL) ← ++ *((const byte*) fn2::BGCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
    jmp __breturn
    // fn2::@return
  __breturn:
    // [18] return 
    rts
}
  // fn1
fn1: {
    .label BORDERCOL = $d020
    // [19] *((const byte*) fn1::BORDERCOL) ← ++ *((const byte*) fn1::BORDERCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    jmp __breturn
    // fn1::@return
  __breturn:
    // [20] 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 __b1
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __bbegin with __b1
Replacing label __b1 with __b2
Replacing label __b1_from_getfn with __b1
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Removing instruction __b1:
Removing instruction __b1_from_getfn:
Removing instruction __breturn_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __b1_from_main:
Removing instruction __b3:
Removing instruction __b1_from___b3:
Removing instruction __breturn_from_getfn:
Removing instruction __breturn:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Replacing jump to rts with rts in jmp __breturn
Succesful ASM optimization Pass5DoubleJumpElimination
Removing instruction __b1:
Removing instruction __breturn:
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()) fn2()
(label) fn2::@return
(const byte*) fn2::BGCOL = (byte*) 53281
(void()*()) getfn((byte) getfn::b)
(byte~) getfn::$0 reg byte a 4.0
(label) getfn::@1
(label) getfn::@return
(byte) getfn::b
(byte) getfn::b#0 reg byte a 13.0
(void()*) getfn::return
(void()*) getfn::return#0 return zp[2]:3 22.0
(void()*) getfn::return#3 return zp[2]:3 3.6666666666666665
(void()) main()
(void()*~) main::$1 zp[2]:3 11.0
(label) main::@1
(label) main::@2
(label) main::@3
(byte) main::i
(byte) main::i#1 i zp[1]:2 5.5
(byte) main::i#2 i zp[1]:2 22.0

zp[1]:2 [ main::i#2 main::i#1 ]
zp[2]:3 [ getfn::return#3 getfn::return#0 main::$1 ]
reg byte a [ getfn::b#0 ]
reg byte a [ getfn::$0 ]


FINAL ASSEMBLER
Score: 392

  // 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: {
    .label __1 = 3
    .label i = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z i
    // main::@1
    // main::@2
  __b2:
    // (*getfn(++i))();
    // [6] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 
    inc.z i
    // getfn(++i)
    // [7] (byte) getfn::b#0 ← (byte) main::i#1 -- vbuaa=vbuz1 
    lda.z i
    // [8] call getfn 
    jsr getfn
    // [9] (void()*) getfn::return#0 ← (void()*) getfn::return#3
    // main::@3
    // [10] (void()*~) main::$1 ← (void()*) getfn::return#0
    // (*getfn(++i))()
    // [11] call *((void()*~) main::$1) 
    jsr bi___1
    // [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
  bi___1:
    jmp (__1)
}
  // getfn
// getfn(byte register(A) b)
getfn: {
    .label return = 3
    // b&1
    // [12] (byte~) getfn::$0 ← (byte) getfn::b#0 & (byte) 1 -- vbuaa=vbuaa_band_vbuc1 
    and #1
    // if((b&1)==0)
    // [13] if((byte~) getfn::$0==(byte) 0) goto getfn::@1 -- vbuaa_eq_0_then_la1 
    cmp #0
    beq __b1
    // [15] phi from getfn to getfn::@return [phi:getfn->getfn::@return]
    // [15] phi (void()*) getfn::return#3 = &(void()) fn2() [phi:getfn->getfn::@return#0] -- pprz1=pprc1 
    lda #<fn2
    sta.z return
    lda #>fn2
    sta.z return+1
    rts
    // [14] phi from getfn to getfn::@1 [phi:getfn->getfn::@1]
    // getfn::@1
  __b1:
    // [15] phi from getfn::@1 to getfn::@return [phi:getfn::@1->getfn::@return]
    // [15] phi (void()*) getfn::return#3 = &(void()) fn1() [phi:getfn::@1->getfn::@return#0] -- pprz1=pprc1 
    lda #<fn1
    sta.z return
    lda #>fn1
    sta.z return+1
    // getfn::@return
    // }
    // [16] return 
    rts
}
  // fn2
fn2: {
    .label BGCOL = $d021
    // (*BGCOL)++;
    // [17] *((const byte*) fn2::BGCOL) ← ++ *((const byte*) fn2::BGCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
    // fn2::@return
    // }
    // [18] return 
    rts
}
  // fn1
fn1: {
    .label BORDERCOL = $d020
    // (*BORDERCOL)++;
    // [19] *((const byte*) fn1::BORDERCOL) ← ++ *((const byte*) fn1::BORDERCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    // fn1::@return
    // }
    // [20] return 
    rts
}
  // File Data

