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

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) BORDERCOL#0 ← ((byte*)) (word/dword/signed dword) 53280
  (byte*) RASTER#0 ← ((byte*)) (word/dword/signed dword) 53266
  (byte) DARK_GREY#0 ← (byte/signed byte/word/signed word/dword/signed dword) 11
  (byte) BLACK#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  (void()**) KERNEL_IRQ#0 ← ((void()**)) (word/signed word/dword/signed dword) 788
  to:@1
main: scope:[main]  from @2
  (void()*~) main::$0 ← & interrupt(HARDWARE_CLOBBER)(void()) irq()
  *((void()**) KERNEL_IRQ#0) ← (void()*~) main::$0
  to:main::@return
main::@return: scope:[main]  from main
  return 
  to:@return
@1: scope:[]  from @begin
  (byte) BLACK#5 ← phi( @begin/(byte) BLACK#0 )
  (byte*) RASTER#5 ← phi( @begin/(byte*) RASTER#0 )
  (byte*) BORDERCOL#5 ← phi( @begin/(byte*) BORDERCOL#0 )
  (byte) DARK_GREY#3 ← phi( @begin/(byte) DARK_GREY#0 )
  (byte) irq_raster_next#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:@2
irq: scope:[irq]  from
  (byte) BLACK#2 ← phi( @2/(byte) BLACK#4 )
  (byte*) RASTER#2 ← phi( @2/(byte*) RASTER#4 )
  (byte) irq_raster_next#3 ← phi( @2/(byte) irq_raster_next#5 )
  (byte*) BORDERCOL#1 ← phi( @2/(byte*) BORDERCOL#3 )
  (byte) DARK_GREY#1 ← phi( @2/(byte) DARK_GREY#2 )
  *((byte*) BORDERCOL#1) ← (byte) DARK_GREY#1
  (byte) irq_raster_next#1 ← (byte) irq_raster_next#3 + (byte/signed byte/word/signed word/dword/signed dword) 21
  (byte) irq::raster_next#0 ← (byte) irq_raster_next#1
  (byte~) irq::$0 ← (byte) irq::raster_next#0 & (byte/signed byte/word/signed word/dword/signed dword) 7
  (bool~) irq::$1 ← (byte~) irq::$0 == (byte/signed byte/word/signed word/dword/signed dword) 0
  (bool~) irq::$2 ← ! (bool~) irq::$1
  if((bool~) irq::$2) goto irq::@1
  to:irq::@2
irq::@1: scope:[irq]  from irq irq::@2
  (byte) irq_raster_next#6 ← phi( irq/(byte) irq_raster_next#1 irq::@2/(byte) irq_raster_next#7 )
  (byte*) BORDERCOL#2 ← phi( irq/(byte*) BORDERCOL#1 irq::@2/(byte*) BORDERCOL#4 )
  (byte) BLACK#1 ← phi( irq/(byte) BLACK#2 irq::@2/(byte) BLACK#3 )
  (byte*) RASTER#1 ← phi( irq/(byte*) RASTER#2 irq::@2/(byte*) RASTER#3 )
  (byte) irq::raster_next#2 ← phi( irq/(byte) irq::raster_next#0 irq::@2/(byte) irq::raster_next#1 )
  *((byte*) RASTER#1) ← (byte) irq::raster_next#2
  *((byte*) BORDERCOL#2) ← (byte) BLACK#1
  to:irq::@return
irq::@2: scope:[irq]  from irq
  (byte) irq_raster_next#7 ← phi( irq/(byte) irq_raster_next#1 )
  (byte*) BORDERCOL#4 ← phi( irq/(byte*) BORDERCOL#1 )
  (byte) BLACK#3 ← phi( irq/(byte) BLACK#2 )
  (byte*) RASTER#3 ← phi( irq/(byte*) RASTER#2 )
  (byte) irq::raster_next#3 ← phi( irq/(byte) irq::raster_next#0 )
  (byte) irq::raster_next#1 ← (byte) irq::raster_next#3 - (byte/signed byte/word/signed word/dword/signed dword) 1
  to:irq::@1
irq::@return: scope:[irq]  from irq::@1
  (byte) irq_raster_next#4 ← phi( irq::@1/(byte) irq_raster_next#6 )
  (byte) irq_raster_next#2 ← (byte) irq_raster_next#4
  return 
  to:@return
@2: scope:[]  from @1
  (byte) BLACK#4 ← phi( @1/(byte) BLACK#5 )
  (byte*) RASTER#4 ← phi( @1/(byte*) RASTER#5 )
  (byte) irq_raster_next#5 ← phi( @1/(byte) irq_raster_next#0 )
  (byte*) BORDERCOL#3 ← phi( @1/(byte*) BORDERCOL#5 )
  (byte) DARK_GREY#2 ← phi( @1/(byte) DARK_GREY#3 )
  call main 
  to:@3
@3: scope:[]  from @2
  to:@end
@end: scope:[]  from @3

SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @3
(label) @begin
(label) @end
(byte) BLACK
(byte) BLACK#0
(byte) BLACK#1
(byte) BLACK#2
(byte) BLACK#3
(byte) BLACK#4
(byte) BLACK#5
(byte*) BORDERCOL
(byte*) BORDERCOL#0
(byte*) BORDERCOL#1
(byte*) BORDERCOL#2
(byte*) BORDERCOL#3
(byte*) BORDERCOL#4
(byte*) BORDERCOL#5
(byte) DARK_GREY
(byte) DARK_GREY#0
(byte) DARK_GREY#1
(byte) DARK_GREY#2
(byte) DARK_GREY#3
(void()**) KERNEL_IRQ
(void()**) KERNEL_IRQ#0
(byte*) RASTER
(byte*) RASTER#0
(byte*) RASTER#1
(byte*) RASTER#2
(byte*) RASTER#3
(byte*) RASTER#4
(byte*) RASTER#5
interrupt(HARDWARE_CLOBBER)(void()) irq()
(byte~) irq::$0
(bool~) irq::$1
(bool~) irq::$2
(label) irq::@1
(label) irq::@2
(label) irq::@return
(byte) irq::raster_next
(byte) irq::raster_next#0
(byte) irq::raster_next#1
(byte) irq::raster_next#2
(byte) irq::raster_next#3
(byte) irq_raster_next
(byte) irq_raster_next#0
(byte) irq_raster_next#1
(byte) irq_raster_next#2
(byte) irq_raster_next#3
(byte) irq_raster_next#4
(byte) irq_raster_next#5
(byte) irq_raster_next#6
(byte) irq_raster_next#7
(void()) main()
(void()*~) main::$0
(label) main::@return

Culled Empty Block (label) @3
Successful SSA optimization Pass2CullEmptyBlocks
Inversing boolean not [16] (bool~) irq::$2 ← (byte~) irq::$0 != (byte/signed byte/word/signed word/dword/signed dword) 0 from [15] (bool~) irq::$1 ← (byte~) irq::$0 == (byte/signed byte/word/signed word/dword/signed dword) 0
Successful SSA optimization Pass2UnaryNotSimplification
Alias (byte) DARK_GREY#0 = (byte) DARK_GREY#3 (byte) DARK_GREY#2 
Alias (byte*) BORDERCOL#0 = (byte*) BORDERCOL#5 (byte*) BORDERCOL#3 
Alias (byte*) RASTER#0 = (byte*) RASTER#5 (byte*) RASTER#4 
Alias (byte) BLACK#0 = (byte) BLACK#5 (byte) BLACK#4 
Alias (byte) irq::raster_next#0 = (byte) irq::raster_next#3 
Alias (byte*) RASTER#2 = (byte*) RASTER#3 
Alias (byte) BLACK#2 = (byte) BLACK#3 
Alias (byte*) BORDERCOL#1 = (byte*) BORDERCOL#4 
Alias (byte) irq_raster_next#1 = (byte) irq_raster_next#7 
Alias (byte) irq_raster_next#2 = (byte) irq_raster_next#4 (byte) irq_raster_next#6 
Alias (byte) irq_raster_next#0 = (byte) irq_raster_next#5 
Successful SSA optimization Pass2AliasElimination
Alias (byte*) RASTER#1 = (byte*) RASTER#2 
Alias (byte) BLACK#1 = (byte) BLACK#2 
Alias (byte*) BORDERCOL#1 = (byte*) BORDERCOL#2 
Alias (byte) irq_raster_next#1 = (byte) irq_raster_next#2 
Successful SSA optimization Pass2AliasElimination
Redundant Phi (byte) DARK_GREY#1 (byte) DARK_GREY#0
Redundant Phi (byte*) BORDERCOL#1 (byte*) BORDERCOL#0
Redundant Phi (byte) irq_raster_next#3 (byte) irq_raster_next#0
Redundant Phi (byte*) RASTER#1 (byte*) RASTER#0
Redundant Phi (byte) BLACK#1 (byte) BLACK#0
Successful SSA optimization Pass2RedundantPhiElimination
Simple Condition (bool~) irq::$2 [17] if((byte~) irq::$0!=(byte/signed byte/word/signed word/dword/signed dword) 0) goto irq::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) BORDERCOL#0 = ((byte*))53280
Constant (const byte*) RASTER#0 = ((byte*))53266
Constant (const byte) DARK_GREY#0 = 11
Constant (const byte) BLACK#0 = 0
Constant (const void()**) KERNEL_IRQ#0 = ((void()**))788
Constant (const void()*) main::$0 = &irq
Successful SSA optimization Pass2ConstantIdentification
Constant inlined main::$0 = &interrupt(HARDWARE_CLOBBER)(void()) irq()
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting irq::@3(between irq and irq::@1)
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:3 

Created 1 initial phi equivalence classes
Coalesced [13] irq::raster_next#5 ← irq::raster_next#1
Coalesced [18] irq::raster_next#4 ← irq::raster_next#0
Coalesced down to 1 phi equivalence classes
Culled Empty Block (label) irq::@3
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:@1
@1: scope:[]  from @begin
  [1] (byte) irq_raster_next#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:@2
@2: scope:[]  from @1
  [2] phi()
  [3] call main 
  to:@end
@end: scope:[]  from @2
  [4] phi()
main: scope:[main]  from @2
  [5] *((const void()**) KERNEL_IRQ#0) ← &interrupt(HARDWARE_CLOBBER)(void()) irq()
  to:main::@return
main::@return: scope:[main]  from main
  [6] return 
  to:@return
irq: scope:[irq]  from
  [7] *((const byte*) BORDERCOL#0) ← (const byte) DARK_GREY#0
  [8] (byte) irq_raster_next#1 ← (byte) irq_raster_next#0 + (byte/signed byte/word/signed word/dword/signed dword) 21
  [9] (byte) irq::raster_next#0 ← (byte) irq_raster_next#1
  [10] (byte~) irq::$0 ← (byte) irq::raster_next#0 & (byte/signed byte/word/signed word/dword/signed dword) 7
  [11] if((byte~) irq::$0!=(byte/signed byte/word/signed word/dword/signed dword) 0) goto irq::@1
  to:irq::@2
irq::@2: scope:[irq]  from irq
  [12] (byte) irq::raster_next#1 ← (byte) irq::raster_next#0 - (byte/signed byte/word/signed word/dword/signed dword) 1
  to:irq::@1
irq::@1: scope:[irq]  from irq irq::@2
  [13] (byte) irq::raster_next#2 ← phi( irq/(byte) irq::raster_next#0 irq::@2/(byte) irq::raster_next#1 )
  [14] *((const byte*) RASTER#0) ← (byte) irq::raster_next#2
  [15] *((const byte*) BORDERCOL#0) ← (const byte) BLACK#0
  to:irq::@return
irq::@return: scope:[irq]  from irq::@1
  [16] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte) BLACK
(byte*) BORDERCOL
(byte) DARK_GREY
(void()**) KERNEL_IRQ
(byte*) RASTER
interrupt(HARDWARE_CLOBBER)(void()) irq()
(byte~) irq::$0 4.0
(byte) irq::raster_next
(byte) irq::raster_next#0 2.6666666666666665
(byte) irq::raster_next#1 4.0
(byte) irq::raster_next#2 6.0
(byte) irq_raster_next
(byte) irq_raster_next#0 4.0
(byte) irq_raster_next#1 4.0
(void()) main()

Initial phi equivalence classes
[ irq::raster_next#2 irq::raster_next#0 irq::raster_next#1 ]
Added variable irq_raster_next#0 to zero page equivalence class [ irq_raster_next#0 ]
Added variable irq_raster_next#1 to zero page equivalence class [ irq_raster_next#1 ]
Added variable irq::$0 to zero page equivalence class [ irq::$0 ]
Complete equivalence classes
[ irq::raster_next#2 irq::raster_next#0 irq::raster_next#1 ]
[ irq_raster_next#0 ]
[ irq_raster_next#1 ]
[ irq::$0 ]
Allocated zp ZP_BYTE:2 [ irq::raster_next#2 irq::raster_next#0 irq::raster_next#1 ]
Allocated zp ZP_BYTE:3 [ irq_raster_next#0 ]
Allocated zp ZP_BYTE:4 [ irq_raster_next#1 ]
Allocated zp ZP_BYTE:5 [ irq::$0 ]

INITIAL ASM
//SEG0 File Comments
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label BORDERCOL = $d020
  .label RASTER = $d012
  .const DARK_GREY = $b
  .const BLACK = 0
  .label KERNEL_IRQ = $314
  .label irq_raster_next = 3
  .label irq_raster_next_1 = 4
//SEG3 @begin
bbegin:
  jmp b1
//SEG4 @1
b1:
//SEG5 [1] (byte) irq_raster_next#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0 -- vbuz1=vbuc1 
  lda #0
  sta irq_raster_next
//SEG6 [2] phi from @1 to @2 [phi:@1->@2]
b2_from_b1:
  jmp b2
//SEG7 @2
b2:
//SEG8 [3] call main 
  jsr main
//SEG9 [4] phi from @2 to @end [phi:@2->@end]
bend_from_b2:
  jmp bend
//SEG10 @end
bend:
//SEG11 main
main: {
  //SEG12 [5] *((const void()**) KERNEL_IRQ#0) ← &interrupt(HARDWARE_CLOBBER)(void()) irq() -- _deref_pptc1=pprc2 
    lda #<irq
    sta KERNEL_IRQ
    lda #>irq
    sta KERNEL_IRQ+1
    jmp breturn
  //SEG13 main::@return
  breturn:
  //SEG14 [6] return 
    rts
}
//SEG15 irq
irq: {
    .label _0 = 5
    .label raster_next = 2
  //SEG16 entry interrupt(HARDWARE_CLOBBER)
    sta rega+1
    stx regx+1
    sty regy+1
  //SEG17 [7] *((const byte*) BORDERCOL#0) ← (const byte) DARK_GREY#0 -- _deref_pbuc1=vbuc2 
    lda #DARK_GREY
    sta BORDERCOL
  //SEG18 [8] (byte) irq_raster_next#1 ← (byte) irq_raster_next#0 + (byte/signed byte/word/signed word/dword/signed dword) 21 -- vbuz1=vbuz2_plus_vbuc1 
    lda #$15
    clc
    adc irq_raster_next
    sta irq_raster_next_1
  //SEG19 [9] (byte) irq::raster_next#0 ← (byte) irq_raster_next#1 -- vbuz1=vbuz2 
    // Setup next interrupt
    lda irq_raster_next_1
    sta raster_next
  //SEG20 [10] (byte~) irq::$0 ← (byte) irq::raster_next#0 & (byte/signed byte/word/signed word/dword/signed dword) 7 -- vbuz1=vbuz2_band_vbuc1 
    lda #7
    and raster_next
    sta _0
  //SEG21 [11] if((byte~) irq::$0!=(byte/signed byte/word/signed word/dword/signed dword) 0) goto irq::@1 -- vbuz1_neq_0_then_la1 
    lda _0
    cmp #0
    bne b1_from_irq
    jmp b2
  //SEG22 irq::@2
  b2:
  //SEG23 [12] (byte) irq::raster_next#1 ← (byte) irq::raster_next#0 - (byte/signed byte/word/signed word/dword/signed dword) 1 -- vbuz1=vbuz1_minus_1 
    dec raster_next
  //SEG24 [13] phi from irq irq::@2 to irq::@1 [phi:irq/irq::@2->irq::@1]
  b1_from_irq:
  b1_from_b2:
  //SEG25 [13] phi (byte) irq::raster_next#2 = (byte) irq::raster_next#0 [phi:irq/irq::@2->irq::@1#0] -- register_copy 
    jmp b1
  //SEG26 irq::@1
  b1:
  //SEG27 [14] *((const byte*) RASTER#0) ← (byte) irq::raster_next#2 -- _deref_pbuc1=vbuz1 
    lda raster_next
    sta RASTER
  //SEG28 [15] *((const byte*) BORDERCOL#0) ← (const byte) BLACK#0 -- _deref_pbuc1=vbuc2 
    lda #BLACK
    sta BORDERCOL
    jmp breturn
  //SEG29 irq::@return
  breturn:
  //SEG30 [16] return  - exit interrupt(HARDWARE_CLOBBER)
  rega:
    lda #00
  regx:
    ldx #00
  regy:
    ldy #00
    rti
}

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [1] (byte) irq_raster_next#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0 [ ] ( ) always clobbers reg byte a 
Statement [5] *((const void()**) KERNEL_IRQ#0) ← &interrupt(HARDWARE_CLOBBER)(void()) irq() [ ] ( main:3 [ ] ) always clobbers reg byte a 
Statement [7] *((const byte*) BORDERCOL#0) ← (const byte) DARK_GREY#0 [ irq_raster_next#0 ] (  [ irq_raster_next#0 ] ) always clobbers reg byte a 
Statement [8] (byte) irq_raster_next#1 ← (byte) irq_raster_next#0 + (byte/signed byte/word/signed word/dword/signed dword) 21 [ irq_raster_next#1 ] (  [ irq_raster_next#1 ] ) always clobbers reg byte a 
Statement [10] (byte~) irq::$0 ← (byte) irq::raster_next#0 & (byte/signed byte/word/signed word/dword/signed dword) 7 [ irq::raster_next#0 irq::$0 ] (  [ irq::raster_next#0 irq::$0 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ irq::raster_next#2 irq::raster_next#0 irq::raster_next#1 ]
Statement [15] *((const byte*) BORDERCOL#0) ← (const byte) BLACK#0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [16] return  [ ] (  [ ] ) always clobbers reg byte a reg byte x reg byte y 
Statement [1] (byte) irq_raster_next#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0 [ ] ( ) always clobbers reg byte a 
Statement [5] *((const void()**) KERNEL_IRQ#0) ← &interrupt(HARDWARE_CLOBBER)(void()) irq() [ ] ( main:3 [ ] ) always clobbers reg byte a 
Statement [7] *((const byte*) BORDERCOL#0) ← (const byte) DARK_GREY#0 [ irq_raster_next#0 ] (  [ irq_raster_next#0 ] ) always clobbers reg byte a 
Statement [8] (byte) irq_raster_next#1 ← (byte) irq_raster_next#0 + (byte/signed byte/word/signed word/dword/signed dword) 21 [ irq_raster_next#1 ] (  [ irq_raster_next#1 ] ) always clobbers reg byte a 
Statement [10] (byte~) irq::$0 ← (byte) irq::raster_next#0 & (byte/signed byte/word/signed word/dword/signed dword) 7 [ irq::raster_next#0 irq::$0 ] (  [ irq::raster_next#0 irq::$0 ] ) always clobbers reg byte a 
Statement [15] *((const byte*) BORDERCOL#0) ← (const byte) BLACK#0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [16] return  [ ] (  [ ] ) always clobbers reg byte a reg byte x reg byte y 
Potential registers zp ZP_BYTE:2 [ irq::raster_next#2 irq::raster_next#0 irq::raster_next#1 ] : zp ZP_BYTE:2 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:3 [ irq_raster_next#0 ] : zp ZP_BYTE:3 , 
Potential registers zp ZP_BYTE:4 [ irq_raster_next#1 ] : zp ZP_BYTE:4 , 
Potential registers zp ZP_BYTE:5 [ irq::$0 ] : zp ZP_BYTE:5 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [irq] 12.67: zp ZP_BYTE:2 [ irq::raster_next#2 irq::raster_next#0 irq::raster_next#1 ] 4: zp ZP_BYTE:5 [ irq::$0 ] 
Uplift Scope [] 4: zp ZP_BYTE:3 [ irq_raster_next#0 ] 4: zp ZP_BYTE:4 [ irq_raster_next#1 ] 
Uplift Scope [main] 

Uplifting [irq] best 248 combination reg byte x [ irq::raster_next#2 irq::raster_next#0 irq::raster_next#1 ] reg byte a [ irq::$0 ] 
Uplifting [] best 248 combination zp ZP_BYTE:3 [ irq_raster_next#0 ] zp ZP_BYTE:4 [ irq_raster_next#1 ] 
Uplifting [main] best 248 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:3 [ irq_raster_next#0 ]
Uplifting [] best 248 combination zp ZP_BYTE:3 [ irq_raster_next#0 ] 
Attempting to uplift remaining variables inzp ZP_BYTE:4 [ irq_raster_next#1 ]
Uplifting [] best 248 combination zp ZP_BYTE:4 [ irq_raster_next#1 ] 
Coalescing zero page register with common assignment [ zp ZP_BYTE:3 [ irq_raster_next#0 ] ] with [ zp ZP_BYTE:4 [ irq_raster_next#1 ] ] - score: 1
Allocated (was zp ZP_BYTE:3) zp ZP_BYTE:2 [ irq_raster_next#0 irq_raster_next#1 ]
Interrupt procedure irq clobbers AXCNZV
Removing interrupt register storage sty regy+1 in SEG16 entry interrupt(HARDWARE_CLOBBER)
Removing interrupt register storage regy: in SEG30 [16] return  - exit interrupt(HARDWARE_CLOBBER)
Removing interrupt register storage ldy #00 in SEG30 [16] return  - exit interrupt(HARDWARE_CLOBBER)

ASSEMBLER BEFORE OPTIMIZATION
//SEG0 File Comments
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label BORDERCOL = $d020
  .label RASTER = $d012
  .const DARK_GREY = $b
  .const BLACK = 0
  .label KERNEL_IRQ = $314
  .label irq_raster_next = 2
//SEG3 @begin
bbegin:
  jmp b1
//SEG4 @1
b1:
//SEG5 [1] (byte) irq_raster_next#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0 -- vbuz1=vbuc1 
  lda #0
  sta irq_raster_next
//SEG6 [2] phi from @1 to @2 [phi:@1->@2]
b2_from_b1:
  jmp b2
//SEG7 @2
b2:
//SEG8 [3] call main 
  jsr main
//SEG9 [4] phi from @2 to @end [phi:@2->@end]
bend_from_b2:
  jmp bend
//SEG10 @end
bend:
//SEG11 main
main: {
  //SEG12 [5] *((const void()**) KERNEL_IRQ#0) ← &interrupt(HARDWARE_CLOBBER)(void()) irq() -- _deref_pptc1=pprc2 
    lda #<irq
    sta KERNEL_IRQ
    lda #>irq
    sta KERNEL_IRQ+1
    jmp breturn
  //SEG13 main::@return
  breturn:
  //SEG14 [6] return 
    rts
}
//SEG15 irq
irq: {
  //SEG16 entry interrupt(HARDWARE_CLOBBER)
    sta rega+1
    stx regx+1
  //SEG17 [7] *((const byte*) BORDERCOL#0) ← (const byte) DARK_GREY#0 -- _deref_pbuc1=vbuc2 
    lda #DARK_GREY
    sta BORDERCOL
  //SEG18 [8] (byte) irq_raster_next#1 ← (byte) irq_raster_next#0 + (byte/signed byte/word/signed word/dword/signed dword) 21 -- vbuz1=vbuz1_plus_vbuc1 
    lda #$15
    clc
    adc irq_raster_next
    sta irq_raster_next
  //SEG19 [9] (byte) irq::raster_next#0 ← (byte) irq_raster_next#1 -- vbuxx=vbuz1 
    // Setup next interrupt
    ldx irq_raster_next
  //SEG20 [10] (byte~) irq::$0 ← (byte) irq::raster_next#0 & (byte/signed byte/word/signed word/dword/signed dword) 7 -- vbuaa=vbuxx_band_vbuc1 
    txa
    and #7
  //SEG21 [11] if((byte~) irq::$0!=(byte/signed byte/word/signed word/dword/signed dword) 0) goto irq::@1 -- vbuaa_neq_0_then_la1 
    cmp #0
    bne b1_from_irq
    jmp b2
  //SEG22 irq::@2
  b2:
  //SEG23 [12] (byte) irq::raster_next#1 ← (byte) irq::raster_next#0 - (byte/signed byte/word/signed word/dword/signed dword) 1 -- vbuxx=vbuxx_minus_1 
    dex
  //SEG24 [13] phi from irq irq::@2 to irq::@1 [phi:irq/irq::@2->irq::@1]
  b1_from_irq:
  b1_from_b2:
  //SEG25 [13] phi (byte) irq::raster_next#2 = (byte) irq::raster_next#0 [phi:irq/irq::@2->irq::@1#0] -- register_copy 
    jmp b1
  //SEG26 irq::@1
  b1:
  //SEG27 [14] *((const byte*) RASTER#0) ← (byte) irq::raster_next#2 -- _deref_pbuc1=vbuxx 
    stx RASTER
  //SEG28 [15] *((const byte*) BORDERCOL#0) ← (const byte) BLACK#0 -- _deref_pbuc1=vbuc2 
    lda #BLACK
    sta BORDERCOL
    jmp breturn
  //SEG29 irq::@return
  breturn:
  //SEG30 [16] return  - exit interrupt(HARDWARE_CLOBBER)
  rega:
    lda #00
  regx:
    ldx #00
    rti
}

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp bend
Removing instruction jmp breturn
Removing instruction jmp b2
Removing instruction jmp b1
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing instruction ldx irq_raster_next with TAX
Replacing label b1_from_irq with b1
Removing instruction b1:
Removing instruction b2_from_b1:
Removing instruction bend_from_b2:
Removing instruction b1_from_irq:
Removing instruction b1_from_b2:
Removing instruction breturn:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction b2:
Removing instruction bend:
Removing instruction breturn:
Removing instruction b2:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @2
(label) @begin
(label) @end
(byte) BLACK
(const byte) BLACK#0 BLACK = (byte/signed byte/word/signed word/dword/signed dword) 0
(byte*) BORDERCOL
(const byte*) BORDERCOL#0 BORDERCOL = ((byte*))(word/dword/signed dword) 53280
(byte) DARK_GREY
(const byte) DARK_GREY#0 DARK_GREY = (byte/signed byte/word/signed word/dword/signed dword) 11
(void()**) KERNEL_IRQ
(const void()**) KERNEL_IRQ#0 KERNEL_IRQ = ((void()**))(word/signed word/dword/signed dword) 788
(byte*) RASTER
(const byte*) RASTER#0 RASTER = ((byte*))(word/dword/signed dword) 53266
interrupt(HARDWARE_CLOBBER)(void()) irq()
(byte~) irq::$0 reg byte a 4.0
(label) irq::@1
(label) irq::@2
(label) irq::@return
(byte) irq::raster_next
(byte) irq::raster_next#0 reg byte x 2.6666666666666665
(byte) irq::raster_next#1 reg byte x 4.0
(byte) irq::raster_next#2 reg byte x 6.0
(byte) irq_raster_next
(byte) irq_raster_next#0 irq_raster_next zp ZP_BYTE:2 4.0
(byte) irq_raster_next#1 irq_raster_next zp ZP_BYTE:2 4.0
(void()) main()
(label) main::@return

reg byte x [ irq::raster_next#2 irq::raster_next#0 irq::raster_next#1 ]
zp ZP_BYTE:2 [ irq_raster_next#0 irq_raster_next#1 ]
reg byte a [ irq::$0 ]


FINAL ASSEMBLER
Score: 157

//SEG0 File Comments
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label BORDERCOL = $d020
  .label RASTER = $d012
  .const DARK_GREY = $b
  .const BLACK = 0
  .label KERNEL_IRQ = $314
  .label irq_raster_next = 2
//SEG3 @begin
bbegin:
//SEG4 @1
//SEG5 [1] (byte) irq_raster_next#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0 -- vbuz1=vbuc1 
  lda #0
  sta irq_raster_next
//SEG6 [2] phi from @1 to @2 [phi:@1->@2]
//SEG7 @2
//SEG8 [3] call main 
  jsr main
//SEG9 [4] phi from @2 to @end [phi:@2->@end]
//SEG10 @end
//SEG11 main
main: {
  //SEG12 [5] *((const void()**) KERNEL_IRQ#0) ← &interrupt(HARDWARE_CLOBBER)(void()) irq() -- _deref_pptc1=pprc2 
    lda #<irq
    sta KERNEL_IRQ
    lda #>irq
    sta KERNEL_IRQ+1
  //SEG13 main::@return
  //SEG14 [6] return 
    rts
}
//SEG15 irq
irq: {
  //SEG16 entry interrupt(HARDWARE_CLOBBER)
    sta rega+1
    stx regx+1
  //SEG17 [7] *((const byte*) BORDERCOL#0) ← (const byte) DARK_GREY#0 -- _deref_pbuc1=vbuc2 
    lda #DARK_GREY
    sta BORDERCOL
  //SEG18 [8] (byte) irq_raster_next#1 ← (byte) irq_raster_next#0 + (byte/signed byte/word/signed word/dword/signed dword) 21 -- vbuz1=vbuz1_plus_vbuc1 
    lda #$15
    clc
    adc irq_raster_next
    sta irq_raster_next
  //SEG19 [9] (byte) irq::raster_next#0 ← (byte) irq_raster_next#1 -- vbuxx=vbuz1 
    // Setup next interrupt
    tax
  //SEG20 [10] (byte~) irq::$0 ← (byte) irq::raster_next#0 & (byte/signed byte/word/signed word/dword/signed dword) 7 -- vbuaa=vbuxx_band_vbuc1 
    txa
    and #7
  //SEG21 [11] if((byte~) irq::$0!=(byte/signed byte/word/signed word/dword/signed dword) 0) goto irq::@1 -- vbuaa_neq_0_then_la1 
    cmp #0
    bne b1
  //SEG22 irq::@2
  //SEG23 [12] (byte) irq::raster_next#1 ← (byte) irq::raster_next#0 - (byte/signed byte/word/signed word/dword/signed dword) 1 -- vbuxx=vbuxx_minus_1 
    dex
  //SEG24 [13] phi from irq irq::@2 to irq::@1 [phi:irq/irq::@2->irq::@1]
  //SEG25 [13] phi (byte) irq::raster_next#2 = (byte) irq::raster_next#0 [phi:irq/irq::@2->irq::@1#0] -- register_copy 
  //SEG26 irq::@1
  b1:
  //SEG27 [14] *((const byte*) RASTER#0) ← (byte) irq::raster_next#2 -- _deref_pbuc1=vbuxx 
    stx RASTER
  //SEG28 [15] *((const byte*) BORDERCOL#0) ← (const byte) BLACK#0 -- _deref_pbuc1=vbuc2 
    lda #BLACK
    sta BORDERCOL
  //SEG29 irq::@return
  //SEG30 [16] return  - exit interrupt(HARDWARE_CLOBBER)
  rega:
    lda #00
  regx:
    ldx #00
    rti
}

