Resolved forward reference irq to interrupt(KERNEL_MIN)(void()) irq()
Culled Empty Block (label) @1

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (void()**) KERNEL_IRQ#0 ← ((void()**)) (number) $314
  (byte*) SCREEN#0 ← ((byte*)) (number) $400
  (byte) col1#0 ← (number) 0
  (byte) col2#0 ← (number) 8
  to:@2
main: scope:[main]  from @2
  (void()*~) main::$0 ← & interrupt(KERNEL_MIN)(void()) irq()
  *((void()**) KERNEL_IRQ#0) ← (void()*~) main::$0
  to:main::@return
main::@return: scope:[main]  from main
  return 
  to:@return
irq: scope:[irq]  from
  (byte) col2#3 ← phi( @2/(byte) col2#5 )
  (byte) col1#3 ← phi( @2/(byte) col1#5 )
  *((byte*) SCREEN#0 + (number) $28) ← (byte) col1#3
  (byte) col1#1 ← ++ (byte) col1#3
  *((byte*) SCREEN#0 + (number) $29) ← (byte) col2#3
  (byte) col2#1 ← ++ (byte) col2#3
  to:irq::@return
irq::@return: scope:[irq]  from irq
  (byte) col2#4 ← phi( irq/(byte) col2#1 )
  (byte) col1#4 ← phi( irq/(byte) col1#1 )
  (byte) col1#2 ← (byte) col1#4
  (byte) col2#2 ← (byte) col2#4
  return 
  to:@return
@2: scope:[]  from @begin
  (byte) col2#5 ← phi( @begin/(byte) col2#0 )
  (byte) col1#5 ← phi( @begin/(byte) col1#0 )
  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
(void()**) KERNEL_IRQ
(void()**) KERNEL_IRQ#0
(byte*) SCREEN
(byte*) SCREEN#0
(byte) col1
(byte) col1#0
(byte) col1#1
(byte) col1#2
(byte) col1#3
(byte) col1#4
(byte) col1#5
(byte) col2
(byte) col2#0
(byte) col2#1
(byte) col2#2
(byte) col2#3
(byte) col2#4
(byte) col2#5
interrupt(KERNEL_MIN)(void()) irq()
(label) irq::@return
(void()) main()
(void()*~) main::$0
(label) main::@return

Adding number conversion cast (unumber) 0 in (byte) col1#0 ← (number) 0
Adding number conversion cast (unumber) 8 in (byte) col2#0 ← (number) 8
Adding number conversion cast (unumber) $28 in *((byte*) SCREEN#0 + (number) $28) ← (byte) col1#3
Adding number conversion cast (unumber) $29 in *((byte*) SCREEN#0 + (number) $29) ← (byte) col2#3
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (void()**) KERNEL_IRQ#0 ← (void()**)(number) $314
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
Inlining cast (byte) col1#0 ← (unumber)(number) 0
Inlining cast (byte) col2#0 ← (unumber)(number) 8
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (void()**) 788
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 8
Simplifying constant integer cast $28
Simplifying constant integer cast $29
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 8
Finalized unsigned number type (byte) $28
Finalized unsigned number type (byte) $29
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte) col1#1 = (byte) col1#4 (byte) col1#2 
Alias (byte) col2#1 = (byte) col2#4 (byte) col2#2 
Alias (byte) col1#0 = (byte) col1#5 
Alias (byte) col2#0 = (byte) col2#5 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) col1#3 (byte) col1#0
Identical Phi Values (byte) col2#3 (byte) col2#0
Successful SSA optimization Pass2IdenticalPhiElimination
Constant right-side identified [4] (void()*~) main::$0 ← & interrupt(KERNEL_MIN)(void()) irq()
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const void()**) KERNEL_IRQ#0 = (void()**) 788
Constant (const byte*) SCREEN#0 = (byte*) 1024
Constant (const void()*) main::$0 = &irq
Successful SSA optimization Pass2ConstantIdentification
Constant inlined main::$0 = &interrupt(KERNEL_MIN)(void()) irq()
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(SCREEN#0+$28)
Consolidated array index constant in *(SCREEN#0+$29)
Successful SSA optimization Pass2ConstantAdditionElimination
Adding NOP phi() at start of @2
Adding NOP phi() at start of @3
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) @3
Renumbering block @2 to @1
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] (byte) col1#0 ← (byte) 0
  [1] (byte) col2#0 ← (byte) 8
  to:@1
@1: scope:[]  from @begin
  [2] phi()
  [3] call main 
  to:@end
@end: scope:[]  from @1
  [4] phi()
main: scope:[main]  from @1
  [5] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq()
  to:main::@return
main::@return: scope:[main]  from main
  [6] return 
  to:@return
irq: scope:[irq]  from
  [7] *((const byte*) SCREEN#0+(byte) $28) ← (byte) col1#0
  [8] (byte) col1#1 ← ++ (byte) col1#0
  [9] *((const byte*) SCREEN#0+(byte) $29) ← (byte) col2#0
  [10] (byte) col2#1 ← ++ (byte) col2#0
  to:irq::@return
irq::@return: scope:[irq]  from irq
  [11] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()**) KERNEL_IRQ
(byte*) SCREEN
(byte) col1
(byte) col1#0 6.0
(byte) col1#1 20.0
(byte) col2
(byte) col2#0 2.0
(byte) col2#1 20.0
interrupt(KERNEL_MIN)(void()) irq()
(void()) main()

Initial phi equivalence classes
Coalescing volatile variable equivalence classes [ col1#0 ] and [ col1#1 ]
Coalescing volatile variable equivalence classes [ col2#0 ] and [ col2#1 ]
Complete equivalence classes
[ col1#0 col1#1 ]
[ col2#0 col2#1 ]
Allocated zp ZP_BYTE:2 [ col1#0 col1#1 ]
Allocated zp ZP_BYTE:3 [ col2#0 col2#1 ]

INITIAL ASM
Target platform is c64basic
  // File Comments
// Illustrates problem where volatiles reuse the same ZP addresses for multiple overlapping volatiles
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label KERNEL_IRQ = $314
  .label SCREEN = $400
  .label col1 = 2
  .label col2 = 3
  // @begin
bbegin:
  // [0] (byte) col1#0 ← (byte) 0 -- vbuz1=vbuc1 
  lda #0
  sta.z col1
  // [1] (byte) col2#0 ← (byte) 8 -- vbuz1=vbuc1 
  lda #8
  sta.z col2
  // [2] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
  // @1
b1:
  // [3] call main 
  jsr main
  // [4] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
main: {
    // [5] *((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 breturn
    // main::@return
  breturn:
    // [6] return 
    rts
}
  // irq
irq: {
    // entry interrupt(KERNEL_MIN)
    // [7] *((const byte*) SCREEN#0+(byte) $28) ← (byte) col1#0 -- _deref_pbuc1=vbuz1 
    lda.z col1
    sta SCREEN+$28
    // [8] (byte) col1#1 ← ++ (byte) col1#0 -- vbuz1=_inc_vbuz1 
    inc.z col1
    // [9] *((const byte*) SCREEN#0+(byte) $29) ← (byte) col2#0 -- _deref_pbuc1=vbuz1 
    lda.z col2
    sta SCREEN+$29
    // [10] (byte) col2#1 ← ++ (byte) col2#0 -- vbuz1=_inc_vbuz1 
    inc.z col2
    jmp breturn
    // irq::@return
  breturn:
    // [11] return  - exit interrupt(KERNEL_MIN)
    jmp $ea81
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] (byte) col1#0 ← (byte) 0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [1] (byte) col2#0 ← (byte) 8 [ ] (  [ ] ) always clobbers reg byte a 
Statement [5] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq() [ ] ( main:3 [ ] ) always clobbers reg byte a 
Statement [7] *((const byte*) SCREEN#0+(byte) $28) ← (byte) col1#0 [ col1#0 col2#0 ] (  [ col1#0 col2#0 ] ) always clobbers reg byte a 
Statement [9] *((const byte*) SCREEN#0+(byte) $29) ← (byte) col2#0 [ col2#0 ] (  [ col2#0 ] ) always clobbers reg byte a 
Potential registers zp ZP_BYTE:2 [ col1#0 col1#1 ] : zp ZP_BYTE:2 , 
Potential registers zp ZP_BYTE:3 [ col2#0 col2#1 ] : zp ZP_BYTE:3 , 

REGISTER UPLIFT SCOPES
Uplift Scope [] 26: zp ZP_BYTE:2 [ col1#0 col1#1 ] 22: zp ZP_BYTE:3 [ col2#0 col2#1 ] 
Uplift Scope [main] 
Uplift Scope [irq] 

Uplifting [] best 73 combination zp ZP_BYTE:2 [ col1#0 col1#1 ] zp ZP_BYTE:3 [ col2#0 col2#1 ] 
Uplifting [main] best 73 combination 
Uplifting [irq] best 73 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:2 [ col1#0 col1#1 ]
Uplifting [] best 73 combination zp ZP_BYTE:2 [ col1#0 col1#1 ] 
Attempting to uplift remaining variables inzp ZP_BYTE:3 [ col2#0 col2#1 ]
Uplifting [] best 73 combination zp ZP_BYTE:3 [ col2#0 col2#1 ] 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Illustrates problem where volatiles reuse the same ZP addresses for multiple overlapping volatiles
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label KERNEL_IRQ = $314
  .label SCREEN = $400
  .label col1 = 2
  .label col2 = 3
  // @begin
bbegin:
  // [0] (byte) col1#0 ← (byte) 0 -- vbuz1=vbuc1 
  lda #0
  sta.z col1
  // [1] (byte) col2#0 ← (byte) 8 -- vbuz1=vbuc1 
  lda #8
  sta.z col2
  // [2] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
  // @1
b1:
  // [3] call main 
  jsr main
  // [4] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
main: {
    // [5] *((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 breturn
    // main::@return
  breturn:
    // [6] return 
    rts
}
  // irq
irq: {
    // entry interrupt(KERNEL_MIN)
    // [7] *((const byte*) SCREEN#0+(byte) $28) ← (byte) col1#0 -- _deref_pbuc1=vbuz1 
    lda.z col1
    sta SCREEN+$28
    // [8] (byte) col1#1 ← ++ (byte) col1#0 -- vbuz1=_inc_vbuz1 
    inc.z col1
    // [9] *((const byte*) SCREEN#0+(byte) $29) ← (byte) col2#0 -- _deref_pbuc1=vbuz1 
    lda.z col2
    sta SCREEN+$29
    // [10] (byte) col2#1 ← ++ (byte) col2#0 -- vbuz1=_inc_vbuz1 
    inc.z col2
    jmp breturn
    // irq::@return
  breturn:
    // [11] 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
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction b1_from_bbegin:
Removing instruction bend_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction b1:
Removing instruction bend:
Removing instruction breturn:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Adding RTS to root block 
Succesful ASM optimization Pass5AddMainRts

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()**) KERNEL_IRQ
(const void()**) KERNEL_IRQ#0 KERNEL_IRQ = (void()**) 788
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
(byte) col1
(byte) col1#0 col1 zp ZP_BYTE:2 6.0
(byte) col1#1 col1 zp ZP_BYTE:2 20.0
(byte) col2
(byte) col2#0 col2 zp ZP_BYTE:3 2.0
(byte) col2#1 col2 zp ZP_BYTE:3 20.0
interrupt(KERNEL_MIN)(void()) irq()
(label) irq::@return
(void()) main()
(label) main::@return

zp ZP_BYTE:2 [ col1#0 col1#1 ]
zp ZP_BYTE:3 [ col2#0 col2#1 ]


FINAL ASSEMBLER
Score: 67

  // File Comments
// Illustrates problem where volatiles reuse the same ZP addresses for multiple overlapping volatiles
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label KERNEL_IRQ = $314
  .label SCREEN = $400
  .label col1 = 2
  .label col2 = 3
  // @begin
bbegin:
  // col1 = 0
  // [0] (byte) col1#0 ← (byte) 0 -- vbuz1=vbuc1 
  lda #0
  sta.z col1
  // col2 = 8
  // [1] (byte) col2#0 ← (byte) 8 -- vbuz1=vbuc1 
  lda #8
  sta.z col2
  // [2] phi from @begin to @1 [phi:@begin->@1]
  // @1
  // [3] call main 
  jsr main
  rts
  // [4] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    // *KERNEL_IRQ = &irq
    // [5] *((const void()**) KERNEL_IRQ#0) ← &interrupt(KERNEL_MIN)(void()) irq() -- _deref_pptc1=pprc2 
    lda #<irq
    sta KERNEL_IRQ
    lda #>irq
    sta KERNEL_IRQ+1
    // main::@return
    // }
    // [6] return 
    rts
}
  // irq
irq: {
    // entry interrupt(KERNEL_MIN)
    // SCREEN[40] = col1++
    // [7] *((const byte*) SCREEN#0+(byte) $28) ← (byte) col1#0 -- _deref_pbuc1=vbuz1 
    lda.z col1
    sta SCREEN+$28
    // SCREEN[40] = col1++;
    // [8] (byte) col1#1 ← ++ (byte) col1#0 -- vbuz1=_inc_vbuz1 
    inc.z col1
    // SCREEN[41] = col2++
    // [9] *((const byte*) SCREEN#0+(byte) $29) ← (byte) col2#0 -- _deref_pbuc1=vbuz1 
    lda.z col2
    sta SCREEN+$29
    // SCREEN[41] = col2++;
    // [10] (byte) col2#1 ← ++ (byte) col2#0 -- vbuz1=_inc_vbuz1 
    inc.z col2
    // irq::@return
    // }
    // [11] return  - exit interrupt(KERNEL_MIN)
    jmp $ea81
}
  // File Data

