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*) FGCOL#0 ← ((byte*)) (word/dword/signed dword) 53281
  to:@2
main: scope:[main]  from @2
  (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
  if(true) goto main::@2
  to:main::@return
main::@2: scope:[main]  from main::@1
  *((byte*) FGCOL#0) ← ++ *((byte*) FGCOL#0)
  to:main::@1
main::@return: scope:[main]  from main::@1
  return 
  to:@return
irq: scope:[irq]  from
  *((byte*) BGCOL#0) ← ++ *((byte*) BGCOL#0)
  asm { lda$dc0d  }
  to:irq::@return
irq::@return: scope:[irq]  from irq
  return 
  to:@return
@2: scope:[]  from @begin
  call main 
  to:@3
@3: scope:[]  from @2
  to:@end
@end: scope:[]  from @3

SYMBOL TABLE SSA
(label) @2
(label) @3
(label) @begin
(label) @end
(byte*) BGCOL
(byte*) BGCOL#0
(byte*) FGCOL
(byte*) FGCOL#0
(void()**) KERNEL_IRQ
(void()**) KERNEL_IRQ#0
interrupt(KERNEL_MIN)(void()) irq()
(label) irq::@return
(void()) main()
(void()*~) main::$0
(label) main::@1
(label) main::@2
(label) main::@return

Culled Empty Block (label) @3
Successful SSA optimization Pass2CullEmptyBlocks
Constant (const void()**) KERNEL_IRQ#0 = ((void()**))788
Constant (const byte*) BGCOL#0 = ((byte*))53280
Constant (const byte*) FGCOL#0 = ((byte*))53281
Constant (const void()*) main::$0 = &irq
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [1] if(true) goto main::@2
Successful SSA optimization Pass2ConstantIfs
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Culled Empty Block (label) main::@1
Successful SSA optimization Pass2CullEmptyBlocks
Constant inlined main::$0 = &interrupt(KERNEL_MIN)(void()) irq()
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
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
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi()
  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::@2
main::@2: scope:[main]  from main main::@2
  [5] *((const byte*) FGCOL#0) ← ++ *((const byte*) FGCOL#0)
  to:main::@2
irq: scope:[irq]  from
  [6] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0)
  asm { lda$dc0d  }
  to:irq::@return
irq::@return: scope:[irq]  from irq
  [8] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte*) BGCOL
(byte*) FGCOL
(void()**) KERNEL_IRQ
interrupt(KERNEL_MIN)(void()) irq()
(void()) main()

Initial phi equivalence classes
Complete equivalence classes

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 FGCOL = $d021
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @2 [phi:@begin->@2]
b2_from_bbegin:
  jmp b2
//SEG5 @2
b2:
//SEG6 [2] call main 
  jsr main
//SEG7 [3] phi from @2 to @end [phi:@2->@end]
bend_from_b2:
  jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
  //SEG10 [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
    jmp b2
  //SEG11 main::@2
  b2:
  //SEG12 [5] *((const byte*) FGCOL#0) ← ++ *((const byte*) FGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc FGCOL
    jmp b2
}
//SEG13 irq
irq: {
  //SEG14 entry interrupt(KERNEL_MIN)
  //SEG15 [6] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
  //SEG16 asm { lda$dc0d  }
    lda $dc0d
    jmp breturn
  //SEG17 irq::@return
  breturn:
  //SEG18 [8] return  - exit interrupt(KERNEL_MIN)
    jmp $ea81
}

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq() [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement asm { lda$dc0d  } always clobbers reg byte a 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 
Uplift Scope [irq] 
Uplift Scope [] 

Uplifting [main] best 133 combination 
Uplifting [irq] best 133 combination 
Uplifting [] best 133 combination 

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 FGCOL = $d021
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @2 [phi:@begin->@2]
b2_from_bbegin:
  jmp b2
//SEG5 @2
b2:
//SEG6 [2] call main 
  jsr main
//SEG7 [3] phi from @2 to @end [phi:@2->@end]
bend_from_b2:
  jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
  //SEG10 [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
    jmp b2
  //SEG11 main::@2
  b2:
  //SEG12 [5] *((const byte*) FGCOL#0) ← ++ *((const byte*) FGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc FGCOL
    jmp b2
}
//SEG13 irq
irq: {
  //SEG14 entry interrupt(KERNEL_MIN)
  //SEG15 [6] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
  //SEG16 asm { lda$dc0d  }
    lda $dc0d
    jmp breturn
  //SEG17 irq::@return
  breturn:
  //SEG18 [8] return  - exit interrupt(KERNEL_MIN)
    jmp $ea81
}

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b2
Removing instruction jmp bend
Removing instruction jmp b2
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction b2_from_bbegin:
Removing instruction b2:
Removing instruction bend_from_b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
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) @2
(label) @begin
(label) @end
(byte*) BGCOL
(const byte*) BGCOL#0 BGCOL = ((byte*))(word/dword/signed dword) 53280
(byte*) FGCOL
(const byte*) FGCOL#0 FGCOL = ((byte*))(word/dword/signed dword) 53281
(void()**) KERNEL_IRQ
(const void()**) KERNEL_IRQ#0 KERNEL_IRQ = ((void()**))(word/signed word/dword/signed dword) 788
interrupt(KERNEL_MIN)(void()) irq()
(label) irq::@return
(void()) main()
(label) main::@2



FINAL ASSEMBLER
Score: 115

//SEG0 File Comments
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label KERNEL_IRQ = $314
  .label BGCOL = $d020
  .label FGCOL = $d021
//SEG3 @begin
//SEG4 [1] phi from @begin to @2 [phi:@begin->@2]
//SEG5 @2
//SEG6 [2] call main 
//SEG7 [3] phi from @2 to @end [phi:@2->@end]
//SEG8 @end
//SEG9 main
main: {
  //SEG10 [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
  //SEG11 main::@2
  b2:
  //SEG12 [5] *((const byte*) FGCOL#0) ← ++ *((const byte*) FGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc FGCOL
    jmp b2
}
//SEG13 irq
irq: {
  //SEG14 entry interrupt(KERNEL_MIN)
  //SEG15 [6] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
  //SEG16 asm { lda$dc0d  }
    lda $dc0d
  //SEG17 irq::@return
  //SEG18 [8] return  - exit interrupt(KERNEL_MIN)
    jmp $ea81
}

