Identified constant variable (byte*) main::screen
Identified constant variable (byte*) main::BGCOL

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@1
main: scope:[main]  from @1
  (byte*) main::screen#0 ← ((byte*)) (number) $400
  (byte) main::i#0 ← (byte) 0
  to:main::@1
main::@1: scope:[main]  from main main::@1
  (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
  (byte*~) main::$11 ← (byte*) main::screen#0 + (number) $28
  (byte*~) main::$12 ← (byte*~) main::$11 + (byte) main::i#2
  *((byte*) main::screen#0 + (byte) main::i#2) ← *((byte*~) main::$12)
  (byte) main::i#1 ← (byte) main::i#2 + rangenext(0,$a)
  (bool~) main::$13 ← (byte) main::i#1 != rangelast(0,$a)
  if((bool~) main::$13) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1
  (byte*~) main::$1 ← (byte*) main::screen#0 + (number) $51
  (byte*) main::sc2#0 ← (byte*~) main::$1
  (byte*~) main::$2 ← (byte*) main::screen#0 + (number) $79
  *((byte*) main::sc2#0) ← *((byte*~) main::$2)
  (byte*~) main::$3 ← (byte*) main::screen#0 + (number) $52
  (byte*~) main::$4 ← (byte*) main::screen#0 + (number) $7a
  *((byte*~) main::$3) ← *((byte*~) main::$4)
  (byte) main::j#0 ← (byte) 0
  to:main::@3
main::@3: scope:[main]  from main::@2 main::@3
  (byte) main::j#2 ← phi( main::@2/(byte) main::j#0 main::@3/(byte) main::j#1 )
  (byte*~) main::$14 ← (byte*) main::screen#0 + (number) $a0
  (byte*~) main::$15 ← (byte*~) main::$14 + (byte) main::j#2
  (byte*~) main::$16 ← (byte*) main::screen#0 + (number) $c8
  (byte*~) main::$17 ← (byte*~) main::$16 + (byte) main::j#2
  *((byte*~) main::$15) ← *((byte*~) main::$17)
  (byte) main::j#1 ← (byte) main::j#2 + rangenext(0,$a)
  (bool~) main::$18 ← (byte) main::j#1 != rangelast(0,$a)
  if((bool~) main::$18) goto main::@3
  to:main::@4
main::@4: scope:[main]  from main::@3
  (byte*~) main::$5 ← ((byte*)) (number) $d020
  *((byte*~) main::$5) ← ++ *((byte*~) main::$5)
  (byte*~) main::$8 ← ((byte*)) (number) $d000+(number) $21
  *((byte*~) main::$8) ← -- *((byte*~) main::$8)
  (byte*) main::BGCOL#0 ← ((byte*)) (number) $d020
  *((byte*) main::BGCOL#0) ← ++ *((byte*) main::BGCOL#0)
  to:main::@return
main::@return: scope:[main]  from main::@4
  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()
(byte*~) main::$1
(byte*~) main::$11
(byte*~) main::$12
(bool~) main::$13
(byte*~) main::$14
(byte*~) main::$15
(byte*~) main::$16
(byte*~) main::$17
(bool~) main::$18
(byte*~) main::$2
(byte*~) main::$3
(byte*~) main::$4
(byte*~) main::$5
(byte*~) main::$8
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@return
(byte*) main::BGCOL
(byte*) main::BGCOL#0
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(byte) main::j
(byte) main::j#0
(byte) main::j#1
(byte) main::j#2
(byte*) main::sc2
(byte*) main::sc2#0
(byte*) main::screen
(byte*) main::screen#0

Adding number conversion cast (unumber) $28 in (byte*~) main::$11 ← (byte*) main::screen#0 + (number) $28
Adding number conversion cast (unumber) $51 in (byte*~) main::$1 ← (byte*) main::screen#0 + (number) $51
Adding number conversion cast (unumber) $79 in (byte*~) main::$2 ← (byte*) main::screen#0 + (number) $79
Adding number conversion cast (unumber) $52 in (byte*~) main::$3 ← (byte*) main::screen#0 + (number) $52
Adding number conversion cast (unumber) $7a in (byte*~) main::$4 ← (byte*) main::screen#0 + (number) $7a
Adding number conversion cast (unumber) $a0 in (byte*~) main::$14 ← (byte*) main::screen#0 + (number) $a0
Adding number conversion cast (unumber) $c8 in (byte*~) main::$16 ← (byte*) main::screen#0 + (number) $c8
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) main::screen#0 ← (byte*)(number) $400
Inlining cast (byte*~) main::$5 ← (byte*)(number) $d020
Inlining cast (byte*~) main::$8 ← (byte*)(number) $d000+(number) $21
Inlining cast (byte*) main::BGCOL#0 ← (byte*)(number) $d020
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast $28
Simplifying constant integer cast $51
Simplifying constant integer cast $79
Simplifying constant integer cast $52
Simplifying constant integer cast $7a
Simplifying constant integer cast $a0
Simplifying constant integer cast $c8
Simplifying constant pointer cast (byte*) 53280
Simplifying constant pointer cast (byte*) 53280
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $28
Finalized unsigned number type (byte) $51
Finalized unsigned number type (byte) $79
Finalized unsigned number type (byte) $52
Finalized unsigned number type (byte) $7a
Finalized unsigned number type (byte) $a0
Finalized unsigned number type (byte) $c8
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte*) main::sc2#0 = (byte*~) main::$1 
Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) main::$13 [8] if((byte) main::i#1!=rangelast(0,$a)) goto main::@1
Simple Condition (bool~) main::$18 [25] if((byte) main::j#1!=rangelast(0,$a)) goto main::@3
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant right-side identified [28] (byte*~) main::$8 ← (byte*)(number) $d000+(number) $21
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) main::screen#0 = (byte*) 1024
Constant (const byte) main::i#0 = 0
Constant (const byte) main::j#0 = 0
Constant (const byte*) main::$5 = (byte*) 53280
Constant (const byte*) main::$8 = (byte*)$d000+$21
Constant (const byte*) main::BGCOL#0 = (byte*) 53280
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [6] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [8] if(main::i#1!=rangelast(0,$a)) goto main::@1 to (number) $b
Resolved ranged next value [23] main::j#1 ← ++ main::j#2 to ++
Resolved ranged comparison value [25] if(main::j#1!=rangelast(0,$a)) goto main::@3 to (number) $b
Converting *(pointer+n) to pointer[n] [5] *((const byte*) main::screen#0 + (byte) main::i#2) ← *((byte*~) main::$12)  -- *(main::$11 + main::i#2)
Converting *(pointer+n) to pointer[n] [12] *((byte*) main::sc2#0) ← *((byte*~) main::$2)  -- *(main::screen#0 + $79)
Converting *(pointer+n) to pointer[n] [12] *((byte*) main::sc2#0) ← *((const byte*) main::screen#0 + (byte) $79)  -- *(main::screen#0 + $51)
Converting *(pointer+n) to pointer[n] [15] *((byte*~) main::$3) ← *((byte*~) main::$4)  -- *(main::screen#0 + $7a)
Converting *(pointer+n) to pointer[n] [15] *((byte*~) main::$3) ← *((const byte*) main::screen#0 + (byte) $7a)  -- *(main::screen#0 + $52)
Converting *(pointer+n) to pointer[n] [22] *((byte*~) main::$15) ← *((byte*~) main::$17)  -- *(main::$16 + main::j#2)
Converting *(pointer+n) to pointer[n] [22] *((byte*~) main::$15) ← *((byte*~) main::$16 + (byte) main::j#2)  -- *(main::$14 + main::j#2)
Successful SSA optimization Pass2InlineDerefIdx
Eliminating unused variable (byte*~) main::$12 and assignment [2] (byte*~) main::$12 ← (byte*~) main::$11 + (byte) main::i#2
Eliminating unused variable (byte*) main::sc2#0 and assignment [6] (byte*) main::sc2#0 ← (const byte*) main::screen#0 + (byte) $51
Eliminating unused variable (byte*~) main::$2 and assignment [7] (byte*~) main::$2 ← (const byte*) main::screen#0 + (byte) $79
Eliminating unused variable (byte*~) main::$3 and assignment [9] (byte*~) main::$3 ← (const byte*) main::screen#0 + (byte) $52
Eliminating unused variable (byte*~) main::$4 and assignment [10] (byte*~) main::$4 ← (const byte*) main::screen#0 + (byte) $7a
Eliminating unused variable (byte*~) main::$15 and assignment [14] (byte*~) main::$15 ← (byte*~) main::$14 + (byte) main::j#2
Eliminating unused variable (byte*~) main::$17 and assignment [16] (byte*~) main::$17 ← (byte*~) main::$16 + (byte) main::j#2
Successful SSA optimization PassNEliminateUnusedVars
Adding number conversion cast (unumber) $b in if((byte) main::i#1!=(number) $b) goto main::@1
Adding number conversion cast (unumber) $b in if((byte) main::j#1!=(number) $b) goto main::@3
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast $b
Simplifying constant integer cast $b
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $b
Finalized unsigned number type (byte) $b
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant right-side identified [1] (byte*~) main::$11 ← (const byte*) main::screen#0 + (byte) $28
Constant right-side identified [8] (byte*~) main::$14 ← (const byte*) main::screen#0 + (byte) $a0
Constant right-side identified [9] (byte*~) main::$16 ← (const byte*) main::screen#0 + (byte) $c8
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) main::$11 = main::screen#0+$28
Constant (const byte*) main::$14 = main::screen#0+$a0
Constant (const byte*) main::$16 = main::screen#0+$c8
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with var siblings (const byte) main::i#0
Inlining constant with var siblings (const byte) main::j#0
Constant inlined main::$16 = (const byte*) main::screen#0+(byte) $c8
Constant inlined main::$5 = (byte*) 53280
Constant inlined main::i#0 = (byte) 0
Constant inlined main::$14 = (const byte*) main::screen#0+(byte) $a0
Constant inlined main::j#0 = (byte) 0
Constant inlined main::$8 = (byte*)(number) $d000+(number) $21
Constant inlined main::$11 = (const byte*) main::screen#0+(byte) $28
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(main::screen#0+$79)
Consolidated array index constant in *(main::screen#0+$51)
Consolidated array index constant in *(main::screen#0+$7a)
Consolidated array index constant in *(main::screen#0+$52)
Successful SSA optimization Pass2ConstantAdditionElimination
Added new block during phi lifting main::@5(between main::@1 and main::@1)
Added new block during phi lifting main::@6(between main::@3 and main::@3)
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
CALL GRAPH
Calls in [] to main:2 

Created 2 initial phi equivalence classes
Coalesced [20] main::j#3 ← main::j#1
Coalesced [21] main::i#3 ← main::i#1
Coalesced down to 2 phi equivalence classes
Culled Empty Block (label) @2
Culled Empty Block (label) main::@6
Culled Empty Block (label) main::@5
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()
main: scope:[main]  from @1
  [4] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@1
  [5] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
  [6] *((const byte*) main::screen#0 + (byte) main::i#2) ← *((const byte*) main::screen#0+(byte) $28 + (byte) main::i#2)
  [7] (byte) main::i#1 ← ++ (byte) main::i#2
  [8] if((byte) main::i#1!=(byte) $b) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1
  [9] *((const byte*) main::screen#0+(byte) $51) ← *((const byte*) main::screen#0+(byte) $79)
  [10] *((const byte*) main::screen#0+(byte) $52) ← *((const byte*) main::screen#0+(byte) $7a)
  to:main::@3
main::@3: scope:[main]  from main::@2 main::@3
  [11] (byte) main::j#2 ← phi( main::@2/(byte) 0 main::@3/(byte) main::j#1 )
  [12] *((const byte*) main::screen#0+(byte) $a0 + (byte) main::j#2) ← *((const byte*) main::screen#0+(byte) $c8 + (byte) main::j#2)
  [13] (byte) main::j#1 ← ++ (byte) main::j#2
  [14] if((byte) main::j#1!=(byte) $b) goto main::@3
  to:main::@4
main::@4: scope:[main]  from main::@3
  [15] *((byte*) 53280) ← ++ *((byte*) 53280)
  [16] *((byte*)(number) $d000+(number) $21) ← -- *((byte*)(number) $d000+(number) $21)
  [17] *((const byte*) main::BGCOL#0) ← ++ *((const byte*) main::BGCOL#0)
  to:main::@return
main::@return: scope:[main]  from main::@4
  [18] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(byte*) main::BGCOL
(byte) main::i
(byte) main::i#1 16.5
(byte) main::i#2 22.0
(byte) main::j
(byte) main::j#1 16.5
(byte) main::j#2 22.0
(byte*) main::sc2
(byte*) main::screen

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

INITIAL ASM
  // File Comments
// Test some complex pointers
  // Basic 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 
  // [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: {
    // RValue pointer expression (constant)
    .label screen = $400
    // Increment on a const named pointer
    .label BGCOL = $d020
    .label i = 2
    .label j = 3
    // [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta i
    jmp b1
  // RValue pointer expression (variable)
    // [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] *((const byte*) main::screen#0 + (byte) main::i#2) ← *((const byte*) main::screen#0+(byte) $28 + (byte) main::i#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1 
    ldy i
    lda screen+$28,y
    sta screen,y
    // [7] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 
    inc i
    // [8] if((byte) main::i#1!=(byte) $b) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #$b
    cmp i
    bne b1_from_b1
    jmp b2
    // main::@2
  b2:
    // [9] *((const byte*) main::screen#0+(byte) $51) ← *((const byte*) main::screen#0+(byte) $79) -- _deref_pbuc1=_deref_pbuc2 
    lda screen+$79
    sta screen+$51
    // [10] *((const byte*) main::screen#0+(byte) $52) ← *((const byte*) main::screen#0+(byte) $7a) -- _deref_pbuc1=_deref_pbuc2 
    // LValue pointer expression (constant - directly)
    lda screen+$7a
    sta screen+$52
    // [11] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
  b3_from_b2:
    // [11] phi (byte) main::j#2 = (byte) 0 [phi:main::@2->main::@3#0] -- vbuz1=vbuc1 
    lda #0
    sta j
    jmp b3
  // LValue pointer expression (variable - directly)
    // [11] phi from main::@3 to main::@3 [phi:main::@3->main::@3]
  b3_from_b3:
    // [11] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@3->main::@3#0] -- register_copy 
    jmp b3
    // main::@3
  b3:
    // [12] *((const byte*) main::screen#0+(byte) $a0 + (byte) main::j#2) ← *((const byte*) main::screen#0+(byte) $c8 + (byte) main::j#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1 
    ldy j
    lda screen+$c8,y
    sta screen+$a0,y
    // [13] (byte) main::j#1 ← ++ (byte) main::j#2 -- vbuz1=_inc_vbuz1 
    inc j
    // [14] if((byte) main::j#1!=(byte) $b) goto main::@3 -- vbuz1_neq_vbuc1_then_la1 
    lda #$b
    cmp j
    bne b3_from_b3
    jmp b4
    // main::@4
  b4:
    // [15] *((byte*) 53280) ← ++ *((byte*) 53280) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc $d020
    // [16] *((byte*)(number) $d000+(number) $21) ← -- *((byte*)(number) $d000+(number) $21) -- _deref_pbuc1=_dec__deref_pbuc1 
    dec $d000+$21
    // [17] *((const byte*) main::BGCOL#0) ← ++ *((const byte*) main::BGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
    jmp breturn
    // main::@return
  breturn:
    // [18] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] *((const byte*) main::screen#0 + (byte) main::i#2) ← *((const byte*) main::screen#0+(byte) $28 + (byte) main::i#2) [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
Statement [9] *((const byte*) main::screen#0+(byte) $51) ← *((const byte*) main::screen#0+(byte) $79) [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [10] *((const byte*) main::screen#0+(byte) $52) ← *((const byte*) main::screen#0+(byte) $7a) [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [12] *((const byte*) main::screen#0+(byte) $a0 + (byte) main::j#2) ← *((const byte*) main::screen#0+(byte) $c8 + (byte) main::j#2) [ main::j#2 ] ( main:2 [ main::j#2 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:3 [ main::j#2 main::j#1 ]
Statement [6] *((const byte*) main::screen#0 + (byte) main::i#2) ← *((const byte*) main::screen#0+(byte) $28 + (byte) main::i#2) [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a 
Statement [9] *((const byte*) main::screen#0+(byte) $51) ← *((const byte*) main::screen#0+(byte) $79) [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [10] *((const byte*) main::screen#0+(byte) $52) ← *((const byte*) main::screen#0+(byte) $7a) [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [12] *((const byte*) main::screen#0+(byte) $a0 + (byte) main::j#2) ← *((const byte*) main::screen#0+(byte) $c8 + (byte) main::j#2) [ main::j#2 ] ( main:2 [ main::j#2 ] ) always clobbers reg byte a 
Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:3 [ main::j#2 main::j#1 ] : zp ZP_BYTE:3 , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 38.5: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 38.5: zp ZP_BYTE:3 [ main::j#2 main::j#1 ] 
Uplift Scope [] 

Uplifting [main] best 595 combination reg byte x [ main::i#2 main::i#1 ] reg byte x [ main::j#2 main::j#1 ] 
Uplifting [] best 595 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test some complex pointers
  // Basic 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 
  // [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: {
    // RValue pointer expression (constant)
    .label screen = $400
    // Increment on a const named pointer
    .label BGCOL = $d020
    // [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    jmp b1
  // RValue pointer expression (variable)
    // [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] *((const byte*) main::screen#0 + (byte) main::i#2) ← *((const byte*) main::screen#0+(byte) $28 + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx 
    lda screen+$28,x
    sta screen,x
    // [7] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [8] if((byte) main::i#1!=(byte) $b) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne b1_from_b1
    jmp b2
    // main::@2
  b2:
    // [9] *((const byte*) main::screen#0+(byte) $51) ← *((const byte*) main::screen#0+(byte) $79) -- _deref_pbuc1=_deref_pbuc2 
    lda screen+$79
    sta screen+$51
    // [10] *((const byte*) main::screen#0+(byte) $52) ← *((const byte*) main::screen#0+(byte) $7a) -- _deref_pbuc1=_deref_pbuc2 
    // LValue pointer expression (constant - directly)
    lda screen+$7a
    sta screen+$52
    // [11] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
  b3_from_b2:
    // [11] phi (byte) main::j#2 = (byte) 0 [phi:main::@2->main::@3#0] -- vbuxx=vbuc1 
    ldx #0
    jmp b3
  // LValue pointer expression (variable - directly)
    // [11] phi from main::@3 to main::@3 [phi:main::@3->main::@3]
  b3_from_b3:
    // [11] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@3->main::@3#0] -- register_copy 
    jmp b3
    // main::@3
  b3:
    // [12] *((const byte*) main::screen#0+(byte) $a0 + (byte) main::j#2) ← *((const byte*) main::screen#0+(byte) $c8 + (byte) main::j#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx 
    lda screen+$c8,x
    sta screen+$a0,x
    // [13] (byte) main::j#1 ← ++ (byte) main::j#2 -- vbuxx=_inc_vbuxx 
    inx
    // [14] if((byte) main::j#1!=(byte) $b) goto main::@3 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne b3_from_b3
    jmp b4
    // main::@4
  b4:
    // [15] *((byte*) 53280) ← ++ *((byte*) 53280) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc $d020
    // [16] *((byte*)(number) $d000+(number) $21) ← -- *((byte*)(number) $d000+(number) $21) -- _deref_pbuc1=_dec__deref_pbuc1 
    dec $d000+$21
    // [17] *((const byte*) main::BGCOL#0) ← ++ *((const byte*) main::BGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
    jmp breturn
    // main::@return
  breturn:
    // [18] return 
    rts
}
  // 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
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b1_from_b1 with b1
Replacing label b3_from_b3 with b3
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_b1:
Removing instruction b3_from_b3:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction b2:
Removing instruction b3_from_b2:
Removing instruction b4:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction jmp b1
Removing instruction jmp b3
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@return
(byte*) main::BGCOL
(const byte*) main::BGCOL#0 BGCOL = (byte*) 53280
(byte) main::i
(byte) main::i#1 reg byte x 16.5
(byte) main::i#2 reg byte x 22.0
(byte) main::j
(byte) main::j#1 reg byte x 16.5
(byte) main::j#2 reg byte x 22.0
(byte*) main::sc2
(byte*) main::screen
(const byte*) main::screen#0 screen = (byte*) 1024

reg byte x [ main::i#2 main::i#1 ]
reg byte x [ main::j#2 main::j#1 ]


FINAL ASSEMBLER
Score: 400

  // File Comments
// Test some complex pointers
  // Basic 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 
  // [4] phi from @1 to main [phi:@1->main]
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    // RValue pointer expression (constant)
    .label screen = $400
    // Increment on a const named pointer
    .label BGCOL = $d020
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
  // RValue pointer expression (variable)
    // [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy 
    // main::@1
  b1:
    // screen[i] = *(screen+40+i)
    // [6] *((const byte*) main::screen#0 + (byte) main::i#2) ← *((const byte*) main::screen#0+(byte) $28 + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx 
    lda screen+$28,x
    sta screen,x
    // for(byte i : 0..10)
    // [7] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [8] if((byte) main::i#1!=(byte) $b) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne b1
    // main::@2
    // *sc2 = *(screen+121)
    // [9] *((const byte*) main::screen#0+(byte) $51) ← *((const byte*) main::screen#0+(byte) $79) -- _deref_pbuc1=_deref_pbuc2 
    lda screen+$79
    sta screen+$51
    // *(screen+82) = *(screen+122)
    // [10] *((const byte*) main::screen#0+(byte) $52) ← *((const byte*) main::screen#0+(byte) $7a) -- _deref_pbuc1=_deref_pbuc2 
    // LValue pointer expression (constant - directly)
    lda screen+$7a
    sta screen+$52
    // [11] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
    // [11] phi (byte) main::j#2 = (byte) 0 [phi:main::@2->main::@3#0] -- vbuxx=vbuc1 
    ldx #0
  // LValue pointer expression (variable - directly)
    // [11] phi from main::@3 to main::@3 [phi:main::@3->main::@3]
    // [11] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@3->main::@3#0] -- register_copy 
    // main::@3
  b3:
    // *(screen+160+j) = *(screen+200+j)
    // [12] *((const byte*) main::screen#0+(byte) $a0 + (byte) main::j#2) ← *((const byte*) main::screen#0+(byte) $c8 + (byte) main::j#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx 
    lda screen+$c8,x
    sta screen+$a0,x
    // for(byte j : 0..10)
    // [13] (byte) main::j#1 ← ++ (byte) main::j#2 -- vbuxx=_inc_vbuxx 
    inx
    // [14] if((byte) main::j#1!=(byte) $b) goto main::@3 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne b3
    // main::@4
    // ++*(byte*)$d020;
    // [15] *((byte*) 53280) ← ++ *((byte*) 53280) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc $d020
    // --*(byte*)($d000+$21);
    // [16] *((byte*)(number) $d000+(number) $21) ← -- *((byte*)(number) $d000+(number) $21) -- _deref_pbuc1=_dec__deref_pbuc1 
    dec $d000+$21
    // ++*BGCOL;
    // [17] *((const byte*) main::BGCOL#0) ← ++ *((const byte*) main::BGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
    // main::@return
    // }
    // [18] return 
    rts
}
  // File Data

