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
  (byte*) RASTER#0 ← ((byte*)) (number) $d012
  (byte*) BORDERCOL#0 ← ((byte*)) (number) $d020
  to:@4
@4: scope:[]  from @begin
  (byte*) MUSIC#0 ← ((byte*)) (number) $1000
  kickasm() {{ .const music = LoadSid("toiletrensdyr.sid")
 }}
  kickasm(location (byte*) MUSIC#0) {{ .fill music.size, music.getData(i)
 }}
  to:@5
main: scope:[main]  from @5
  asm { jsrmusic.init  }
  to:main::@2
main::@2: scope:[main]  from main main::@2 main::@3
  (bool~) main::$0 ← *((byte*) RASTER#0) != (number) $fd
  if((bool~) main::$0) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@2
  *((byte*) BORDERCOL#0) ← ++ *((byte*) BORDERCOL#0)
  asm { jsrmusic.play  }
  *((byte*) BORDERCOL#0) ← -- *((byte*) BORDERCOL#0)
  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
(byte*) BORDERCOL
(byte*) BORDERCOL#0
(byte*) MUSIC
(byte*) MUSIC#0
(byte*) RASTER
(byte*) RASTER#0
(void()) main()
(bool~) main::$0
(label) main::@2
(label) main::@3
(label) main::@return

Adding number conversion cast (unumber) $fd in (bool~) main::$0 ← *((byte*) RASTER#0) != (number) $fd
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) RASTER#0 ← (byte*)(number) $d012
Inlining cast (byte*) BORDERCOL#0 ← (byte*)(number) $d020
Inlining cast (byte*) MUSIC#0 ← (byte*)(number) $1000
Successful SSA optimization Pass2InlineCast
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 [7] if(*((byte*) RASTER#0)!=(byte) $fd) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) RASTER#0 = (byte*) 53266
Constant (const byte*) BORDERCOL#0 = (byte*) 53280
Constant (const byte*) MUSIC#0 = (byte*) 4096
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [11] 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#0) {{ .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()
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#0)!=(byte) $fd) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1
  [8] *((const byte*) BORDERCOL#0) ← ++ *((const byte*) BORDERCOL#0)
  asm { jsrmusic.play  }
  [10] *((const byte*) BORDERCOL#0) ← -- *((const byte*) BORDERCOL#0)
  to:main::@1


VARIABLE REGISTER WEIGHTS
(byte*) BORDERCOL
(byte*) MUSIC
(byte*) RASTER
(void()) main()

Initial phi equivalence classes
Complete equivalence classes

INITIAL ASM
  // File Comments
// A simple SID music player playing music in the main loop.
  // Basic 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#0) {{ .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#0)!=(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#0) ← ++ *((const byte*) BORDERCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    // asm { jsrmusic.play  }
    // Play the music
    jsr music.play
    // [10] *((const byte*) BORDERCOL#0) ← -- *((const byte*) BORDERCOL#0) -- _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#0)!=(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.
  // Basic 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#0) {{ .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#0)!=(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#0) ← ++ *((const byte*) BORDERCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    // asm { jsrmusic.play  }
    // Play the music
    jsr music.play
    // [10] *((const byte*) BORDERCOL#0) ← -- *((const byte*) BORDERCOL#0) -- _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
Removing instruction b1:
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 bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @2
(label) @begin
(label) @end
(byte*) BORDERCOL
(const byte*) BORDERCOL#0 BORDERCOL = (byte*) 53280
(byte*) MUSIC
(const byte*) MUSIC#0 MUSIC = (byte*) 4096
(byte*) RASTER
(const byte*) RASTER#0 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.
  // Basic 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#0) {{ .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#0)!=(byte) $fd) goto main::@1 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$fd
    cmp RASTER
    bne b1
    // main::@2
    // (*BORDERCOL)++;
    // [8] *((const byte*) BORDERCOL#0) ← ++ *((const byte*) BORDERCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    // asm
    // asm { jsrmusic.play  }
    // Play the music
    jsr music.play
    // (*BORDERCOL)--;
    // [10] *((const byte*) BORDERCOL#0) ← -- *((const byte*) BORDERCOL#0) -- _deref_pbuc1=_dec__deref_pbuc1 
    dec BORDERCOL
    jmp b1
}
  // File Data
.pc = MUSIC "MUSIC"
  .fill music.size, music.getData(i)


