Fixing pointer array-indexing *((const byte**) screens + (byte) getScreen::id)
Identified constant variable (byte*) main::DSP
Inlined call (byte*~) main::$0 ← call getScreen (number) 0 
Inlined call (byte~) main::$1 ← call spritePtr (byte*~) main::$0 
Culled Empty Block (label) main::getScreen1_@1
Culled Empty Block (label) main::spritePtr1_@1
Culled Empty Block (label) @1
Culled Empty Block (label) @2

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@3

(void()) main()
main: scope:[main]  from @3
  (byte) main::getScreen1_id#0 ← (number) 0
  to:main::getScreen1
main::getScreen1: scope:[main]  from main
  (byte) main::getScreen1_id#1 ← phi( main/(byte) main::getScreen1_id#0 )
  (byte~) main::getScreen1_$0 ← (byte) main::getScreen1_id#1 * (const byte) SIZEOF_POINTER
  (byte*) main::getScreen1_return#0 ← *((const byte**) screens + (byte~) main::getScreen1_$0)
  to:main::getScreen1_@return
main::getScreen1_@return: scope:[main]  from main::getScreen1
  (byte*) main::getScreen1_return#2 ← phi( main::getScreen1/(byte*) main::getScreen1_return#0 )
  (byte*) main::getScreen1_return#1 ← (byte*) main::getScreen1_return#2
  to:main::@1
main::@1: scope:[main]  from main::getScreen1_@return
  (byte*) main::getScreen1_return#3 ← phi( main::getScreen1_@return/(byte*) main::getScreen1_return#1 )
  (byte*~) main::$0 ← (byte*) main::getScreen1_return#3
  (byte*) main::spritePtr1_screen#0 ← (byte*~) main::$0
  to:main::spritePtr1
main::spritePtr1: scope:[main]  from main::@1
  (byte*) main::spritePtr1_screen#1 ← phi( main::@1/(byte*) main::spritePtr1_screen#0 )
  (byte*~) main::spritePtr1_$0 ← (byte*) main::spritePtr1_screen#1 + (number) $378
  (byte~) main::spritePtr1_$1 ← ((byte)) *((byte*~) main::spritePtr1_$0)
  (byte) main::spritePtr1_return#0 ← (byte~) main::spritePtr1_$1
  to:main::spritePtr1_@return
main::spritePtr1_@return: scope:[main]  from main::spritePtr1
  (byte) main::spritePtr1_return#2 ← phi( main::spritePtr1/(byte) main::spritePtr1_return#0 )
  (byte) main::spritePtr1_return#1 ← (byte) main::spritePtr1_return#2
  to:main::@2
main::@2: scope:[main]  from main::spritePtr1_@return
  (byte) main::spritePtr1_return#3 ← phi( main::spritePtr1_@return/(byte) main::spritePtr1_return#1 )
  (byte~) main::$1 ← (byte) main::spritePtr1_return#3
  *((const byte*) main::DSP + (number) 0) ← (byte~) main::$1
  to:main::@return
main::@return: scope:[main]  from main::@2
  return 
  to:@return
@3: scope:[]  from @begin
  call main 
  to:@4
@4: scope:[]  from @3
  to:@end
@end: scope:[]  from @4

SYMBOL TABLE SSA
(label) @3
(label) @4
(label) @begin
(label) @end
(const byte) SIZEOF_POINTER = (byte) 2
(void()) main()
(byte*~) main::$0
(byte~) main::$1
(label) main::@1
(label) main::@2
(label) main::@return
(const byte*) main::DSP = (byte*)(number) $400
(label) main::getScreen1
(byte~) main::getScreen1_$0
(label) main::getScreen1_@return
(byte) main::getScreen1_id
(byte) main::getScreen1_id#0
(byte) main::getScreen1_id#1
(byte*) main::getScreen1_return
(byte*) main::getScreen1_return#0
(byte*) main::getScreen1_return#1
(byte*) main::getScreen1_return#2
(byte*) main::getScreen1_return#3
(label) main::spritePtr1
(byte*~) main::spritePtr1_$0
(byte~) main::spritePtr1_$1
(label) main::spritePtr1_@return
(byte) main::spritePtr1_return
(byte) main::spritePtr1_return#0
(byte) main::spritePtr1_return#1
(byte) main::spritePtr1_return#2
(byte) main::spritePtr1_return#3
(byte*) main::spritePtr1_screen
(byte*) main::spritePtr1_screen#0
(byte*) main::spritePtr1_screen#1
(const byte**) screens[]  = { (byte*)(number) $400, (byte*)(number) $1400 }

Adding number conversion cast (unumber) 0 in (byte) main::getScreen1_id#0 ← (number) 0
Adding number conversion cast (unumber) $378 in (byte*~) main::spritePtr1_$0 ← (byte*) main::spritePtr1_screen#1 + (number) $378
Adding number conversion cast (unumber) 0 in *((const byte*) main::DSP + (number) 0) ← (byte~) main::$1
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte) main::getScreen1_id#0 ← (unumber)(number) 0
Inlining cast (byte~) main::spritePtr1_$1 ← (byte)*((byte*~) main::spritePtr1_$0)
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (byte*) 5120
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast $378
Simplifying constant integer cast *((byte*~) main::spritePtr1_$0)
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (word) $378
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte) main::getScreen1_id#0 = (byte) main::getScreen1_id#1 
Alias (byte*) main::getScreen1_return#0 = (byte*) main::getScreen1_return#2 (byte*) main::getScreen1_return#1 (byte*) main::getScreen1_return#3 (byte*~) main::$0 (byte*) main::spritePtr1_screen#0 (byte*) main::spritePtr1_screen#1 
Alias (byte) main::spritePtr1_return#0 = (byte~) main::spritePtr1_$1 (byte) main::spritePtr1_return#2 (byte) main::spritePtr1_return#1 (byte) main::spritePtr1_return#3 (byte~) main::$1 
Successful SSA optimization Pass2AliasElimination
Constant (const byte) main::getScreen1_id#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero main::DSP in [5] *((const byte*) main::DSP + (byte) 0) ← (byte) main::spritePtr1_return#0
Successful SSA optimization PassNSimplifyExpressionWithZero
Constant right-side identified [0] (byte~) main::getScreen1_$0 ← (const byte) main::getScreen1_id#0 * (const byte) SIZEOF_POINTER
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::getScreen1_$0 = main::getScreen1_id#0*SIZEOF_POINTER
Successful SSA optimization Pass2ConstantIdentification
Simplifying constant evaluating to zero (const byte) main::getScreen1_id#0*(const byte) SIZEOF_POINTER in 
Successful SSA optimization PassNSimplifyConstantZero
Simplifying expression containing zero screens in [1] (byte*) main::getScreen1_return#0 ← *((const byte**) screens + (const byte) main::getScreen1_$0)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant (const byte) main::getScreen1_id#0
Eliminating unused constant (const byte) main::getScreen1_$0
Eliminating unused constant (const byte) SIZEOF_POINTER
Successful SSA optimization PassNEliminateUnusedVars
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @3
Adding NOP phi() at start of @4
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::getScreen1_@return
Adding NOP phi() at start of main::@1
Adding NOP phi() at start of main::spritePtr1_@return
CALL GRAPH
Calls in [] to main:2 

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block (label) @4
Culled Empty Block (label) main::getScreen1_@return
Culled Empty Block (label) main::@1
Culled Empty Block (label) main::spritePtr1_@return
Renumbering block @3 to @1
Renumbering block main::@2 to main::@1
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
Adding NOP phi() at start of main

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi()
  to:@1
@1: scope:[]  from @begin
  [1] phi()
  [2] call main 
  to:@end
@end: scope:[]  from @1
  [3] phi()

(void()) main()
main: scope:[main]  from @1
  [4] phi()
  to:main::getScreen1
main::getScreen1: scope:[main]  from main
  [5] (byte*) main::getScreen1_return#0 ← *((const byte**) screens)
  to:main::spritePtr1
main::spritePtr1: scope:[main]  from main::getScreen1
  [6] (byte*~) main::spritePtr1_$0 ← (byte*) main::getScreen1_return#0 + (word) $378
  [7] (byte) main::spritePtr1_return#0 ← *((byte*~) main::spritePtr1_$0)
  to:main::@1
main::@1: scope:[main]  from main::spritePtr1
  [8] *((const byte*) main::DSP) ← (byte) main::spritePtr1_return#0
  to:main::@return
main::@return: scope:[main]  from main::@1
  [9] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(byte) main::getScreen1_id
(byte*) main::getScreen1_return
(byte*) main::getScreen1_return#0 4.0
(byte*~) main::spritePtr1_$0 4.0
(byte) main::spritePtr1_return
(byte) main::spritePtr1_return#0 4.0
(byte*) main::spritePtr1_screen

Initial phi equivalence classes
Added variable main::getScreen1_return#0 to live range equivalence class [ main::getScreen1_return#0 ]
Added variable main::spritePtr1_$0 to live range equivalence class [ main::spritePtr1_$0 ]
Added variable main::spritePtr1_return#0 to live range equivalence class [ main::spritePtr1_return#0 ]
Complete equivalence classes
[ main::getScreen1_return#0 ]
[ main::spritePtr1_$0 ]
[ main::spritePtr1_return#0 ]
Allocated zp[2]:2 [ main::getScreen1_return#0 ]
Allocated zp[2]:4 [ main::spritePtr1_$0 ]
Allocated zp[1]:6 [ main::spritePtr1_return#0 ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// Tests a cast that is not needed
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  // @begin
__bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
  jmp __b1
  // @1
__b1:
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
main_from___b1:
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
  jmp __bend
  // @end
__bend:
  // main
main: {
    .label DSP = $400
    .label spritePtr1___0 = 4
    .label getScreen1_return = 2
    .label spritePtr1_return = 6
    jmp getScreen1
    // main::getScreen1
  getScreen1:
    // [5] (byte*) main::getScreen1_return#0 ← *((const byte**) screens) -- pbuz1=_deref_pptc1 
    lda screens
    sta.z getScreen1_return
    lda screens+1
    sta.z getScreen1_return+1
    jmp spritePtr1
    // main::spritePtr1
  spritePtr1:
    // [6] (byte*~) main::spritePtr1_$0 ← (byte*) main::getScreen1_return#0 + (word) $378 -- pbuz1=pbuz2_plus_vwuc1 
    lda.z getScreen1_return
    clc
    adc #<$378
    sta.z spritePtr1___0
    lda.z getScreen1_return+1
    adc #>$378
    sta.z spritePtr1___0+1
    // [7] (byte) main::spritePtr1_return#0 ← *((byte*~) main::spritePtr1_$0) -- vbuz1=_deref_pbuz2 
    ldy #0
    lda (spritePtr1___0),y
    sta.z spritePtr1_return
    jmp __b1
    // main::@1
  __b1:
    // [8] *((const byte*) main::DSP) ← (byte) main::spritePtr1_return#0 -- _deref_pbuc1=vbuz1 
    lda.z spritePtr1_return
    sta DSP
    jmp __breturn
    // main::@return
  __breturn:
    // [9] return 
    rts
}
  // File Data
  screens: .word $400, $1400

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [5] (byte*) main::getScreen1_return#0 ← *((const byte**) screens) [ main::getScreen1_return#0 ] ( main:2 [ main::getScreen1_return#0 ] ) always clobbers reg byte a 
Statement [6] (byte*~) main::spritePtr1_$0 ← (byte*) main::getScreen1_return#0 + (word) $378 [ main::spritePtr1_$0 ] ( main:2 [ main::spritePtr1_$0 ] ) always clobbers reg byte a 
Statement [7] (byte) main::spritePtr1_return#0 ← *((byte*~) main::spritePtr1_$0) [ main::spritePtr1_return#0 ] ( main:2 [ main::spritePtr1_return#0 ] ) always clobbers reg byte a reg byte y 
Potential registers zp[2]:2 [ main::getScreen1_return#0 ] : zp[2]:2 , 
Potential registers zp[2]:4 [ main::spritePtr1_$0 ] : zp[2]:4 , 
Potential registers zp[1]:6 [ main::spritePtr1_return#0 ] : zp[1]:6 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 4: zp[2]:2 [ main::getScreen1_return#0 ] 4: zp[2]:4 [ main::spritePtr1_$0 ] 4: zp[1]:6 [ main::spritePtr1_return#0 ] 
Uplift Scope [] 

Uplifting [main] best 100 combination zp[2]:2 [ main::getScreen1_return#0 ] zp[2]:4 [ main::spritePtr1_$0 ] reg byte a [ main::spritePtr1_return#0 ] 
Uplifting [] best 100 combination 
Coalescing zero page register [ zp[2]:2 [ main::getScreen1_return#0 ] ] with [ zp[2]:4 [ main::spritePtr1_$0 ] ] - score: 1

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests a cast that is not needed
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  // @begin
__bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
  jmp __b1
  // @1
__b1:
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
main_from___b1:
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
  jmp __bend
  // @end
__bend:
  // main
main: {
    .label DSP = $400
    .label spritePtr1___0 = 2
    .label getScreen1_return = 2
    jmp getScreen1
    // main::getScreen1
  getScreen1:
    // [5] (byte*) main::getScreen1_return#0 ← *((const byte**) screens) -- pbuz1=_deref_pptc1 
    lda screens
    sta.z getScreen1_return
    lda screens+1
    sta.z getScreen1_return+1
    jmp spritePtr1
    // main::spritePtr1
  spritePtr1:
    // [6] (byte*~) main::spritePtr1_$0 ← (byte*) main::getScreen1_return#0 + (word) $378 -- pbuz1=pbuz1_plus_vwuc1 
    clc
    lda.z spritePtr1___0
    adc #<$378
    sta.z spritePtr1___0
    lda.z spritePtr1___0+1
    adc #>$378
    sta.z spritePtr1___0+1
    // [7] (byte) main::spritePtr1_return#0 ← *((byte*~) main::spritePtr1_$0) -- vbuaa=_deref_pbuz1 
    ldy #0
    lda (spritePtr1___0),y
    jmp __b1
    // main::@1
  __b1:
    // [8] *((const byte*) main::DSP) ← (byte) main::spritePtr1_return#0 -- _deref_pbuc1=vbuaa 
    sta DSP
    jmp __breturn
    // main::@return
  __breturn:
    // [9] return 
    rts
}
  // File Data
  screens: .word $400, $1400

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp getScreen1
Removing instruction jmp spritePtr1
Removing instruction jmp __b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __bbegin with __b1
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction getScreen1:
Removing instruction spritePtr1:
Removing instruction __b1:
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) @begin
(label) @end
(void()) main()
(label) main::@1
(label) main::@return
(const byte*) main::DSP = (byte*) 1024
(label) main::getScreen1
(byte) main::getScreen1_id
(byte*) main::getScreen1_return
(byte*) main::getScreen1_return#0 getScreen1_return zp[2]:2 4.0
(label) main::spritePtr1
(byte*~) main::spritePtr1_$0 zp[2]:2 4.0
(byte) main::spritePtr1_return
(byte) main::spritePtr1_return#0 reg byte a 4.0
(byte*) main::spritePtr1_screen
(const byte**) screens[]  = { (byte*) 1024, (byte*) 5120 }

zp[2]:2 [ main::getScreen1_return#0 main::spritePtr1_$0 ]
reg byte a [ main::spritePtr1_return#0 ]


FINAL ASSEMBLER
Score: 49

  // File Comments
// Tests a cast that is not needed
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  // @begin
  // [1] phi from @begin to @1 [phi:@begin->@1]
  // @1
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    .label DSP = $400
    .label spritePtr1___0 = 2
    .label getScreen1_return = 2
    // main::getScreen1
    // return screens[id];
    // [5] (byte*) main::getScreen1_return#0 ← *((const byte**) screens) -- pbuz1=_deref_pptc1 
    lda screens
    sta.z getScreen1_return
    lda screens+1
    sta.z getScreen1_return+1
    // main::spritePtr1
    // screen+$378
    // [6] (byte*~) main::spritePtr1_$0 ← (byte*) main::getScreen1_return#0 + (word) $378 -- pbuz1=pbuz1_plus_vwuc1 
    clc
    lda.z spritePtr1___0
    adc #<$378
    sta.z spritePtr1___0
    lda.z spritePtr1___0+1
    adc #>$378
    sta.z spritePtr1___0+1
    // (byte)*(screen+$378)
    // [7] (byte) main::spritePtr1_return#0 ← *((byte*~) main::spritePtr1_$0) -- vbuaa=_deref_pbuz1 
    ldy #0
    lda (spritePtr1___0),y
    // main::@1
    // DSP[0] = spritePtr(getScreen(0))
    // [8] *((const byte*) main::DSP) ← (byte) main::spritePtr1_return#0 -- _deref_pbuc1=vbuaa 
    sta DSP
    // main::@return
    // }
    // [9] return 
    rts
}
  // File Data
  screens: .word $400, $1400

