Fixing pointer array-indexing *((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
  (byte*~) $0 ← ((byte*)) (number) $400
  (byte*~) $1 ← ((byte*)) (number) $1400
  (byte*[]) screens#0 ← { (byte*~) $0, (byte*~) $1 }
  to:@3
main: scope:[main]  from @3
  (byte*) main::DSP#0 ← ((byte*)) (number) $400
  (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#0 ← (byte) main::getScreen1_id#1 * (const byte) SIZEOF_POINTER
  (byte*) main::getScreen1_return#0 ← *((byte*[]) screens#0 + (byte~) main::getScreen1_$0#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#0 ← (byte*) main::spritePtr1_screen#1 + (number) $378
  (byte~) main::spritePtr1_$1#0 ← ((byte)) *((byte*~) main::spritePtr1_$0#0)
  (byte) main::spritePtr1_return#0 ← (byte~) main::spritePtr1_$1#0
  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
  *((byte*) main::DSP#0 + (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
(byte*~) $0
(byte*~) $1
(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
(byte*) main::DSP
(byte*) main::DSP#0
(label) main::getScreen1
(byte~) main::getScreen1_$0
(byte~) main::getScreen1_$0#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_$0#0
(byte~) main::spritePtr1_$1
(byte~) main::spritePtr1_$1#0
(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
(byte*[]) screens
(byte*[]) screens#0

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#0 ← (byte*) main::spritePtr1_screen#1 + (number) $378
Adding number conversion cast (unumber) 0 in *((byte*) main::DSP#0 + (number) 0) ← (byte~) main::$1
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*~) $0 ← (byte*)(number) $400
Inlining cast (byte*~) $1 ← (byte*)(number) $1400
Inlining cast (byte*) main::DSP#0 ← (byte*)(number) $400
Inlining cast (byte) main::getScreen1_id#0 ← (unumber)(number) 0
Inlining cast (byte~) main::spritePtr1_$1#0 ← (byte)*((byte*~) main::spritePtr1_$0#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#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#0 (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*) $0 = (byte*) 1024
Constant (const byte*) $1 = (byte*) 5120
Constant (const byte*) main::DSP#0 = (byte*) 1024
Constant (const byte) main::getScreen1_id#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero main::DSP#0 in [21] *((const byte*) main::DSP#0 + (byte) 0) ← (byte) main::spritePtr1_return#0
Successful SSA optimization PassNSimplifyExpressionWithZero
Constant right-side identified [0] (byte*[]) screens#0 ← { (const byte*) $0, (const byte*) $1 }
Constant right-side identified [1] (byte~) main::getScreen1_$0#0 ← (const byte) main::getScreen1_id#0 * (const byte) SIZEOF_POINTER
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*[]) screens#0 = { $0, $1 }
Constant (const byte) main::getScreen1_$0#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#0 in [2] (byte*) main::getScreen1_return#0 ← *((const byte*[]) screens#0 + (const byte) main::getScreen1_$0#0)
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant (const byte) main::getScreen1_id#0
Eliminating unused constant (const byte) main::getScreen1_$0#0
Eliminating unused constant (const byte) SIZEOF_POINTER
Successful SSA optimization PassNEliminateUnusedVars
Constant inlined $0 = (byte*) 1024
Constant inlined $1 = (byte*) 5120
Successful SSA optimization Pass2ConstantInlining
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()
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#0)
  to:main::spritePtr1
main::spritePtr1: scope:[main]  from main::getScreen1
  [6] (byte*~) main::spritePtr1_$0#0 ← (byte*) main::getScreen1_return#0 + (word) $378
  [7] (byte) main::spritePtr1_return#0 ← *((byte*~) main::spritePtr1_$0#0)
  to:main::@1
main::@1: scope:[main]  from main::spritePtr1
  [8] *((const byte*) main::DSP#0) ← (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::DSP
(byte~) main::getScreen1_$0
(byte) main::getScreen1_id
(byte*) main::getScreen1_return
(byte*) main::getScreen1_return#0 4.0
(byte*~) main::spritePtr1_$0
(byte*~) main::spritePtr1_$0#0 4.0
(byte~) main::spritePtr1_$1
(byte) main::spritePtr1_return
(byte) main::spritePtr1_return#0 4.0
(byte*) main::spritePtr1_screen
(byte*[]) screens

Initial phi equivalence classes
Added variable main::getScreen1_return#0 to zero page equivalence class [ main::getScreen1_return#0 ]
Added variable main::spritePtr1_$0#0 to zero page equivalence class [ main::spritePtr1_$0#0 ]
Added variable main::spritePtr1_return#0 to zero page equivalence class [ main::spritePtr1_return#0 ]
Complete equivalence classes
[ main::getScreen1_return#0 ]
[ main::spritePtr1_$0#0 ]
[ main::spritePtr1_return#0 ]
Allocated zp ZP_WORD:2 [ main::getScreen1_return#0 ]
Allocated zp ZP_WORD:4 [ main::spritePtr1_$0#0 ]
Allocated zp ZP_BYTE:6 [ main::spritePtr1_return#0 ]

INITIAL ASM
  // File Comments
// Tests a cast that is not needed
  // Basic 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 getScreen1_return = 2
    .label spritePtr1__0 = 4
    .label spritePtr1_return = 6
    jmp getScreen1
    // main::getScreen1
  getScreen1:
    // [5] (byte*) main::getScreen1_return#0 ← *((const byte*[]) screens#0) -- pbuz1=_deref_pptc1 
    lda screens
    sta getScreen1_return
    lda screens+1
    sta getScreen1_return+1
    jmp spritePtr1
    // main::spritePtr1
  spritePtr1:
    // [6] (byte*~) main::spritePtr1_$0#0 ← (byte*) main::getScreen1_return#0 + (word) $378 -- pbuz1=pbuz2_plus_vwuc1 
    lda getScreen1_return
    clc
    adc #<$378
    sta spritePtr1__0
    lda getScreen1_return+1
    adc #>$378
    sta spritePtr1__0+1
    // [7] (byte) main::spritePtr1_return#0 ← *((byte*~) main::spritePtr1_$0#0) -- vbuz1=_deref_pbuz2 
    ldy #0
    lda (spritePtr1__0),y
    sta spritePtr1_return
    jmp b1
    // main::@1
  b1:
    // [8] *((const byte*) main::DSP#0) ← (byte) main::spritePtr1_return#0 -- _deref_pbuc1=vbuz1 
    lda 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#0) [ main::getScreen1_return#0 ] ( main:2 [ main::getScreen1_return#0 ] ) always clobbers reg byte a 
Statement [6] (byte*~) main::spritePtr1_$0#0 ← (byte*) main::getScreen1_return#0 + (word) $378 [ main::spritePtr1_$0#0 ] ( main:2 [ main::spritePtr1_$0#0 ] ) always clobbers reg byte a 
Statement [7] (byte) main::spritePtr1_return#0 ← *((byte*~) main::spritePtr1_$0#0) [ main::spritePtr1_return#0 ] ( main:2 [ main::spritePtr1_return#0 ] ) always clobbers reg byte a reg byte y 
Potential registers zp ZP_WORD:2 [ main::getScreen1_return#0 ] : zp ZP_WORD:2 , 
Potential registers zp ZP_WORD:4 [ main::spritePtr1_$0#0 ] : zp ZP_WORD:4 , 
Potential registers zp ZP_BYTE:6 [ main::spritePtr1_return#0 ] : zp ZP_BYTE:6 , reg byte a , reg byte x , reg byte y , 

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

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

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests a cast that is not needed
  // Basic 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 getScreen1_return = 2
    .label spritePtr1__0 = 2
    jmp getScreen1
    // main::getScreen1
  getScreen1:
    // [5] (byte*) main::getScreen1_return#0 ← *((const byte*[]) screens#0) -- pbuz1=_deref_pptc1 
    lda screens
    sta getScreen1_return
    lda screens+1
    sta getScreen1_return+1
    jmp spritePtr1
    // main::spritePtr1
  spritePtr1:
    // [6] (byte*~) main::spritePtr1_$0#0 ← (byte*) main::getScreen1_return#0 + (word) $378 -- pbuz1=pbuz1_plus_vwuc1 
    clc
    lda spritePtr1__0
    adc #<$378
    sta spritePtr1__0
    lda spritePtr1__0+1
    adc #>$378
    sta spritePtr1__0+1
    // [7] (byte) main::spritePtr1_return#0 ← *((byte*~) main::spritePtr1_$0#0) -- vbuaa=_deref_pbuz1 
    ldy #0
    lda (spritePtr1__0),y
    jmp b1
    // main::@1
  b1:
    // [8] *((const byte*) main::DSP#0) ← (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
Removing instruction b1_from_bbegin:
Removing instruction b1:
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 bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(label) main::@1
(label) main::@return
(byte*) main::DSP
(const byte*) main::DSP#0 DSP = (byte*) 1024
(label) main::getScreen1
(byte~) main::getScreen1_$0
(byte) main::getScreen1_id
(byte*) main::getScreen1_return
(byte*) main::getScreen1_return#0 getScreen1_return zp ZP_WORD:2 4.0
(label) main::spritePtr1
(byte*~) main::spritePtr1_$0
(byte*~) main::spritePtr1_$0#0 spritePtr1_$0 zp ZP_WORD:2 4.0
(byte~) main::spritePtr1_$1
(byte) main::spritePtr1_return
(byte) main::spritePtr1_return#0 reg byte a 4.0
(byte*) main::spritePtr1_screen
(byte*[]) screens
(const byte*[]) screens#0 screens = { (byte*) 1024, (byte*) 5120 }

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


FINAL ASSEMBLER
Score: 49

  // File Comments
// Tests a cast that is not needed
  // Basic 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 getScreen1_return = 2
    .label spritePtr1__0 = 2
    // main::getScreen1
    // return screens[id];
    // [5] (byte*) main::getScreen1_return#0 ← *((const byte*[]) screens#0) -- pbuz1=_deref_pptc1 
    lda screens
    sta getScreen1_return
    lda screens+1
    sta getScreen1_return+1
    // main::spritePtr1
    // screen+$378
    // [6] (byte*~) main::spritePtr1_$0#0 ← (byte*) main::getScreen1_return#0 + (word) $378 -- pbuz1=pbuz1_plus_vwuc1 
    clc
    lda spritePtr1__0
    adc #<$378
    sta spritePtr1__0
    lda spritePtr1__0+1
    adc #>$378
    sta spritePtr1__0+1
    // (byte)*(screen+$378)
    // [7] (byte) main::spritePtr1_return#0 ← *((byte*~) main::spritePtr1_$0#0) -- vbuaa=_deref_pbuz1 
    ldy #0
    lda (spritePtr1__0),y
    // main::@1
    // DSP[0] = spritePtr(getScreen(0))
    // [8] *((const byte*) main::DSP#0) ← (byte) main::spritePtr1_return#0 -- _deref_pbuc1=vbuaa 
    sta DSP
    // main::@return
    // }
    // [9] return 
    rts
}
  // File Data
  screens: .word $400, $1400

