Resolved forward reference irq to interrupt(KERNEL_MIN)(void()) irq()

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (void()**) KERNEL_IRQ#0 ← ((void()**)) (word/signed word/dword/signed dword) 788
  (byte*) BGCOL#0 ← ((byte*)) (word/dword/signed dword) 53280
  (byte) col#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:@2
main: scope:[main]  from @2
  (byte) col#10 ← phi( @2/(byte) col#9 )
  (void()*~) main::$0 ← & interrupt(KERNEL_MIN)(void()) irq()
  *((void()**) KERNEL_IRQ#0) ← (void()*~) main::$0
  to:main::@1
main::@1: scope:[main]  from main main::@2
  (byte) col#8 ← phi( main/(byte) col#10 main::@2/(byte) col#1 )
  if(true) goto main::@2
  to:main::@return
main::@2: scope:[main]  from main::@1
  (byte) col#4 ← phi( main::@1/(byte) col#8 )
  (byte) col#1 ← ++ (byte) col#4
  to:main::@1
main::@return: scope:[main]  from main::@1
  (byte) col#5 ← phi( main::@1/(byte) col#8 )
  (byte) col#2 ← (byte) col#5
  return 
  to:@return
irq: scope:[irq]  from
  (byte) col#6 ← phi( @2/(byte) col#9 )
  asm { lda$dc0d  }
  *((byte*) BGCOL#0) ← (byte) col#6
  to:irq::@return
irq::@return: scope:[irq]  from irq
  return 
  to:@return
@2: scope:[]  from @begin
  (byte) col#9 ← phi( @begin/(byte) col#0 )
  call main 
  to:@3
@3: scope:[]  from @2
  (byte) col#7 ← phi( @2/(byte) col#2 )
  (byte) col#3 ← (byte) col#7
  to:@end
@end: scope:[]  from @3

SYMBOL TABLE SSA
(label) @2
(label) @3
(label) @begin
(label) @end
(byte*) BGCOL
(byte*) BGCOL#0
(void()**) KERNEL_IRQ
(void()**) KERNEL_IRQ#0
(byte) col
(byte) col#0
(byte) col#1
(byte) col#10
(byte) col#2
(byte) col#3
(byte) col#4
(byte) col#5
(byte) col#6
(byte) col#7
(byte) col#8
(byte) col#9
interrupt(KERNEL_MIN)(void()) irq()
(label) irq::@return
(void()) main()
(void()*~) main::$0
(label) main::@1
(label) main::@2
(label) main::@return

Alias (byte) col#2 = (byte) col#4 (byte) col#8 (byte) col#5 
Alias (byte) col#0 = (byte) col#9 
Alias (byte) col#3 = (byte) col#7 
Successful SSA optimization Pass2AliasElimination
Redundant Phi (byte) col#10 (byte) col#0
Redundant Phi (byte) col#6 (byte) col#0
Redundant Phi (byte) col#3 (byte) col#2
Successful SSA optimization Pass2RedundantPhiElimination
Constant (const void()**) KERNEL_IRQ#0 = ((void()**))788
Constant (const byte*) BGCOL#0 = ((byte*))53280
Constant (const void()*) main::$0 = &irq
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [3] if(true) goto main::@2
Successful SSA optimization Pass2ConstantIfs
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Culled Empty Block (label) @3
Successful SSA optimization Pass2CullEmptyBlocks
Constant inlined main::$0 = &interrupt(KERNEL_MIN)(void()) irq()
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
CALL GRAPH
Calls in [] to main:2 

Created 1 initial phi equivalence classes
Coalesced [5] col#11 ← col#0
Coalesced [8] col#12 ← col#1
Coalesced down to 1 phi equivalence classes
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] (byte) col#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:@2
@2: scope:[]  from @begin
  [1] phi()
  [2] call main 
  to:@end
@end: scope:[]  from @2
  [3] phi()
main: scope:[main]  from @2
  [4] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq()
  to:main::@1
main::@1: scope:[main]  from main main::@2
  [5] (byte) col#2 ← phi( main/(byte) col#0 main::@2/(byte) col#1 )
  to:main::@2
main::@2: scope:[main]  from main::@1
  [6] (byte) col#1 ← ++ (byte) col#2
  to:main::@1
irq: scope:[irq]  from
  asm { lda$dc0d  }
  [8] *((const byte*) BGCOL#0) ← (byte) col#0
  to:irq::@return
irq::@return: scope:[irq]  from irq
  [9] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte*) BGCOL
(void()**) KERNEL_IRQ
(byte) col
(byte) col#0 1.5
(byte) col#1 22.0
(byte) col#2 24.0
interrupt(KERNEL_MIN)(void()) irq()
(void()) main()

Initial phi equivalence classes
[ col#2 col#0 col#1 ]
Complete equivalence classes
[ col#2 col#0 col#1 ]
Allocated zp ZP_BYTE:2 [ col#2 col#0 col#1 ]

INITIAL ASM
//SEG0 File Comments
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label KERNEL_IRQ = $314
  .label BGCOL = $d020
  .label col = 2
//SEG3 @begin
bbegin:
//SEG4 [0] (byte) col#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0 -- vbuz1=vbuc1 
  lda #0
  sta col
//SEG5 [1] phi from @begin to @2 [phi:@begin->@2]
b2_from_bbegin:
  jmp b2
//SEG6 @2
b2:
//SEG7 [2] call main 
  jsr main
//SEG8 [3] phi from @2 to @end [phi:@2->@end]
bend_from_b2:
  jmp bend
//SEG9 @end
bend:
//SEG10 main
main: {
  //SEG11 [4] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq() -- _deref_pptc1=pprc2 
    lda #<irq
    sta KERNEL_IRQ
    lda #>irq
    sta KERNEL_IRQ+1
  //SEG12 [5] phi from main main::@2 to main::@1 [phi:main/main::@2->main::@1]
  b1_from_main:
  b1_from_b2:
  //SEG13 [5] phi (byte) col#2 = (byte) col#0 [phi:main/main::@2->main::@1#0] -- register_copy 
    jmp b1
  //SEG14 main::@1
  b1:
    jmp b2
  //SEG15 main::@2
  b2:
  //SEG16 [6] (byte) col#1 ← ++ (byte) col#2 -- vbuz1=_inc_vbuz1 
    inc col
    jmp b1_from_b2
}
//SEG17 irq
irq: {
  //SEG18 entry interrupt(KERNEL_MIN)
  //SEG19 asm { lda$dc0d  }
    lda $dc0d
  //SEG20 [8] *((const byte*) BGCOL#0) ← (byte) col#0 -- _deref_pbuc1=vbuz1 
    lda col
    sta BGCOL
    jmp breturn
  //SEG21 irq::@return
  breturn:
  //SEG22 [9] return  - exit interrupt(KERNEL_MIN)
    jmp $ea81
}

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] (byte) col#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0 [ col#0 ] ( ) always clobbers reg byte a 
Statement [4] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq() [ col#0 ] ( main:2 [ col#0 ] ) always clobbers reg byte a 
Statement asm { lda$dc0d  } always clobbers reg byte a 
Statement [8] *((const byte*) BGCOL#0) ← (byte) col#0 [ ] (  [ ] ) always clobbers reg byte a 
Potential registers zp ZP_BYTE:2 [ col#2 col#0 col#1 ] : zp ZP_BYTE:2 , 

REGISTER UPLIFT SCOPES
Uplift Scope [] 47.5: zp ZP_BYTE:2 [ col#2 col#0 col#1 ] 
Uplift Scope [main] 
Uplift Scope [irq] 

Uplifting [] best 186 combination zp ZP_BYTE:2 [ col#2 col#0 col#1 ] 
Uplifting [main] best 186 combination 
Uplifting [irq] best 186 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:2 [ col#2 col#0 col#1 ]
Uplifting [] best 186 combination zp ZP_BYTE:2 [ col#2 col#0 col#1 ] 

ASSEMBLER BEFORE OPTIMIZATION
//SEG0 File Comments
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label KERNEL_IRQ = $314
  .label BGCOL = $d020
  .label col = 2
//SEG3 @begin
bbegin:
//SEG4 [0] (byte) col#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0 -- vbuz1=vbuc1 
  lda #0
  sta col
//SEG5 [1] phi from @begin to @2 [phi:@begin->@2]
b2_from_bbegin:
  jmp b2
//SEG6 @2
b2:
//SEG7 [2] call main 
  jsr main
//SEG8 [3] phi from @2 to @end [phi:@2->@end]
bend_from_b2:
  jmp bend
//SEG9 @end
bend:
//SEG10 main
main: {
  //SEG11 [4] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq() -- _deref_pptc1=pprc2 
    lda #<irq
    sta KERNEL_IRQ
    lda #>irq
    sta KERNEL_IRQ+1
  //SEG12 [5] phi from main main::@2 to main::@1 [phi:main/main::@2->main::@1]
  b1_from_main:
  b1_from_b2:
  //SEG13 [5] phi (byte) col#2 = (byte) col#0 [phi:main/main::@2->main::@1#0] -- register_copy 
    jmp b1
  //SEG14 main::@1
  b1:
    jmp b2
  //SEG15 main::@2
  b2:
  //SEG16 [6] (byte) col#1 ← ++ (byte) col#2 -- vbuz1=_inc_vbuz1 
    inc col
    jmp b1_from_b2
}
//SEG17 irq
irq: {
  //SEG18 entry interrupt(KERNEL_MIN)
  //SEG19 asm { lda$dc0d  }
    lda $dc0d
  //SEG20 [8] *((const byte*) BGCOL#0) ← (byte) col#0 -- _deref_pbuc1=vbuz1 
    lda col
    sta BGCOL
    jmp breturn
  //SEG21 irq::@return
  breturn:
  //SEG22 [9] return  - exit interrupt(KERNEL_MIN)
    jmp $ea81
}

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b2
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b1_from_b2 with b2
Removing instruction b2_from_bbegin:
Removing instruction bend_from_b2:
Removing instruction b1_from_main:
Removing instruction b1_from_b2:
Removing instruction b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction b2:
Removing instruction bend:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @2
(label) @begin
(label) @end
(byte*) BGCOL
(const byte*) BGCOL#0 BGCOL = ((byte*))(word/dword/signed dword) 53280
(void()**) KERNEL_IRQ
(const void()**) KERNEL_IRQ#0 KERNEL_IRQ = ((void()**))(word/signed word/dword/signed dword) 788
(byte) col
(byte) col#0 col zp ZP_BYTE:2 1.5
(byte) col#1 col zp ZP_BYTE:2 22.0
(byte) col#2 col zp ZP_BYTE:2 24.0
interrupt(KERNEL_MIN)(void()) irq()
(label) irq::@return
(void()) main()
(label) main::@1
(label) main::@2

zp ZP_BYTE:2 [ col#2 col#0 col#1 ]


FINAL ASSEMBLER
Score: 117

//SEG0 File Comments
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label KERNEL_IRQ = $314
  .label BGCOL = $d020
  .label col = 2
//SEG3 @begin
bbegin:
//SEG4 [0] (byte) col#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0 -- vbuz1=vbuc1 
  lda #0
  sta col
//SEG5 [1] phi from @begin to @2 [phi:@begin->@2]
//SEG6 @2
//SEG7 [2] call main 
  jsr main
//SEG8 [3] phi from @2 to @end [phi:@2->@end]
//SEG9 @end
//SEG10 main
main: {
  //SEG11 [4] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq() -- _deref_pptc1=pprc2 
    lda #<irq
    sta KERNEL_IRQ
    lda #>irq
    sta KERNEL_IRQ+1
  //SEG12 [5] phi from main main::@2 to main::@1 [phi:main/main::@2->main::@1]
  //SEG13 [5] phi (byte) col#2 = (byte) col#0 [phi:main/main::@2->main::@1#0] -- register_copy 
  //SEG14 main::@1
  //SEG15 main::@2
  b2:
  //SEG16 [6] (byte) col#1 ← ++ (byte) col#2 -- vbuz1=_inc_vbuz1 
    inc col
    jmp b2
}
//SEG17 irq
irq: {
  //SEG18 entry interrupt(KERNEL_MIN)
  //SEG19 asm { lda$dc0d  }
    lda $dc0d
  //SEG20 [8] *((const byte*) BGCOL#0) ← (byte) col#0 -- _deref_pbuc1=vbuz1 
    lda col
    sta BGCOL
  //SEG21 irq::@return
  //SEG22 [9] return  - exit interrupt(KERNEL_MIN)
    jmp $ea81
}

