Resolved forward reference irq_play to interrupt(KERNEL_KEYBOARD)(void()) irq_play()
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

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@4
@4: scope:[]  from @begin
  kickasm() {{ .const music = LoadSid("toiletrensdyr.sid")
 }}
  kickasm(location (const byte*) MUSIC) {{ .fill music.size, music.getData(i)
 }}
  to:@6

(void()) main()
main: scope:[main]  from @6
  asm { sei jsrmusic.init  }
  *((const byte*) CIA1_INTERRUPT) ← (const byte) CIA_INTERRUPT_CLEAR
  *((const byte*) VIC_CONTROL) ← *((const byte*) VIC_CONTROL) & (number) $7f
  *((const byte*) RASTER) ← (number) $fd
  *((const byte*) IRQ_ENABLE) ← (const byte) IRQ_RASTER
  *((const void()**) KERNEL_IRQ) ← &interrupt(KERNEL_KEYBOARD)(void()) irq_play()
  asm { cli  }
  to:main::@return
main::@return: scope:[main]  from main
  return 
  to:@return

interrupt(KERNEL_KEYBOARD)(void()) irq_play()
irq_play: scope:[irq_play]  from
  *((const byte*) BORDERCOL) ← ++ *((const byte*) BORDERCOL)
  asm { jsrmusic.play  }
  *((const byte*) IRQ_STATUS) ← (const byte) IRQ_RASTER
  *((const byte*) BORDERCOL) ← -- *((const byte*) BORDERCOL)
  to:irq_play::@return
irq_play::@return: scope:[irq_play]  from irq_play
  return 
  to:@return
@6: scope:[]  from @4
  call main 
  to:@7
@7: scope:[]  from @6
  to:@end
@end: scope:[]  from @7

SYMBOL TABLE SSA
(label) @4
(label) @6
(label) @7
(label) @begin
(label) @end
(const byte*) BORDERCOL = (byte*)(number) $d020
(const byte*) CIA1_INTERRUPT = (byte*)(number) $dc0d
(const byte) CIA_INTERRUPT_CLEAR = (byte) $7f
(const byte*) IRQ_ENABLE = (byte*)(number) $d01a
(const byte) IRQ_RASTER = (byte) 1
(const byte*) IRQ_STATUS = (byte*)(number) $d019
(const void()**) KERNEL_IRQ = (void()**)(number) $314
(const byte*) MUSIC = (byte*)(number) $1000
(const byte*) RASTER = (byte*)(number) $d012
(const byte*) VIC_CONTROL = (byte*)(number) $d011
interrupt(KERNEL_KEYBOARD)(void()) irq_play()
(label) irq_play::@return
(void()) main()
(label) main::@return

Adding number conversion cast (unumber) $7f in *((const byte*) VIC_CONTROL) ← *((const byte*) VIC_CONTROL) & (number) $7f
Adding number conversion cast (unumber) $fd in *((const byte*) RASTER) ← (number) $fd
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast *((const byte*) RASTER) ← (unumber)(number) $fd
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 53266
Simplifying constant pointer cast (byte*) 53280
Simplifying constant pointer cast (byte*) 53265
Simplifying constant pointer cast (byte*) 53273
Simplifying constant pointer cast (byte*) 53274
Simplifying constant pointer cast (byte*) 56333
Simplifying constant pointer cast (void()**) 788
Simplifying constant pointer cast (byte*) 4096
Simplifying constant integer cast $7f
Simplifying constant integer cast $fd
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $7f
Finalized unsigned number type (byte) $fd
Successful SSA optimization PassNFinalizeNumberTypeConversions
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:4 

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block (label) @7
Renumbering block @4 to @1
Renumbering block @6 to @2
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
  kickasm() {{ .const music = LoadSid("toiletrensdyr.sid")
 }}
  kickasm(location (const byte*) MUSIC) {{ .fill music.size, music.getData(i)
 }}
  to:@2
@2: scope:[]  from @1
  [3] phi()
  [4] call main 
  to:@end
@end: scope:[]  from @2
  [5] phi()

(void()) main()
main: scope:[main]  from @2
  asm { sei jsrmusic.init  }
  [7] *((const byte*) CIA1_INTERRUPT) ← (const byte) CIA_INTERRUPT_CLEAR
  [8] *((const byte*) VIC_CONTROL) ← *((const byte*) VIC_CONTROL) & (byte) $7f
  [9] *((const byte*) RASTER) ← (byte) $fd
  [10] *((const byte*) IRQ_ENABLE) ← (const byte) IRQ_RASTER
  [11] *((const void()**) KERNEL_IRQ) ← &interrupt(KERNEL_KEYBOARD)(void()) irq_play()
  asm { cli  }
  to:main::@return
main::@return: scope:[main]  from main
  [13] return 
  to:@return

interrupt(KERNEL_KEYBOARD)(void()) irq_play()
irq_play: scope:[irq_play]  from
  [14] *((const byte*) BORDERCOL) ← ++ *((const byte*) BORDERCOL)
  asm { jsrmusic.play  }
  [16] *((const byte*) IRQ_STATUS) ← (const byte) IRQ_RASTER
  [17] *((const byte*) BORDERCOL) ← -- *((const byte*) BORDERCOL)
  to:irq_play::@return
irq_play::@return: scope:[irq_play]  from irq_play
  [18] return 
  to:@return


VARIABLE REGISTER WEIGHTS
interrupt(KERNEL_KEYBOARD)(void()) irq_play()
(void()) main()

Initial phi equivalence classes
Complete equivalence classes

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// A simple SID music player using RASTER IRQ
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label RASTER = $d012
  .label BORDERCOL = $d020
  .label VIC_CONTROL = $d011
  // 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
  .label MUSIC = $1000
  // @begin
__bbegin:
  jmp __b1
  // @1
__b1:
  // kickasm() {{ .const music = LoadSid("toiletrensdyr.sid")  }}
  // Load the SID
  .const music = LoadSid("toiletrensdyr.sid")

  // kickasm(location (const byte*) MUSIC) {{ .fill music.size, music.getData(i)  }}
// Place the SID into memory
  // [3] phi from @1 to @2 [phi:@1->@2]
__b2_from___b1:
  jmp __b2
  // @2
__b2:
  // [4] call main 
  jsr main
  // [5] phi from @2 to @end [phi:@2->@end]
__bend_from___b2:
  jmp __bend
  // @end
__bend:
  // main
// Setup Raster IRQ and initialize SID player
main: {
    // asm { sei jsrmusic.init  }
    sei
    jsr music.init
    // [7] *((const byte*) CIA1_INTERRUPT) ← (const byte) CIA_INTERRUPT_CLEAR -- _deref_pbuc1=vbuc2 
    // Disable CIA 1 Timer IRQ
    lda #CIA_INTERRUPT_CLEAR
    sta CIA1_INTERRUPT
    // [8] *((const byte*) VIC_CONTROL) ← *((const byte*) VIC_CONTROL) & (byte) $7f -- _deref_pbuc1=_deref_pbuc1_band_vbuc2 
    // Set raster line to $fd
    lda #$7f
    and VIC_CONTROL
    sta VIC_CONTROL
    // [9] *((const byte*) RASTER) ← (byte) $fd -- _deref_pbuc1=vbuc2 
    lda #$fd
    sta RASTER
    // [10] *((const byte*) IRQ_ENABLE) ← (const byte) IRQ_RASTER -- _deref_pbuc1=vbuc2 
    // Enable Raster Interrupt
    lda #IRQ_RASTER
    sta IRQ_ENABLE
    // [11] *((const void()**) KERNEL_IRQ) ← &interrupt(KERNEL_KEYBOARD)(void()) irq_play() -- _deref_pptc1=pprc2 
    // Set the IRQ routine
    lda #<irq_play
    sta KERNEL_IRQ
    lda #>irq_play
    sta KERNEL_IRQ+1
    // asm { cli  }
    cli
    jmp __breturn
    // main::@return
  __breturn:
    // [13] return 
    rts
}
  // irq_play
// Raster IRQ Routine playing music
irq_play: {
    // entry interrupt(KERNEL_KEYBOARD)
    // [14] *((const byte*) BORDERCOL) ← ++ *((const byte*) BORDERCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    // asm { jsrmusic.play  }
    // Play SID
    jsr music.play
    // [16] *((const byte*) IRQ_STATUS) ← (const byte) IRQ_RASTER -- _deref_pbuc1=vbuc2 
    // Acknowledge the IRQ
    lda #IRQ_RASTER
    sta IRQ_STATUS
    // [17] *((const byte*) BORDERCOL) ← -- *((const byte*) BORDERCOL) -- _deref_pbuc1=_dec__deref_pbuc1 
    dec BORDERCOL
    jmp __breturn
    // irq_play::@return
  __breturn:
    // [18] return  - exit interrupt(KERNEL_KEYBOARD)
    jmp $ea31
}
  // File Data
.pc = MUSIC "MUSIC"
  .fill music.size, music.getData(i)


REGISTER UPLIFT POTENTIAL REGISTERS
Statement asm { sei jsrmusic.init  } always clobbers reg byte a reg byte x reg byte y 
Statement [7] *((const byte*) CIA1_INTERRUPT) ← (const byte) CIA_INTERRUPT_CLEAR [ ] ( main:4 [ ] ) always clobbers reg byte a 
Statement [8] *((const byte*) VIC_CONTROL) ← *((const byte*) VIC_CONTROL) & (byte) $7f [ ] ( main:4 [ ] ) always clobbers reg byte a 
Statement [9] *((const byte*) RASTER) ← (byte) $fd [ ] ( main:4 [ ] ) always clobbers reg byte a 
Statement [10] *((const byte*) IRQ_ENABLE) ← (const byte) IRQ_RASTER [ ] ( main:4 [ ] ) always clobbers reg byte a 
Statement [11] *((const void()**) KERNEL_IRQ) ← &interrupt(KERNEL_KEYBOARD)(void()) irq_play() [ ] ( main:4 [ ] ) always clobbers reg byte a 
Statement asm { jsrmusic.play  } always clobbers reg byte a reg byte x reg byte y 
Statement [16] *((const byte*) IRQ_STATUS) ← (const byte) IRQ_RASTER [ ] (  [ ] ) always clobbers reg byte a 

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

Uplifting [main] best 2947 combination 
Uplifting [irq_play] best 2947 combination 
Uplifting [] best 2947 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// A simple SID music player using RASTER IRQ
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label RASTER = $d012
  .label BORDERCOL = $d020
  .label VIC_CONTROL = $d011
  // 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
  .label MUSIC = $1000
  // @begin
__bbegin:
  jmp __b1
  // @1
__b1:
  // kickasm() {{ .const music = LoadSid("toiletrensdyr.sid")  }}
  // Load the SID
  .const music = LoadSid("toiletrensdyr.sid")

  // kickasm(location (const byte*) MUSIC) {{ .fill music.size, music.getData(i)  }}
// Place the SID into memory
  // [3] phi from @1 to @2 [phi:@1->@2]
__b2_from___b1:
  jmp __b2
  // @2
__b2:
  // [4] call main 
  jsr main
  // [5] phi from @2 to @end [phi:@2->@end]
__bend_from___b2:
  jmp __bend
  // @end
__bend:
  // main
// Setup Raster IRQ and initialize SID player
main: {
    // asm { sei jsrmusic.init  }
    sei
    jsr music.init
    // [7] *((const byte*) CIA1_INTERRUPT) ← (const byte) CIA_INTERRUPT_CLEAR -- _deref_pbuc1=vbuc2 
    // Disable CIA 1 Timer IRQ
    lda #CIA_INTERRUPT_CLEAR
    sta CIA1_INTERRUPT
    // [8] *((const byte*) VIC_CONTROL) ← *((const byte*) VIC_CONTROL) & (byte) $7f -- _deref_pbuc1=_deref_pbuc1_band_vbuc2 
    // Set raster line to $fd
    lda #$7f
    and VIC_CONTROL
    sta VIC_CONTROL
    // [9] *((const byte*) RASTER) ← (byte) $fd -- _deref_pbuc1=vbuc2 
    lda #$fd
    sta RASTER
    // [10] *((const byte*) IRQ_ENABLE) ← (const byte) IRQ_RASTER -- _deref_pbuc1=vbuc2 
    // Enable Raster Interrupt
    lda #IRQ_RASTER
    sta IRQ_ENABLE
    // [11] *((const void()**) KERNEL_IRQ) ← &interrupt(KERNEL_KEYBOARD)(void()) irq_play() -- _deref_pptc1=pprc2 
    // Set the IRQ routine
    lda #<irq_play
    sta KERNEL_IRQ
    lda #>irq_play
    sta KERNEL_IRQ+1
    // asm { cli  }
    cli
    jmp __breturn
    // main::@return
  __breturn:
    // [13] return 
    rts
}
  // irq_play
// Raster IRQ Routine playing music
irq_play: {
    // entry interrupt(KERNEL_KEYBOARD)
    // [14] *((const byte*) BORDERCOL) ← ++ *((const byte*) BORDERCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    // asm { jsrmusic.play  }
    // Play SID
    jsr music.play
    // [16] *((const byte*) IRQ_STATUS) ← (const byte) IRQ_RASTER -- _deref_pbuc1=vbuc2 
    // Acknowledge the IRQ
    lda #IRQ_RASTER
    sta IRQ_STATUS
    // [17] *((const byte*) BORDERCOL) ← -- *((const byte*) BORDERCOL) -- _deref_pbuc1=_dec__deref_pbuc1 
    dec BORDERCOL
    jmp __breturn
    // irq_play::@return
  __breturn:
    // [18] return  - exit interrupt(KERNEL_KEYBOARD)
    jmp $ea31
}
  // File Data
.pc = MUSIC "MUSIC"
  .fill music.size, music.getData(i)


ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __bend
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __bbegin with __b1
Removing instruction __bbegin:
Removing instruction __b2_from___b1:
Removing instruction __bend_from___b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b2:
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 __b1:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @2
(label) @begin
(label) @end
(const byte*) BORDERCOL = (byte*) 53280
(const byte*) CIA1_INTERRUPT = (byte*) 56333
(const byte) CIA_INTERRUPT_CLEAR = (byte) $7f
(const byte*) IRQ_ENABLE = (byte*) 53274
(const byte) IRQ_RASTER = (byte) 1
(const byte*) IRQ_STATUS = (byte*) 53273
(const void()**) KERNEL_IRQ = (void()**) 788
(const byte*) MUSIC = (byte*) 4096
(const byte*) RASTER = (byte*) 53266
(const byte*) VIC_CONTROL = (byte*) 53265
interrupt(KERNEL_KEYBOARD)(void()) irq_play()
(label) irq_play::@return
(void()) main()
(label) main::@return



FINAL ASSEMBLER
Score: 2899

  // File Comments
// A simple SID music player using RASTER IRQ
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .label RASTER = $d012
  .label BORDERCOL = $d020
  .label VIC_CONTROL = $d011
  // 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
  .label MUSIC = $1000
  // @begin
  // @1
  // kickasm
  // kickasm() {{ .const music = LoadSid("toiletrensdyr.sid")  }}
  // Load the SID
  .const music = LoadSid("toiletrensdyr.sid")

  // kickasm(location (const byte*) MUSIC) {{ .fill music.size, music.getData(i)  }}
// Place the SID into memory
  // [3] phi from @1 to @2 [phi:@1->@2]
  // @2
  // [4] call main 
  // [5] phi from @2 to @end [phi:@2->@end]
  // @end
  // main
// Setup Raster IRQ and initialize SID player
main: {
    // asm
    // asm { sei jsrmusic.init  }
    sei
    jsr music.init
    // *CIA1_INTERRUPT = CIA_INTERRUPT_CLEAR
    // [7] *((const byte*) CIA1_INTERRUPT) ← (const byte) CIA_INTERRUPT_CLEAR -- _deref_pbuc1=vbuc2 
    // Disable CIA 1 Timer IRQ
    lda #CIA_INTERRUPT_CLEAR
    sta CIA1_INTERRUPT
    // *VIC_CONTROL &=$7f
    // [8] *((const byte*) VIC_CONTROL) ← *((const byte*) VIC_CONTROL) & (byte) $7f -- _deref_pbuc1=_deref_pbuc1_band_vbuc2 
    // Set raster line to $fd
    lda #$7f
    and VIC_CONTROL
    sta VIC_CONTROL
    // *RASTER = $fd
    // [9] *((const byte*) RASTER) ← (byte) $fd -- _deref_pbuc1=vbuc2 
    lda #$fd
    sta RASTER
    // *IRQ_ENABLE = IRQ_RASTER
    // [10] *((const byte*) IRQ_ENABLE) ← (const byte) IRQ_RASTER -- _deref_pbuc1=vbuc2 
    // Enable Raster Interrupt
    lda #IRQ_RASTER
    sta IRQ_ENABLE
    // *KERNEL_IRQ = &irq_play
    // [11] *((const void()**) KERNEL_IRQ) ← &interrupt(KERNEL_KEYBOARD)(void()) irq_play() -- _deref_pptc1=pprc2 
    // Set the IRQ routine
    lda #<irq_play
    sta KERNEL_IRQ
    lda #>irq_play
    sta KERNEL_IRQ+1
    // asm
    // asm { cli  }
    cli
    // main::@return
    // }
    // [13] return 
    rts
}
  // irq_play
// Raster IRQ Routine playing music
irq_play: {
    // entry interrupt(KERNEL_KEYBOARD)
    // (*BORDERCOL)++;
    // [14] *((const byte*) BORDERCOL) ← ++ *((const byte*) BORDERCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    // asm
    // asm { jsrmusic.play  }
    // Play SID
    jsr music.play
    // *IRQ_STATUS = IRQ_RASTER
    // [16] *((const byte*) IRQ_STATUS) ← (const byte) IRQ_RASTER -- _deref_pbuc1=vbuc2 
    // Acknowledge the IRQ
    lda #IRQ_RASTER
    sta IRQ_STATUS
    // (*BORDERCOL)--;
    // [17] *((const byte*) BORDERCOL) ← -- *((const byte*) BORDERCOL) -- _deref_pbuc1=_dec__deref_pbuc1 
    dec BORDERCOL
    // irq_play::@return
    // }
    // [18] return  - exit interrupt(KERNEL_KEYBOARD)
    jmp $ea31
}
  // File Data
.pc = MUSIC "MUSIC"
  .fill music.size, music.getData(i)


