Setting inferred volatile on symbol affected by address-of (void~) main::$0 ← call setscreen &(byte*) screen (byte*) screen1 
Setting inferred volatile on symbol affected by address-of (void~) main::$1 ← call setscreen &(byte*) screen (byte*) screen2 
Identified constant variable (byte*) screen1
Identified constant variable (byte*) screen2
Culled Empty Block (label) @1

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) screen ← (byte*)(number) $400
  to:@2

(void()) main()
main: scope:[main]  from @2
  (byte**) setscreen::screen#0 ← &(byte*) screen
  (byte*) setscreen::val#0 ← (const byte*) screen1
  call setscreen 
  to:main::@1
main::@1: scope:[main]  from main
  *((byte*) screen + (number) 0) ← (byte) 'a'
  (byte**) setscreen::screen#1 ← &(byte*) screen
  (byte*) setscreen::val#1 ← (const byte*) screen2
  call setscreen 
  to:main::@2
main::@2: scope:[main]  from main::@1
  *((byte*) screen + (number) 0) ← (byte) 'a'
  to:main::@return
main::@return: scope:[main]  from main::@2
  return 
  to:@return

(void()) setscreen((byte**) setscreen::screen , (byte*) setscreen::val)
setscreen: scope:[setscreen]  from main main::@1
  (byte**) setscreen::screen#2 ← phi( main/(byte**) setscreen::screen#0 main::@1/(byte**) setscreen::screen#1 )
  (byte*) setscreen::val#2 ← phi( main/(byte*) setscreen::val#0 main::@1/(byte*) setscreen::val#1 )
  *((byte**) setscreen::screen#2) ← (byte*) setscreen::val#2
  to:setscreen::@return
setscreen::@return: scope:[setscreen]  from setscreen
  return 
  to:@return
@2: scope:[]  from @begin
  call main 
  to:@3
@3: scope:[]  from @2
  to:@end
@end: scope:[]  from @3

SYMBOL TABLE SSA
(label) @2
(label) @3
(label) @begin
(label) @end
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(byte*) screen loadstore
(const byte*) screen1 = (byte*)(number) $400
(const byte*) screen2 = (byte*)(number) $400+(number) $28
(void()) setscreen((byte**) setscreen::screen , (byte*) setscreen::val)
(label) setscreen::@return
(byte**) setscreen::screen
(byte**) setscreen::screen#0
(byte**) setscreen::screen#1
(byte**) setscreen::screen#2
(byte*) setscreen::val
(byte*) setscreen::val#0
(byte*) setscreen::val#1
(byte*) setscreen::val#2

Adding number conversion cast (unumber) 0 in *((byte*) screen + (number) 0) ← (byte) 'a'
Adding number conversion cast (unumber) 0 in *((byte*) screen + (number) 0) ← (byte) 'a'
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant (const byte**) setscreen::screen#0 = &screen
Constant (const byte*) setscreen::val#0 = screen1
Constant (const byte**) setscreen::screen#1 = &screen
Constant (const byte*) setscreen::val#1 = screen2
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero screen in [4] *((byte*) screen + (byte) 0) ← (byte) 'a'
Simplifying expression containing zero screen in [8] *((byte*) screen + (byte) 0) ← (byte) 'a'
Successful SSA optimization PassNSimplifyExpressionWithZero
Inlining constant with var siblings (const byte**) setscreen::screen#0
Inlining constant with var siblings (const byte*) setscreen::val#0
Inlining constant with var siblings (const byte**) setscreen::screen#1
Inlining constant with var siblings (const byte*) setscreen::val#1
Constant inlined setscreen::screen#0 = &(byte*) screen
Constant inlined setscreen::val#1 = (const byte*) screen2
Constant inlined setscreen::screen#1 = &(byte*) screen
Constant inlined setscreen::val#0 = (const byte*) screen1
Successful SSA optimization Pass2ConstantInlining
Identical Phi Values (byte**) setscreen::screen#2 &(byte*) screen
Successful SSA optimization Pass2IdenticalPhiElimination
Adding NOP phi() at start of @2
Adding NOP phi() at start of @3
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to setscreen:6 setscreen:8 

Created 1 initial phi equivalence classes
Coalesced down to 1 phi equivalence classes
Culled Empty Block (label) @3
Renumbering block @2 to @1
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] (byte*) screen ← (byte*) 1024
  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()
  [5] call setscreen 
  to:main::@1
main::@1: scope:[main]  from main
  [6] *((byte*) screen) ← (byte) 'a'
  [7] call setscreen 
  to:main::@2
main::@2: scope:[main]  from main::@1
  [8] *((byte*) screen) ← (byte) 'a'
  to:main::@return
main::@return: scope:[main]  from main::@2
  [9] return 
  to:@return

(void()) setscreen((byte**) setscreen::screen , (byte*) setscreen::val)
setscreen: scope:[setscreen]  from main main::@1
  [10] (byte*) setscreen::val#2 ← phi( main/(const byte*) screen1 main::@1/(const byte*) screen2 )
  [11] *(&(byte*) screen) ← (byte*) setscreen::val#2
  to:setscreen::@return
setscreen::@return: scope:[setscreen]  from setscreen
  [12] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(byte*) screen loadstore 0.6666666666666666
(void()) setscreen((byte**) setscreen::screen , (byte*) setscreen::val)
(byte**) setscreen::screen
(byte*) setscreen::val
(byte*) setscreen::val#2 2.0

Initial phi equivalence classes
[ setscreen::val#2 ]
Added variable screen to live range equivalence class [ screen ]
Complete equivalence classes
[ setscreen::val#2 ]
[ screen ]
Allocated zp[2]:2 [ setscreen::val#2 ]
Allocated zp[2]:4 [ screen ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// Tests pointer to pointer in a more complex setup
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label screen1 = $400
  .label screen2 = $400+$28
  .label screen = 4
  // @begin
__bbegin:
  // [0] (byte*) screen ← (byte*) 1024 -- pbuz1=pbuc1 
  lda #<$400
  sta.z screen
  lda #>$400
  sta.z screen+1
  // [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: {
    // [5] call setscreen 
    // [10] phi from main to setscreen [phi:main->setscreen]
  setscreen_from_main:
    // [10] phi (byte*) setscreen::val#2 = (const byte*) screen1 [phi:main->setscreen#0] -- pbuz1=pbuc1 
    lda #<screen1
    sta.z setscreen.val
    lda #>screen1
    sta.z setscreen.val+1
    jsr setscreen
    jmp __b1
    // main::@1
  __b1:
    // [6] *((byte*) screen) ← (byte) 'a' -- _deref_pbuz1=vbuc1 
    lda #'a'
    ldy #0
    sta (screen),y
    // [7] call setscreen 
    // [10] phi from main::@1 to setscreen [phi:main::@1->setscreen]
  setscreen_from___b1:
    // [10] phi (byte*) setscreen::val#2 = (const byte*) screen2 [phi:main::@1->setscreen#0] -- pbuz1=pbuc1 
    lda #<screen2
    sta.z setscreen.val
    lda #>screen2
    sta.z setscreen.val+1
    jsr setscreen
    jmp __b2
    // main::@2
  __b2:
    // [8] *((byte*) screen) ← (byte) 'a' -- _deref_pbuz1=vbuc1 
    lda #'a'
    ldy #0
    sta (screen),y
    jmp __breturn
    // main::@return
  __breturn:
    // [9] return 
    rts
}
  // setscreen
// setscreen(byte* zp(2) val)
setscreen: {
    .label val = 2
    // [11] *(&(byte*) screen) ← (byte*) setscreen::val#2 -- _deref_pptc1=pbuz1 
    lda.z val
    sta.z screen
    lda.z val+1
    sta.z screen+1
    jmp __breturn
    // setscreen::@return
  __breturn:
    // [12] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] (byte*) screen ← (byte*) 1024 [ screen ] (  [ screen ] ) always clobbers reg byte a 
Statement [6] *((byte*) screen) ← (byte) 'a' [ screen ] ( main:2 [ screen ] ) always clobbers reg byte a reg byte y 
Statement [8] *((byte*) screen) ← (byte) 'a' [ ] ( main:2 [ ] ) always clobbers reg byte a reg byte y 
Statement [11] *(&(byte*) screen) ← (byte*) setscreen::val#2 [ screen ] ( main:2::setscreen:5 [ screen ] main:2::setscreen:7 [ screen ] ) always clobbers reg byte a 
Potential registers zp[2]:2 [ setscreen::val#2 ] : zp[2]:2 , 
Potential registers zp[2]:4 [ screen ] : zp[2]:4 , 

REGISTER UPLIFT SCOPES
Uplift Scope [setscreen] 2: zp[2]:2 [ setscreen::val#2 ] 
Uplift Scope [] 0.67: zp[2]:4 [ screen ] 
Uplift Scope [main] 

Uplifting [setscreen] best 110 combination zp[2]:2 [ setscreen::val#2 ] 
Uplifting [] best 110 combination zp[2]:4 [ screen ] 
Uplifting [main] best 110 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests pointer to pointer in a more complex setup
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label screen1 = $400
  .label screen2 = $400+$28
  .label screen = 4
  // @begin
__bbegin:
  // [0] (byte*) screen ← (byte*) 1024 -- pbuz1=pbuc1 
  lda #<$400
  sta.z screen
  lda #>$400
  sta.z screen+1
  // [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: {
    // [5] call setscreen 
    // [10] phi from main to setscreen [phi:main->setscreen]
  setscreen_from_main:
    // [10] phi (byte*) setscreen::val#2 = (const byte*) screen1 [phi:main->setscreen#0] -- pbuz1=pbuc1 
    lda #<screen1
    sta.z setscreen.val
    lda #>screen1
    sta.z setscreen.val+1
    jsr setscreen
    jmp __b1
    // main::@1
  __b1:
    // [6] *((byte*) screen) ← (byte) 'a' -- _deref_pbuz1=vbuc1 
    lda #'a'
    ldy #0
    sta (screen),y
    // [7] call setscreen 
    // [10] phi from main::@1 to setscreen [phi:main::@1->setscreen]
  setscreen_from___b1:
    // [10] phi (byte*) setscreen::val#2 = (const byte*) screen2 [phi:main::@1->setscreen#0] -- pbuz1=pbuc1 
    lda #<screen2
    sta.z setscreen.val
    lda #>screen2
    sta.z setscreen.val+1
    jsr setscreen
    jmp __b2
    // main::@2
  __b2:
    // [8] *((byte*) screen) ← (byte) 'a' -- _deref_pbuz1=vbuc1 
    lda #'a'
    ldy #0
    sta (screen),y
    jmp __breturn
    // main::@return
  __breturn:
    // [9] return 
    rts
}
  // setscreen
// setscreen(byte* zp(2) val)
setscreen: {
    .label val = 2
    // [11] *(&(byte*) screen) ← (byte*) setscreen::val#2 -- _deref_pptc1=pbuz1 
    lda.z val
    sta.z screen
    lda.z val+1
    sta.z screen+1
    jmp __breturn
    // setscreen::@return
  __breturn:
    // [12] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1:
Removing instruction __bend:
Removing instruction setscreen_from_main:
Removing instruction __b1:
Removing instruction setscreen_from___b1:
Removing instruction __b2:
Removing instruction __breturn:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Adding RTS to root block 
Succesful ASM optimization Pass5AddMainRts

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(byte*) screen loadstore zp[2]:4 0.6666666666666666
(const byte*) screen1 = (byte*) 1024
(const byte*) screen2 = (byte*)(number) $400+(number) $28
(void()) setscreen((byte**) setscreen::screen , (byte*) setscreen::val)
(label) setscreen::@return
(byte**) setscreen::screen
(byte*) setscreen::val
(byte*) setscreen::val#2 val zp[2]:2 2.0

zp[2]:2 [ setscreen::val#2 ]
zp[2]:4 [ screen ]


FINAL ASSEMBLER
Score: 98

  // File Comments
// Tests pointer to pointer in a more complex setup
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label screen1 = $400
  .label screen2 = $400+$28
  .label screen = 4
  // @begin
__bbegin:
  // screen = $400
  // [0] (byte*) screen ← (byte*) 1024 -- pbuz1=pbuc1 
  lda #<$400
  sta.z screen
  lda #>$400
  sta.z screen+1
  // [1] phi from @begin to @1 [phi:@begin->@1]
  // @1
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
  jsr main
  rts
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    // setscreen(&screen, screen1)
    // [5] call setscreen 
    // [10] phi from main to setscreen [phi:main->setscreen]
    // [10] phi (byte*) setscreen::val#2 = (const byte*) screen1 [phi:main->setscreen#0] -- pbuz1=pbuc1 
    lda #<screen1
    sta.z setscreen.val
    lda #>screen1
    sta.z setscreen.val+1
    jsr setscreen
    // main::@1
    // screen[0] = 'a'
    // [6] *((byte*) screen) ← (byte) 'a' -- _deref_pbuz1=vbuc1 
    lda #'a'
    ldy #0
    sta (screen),y
    // setscreen(&screen, screen2)
    // [7] call setscreen 
    // [10] phi from main::@1 to setscreen [phi:main::@1->setscreen]
    // [10] phi (byte*) setscreen::val#2 = (const byte*) screen2 [phi:main::@1->setscreen#0] -- pbuz1=pbuc1 
    lda #<screen2
    sta.z setscreen.val
    lda #>screen2
    sta.z setscreen.val+1
    jsr setscreen
    // main::@2
    // screen[0] = 'a'
    // [8] *((byte*) screen) ← (byte) 'a' -- _deref_pbuz1=vbuc1 
    lda #'a'
    ldy #0
    sta (screen),y
    // main::@return
    // }
    // [9] return 
    rts
}
  // setscreen
// setscreen(byte* zp(2) val)
setscreen: {
    .label val = 2
    // *screen = val
    // [11] *(&(byte*) screen) ← (byte*) setscreen::val#2 -- _deref_pptc1=pbuz1 
    lda.z val
    sta.z screen
    lda.z val+1
    sta.z screen+1
    // setscreen::@return
    // }
    // [12] return 
    rts
}
  // File Data

