Resolved forward reference fn1 to (void()) fn1()
Resolved forward reference fn2 to (void()) fn2()
Culled Empty Block (label) @1
Culled Empty Block (label) @2

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@3
main: scope:[main]  from @3
  (byte*) main::SCREEN#0 ← ((byte*)) (number) $400
  (void()*) main::f#0 ← (void()*) 0
  (void()*~) main::$0 ← & (void()) fn1()
  (void()*) main::f#1 ← (void()*~) main::$0
  (word~) main::$1 ← ((word)) (void()*) main::f#1
  (byte~) main::$2 ← < (word~) main::$1
  *((byte*) main::SCREEN#0 + (number) 0) ← (byte~) main::$2
  (word~) main::$3 ← ((word)) (void()*) main::f#1
  (byte~) main::$4 ← > (word~) main::$3
  *((byte*) main::SCREEN#0 + (number) 1) ← (byte~) main::$4
  (void()*~) main::$5 ← & (void()) fn2()
  (void()*) main::f#2 ← (void()*~) main::$5
  (word~) main::$6 ← ((word)) (void()*) main::f#2
  (byte~) main::$7 ← < (word~) main::$6
  *((byte*) main::SCREEN#0 + (number) 2) ← (byte~) main::$7
  (word~) main::$8 ← ((word)) (void()*) main::f#2
  (byte~) main::$9 ← > (word~) main::$8
  *((byte*) main::SCREEN#0 + (number) 3) ← (byte~) main::$9
  to:main::@return
main::@return: scope:[main]  from main
  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
fn2: scope:[fn2]  from
  (byte*) fn2::BGCOL#0 ← ((byte*)) (number) $d021
  *((byte*) fn2::BGCOL#0) ← ++ *((byte*) fn2::BGCOL#0)
  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
(byte*) fn1::BORDERCOL
(byte*) fn1::BORDERCOL#0
(void()) fn2()
(label) fn2::@return
(byte*) fn2::BGCOL
(byte*) fn2::BGCOL#0
(void()) main()
(void()*~) main::$0
(word~) main::$1
(byte~) main::$2
(word~) main::$3
(byte~) main::$4
(void()*~) main::$5
(word~) main::$6
(byte~) main::$7
(word~) main::$8
(byte~) main::$9
(label) main::@return
(byte*) main::SCREEN
(byte*) main::SCREEN#0
(void()*) main::f
(void()*) main::f#0
(void()*) main::f#1
(void()*) main::f#2

Adding number conversion cast (unumber) 0 in *((byte*) main::SCREEN#0 + (number) 0) ← (byte~) main::$2
Adding number conversion cast (unumber) 1 in *((byte*) main::SCREEN#0 + (number) 1) ← (byte~) main::$4
Adding number conversion cast (unumber) 2 in *((byte*) main::SCREEN#0 + (number) 2) ← (byte~) main::$7
Adding number conversion cast (unumber) 3 in *((byte*) main::SCREEN#0 + (number) 3) ← (byte~) main::$9
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) main::SCREEN#0 ← (byte*)(number) $400
Inlining cast (word~) main::$1 ← (word)(void()*) main::f#1
Inlining cast (word~) main::$3 ← (word)(void()*) main::f#1
Inlining cast (word~) main::$6 ← (word)(void()*) main::f#2
Inlining cast (word~) main::$8 ← (word)(void()*) main::f#2
Inlining cast (byte*) fn1::BORDERCOL#0 ← (byte*)(number) $d020
Inlining cast (byte*) fn2::BGCOL#0 ← (byte*)(number) $d021
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 2
Simplifying constant integer cast 3
Simplifying constant pointer cast (byte*) 53280
Simplifying constant pointer cast (byte*) 53281
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 3
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (void()*) main::f#1 = (void()*~) main::$0 
Alias (void()*) main::f#2 = (void()*~) main::$5 
Successful SSA optimization Pass2AliasElimination
Constant right-side identified [2] (void()*) main::f#1 ← & (void()) fn1()
Constant right-side identified [10] (void()*) main::f#2 ← & (void()) fn2()
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) main::SCREEN#0 = (byte*) 1024
Constant (const void()*) main::f#0 = (void()*) 0
Constant (const void()*) main::f#1 = &fn1
Constant (const void()*) main::f#2 = &fn2
Constant (const byte*) fn1::BORDERCOL#0 = (byte*) 53280
Constant (const byte*) fn2::BGCOL#0 = (byte*) 53281
Successful SSA optimization Pass2ConstantIdentification
Constant value identified (word)main::f#1 in [4] (word~) main::$1 ← (word)(const void()*) main::f#1
Constant value identified (word)main::f#1 in [7] (word~) main::$3 ← (word)(const void()*) main::f#1
Constant value identified (word)main::f#2 in [12] (word~) main::$6 ← (word)(const void()*) main::f#2
Constant value identified (word)main::f#2 in [15] (word~) main::$8 ← (word)(const void()*) main::f#2
Successful SSA optimization Pass2ConstantValues
Simplifying expression containing zero main::SCREEN#0 in [6] *((const byte*) main::SCREEN#0 + (byte) 0) ← (byte~) main::$2
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant (const void()*) main::f#0
Successful SSA optimization PassNEliminateUnusedVars
Constant (const word) main::$1 = (word)main::f#1
Constant (const word) main::$3 = (word)main::f#1
Constant (const word) main::$6 = (word)main::f#2
Constant (const word) main::$8 = (word)main::f#2
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [0] (byte~) main::$2 ← < (const word) main::$1
Constant right-side identified [2] (byte~) main::$4 ← > (const word) main::$3
Constant right-side identified [4] (byte~) main::$7 ← < (const word) main::$6
Constant right-side identified [6] (byte~) main::$9 ← > (const word) main::$8
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::$2 = <main::$1
Constant (const byte) main::$4 = >main::$3
Constant (const byte) main::$7 = <main::$6
Constant (const byte) main::$9 = >main::$8
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with different constant siblings (const void()*) main::f#1
Inlining constant with different constant siblings (const void()*) main::f#2
Constant inlined main::$1 = (word)&(void()) fn1()
Constant inlined main::$2 = <(word)&(void()) fn1()
Constant inlined main::$6 = (word)&(void()) fn2()
Constant inlined main::f#2 = &(void()) fn2()
Constant inlined main::$3 = (word)&(void()) fn1()
Constant inlined main::$4 = >(word)&(void()) fn1()
Constant inlined main::$9 = >(word)&(void()) fn2()
Constant inlined main::$7 = <(word)&(void()) fn2()
Constant inlined main::f#1 = &(void()) fn1()
Constant inlined main::$8 = (word)&(void()) fn2()
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(main::SCREEN#0+1)
Consolidated array index constant in *(main::SCREEN#0+2)
Consolidated array index constant in *(main::SCREEN#0+3)
Successful SSA optimization Pass2ConstantAdditionElimination
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
CALL GRAPH
Calls in [] to main:2 

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block (label) @4
Renumbering block @3 to @1
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end

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] *((const byte*) main::SCREEN#0) ← <(word)&(void()) fn1()
  [5] *((const byte*) main::SCREEN#0+(byte) 1) ← >(word)&(void()) fn1()
  [6] *((const byte*) main::SCREEN#0+(byte) 2) ← <(word)&(void()) fn2()
  [7] *((const byte*) main::SCREEN#0+(byte) 3) ← >(word)&(void()) fn2()
  to:main::@return
main::@return: scope:[main]  from main
  [8] return 
  to:@return
fn2: scope:[fn2]  from
  [9] *((const byte*) fn2::BGCOL#0) ← ++ *((const byte*) fn2::BGCOL#0)
  to:fn2::@return
fn2::@return: scope:[fn2]  from fn2
  [10] return 
  to:@return
fn1: scope:[fn1]  from
  [11] *((const byte*) fn1::BORDERCOL#0) ← ++ *((const byte*) fn1::BORDERCOL#0)
  to:fn1::@return
fn1::@return: scope:[fn1]  from fn1
  [12] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) fn1()
(byte*) fn1::BORDERCOL
(void()) fn2()
(byte*) fn2::BGCOL
(void()) main()
(byte*) main::SCREEN
(void()*) main::f

Initial phi equivalence classes
Complete equivalence classes

INITIAL ASM
  // File Comments
// Tests creating pointers to non-args no-return functions
  // Basic 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 
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
main: {
    .label SCREEN = $400
    // [4] *((const byte*) main::SCREEN#0) ← <(word)&(void()) fn1() -- _deref_pbuc1=vbuc2 
    lda #<fn1
    sta SCREEN
    // [5] *((const byte*) main::SCREEN#0+(byte) 1) ← >(word)&(void()) fn1() -- _deref_pbuc1=vbuc2 
    lda #>fn1
    sta SCREEN+1
    // [6] *((const byte*) main::SCREEN#0+(byte) 2) ← <(word)&(void()) fn2() -- _deref_pbuc1=vbuc2 
    lda #<fn2
    sta SCREEN+2
    // [7] *((const byte*) main::SCREEN#0+(byte) 3) ← >(word)&(void()) fn2() -- _deref_pbuc1=vbuc2 
    lda #>fn2
    sta SCREEN+3
    jmp breturn
    // main::@return
  breturn:
    // [8] return 
    rts
}
  // fn2
fn2: {
    .label BGCOL = $d021
    // [9] *((const byte*) fn2::BGCOL#0) ← ++ *((const byte*) fn2::BGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
    jmp breturn
    // fn2::@return
  breturn:
    // [10] return 
    rts
}
  // fn1
fn1: {
    .label BORDERCOL = $d020
    // [11] *((const byte*) fn1::BORDERCOL#0) ← ++ *((const byte*) fn1::BORDERCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    jmp breturn
    // fn1::@return
  breturn:
    // [12] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] *((const byte*) main::SCREEN#0) ← <(word)&(void()) fn1() [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [5] *((const byte*) main::SCREEN#0+(byte) 1) ← >(word)&(void()) fn1() [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [6] *((const byte*) main::SCREEN#0+(byte) 2) ← <(word)&(void()) fn2() [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [7] *((const byte*) main::SCREEN#0+(byte) 3) ← >(word)&(void()) fn2() [ ] ( main:2 [ ] ) always clobbers reg byte a 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 
Uplift Scope [fn1] 
Uplift Scope [fn2] 
Uplift Scope [] 

Uplifting [main] best 75 combination 
Uplifting [fn1] best 75 combination 
Uplifting [fn2] best 75 combination 
Uplifting [] best 75 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests creating pointers to non-args no-return functions
  // Basic 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 
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
main: {
    .label SCREEN = $400
    // [4] *((const byte*) main::SCREEN#0) ← <(word)&(void()) fn1() -- _deref_pbuc1=vbuc2 
    lda #<fn1
    sta SCREEN
    // [5] *((const byte*) main::SCREEN#0+(byte) 1) ← >(word)&(void()) fn1() -- _deref_pbuc1=vbuc2 
    lda #>fn1
    sta SCREEN+1
    // [6] *((const byte*) main::SCREEN#0+(byte) 2) ← <(word)&(void()) fn2() -- _deref_pbuc1=vbuc2 
    lda #<fn2
    sta SCREEN+2
    // [7] *((const byte*) main::SCREEN#0+(byte) 3) ← >(word)&(void()) fn2() -- _deref_pbuc1=vbuc2 
    lda #>fn2
    sta SCREEN+3
    jmp breturn
    // main::@return
  breturn:
    // [8] return 
    rts
}
  // fn2
fn2: {
    .label BGCOL = $d021
    // [9] *((const byte*) fn2::BGCOL#0) ← ++ *((const byte*) fn2::BGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
    jmp breturn
    // fn2::@return
  breturn:
    // [10] return 
    rts
}
  // fn1
fn1: {
    .label BORDERCOL = $d020
    // [11] *((const byte*) fn1::BORDERCOL#0) ← ++ *((const byte*) fn1::BORDERCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    jmp breturn
    // fn1::@return
  breturn:
    // [12] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp breturn
Removing instruction jmp breturn
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction bend_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction breturn:
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()) fn2()
(label) fn2::@return
(byte*) fn2::BGCOL
(const byte*) fn2::BGCOL#0 BGCOL = (byte*) 53281
(void()) main()
(label) main::@return
(byte*) main::SCREEN
(const byte*) main::SCREEN#0 SCREEN = (byte*) 1024
(void()*) main::f



FINAL ASSEMBLER
Score: 54

  // File Comments
// Tests creating pointers to non-args no-return functions
  // Basic 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 
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    .label SCREEN = $400
    // SCREEN[0] = <(word)f
    // [4] *((const byte*) main::SCREEN#0) ← <(word)&(void()) fn1() -- _deref_pbuc1=vbuc2 
    lda #<fn1
    sta SCREEN
    // SCREEN[1] = >(word)f
    // [5] *((const byte*) main::SCREEN#0+(byte) 1) ← >(word)&(void()) fn1() -- _deref_pbuc1=vbuc2 
    lda #>fn1
    sta SCREEN+1
    // SCREEN[2] = <(word)f
    // [6] *((const byte*) main::SCREEN#0+(byte) 2) ← <(word)&(void()) fn2() -- _deref_pbuc1=vbuc2 
    lda #<fn2
    sta SCREEN+2
    // SCREEN[3] = >(word)f
    // [7] *((const byte*) main::SCREEN#0+(byte) 3) ← >(word)&(void()) fn2() -- _deref_pbuc1=vbuc2 
    lda #>fn2
    sta SCREEN+3
    // main::@return
    // }
    // [8] return 
    rts
}
  // fn2
fn2: {
    .label BGCOL = $d021
    // (*BGCOL)++;
    // [9] *((const byte*) fn2::BGCOL#0) ← ++ *((const byte*) fn2::BGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
    // fn2::@return
    // }
    // [10] return 
    rts
}
  // fn1
fn1: {
    .label BORDERCOL = $d020
    // (*BORDERCOL)++;
    // [11] *((const byte*) fn1::BORDERCOL#0) ← ++ *((const byte*) fn1::BORDERCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    // fn1::@return
    // }
    // [12] return 
    rts
}
  // File Data

