Resolved forward reference SINTABLE to (const byte*) SINTABLE
Culled Empty Block (label) main::@11
Culled Empty Block (label) main::@3
Culled Empty Block (label) main::@12
Culled Empty Block (label) main::@7
Culled Empty Block (label) main::@8
Culled Empty Block (label) main::@9
Culled Empty Block (label) main::@10

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

(void()) main()
main: scope:[main]  from @1
  to:main::@1
main::@1: scope:[main]  from main main::@6
  if(true) goto main::@2
  to:main::@return
main::@2: scope:[main]  from main::@1
  (byte) main::c1a ← (byte) c1A
  (byte) main::i ← (byte) 0
  to:main::@4
main::@4: scope:[main]  from main::@2 main::@5
  (bool~) main::$0 ← (byte) main::i < (number) $28
  if((bool~) main::$0) goto main::@5
  to:main::@6
main::@5: scope:[main]  from main::@4
  *((const byte*) SCREEN + (byte) main::i) ← *((const byte*) SINTABLE + (byte) main::c1a)
  (byte) main::c1a ← (byte) main::c1a + (number) 4
  (byte) main::i ← ++ (byte) main::i
  to:main::@4
main::@6: scope:[main]  from main::@4
  (byte) c1A ← (byte) c1A + (number) 3
  to:main::@1
main::@return: scope:[main]  from main::@1
  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
(const byte*) SCREEN = (byte*)(number) $400
(const byte*) SINTABLE[(number) $100]  = kickasm {{ .for(var i=0;i<$100;i++)
        .byte round(127.5+127.5*sin(2*PI*i/256))
 }}
(byte) c1A loadstore = (byte) 0
(void()) main()
(bool~) main::$0
(label) main::@1
(label) main::@2
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@return
(byte) main::c1a loadstore
(byte) main::i loadstore

Adding number conversion cast (unumber) $28 in (bool~) main::$0 ← (byte) main::i < (number) $28
Adding number conversion cast (unumber) 4 in (byte) main::c1a ← (byte) main::c1a + (number) 4
Adding number conversion cast (unumber) 3 in (byte) c1A ← (byte) c1A + (number) 3
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast $28
Simplifying constant integer cast 4
Simplifying constant integer cast 3
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $28
Finalized unsigned number type (byte) 4
Finalized unsigned number type (byte) 3
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simple Condition (bool~) main::$0 [4] if((byte) main::i<(byte) $28) goto main::@5
Successful SSA optimization Pass2ConditionalJumpSimplification
if() condition always true - replacing block destination [0] if(true) goto main::@2
Successful SSA optimization Pass2ConstantIfs
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
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
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@1
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
Culled Empty Block (label) main::@1
Renumbering block main::@2 to main::@1
Renumbering block main::@4 to main::@2
Renumbering block main::@5 to main::@3
Renumbering block main::@6 to main::@4
Adding NOP phi() at start of @begin
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] 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] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@4
  [5] (byte) main::c1a ← (byte) c1A
  [6] (byte) main::i ← (byte) 0
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@3
  [7] if((byte) main::i<(byte) $28) goto main::@3
  to:main::@4
main::@4: scope:[main]  from main::@2
  [8] (byte) c1A ← (byte) c1A + (byte) 3
  to:main::@1
main::@3: scope:[main]  from main::@2
  [9] *((const byte*) SCREEN + (byte) main::i) ← *((const byte*) SINTABLE + (byte) main::c1a)
  [10] (byte) main::c1a ← (byte) main::c1a + (byte) 4
  [11] (byte) main::i ← ++ (byte) main::i
  to:main::@2


VARIABLE REGISTER WEIGHTS
(byte) c1A loadstore 3.3000000000000003 = (byte) 0
(void()) main()
(byte) main::c1a loadstore 52.33333333333333
(byte) main::i loadstore 83.0

Initial phi equivalence classes
Added variable main::c1a to live range equivalence class [ main::c1a ]
Added variable main::i to live range equivalence class [ main::i ]
Added variable c1A to live range equivalence class [ c1A ]
Complete equivalence classes
[ main::c1a ]
[ main::i ]
[ c1A ]
Allocated mem[1] [ main::c1a ]
Allocated mem[1] [ main::i ]
Allocated mem[1] [ c1A ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// Demonstrates problem with __ma coalescing
// c1a is erroneously zp-coalesced with c1A
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  // @begin
__bbegin:
  // [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: {
    jmp __b1
    // main::@1
  __b1:
    // [5] (byte) main::c1a ← (byte) c1A -- vbum1=vbum2 
    lda c1A
    sta c1a
    // [6] (byte) main::i ← (byte) 0 -- vbum1=vbuc1 
    lda #0
    sta i
    jmp __b2
    // main::@2
  __b2:
    // [7] if((byte) main::i<(byte) $28) goto main::@3 -- vbum1_lt_vbuc1_then_la1 
    lda i
    cmp #$28
    bcc __b3
    jmp __b4
    // main::@4
  __b4:
    // [8] (byte) c1A ← (byte) c1A + (byte) 3 -- vbum1=vbum1_plus_vbuc1 
    lax c1A
    axs #-[3]
    stx c1A
    jmp __b1
    // main::@3
  __b3:
    // [9] *((const byte*) SCREEN + (byte) main::i) ← *((const byte*) SINTABLE + (byte) main::c1a) -- pbuc1_derefidx_vbum1=pbuc2_derefidx_vbum2 
    ldy c1a
    lda SINTABLE,y
    ldy i
    sta SCREEN,y
    // [10] (byte) main::c1a ← (byte) main::c1a + (byte) 4 -- vbum1=vbum1_plus_vbuc1 
    lax c1a
    axs #-[4]
    stx c1a
    // [11] (byte) main::i ← ++ (byte) main::i -- vbum1=_inc_vbum1 
    inc i
    jmp __b2
    c1a: .byte 0
    i: .byte 0
}
  // File Data
  .align $100
SINTABLE:
.for(var i=0;i<$100;i++)
        .byte round(127.5+127.5*sin(2*PI*i/256))

  // Plasma state variables
  c1A: .byte 0

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [5] (byte) main::c1a ← (byte) c1A [ main::c1a c1A ] ( main:2 [ main::c1a c1A ] ) always clobbers reg byte a 
Statement [6] (byte) main::i ← (byte) 0 [ main::c1a c1A main::i ] ( main:2 [ main::c1a c1A main::i ] ) always clobbers reg byte a 
Statement [7] if((byte) main::i<(byte) $28) goto main::@3 [ main::c1a c1A main::i ] ( main:2 [ main::c1a c1A main::i ] ) always clobbers reg byte a 
Statement [8] (byte) c1A ← (byte) c1A + (byte) 3 [ c1A ] ( main:2 [ c1A ] ) always clobbers reg byte a reg byte x 
Statement [9] *((const byte*) SCREEN + (byte) main::i) ← *((const byte*) SINTABLE + (byte) main::c1a) [ main::c1a c1A main::i ] ( main:2 [ main::c1a c1A main::i ] ) always clobbers reg byte a reg byte y 
Statement [10] (byte) main::c1a ← (byte) main::c1a + (byte) 4 [ main::c1a c1A main::i ] ( main:2 [ main::c1a c1A main::i ] ) always clobbers reg byte a reg byte x 
Potential registers mem[1] [ main::c1a ] : mem[1] , 
Potential registers mem[1] [ main::i ] : mem[1] , 
Potential registers mem[1] [ c1A ] : mem[1] , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 83: mem[1] [ main::i ] 52.33: mem[1] [ main::c1a ] 
Uplift Scope [] 3.3: mem[1] [ c1A ] 

Uplifting [main] best 5142 combination mem[1] [ main::i ] mem[1] [ main::c1a ] 
Uplifting [] best 5142 combination mem[1] [ c1A ] 
Attempting to uplift remaining variables inmem[1] [ main::i ]
Uplifting [main] best 5142 combination mem[1] [ main::i ] 
Attempting to uplift remaining variables inmem[1] [ main::c1a ]
Uplifting [main] best 5142 combination mem[1] [ main::c1a ] 
Attempting to uplift remaining variables inmem[1] [ c1A ]
Uplifting [] best 5142 combination mem[1] [ c1A ] 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Demonstrates problem with __ma coalescing
// c1a is erroneously zp-coalesced with c1A
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  // @begin
__bbegin:
  // [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: {
    jmp __b1
    // main::@1
  __b1:
    // [5] (byte) main::c1a ← (byte) c1A -- vbum1=vbum2 
    lda c1A
    sta c1a
    // [6] (byte) main::i ← (byte) 0 -- vbum1=vbuc1 
    lda #0
    sta i
    jmp __b2
    // main::@2
  __b2:
    // [7] if((byte) main::i<(byte) $28) goto main::@3 -- vbum1_lt_vbuc1_then_la1 
    lda i
    cmp #$28
    bcc __b3
    jmp __b4
    // main::@4
  __b4:
    // [8] (byte) c1A ← (byte) c1A + (byte) 3 -- vbum1=vbum1_plus_vbuc1 
    lax c1A
    axs #-[3]
    stx c1A
    jmp __b1
    // main::@3
  __b3:
    // [9] *((const byte*) SCREEN + (byte) main::i) ← *((const byte*) SINTABLE + (byte) main::c1a) -- pbuc1_derefidx_vbum1=pbuc2_derefidx_vbum2 
    ldy c1a
    lda SINTABLE,y
    ldy i
    sta SCREEN,y
    // [10] (byte) main::c1a ← (byte) main::c1a + (byte) 4 -- vbum1=vbum1_plus_vbuc1 
    lax c1a
    axs #-[4]
    stx c1a
    // [11] (byte) main::i ← ++ (byte) main::i -- vbum1=_inc_vbum1 
    inc i
    jmp __b2
    c1a: .byte 0
    i: .byte 0
}
  // File Data
  .align $100
SINTABLE:
.for(var i=0;i<$100;i++)
        .byte round(127.5+127.5*sin(2*PI*i/256))

  // Plasma state variables
  c1A: .byte 0

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __b4
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __bbegin with __b1
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __b4:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction __b1:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(const byte*) SCREEN = (byte*) 1024
(const byte*) SINTABLE[(number) $100]  = kickasm {{ .for(var i=0;i<$100;i++)
        .byte round(127.5+127.5*sin(2*PI*i/256))
 }}
(byte) c1A loadstore mem[1] 3.3000000000000003 = (byte) 0
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(byte) main::c1a loadstore mem[1] 52.33333333333333
(byte) main::i loadstore mem[1] 83.0

mem[1] [ main::c1a ]
mem[1] [ main::i ]
mem[1] [ c1A ]


FINAL ASSEMBLER
Score: 4770

  // File Comments
// Demonstrates problem with __ma coalescing
// c1a is erroneously zp-coalesced with c1A
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  // @begin
  // [1] phi from @begin to @1 [phi:@begin->@1]
  // @1
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    // main::@1
  __b1:
    // c1a = c1A
    // [5] (byte) main::c1a ← (byte) c1A -- vbum1=vbum2 
    lda c1A
    sta c1a
    // i = 0
    // [6] (byte) main::i ← (byte) 0 -- vbum1=vbuc1 
    lda #0
    sta i
    // main::@2
  __b2:
    // for (char i = 0; i < 40; ++i)
    // [7] if((byte) main::i<(byte) $28) goto main::@3 -- vbum1_lt_vbuc1_then_la1 
    lda i
    cmp #$28
    bcc __b3
    // main::@4
    // c1A += 3
    // [8] (byte) c1A ← (byte) c1A + (byte) 3 -- vbum1=vbum1_plus_vbuc1 
    lax c1A
    axs #-[3]
    stx c1A
    jmp __b1
    // main::@3
  __b3:
    // SCREEN[i] = SINTABLE[c1a]
    // [9] *((const byte*) SCREEN + (byte) main::i) ← *((const byte*) SINTABLE + (byte) main::c1a) -- pbuc1_derefidx_vbum1=pbuc2_derefidx_vbum2 
    ldy c1a
    lda SINTABLE,y
    ldy i
    sta SCREEN,y
    // c1a += 4
    // [10] (byte) main::c1a ← (byte) main::c1a + (byte) 4 -- vbum1=vbum1_plus_vbuc1 
    lax c1a
    axs #-[4]
    stx c1a
    // for (char i = 0; i < 40; ++i)
    // [11] (byte) main::i ← ++ (byte) main::i -- vbum1=_inc_vbum1 
    inc i
    jmp __b2
    c1a: .byte 0
    i: .byte 0
}
  // File Data
  .align $100
SINTABLE:
.for(var i=0;i<$100;i++)
        .byte round(127.5+127.5*sin(2*PI*i/256))

  // Plasma state variables
  c1A: .byte 0

