Resolved forward reference irq to interrupt(KERNEL_KEYBOARD)(void()) irq()
Inlined call (byte~) vicSelectGfxBank::$0 ← call toDd00 (byte*) vicSelectGfxBank::gfx 
Culled Empty Block (label) @1
Culled Empty Block (label) @2
Culled Empty Block (label) @3
Culled Empty Block (label) @4
Culled Empty Block (label) @5

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) BGCOL#0 ← ((byte*)) (number) $d021
  (void()**) KERNEL_IRQ#0 ← ((void()**)) (number) $314
  (byte) BLACK#0 ← (number) 0
  (byte) WHITE#0 ← (number) 1
  to:@6
main: scope:[main]  from @6
  asm { sei  }
  (void()*~) main::$0 ← & interrupt(KERNEL_KEYBOARD)(void()) irq()
  *((void()**) KERNEL_IRQ#0) ← (void()*~) main::$0
  asm { cli  }
  to:main::@return
main::@return: scope:[main]  from main
  return 
  to:@return
irq: scope:[irq]  from
  *((byte*) BGCOL#0) ← (byte) WHITE#0
  *((byte*) BGCOL#0) ← (byte) BLACK#0
  to:irq::@return
irq::@return: scope:[irq]  from irq
  return 
  to:@return
@6: scope:[]  from @begin
  call main 
  to:@7
@7: scope:[]  from @6
  to:@end
@end: scope:[]  from @7

SYMBOL TABLE SSA
(label) @6
(label) @7
(label) @begin
(label) @end
(byte*) BGCOL
(byte*) BGCOL#0
(byte) BLACK
(byte) BLACK#0
(void()**) KERNEL_IRQ
(void()**) KERNEL_IRQ#0
(byte) WHITE
(byte) WHITE#0
interrupt(KERNEL_KEYBOARD)(void()) irq()
(label) irq::@return
(void()) main()
(void()*~) main::$0
(label) main::@return

Adding number conversion cast (unumber) 0 in (byte) BLACK#0 ← (number) 0
Adding number conversion cast (unumber) 1 in (byte) WHITE#0 ← (number) 1
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) BGCOL#0 ← (byte*)(number) $d021
Inlining cast (void()**) KERNEL_IRQ#0 ← (void()**)(number) $314
Inlining cast (byte) BLACK#0 ← (unumber)(number) 0
Inlining cast (byte) WHITE#0 ← (unumber)(number) 1
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 53281
Simplifying constant pointer cast (void()**) 788
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant right-side identified [5] (void()*~) main::$0 ← & interrupt(KERNEL_KEYBOARD)(void()) irq()
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) BGCOL#0 = (byte*) 53281
Constant (const void()**) KERNEL_IRQ#0 = (void()**) 788
Constant (const byte) BLACK#0 = 0
Constant (const byte) WHITE#0 = 1
Constant (const void()*) main::$0 = &irq
Successful SSA optimization Pass2ConstantIdentification
Constant inlined main::$0 = &interrupt(KERNEL_KEYBOARD)(void()) irq()
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @6
Adding NOP phi() at start of @7
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) @7
Renumbering block @6 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
  asm { sei  }
  [5] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_KEYBOARD)(void()) irq()
  asm { cli  }
  to:main::@return
main::@return: scope:[main]  from main
  [7] return 
  to:@return
irq: scope:[irq]  from
  [8] *((const byte*) BGCOL#0) ← (const byte) WHITE#0
  [9] *((const byte*) BGCOL#0) ← (const byte) BLACK#0
  to:irq::@return
irq::@return: scope:[irq]  from irq
  [10] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte*) BGCOL
(byte) BLACK
(void()**) KERNEL_IRQ
(byte) WHITE
interrupt(KERNEL_KEYBOARD)(void()) irq()
(void()) main()

Initial phi equivalence classes
Complete equivalence classes

INITIAL ASM
Target platform is c64basic
  // File Comments
// A minimal working IRQ
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label BGCOL = $d021
  // The vector used when the KERNAL serves IRQ interrupts
  .label KERNEL_IRQ = $314
  // The colors of the C64
  .const BLACK = 0
  .const WHITE = 1
  // @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
// Setup the IRQ routine
main: {
    // asm { sei  }
    sei
    // [5] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_KEYBOARD)(void()) irq() -- _deref_pptc1=pprc2 
    lda #<irq
    sta KERNEL_IRQ
    lda #>irq
    sta KERNEL_IRQ+1
    // asm { cli  }
    cli
    jmp breturn
    // main::@return
  breturn:
    // [7] return 
    rts
}
  // irq
// The Interrupt Handler
irq: {
    // entry interrupt(KERNEL_KEYBOARD)
    // [8] *((const byte*) BGCOL#0) ← (const byte) WHITE#0 -- _deref_pbuc1=vbuc2 
    lda #WHITE
    sta BGCOL
    // [9] *((const byte*) BGCOL#0) ← (const byte) BLACK#0 -- _deref_pbuc1=vbuc2 
    lda #BLACK
    sta BGCOL
    jmp breturn
    // irq::@return
  breturn:
    // [10] return  - exit interrupt(KERNEL_KEYBOARD)
    jmp $ea31
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [5] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_KEYBOARD)(void()) irq() [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [8] *((const byte*) BGCOL#0) ← (const byte) WHITE#0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [9] *((const byte*) BGCOL#0) ← (const byte) BLACK#0 [ ] (  [ ] ) always clobbers reg byte a 

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

Uplifting [main] best 55 combination 
Uplifting [irq] best 55 combination 
Uplifting [] best 55 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// A minimal working IRQ
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label BGCOL = $d021
  // The vector used when the KERNAL serves IRQ interrupts
  .label KERNEL_IRQ = $314
  // The colors of the C64
  .const BLACK = 0
  .const WHITE = 1
  // @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
// Setup the IRQ routine
main: {
    // asm { sei  }
    sei
    // [5] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_KEYBOARD)(void()) irq() -- _deref_pptc1=pprc2 
    lda #<irq
    sta KERNEL_IRQ
    lda #>irq
    sta KERNEL_IRQ+1
    // asm { cli  }
    cli
    jmp breturn
    // main::@return
  breturn:
    // [7] return 
    rts
}
  // irq
// The Interrupt Handler
irq: {
    // entry interrupt(KERNEL_KEYBOARD)
    // [8] *((const byte*) BGCOL#0) ← (const byte) WHITE#0 -- _deref_pbuc1=vbuc2 
    lda #WHITE
    sta BGCOL
    // [9] *((const byte*) BGCOL#0) ← (const byte) BLACK#0 -- _deref_pbuc1=vbuc2 
    lda #BLACK
    sta BGCOL
    jmp breturn
    // irq::@return
  breturn:
    // [10] return  - exit interrupt(KERNEL_KEYBOARD)
    jmp $ea31
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
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:
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
(byte*) BGCOL
(const byte*) BGCOL#0 BGCOL = (byte*) 53281
(byte) BLACK
(const byte) BLACK#0 BLACK = (byte) 0
(void()**) KERNEL_IRQ
(const void()**) KERNEL_IRQ#0 KERNEL_IRQ = (void()**) 788
(byte) WHITE
(const byte) WHITE#0 WHITE = (byte) 1
interrupt(KERNEL_KEYBOARD)(void()) irq()
(label) irq::@return
(void()) main()
(label) main::@return



FINAL ASSEMBLER
Score: 37

  // File Comments
// A minimal working IRQ
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .label BGCOL = $d021
  // The vector used when the KERNAL serves IRQ interrupts
  .label KERNEL_IRQ = $314
  // The colors of the C64
  .const BLACK = 0
  .const WHITE = 1
  // @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
// Setup the IRQ routine
main: {
    // asm
    // asm { sei  }
    sei
    // *KERNEL_IRQ = &irq
    // [5] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_KEYBOARD)(void()) irq() -- _deref_pptc1=pprc2 
    lda #<irq
    sta KERNEL_IRQ
    lda #>irq
    sta KERNEL_IRQ+1
    // asm
    // asm { cli  }
    cli
    // main::@return
    // }
    // [7] return 
    rts
}
  // irq
// The Interrupt Handler
irq: {
    // entry interrupt(KERNEL_KEYBOARD)
    // *BGCOL = WHITE
    // [8] *((const byte*) BGCOL#0) ← (const byte) WHITE#0 -- _deref_pbuc1=vbuc2 
    lda #WHITE
    sta BGCOL
    // *BGCOL = BLACK
    // [9] *((const byte*) BGCOL#0) ← (const byte) BLACK#0 -- _deref_pbuc1=vbuc2 
    lda #BLACK
    sta BGCOL
    // irq::@return
    // }
    // [10] return  - exit interrupt(KERNEL_KEYBOARD)
    jmp $ea31
}
  // File Data

