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) main::@1
Culled Empty Block (label) main::@4

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:@5

(void()) main()
main: scope:[main]  from @5
  asm { jsrmusic.init  }
  to:main::@2
main::@2: scope:[main]  from main main::@2 main::@3
  (bool~) main::$0 ← *((const byte*) RASTER) != (number) $fd
  if((bool~) main::$0) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@2
  *((const byte*) BORDERCOL) ← ++ *((const byte*) BORDERCOL)
  asm { jsrmusic.play  }
  *((const byte*) BORDERCOL) ← -- *((const byte*) BORDERCOL)
  if(true) goto main::@2
  to:main::@return
main::@return: scope:[main]  from main::@3
  return 
  to:@return
@5: scope:[]  from @4
  call main 
  to:@6
@6: scope:[]  from @5
  to:@end
@end: scope:[]  from @6

SYMBOL TABLE SSA
(label) @4
(label) @5
(label) @6
(label) @begin
(label) @end
(const byte*) BORDERCOL = (byte*)(number) $d020
(const byte*) MUSIC = (byte*)(number) $1000
(const byte*) RASTER = (byte*)(number) $d012
(void()) main()
(bool~) main::$0
(label) main::@2
(label) main::@3
(label) main::@return

Adding number conversion cast (unumber) $fd in (bool~) main::$0 ← *((const byte*) RASTER) != (number) $fd
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 53266
Simplifying constant pointer cast (byte*) 53280
Simplifying constant pointer cast (byte*) 4096
Simplifying constant integer cast $fd
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $fd
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simple Condition (bool~) main::$0 [4] if(*((const byte*) RASTER)!=(byte) $fd) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
if() condition always true - replacing block destination [8] if(true) goto main::@2
Successful SSA optimization Pass2ConstantIfs
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @5
Adding NOP phi() at start of @6
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) @6
Renumbering block @4 to @1
Renumbering block @5 to @2
Renumbering block main::@2 to main::@1
Renumbering block main::@3 to main::@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 { jsrmusic.init  }
  to:main::@1
main::@1: scope:[main]  from main main::@1 main::@2
  [7] if(*((const byte*) RASTER)!=(byte) $fd) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1
  [8] *((const byte*) BORDERCOL) ← ++ *((const byte*) BORDERCOL)
  asm { jsrmusic.play  }
  [10] *((const byte*) BORDERCOL) ← -- *((const byte*) BORDERCOL)
  to:main::@1


VARIABLE REGISTER WEIGHTS
(void()) main()

Initial phi equivalence classes
Complete equivalence classes

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// A simple SID music player playing music in the main loop.
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label RASTER = $d012
  .label BORDERCOL = $d020
  .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
// Play the music 
main: {
    // asm { jsrmusic.init  }
    // Initialize the music
    jsr music.init
    jmp __b1
  // Wait for the RASTER
    // main::@1
  __b1:
    // [7] if(*((const byte*) RASTER)!=(byte) $fd) goto main::@1 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$fd
    cmp RASTER
    bne __b1
    jmp __b2
    // main::@2
  __b2:
    // [8] *((const byte*) BORDERCOL) ← ++ *((const byte*) BORDERCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    // asm { jsrmusic.play  }
    // Play the music
    jsr music.play
    // [10] *((const byte*) BORDERCOL) ← -- *((const byte*) BORDERCOL) -- _deref_pbuc1=_dec__deref_pbuc1 
    dec BORDERCOL
    jmp __b1
}
  // File Data
.pc = MUSIC "MUSIC"
  .fill music.size, music.getData(i)


REGISTER UPLIFT POTENTIAL REGISTERS
Statement asm { jsrmusic.init  } always clobbers reg byte a reg byte x reg byte y 
Statement [7] if(*((const byte*) RASTER)!=(byte) $fd) goto main::@1 [ ] ( main:4 [ ] ) always clobbers reg byte a 
Statement asm { jsrmusic.play  } always clobbers reg byte a reg byte x reg byte y 

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

Uplifting [main] best 4227 combination 
Uplifting [] best 4227 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// A simple SID music player playing music in the main loop.
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label RASTER = $d012
  .label BORDERCOL = $d020
  .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
// Play the music 
main: {
    // asm { jsrmusic.init  }
    // Initialize the music
    jsr music.init
    jmp __b1
  // Wait for the RASTER
    // main::@1
  __b1:
    // [7] if(*((const byte*) RASTER)!=(byte) $fd) goto main::@1 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$fd
    cmp RASTER
    bne __b1
    jmp __b2
    // main::@2
  __b2:
    // [8] *((const byte*) BORDERCOL) ← ++ *((const byte*) BORDERCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    // asm { jsrmusic.play  }
    // Play the music
    jsr music.play
    // [10] *((const byte*) BORDERCOL) ← -- *((const byte*) BORDERCOL) -- _deref_pbuc1=_dec__deref_pbuc1 
    dec BORDERCOL
    jmp __b1
}
  // 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 __b1
Removing instruction jmp __b2
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 __b2:
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*) MUSIC = (byte*) 4096
(const byte*) RASTER = (byte*) 53266
(void()) main()
(label) main::@1
(label) main::@2



FINAL ASSEMBLER
Score: 3882

  // File Comments
// A simple SID music player playing music in the main loop.
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .label RASTER = $d012
  .label BORDERCOL = $d020
  .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
// Play the music 
main: {
    // asm
    // asm { jsrmusic.init  }
    // Initialize the music
    jsr music.init
  // Wait for the RASTER
    // main::@1
  __b1:
    // while (*RASTER != $fd)
    // [7] if(*((const byte*) RASTER)!=(byte) $fd) goto main::@1 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$fd
    cmp RASTER
    bne __b1
    // main::@2
    // (*BORDERCOL)++;
    // [8] *((const byte*) BORDERCOL) ← ++ *((const byte*) BORDERCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    // asm
    // asm { jsrmusic.play  }
    // Play the music
    jsr music.play
    // (*BORDERCOL)--;
    // [10] *((const byte*) BORDERCOL) ← -- *((const byte*) BORDERCOL) -- _deref_pbuc1=_dec__deref_pbuc1 
    dec BORDERCOL
    jmp __b1
}
  // File Data
.pc = MUSIC "MUSIC"
  .fill music.size, music.getData(i)


