Setting inferred volatile on symbol affected by address-of (byte*~) main::$0 ← & (byte) main::ub
Setting inferred volatile on symbol affected by address-of (signed byte*~) main::$3 ← & (signed byte) main::sb

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@1
main: scope:[main]  from @1
  (byte*) main::ub_screen#0 ← ((byte*)) (number) $400
  (byte) main::ub#0 ← (number) $ff
  (byte*~) main::$0 ← & (byte) main::ub#0
  (signed byte*~) main::$1 ← ((signed byte*)) (byte*~) main::$0
  (signed byte*) main::sb_ptr#0 ← (signed byte*~) main::$1
  *((signed byte*) main::sb_ptr#0) ← (number) 1
  *((byte*) main::ub_screen#0) ← (byte) main::ub#0
  (signed byte*) main::sb_screen#0 ← ((signed byte*)) (number) $428
  (signed byte~) main::$2 ← ((signed byte)) (number) $7f
  (signed byte) main::sb#0 ← (signed byte~) main::$2
  (signed byte*~) main::$3 ← & (signed byte) main::sb#0
  (byte*~) main::$4 ← ((byte*)) (signed byte*~) main::$3
  (byte*) main::ub_ptr#0 ← (byte*~) main::$4
  *((byte*) main::ub_ptr#0) ← (number) 1
  *((signed byte*) main::sb_screen#0) ← (signed byte) main::sb#0
  to:main::@return
main::@return: scope:[main]  from main
  return 
  to:@return
@1: scope:[]  from @begin
  call main 
  to:@2
@2: scope:[]  from @1
  to:@end
@end: scope:[]  from @2

SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(void()) main()
(byte*~) main::$0
(signed byte*~) main::$1
(signed byte~) main::$2
(signed byte*~) main::$3
(byte*~) main::$4
(label) main::@return
(signed byte) main::sb
(signed byte) main::sb#0
(signed byte*) main::sb_ptr
(signed byte*) main::sb_ptr#0
(signed byte*) main::sb_screen
(signed byte*) main::sb_screen#0
(byte) main::ub
(byte) main::ub#0
(byte*) main::ub_ptr
(byte*) main::ub_ptr#0
(byte*) main::ub_screen
(byte*) main::ub_screen#0

Adding number conversion cast (unumber) $ff in (byte) main::ub#0 ← (number) $ff
Adding number conversion cast (snumber) 1 in *((signed byte*) main::sb_ptr#0) ← (number) 1
Adding number conversion cast (unumber) 1 in *((byte*) main::ub_ptr#0) ← (number) 1
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) main::ub_screen#0 ← (byte*)(number) $400
Inlining cast (byte) main::ub#0 ← (unumber)(number) $ff
Inlining cast (signed byte*~) main::$1 ← (signed byte*)(byte*~) main::$0
Inlining cast *((signed byte*) main::sb_ptr#0) ← (snumber)(number) 1
Inlining cast (signed byte*) main::sb_screen#0 ← (signed byte*)(number) $428
Inlining cast (signed byte~) main::$2 ← (signed byte)(number) $7f
Inlining cast (byte*~) main::$4 ← (byte*)(signed byte*~) main::$3
Inlining cast *((byte*) main::ub_ptr#0) ← (unumber)(number) 1
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast $ff
Simplifying constant integer cast 1
Simplifying constant pointer cast (signed byte*) 1064
Simplifying constant integer cast $7f
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $ff
Finalized signed number type (signed byte) 1
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias candidate removed (volatile)(signed byte) main::sb#0 = (signed byte~) main::$2 
Alias (signed byte*) main::sb_ptr#0 = (signed byte*~) main::$1 
Alias (byte*) main::ub_ptr#0 = (byte*~) main::$4 
Successful SSA optimization Pass2AliasElimination
Alias candidate removed (volatile)(signed byte) main::sb#0 = (signed byte~) main::$2 
Constant right-side identified [2] (byte*~) main::$0 ← & (byte) main::ub#0
Constant right-side identified [10] (signed byte*~) main::$3 ← & (signed byte) main::sb#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) main::ub_screen#0 = (byte*) 1024
Constant (const byte*) main::$0 = &main::ub#0
Constant (const signed byte*) main::sb_screen#0 = (signed byte*) 1064
Constant (const signed byte) main::$2 = $7f
Constant (const signed byte*) main::$3 = &main::sb#0
Successful SSA optimization Pass2ConstantIdentification
Constant value identified (signed byte*)main::$0 in [3] (signed byte*) main::sb_ptr#0 ← (signed byte*)(const byte*) main::$0
Constant value identified (byte*)main::$3 in [11] (byte*) main::ub_ptr#0 ← (byte*)(const signed byte*) main::$3
Successful SSA optimization Pass2ConstantValues
Constant (const signed byte*) main::sb_ptr#0 = (signed byte*)main::$0
Constant (const byte*) main::ub_ptr#0 = (byte*)main::$3
Successful SSA optimization Pass2ConstantIdentification
Constant inlined main::$3 = &(signed byte) main::sb#0
Constant inlined main::$2 = (signed byte) $7f
Constant inlined main::$0 = &(byte) main::ub#0
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
CALL GRAPH
Calls in [] to main:2 

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block (label) @2
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end

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] (byte) main::ub#0 ← (byte) $ff
  [5] *((const signed byte*) main::sb_ptr#0) ← (signed byte) 1
  [6] *((const byte*) main::ub_screen#0) ← (byte) main::ub#0
  [7] (signed byte) main::sb#0 ← (signed byte) $7f
  [8] *((const byte*) main::ub_ptr#0) ← (byte) 1
  [9] *((const signed byte*) main::sb_screen#0) ← (signed byte) main::sb#0
  to:main::@return
main::@return: scope:[main]  from main
  [10] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(signed byte) main::sb
(signed byte) main::sb#0 2.0
(signed byte*) main::sb_ptr
(signed byte*) main::sb_screen
(byte) main::ub
(byte) main::ub#0 2.0
(byte*) main::ub_ptr
(byte*) main::ub_screen

Initial phi equivalence classes
Complete equivalence classes
[ main::ub#0 ]
[ main::sb#0 ]
Allocated zp ZP_BYTE:2 [ main::ub#0 ]
Allocated zp ZP_BYTE:3 [ main::sb#0 ]

INITIAL ASM
Target platform is c64basic
  // File Comments
// Tests casting pointer types to other pointer types
  // 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 
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
main: {
    .label ub_screen = $400
    .label sb_screen = $428
    .label sb_ptr = ub
    .label ub_ptr = sb
    .label ub = 2
    .label sb = 3
    // [4] (byte) main::ub#0 ← (byte) $ff -- vbuz1=vbuc1 
    lda #$ff
    sta.z ub
    // [5] *((const signed byte*) main::sb_ptr#0) ← (signed byte) 1 -- _deref_pbsc1=vbsc2 
    lda #1
    sta sb_ptr
    // [6] *((const byte*) main::ub_screen#0) ← (byte) main::ub#0 -- _deref_pbuc1=vbuz1 
    lda.z ub
    sta ub_screen
    // [7] (signed byte) main::sb#0 ← (signed byte) $7f -- vbsz1=vbsc1 
    lda #$7f
    sta.z sb
    // [8] *((const byte*) main::ub_ptr#0) ← (byte) 1 -- _deref_pbuc1=vbuc2 
    lda #1
    sta ub_ptr
    // [9] *((const signed byte*) main::sb_screen#0) ← (signed byte) main::sb#0 -- _deref_pbsc1=vbsz1 
    lda.z sb
    sta sb_screen
    jmp breturn
    // main::@return
  breturn:
    // [10] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] (byte) main::ub#0 ← (byte) $ff [ main::ub#0 ] ( main:2 [ main::ub#0 ] ) always clobbers reg byte a 
Statement [5] *((const signed byte*) main::sb_ptr#0) ← (signed byte) 1 [ main::ub#0 ] ( main:2 [ main::ub#0 ] ) always clobbers reg byte a 
Statement [6] *((const byte*) main::ub_screen#0) ← (byte) main::ub#0 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [7] (signed byte) main::sb#0 ← (signed byte) $7f [ main::sb#0 ] ( main:2 [ main::sb#0 ] ) always clobbers reg byte a 
Statement [8] *((const byte*) main::ub_ptr#0) ← (byte) 1 [ main::sb#0 ] ( main:2 [ main::sb#0 ] ) always clobbers reg byte a 
Statement [9] *((const signed byte*) main::sb_screen#0) ← (signed byte) main::sb#0 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Potential registers zp ZP_BYTE:2 [ main::ub#0 ] : zp ZP_BYTE:2 , 
Potential registers zp ZP_BYTE:3 [ main::sb#0 ] : zp ZP_BYTE:3 , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 2: zp ZP_BYTE:2 [ main::ub#0 ] 2: zp ZP_BYTE:3 [ main::sb#0 ] 
Uplift Scope [] 

Uplifting [main] best 57 combination zp ZP_BYTE:2 [ main::ub#0 ] zp ZP_BYTE:3 [ main::sb#0 ] 
Uplifting [] best 57 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:2 [ main::ub#0 ]
Uplifting [main] best 57 combination zp ZP_BYTE:2 [ main::ub#0 ] 
Attempting to uplift remaining variables inzp ZP_BYTE:3 [ main::sb#0 ]
Uplifting [main] best 57 combination zp ZP_BYTE:3 [ main::sb#0 ] 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests casting pointer types to other pointer types
  // 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 
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
main: {
    .label ub_screen = $400
    .label sb_screen = $428
    .label sb_ptr = ub
    .label ub_ptr = sb
    .label ub = 2
    .label sb = 3
    // [4] (byte) main::ub#0 ← (byte) $ff -- vbuz1=vbuc1 
    lda #$ff
    sta.z ub
    // [5] *((const signed byte*) main::sb_ptr#0) ← (signed byte) 1 -- _deref_pbsc1=vbsc2 
    lda #1
    sta sb_ptr
    // [6] *((const byte*) main::ub_screen#0) ← (byte) main::ub#0 -- _deref_pbuc1=vbuz1 
    lda.z ub
    sta ub_screen
    // [7] (signed byte) main::sb#0 ← (signed byte) $7f -- vbsz1=vbsc1 
    lda #$7f
    sta.z sb
    // [8] *((const byte*) main::ub_ptr#0) ← (byte) 1 -- _deref_pbuc1=vbuc2 
    lda #1
    sta ub_ptr
    // [9] *((const signed byte*) main::sb_screen#0) ← (signed byte) main::sb#0 -- _deref_pbsc1=vbsz1 
    lda.z sb
    sta sb_screen
    jmp breturn
    // main::@return
  breturn:
    // [10] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction bend_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
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::@return
(signed byte) main::sb
(signed byte) main::sb#0 sb zp ZP_BYTE:3 2.0
(signed byte*) main::sb_ptr
(const signed byte*) main::sb_ptr#0 sb_ptr = (signed byte*)&(byte) main::ub#0
(signed byte*) main::sb_screen
(const signed byte*) main::sb_screen#0 sb_screen = (signed byte*) 1064
(byte) main::ub
(byte) main::ub#0 ub zp ZP_BYTE:2 2.0
(byte*) main::ub_ptr
(const byte*) main::ub_ptr#0 ub_ptr = (byte*)&(signed byte) main::sb#0
(byte*) main::ub_screen
(const byte*) main::ub_screen#0 ub_screen = (byte*) 1024

zp ZP_BYTE:2 [ main::ub#0 ]
zp ZP_BYTE:3 [ main::sb#0 ]


FINAL ASSEMBLER
Score: 42

  // File Comments
// Tests casting pointer types to other pointer types
  // 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 
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    .label ub_screen = $400
    .label sb_screen = $428
    .label sb_ptr = ub
    .label ub_ptr = sb
    .label ub = 2
    .label sb = 3
    // ub = 0xff
    // [4] (byte) main::ub#0 ← (byte) $ff -- vbuz1=vbuc1 
    lda #$ff
    sta.z ub
    // *sb_ptr = 1
    // [5] *((const signed byte*) main::sb_ptr#0) ← (signed byte) 1 -- _deref_pbsc1=vbsc2 
    lda #1
    sta sb_ptr
    // *ub_screen = ub
    // [6] *((const byte*) main::ub_screen#0) ← (byte) main::ub#0 -- _deref_pbuc1=vbuz1 
    lda.z ub
    sta ub_screen
    // sb = (signed byte)0x7f
    // [7] (signed byte) main::sb#0 ← (signed byte) $7f -- vbsz1=vbsc1 
    lda #$7f
    sta.z sb
    // *ub_ptr = 1
    // [8] *((const byte*) main::ub_ptr#0) ← (byte) 1 -- _deref_pbuc1=vbuc2 
    lda #1
    sta ub_ptr
    // *sb_screen = sb
    // [9] *((const signed byte*) main::sb_screen#0) ← (signed byte) main::sb#0 -- _deref_pbsc1=vbsz1 
    lda.z sb
    sta sb_screen
    // main::@return
    // }
    // [10] return 
    rts
}
  // File Data

