Setting inferred volatile on symbol affected by address-of (signed byte*) main::sb_ptr ← (signed byte*)&(byte) main::ub
Setting inferred volatile on symbol affected by address-of (byte*) main::ub_ptr ← (byte*)&(signed byte) main::sb
Identified constant variable (signed byte*) main::sb_ptr
Identified constant variable (byte*) main::ub_ptr

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

(void()) main()
main: scope:[main]  from @1
  (byte) main::ub ← (byte) $ff
  *((const signed byte*) main::sb_ptr) ← (number) 1
  *((const byte*) main::ub_screen) ← (byte) main::ub
  (signed byte) main::sb ← (signed byte)(number) $7f
  *((const byte*) main::ub_ptr) ← (number) 1
  *((const signed byte*) main::sb_screen) ← (signed byte) main::sb
  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()
(label) main::@return
(signed byte) main::sb loadstore
(const signed byte*) main::sb_ptr = (signed byte*)&(byte) main::ub
(const signed byte*) main::sb_screen = (signed byte*)(number) $428
(byte) main::ub loadstore
(const byte*) main::ub_ptr = (byte*)&(signed byte) main::sb
(const byte*) main::ub_screen = (byte*)(number) $400

Adding number conversion cast (snumber) 1 in *((const signed byte*) main::sb_ptr) ← (number) 1
Adding number conversion cast (unumber) 1 in *((const byte*) main::ub_ptr) ← (number) 1
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast *((const signed byte*) main::sb_ptr) ← (snumber)(number) 1
Inlining cast *((const byte*) main::ub_ptr) ← (unumber)(number) 1
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (signed byte*) 1064
Simplifying constant integer cast 1
Simplifying constant integer cast $7f
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized signed number type (signed byte) 1
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
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()

(void()) main()
main: scope:[main]  from @1
  [4] (byte) main::ub ← (byte) $ff
  [5] *((const signed byte*) main::sb_ptr) ← (signed byte) 1
  [6] *((const byte*) main::ub_screen) ← (byte) main::ub
  [7] (signed byte) main::sb ← (signed byte) $7f
  [8] *((const byte*) main::ub_ptr) ← (byte) 1
  [9] *((const signed byte*) main::sb_screen) ← (signed byte) main::sb
  to:main::@return
main::@return: scope:[main]  from main
  [10] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(signed byte) main::sb loadstore 2.0
(byte) main::ub loadstore 2.0

Initial phi equivalence classes
Added variable main::ub to live range equivalence class [ main::ub ]
Added variable main::sb to live range equivalence class [ main::sb ]
Complete equivalence classes
[ main::ub ]
[ main::sb ]
Allocated zp[1]:2 [ main::ub ]
Allocated zp[1]:3 [ main::sb ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // 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 ← (byte) $ff -- vbuz1=vbuc1 
    lda #$ff
    sta.z ub
    // [5] *((const signed byte*) main::sb_ptr) ← (signed byte) 1 -- _deref_pbsc1=vbsc2 
    lda #1
    sta.z sb_ptr
    // [6] *((const byte*) main::ub_screen) ← (byte) main::ub -- _deref_pbuc1=vbuz1 
    lda.z ub
    sta ub_screen
    // [7] (signed byte) main::sb ← (signed byte) $7f -- vbsz1=vbsc1 
    lda #$7f
    sta.z sb
    // [8] *((const byte*) main::ub_ptr) ← (byte) 1 -- _deref_pbuc1=vbuc2 
    lda #1
    sta.z ub_ptr
    // [9] *((const signed byte*) main::sb_screen) ← (signed byte) main::sb -- _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 ← (byte) $ff [ main::ub ] ( main:2 [ main::ub ] ) always clobbers reg byte a 
Statement [5] *((const signed byte*) main::sb_ptr) ← (signed byte) 1 [ main::ub ] ( main:2 [ main::ub ] ) always clobbers reg byte a 
Statement [6] *((const byte*) main::ub_screen) ← (byte) main::ub [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [7] (signed byte) main::sb ← (signed byte) $7f [ main::sb ] ( main:2 [ main::sb ] ) always clobbers reg byte a 
Statement [8] *((const byte*) main::ub_ptr) ← (byte) 1 [ main::sb ] ( main:2 [ main::sb ] ) always clobbers reg byte a 
Statement [9] *((const signed byte*) main::sb_screen) ← (signed byte) main::sb [ ] ( main:2 [ ] ) always clobbers reg byte a 
Potential registers zp[1]:2 [ main::ub ] : zp[1]:2 , 
Potential registers zp[1]:3 [ main::sb ] : zp[1]:3 , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 2: zp[1]:2 [ main::ub ] 2: zp[1]:3 [ main::sb ] 
Uplift Scope [] 

Uplifting [main] best 55 combination zp[1]:2 [ main::ub ] zp[1]:3 [ main::sb ] 
Uplifting [] best 55 combination 
Attempting to uplift remaining variables inzp[1]:2 [ main::ub ]
Uplifting [main] best 55 combination zp[1]:2 [ main::ub ] 
Attempting to uplift remaining variables inzp[1]:3 [ main::sb ]
Uplifting [main] best 55 combination zp[1]:3 [ main::sb ] 

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 ← (byte) $ff -- vbuz1=vbuc1 
    lda #$ff
    sta.z ub
    // [5] *((const signed byte*) main::sb_ptr) ← (signed byte) 1 -- _deref_pbsc1=vbsc2 
    lda #1
    sta.z sb_ptr
    // [6] *((const byte*) main::ub_screen) ← (byte) main::ub -- _deref_pbuc1=vbuz1 
    lda.z ub
    sta ub_screen
    // [7] (signed byte) main::sb ← (signed byte) $7f -- vbsz1=vbsc1 
    lda #$7f
    sta.z sb
    // [8] *((const byte*) main::ub_ptr) ← (byte) 1 -- _deref_pbuc1=vbuc2 
    lda #1
    sta.z ub_ptr
    // [9] *((const signed byte*) main::sb_screen) ← (signed byte) main::sb -- _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
Replacing label __bbegin with __b1
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
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 __b1:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(label) main::@return
(signed byte) main::sb loadstore zp[1]:3 2.0
(const signed byte*) main::sb_ptr = (signed byte*)&(byte) main::ub
(const signed byte*) main::sb_screen = (signed byte*) 1064
(byte) main::ub loadstore zp[1]:2 2.0
(const byte*) main::ub_ptr = (byte*)&(signed byte) main::sb
(const byte*) main::ub_screen = (byte*) 1024

zp[1]:2 [ main::ub ]
zp[1]:3 [ main::sb ]


FINAL ASSEMBLER
Score: 40

  // 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 ← (byte) $ff -- vbuz1=vbuc1 
    lda #$ff
    sta.z ub
    // *sb_ptr = 1
    // [5] *((const signed byte*) main::sb_ptr) ← (signed byte) 1 -- _deref_pbsc1=vbsc2 
    lda #1
    sta.z sb_ptr
    // *ub_screen = ub
    // [6] *((const byte*) main::ub_screen) ← (byte) main::ub -- _deref_pbuc1=vbuz1 
    lda.z ub
    sta ub_screen
    // sb = (signed byte)0x7f
    // [7] (signed byte) main::sb ← (signed byte) $7f -- vbsz1=vbsc1 
    lda #$7f
    sta.z sb
    // *ub_ptr = 1
    // [8] *((const byte*) main::ub_ptr) ← (byte) 1 -- _deref_pbuc1=vbuc2 
    lda #1
    sta.z ub_ptr
    // *sb_screen = sb
    // [9] *((const signed byte*) main::sb_screen) ← (signed byte) main::sb -- _deref_pbsc1=vbsz1 
    lda.z sb
    sta sb_screen
    // main::@return
    // }
    // [10] return 
    rts
}
  // File Data

