Identified constant variable (byte*) dtvSetCpuBankSegment1::cpuBank
Identified constant variable (byte*) DTV_BLITTER_ALU
Inlined call (byte~) vicSelectGfxBank::$0 ← call toDd00 (byte*) vicSelectGfxBank::gfx 
Culled Empty Block (label) @1
Culled Empty Block (label) @2
Culled Empty Block (label) @3
Culled Empty Block (label) @5
Culled Empty Block (label) main::@2
Culled Empty Block (label) main::@15
Culled Empty Block (label) main::@3
Culled Empty Block (label) main::@16
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@7
Culled Empty Block (label) main::@8
Culled Empty Block (label) main::@9
Culled Empty Block (label) main::@13
Culled Empty Block (label) main::@14

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) RASTER#0 ← ((byte*)) (number) $d012
  (byte*) BGCOL#0 ← ((byte*)) (number) $d021
  to:@4
@4: scope:[]  from @begin
  (byte*) DTV_FEATURE#0 ← ((byte*)) (number) $d03f
  (byte) DTV_FEATURE_ENABLE#0 ← (number) 1
  (byte*) DTV_CONTROL#0 ← ((byte*)) (number) $d03c
  (byte) DTV_BORDER_OFF#0 ← (number) 2
  (byte) DTV_HIGHCOLOR#0 ← (number) 4
  (byte) DTV_BADLINE_OFF#0 ← (number) $20
  (byte*) DTV_PALETTE#0 ← ((byte*)) (number) $d200
  to:@6
main: scope:[main]  from @6
  asm { sei  }
  *((byte*) DTV_FEATURE#0) ← (byte) DTV_FEATURE_ENABLE#0
  (byte~) main::$0 ← (byte) DTV_HIGHCOLOR#0 | (byte) DTV_BORDER_OFF#0
  (byte~) main::$1 ← (byte~) main::$0 | (byte) DTV_BADLINE_OFF#0
  *((byte*) DTV_CONTROL#0) ← (byte~) main::$1
  (byte[$10]) main::palette#0 ← { (number) 0, (number) 1, (number) 2, (number) 3, (number) 4, (number) 5, (number) 6, (number) 7, (number) 8, (number) 9, (number) $a, (number) $b, (number) $c, (number) $d, (number) $e, (number) $f }
  to:main::@1
main::@1: scope:[main]  from main main::@12
  if(true) goto main::@4
  to:main::@return
main::@4: scope:[main]  from main::@1 main::@4
  (bool~) main::$2 ← *((byte*) RASTER#0) != (number) $40
  if((bool~) main::$2) goto main::@4
  to:main::@6
main::@6: scope:[main]  from main::@4
  *((byte*) BGCOL#0) ← (number) 0
  (byte) main::r#0 ← (byte) $31
  to:main::@10
main::@10: scope:[main]  from main::@10 main::@6
  (byte) main::r#2 ← phi( main::@10/(byte) main::r#1 main::@6/(byte) main::r#0 )
  asm { nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop  }
  *((byte*) BGCOL#0) ← ++ *((byte*) BGCOL#0)
  (byte) main::r#1 ← (byte) main::r#2 + rangenext($31,$ff)
  (bool~) main::$3 ← (byte) main::r#1 != rangelast($31,$ff)
  if((bool~) main::$3) goto main::@10
  to:main::@11
main::@11: scope:[main]  from main::@10
  (byte) main::c#0 ← (byte) 0
  to:main::@12
main::@12: scope:[main]  from main::@11 main::@12
  (byte) main::c#2 ← phi( main::@11/(byte) main::c#0 main::@12/(byte) main::c#1 )
  *((byte*) DTV_PALETTE#0 + (byte) main::c#2) ← *((byte[$10]) main::palette#0 + (byte) main::c#2)
  *((byte[$10]) main::palette#0 + (byte) main::c#2) ← ++ *((byte[$10]) main::palette#0 + (byte) main::c#2)
  (byte) main::c#1 ← (byte) main::c#2 + rangenext(0,$f)
  (bool~) main::$4 ← (byte) main::c#1 != rangelast(0,$f)
  if((bool~) main::$4) goto main::@12
  to:main::@1
main::@return: scope:[main]  from main::@1
  return 
  to:@return
@6: scope:[]  from @4
  call main 
  to:@7
@7: scope:[]  from @6
  to:@end
@end: scope:[]  from @7

SYMBOL TABLE SSA
(label) @4
(label) @6
(label) @7
(label) @begin
(label) @end
(byte*) BGCOL
(byte*) BGCOL#0
(byte) DTV_BADLINE_OFF
(byte) DTV_BADLINE_OFF#0
(byte) DTV_BORDER_OFF
(byte) DTV_BORDER_OFF#0
(byte*) DTV_CONTROL
(byte*) DTV_CONTROL#0
(byte*) DTV_FEATURE
(byte*) DTV_FEATURE#0
(byte) DTV_FEATURE_ENABLE
(byte) DTV_FEATURE_ENABLE#0
(byte) DTV_HIGHCOLOR
(byte) DTV_HIGHCOLOR#0
(byte*) DTV_PALETTE
(byte*) DTV_PALETTE#0
(byte*) RASTER
(byte*) RASTER#0
(void()) main()
(byte~) main::$0
(byte~) main::$1
(bool~) main::$2
(bool~) main::$3
(bool~) main::$4
(label) main::@1
(label) main::@10
(label) main::@11
(label) main::@12
(label) main::@4
(label) main::@6
(label) main::@return
(byte) main::c
(byte) main::c#0
(byte) main::c#1
(byte) main::c#2
(byte[$10]) main::palette
(byte[$10]) main::palette#0
(byte) main::r
(byte) main::r#0
(byte) main::r#1
(byte) main::r#2

Adding number conversion cast (unumber) 1 in (byte) DTV_FEATURE_ENABLE#0 ← (number) 1
Adding number conversion cast (unumber) 2 in (byte) DTV_BORDER_OFF#0 ← (number) 2
Adding number conversion cast (unumber) 4 in (byte) DTV_HIGHCOLOR#0 ← (number) 4
Adding number conversion cast (unumber) $20 in (byte) DTV_BADLINE_OFF#0 ← (number) $20
Adding number conversion cast (unumber) $40 in (bool~) main::$2 ← *((byte*) RASTER#0) != (number) $40
Adding number conversion cast (unumber) 0 in *((byte*) BGCOL#0) ← (number) 0
Successful SSA optimization PassNAddNumberTypeConversions
Added casts to value list in (byte[$10]) main::palette#0 ← (byte[$10]){ (byte)(number) 0, (byte)(number) 1, (byte)(number) 2, (byte)(number) 3, (byte)(number) 4, (byte)(number) 5, (byte)(number) 6, (byte)(number) 7, (byte)(number) 8, (byte)(number) 9, (byte)(number) $a, (byte)(number) $b, (byte)(number) $c, (byte)(number) $d, (byte)(number) $e, (byte)(number) $f }
Successful SSA optimization PassNAddInitializerValueListTypeCasts
Inlining cast (byte*) RASTER#0 ← (byte*)(number) $d012
Inlining cast (byte*) BGCOL#0 ← (byte*)(number) $d021
Inlining cast (byte*) DTV_FEATURE#0 ← (byte*)(number) $d03f
Inlining cast (byte) DTV_FEATURE_ENABLE#0 ← (unumber)(number) 1
Inlining cast (byte*) DTV_CONTROL#0 ← (byte*)(number) $d03c
Inlining cast (byte) DTV_BORDER_OFF#0 ← (unumber)(number) 2
Inlining cast (byte) DTV_HIGHCOLOR#0 ← (unumber)(number) 4
Inlining cast (byte) DTV_BADLINE_OFF#0 ← (unumber)(number) $20
Inlining cast (byte*) DTV_PALETTE#0 ← (byte*)(number) $d200
Inlining cast *((byte*) BGCOL#0) ← (unumber)(number) 0
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 53266
Simplifying constant pointer cast (byte*) 53281
Simplifying constant pointer cast (byte*) 53311
Simplifying constant integer cast 1
Simplifying constant pointer cast (byte*) 53308
Simplifying constant integer cast 2
Simplifying constant integer cast 4
Simplifying constant integer cast $20
Simplifying constant pointer cast (byte*) 53760
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 2
Simplifying constant integer cast 3
Simplifying constant integer cast 4
Simplifying constant integer cast 5
Simplifying constant integer cast 6
Simplifying constant integer cast 7
Simplifying constant integer cast 8
Simplifying constant integer cast 9
Simplifying constant integer cast $a
Simplifying constant integer cast $b
Simplifying constant integer cast $c
Simplifying constant integer cast $d
Simplifying constant integer cast $e
Simplifying constant integer cast $f
Simplifying constant integer cast $40
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 4
Finalized unsigned number type (byte) $20
Finalized unsigned number type (byte) $40
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simple Condition (bool~) main::$2 [17] if(*((byte*) RASTER#0)!=(byte) $40) goto main::@4
Simple Condition (bool~) main::$3 [25] if((byte) main::r#1!=rangelast($31,$ff)) goto main::@10
Simple Condition (bool~) main::$4 [32] if((byte) main::c#1!=rangelast(0,$f)) goto main::@12
Successful SSA optimization Pass2ConditionalJumpSimplification
Identified constant from value list (byte[$10]) { (byte) 0, (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5, (byte) 6, (byte) 7, (byte) 8, (byte) 9, (byte) $a, (byte) $b, (byte) $c, (byte) $d, (byte) $e, (byte) $f }
Successful SSA optimization Pass2ConstantInitializerValueLists
Constant (const byte*) RASTER#0 = (byte*) 53266
Constant (const byte*) BGCOL#0 = (byte*) 53281
Constant (const byte*) DTV_FEATURE#0 = (byte*) 53311
Constant (const byte) DTV_FEATURE_ENABLE#0 = 1
Constant (const byte*) DTV_CONTROL#0 = (byte*) 53308
Constant (const byte) DTV_BORDER_OFF#0 = 2
Constant (const byte) DTV_HIGHCOLOR#0 = 4
Constant (const byte) DTV_BADLINE_OFF#0 = $20
Constant (const byte*) DTV_PALETTE#0 = (byte*) 53760
Constant (const byte[$10]) main::palette#0 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, $a, $b, $c, $d, $e, $f }
Constant (const byte) main::r#0 = $31
Constant (const byte) main::c#0 = 0
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [15] if(true) goto main::@4
Successful SSA optimization Pass2ConstantIfs
Resolved ranged next value [23] main::r#1 ← ++ main::r#2 to ++
Resolved ranged comparison value [25] if(main::r#1!=rangelast($31,$ff)) goto main::@10 to (number) 0
Resolved ranged next value [30] main::c#1 ← ++ main::c#2 to ++
Resolved ranged comparison value [32] if(main::c#1!=rangelast(0,$f)) goto main::@12 to (number) $10
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Adding number conversion cast (unumber) 0 in if((byte) main::r#1!=(number) 0) goto main::@10
Adding number conversion cast (unumber) $10 in if((byte) main::c#1!=(number) $10) goto main::@12
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 0
Simplifying constant integer cast $10
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $10
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant right-side identified [2] (byte~) main::$0 ← (const byte) DTV_HIGHCOLOR#0 | (const byte) DTV_BORDER_OFF#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::$0 = DTV_HIGHCOLOR#0|DTV_BORDER_OFF#0
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [2] (byte~) main::$1 ← (const byte) main::$0 | (const byte) DTV_BADLINE_OFF#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::$1 = main::$0|DTV_BADLINE_OFF#0
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with var siblings (const byte) main::r#0
Inlining constant with var siblings (const byte) main::c#0
Constant inlined main::r#0 = (byte) $31
Constant inlined main::c#0 = (byte) 0
Constant inlined main::$1 = (const byte) DTV_HIGHCOLOR#0|(const byte) DTV_BORDER_OFF#0|(const byte) DTV_BADLINE_OFF#0
Constant inlined main::$0 = (const byte) DTV_HIGHCOLOR#0|(const byte) DTV_BORDER_OFF#0
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@17(between main::@10 and main::@10)
Added new block during phi lifting main::@18(between main::@12 and main::@12)
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @4
Adding NOP phi() at start of @6
Adding NOP phi() at start of @7
Adding NOP phi() at start of @end
Adding NOP phi() at start of main::@1
Adding NOP phi() at start of main::@11
CALL GRAPH
Calls in [] to main:3 

Created 2 initial phi equivalence classes
Coalesced [23] main::c#3 ← main::c#1
Coalesced [24] main::r#3 ← main::r#1
Coalesced down to 2 phi equivalence classes
Culled Empty Block (label) @4
Culled Empty Block (label) @7
Culled Empty Block (label) main::@1
Culled Empty Block (label) main::@11
Culled Empty Block (label) main::@18
Culled Empty Block (label) main::@17
Renumbering block @6 to @1
Renumbering block main::@4 to main::@1
Renumbering block main::@6 to main::@2
Renumbering block main::@10 to main::@3
Renumbering block main::@12 to main::@4
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()
main: scope:[main]  from @1
  asm { sei  }
  [5] *((const byte*) DTV_FEATURE#0) ← (const byte) DTV_FEATURE_ENABLE#0
  [6] *((const byte*) DTV_CONTROL#0) ← (const byte) DTV_HIGHCOLOR#0|(const byte) DTV_BORDER_OFF#0|(const byte) DTV_BADLINE_OFF#0
  to:main::@1
main::@1: scope:[main]  from main main::@1 main::@4
  [7] if(*((const byte*) RASTER#0)!=(byte) $40) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1
  [8] *((const byte*) BGCOL#0) ← (byte) 0
  to:main::@3
main::@3: scope:[main]  from main::@2 main::@3
  [9] (byte) main::r#2 ← phi( main::@3/(byte) main::r#1 main::@2/(byte) $31 )
  asm { nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop  }
  [11] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0)
  [12] (byte) main::r#1 ← ++ (byte) main::r#2
  [13] if((byte) main::r#1!=(byte) 0) goto main::@3
  to:main::@4
main::@4: scope:[main]  from main::@3 main::@4
  [14] (byte) main::c#2 ← phi( main::@3/(byte) 0 main::@4/(byte) main::c#1 )
  [15] *((const byte*) DTV_PALETTE#0 + (byte) main::c#2) ← *((const byte[$10]) main::palette#0 + (byte) main::c#2)
  [16] *((const byte[$10]) main::palette#0 + (byte) main::c#2) ← ++ *((const byte[$10]) main::palette#0 + (byte) main::c#2)
  [17] (byte) main::c#1 ← ++ (byte) main::c#2
  [18] if((byte) main::c#1!=(byte) $10) goto main::@4
  to:main::@1


VARIABLE REGISTER WEIGHTS
(byte*) BGCOL
(byte) DTV_BADLINE_OFF
(byte) DTV_BORDER_OFF
(byte*) DTV_CONTROL
(byte*) DTV_FEATURE
(byte) DTV_FEATURE_ENABLE
(byte) DTV_HIGHCOLOR
(byte*) DTV_PALETTE
(byte*) RASTER
(void()) main()
(byte) main::c
(byte) main::c#1 151.5
(byte) main::c#2 201.99999999999997
(byte[$10]) main::palette
(byte) main::r
(byte) main::r#1 151.5
(byte) main::r#2 67.33333333333333

Initial phi equivalence classes
[ main::r#2 main::r#1 ]
[ main::c#2 main::c#1 ]
Complete equivalence classes
[ main::r#2 main::r#1 ]
[ main::c#2 main::c#1 ]
Allocated zp ZP_BYTE:2 [ main::r#2 main::r#1 ]
Allocated zp ZP_BYTE:3 [ main::c#2 main::c#1 ]

INITIAL ASM
Target platform is c64basic
  // File Comments
// Test C64DTV v2 256-colors and the 16-color redefinable palette
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label RASTER = $d012
  .label BGCOL = $d021
  // Feature enables or disables the extra C64 DTV features
  .label DTV_FEATURE = $d03f
  .const DTV_FEATURE_ENABLE = 1
  // Controls the graphics modes of the C64 DTV
  .label DTV_CONTROL = $d03c
  .const DTV_BORDER_OFF = 2
  .const DTV_HIGHCOLOR = 4
  .const DTV_BADLINE_OFF = $20
  // Defines colors for the 16 first colors ($00-$0f)
  .label DTV_PALETTE = $d200
  // @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: {
    .label r = 2
    .label c = 3
    // asm { sei  }
    sei
    // [5] *((const byte*) DTV_FEATURE#0) ← (const byte) DTV_FEATURE_ENABLE#0 -- _deref_pbuc1=vbuc2 
    lda #DTV_FEATURE_ENABLE
    sta DTV_FEATURE
    // [6] *((const byte*) DTV_CONTROL#0) ← (const byte) DTV_HIGHCOLOR#0|(const byte) DTV_BORDER_OFF#0|(const byte) DTV_BADLINE_OFF#0 -- _deref_pbuc1=vbuc2 
    lda #DTV_HIGHCOLOR|DTV_BORDER_OFF|DTV_BADLINE_OFF
    sta DTV_CONTROL
    jmp b1
    // main::@1
  b1:
    // [7] if(*((const byte*) RASTER#0)!=(byte) $40) goto main::@1 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$40
    cmp RASTER
    bne b1
    jmp b2
    // main::@2
  b2:
    // [8] *((const byte*) BGCOL#0) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    // Create rasterbars
    lda #0
    sta BGCOL
    // [9] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
  b3_from_b2:
    // [9] phi (byte) main::r#2 = (byte) $31 [phi:main::@2->main::@3#0] -- vbuz1=vbuc1 
    lda #$31
    sta.z r
    jmp b3
    // [9] phi from main::@3 to main::@3 [phi:main::@3->main::@3]
  b3_from_b3:
    // [9] phi (byte) main::r#2 = (byte) main::r#1 [phi:main::@3->main::@3#0] -- register_copy 
    jmp b3
    // main::@3
  b3:
    // asm { nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop  }
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    // [11] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
    // [12] (byte) main::r#1 ← ++ (byte) main::r#2 -- vbuz1=_inc_vbuz1 
    inc.z r
    // [13] if((byte) main::r#1!=(byte) 0) goto main::@3 -- vbuz1_neq_0_then_la1 
    lda.z r
    cmp #0
    bne b3_from_b3
    // [14] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
  b4_from_b3:
    // [14] phi (byte) main::c#2 = (byte) 0 [phi:main::@3->main::@4#0] -- vbuz1=vbuc1 
    lda #0
    sta.z c
    jmp b4
  // Rotate palette
    // [14] phi from main::@4 to main::@4 [phi:main::@4->main::@4]
  b4_from_b4:
    // [14] phi (byte) main::c#2 = (byte) main::c#1 [phi:main::@4->main::@4#0] -- register_copy 
    jmp b4
    // main::@4
  b4:
    // [15] *((const byte*) DTV_PALETTE#0 + (byte) main::c#2) ← *((const byte[$10]) main::palette#0 + (byte) main::c#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1 
    ldy.z c
    lda palette,y
    sta DTV_PALETTE,y
    // [16] *((const byte[$10]) main::palette#0 + (byte) main::c#2) ← ++ *((const byte[$10]) main::palette#0 + (byte) main::c#2) -- pbuc1_derefidx_vbuz1=_inc_pbuc1_derefidx_vbuz1 
    ldx.z c
    inc palette,x
    // [17] (byte) main::c#1 ← ++ (byte) main::c#2 -- vbuz1=_inc_vbuz1 
    inc.z c
    // [18] if((byte) main::c#1!=(byte) $10) goto main::@4 -- vbuz1_neq_vbuc1_then_la1 
    lda #$10
    cmp.z c
    bne b4_from_b4
    jmp b1
    palette: .byte 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, $a, $b, $c, $d, $e, $f
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [5] *((const byte*) DTV_FEATURE#0) ← (const byte) DTV_FEATURE_ENABLE#0 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [6] *((const byte*) DTV_CONTROL#0) ← (const byte) DTV_HIGHCOLOR#0|(const byte) DTV_BORDER_OFF#0|(const byte) DTV_BADLINE_OFF#0 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [7] if(*((const byte*) RASTER#0)!=(byte) $40) goto main::@1 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [8] *((const byte*) BGCOL#0) ← (byte) 0 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [15] *((const byte*) DTV_PALETTE#0 + (byte) main::c#2) ← *((const byte[$10]) main::palette#0 + (byte) main::c#2) [ main::c#2 ] ( main:2 [ main::c#2 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:3 [ main::c#2 main::c#1 ]
Statement [5] *((const byte*) DTV_FEATURE#0) ← (const byte) DTV_FEATURE_ENABLE#0 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [6] *((const byte*) DTV_CONTROL#0) ← (const byte) DTV_HIGHCOLOR#0|(const byte) DTV_BORDER_OFF#0|(const byte) DTV_BADLINE_OFF#0 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [7] if(*((const byte*) RASTER#0)!=(byte) $40) goto main::@1 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [8] *((const byte*) BGCOL#0) ← (byte) 0 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [15] *((const byte*) DTV_PALETTE#0 + (byte) main::c#2) ← *((const byte[$10]) main::palette#0 + (byte) main::c#2) [ main::c#2 ] ( main:2 [ main::c#2 ] ) always clobbers reg byte a 
Potential registers zp ZP_BYTE:2 [ main::r#2 main::r#1 ] : zp ZP_BYTE:2 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:3 [ main::c#2 main::c#1 ] : zp ZP_BYTE:3 , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 353.5: zp ZP_BYTE:3 [ main::c#2 main::c#1 ] 218.83: zp ZP_BYTE:2 [ main::r#2 main::r#1 ] 
Uplift Scope [] 

Uplifting [main] best 11689 combination reg byte x [ main::c#2 main::c#1 ] reg byte x [ main::r#2 main::r#1 ] 
Uplifting [] best 11689 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test C64DTV v2 256-colors and the 16-color redefinable palette
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label RASTER = $d012
  .label BGCOL = $d021
  // Feature enables or disables the extra C64 DTV features
  .label DTV_FEATURE = $d03f
  .const DTV_FEATURE_ENABLE = 1
  // Controls the graphics modes of the C64 DTV
  .label DTV_CONTROL = $d03c
  .const DTV_BORDER_OFF = 2
  .const DTV_HIGHCOLOR = 4
  .const DTV_BADLINE_OFF = $20
  // Defines colors for the 16 first colors ($00-$0f)
  .label DTV_PALETTE = $d200
  // @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: {
    // asm { sei  }
    sei
    // [5] *((const byte*) DTV_FEATURE#0) ← (const byte) DTV_FEATURE_ENABLE#0 -- _deref_pbuc1=vbuc2 
    lda #DTV_FEATURE_ENABLE
    sta DTV_FEATURE
    // [6] *((const byte*) DTV_CONTROL#0) ← (const byte) DTV_HIGHCOLOR#0|(const byte) DTV_BORDER_OFF#0|(const byte) DTV_BADLINE_OFF#0 -- _deref_pbuc1=vbuc2 
    lda #DTV_HIGHCOLOR|DTV_BORDER_OFF|DTV_BADLINE_OFF
    sta DTV_CONTROL
    jmp b1
    // main::@1
  b1:
    // [7] if(*((const byte*) RASTER#0)!=(byte) $40) goto main::@1 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$40
    cmp RASTER
    bne b1
    jmp b2
    // main::@2
  b2:
    // [8] *((const byte*) BGCOL#0) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    // Create rasterbars
    lda #0
    sta BGCOL
    // [9] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
  b3_from_b2:
    // [9] phi (byte) main::r#2 = (byte) $31 [phi:main::@2->main::@3#0] -- vbuxx=vbuc1 
    ldx #$31
    jmp b3
    // [9] phi from main::@3 to main::@3 [phi:main::@3->main::@3]
  b3_from_b3:
    // [9] phi (byte) main::r#2 = (byte) main::r#1 [phi:main::@3->main::@3#0] -- register_copy 
    jmp b3
    // main::@3
  b3:
    // asm { nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop  }
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    // [11] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
    // [12] (byte) main::r#1 ← ++ (byte) main::r#2 -- vbuxx=_inc_vbuxx 
    inx
    // [13] if((byte) main::r#1!=(byte) 0) goto main::@3 -- vbuxx_neq_0_then_la1 
    cpx #0
    bne b3_from_b3
    // [14] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
  b4_from_b3:
    // [14] phi (byte) main::c#2 = (byte) 0 [phi:main::@3->main::@4#0] -- vbuxx=vbuc1 
    ldx #0
    jmp b4
  // Rotate palette
    // [14] phi from main::@4 to main::@4 [phi:main::@4->main::@4]
  b4_from_b4:
    // [14] phi (byte) main::c#2 = (byte) main::c#1 [phi:main::@4->main::@4#0] -- register_copy 
    jmp b4
    // main::@4
  b4:
    // [15] *((const byte*) DTV_PALETTE#0 + (byte) main::c#2) ← *((const byte[$10]) main::palette#0 + (byte) main::c#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx 
    lda palette,x
    sta DTV_PALETTE,x
    // [16] *((const byte[$10]) main::palette#0 + (byte) main::c#2) ← ++ *((const byte[$10]) main::palette#0 + (byte) main::c#2) -- pbuc1_derefidx_vbuxx=_inc_pbuc1_derefidx_vbuxx 
    inc palette,x
    // [17] (byte) main::c#1 ← ++ (byte) main::c#2 -- vbuxx=_inc_vbuxx 
    inx
    // [18] if((byte) main::c#1!=(byte) $10) goto main::@4 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$10
    bne b4_from_b4
    jmp b1
    palette: .byte 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, $a, $b, $c, $d, $e, $f
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp b3
Removing instruction jmp b4
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b3_from_b3 with b3
Replacing label b4_from_b4 with b4
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction bend_from_b1:
Removing instruction b3_from_b3:
Removing instruction b4_from_b4:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b2:
Removing instruction b3_from_b2:
Removing instruction b4_from_b3:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction jmp b3
Removing instruction jmp b4
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte*) BGCOL
(const byte*) BGCOL#0 BGCOL = (byte*) 53281
(byte) DTV_BADLINE_OFF
(const byte) DTV_BADLINE_OFF#0 DTV_BADLINE_OFF = (byte) $20
(byte) DTV_BORDER_OFF
(const byte) DTV_BORDER_OFF#0 DTV_BORDER_OFF = (byte) 2
(byte*) DTV_CONTROL
(const byte*) DTV_CONTROL#0 DTV_CONTROL = (byte*) 53308
(byte*) DTV_FEATURE
(const byte*) DTV_FEATURE#0 DTV_FEATURE = (byte*) 53311
(byte) DTV_FEATURE_ENABLE
(const byte) DTV_FEATURE_ENABLE#0 DTV_FEATURE_ENABLE = (byte) 1
(byte) DTV_HIGHCOLOR
(const byte) DTV_HIGHCOLOR#0 DTV_HIGHCOLOR = (byte) 4
(byte*) DTV_PALETTE
(const byte*) DTV_PALETTE#0 DTV_PALETTE = (byte*) 53760
(byte*) RASTER
(const byte*) RASTER#0 RASTER = (byte*) 53266
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(byte) main::c
(byte) main::c#1 reg byte x 151.5
(byte) main::c#2 reg byte x 201.99999999999997
(byte[$10]) main::palette
(const byte[$10]) main::palette#0 palette = { (byte) 0, (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5, (byte) 6, (byte) 7, (byte) 8, (byte) 9, (byte) $a, (byte) $b, (byte) $c, (byte) $d, (byte) $e, (byte) $f }
(byte) main::r
(byte) main::r#1 reg byte x 151.5
(byte) main::r#2 reg byte x 67.33333333333333

reg byte x [ main::r#2 main::r#1 ]
reg byte x [ main::c#2 main::c#1 ]


FINAL ASSEMBLER
Score: 10174

  // File Comments
// Test C64DTV v2 256-colors and the 16-color redefinable palette
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .label RASTER = $d012
  .label BGCOL = $d021
  // Feature enables or disables the extra C64 DTV features
  .label DTV_FEATURE = $d03f
  .const DTV_FEATURE_ENABLE = 1
  // Controls the graphics modes of the C64 DTV
  .label DTV_CONTROL = $d03c
  .const DTV_BORDER_OFF = 2
  .const DTV_HIGHCOLOR = 4
  .const DTV_BADLINE_OFF = $20
  // Defines colors for the 16 first colors ($00-$0f)
  .label DTV_PALETTE = $d200
  // @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: {
    // asm
    // asm { sei  }
    sei
    // *DTV_FEATURE = DTV_FEATURE_ENABLE
    // [5] *((const byte*) DTV_FEATURE#0) ← (const byte) DTV_FEATURE_ENABLE#0 -- _deref_pbuc1=vbuc2 
    lda #DTV_FEATURE_ENABLE
    sta DTV_FEATURE
    // *DTV_CONTROL = DTV_HIGHCOLOR | DTV_BORDER_OFF | DTV_BADLINE_OFF
    // [6] *((const byte*) DTV_CONTROL#0) ← (const byte) DTV_HIGHCOLOR#0|(const byte) DTV_BORDER_OFF#0|(const byte) DTV_BADLINE_OFF#0 -- _deref_pbuc1=vbuc2 
    lda #DTV_HIGHCOLOR|DTV_BORDER_OFF|DTV_BADLINE_OFF
    sta DTV_CONTROL
    // main::@1
  b1:
    // while(*RASTER!=$40)
    // [7] if(*((const byte*) RASTER#0)!=(byte) $40) goto main::@1 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$40
    cmp RASTER
    bne b1
    // main::@2
    // *BGCOL = 0
    // [8] *((const byte*) BGCOL#0) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    // Create rasterbars
    lda #0
    sta BGCOL
    // [9] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
    // [9] phi (byte) main::r#2 = (byte) $31 [phi:main::@2->main::@3#0] -- vbuxx=vbuc1 
    ldx #$31
    // [9] phi from main::@3 to main::@3 [phi:main::@3->main::@3]
    // [9] phi (byte) main::r#2 = (byte) main::r#1 [phi:main::@3->main::@3#0] -- register_copy 
    // main::@3
  b3:
    // asm
    // asm { nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop  }
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    nop
    // (*BGCOL)++;
    // [11] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
    // for (byte r : $31..$ff)
    // [12] (byte) main::r#1 ← ++ (byte) main::r#2 -- vbuxx=_inc_vbuxx 
    inx
    // [13] if((byte) main::r#1!=(byte) 0) goto main::@3 -- vbuxx_neq_0_then_la1 
    cpx #0
    bne b3
    // [14] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
    // [14] phi (byte) main::c#2 = (byte) 0 [phi:main::@3->main::@4#0] -- vbuxx=vbuc1 
    ldx #0
  // Rotate palette
    // [14] phi from main::@4 to main::@4 [phi:main::@4->main::@4]
    // [14] phi (byte) main::c#2 = (byte) main::c#1 [phi:main::@4->main::@4#0] -- register_copy 
    // main::@4
  b4:
    // DTV_PALETTE[c] = palette[c]
    // [15] *((const byte*) DTV_PALETTE#0 + (byte) main::c#2) ← *((const byte[$10]) main::palette#0 + (byte) main::c#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx 
    lda palette,x
    sta DTV_PALETTE,x
    // palette[c]++;
    // [16] *((const byte[$10]) main::palette#0 + (byte) main::c#2) ← ++ *((const byte[$10]) main::palette#0 + (byte) main::c#2) -- pbuc1_derefidx_vbuxx=_inc_pbuc1_derefidx_vbuxx 
    inc palette,x
    // for(byte c : 0..$f)
    // [17] (byte) main::c#1 ← ++ (byte) main::c#2 -- vbuxx=_inc_vbuxx 
    inx
    // [18] if((byte) main::c#1!=(byte) $10) goto main::@4 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$10
    bne b4
    jmp b1
    palette: .byte 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, $a, $b, $c, $d, $e, $f
}
  // File Data

