Identified constant variable (byte) main::b
Identified constant variable (byte*) main::pos
Identified constant variable (byte*) main::bgcol
Culled Empty Block (label) main::@2
Culled Empty Block (label) main::@4

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

(void()) main()
main: scope:[main]  from @1
  (word) main::w#0 ← (word){ (const byte) main::b, (byte) 0 }
  (word~) main::$0 ← ((word)) { (number) 1, (number) 1 }
  (word~) main::$1 ← (word~) main::$0 + (word) main::w#0
  (word~) main::$2 ← ((word)) { (number) 0, (number) 0 }
  (word~) main::$3 ← (word~) main::$1 + (word~) main::$2
  (word) main::w2#0 ← (word~) main::$3
  (byte*) main::sc#0 ← ((byte*)) (word) main::w2#0
  *((byte*) main::sc#0) ← *((const byte*) main::bs + (number) 1)
  (bool~) main::$4 ← *((const byte*) main::pos) == (byte) 'm'
  if((bool~) main::$4) goto main::@1
  to:main::@3
main::@1: scope:[main]  from main
  *((const byte*) main::bgcol) ← (number) 5
  to:main::@return
main::@3: scope:[main]  from main
  *((const byte*) main::bgcol) ← (number) 2
  to:main::@return
main::@return: scope:[main]  from main::@1 main::@3
  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()
(word~) main::$0
(word~) main::$1
(word~) main::$2
(word~) main::$3
(bool~) main::$4
(label) main::@1
(label) main::@3
(label) main::@return
(const byte) main::b = (byte) 4
(const byte*) main::bgcol = (byte*)(number) $d021
(const byte*) main::bs[]  = { (byte) 'c', (byte) 'm' }
(const byte*) main::pos = (byte*)(number) $501
(byte*) main::sc
(byte*) main::sc#0
(word) main::w
(word) main::w#0
(word) main::w2
(word) main::w2#0

Fixing inline constructor with main::$5 ← (byte)main::b w= (byte)0
Fixing inline constructor with main::$6 ← (byte)1 w= (byte)1
Fixing inline constructor with main::$7 ← (byte)0 w= (byte)0
Successful SSA optimization Pass2FixInlineConstructors
Adding number conversion cast (unumber) 1 in *((byte*) main::sc#0) ← *((const byte*) main::bs + (number) 1)
Adding number conversion cast (unumber) 5 in *((const byte*) main::bgcol) ← (number) 5
Adding number conversion cast (unumber) 2 in *((const byte*) main::bgcol) ← (number) 2
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) main::sc#0 ← (byte*)(word) main::w2#0
Inlining cast *((const byte*) main::bgcol) ← (unumber)(number) 5
Inlining cast *((const byte*) main::bgcol) ← (unumber)(number) 2
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1281
Simplifying constant pointer cast (byte*) 53281
Simplifying constant integer cast (const byte) main::b
Simplifying constant integer cast (byte) 0
Simplifying constant integer cast 1
Simplifying constant integer cast 1
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 5
Simplifying constant integer cast 2
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 5
Finalized unsigned number type (byte) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (word) main::w#0 = (word~) main::$5 
Alias (word~) main::$0 = (word~) main::$6 
Alias (word~) main::$2 = (word~) main::$7 
Alias (word) main::w2#0 = (word~) main::$3 
Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) main::$4 [12] if(*((const byte*) main::pos)==(byte) 'm') goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant right-side identified [0] (word) main::w#0 ← (const byte) main::b w= (byte) 0
Constant right-side identified [2] (word~) main::$0 ← (byte) 1 w= (byte) 1
Constant right-side identified [5] (word~) main::$2 ← (byte) 0 w= (byte) 0
Successful SSA optimization Pass2ConstantRValueConsolidation
Simplifying constant evaluating to zero (byte) 0*(number) $100+(byte) 0 in [5] (word~) main::$2 ← (byte) 0*(number) $100+(byte) 0
Successful SSA optimization PassNSimplifyConstantZero
Simplifying expression containing zero main::b*$100 in [0] (word) main::w#0 ← (const byte) main::b*(number) $100+(byte) 0
Successful SSA optimization PassNSimplifyExpressionWithZero
Adding number conversion cast (unumber) main::b*$100 in (word) main::w#0 ← (const byte) main::b*(number) $100
Adding number conversion cast (unumber) $100 in (word) main::w#0 ← ((unumber)) (const byte) main::b*(number) $100
Adding number conversion cast (unumber) 1*$100+1 in (word~) main::$0 ← (byte) 1*(number) $100+(byte) 1
Adding number conversion cast (unumber) 1*$100 in (word~) main::$0 ← ((unumber)) (byte) 1*(number) $100+(byte) 1
Adding number conversion cast (unumber) $100 in (word~) main::$0 ← ((unumber)) (unumber)(byte) 1*(number) $100+(byte) 1
Adding number conversion cast (unumber) 0 in (word~) main::$2 ← (number) 0
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (word) main::w#0 ← (unumber)(const byte) main::b*(unumber)(number) $100
Inlining cast (word~) main::$0 ← (unumber)(unumber)(byte) 1*(unumber)(number) $100+(byte) 1
Inlining cast (word~) main::$2 ← (unumber)(number) 0
Successful SSA optimization Pass2InlineCast
Simplifying constant integer cast (const byte) main::b*(unumber)(number) $100
Simplifying constant integer cast $100
Simplifying constant integer cast (unumber)(byte) 1*(unumber)(number) $100+(byte) 1
Simplifying constant integer cast (byte) 1*(unumber)(number) $100
Simplifying constant integer cast $100
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (word) $100
Finalized unsigned number type (word) $100
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant (const word) main::w#0 = main::b*$100
Constant (const word) main::$0 = 1*$100+1
Constant (const word) main::$2 = 0
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero main::$1 in [4] (word) main::w2#0 ← (word~) main::$1 + (const word) main::$2
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant (const word) main::$2
Successful SSA optimization PassNEliminateUnusedVars
Alias (word) main::w2#0 = (word~) main::$1 
Successful SSA optimization Pass2AliasElimination
Constant right-side identified [0] (word) main::w2#0 ← (const word) main::$0 + (const word) main::w#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const word) main::w2#0 = main::$0+main::w#0
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte*) main::sc#0 = (byte*)main::w2#0
Successful SSA optimization Pass2ConstantIdentification
Constant inlined main::$0 = (byte) 1*(word) $100+(byte) 1
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(main::bs+1)
Successful SSA optimization Pass2ConstantAdditionElimination
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
Renumbering block main::@3 to main::@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] *((const byte*) main::sc#0) ← *((const byte*) main::bs+(byte) 1)
  [5] if(*((const byte*) main::pos)==(byte) 'm') goto main::@1
  to:main::@2
main::@2: scope:[main]  from main
  [6] *((const byte*) main::bgcol) ← (byte) 2
  to:main::@return
main::@return: scope:[main]  from main::@1 main::@2
  [7] return 
  to:@return
main::@1: scope:[main]  from main
  [8] *((const byte*) main::bgcol) ← (byte) 5
  to:main::@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(byte*) main::sc
(word) main::w
(word) main::w2

Initial phi equivalence classes
Complete equivalence classes

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
  // 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: {
    // constant byte array
    .const b = 4
    // Test the result
    .label pos = $501
    .label bgcol = $d021
    .const w = b*$100
    .const w2 = 1*$100+1+w
    // constant inline words inside expression
    .label sc = w2
    // [4] *((const byte*) main::sc#0) ← *((const byte*) main::bs+(byte) 1) -- _deref_pbuc1=_deref_pbuc2 
    // implicit cast to (byte*)
    lda bs+1
    sta sc
    // [5] if(*((const byte*) main::pos)==(byte) 'm') goto main::@1 -- _deref_pbuc1_eq_vbuc2_then_la1 
    lda #'m'
    cmp pos
    beq __b1
    jmp __b2
    // main::@2
  __b2:
    // [6] *((const byte*) main::bgcol) ← (byte) 2 -- _deref_pbuc1=vbuc2 
    lda #2
    sta bgcol
    jmp __breturn
    // main::@return
  __breturn:
    // [7] return 
    rts
    // main::@1
  __b1:
    // [8] *((const byte*) main::bgcol) ← (byte) 5 -- _deref_pbuc1=vbuc2 
    lda #5
    sta bgcol
    jmp __breturn
    bs: .byte 'c', 'm'
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] *((const byte*) main::sc#0) ← *((const byte*) main::bs+(byte) 1) [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [5] if(*((const byte*) main::pos)==(byte) 'm') goto main::@1 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [6] *((const byte*) main::bgcol) ← (byte) 2 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [8] *((const byte*) main::bgcol) ← (byte) 5 [ ] ( main:2 [ ] ) always clobbers reg byte a 

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

Uplifting [main] best 55 combination 
Uplifting [] best 55 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
  // 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: {
    // constant byte array
    .const b = 4
    // Test the result
    .label pos = $501
    .label bgcol = $d021
    .const w = b*$100
    .const w2 = 1*$100+1+w
    // constant inline words inside expression
    .label sc = w2
    // [4] *((const byte*) main::sc#0) ← *((const byte*) main::bs+(byte) 1) -- _deref_pbuc1=_deref_pbuc2 
    // implicit cast to (byte*)
    lda bs+1
    sta sc
    // [5] if(*((const byte*) main::pos)==(byte) 'm') goto main::@1 -- _deref_pbuc1_eq_vbuc2_then_la1 
    lda #'m'
    cmp pos
    beq __b1
    jmp __b2
    // main::@2
  __b2:
    // [6] *((const byte*) main::bgcol) ← (byte) 2 -- _deref_pbuc1=vbuc2 
    lda #2
    sta bgcol
    jmp __breturn
    // main::@return
  __breturn:
    // [7] return 
    rts
    // main::@1
  __b1:
    // [8] *((const byte*) main::bgcol) ← (byte) 5 -- _deref_pbuc1=vbuc2 
    lda #5
    sta bgcol
    jmp __breturn
    bs: .byte 'c', 'm'
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b2
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 __b2:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Replacing jump to rts with rts in jmp __breturn
Succesful ASM optimization Pass5DoubleJumpElimination
Removing instruction __b1:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(const byte) main::b = (byte) 4
(const byte*) main::bgcol = (byte*) 53281
(const byte*) main::bs[]  = { (byte) 'c', (byte) 'm' }
(const byte*) main::pos = (byte*) 1281
(byte*) main::sc
(const byte*) main::sc#0 sc = (byte*)(const word) main::w2#0
(word) main::w
(const word) main::w#0 w = (const byte) main::b*(word) $100
(word) main::w2
(const word) main::w2#0 w2 = (byte) 1*(word) $100+(byte) 1+(const word) main::w#0



FINAL ASSEMBLER
Score: 40

  // File Comments
  // 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: {
    // constant byte array
    .const b = 4
    // Test the result
    .label pos = $501
    .label bgcol = $d021
    .const w = b*$100
    .const w2 = 1*$100+1+w
    // constant inline words inside expression
    .label sc = w2
    // *sc = bs[1]
    // [4] *((const byte*) main::sc#0) ← *((const byte*) main::bs+(byte) 1) -- _deref_pbuc1=_deref_pbuc2 
    // implicit cast to (byte*)
    lda bs+1
    sta sc
    // if(*pos=='m')
    // [5] if(*((const byte*) main::pos)==(byte) 'm') goto main::@1 -- _deref_pbuc1_eq_vbuc2_then_la1 
    lda #'m'
    cmp pos
    beq __b1
    // main::@2
    // *bgcol = 2
    // [6] *((const byte*) main::bgcol) ← (byte) 2 -- _deref_pbuc1=vbuc2 
    lda #2
    sta bgcol
    // main::@return
    // }
    // [7] return 
    rts
    // main::@1
  __b1:
    // *bgcol = 5
    // [8] *((const byte*) main::bgcol) ← (byte) 5 -- _deref_pbuc1=vbuc2 
    lda #5
    sta bgcol
    rts
    bs: .byte 'c', 'm'
}
  // File Data

