Resolved forward reference irq_bottom_1 to interrupt(KERNEL_MIN)(void()) irq_bottom_1()
Resolved forward reference irq_bottom_2 to interrupt(KERNEL_KEYBOARD)(void()) irq_bottom_2()
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) @5
Culled Empty Block (label) @6

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) RASTER#0 ← ((byte*)) (number) $d012
  (byte*) BORDERCOL#0 ← ((byte*)) (number) $d020
  (byte*) VIC_CONTROL#0 ← ((byte*)) (number) $d011
  (byte) VIC_RSEL#0 ← (number) 8
  (byte*) IRQ_STATUS#0 ← ((byte*)) (number) $d019
  (byte*) IRQ_ENABLE#0 ← ((byte*)) (number) $d01a
  (byte) IRQ_RASTER#0 ← (number) 1
  (byte*) CIA1_INTERRUPT#0 ← ((byte*)) (number) $dc0d
  (byte) CIA_INTERRUPT_CLEAR#0 ← (number) $7f
  (void()**) KERNEL_IRQ#0 ← ((void()**)) (number) $314
  (byte) WHITE#0 ← (number) 1
  (byte) RED#0 ← (number) 2
  to:@4
@4: scope:[]  from @begin
  (byte*) GHOST_BYTE#0 ← ((byte*)) (number) $3fff
  to:@7
main: scope:[main]  from @7
  *((byte*) GHOST_BYTE#0) ← (number) 0
  asm { sei  }
  *((byte*) CIA1_INTERRUPT#0) ← (byte) CIA_INTERRUPT_CLEAR#0
  *((byte*) VIC_CONTROL#0) ← *((byte*) VIC_CONTROL#0) & (number) $7f
  *((byte*) RASTER#0) ← (number) $fa
  *((byte*) IRQ_ENABLE#0) ← (byte) IRQ_RASTER#0
  (void()*~) main::$0 ← & interrupt(KERNEL_MIN)(void()) irq_bottom_1()
  *((void()**) KERNEL_IRQ#0) ← (void()*~) main::$0
  asm { cli  }
  to:main::@return
main::@return: scope:[main]  from main
  return 
  to:@return
irq_bottom_1: scope:[irq_bottom_1]  from
  *((byte*) BORDERCOL#0) ← (byte) WHITE#0
  (number~) irq_bottom_1::$0 ← (number) $ff ^ (byte) VIC_RSEL#0
  *((byte*) VIC_CONTROL#0) ← *((byte*) VIC_CONTROL#0) & (number~) irq_bottom_1::$0
  *((byte*) IRQ_STATUS#0) ← (byte) IRQ_RASTER#0
  *((byte*) RASTER#0) ← (number) $fd
  (void()*~) irq_bottom_1::$1 ← & interrupt(KERNEL_KEYBOARD)(void()) irq_bottom_2()
  *((void()**) KERNEL_IRQ#0) ← (void()*~) irq_bottom_1::$1
  *((byte*) BORDERCOL#0) ← (byte) RED#0
  to:irq_bottom_1::@return
irq_bottom_1::@return: scope:[irq_bottom_1]  from irq_bottom_1
  return 
  to:@return
irq_bottom_2: scope:[irq_bottom_2]  from
  *((byte*) BORDERCOL#0) ← (byte) WHITE#0
  *((byte*) VIC_CONTROL#0) ← *((byte*) VIC_CONTROL#0) | (byte) VIC_RSEL#0
  *((byte*) IRQ_STATUS#0) ← (byte) IRQ_RASTER#0
  *((byte*) RASTER#0) ← (number) $fa
  (void()*~) irq_bottom_2::$0 ← & interrupt(KERNEL_MIN)(void()) irq_bottom_1()
  *((void()**) KERNEL_IRQ#0) ← (void()*~) irq_bottom_2::$0
  *((byte*) BORDERCOL#0) ← (byte) RED#0
  to:irq_bottom_2::@return
irq_bottom_2::@return: scope:[irq_bottom_2]  from irq_bottom_2
  return 
  to:@return
@7: scope:[]  from @4
  call main 
  to:@8
@8: scope:[]  from @7
  to:@end
@end: scope:[]  from @8

SYMBOL TABLE SSA
(label) @4
(label) @7
(label) @8
(label) @begin
(label) @end
(byte*) BORDERCOL
(byte*) BORDERCOL#0
(byte*) CIA1_INTERRUPT
(byte*) CIA1_INTERRUPT#0
(byte) CIA_INTERRUPT_CLEAR
(byte) CIA_INTERRUPT_CLEAR#0
(byte*) GHOST_BYTE
(byte*) GHOST_BYTE#0
(byte*) IRQ_ENABLE
(byte*) IRQ_ENABLE#0
(byte) IRQ_RASTER
(byte) IRQ_RASTER#0
(byte*) IRQ_STATUS
(byte*) IRQ_STATUS#0
(void()**) KERNEL_IRQ
(void()**) KERNEL_IRQ#0
(byte*) RASTER
(byte*) RASTER#0
(byte) RED
(byte) RED#0
(byte*) VIC_CONTROL
(byte*) VIC_CONTROL#0
(byte) VIC_RSEL
(byte) VIC_RSEL#0
(byte) WHITE
(byte) WHITE#0
interrupt(KERNEL_MIN)(void()) irq_bottom_1()
(number~) irq_bottom_1::$0
(void()*~) irq_bottom_1::$1
(label) irq_bottom_1::@return
interrupt(KERNEL_KEYBOARD)(void()) irq_bottom_2()
(void()*~) irq_bottom_2::$0
(label) irq_bottom_2::@return
(void()) main()
(void()*~) main::$0
(label) main::@return

Adding number conversion cast (unumber) 8 in (byte) VIC_RSEL#0 ← (number) 8
Adding number conversion cast (unumber) 1 in (byte) IRQ_RASTER#0 ← (number) 1
Adding number conversion cast (unumber) $7f in (byte) CIA_INTERRUPT_CLEAR#0 ← (number) $7f
Adding number conversion cast (unumber) 1 in (byte) WHITE#0 ← (number) 1
Adding number conversion cast (unumber) 2 in (byte) RED#0 ← (number) 2
Adding number conversion cast (unumber) 0 in *((byte*) GHOST_BYTE#0) ← (number) 0
Adding number conversion cast (unumber) $7f in *((byte*) VIC_CONTROL#0) ← *((byte*) VIC_CONTROL#0) & (number) $7f
Adding number conversion cast (unumber) $fa in *((byte*) RASTER#0) ← (number) $fa
Adding number conversion cast (unumber) $ff in (number~) irq_bottom_1::$0 ← (number) $ff ^ (byte) VIC_RSEL#0
Adding number conversion cast (unumber) irq_bottom_1::$0 in (number~) irq_bottom_1::$0 ← (unumber)(number) $ff ^ (byte) VIC_RSEL#0
Adding number conversion cast (unumber) $fd in *((byte*) RASTER#0) ← (number) $fd
Adding number conversion cast (unumber) $fa in *((byte*) RASTER#0) ← (number) $fa
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) RASTER#0 ← (byte*)(number) $d012
Inlining cast (byte*) BORDERCOL#0 ← (byte*)(number) $d020
Inlining cast (byte*) VIC_CONTROL#0 ← (byte*)(number) $d011
Inlining cast (byte) VIC_RSEL#0 ← (unumber)(number) 8
Inlining cast (byte*) IRQ_STATUS#0 ← (byte*)(number) $d019
Inlining cast (byte*) IRQ_ENABLE#0 ← (byte*)(number) $d01a
Inlining cast (byte) IRQ_RASTER#0 ← (unumber)(number) 1
Inlining cast (byte*) CIA1_INTERRUPT#0 ← (byte*)(number) $dc0d
Inlining cast (byte) CIA_INTERRUPT_CLEAR#0 ← (unumber)(number) $7f
Inlining cast (void()**) KERNEL_IRQ#0 ← (void()**)(number) $314
Inlining cast (byte) WHITE#0 ← (unumber)(number) 1
Inlining cast (byte) RED#0 ← (unumber)(number) 2
Inlining cast (byte*) GHOST_BYTE#0 ← (byte*)(number) $3fff
Inlining cast *((byte*) GHOST_BYTE#0) ← (unumber)(number) 0
Inlining cast *((byte*) RASTER#0) ← (unumber)(number) $fa
Inlining cast *((byte*) RASTER#0) ← (unumber)(number) $fd
Inlining cast *((byte*) RASTER#0) ← (unumber)(number) $fa
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 53266
Simplifying constant pointer cast (byte*) 53280
Simplifying constant pointer cast (byte*) 53265
Simplifying constant integer cast 8
Simplifying constant pointer cast (byte*) 53273
Simplifying constant pointer cast (byte*) 53274
Simplifying constant integer cast 1
Simplifying constant pointer cast (byte*) 56333
Simplifying constant integer cast $7f
Simplifying constant pointer cast (void()**) 788
Simplifying constant integer cast 1
Simplifying constant integer cast 2
Simplifying constant pointer cast (byte*) 16383
Simplifying constant integer cast 0
Simplifying constant integer cast $7f
Simplifying constant integer cast $fa
Simplifying constant integer cast $ff
Simplifying constant integer cast $fd
Simplifying constant integer cast $fa
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 8
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) $7f
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $7f
Finalized unsigned number type (byte) $fa
Finalized unsigned number type (byte) $ff
Finalized unsigned number type (byte) $fd
Finalized unsigned number type (byte) $fa
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) irq_bottom_1::$0 ← (byte) $ff ^ (byte) VIC_RSEL#0
Constant right-side identified [19] (void()*~) main::$0 ← & interrupt(KERNEL_MIN)(void()) irq_bottom_1()
Constant right-side identified [28] (void()*~) irq_bottom_1::$1 ← & interrupt(KERNEL_KEYBOARD)(void()) irq_bottom_2()
Constant right-side identified [36] (void()*~) irq_bottom_2::$0 ← & interrupt(KERNEL_MIN)(void()) irq_bottom_1()
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) RASTER#0 = (byte*) 53266
Constant (const byte*) BORDERCOL#0 = (byte*) 53280
Constant (const byte*) VIC_CONTROL#0 = (byte*) 53265
Constant (const byte) VIC_RSEL#0 = 8
Constant (const byte*) IRQ_STATUS#0 = (byte*) 53273
Constant (const byte*) IRQ_ENABLE#0 = (byte*) 53274
Constant (const byte) IRQ_RASTER#0 = 1
Constant (const byte*) CIA1_INTERRUPT#0 = (byte*) 56333
Constant (const byte) CIA_INTERRUPT_CLEAR#0 = $7f
Constant (const void()**) KERNEL_IRQ#0 = (void()**) 788
Constant (const byte) WHITE#0 = 1
Constant (const byte) RED#0 = 2
Constant (const byte*) GHOST_BYTE#0 = (byte*) 16383
Constant (const void()*) main::$0 = &irq_bottom_1
Constant (const void()*) irq_bottom_1::$1 = &irq_bottom_2
Constant (const void()*) irq_bottom_2::$0 = &irq_bottom_1
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [10] (byte~) irq_bottom_1::$0 ← (byte) $ff ^ (const byte) VIC_RSEL#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) irq_bottom_1::$0 = $ff^VIC_RSEL#0
Successful SSA optimization Pass2ConstantIdentification
Constant inlined irq_bottom_2::$0 = &interrupt(KERNEL_MIN)(void()) irq_bottom_1()
Constant inlined irq_bottom_1::$0 = (byte) $ff^(const byte) VIC_RSEL#0
Constant inlined main::$0 = &interrupt(KERNEL_MIN)(void()) irq_bottom_1()
Constant inlined irq_bottom_1::$1 = &interrupt(KERNEL_KEYBOARD)(void()) irq_bottom_2()
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @4
Adding NOP phi() at start of @7
Adding NOP phi() at start of @8
Adding NOP phi() at start of @end
CALL GRAPH
Calls in [] to main:3 

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block (label) @4
Culled Empty Block (label) @8
Renumbering block @7 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*) GHOST_BYTE#0) ← (byte) 0
  asm { sei  }
  [6] *((const byte*) CIA1_INTERRUPT#0) ← (const byte) CIA_INTERRUPT_CLEAR#0
  [7] *((const byte*) VIC_CONTROL#0) ← *((const byte*) VIC_CONTROL#0) & (byte) $7f
  [8] *((const byte*) RASTER#0) ← (byte) $fa
  [9] *((const byte*) IRQ_ENABLE#0) ← (const byte) IRQ_RASTER#0
  [10] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq_bottom_1()
  asm { cli  }
  to:main::@return
main::@return: scope:[main]  from main
  [12] return 
  to:@return
irq_bottom_2: scope:[irq_bottom_2]  from
  [13] *((const byte*) BORDERCOL#0) ← (const byte) WHITE#0
  [14] *((const byte*) VIC_CONTROL#0) ← *((const byte*) VIC_CONTROL#0) | (const byte) VIC_RSEL#0
  [15] *((const byte*) IRQ_STATUS#0) ← (const byte) IRQ_RASTER#0
  [16] *((const byte*) RASTER#0) ← (byte) $fa
  [17] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq_bottom_1()
  [18] *((const byte*) BORDERCOL#0) ← (const byte) RED#0
  to:irq_bottom_2::@return
irq_bottom_2::@return: scope:[irq_bottom_2]  from irq_bottom_2
  [19] return 
  to:@return
irq_bottom_1: scope:[irq_bottom_1]  from
  [20] *((const byte*) BORDERCOL#0) ← (const byte) WHITE#0
  [21] *((const byte*) VIC_CONTROL#0) ← *((const byte*) VIC_CONTROL#0) & (byte) $ff^(const byte) VIC_RSEL#0
  [22] *((const byte*) IRQ_STATUS#0) ← (const byte) IRQ_RASTER#0
  [23] *((const byte*) RASTER#0) ← (byte) $fd
  [24] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_KEYBOARD)(void()) irq_bottom_2()
  [25] *((const byte*) BORDERCOL#0) ← (const byte) RED#0
  to:irq_bottom_1::@return
irq_bottom_1::@return: scope:[irq_bottom_1]  from irq_bottom_1
  [26] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte*) BORDERCOL
(byte*) CIA1_INTERRUPT
(byte) CIA_INTERRUPT_CLEAR
(byte*) GHOST_BYTE
(byte*) IRQ_ENABLE
(byte) IRQ_RASTER
(byte*) IRQ_STATUS
(void()**) KERNEL_IRQ
(byte*) RASTER
(byte) RED
(byte*) VIC_CONTROL
(byte) VIC_RSEL
(byte) WHITE
interrupt(KERNEL_MIN)(void()) irq_bottom_1()
interrupt(KERNEL_KEYBOARD)(void()) irq_bottom_2()
(void()) main()

Initial phi equivalence classes
Complete equivalence classes

INITIAL ASM
  // File Comments
// A raster IRQ that opens the top/bottom border.
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label RASTER = $d012
  .label BORDERCOL = $d020
  .label VIC_CONTROL = $d011
  .const VIC_RSEL = 8
  // VIC II IRQ Status Register
  .label IRQ_STATUS = $d019
  // VIC II IRQ Enable Register
  .label IRQ_ENABLE = $d01a
  // Bits for the IRQ Status/Enable Registers
  .const IRQ_RASTER = 1
  // CIA#1 Interrupt Status & Control Register
  .label CIA1_INTERRUPT = $dc0d
  // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
  .const CIA_INTERRUPT_CLEAR = $7f
  // The vector used when the KERNAL serves IRQ interrupts
  .label KERNEL_IRQ = $314
  .const WHITE = 1
  .const RED = 2
  .label GHOST_BYTE = $3fff
  // @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: {
    // [4] *((const byte*) GHOST_BYTE#0) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta GHOST_BYTE
    // asm { sei  }
    sei
    // [6] *((const byte*) CIA1_INTERRUPT#0) ← (const byte) CIA_INTERRUPT_CLEAR#0 -- _deref_pbuc1=vbuc2 
    // Disable CIA 1 Timer IRQ
    lda #CIA_INTERRUPT_CLEAR
    sta CIA1_INTERRUPT
    // [7] *((const byte*) VIC_CONTROL#0) ← *((const byte*) VIC_CONTROL#0) & (byte) $7f -- _deref_pbuc1=_deref_pbuc1_band_vbuc2 
    // Set raster line to $fa
    lda #$7f
    and VIC_CONTROL
    sta VIC_CONTROL
    // [8] *((const byte*) RASTER#0) ← (byte) $fa -- _deref_pbuc1=vbuc2 
    lda #$fa
    sta RASTER
    // [9] *((const byte*) IRQ_ENABLE#0) ← (const byte) IRQ_RASTER#0 -- _deref_pbuc1=vbuc2 
    // Enable Raster Interrupt
    lda #IRQ_RASTER
    sta IRQ_ENABLE
    // [10] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq_bottom_1() -- _deref_pptc1=pprc2 
    // Set the IRQ routine
    lda #<irq_bottom_1
    sta KERNEL_IRQ
    lda #>irq_bottom_1
    sta KERNEL_IRQ+1
    // asm { cli  }
    cli
    jmp breturn
    // main::@return
  breturn:
    // [12] return 
    rts
}
  // irq_bottom_2
// Interrupt Routine 2
irq_bottom_2: {
    // entry interrupt(KERNEL_KEYBOARD)
    // [13] *((const byte*) BORDERCOL#0) ← (const byte) WHITE#0 -- _deref_pbuc1=vbuc2 
    lda #WHITE
    sta BORDERCOL
    // [14] *((const byte*) VIC_CONTROL#0) ← *((const byte*) VIC_CONTROL#0) | (const byte) VIC_RSEL#0 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2 
    // Set screen height back to 25 lines (preparing for the next screen)
    lda #VIC_RSEL
    ora VIC_CONTROL
    sta VIC_CONTROL
    // [15] *((const byte*) IRQ_STATUS#0) ← (const byte) IRQ_RASTER#0 -- _deref_pbuc1=vbuc2 
    // Acknowledge the IRQ
    lda #IRQ_RASTER
    sta IRQ_STATUS
    // [16] *((const byte*) RASTER#0) ← (byte) $fa -- _deref_pbuc1=vbuc2 
    // Trigger IRQ 1 at line $fa
    lda #$fa
    sta RASTER
    // [17] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq_bottom_1() -- _deref_pptc1=pprc2 
    lda #<irq_bottom_1
    sta KERNEL_IRQ
    lda #>irq_bottom_1
    sta KERNEL_IRQ+1
    // [18] *((const byte*) BORDERCOL#0) ← (const byte) RED#0 -- _deref_pbuc1=vbuc2 
    lda #RED
    sta BORDERCOL
    jmp breturn
    // irq_bottom_2::@return
  breturn:
    // [19] return  - exit interrupt(KERNEL_KEYBOARD)
    jmp $ea31
}
  // irq_bottom_1
// Interrupt Routine 1
irq_bottom_1: {
    // entry interrupt(KERNEL_MIN)
    // [20] *((const byte*) BORDERCOL#0) ← (const byte) WHITE#0 -- _deref_pbuc1=vbuc2 
    lda #WHITE
    sta BORDERCOL
    // [21] *((const byte*) VIC_CONTROL#0) ← *((const byte*) VIC_CONTROL#0) & (byte) $ff^(const byte) VIC_RSEL#0 -- _deref_pbuc1=_deref_pbuc1_band_vbuc2 
    // Set screen height to 24 lines - this is done after the border should have started drawing - so it wont start
    lda #$ff^VIC_RSEL
    and VIC_CONTROL
    sta VIC_CONTROL
    // [22] *((const byte*) IRQ_STATUS#0) ← (const byte) IRQ_RASTER#0 -- _deref_pbuc1=vbuc2 
    // Acknowledge the IRQ
    lda #IRQ_RASTER
    sta IRQ_STATUS
    // [23] *((const byte*) RASTER#0) ← (byte) $fd -- _deref_pbuc1=vbuc2 
    // Trigger IRQ 2 at line $fd
    lda #$fd
    sta RASTER
    // [24] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_KEYBOARD)(void()) irq_bottom_2() -- _deref_pptc1=pprc2 
    lda #<irq_bottom_2
    sta KERNEL_IRQ
    lda #>irq_bottom_2
    sta KERNEL_IRQ+1
    // [25] *((const byte*) BORDERCOL#0) ← (const byte) RED#0 -- _deref_pbuc1=vbuc2 
    lda #RED
    sta BORDERCOL
    jmp breturn
    // irq_bottom_1::@return
  breturn:
    // [26] return  - exit interrupt(KERNEL_MIN)
    jmp $ea81
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] *((const byte*) GHOST_BYTE#0) ← (byte) 0 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [6] *((const byte*) CIA1_INTERRUPT#0) ← (const byte) CIA_INTERRUPT_CLEAR#0 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [7] *((const byte*) VIC_CONTROL#0) ← *((const byte*) VIC_CONTROL#0) & (byte) $7f [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [8] *((const byte*) RASTER#0) ← (byte) $fa [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [9] *((const byte*) IRQ_ENABLE#0) ← (const byte) IRQ_RASTER#0 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [10] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq_bottom_1() [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [13] *((const byte*) BORDERCOL#0) ← (const byte) WHITE#0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [14] *((const byte*) VIC_CONTROL#0) ← *((const byte*) VIC_CONTROL#0) | (const byte) VIC_RSEL#0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [15] *((const byte*) IRQ_STATUS#0) ← (const byte) IRQ_RASTER#0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [16] *((const byte*) RASTER#0) ← (byte) $fa [ ] (  [ ] ) always clobbers reg byte a 
Statement [17] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq_bottom_1() [ ] (  [ ] ) always clobbers reg byte a 
Statement [18] *((const byte*) BORDERCOL#0) ← (const byte) RED#0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [20] *((const byte*) BORDERCOL#0) ← (const byte) WHITE#0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [21] *((const byte*) VIC_CONTROL#0) ← *((const byte*) VIC_CONTROL#0) & (byte) $ff^(const byte) VIC_RSEL#0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [22] *((const byte*) IRQ_STATUS#0) ← (const byte) IRQ_RASTER#0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [23] *((const byte*) RASTER#0) ← (byte) $fd [ ] (  [ ] ) always clobbers reg byte a 
Statement [24] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_KEYBOARD)(void()) irq_bottom_2() [ ] (  [ ] ) always clobbers reg byte a 
Statement [25] *((const byte*) BORDERCOL#0) ← (const byte) RED#0 [ ] (  [ ] ) always clobbers reg byte a 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 
Uplift Scope [irq_bottom_1] 
Uplift Scope [irq_bottom_2] 
Uplift Scope [] 

Uplifting [main] best 175 combination 
Uplifting [irq_bottom_1] best 175 combination 
Uplifting [irq_bottom_2] best 175 combination 
Uplifting [] best 175 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// A raster IRQ that opens the top/bottom border.
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label RASTER = $d012
  .label BORDERCOL = $d020
  .label VIC_CONTROL = $d011
  .const VIC_RSEL = 8
  // VIC II IRQ Status Register
  .label IRQ_STATUS = $d019
  // VIC II IRQ Enable Register
  .label IRQ_ENABLE = $d01a
  // Bits for the IRQ Status/Enable Registers
  .const IRQ_RASTER = 1
  // CIA#1 Interrupt Status & Control Register
  .label CIA1_INTERRUPT = $dc0d
  // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
  .const CIA_INTERRUPT_CLEAR = $7f
  // The vector used when the KERNAL serves IRQ interrupts
  .label KERNEL_IRQ = $314
  .const WHITE = 1
  .const RED = 2
  .label GHOST_BYTE = $3fff
  // @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: {
    // [4] *((const byte*) GHOST_BYTE#0) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta GHOST_BYTE
    // asm { sei  }
    sei
    // [6] *((const byte*) CIA1_INTERRUPT#0) ← (const byte) CIA_INTERRUPT_CLEAR#0 -- _deref_pbuc1=vbuc2 
    // Disable CIA 1 Timer IRQ
    lda #CIA_INTERRUPT_CLEAR
    sta CIA1_INTERRUPT
    // [7] *((const byte*) VIC_CONTROL#0) ← *((const byte*) VIC_CONTROL#0) & (byte) $7f -- _deref_pbuc1=_deref_pbuc1_band_vbuc2 
    // Set raster line to $fa
    lda #$7f
    and VIC_CONTROL
    sta VIC_CONTROL
    // [8] *((const byte*) RASTER#0) ← (byte) $fa -- _deref_pbuc1=vbuc2 
    lda #$fa
    sta RASTER
    // [9] *((const byte*) IRQ_ENABLE#0) ← (const byte) IRQ_RASTER#0 -- _deref_pbuc1=vbuc2 
    // Enable Raster Interrupt
    lda #IRQ_RASTER
    sta IRQ_ENABLE
    // [10] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq_bottom_1() -- _deref_pptc1=pprc2 
    // Set the IRQ routine
    lda #<irq_bottom_1
    sta KERNEL_IRQ
    lda #>irq_bottom_1
    sta KERNEL_IRQ+1
    // asm { cli  }
    cli
    jmp breturn
    // main::@return
  breturn:
    // [12] return 
    rts
}
  // irq_bottom_2
// Interrupt Routine 2
irq_bottom_2: {
    // entry interrupt(KERNEL_KEYBOARD)
    // [13] *((const byte*) BORDERCOL#0) ← (const byte) WHITE#0 -- _deref_pbuc1=vbuc2 
    lda #WHITE
    sta BORDERCOL
    // [14] *((const byte*) VIC_CONTROL#0) ← *((const byte*) VIC_CONTROL#0) | (const byte) VIC_RSEL#0 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2 
    // Set screen height back to 25 lines (preparing for the next screen)
    lda #VIC_RSEL
    ora VIC_CONTROL
    sta VIC_CONTROL
    // [15] *((const byte*) IRQ_STATUS#0) ← (const byte) IRQ_RASTER#0 -- _deref_pbuc1=vbuc2 
    // Acknowledge the IRQ
    lda #IRQ_RASTER
    sta IRQ_STATUS
    // [16] *((const byte*) RASTER#0) ← (byte) $fa -- _deref_pbuc1=vbuc2 
    // Trigger IRQ 1 at line $fa
    lda #$fa
    sta RASTER
    // [17] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq_bottom_1() -- _deref_pptc1=pprc2 
    lda #<irq_bottom_1
    sta KERNEL_IRQ
    lda #>irq_bottom_1
    sta KERNEL_IRQ+1
    // [18] *((const byte*) BORDERCOL#0) ← (const byte) RED#0 -- _deref_pbuc1=vbuc2 
    lda #RED
    sta BORDERCOL
    jmp breturn
    // irq_bottom_2::@return
  breturn:
    // [19] return  - exit interrupt(KERNEL_KEYBOARD)
    jmp $ea31
}
  // irq_bottom_1
// Interrupt Routine 1
irq_bottom_1: {
    // entry interrupt(KERNEL_MIN)
    // [20] *((const byte*) BORDERCOL#0) ← (const byte) WHITE#0 -- _deref_pbuc1=vbuc2 
    lda #WHITE
    sta BORDERCOL
    // [21] *((const byte*) VIC_CONTROL#0) ← *((const byte*) VIC_CONTROL#0) & (byte) $ff^(const byte) VIC_RSEL#0 -- _deref_pbuc1=_deref_pbuc1_band_vbuc2 
    // Set screen height to 24 lines - this is done after the border should have started drawing - so it wont start
    lda #$ff^VIC_RSEL
    and VIC_CONTROL
    sta VIC_CONTROL
    // [22] *((const byte*) IRQ_STATUS#0) ← (const byte) IRQ_RASTER#0 -- _deref_pbuc1=vbuc2 
    // Acknowledge the IRQ
    lda #IRQ_RASTER
    sta IRQ_STATUS
    // [23] *((const byte*) RASTER#0) ← (byte) $fd -- _deref_pbuc1=vbuc2 
    // Trigger IRQ 2 at line $fd
    lda #$fd
    sta RASTER
    // [24] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_KEYBOARD)(void()) irq_bottom_2() -- _deref_pptc1=pprc2 
    lda #<irq_bottom_2
    sta KERNEL_IRQ
    lda #>irq_bottom_2
    sta KERNEL_IRQ+1
    // [25] *((const byte*) BORDERCOL#0) ← (const byte) RED#0 -- _deref_pbuc1=vbuc2 
    lda #RED
    sta BORDERCOL
    jmp breturn
    // irq_bottom_1::@return
  breturn:
    // [26] return  - exit interrupt(KERNEL_MIN)
    jmp $ea81
}
  // 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
(byte*) BORDERCOL
(const byte*) BORDERCOL#0 BORDERCOL = (byte*) 53280
(byte*) CIA1_INTERRUPT
(const byte*) CIA1_INTERRUPT#0 CIA1_INTERRUPT = (byte*) 56333
(byte) CIA_INTERRUPT_CLEAR
(const byte) CIA_INTERRUPT_CLEAR#0 CIA_INTERRUPT_CLEAR = (byte) $7f
(byte*) GHOST_BYTE
(const byte*) GHOST_BYTE#0 GHOST_BYTE = (byte*) 16383
(byte*) IRQ_ENABLE
(const byte*) IRQ_ENABLE#0 IRQ_ENABLE = (byte*) 53274
(byte) IRQ_RASTER
(const byte) IRQ_RASTER#0 IRQ_RASTER = (byte) 1
(byte*) IRQ_STATUS
(const byte*) IRQ_STATUS#0 IRQ_STATUS = (byte*) 53273
(void()**) KERNEL_IRQ
(const void()**) KERNEL_IRQ#0 KERNEL_IRQ = (void()**) 788
(byte*) RASTER
(const byte*) RASTER#0 RASTER = (byte*) 53266
(byte) RED
(const byte) RED#0 RED = (byte) 2
(byte*) VIC_CONTROL
(const byte*) VIC_CONTROL#0 VIC_CONTROL = (byte*) 53265
(byte) VIC_RSEL
(const byte) VIC_RSEL#0 VIC_RSEL = (byte) 8
(byte) WHITE
(const byte) WHITE#0 WHITE = (byte) 1
interrupt(KERNEL_MIN)(void()) irq_bottom_1()
(label) irq_bottom_1::@return
interrupt(KERNEL_KEYBOARD)(void()) irq_bottom_2()
(label) irq_bottom_2::@return
(void()) main()
(label) main::@return



FINAL ASSEMBLER
Score: 154

  // File Comments
// A raster IRQ that opens the top/bottom border.
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .label RASTER = $d012
  .label BORDERCOL = $d020
  .label VIC_CONTROL = $d011
  .const VIC_RSEL = 8
  // VIC II IRQ Status Register
  .label IRQ_STATUS = $d019
  // VIC II IRQ Enable Register
  .label IRQ_ENABLE = $d01a
  // Bits for the IRQ Status/Enable Registers
  .const IRQ_RASTER = 1
  // CIA#1 Interrupt Status & Control Register
  .label CIA1_INTERRUPT = $dc0d
  // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
  .const CIA_INTERRUPT_CLEAR = $7f
  // The vector used when the KERNAL serves IRQ interrupts
  .label KERNEL_IRQ = $314
  .const WHITE = 1
  .const RED = 2
  .label GHOST_BYTE = $3fff
  // @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: {
    // *GHOST_BYTE = 0
    // [4] *((const byte*) GHOST_BYTE#0) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta GHOST_BYTE
    // asm
    // asm { sei  }
    sei
    // *CIA1_INTERRUPT = CIA_INTERRUPT_CLEAR
    // [6] *((const byte*) CIA1_INTERRUPT#0) ← (const byte) CIA_INTERRUPT_CLEAR#0 -- _deref_pbuc1=vbuc2 
    // Disable CIA 1 Timer IRQ
    lda #CIA_INTERRUPT_CLEAR
    sta CIA1_INTERRUPT
    // *VIC_CONTROL &=$7f
    // [7] *((const byte*) VIC_CONTROL#0) ← *((const byte*) VIC_CONTROL#0) & (byte) $7f -- _deref_pbuc1=_deref_pbuc1_band_vbuc2 
    // Set raster line to $fa
    lda #$7f
    and VIC_CONTROL
    sta VIC_CONTROL
    // *RASTER = $fa
    // [8] *((const byte*) RASTER#0) ← (byte) $fa -- _deref_pbuc1=vbuc2 
    lda #$fa
    sta RASTER
    // *IRQ_ENABLE = IRQ_RASTER
    // [9] *((const byte*) IRQ_ENABLE#0) ← (const byte) IRQ_RASTER#0 -- _deref_pbuc1=vbuc2 
    // Enable Raster Interrupt
    lda #IRQ_RASTER
    sta IRQ_ENABLE
    // *KERNEL_IRQ = &irq_bottom_1
    // [10] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq_bottom_1() -- _deref_pptc1=pprc2 
    // Set the IRQ routine
    lda #<irq_bottom_1
    sta KERNEL_IRQ
    lda #>irq_bottom_1
    sta KERNEL_IRQ+1
    // asm
    // asm { cli  }
    cli
    // main::@return
    // }
    // [12] return 
    rts
}
  // irq_bottom_2
// Interrupt Routine 2
irq_bottom_2: {
    // entry interrupt(KERNEL_KEYBOARD)
    // *BORDERCOL = WHITE
    // [13] *((const byte*) BORDERCOL#0) ← (const byte) WHITE#0 -- _deref_pbuc1=vbuc2 
    lda #WHITE
    sta BORDERCOL
    // *VIC_CONTROL |= VIC_RSEL
    // [14] *((const byte*) VIC_CONTROL#0) ← *((const byte*) VIC_CONTROL#0) | (const byte) VIC_RSEL#0 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2 
    // Set screen height back to 25 lines (preparing for the next screen)
    lda #VIC_RSEL
    ora VIC_CONTROL
    sta VIC_CONTROL
    // *IRQ_STATUS = IRQ_RASTER
    // [15] *((const byte*) IRQ_STATUS#0) ← (const byte) IRQ_RASTER#0 -- _deref_pbuc1=vbuc2 
    // Acknowledge the IRQ
    lda #IRQ_RASTER
    sta IRQ_STATUS
    // *RASTER = $fa
    // [16] *((const byte*) RASTER#0) ← (byte) $fa -- _deref_pbuc1=vbuc2 
    // Trigger IRQ 1 at line $fa
    lda #$fa
    sta RASTER
    // *KERNEL_IRQ = &irq_bottom_1
    // [17] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq_bottom_1() -- _deref_pptc1=pprc2 
    lda #<irq_bottom_1
    sta KERNEL_IRQ
    lda #>irq_bottom_1
    sta KERNEL_IRQ+1
    // *BORDERCOL = RED
    // [18] *((const byte*) BORDERCOL#0) ← (const byte) RED#0 -- _deref_pbuc1=vbuc2 
    lda #RED
    sta BORDERCOL
    // irq_bottom_2::@return
    // }
    // [19] return  - exit interrupt(KERNEL_KEYBOARD)
    jmp $ea31
}
  // irq_bottom_1
// Interrupt Routine 1
irq_bottom_1: {
    // entry interrupt(KERNEL_MIN)
    // *BORDERCOL = WHITE
    // [20] *((const byte*) BORDERCOL#0) ← (const byte) WHITE#0 -- _deref_pbuc1=vbuc2 
    lda #WHITE
    sta BORDERCOL
    // *VIC_CONTROL &= ($ff^VIC_RSEL)
    // [21] *((const byte*) VIC_CONTROL#0) ← *((const byte*) VIC_CONTROL#0) & (byte) $ff^(const byte) VIC_RSEL#0 -- _deref_pbuc1=_deref_pbuc1_band_vbuc2 
    // Set screen height to 24 lines - this is done after the border should have started drawing - so it wont start
    lda #$ff^VIC_RSEL
    and VIC_CONTROL
    sta VIC_CONTROL
    // *IRQ_STATUS = IRQ_RASTER
    // [22] *((const byte*) IRQ_STATUS#0) ← (const byte) IRQ_RASTER#0 -- _deref_pbuc1=vbuc2 
    // Acknowledge the IRQ
    lda #IRQ_RASTER
    sta IRQ_STATUS
    // *RASTER = $fd
    // [23] *((const byte*) RASTER#0) ← (byte) $fd -- _deref_pbuc1=vbuc2 
    // Trigger IRQ 2 at line $fd
    lda #$fd
    sta RASTER
    // *KERNEL_IRQ = &irq_bottom_2
    // [24] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_KEYBOARD)(void()) irq_bottom_2() -- _deref_pptc1=pprc2 
    lda #<irq_bottom_2
    sta KERNEL_IRQ
    lda #>irq_bottom_2
    sta KERNEL_IRQ+1
    // *BORDERCOL = RED
    // [25] *((const byte*) BORDERCOL#0) ← (const byte) RED#0 -- _deref_pbuc1=vbuc2 
    lda #RED
    sta BORDERCOL
    // irq_bottom_1::@return
    // }
    // [26] return  - exit interrupt(KERNEL_MIN)
    jmp $ea81
}
  // File Data

