Resolved forward reference irq_play to __interrupt(rom_sys_c64) void irq_play()
Inlined call vicSelectGfxBank::$0 = call toDd00(vicSelectGfxBank::gfx)
Inlined call call __init
Calling convention STACK_CALL adding prepare/execute/finalize for call *musicInit 
Calling convention STACK_CALL adding prepare/execute/finalize for call *musicPlay 

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start::@1
  asm { sei  }
  callexecute *musicInit 
  to:main::@1
main::@1: scope:[main]  from main
  *((char *)CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT) = CIA_INTERRUPT_CLEAR
  *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) = *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) & $7f
  *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER) = $fd
  *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE) = IRQ_RASTER
  *KERNEL_IRQ = &irq_play
  asm { cli  }
  to:main::@return
main::@return: scope:[main]  from main::@1
  return 
  to:@return

__interrupt(rom_sys_c64) void irq_play()
irq_play: scope:[irq_play]  from
  *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = ++ *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR)
  callexecute *musicPlay 
  to:irq_play::@1
irq_play::@1: scope:[irq_play]  from irq_play
  *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS) = IRQ_RASTER
  *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = -- *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR)
  to:irq_play::@return
irq_play::@return: scope:[irq_play]  from irq_play::@1
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  to:__start::__init1
__start::__init1: scope:[__start]  from __start
  to:__start::@1
__start::@1: scope:[__start]  from __start::__init1
  call main
  to:__start::@2
__start::@2: scope:[__start]  from __start::@1
  to:__start::@return
__start::@return: scope:[__start]  from __start::@2
  return 
  to:@return

SYMBOL TABLE SSA
__constant struct MOS6526_CIA * const CIA1 = (struct MOS6526_CIA *)$dc00
__constant const char CIA_INTERRUPT_CLEAR = $7f
__constant const char IRQ_RASTER = 1
__constant void (** const KERNEL_IRQ)() = (void (**)())$314
__constant char MUSIC[] = kickasm {{ .const music = LoadSid("toiletrensdyr.sid")
    .fill music.size, music.getData(i)
 }}
__constant char OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
__constant char OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
__constant char OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
__constant char OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a
__constant char OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19
__constant char OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
__constant struct MOS6569_VICII * const VICII = (struct MOS6569_VICII *)$d000
void __start()
__interrupt(rom_sys_c64) void irq_play()
void main()
__constant void (*musicInit)() = (void (*)())MUSIC
__constant void (*musicPlay)() = (void (*)())MUSIC+3

Adding number conversion cast (unumber) 3 in 
Adding number conversion cast (unumber) $7f in *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) = *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) & $7f
Adding number conversion cast (unumber) $fd in *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER) = $fd
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER) = (unumber)$fd
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (struct MOS6569_VICII *) 53248
Simplifying constant pointer cast (struct MOS6526_CIA *) 56320
Simplifying constant pointer cast (void (**)()) 788
Simplifying constant integer cast 3
Simplifying constant integer cast $7f
Simplifying constant integer cast $fd
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 3
Finalized unsigned number type (char) $7f
Finalized unsigned number type (char) $fd
Successful SSA optimization PassNFinalizeNumberTypeConversions
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::__init1
Removing unused procedure block __start::@1
Removing unused procedure block __start::@2
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Finalized unsigned number type (unsigned int) $1000
Successful SSA optimization PassNFinalizeNumberTypeConversions
CALL GRAPH
Calls in [irq_play] to null:1 
Calls in [main] to null:6 

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes

FINAL CONTROL FLOW GRAPH

__interrupt(rom_sys_c64) void irq_play()
irq_play: scope:[irq_play]  from
  [0] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = ++ *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR)
  [1] callexecute *musicPlay 
  to:irq_play::@1
irq_play::@1: scope:[irq_play]  from irq_play
  [2] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS) = IRQ_RASTER
  [3] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = -- *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR)
  to:irq_play::@return
irq_play::@return: scope:[irq_play]  from irq_play::@1
  [4] return 
  to:@return

void main()
main: scope:[main]  from
  asm { sei  }
  [6] callexecute *musicInit 
  to:main::@1
main::@1: scope:[main]  from main
  [7] *((char *)CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT) = CIA_INTERRUPT_CLEAR
  [8] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) = *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) & $7f
  [9] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER) = $fd
  [10] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE) = IRQ_RASTER
  [11] *KERNEL_IRQ = &irq_play
  asm { cli  }
  to:main::@return
main::@return: scope:[main]  from main::@1
  [13] return 
  to:@return


VARIABLE REGISTER WEIGHTS
__interrupt(rom_sys_c64) void irq_play()
void main()

Initial phi equivalence classes
Complete equivalence classes
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [1] callexecute *musicPlay  [ ] (  [ ] { }  ) always clobbers reg byte a reg byte x reg byte y 
Statement [2] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS) = IRQ_RASTER [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [6] callexecute *musicInit  [ ] (  [ ] { }  ) always clobbers reg byte a reg byte x reg byte y 
Statement [7] *((char *)CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT) = CIA_INTERRUPT_CLEAR [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [8] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) = *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) & $7f [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [9] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER) = $fd [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [10] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE) = IRQ_RASTER [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [11] *KERNEL_IRQ = &irq_play [ ] (  [ ] { }  ) always clobbers reg byte a 

REGISTER UPLIFT SCOPES
Uplift Scope [MOS6526_CIA] 
Uplift Scope [MOS6569_VICII] 
Uplift Scope [MOS6581_SID] 
Uplift Scope [main] 
Uplift Scope [irq_play] 
Uplift Scope [] 

Uplifting [MOS6526_CIA] best 122 combination 
Uplifting [MOS6569_VICII] best 122 combination 
Uplifting [MOS6581_SID] best 122 combination 
Uplifting [main] best 122 combination 
Uplifting [irq_play] best 122 combination 
Uplifting [] best 122 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// A simple SID music player using RASTER IRQ
/// @file
/// Commodore 64 Registers and Constants
/// @file
/// The MOS 6526 Complex Interface Adapter (CIA)
///
/// http://archive.6502.org/datasheets/mos_6526_cia_recreated.pdf
  // Upstart
  // Commodore 64 PRG executable file
.file [name="music_irq.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
  // Global Constants & labels
  /// Value that disables all CIA interrupts when stored to the CIA Interrupt registers
  .const CIA_INTERRUPT_CLEAR = $7f
  /// VICII IRQ Status/Enable Raster
  // @see #IRQ_ENABLE #IRQ_STATUS
  ///  0 | RST| Reaching a certain raster line. The line is specified by writing
  ///    |    | to register 0xd012 and bit 7 of $d011 and internally stored by
  ///    |    | the VIC for the raster compare. The test for reaching the
  ///    |    | interrupt raster line is done in cycle 0 of every line (for line
  ///    |    | 0, in cycle 1).
  .const IRQ_RASTER = 1
  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
  .const OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a
  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
  .const OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19
  /// The VIC-II MOS 6567/6569
  .label VICII = $d000
  /// The CIA#1: keyboard matrix, joystick #1/#2
  .label CIA1 = $dc00
  /// The vector used when the KERNAL serves IRQ interrupts
  .label KERNEL_IRQ = $314
  // Pointer to the music init routine
  .label musicInit = MUSIC
  // Pointer to the music play routine
  .label musicPlay = MUSIC+3
.segment Code
  // irq_play
// Raster IRQ Routine playing music
irq_play: {
    // interrupt(isr_rom_sys_c64_entry) -- isr_rom_sys_c64_entry 
    // [0] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = ++ *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR
    // [1] callexecute *musicPlay  -- call__deref_pprc1 
    // Play SID
    jsr musicPlay
    jmp __b1
    // irq_play::@1
  __b1:
    // [2] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS) = IRQ_RASTER -- _deref_pbuc1=vbuc2 
    // Acknowledge the IRQ
    lda #IRQ_RASTER
    sta VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS
    // [3] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = -- *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) -- _deref_pbuc1=_dec__deref_pbuc1 
    dec VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR
    jmp __breturn
    // irq_play::@return
  __breturn:
    // [4] return 
    // interrupt(isr_rom_sys_c64_exit) -- isr_rom_sys_c64_exit 
    jmp $ea31
}
  // main
// Setup Raster IRQ and initialize SID player
main: {
    // asm { sei  }
    sei
    // [6] callexecute *musicInit  -- call__deref_pprc1 
    jsr musicInit
    jmp __b1
    // main::@1
  __b1:
    // [7] *((char *)CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT) = CIA_INTERRUPT_CLEAR -- _deref_pbuc1=vbuc2 
    // Disable CIA 1 Timer IRQ
    lda #CIA_INTERRUPT_CLEAR
    sta CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT
    // [8] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) = *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) & $7f -- _deref_pbuc1=_deref_pbuc1_band_vbuc2 
    // Set raster line to $fd
    lda #$7f
    and VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1
    sta VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1
    // [9] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER) = $fd -- _deref_pbuc1=vbuc2 
    lda #$fd
    sta VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER
    // [10] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE) = IRQ_RASTER -- _deref_pbuc1=vbuc2 
    // Enable Raster Interrupt
    lda #IRQ_RASTER
    sta VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE
    // [11] *KERNEL_IRQ = &irq_play -- _deref_qprc1=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
}
  // File Data
.segment Data
.pc = $1000 "MUSIC"
// SID tune at an absolute address
MUSIC:
.const music = LoadSid("toiletrensdyr.sid")
    .fill music.size, music.getData(i)


ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1:
Removing instruction __breturn:
Removing instruction __b1:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
__constant struct MOS6526_CIA * const CIA1 = (struct MOS6526_CIA *) 56320
__constant const char CIA_INTERRUPT_CLEAR = $7f
__constant const char IRQ_RASTER = 1
__constant void (** const KERNEL_IRQ)() = (void (**)()) 788
__constant char MUSIC[] = kickasm {{ .const music = LoadSid("toiletrensdyr.sid")
    .fill music.size, music.getData(i)
 }}
__constant char OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
__constant char OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
__constant char OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
__constant char OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a
__constant char OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19
__constant char OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
__constant struct MOS6569_VICII * const VICII = (struct MOS6569_VICII *) 53248
__interrupt(rom_sys_c64) void irq_play()
void main()
__constant void (*musicInit)() = (void (*)())MUSIC
__constant void (*musicPlay)() = (void (*)())MUSIC+3



FINAL ASSEMBLER
Score: 110

  // File Comments
// A simple SID music player using RASTER IRQ
/// @file
/// Commodore 64 Registers and Constants
/// @file
/// The MOS 6526 Complex Interface Adapter (CIA)
///
/// http://archive.6502.org/datasheets/mos_6526_cia_recreated.pdf
  // Upstart
  // Commodore 64 PRG executable file
.file [name="music_irq.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
  // Global Constants & labels
  /// Value that disables all CIA interrupts when stored to the CIA Interrupt registers
  .const CIA_INTERRUPT_CLEAR = $7f
  /// VICII IRQ Status/Enable Raster
  // @see #IRQ_ENABLE #IRQ_STATUS
  ///  0 | RST| Reaching a certain raster line. The line is specified by writing
  ///    |    | to register 0xd012 and bit 7 of $d011 and internally stored by
  ///    |    | the VIC for the raster compare. The test for reaching the
  ///    |    | interrupt raster line is done in cycle 0 of every line (for line
  ///    |    | 0, in cycle 1).
  .const IRQ_RASTER = 1
  .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d
  .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11
  .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12
  .const OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a
  .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20
  .const OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19
  /// The VIC-II MOS 6567/6569
  .label VICII = $d000
  /// The CIA#1: keyboard matrix, joystick #1/#2
  .label CIA1 = $dc00
  /// The vector used when the KERNAL serves IRQ interrupts
  .label KERNEL_IRQ = $314
  // Pointer to the music init routine
  .label musicInit = MUSIC
  // Pointer to the music play routine
  .label musicPlay = MUSIC+3
.segment Code
  // irq_play
// Raster IRQ Routine playing music
irq_play: {
    // interrupt(isr_rom_sys_c64_entry) -- isr_rom_sys_c64_entry 
    // (VICII->BORDER_COLOR)++;
    // [0] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = ++ *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR
    // (*musicPlay)()
    // [1] callexecute *musicPlay  -- call__deref_pprc1 
    // Play SID
    jsr musicPlay
    // irq_play::@1
    // VICII->IRQ_STATUS = IRQ_RASTER
    // [2] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS) = IRQ_RASTER -- _deref_pbuc1=vbuc2 
    // Acknowledge the IRQ
    lda #IRQ_RASTER
    sta VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS
    // (VICII->BORDER_COLOR)--;
    // [3] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) = -- *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) -- _deref_pbuc1=_dec__deref_pbuc1 
    dec VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR
    // irq_play::@return
    // }
    // [4] return 
    // interrupt(isr_rom_sys_c64_exit) -- isr_rom_sys_c64_exit 
    jmp $ea31
}
  // main
// Setup Raster IRQ and initialize SID player
main: {
    // asm
    // asm { sei  }
    sei
    // (*musicInit)()
    // [6] callexecute *musicInit  -- call__deref_pprc1 
    jsr musicInit
    // main::@1
    // CIA1->INTERRUPT = CIA_INTERRUPT_CLEAR
    // [7] *((char *)CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT) = CIA_INTERRUPT_CLEAR -- _deref_pbuc1=vbuc2 
    // Disable CIA 1 Timer IRQ
    lda #CIA_INTERRUPT_CLEAR
    sta CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT
    // VICII->CONTROL1 &=$7f
    // [8] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) = *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1) & $7f -- _deref_pbuc1=_deref_pbuc1_band_vbuc2 
    // Set raster line to $fd
    lda #$7f
    and VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1
    sta VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1
    // VICII->RASTER = $fd
    // [9] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER) = $fd -- _deref_pbuc1=vbuc2 
    lda #$fd
    sta VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER
    // VICII->IRQ_ENABLE = IRQ_RASTER
    // [10] *((char *)VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE) = IRQ_RASTER -- _deref_pbuc1=vbuc2 
    // Enable Raster Interrupt
    lda #IRQ_RASTER
    sta VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE
    // *KERNEL_IRQ = &irq_play
    // [11] *KERNEL_IRQ = &irq_play -- _deref_qprc1=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
}
  // File Data
.segment Data
.pc = $1000 "MUSIC"
// SID tune at an absolute address
MUSIC:
.const music = LoadSid("toiletrensdyr.sid")
    .fill music.size, music.getData(i)


