
CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  main::bu = 7
  main::bs = 7
  main::wu = $4e20
  main::ws = -$b1
  main::du = $1e8480
  main::ds = -$39a4f1
  main::ptr = (char *)0
  main::i#0 = 0
  main::SCREEN[main::i#0] = byte1 $11
  main::i#1 = ++ main::i#0
  main::SCREEN[main::i#1] = byte1 $179
  main::i#2 = ++ main::i#1
  main::$0 = byte1  main::bu
  main::SCREEN[main::i#2] = main::$0
  main::i#3 = ++ main::i#2
  main::$1 = byte1  main::bs
  main::SCREEN[main::i#3] = main::$1
  main::i#4 = ++ main::i#3
  main::$2 = byte1  main::wu
  main::SCREEN[main::i#4] = main::$2
  main::i#5 = ++ main::i#4
  main::$3 = byte1  main::ws
  main::SCREEN[main::i#5] = main::$3
  main::i#6 = ++ main::i#5
  main::$4 = byte1  main::du
  main::SCREEN[main::i#6] = main::$4
  main::i#7 = ++ main::i#6
  main::$5 = byte1  main::ds
  main::SCREEN[main::i#7] = main::$5
  main::i#8 = ++ main::i#7
  main::$6 = byte1  main::ptr
  main::SCREEN[main::i#8] = main::$6
  main::i#9 = ++ main::i#8
  to:main::@return
main::@return: scope:[main]  from main
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  call main
  to:__start::@1
__start::@1: scope:[__start]  from __start
  to:__start::@return
__start::@return: scope:[__start]  from __start::@1
  return 
  to:@return

SYMBOL TABLE SSA
void __start()
void main()
char main::$0
char main::$1
char main::$2
char main::$3
char main::$4
char main::$5
char main::$6
__constant char * const main::SCREEN = (char *)$400
__loadstore volatile signed char main::bs
__loadstore volatile char main::bu
__loadstore volatile long main::ds
__loadstore volatile unsigned long main::du
char main::i
char main::i#0
char main::i#1
char main::i#2
char main::i#3
char main::i#4
char main::i#5
char main::i#6
char main::i#7
char main::i#8
char main::i#9
__loadstore char * volatile main::ptr
__loadstore volatile int main::ws
__loadstore volatile unsigned int main::wu

Simplifying constant pointer cast (char *) 1024
Simplifying constant pointer cast (char *) 0
Successful SSA optimization PassNCastSimplification
Constant right-side identified [12] main::$0 = byte1  main::bu
Constant right-side identified [15] main::$1 = byte1  main::bs
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::i#0 = 0
Constant main::$0 = 0
Constant main::$1 = 0
Successful SSA optimization Pass2ConstantIdentification
Simplifying constant evaluating to zero byte1 $11 in [8] main::SCREEN[main::i#0] = byte1 $11
Successful SSA optimization PassNSimplifyConstantZero
Simplifying expression containing zero main::SCREEN in [8] main::SCREEN[main::i#0] = 0
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable main::bu and assignment [0] main::bu = 7
Eliminating unused variable main::bs and assignment [1] main::bs = 7
Eliminating unused variable main::i#9 and assignment [29] main::i#9 = ++ main::i#8
Successful SSA optimization PassNEliminateUnusedVars
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::@1
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Constant right-side identified [6] main::i#1 = ++ main::i#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::i#1 = ++main::i#0
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [7] main::i#2 = ++ main::i#1
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::i#2 = ++main::i#1
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [8] main::i#3 = ++ main::i#2
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::i#3 = ++main::i#2
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [9] main::i#4 = ++ main::i#3
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::i#4 = ++main::i#3
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [11] main::i#5 = ++ main::i#4
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::i#5 = ++main::i#4
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [13] main::i#6 = ++ main::i#5
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::i#6 = ++main::i#5
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [15] main::i#7 = ++ main::i#6
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::i#7 = ++main::i#6
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [17] main::i#8 = ++ main::i#7
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::i#8 = ++main::i#7
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with different constant siblings main::i#0
Inlining constant with different constant siblings main::i#1
Inlining constant with different constant siblings main::i#2
Inlining constant with different constant siblings main::i#3
Inlining constant with different constant siblings main::i#4
Inlining constant with different constant siblings main::i#5
Inlining constant with different constant siblings main::i#6
Inlining constant with different constant siblings main::i#7
Inlining constant with different constant siblings main::i#8
Constant inlined main::i#8 = ++++++++++++++++0
Constant inlined main::i#7 = ++++++++++++++0
Constant inlined main::$1 = 0
Constant inlined main::i#4 = ++++++++0
Constant inlined main::i#3 = ++++++0
Constant inlined main::i#6 = ++++++++++++0
Constant inlined main::$0 = 0
Constant inlined main::i#5 = ++++++++++0
Constant inlined main::i#0 = 0
Constant inlined main::i#2 = ++++0
Constant inlined main::i#1 = ++0
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(main::SCREEN+++0)
Consolidated array index constant in *(main::SCREEN+++++0)
Consolidated array index constant in *(main::SCREEN+++++++0)
Consolidated array index constant in *(main::SCREEN+++++++++0)
Consolidated array index constant in *(main::SCREEN+++++++++++0)
Consolidated array index constant in *(main::SCREEN+++++++++++++0)
Consolidated array index constant in *(main::SCREEN+++++++++++++++0)
Consolidated array index constant in *(main::SCREEN+++++++++++++++++0)
Successful SSA optimization Pass2ConstantAdditionElimination
Simplifying constant integer increment ++0
Simplifying constant integer increment ++0
Simplifying constant integer increment ++1
Simplifying constant integer increment ++2
Simplifying constant integer increment ++3
Simplifying constant integer increment ++4
Simplifying constant integer increment ++5
Simplifying constant integer increment ++6
Successful SSA optimization Pass2ConstantSimplification
Simplifying constant integer increment ++1
Simplifying constant integer increment ++2
Simplifying constant integer increment ++3
Simplifying constant integer increment ++4
Simplifying constant integer increment ++5
Simplifying constant integer increment ++6
Simplifying constant integer increment ++7
Successful SSA optimization Pass2ConstantSimplification
Finalized unsigned number type (unsigned int) $179
Successful SSA optimization PassNFinalizeNumberTypeConversions
CALL GRAPH

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] main::wu = $4e20
  [1] main::ws = -$b1
  [2] main::du = $1e8480
  [3] main::ds = -$39a4f1
  [4] main::ptr = (char *) 0
  [5] *main::SCREEN = 0
  [6] *(main::SCREEN+1) = byte1 $179
  [7] *(main::SCREEN+2) = 0
  [8] *(main::SCREEN+3) = 0
  [9] main::$2 = byte1  main::wu
  [10] *(main::SCREEN+4) = main::$2
  [11] main::$3 = byte1  main::ws
  [12] *(main::SCREEN+5) = main::$3
  [13] main::$4 = byte1  main::du
  [14] *(main::SCREEN+6) = main::$4
  [15] main::$5 = byte1  main::ds
  [16] *(main::SCREEN+7) = main::$5
  [17] main::$6 = byte1  main::ptr
  [18] *(main::SCREEN+8) = main::$6
  to:main::@return
main::@return: scope:[main]  from main
  [19] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
char main::$2 // 4.0
char main::$3 // 4.0
char main::$4 // 4.0
char main::$5 // 4.0
char main::$6 // 4.0
__loadstore volatile long main::ds // 0.3333333333333333
__loadstore volatile unsigned long main::du // 0.36363636363636365
char main::i
__loadstore char * volatile main::ptr // 0.3076923076923077
__loadstore volatile int main::ws // 0.4
__loadstore volatile unsigned int main::wu // 0.4444444444444444

Initial phi equivalence classes
Added variable main::wu to live range equivalence class [ main::wu ]
Added variable main::ws to live range equivalence class [ main::ws ]
Added variable main::du to live range equivalence class [ main::du ]
Added variable main::ds to live range equivalence class [ main::ds ]
Added variable main::ptr to live range equivalence class [ main::ptr ]
Added variable main::$2 to live range equivalence class [ main::$2 ]
Added variable main::$3 to live range equivalence class [ main::$3 ]
Added variable main::$4 to live range equivalence class [ main::$4 ]
Added variable main::$5 to live range equivalence class [ main::$5 ]
Added variable main::$6 to live range equivalence class [ main::$6 ]
Complete equivalence classes
[ main::wu ]
[ main::ws ]
[ main::du ]
[ main::ds ]
[ main::ptr ]
[ main::$2 ]
[ main::$3 ]
[ main::$4 ]
[ main::$5 ]
[ main::$6 ]
Allocated zp[1]:2 [ main::$2 ]
Allocated zp[1]:3 [ main::$3 ]
Allocated zp[1]:4 [ main::$4 ]
Allocated zp[1]:5 [ main::$5 ]
Allocated zp[1]:6 [ main::$6 ]
Allocated zp[2]:7 [ main::wu ]
Allocated zp[2]:9 [ main::ws ]
Allocated zp[4]:11 [ main::du ]
Allocated zp[4]:15 [ main::ds ]
Allocated zp[2]:19 [ main::ptr ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] main::wu = $4e20 [ main::wu ] (  [ main::wu ] { }  ) always clobbers reg byte a 
Statement [1] main::ws = -$b1 [ main::wu main::ws ] (  [ main::wu main::ws ] { }  ) always clobbers reg byte a 
Statement [2] main::du = $1e8480 [ main::wu main::ws main::du ] (  [ main::wu main::ws main::du ] { }  ) always clobbers reg byte a 
Statement [3] main::ds = -$39a4f1 [ main::wu main::ws main::du main::ds ] (  [ main::wu main::ws main::du main::ds ] { }  ) always clobbers reg byte a 
Statement [4] main::ptr = (char *) 0 [ main::wu main::ws main::du main::ds main::ptr ] (  [ main::wu main::ws main::du main::ds main::ptr ] { }  ) always clobbers reg byte a 
Statement [5] *main::SCREEN = 0 [ main::wu main::ws main::du main::ds main::ptr ] (  [ main::wu main::ws main::du main::ds main::ptr ] { }  ) always clobbers reg byte a 
Statement [6] *(main::SCREEN+1) = byte1 $179 [ main::wu main::ws main::du main::ds main::ptr ] (  [ main::wu main::ws main::du main::ds main::ptr ] { }  ) always clobbers reg byte a 
Statement [7] *(main::SCREEN+2) = 0 [ main::wu main::ws main::du main::ds main::ptr ] (  [ main::wu main::ws main::du main::ds main::ptr ] { }  ) always clobbers reg byte a 
Statement [8] *(main::SCREEN+3) = 0 [ main::wu main::ws main::du main::ds main::ptr ] (  [ main::wu main::ws main::du main::ds main::ptr ] { }  ) always clobbers reg byte a 
Potential registers zp[2]:7 [ main::wu ] : zp[2]:7 , 
Potential registers zp[2]:9 [ main::ws ] : zp[2]:9 , 
Potential registers zp[4]:11 [ main::du ] : zp[4]:11 , 
Potential registers zp[4]:15 [ main::ds ] : zp[4]:15 , 
Potential registers zp[2]:19 [ main::ptr ] : zp[2]:19 , 
Potential registers zp[1]:2 [ main::$2 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ main::$3 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:4 [ main::$4 ] : zp[1]:4 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:5 [ main::$5 ] : zp[1]:5 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:6 [ main::$6 ] : zp[1]:6 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 4: zp[1]:2 [ main::$2 ] 4: zp[1]:3 [ main::$3 ] 4: zp[1]:4 [ main::$4 ] 4: zp[1]:5 [ main::$5 ] 4: zp[1]:6 [ main::$6 ] 0.44: zp[2]:7 [ main::wu ] 0.4: zp[2]:9 [ main::ws ] 0.36: zp[4]:11 [ main::du ] 0.33: zp[4]:15 [ main::ds ] 0.31: zp[2]:19 [ main::ptr ] 
Uplift Scope [] 

Uplifting [main] best 144 combination reg byte a [ main::$2 ] reg byte a [ main::$3 ] reg byte a [ main::$4 ] reg byte a [ main::$5 ] zp[1]:6 [ main::$6 ] zp[2]:7 [ main::wu ] zp[2]:9 [ main::ws ] zp[4]:11 [ main::du ] zp[4]:15 [ main::ds ] zp[2]:19 [ main::ptr ] 
Limited combination testing to 100 combinations of 1024 possible.
Uplifting [] best 144 combination 
Attempting to uplift remaining variables inzp[1]:6 [ main::$6 ]
Uplifting [main] best 138 combination reg byte a [ main::$6 ] 
Allocated (was zp[2]:7) zp[2]:2 [ main::wu ]
Allocated (was zp[2]:9) zp[2]:4 [ main::ws ]
Allocated (was zp[4]:11) zp[4]:6 [ main::du ]
Allocated (was zp[4]:15) zp[4]:10 [ main::ds ]
Allocated (was zp[2]:19) zp[2]:14 [ main::ptr ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test operator BYTE1()
  // Upstart
  // Commodore 64 PRG executable file
.file [name="operator-byte1.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
  // Global Constants & labels
.segment Code
  // main
main: {
    .label SCREEN = $400
    .label wu = 2
    .label ws = 4
    .label du = 6
    .label ds = $a
    .label ptr = $e
    // [0] main::wu = $4e20 -- vwuz1=vwuc1 
    lda #<$4e20
    sta.z wu
    lda #>$4e20
    sta.z wu+1
    // [1] main::ws = -$b1 -- vwsz1=vwsc1 
    lda #<-$b1
    sta.z ws
    lda #>-$b1
    sta.z ws+1
    // [2] main::du = $1e8480 -- vduz1=vduc1 
    lda #<$1e8480
    sta.z du
    lda #>$1e8480
    sta.z du+1
    lda #<$1e8480>>$10
    sta.z du+2
    lda #>$1e8480>>$10
    sta.z du+3
    // [3] main::ds = -$39a4f1 -- vdsz1=vdsc1 
    lda #<-$39a4f1
    sta.z ds
    lda #>-$39a4f1
    sta.z ds+1
    lda #<-$39a4f1>>$10
    sta.z ds+2
    lda #>-$39a4f1>>$10
    sta.z ds+3
    // [4] main::ptr = (char *) 0 -- pbuz1=pbuc1 
    lda #<0
    sta.z ptr
    lda #>0
    sta.z ptr+1
    // [5] *main::SCREEN = 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta SCREEN
    // [6] *(main::SCREEN+1) = byte1 $179 -- _deref_pbuc1=vbuc2 
    lda #>$179
    sta SCREEN+1
    // [7] *(main::SCREEN+2) = 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta SCREEN+2
    // [8] *(main::SCREEN+3) = 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta SCREEN+3
    // [9] main::$2 = byte1  main::wu -- vbuaa=_byte1_vwuz1 
    lda.z wu+1
    // [10] *(main::SCREEN+4) = main::$2 -- _deref_pbuc1=vbuaa 
    sta SCREEN+4
    // [11] main::$3 = byte1  main::ws -- vbuaa=_byte1_vwsz1 
    lda.z ws+1
    // [12] *(main::SCREEN+5) = main::$3 -- _deref_pbuc1=vbuaa 
    sta SCREEN+5
    // [13] main::$4 = byte1  main::du -- vbuaa=_byte1_vduz1 
    lda.z du+1
    // [14] *(main::SCREEN+6) = main::$4 -- _deref_pbuc1=vbuaa 
    sta SCREEN+6
    // [15] main::$5 = byte1  main::ds -- vbuaa=_byte1_vdsz1 
    lda.z ds+1
    // [16] *(main::SCREEN+7) = main::$5 -- _deref_pbuc1=vbuaa 
    sta SCREEN+7
    // [17] main::$6 = byte1  main::ptr -- vbuaa=_byte1_pbuz1 
    lda.z ptr+1
    // [18] *(main::SCREEN+8) = main::$6 -- _deref_pbuc1=vbuaa 
    sta SCREEN+8
    jmp __breturn
    // main::@return
  __breturn:
    // [19] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda #>0
Removing instruction lda #0
Removing instruction lda #0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
void main()
char main::$2 // reg byte a 4.0
char main::$3 // reg byte a 4.0
char main::$4 // reg byte a 4.0
char main::$5 // reg byte a 4.0
char main::$6 // reg byte a 4.0
__constant char * const main::SCREEN = (char *) 1024
__loadstore volatile long main::ds // zp[4]:10 0.3333333333333333
__loadstore volatile unsigned long main::du // zp[4]:6 0.36363636363636365
char main::i
__loadstore char * volatile main::ptr // zp[2]:14 0.3076923076923077
__loadstore volatile int main::ws // zp[2]:4 0.4
__loadstore volatile unsigned int main::wu // zp[2]:2 0.4444444444444444

zp[2]:2 [ main::wu ]
zp[2]:4 [ main::ws ]
zp[4]:6 [ main::du ]
zp[4]:10 [ main::ds ]
zp[2]:14 [ main::ptr ]
reg byte a [ main::$2 ]
reg byte a [ main::$3 ]
reg byte a [ main::$4 ]
reg byte a [ main::$5 ]
reg byte a [ main::$6 ]


FINAL ASSEMBLER
Score: 129

  // File Comments
// Test operator BYTE1()
  // Upstart
  // Commodore 64 PRG executable file
.file [name="operator-byte1.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
  // Global Constants & labels
.segment Code
  // main
main: {
    .label SCREEN = $400
    .label wu = 2
    .label ws = 4
    .label du = 6
    .label ds = $a
    .label ptr = $e
    // volatile unsigned int wu = 20000
    // [0] main::wu = $4e20 -- vwuz1=vwuc1 
    lda #<$4e20
    sta.z wu
    lda #>$4e20
    sta.z wu+1
    // volatile signed int ws = -177
    // [1] main::ws = -$b1 -- vwsz1=vwsc1 
    lda #<-$b1
    sta.z ws
    lda #>-$b1
    sta.z ws+1
    // volatile unsigned long du = 2000000
    // [2] main::du = $1e8480 -- vduz1=vduc1 
    lda #<$1e8480
    sta.z du
    lda #>$1e8480
    sta.z du+1
    lda #<$1e8480>>$10
    sta.z du+2
    lda #>$1e8480>>$10
    sta.z du+3
    // volatile signed long ds = -3777777
    // [3] main::ds = -$39a4f1 -- vdsz1=vdsc1 
    lda #<-$39a4f1
    sta.z ds
    lda #>-$39a4f1
    sta.z ds+1
    lda #<-$39a4f1>>$10
    sta.z ds+2
    lda #>-$39a4f1>>$10
    sta.z ds+3
    // char * volatile ptr = (char*)0x0000
    // [4] main::ptr = (char *) 0 -- pbuz1=pbuc1 
    lda #<0
    sta.z ptr
    sta.z ptr+1
    // SCREEN[i++] = BYTE1(17)
    // [5] *main::SCREEN = 0 -- _deref_pbuc1=vbuc2 
    sta SCREEN
    // SCREEN[i++] = BYTE1(377)
    // [6] *(main::SCREEN+1) = byte1 $179 -- _deref_pbuc1=vbuc2 
    lda #>$179
    sta SCREEN+1
    // SCREEN[i++] = BYTE1(bu)
    // [7] *(main::SCREEN+2) = 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta SCREEN+2
    // SCREEN[i++] = BYTE1(bs)
    // [8] *(main::SCREEN+3) = 0 -- _deref_pbuc1=vbuc2 
    sta SCREEN+3
    // BYTE1(wu)
    // [9] main::$2 = byte1  main::wu -- vbuaa=_byte1_vwuz1 
    lda.z wu+1
    // SCREEN[i++] = BYTE1(wu)
    // [10] *(main::SCREEN+4) = main::$2 -- _deref_pbuc1=vbuaa 
    sta SCREEN+4
    // BYTE1(ws)
    // [11] main::$3 = byte1  main::ws -- vbuaa=_byte1_vwsz1 
    lda.z ws+1
    // SCREEN[i++] = BYTE1(ws)
    // [12] *(main::SCREEN+5) = main::$3 -- _deref_pbuc1=vbuaa 
    sta SCREEN+5
    // BYTE1(du)
    // [13] main::$4 = byte1  main::du -- vbuaa=_byte1_vduz1 
    lda.z du+1
    // SCREEN[i++] = BYTE1(du)
    // [14] *(main::SCREEN+6) = main::$4 -- _deref_pbuc1=vbuaa 
    sta SCREEN+6
    // BYTE1(ds)
    // [15] main::$5 = byte1  main::ds -- vbuaa=_byte1_vdsz1 
    lda.z ds+1
    // SCREEN[i++] = BYTE1(ds)
    // [16] *(main::SCREEN+7) = main::$5 -- _deref_pbuc1=vbuaa 
    sta SCREEN+7
    // BYTE1(ptr)
    // [17] main::$6 = byte1  main::ptr -- vbuaa=_byte1_pbuz1 
    lda.z ptr+1
    // SCREEN[i++] = BYTE1(ptr)
    // [18] *(main::SCREEN+8) = main::$6 -- _deref_pbuc1=vbuaa 
    sta SCREEN+8
    // main::@return
    // }
    // [19] return 
    rts
}
  // File Data

