Resolved forward reference fn1 to (void()) fn1()
Resolved forward reference fn2 to (void()) fn2()
Culled Empty Block (label) main::@6
Culled Empty Block (label) main::@3
Culled Empty Block (label) main::@7
Culled Empty Block (label) main::@9
Culled Empty Block (label) main::@10
Culled Empty Block (label) @1
Culled Empty Block (label) @2

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

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

Adding number conversion cast (unumber) 1 in (number~) main::$0 ← (byte) main::i#1 & (number) 1
Adding number conversion cast (unumber) main::$0 in (number~) main::$0 ← (byte) main::i#1 & (unumber)(number) 1
Adding number conversion cast (unumber) 0 in (bool~) main::$1 ← (unumber~) main::$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~) main::$0 ← (byte) main::i#1 & (byte) 1
Alias (byte) main::i#2 = (byte) main::i#3 
Alias (byte) main::i#1 = (byte) main::i#5 (byte) main::i#6 
Successful SSA optimization Pass2AliasElimination
Alias (byte) main::i#1 = (byte) main::i#4 
Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) main::$1 [8] if((byte~) main::$0==(byte) 0) goto main::@4
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const void()*) main::f#0 = (void()*) 0
Constant (const byte) main::i#0 = 0
Constant (const void()*) main::f#1 = &fn1
Constant (const void()*) main::f#2 = &fn2
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [3] if(true) goto main::@2
Successful SSA optimization Pass2ConstantIfs
Eliminating unused constant (const void()*) main::f#0
Successful SSA optimization PassNEliminateUnusedVars
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()*) main::f#1
Inlining constant with var siblings (const void()*) main::f#2
Constant inlined main::i#0 = (byte) 0
Constant inlined main::f#2 = &(void()) fn2()
Constant inlined main::f#1 = &(void()) fn1()
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::@8
Adding NOP phi() at start of main::@4
CALL GRAPH
Calls in [] to main:2 

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

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::@4
  [5] (byte) main::i#2 ← phi( main/(byte) 0 main::@4/(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~) main::$0 ← (byte) main::i#1 & (byte) 1
  [8] if((byte~) main::$0==(byte) 0) goto main::@3
  to:main::@4
main::@3: scope:[main]  from main::@2
  [9] phi()
  to:main::@4
main::@4: scope:[main]  from main::@2 main::@3
  [10] (void()*) main::f#3 ← phi( main::@3/&(void()) fn1() main::@2/&(void()) fn2() )
  [11] call *((void()*) main::f#3) 
  to:main::@1

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

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


VARIABLE REGISTER WEIGHTS
(void()) fn1()
(void()) fn2()
(void()) main()
(byte~) main::$0 22.0
(void()*) main::f
(void()*) main::f#3
(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 ]
[ main::f#3 ]
Added variable main::$0 to live range equivalence class [ main::$0 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ main::f#3 ]
[ main::$0 ]
Allocated zp[1]:2 [ main::i#2 main::i#1 ]
Allocated zp[2]:3 [ main::f#3 ]
Allocated zp[1]:5 [ main::$0 ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// Tests creating, assigning 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 __0 = 5
    .label i = 2
    .label f = 3
    // [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~) main::$0 ← (byte) main::i#1 & (byte) 1 -- vbuz1=vbuz2_band_vbuc1 
    lda #1
    and.z i
    sta.z __0
    // [8] if((byte~) main::$0==(byte) 0) goto main::@3 -- vbuz1_eq_0_then_la1 
    lda.z __0
    cmp #0
    beq __b3_from___b2
    // [10] phi from main::@2 to main::@4 [phi:main::@2->main::@4]
  __b4_from___b2:
    // [10] phi (void()*) main::f#3 = &(void()) fn2() [phi:main::@2->main::@4#0] -- pprz1=pprc1 
    lda #<fn2
    sta.z f
    lda #>fn2
    sta.z f+1
    jmp __b4
    // [9] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
  __b3_from___b2:
    jmp __b3
    // main::@3
  __b3:
    // [10] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
  __b4_from___b3:
    // [10] phi (void()*) main::f#3 = &(void()) fn1() [phi:main::@3->main::@4#0] -- pprz1=pprc1 
    lda #<fn1
    sta.z f
    lda #>fn1
    sta.z f+1
    jmp __b4
    // main::@4
  __b4:
    // [11] call *((void()*) main::f#3) 
    jsr bi_f
    // [5] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
  __b1_from___b4:
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4->main::@1#0] -- register_copy 
    jmp __b1
  bi_f:
    jmp (f)
}
  // fn2
fn2: {
    .label BGCOL = $d021
    // [12] *((const byte*) fn2::BGCOL) ← ++ *((const byte*) fn2::BGCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
    jmp __breturn
    // fn2::@return
  __breturn:
    // [13] return 
    rts
}
  // fn1
fn1: {
    .label BORDERCOL = $d020
    // [14] *((const byte*) fn1::BORDERCOL) ← ++ *((const byte*) fn1::BORDERCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    jmp __breturn
    // fn1::@return
  __breturn:
    // [15] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [11] call *((void()*) main::f#3)  [ 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 a as potential for zp[1]:2 [ main::i#2 main::i#1 ]
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 [7] (byte~) main::$0 ← (byte) main::i#1 & (byte) 1 [ main::i#1 main::$0 ] ( main:2 [ main::i#1 main::$0 ] ) always clobbers reg byte a 
Statement [11] call *((void()*) main::f#3)  [ 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 [ main::f#3 ] : zp[2]:3 , 
Potential registers zp[1]:5 [ main::$0 ] : zp[1]:5 , 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 ] 22: zp[1]:5 [ main::$0 ] 0: zp[2]:3 [ main::f#3 ] 
Uplift Scope [fn1] 
Uplift Scope [fn2] 
Uplift Scope [] 

Uplifting [main] best 727 combination zp[1]:2 [ main::i#2 main::i#1 ] reg byte a [ main::$0 ] zp[2]:3 [ main::f#3 ] 
Uplifting [fn1] best 727 combination 
Uplifting [fn2] best 727 combination 
Uplifting [] best 727 combination 
Attempting to uplift remaining variables inzp[1]:2 [ main::i#2 main::i#1 ]
Uplifting [main] best 727 combination zp[1]:2 [ main::i#2 main::i#1 ] 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests creating, assigning 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
    .label f = 3
    // [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~) main::$0 ← (byte) main::i#1 & (byte) 1 -- vbuaa=vbuz1_band_vbuc1 
    lda #1
    and.z i
    // [8] if((byte~) main::$0==(byte) 0) goto main::@3 -- vbuaa_eq_0_then_la1 
    cmp #0
    beq __b3_from___b2
    // [10] phi from main::@2 to main::@4 [phi:main::@2->main::@4]
  __b4_from___b2:
    // [10] phi (void()*) main::f#3 = &(void()) fn2() [phi:main::@2->main::@4#0] -- pprz1=pprc1 
    lda #<fn2
    sta.z f
    lda #>fn2
    sta.z f+1
    jmp __b4
    // [9] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
  __b3_from___b2:
    jmp __b3
    // main::@3
  __b3:
    // [10] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
  __b4_from___b3:
    // [10] phi (void()*) main::f#3 = &(void()) fn1() [phi:main::@3->main::@4#0] -- pprz1=pprc1 
    lda #<fn1
    sta.z f
    lda #>fn1
    sta.z f+1
    jmp __b4
    // main::@4
  __b4:
    // [11] call *((void()*) main::f#3) 
    jsr bi_f
    // [5] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
  __b1_from___b4:
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4->main::@1#0] -- register_copy 
    jmp __b1
  bi_f:
    jmp (f)
}
  // fn2
fn2: {
    .label BGCOL = $d021
    // [12] *((const byte*) fn2::BGCOL) ← ++ *((const byte*) fn2::BGCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
    jmp __breturn
    // fn2::@return
  __breturn:
    // [13] return 
    rts
}
  // fn1
fn1: {
    .label BORDERCOL = $d020
    // [14] *((const byte*) fn1::BORDERCOL) ← ++ *((const byte*) fn1::BORDERCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    jmp __breturn
    // fn1::@return
  __breturn:
    // [15] 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 __b4
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __bbegin with __b1
Replacing label __b3_from___b2 with __b3
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:
Removing instruction __b4_from___b3:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __b1_from_main:
Removing instruction __b4_from___b2:
Removing instruction __b1_from___b4:
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()) fn2()
(label) fn2::@return
(const byte*) fn2::BGCOL = (byte*) 53281
(void()) main()
(byte~) main::$0 reg byte a 22.0
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(void()*) main::f
(void()*) main::f#3 f zp[2]: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 [ main::f#3 ]
reg byte a [ main::$0 ]


FINAL ASSEMBLER
Score: 589

  // File Comments
// Tests creating, assigning 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 i = 2
    .label f = 3
    // [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:
    // ++i;
    // [6] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 
    inc.z i
    // i&1
    // [7] (byte~) main::$0 ← (byte) main::i#1 & (byte) 1 -- vbuaa=vbuz1_band_vbuc1 
    lda #1
    and.z i
    // if((i&1)==0)
    // [8] if((byte~) main::$0==(byte) 0) goto main::@3 -- vbuaa_eq_0_then_la1 
    cmp #0
    beq __b3
    // [10] phi from main::@2 to main::@4 [phi:main::@2->main::@4]
    // [10] phi (void()*) main::f#3 = &(void()) fn2() [phi:main::@2->main::@4#0] -- pprz1=pprc1 
    lda #<fn2
    sta.z f
    lda #>fn2
    sta.z f+1
    jmp __b4
    // [9] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
    // main::@3
  __b3:
    // [10] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
    // [10] phi (void()*) main::f#3 = &(void()) fn1() [phi:main::@3->main::@4#0] -- pprz1=pprc1 
    lda #<fn1
    sta.z f
    lda #>fn1
    sta.z f+1
    // main::@4
  __b4:
    // (*f)()
    // [11] call *((void()*) main::f#3) 
    jsr bi_f
    // [5] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4->main::@1#0] -- register_copy 
    jmp __b2
  bi_f:
    jmp (f)
}
  // fn2
fn2: {
    .label BGCOL = $d021
    // (*BGCOL)++;
    // [12] *((const byte*) fn2::BGCOL) ← ++ *((const byte*) fn2::BGCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
    // fn2::@return
    // }
    // [13] return 
    rts
}
  // fn1
fn1: {
    .label BORDERCOL = $d020
    // (*BORDERCOL)++;
    // [14] *((const byte*) fn1::BORDERCOL) ← ++ *((const byte*) fn1::BORDERCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    // fn1::@return
    // }
    // [15] return 
    rts
}
  // File Data

