Eliminating unused variable with no statement main::$0
Eliminating unused variable with no statement main::$2

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  main::w1#0 = word0  main::dw
  main::$1 = main::dw + 1
  main::w2#0 = word0  main::$1
  main::$3 = byte0  main::w1#0
  SCREEN[0] = main::$3
  main::$4 = byte1  main::w1#0
  SCREEN[1] = main::$4
  main::$5 = byte0  main::w2#0
  SCREEN[3] = main::$5
  main::$6 = byte1  main::w2#0
  SCREEN[4] = main::$6
  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
__constant char * const SCREEN = (char *)$400
void __start()
void main()
number main::$1
char main::$3
char main::$4
char main::$5
char main::$6
__constant unsigned long main::dw = $2000
unsigned int main::w1
unsigned int main::w1#0
unsigned int main::w2
unsigned int main::w2#0

Adding number conversion cast (unumber) 1 in main::$1 = main::dw + 1
Adding number conversion cast (unumber) main::$1 in main::$1 = main::dw + (unumber)1
Adding number conversion cast (unumber) 0 in SCREEN[0] = main::$3
Adding number conversion cast (unumber) 1 in SCREEN[1] = main::$4
Adding number conversion cast (unumber) 3 in SCREEN[3] = main::$5
Adding number conversion cast (unumber) 4 in SCREEN[4] = main::$6
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 1
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 3
Simplifying constant integer cast 4
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 3
Finalized unsigned number type (char) 4
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to unsigned long in main::$1 = main::dw + 1
Constant right-side identified [0] main::w1#0 = word0  main::dw
Constant right-side identified [1] main::$1 = main::dw + 1
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::w1#0 = word0 main::dw
Constant main::$1 = main::dw+1
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero SCREEN in [4] SCREEN[0] = main::$3
Successful SSA optimization PassNSimplifyExpressionWithZero
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 [0] main::w2#0 = word0  main::$1
Constant right-side identified [1] main::$3 = byte0  main::w1#0
Constant right-side identified [3] main::$4 = byte1  main::w1#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::w2#0 = word0 main::$1
Constant main::$3 = byte0 main::w1#0
Constant main::$4 = byte1 main::w1#0
Successful SSA optimization Pass2ConstantIdentification
Simplifying constant evaluating to zero byte0 main::w1#0 in 
Successful SSA optimization PassNSimplifyConstantZero
Constant right-side identified [2] main::$5 = byte0  main::w2#0
Constant right-side identified [4] main::$6 = byte1  main::w2#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::$5 = byte0 main::w2#0
Constant main::$6 = byte1 main::w2#0
Successful SSA optimization Pass2ConstantIdentification
Constant inlined main::$5 = byte0 main::w2#0
Constant inlined main::$6 = byte1 main::w2#0
Constant inlined main::$3 = 0
Constant inlined main::$4 = byte1 main::w1#0
Constant inlined main::$1 = main::dw+1
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(SCREEN+1)
Consolidated array index constant in *(SCREEN+3)
Consolidated array index constant in *(SCREEN+4)
Successful SSA optimization Pass2ConstantAdditionElimination
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] *SCREEN = 0
  [1] *(SCREEN+1) = byte1 main::w1#0
  [2] *(SCREEN+3) = byte0 main::w2#0
  [3] *(SCREEN+4) = byte1 main::w2#0
  to:main::@return
main::@return: scope:[main]  from main
  [4] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
unsigned int main::w1
unsigned int main::w2

Initial phi equivalence classes
Complete equivalence classes
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] *SCREEN = 0 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [1] *(SCREEN+1) = byte1 main::w1#0 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [2] *(SCREEN+3) = byte0 main::w2#0 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [3] *(SCREEN+4) = byte1 main::w2#0 [ ] (  [ ] { }  ) always clobbers reg byte a 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 
Uplift Scope [] 

Uplifting [main] best 33 combination 
Uplifting [] best 33 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Illustrates problem with constant evaluation of lo/hi-operator
// $20000 /$400 results in a byte value - confusing the lo/hi-evaluation
// which currently relies on getting the type from the literal value.
// A fix could be adding support for "declared" types for constant literal values
// - enabling the lo/hi to know that their operand is a word (from the cast).
  // Upstart
  // Commodore 64 PRG executable file
.file [name="operator-lohi-problem.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
  .label SCREEN = $400
.segment Code
  // main
main: {
    .const dw = $2000
    .const w1 = dw&$ffff
    .const w2 = dw+1&$ffff
    // [0] *SCREEN = 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta SCREEN
    // [1] *(SCREEN+1) = byte1 main::w1#0 -- _deref_pbuc1=vbuc2 
    lda #>w1
    sta SCREEN+1
    // [2] *(SCREEN+3) = byte0 main::w2#0 -- _deref_pbuc1=vbuc2 
    lda #<w2
    sta SCREEN+3
    // [3] *(SCREEN+4) = byte1 main::w2#0 -- _deref_pbuc1=vbuc2 
    lda #>w2
    sta SCREEN+4
    jmp __breturn
    // main::@return
  __breturn:
    // [4] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
__constant char * const SCREEN = (char *) 1024
void main()
__constant unsigned long main::dw = $2000
unsigned int main::w1
__constant unsigned int main::w1#0 = word0 main::dw // w1
unsigned int main::w2
__constant unsigned int main::w2#0 = word0 main::dw+1 // w2



FINAL ASSEMBLER
Score: 30

  // File Comments
// Illustrates problem with constant evaluation of lo/hi-operator
// $20000 /$400 results in a byte value - confusing the lo/hi-evaluation
// which currently relies on getting the type from the literal value.
// A fix could be adding support for "declared" types for constant literal values
// - enabling the lo/hi to know that their operand is a word (from the cast).
  // Upstart
  // Commodore 64 PRG executable file
.file [name="operator-lohi-problem.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
  .label SCREEN = $400
.segment Code
  // main
main: {
    .const dw = $2000
    .const w1 = dw&$ffff
    .const w2 = dw+1&$ffff
    // SCREEN[0] = BYTE0(w1)
    // [0] *SCREEN = 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta SCREEN
    // SCREEN[1] = BYTE1(w1)
    // [1] *(SCREEN+1) = byte1 main::w1#0 -- _deref_pbuc1=vbuc2 
    lda #>w1
    sta SCREEN+1
    // SCREEN[3] = BYTE0(w2)
    // [2] *(SCREEN+3) = byte0 main::w2#0 -- _deref_pbuc1=vbuc2 
    lda #<w2
    sta SCREEN+3
    // SCREEN[4] = BYTE1(w2)
    // [3] *(SCREEN+4) = byte1 main::w2#0 -- _deref_pbuc1=vbuc2 
    lda #>w2
    sta SCREEN+4
    // main::@return
    // }
    // [4] return 
    rts
}
  // File Data

