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

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  main::b2#0 = main::b1 + $fa
  main::w#0 = main::b2#0 + 1
  main::$4 = 0 * SIZEOF_UNSIGNED_INT
  main::screen[main::$4] = main::w#0
  main::$2 = main::w#0 > $ff
  main::$3 = ! main::$2
  if(main::$3) goto main::@return
  to:main::@1
main::@1: scope:[main]  from main
  *main::BG_COLOR = main::RED
  to:main::@return
main::@return: scope:[main]  from main main::@1
  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 SIZEOF_UNSIGNED_INT = 2
void __start()
void main()
bool main::$2
bool main::$3
number main::$4
__constant char * const main::BG_COLOR = (char *)$d020
__constant const char main::RED = 2
__constant char main::b1 = $fa
char main::b2
char main::b2#0
__constant unsigned int * const main::screen = (unsigned int *)$400
unsigned int main::w
unsigned int main::w#0

Adding number conversion cast (unumber) $fa in main::b2#0 = main::b1 + $fa
Adding number conversion cast (unumber) 1 in main::w#0 = main::b2#0 + 1
Adding number conversion cast (unumber) 0 in main::$4 = 0 * SIZEOF_UNSIGNED_INT
Adding number conversion cast (unumber) main::$4 in main::$4 = (unumber)0 * SIZEOF_UNSIGNED_INT
Adding number conversion cast (unumber) $ff in main::$2 = main::w#0 > $ff
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (unsigned int *) 1024
Simplifying constant pointer cast (char *) 53280
Simplifying constant integer cast $fa
Simplifying constant integer cast 1
Simplifying constant integer cast 0
Simplifying constant integer cast $ff
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) $fa
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) $ff
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to char in main::$4 = 0 * SIZEOF_UNSIGNED_INT
Inversing boolean not [5] main::$3 = main::w#0 <= $ff from [4] main::$2 = main::w#0 > $ff
Successful SSA optimization Pass2UnaryNotSimplification
Simple Condition main::$3 [5] if(main::w#0<=$ff) goto main::@return
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant right-side identified [0] main::b2#0 = main::b1 + $fa
Constant right-side identified [2] main::$4 = 0 * SIZEOF_UNSIGNED_INT
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::b2#0 = main::b1+$fa
Constant main::$4 = 0*SIZEOF_UNSIGNED_INT
Successful SSA optimization Pass2ConstantIdentification
Simplifying constant evaluating to zero 0*SIZEOF_UNSIGNED_INT in 
Successful SSA optimization PassNSimplifyConstantZero
Simplifying expression containing zero main::screen in [3] main::screen[main::$4] = main::w#0
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant main::$4
Eliminating unused constant SIZEOF_UNSIGNED_INT
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 [0] main::w#0 = main::b2#0 + 1
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::w#0 = main::b2#0+1
Successful SSA optimization Pass2ConstantIdentification
if() condition always false - eliminating [2] if(main::w#0<=$ff) goto main::@return
Successful SSA optimization Pass2ConstantIfs
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::screen = main::w#0
  to:main::@1
main::@1: scope:[main]  from main
  [1] *main::BG_COLOR = main::RED
  to:main::@return
main::@return: scope:[main]  from main::@1
  [2] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
char main::b2
unsigned int main::w

Initial phi equivalence classes
Complete equivalence classes
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] *main::screen = main::w#0 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [1] *main::BG_COLOR = main::RED [ ] (  [ ] { }  ) always clobbers reg byte a 

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

Uplifting [main] best 30 combination 
Uplifting [] best 30 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test inference of number types using a long sum
// Currently fails - because the compiler does not handle byte+byte correctly (not truncating the result to 8 bits)
  // Upstart
  // Commodore 64 PRG executable file
.file [name="number-inference-sum.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: {
    .const RED = 2
    .const b1 = $fa
    .const b2 = b1+$fa
    .const w = b2+1
    .label screen = $400
    .label BG_COLOR = $d020
    // [0] *main::screen = main::w#0 -- _deref_pwuc1=vwuc2 
    lda #<w
    sta screen
    lda #>w
    sta screen+1
    jmp __b1
    // main::@1
  __b1:
    // [1] *main::BG_COLOR = main::RED -- _deref_pbuc1=vbuc2 
    lda #RED
    sta BG_COLOR
    jmp __breturn
    // main::@return
  __breturn:
    // [2] return 
    rts
}
  // File Data

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

FINAL SYMBOL TABLE
void main()
__constant char * const main::BG_COLOR = (char *) 53280
__constant const char main::RED = 2
__constant char main::b1 = $fa
char main::b2
__constant char main::b2#0 = main::b1+$fa // b2
__constant unsigned int * const main::screen = (unsigned int *) 1024
unsigned int main::w
__constant unsigned int main::w#0 = main::b2#0+1 // w



FINAL ASSEMBLER
Score: 24

  // File Comments
// Test inference of number types using a long sum
// Currently fails - because the compiler does not handle byte+byte correctly (not truncating the result to 8 bits)
  // Upstart
  // Commodore 64 PRG executable file
.file [name="number-inference-sum.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: {
    .const RED = 2
    .const b1 = $fa
    .const b2 = b1+$fa
    .const w = b2+1
    .label screen = $400
    .label BG_COLOR = $d020
    // screen[0] = w
    // [0] *main::screen = main::w#0 -- _deref_pwuc1=vwuc2 
    lda #<w
    sta screen
    lda #>w
    sta screen+1
    // main::@1
    // *BG_COLOR = RED
    // [1] *main::BG_COLOR = main::RED -- _deref_pbuc1=vbuc2 
    lda #RED
    sta BG_COLOR
    // main::@return
    // }
    // [2] return 
    rts
}
  // File Data

