Culled Empty Block (label) main::@4

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@1
main: scope:[main]  from @1
  (byte*) main::screen#0 ← ((byte*)) (number) $400
  (byte*) main::colors#0 ← ((byte*)) (number) $d800
  (byte) main::color#0 ← (number) 1
  (byte) main::row#0 ← (byte) 0
  to:main::@1
main::@1: scope:[main]  from main main::@3
  (byte) main::row#4 ← phi( main/(byte) main::row#0 main::@3/(byte) main::row#1 )
  (byte*) main::colors#4 ← phi( main/(byte*) main::colors#0 main::@3/(byte*) main::colors#1 )
  (byte) main::color#5 ← phi( main/(byte) main::color#0 main::@3/(byte) main::color#2 )
  (byte*) main::screen#4 ← phi( main/(byte*) main::screen#0 main::@3/(byte*) main::screen#1 )
  (byte) main::column#0 ← (byte) 0
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@2
  (byte) main::row#3 ← phi( main::@1/(byte) main::row#4 main::@2/(byte) main::row#3 )
  (byte*) main::colors#2 ← phi( main::@1/(byte*) main::colors#4 main::@2/(byte*) main::colors#2 )
  (byte) main::color#3 ← phi( main::@1/(byte) main::color#5 main::@2/(byte) main::color#1 )
  (byte) main::column#2 ← phi( main::@1/(byte) main::column#0 main::@2/(byte) main::column#1 )
  (byte*) main::screen#2 ← phi( main::@1/(byte*) main::screen#4 main::@2/(byte*) main::screen#2 )
  *((byte*) main::screen#2 + (byte) main::column#2) ← (number) $a0
  *((byte*) main::colors#2 + (byte) main::column#2) ← (byte) main::color#3
  (number~) main::$0 ← (byte) main::color#3 ^ (number) 1
  (byte) main::color#1 ← (number~) main::$0
  (byte) main::column#1 ← (byte) main::column#2 + rangenext(0,7)
  (bool~) main::$1 ← (byte) main::column#1 != rangelast(0,7)
  if((bool~) main::$1) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@2
  (byte) main::row#2 ← phi( main::@2/(byte) main::row#3 )
  (byte*) main::colors#3 ← phi( main::@2/(byte*) main::colors#2 )
  (byte*) main::screen#3 ← phi( main::@2/(byte*) main::screen#2 )
  (byte) main::color#4 ← phi( main::@2/(byte) main::color#1 )
  (number~) main::$2 ← (byte) main::color#4 ^ (number) 1
  (byte) main::color#2 ← (number~) main::$2
  (byte*~) main::$3 ← (byte*) main::screen#3 + (number) $28
  (byte*) main::screen#1 ← (byte*~) main::$3
  (byte*~) main::$4 ← (byte*) main::colors#3 + (number) $28
  (byte*) main::colors#1 ← (byte*~) main::$4
  (byte) main::row#1 ← (byte) main::row#2 + rangenext(0,7)
  (bool~) main::$5 ← (byte) main::row#1 != rangelast(0,7)
  if((bool~) main::$5) goto main::@1
  to:main::@return
main::@return: scope:[main]  from 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()
(number~) main::$0
(bool~) main::$1
(number~) main::$2
(byte*~) main::$3
(byte*~) main::$4
(bool~) main::$5
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte) main::color
(byte) main::color#0
(byte) main::color#1
(byte) main::color#2
(byte) main::color#3
(byte) main::color#4
(byte) main::color#5
(byte*) main::colors
(byte*) main::colors#0
(byte*) main::colors#1
(byte*) main::colors#2
(byte*) main::colors#3
(byte*) main::colors#4
(byte) main::column
(byte) main::column#0
(byte) main::column#1
(byte) main::column#2
(byte) main::row
(byte) main::row#0
(byte) main::row#1
(byte) main::row#2
(byte) main::row#3
(byte) main::row#4
(byte*) main::screen
(byte*) main::screen#0
(byte*) main::screen#1
(byte*) main::screen#2
(byte*) main::screen#3
(byte*) main::screen#4

Adding number conversion cast (unumber) 1 in (byte) main::color#0 ← (number) 1
Adding number conversion cast (unumber) $a0 in *((byte*) main::screen#2 + (byte) main::column#2) ← (number) $a0
Adding number conversion cast (unumber) 1 in (number~) main::$0 ← (byte) main::color#3 ^ (number) 1
Adding number conversion cast (unumber) main::$0 in (number~) main::$0 ← (byte) main::color#3 ^ (unumber)(number) 1
Adding number conversion cast (unumber) 1 in (number~) main::$2 ← (byte) main::color#4 ^ (number) 1
Adding number conversion cast (unumber) main::$2 in (number~) main::$2 ← (byte) main::color#4 ^ (unumber)(number) 1
Adding number conversion cast (unumber) $28 in (byte*~) main::$3 ← (byte*) main::screen#3 + (number) $28
Adding number conversion cast (unumber) $28 in (byte*~) main::$4 ← (byte*) main::colors#3 + (number) $28
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) main::screen#0 ← (byte*)(number) $400
Inlining cast (byte*) main::colors#0 ← (byte*)(number) $d800
Inlining cast (byte) main::color#0 ← (unumber)(number) 1
Inlining cast *((byte*) main::screen#2 + (byte) main::column#2) ← (unumber)(number) $a0
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (byte*) 55296
Simplifying constant integer cast 1
Simplifying constant integer cast $a0
Simplifying constant integer cast 1
Simplifying constant integer cast 1
Simplifying constant integer cast $28
Simplifying constant integer cast $28
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) $a0
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) $28
Finalized unsigned number type (byte) $28
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) main::$0 ← (byte) main::color#3 ^ (byte) 1
Inferred type updated to byte in (unumber~) main::$2 ← (byte) main::color#4 ^ (byte) 1
Alias (byte) main::color#1 = (byte~) main::$0 (byte) main::color#4 
Alias (byte*) main::screen#2 = (byte*) main::screen#3 
Alias (byte*) main::colors#2 = (byte*) main::colors#3 
Alias (byte) main::row#2 = (byte) main::row#3 
Alias (byte) main::color#2 = (byte~) main::$2 
Alias (byte*) main::screen#1 = (byte*~) main::$3 
Alias (byte*) main::colors#1 = (byte*~) main::$4 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte*) main::screen#2 (byte*) main::screen#4
Identical Phi Values (byte*) main::colors#2 (byte*) main::colors#4
Identical Phi Values (byte) main::row#2 (byte) main::row#4
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$1 [13] if((byte) main::column#1!=rangelast(0,7)) goto main::@2
Simple Condition (bool~) main::$5 [23] if((byte) main::row#1!=rangelast(0,7)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) main::screen#0 = (byte*) 1024
Constant (const byte*) main::colors#0 = (byte*) 55296
Constant (const byte) main::color#0 = 1
Constant (const byte) main::row#0 = 0
Constant (const byte) main::column#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [11] main::column#1 ← ++ main::column#2 to ++
Resolved ranged comparison value [13] if(main::column#1!=rangelast(0,7)) goto main::@2 to (number) 8
Resolved ranged next value [21] main::row#1 ← ++ main::row#4 to ++
Resolved ranged comparison value [23] if(main::row#1!=rangelast(0,7)) goto main::@1 to (number) 8
Adding number conversion cast (unumber) 8 in if((byte) main::column#1!=(number) 8) goto main::@2
Adding number conversion cast (unumber) 8 in if((byte) main::row#1!=(number) 8) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 8
Simplifying constant integer cast 8
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 8
Finalized unsigned number type (byte) 8
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inlining constant with var siblings (const byte*) main::screen#0
Inlining constant with var siblings (const byte*) main::colors#0
Inlining constant with var siblings (const byte) main::color#0
Inlining constant with var siblings (const byte) main::row#0
Inlining constant with var siblings (const byte) main::column#0
Constant inlined main::screen#0 = (byte*) 1024
Constant inlined main::colors#0 = (byte*) 55296
Constant inlined main::color#0 = (byte) 1
Constant inlined main::row#0 = (byte) 0
Constant inlined main::column#0 = (byte) 0
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@5(between main::@3 and main::@1)
Added new block during phi lifting main::@6(between main::@2 and main::@2)
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 6 initial phi equivalence classes
Coalesced [7] main::color#7 ← main::color#5
Coalesced [20] main::screen#5 ← main::screen#1
Coalesced [21] main::color#6 ← main::color#2
Coalesced [22] main::colors#5 ← main::colors#1
Coalesced [23] main::row#5 ← main::row#1
Coalesced [24] main::column#3 ← main::column#1
Coalesced [25] main::color#8 ← main::color#1
Coalesced down to 5 phi equivalence classes
Culled Empty Block (label) @2
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@6
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::@3
  [5] (byte) main::row#4 ← phi( main/(byte) 0 main::@3/(byte) main::row#1 )
  [5] (byte*) main::colors#4 ← phi( main/(byte*) 55296 main::@3/(byte*) main::colors#1 )
  [5] (byte) main::color#5 ← phi( main/(byte) 1 main::@3/(byte) main::color#2 )
  [5] (byte*) main::screen#4 ← phi( main/(byte*) 1024 main::@3/(byte*) main::screen#1 )
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@2
  [6] (byte) main::color#3 ← phi( main::@1/(byte) main::color#5 main::@2/(byte) main::color#1 )
  [6] (byte) main::column#2 ← phi( main::@1/(byte) 0 main::@2/(byte) main::column#1 )
  [7] *((byte*) main::screen#4 + (byte) main::column#2) ← (byte) $a0
  [8] *((byte*) main::colors#4 + (byte) main::column#2) ← (byte) main::color#3
  [9] (byte) main::color#1 ← (byte) main::color#3 ^ (byte) 1
  [10] (byte) main::column#1 ← ++ (byte) main::column#2
  [11] if((byte) main::column#1!=(byte) 8) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@2
  [12] (byte) main::color#2 ← (byte) main::color#1 ^ (byte) 1
  [13] (byte*) main::screen#1 ← (byte*) main::screen#4 + (byte) $28
  [14] (byte*) main::colors#1 ← (byte*) main::colors#4 + (byte) $28
  [15] (byte) main::row#1 ← ++ (byte) main::row#4
  [16] if((byte) main::row#1!=(byte) 8) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@3
  [17] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(byte) main::color
(byte) main::color#1 71.0
(byte) main::color#2 4.4
(byte) main::color#3 104.66666666666666
(byte) main::color#5 22.0
(byte*) main::colors
(byte*) main::colors#1 7.333333333333333
(byte*) main::colors#4 13.666666666666664
(byte) main::column
(byte) main::column#1 151.5
(byte) main::column#2 101.0
(byte) main::row
(byte) main::row#1 16.5
(byte) main::row#4 2.2
(byte*) main::screen
(byte*) main::screen#1 5.5
(byte*) main::screen#4 15.375

Initial phi equivalence classes
[ main::screen#4 main::screen#1 ]
[ main::colors#4 main::colors#1 ]
[ main::row#4 main::row#1 ]
[ main::column#2 main::column#1 ]
[ main::color#3 main::color#5 main::color#2 main::color#1 ]
Complete equivalence classes
[ main::screen#4 main::screen#1 ]
[ main::colors#4 main::colors#1 ]
[ main::row#4 main::row#1 ]
[ main::column#2 main::column#1 ]
[ main::color#3 main::color#5 main::color#2 main::color#1 ]
Allocated zp ZP_WORD:2 [ main::screen#4 main::screen#1 ]
Allocated zp ZP_WORD:4 [ main::colors#4 main::colors#1 ]
Allocated zp ZP_BYTE:6 [ main::row#4 main::row#1 ]
Allocated zp ZP_BYTE:7 [ main::column#2 main::column#1 ]
Allocated zp ZP_BYTE:8 [ main::color#3 main::color#5 main::color#2 main::color#1 ]

INITIAL ASM
Target platform is c64basic
  // File Comments
// Draws a chess board in the upper left corner of the screen
  // 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: {
    .label color = 8
    .label column = 7
    .label screen = 2
    .label colors = 4
    .label row = 6
    // [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [5] phi (byte) main::row#4 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z row
    // [5] phi (byte*) main::colors#4 = (byte*) 55296 [phi:main->main::@1#1] -- pbuz1=pbuc1 
    lda #<$d800
    sta.z colors
    lda #>$d800
    sta.z colors+1
    // [5] phi (byte) main::color#5 = (byte) 1 [phi:main->main::@1#2] -- vbuz1=vbuc1 
    lda #1
    sta.z color
    // [5] phi (byte*) main::screen#4 = (byte*) 1024 [phi:main->main::@1#3] -- pbuz1=pbuc1 
    lda #<$400
    sta.z screen
    lda #>$400
    sta.z screen+1
    jmp b1
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  b1_from_b3:
    // [5] phi (byte) main::row#4 = (byte) main::row#1 [phi:main::@3->main::@1#0] -- register_copy 
    // [5] phi (byte*) main::colors#4 = (byte*) main::colors#1 [phi:main::@3->main::@1#1] -- register_copy 
    // [5] phi (byte) main::color#5 = (byte) main::color#2 [phi:main::@3->main::@1#2] -- register_copy 
    // [5] phi (byte*) main::screen#4 = (byte*) main::screen#1 [phi:main::@3->main::@1#3] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
    // [6] phi (byte) main::color#3 = (byte) main::color#5 [phi:main::@1->main::@2#0] -- register_copy 
    // [6] phi (byte) main::column#2 = (byte) 0 [phi:main::@1->main::@2#1] -- vbuz1=vbuc1 
    lda #0
    sta.z column
    jmp b2
    // [6] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
  b2_from_b2:
    // [6] phi (byte) main::color#3 = (byte) main::color#1 [phi:main::@2->main::@2#0] -- register_copy 
    // [6] phi (byte) main::column#2 = (byte) main::column#1 [phi:main::@2->main::@2#1] -- register_copy 
    jmp b2
    // main::@2
  b2:
    // [7] *((byte*) main::screen#4 + (byte) main::column#2) ← (byte) $a0 -- pbuz1_derefidx_vbuz2=vbuc1 
    lda #$a0
    ldy.z column
    sta (screen),y
    // [8] *((byte*) main::colors#4 + (byte) main::column#2) ← (byte) main::color#3 -- pbuz1_derefidx_vbuz2=vbuz3 
    lda.z color
    ldy.z column
    sta (colors),y
    // [9] (byte) main::color#1 ← (byte) main::color#3 ^ (byte) 1 -- vbuz1=vbuz1_bxor_vbuc1 
    lda #1
    eor.z color
    sta.z color
    // [10] (byte) main::column#1 ← ++ (byte) main::column#2 -- vbuz1=_inc_vbuz1 
    inc.z column
    // [11] if((byte) main::column#1!=(byte) 8) goto main::@2 -- vbuz1_neq_vbuc1_then_la1 
    lda #8
    cmp.z column
    bne b2_from_b2
    jmp b3
    // main::@3
  b3:
    // [12] (byte) main::color#2 ← (byte) main::color#1 ^ (byte) 1 -- vbuz1=vbuz1_bxor_vbuc1 
    lda #1
    eor.z color
    sta.z color
    // [13] (byte*) main::screen#1 ← (byte*) main::screen#4 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 
    lda #$28
    clc
    adc.z screen
    sta.z screen
    bcc !+
    inc.z screen+1
  !:
    // [14] (byte*) main::colors#1 ← (byte*) main::colors#4 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 
    lda #$28
    clc
    adc.z colors
    sta.z colors
    bcc !+
    inc.z colors+1
  !:
    // [15] (byte) main::row#1 ← ++ (byte) main::row#4 -- vbuz1=_inc_vbuz1 
    inc.z row
    // [16] if((byte) main::row#1!=(byte) 8) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #8
    cmp.z row
    bne b1_from_b3
    jmp breturn
    // main::@return
  breturn:
    // [17] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [7] *((byte*) main::screen#4 + (byte) main::column#2) ← (byte) $a0 [ main::screen#4 main::colors#4 main::row#4 main::column#2 main::color#3 ] ( main:2 [ main::screen#4 main::colors#4 main::row#4 main::column#2 main::color#3 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:6 [ main::row#4 main::row#1 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:7 [ main::column#2 main::column#1 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:8 [ main::color#3 main::color#5 main::color#2 main::color#1 ]
Statement [8] *((byte*) main::colors#4 + (byte) main::column#2) ← (byte) main::color#3 [ main::screen#4 main::colors#4 main::row#4 main::column#2 main::color#3 ] ( main:2 [ main::screen#4 main::colors#4 main::row#4 main::column#2 main::color#3 ] ) always clobbers reg byte a 
Statement [9] (byte) main::color#1 ← (byte) main::color#3 ^ (byte) 1 [ main::screen#4 main::colors#4 main::row#4 main::column#2 main::color#1 ] ( main:2 [ main::screen#4 main::colors#4 main::row#4 main::column#2 main::color#1 ] ) always clobbers reg byte a 
Statement [12] (byte) main::color#2 ← (byte) main::color#1 ^ (byte) 1 [ main::screen#4 main::colors#4 main::row#4 main::color#2 ] ( main:2 [ main::screen#4 main::colors#4 main::row#4 main::color#2 ] ) always clobbers reg byte a 
Statement [13] (byte*) main::screen#1 ← (byte*) main::screen#4 + (byte) $28 [ main::colors#4 main::row#4 main::screen#1 main::color#2 ] ( main:2 [ main::colors#4 main::row#4 main::screen#1 main::color#2 ] ) always clobbers reg byte a 
Statement [14] (byte*) main::colors#1 ← (byte*) main::colors#4 + (byte) $28 [ main::row#4 main::screen#1 main::color#2 main::colors#1 ] ( main:2 [ main::row#4 main::screen#1 main::color#2 main::colors#1 ] ) always clobbers reg byte a 
Statement [7] *((byte*) main::screen#4 + (byte) main::column#2) ← (byte) $a0 [ main::screen#4 main::colors#4 main::row#4 main::column#2 main::color#3 ] ( main:2 [ main::screen#4 main::colors#4 main::row#4 main::column#2 main::color#3 ] ) always clobbers reg byte a 
Statement [8] *((byte*) main::colors#4 + (byte) main::column#2) ← (byte) main::color#3 [ main::screen#4 main::colors#4 main::row#4 main::column#2 main::color#3 ] ( main:2 [ main::screen#4 main::colors#4 main::row#4 main::column#2 main::color#3 ] ) always clobbers reg byte a 
Statement [9] (byte) main::color#1 ← (byte) main::color#3 ^ (byte) 1 [ main::screen#4 main::colors#4 main::row#4 main::column#2 main::color#1 ] ( main:2 [ main::screen#4 main::colors#4 main::row#4 main::column#2 main::color#1 ] ) always clobbers reg byte a 
Statement [12] (byte) main::color#2 ← (byte) main::color#1 ^ (byte) 1 [ main::screen#4 main::colors#4 main::row#4 main::color#2 ] ( main:2 [ main::screen#4 main::colors#4 main::row#4 main::color#2 ] ) always clobbers reg byte a 
Statement [13] (byte*) main::screen#1 ← (byte*) main::screen#4 + (byte) $28 [ main::colors#4 main::row#4 main::screen#1 main::color#2 ] ( main:2 [ main::colors#4 main::row#4 main::screen#1 main::color#2 ] ) always clobbers reg byte a 
Statement [14] (byte*) main::colors#1 ← (byte*) main::colors#4 + (byte) $28 [ main::row#4 main::screen#1 main::color#2 main::colors#1 ] ( main:2 [ main::row#4 main::screen#1 main::color#2 main::colors#1 ] ) always clobbers reg byte a 
Potential registers zp ZP_WORD:2 [ main::screen#4 main::screen#1 ] : zp ZP_WORD:2 , 
Potential registers zp ZP_WORD:4 [ main::colors#4 main::colors#1 ] : zp ZP_WORD:4 , 
Potential registers zp ZP_BYTE:6 [ main::row#4 main::row#1 ] : zp ZP_BYTE:6 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:7 [ main::column#2 main::column#1 ] : zp ZP_BYTE:7 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:8 [ main::color#3 main::color#5 main::color#2 main::color#1 ] : zp ZP_BYTE:8 , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 252.5: zp ZP_BYTE:7 [ main::column#2 main::column#1 ] 202.07: zp ZP_BYTE:8 [ main::color#3 main::color#5 main::color#2 main::color#1 ] 21: zp ZP_WORD:4 [ main::colors#4 main::colors#1 ] 20.88: zp ZP_WORD:2 [ main::screen#4 main::screen#1 ] 18.7: zp ZP_BYTE:6 [ main::row#4 main::row#1 ] 
Uplift Scope [] 

Uplifting [main] best 4863 combination reg byte y [ main::column#2 main::column#1 ] reg byte x [ main::color#3 main::color#5 main::color#2 main::color#1 ] zp ZP_WORD:4 [ main::colors#4 main::colors#1 ] zp ZP_WORD:2 [ main::screen#4 main::screen#1 ] zp ZP_BYTE:6 [ main::row#4 main::row#1 ] 
Uplifting [] best 4863 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:6 [ main::row#4 main::row#1 ]
Uplifting [main] best 4863 combination zp ZP_BYTE:6 [ main::row#4 main::row#1 ] 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Draws a chess board in the upper left corner of the screen
  // 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: {
    .label screen = 2
    .label colors = 4
    .label row = 6
    // [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [5] phi (byte) main::row#4 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z row
    // [5] phi (byte*) main::colors#4 = (byte*) 55296 [phi:main->main::@1#1] -- pbuz1=pbuc1 
    lda #<$d800
    sta.z colors
    lda #>$d800
    sta.z colors+1
    // [5] phi (byte) main::color#5 = (byte) 1 [phi:main->main::@1#2] -- vbuxx=vbuc1 
    ldx #1
    // [5] phi (byte*) main::screen#4 = (byte*) 1024 [phi:main->main::@1#3] -- pbuz1=pbuc1 
    lda #<$400
    sta.z screen
    lda #>$400
    sta.z screen+1
    jmp b1
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  b1_from_b3:
    // [5] phi (byte) main::row#4 = (byte) main::row#1 [phi:main::@3->main::@1#0] -- register_copy 
    // [5] phi (byte*) main::colors#4 = (byte*) main::colors#1 [phi:main::@3->main::@1#1] -- register_copy 
    // [5] phi (byte) main::color#5 = (byte) main::color#2 [phi:main::@3->main::@1#2] -- register_copy 
    // [5] phi (byte*) main::screen#4 = (byte*) main::screen#1 [phi:main::@3->main::@1#3] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
    // [6] phi (byte) main::color#3 = (byte) main::color#5 [phi:main::@1->main::@2#0] -- register_copy 
    // [6] phi (byte) main::column#2 = (byte) 0 [phi:main::@1->main::@2#1] -- vbuyy=vbuc1 
    ldy #0
    jmp b2
    // [6] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
  b2_from_b2:
    // [6] phi (byte) main::color#3 = (byte) main::color#1 [phi:main::@2->main::@2#0] -- register_copy 
    // [6] phi (byte) main::column#2 = (byte) main::column#1 [phi:main::@2->main::@2#1] -- register_copy 
    jmp b2
    // main::@2
  b2:
    // [7] *((byte*) main::screen#4 + (byte) main::column#2) ← (byte) $a0 -- pbuz1_derefidx_vbuyy=vbuc1 
    lda #$a0
    sta (screen),y
    // [8] *((byte*) main::colors#4 + (byte) main::column#2) ← (byte) main::color#3 -- pbuz1_derefidx_vbuyy=vbuxx 
    txa
    sta (colors),y
    // [9] (byte) main::color#1 ← (byte) main::color#3 ^ (byte) 1 -- vbuxx=vbuxx_bxor_vbuc1 
    txa
    eor #1
    tax
    // [10] (byte) main::column#1 ← ++ (byte) main::column#2 -- vbuyy=_inc_vbuyy 
    iny
    // [11] if((byte) main::column#1!=(byte) 8) goto main::@2 -- vbuyy_neq_vbuc1_then_la1 
    cpy #8
    bne b2_from_b2
    jmp b3
    // main::@3
  b3:
    // [12] (byte) main::color#2 ← (byte) main::color#1 ^ (byte) 1 -- vbuxx=vbuxx_bxor_vbuc1 
    txa
    eor #1
    tax
    // [13] (byte*) main::screen#1 ← (byte*) main::screen#4 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 
    lda #$28
    clc
    adc.z screen
    sta.z screen
    bcc !+
    inc.z screen+1
  !:
    // [14] (byte*) main::colors#1 ← (byte*) main::colors#4 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 
    lda #$28
    clc
    adc.z colors
    sta.z colors
    bcc !+
    inc.z colors+1
  !:
    // [15] (byte) main::row#1 ← ++ (byte) main::row#4 -- vbuz1=_inc_vbuz1 
    inc.z row
    // [16] if((byte) main::row#1!=(byte) 8) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #8
    cmp.z row
    bne b1_from_b3
    jmp breturn
    // main::@return
  breturn:
    // [17] 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 breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b2_from_b2 with b2
Replacing label b1_from_b3 with b1
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_b3:
Removing instruction b2_from_b1:
Removing instruction b2_from_b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction b3:
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 b2
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::@return
(byte) main::color
(byte) main::color#1 reg byte x 71.0
(byte) main::color#2 reg byte x 4.4
(byte) main::color#3 reg byte x 104.66666666666666
(byte) main::color#5 reg byte x 22.0
(byte*) main::colors
(byte*) main::colors#1 colors zp ZP_WORD:4 7.333333333333333
(byte*) main::colors#4 colors zp ZP_WORD:4 13.666666666666664
(byte) main::column
(byte) main::column#1 reg byte y 151.5
(byte) main::column#2 reg byte y 101.0
(byte) main::row
(byte) main::row#1 row zp ZP_BYTE:6 16.5
(byte) main::row#4 row zp ZP_BYTE:6 2.2
(byte*) main::screen
(byte*) main::screen#1 screen zp ZP_WORD:2 5.5
(byte*) main::screen#4 screen zp ZP_WORD:2 15.375

zp ZP_WORD:2 [ main::screen#4 main::screen#1 ]
zp ZP_WORD:4 [ main::colors#4 main::colors#1 ]
zp ZP_BYTE:6 [ main::row#4 main::row#1 ]
reg byte y [ main::column#2 main::column#1 ]
reg byte x [ main::color#3 main::color#5 main::color#2 main::color#1 ]


FINAL ASSEMBLER
Score: 3861

  // File Comments
// Draws a chess board in the upper left corner of the screen
  // 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: {
    .label screen = 2
    .label colors = 4
    .label row = 6
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // [5] phi (byte) main::row#4 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z row
    // [5] phi (byte*) main::colors#4 = (byte*) 55296 [phi:main->main::@1#1] -- pbuz1=pbuc1 
    lda #<$d800
    sta.z colors
    lda #>$d800
    sta.z colors+1
    // [5] phi (byte) main::color#5 = (byte) 1 [phi:main->main::@1#2] -- vbuxx=vbuc1 
    ldx #1
    // [5] phi (byte*) main::screen#4 = (byte*) 1024 [phi:main->main::@1#3] -- pbuz1=pbuc1 
    lda #<$400
    sta.z screen
    lda #>$400
    sta.z screen+1
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
    // [5] phi (byte) main::row#4 = (byte) main::row#1 [phi:main::@3->main::@1#0] -- register_copy 
    // [5] phi (byte*) main::colors#4 = (byte*) main::colors#1 [phi:main::@3->main::@1#1] -- register_copy 
    // [5] phi (byte) main::color#5 = (byte) main::color#2 [phi:main::@3->main::@1#2] -- register_copy 
    // [5] phi (byte*) main::screen#4 = (byte*) main::screen#1 [phi:main::@3->main::@1#3] -- register_copy 
    // main::@1
  b1:
    // [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
    // [6] phi (byte) main::color#3 = (byte) main::color#5 [phi:main::@1->main::@2#0] -- register_copy 
    // [6] phi (byte) main::column#2 = (byte) 0 [phi:main::@1->main::@2#1] -- vbuyy=vbuc1 
    ldy #0
    // [6] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
    // [6] phi (byte) main::color#3 = (byte) main::color#1 [phi:main::@2->main::@2#0] -- register_copy 
    // [6] phi (byte) main::column#2 = (byte) main::column#1 [phi:main::@2->main::@2#1] -- register_copy 
    // main::@2
  b2:
    // screen[column] = $a0
    // [7] *((byte*) main::screen#4 + (byte) main::column#2) ← (byte) $a0 -- pbuz1_derefidx_vbuyy=vbuc1 
    lda #$a0
    sta (screen),y
    // colors[column] = color
    // [8] *((byte*) main::colors#4 + (byte) main::column#2) ← (byte) main::color#3 -- pbuz1_derefidx_vbuyy=vbuxx 
    txa
    sta (colors),y
    // color = color^1
    // [9] (byte) main::color#1 ← (byte) main::color#3 ^ (byte) 1 -- vbuxx=vbuxx_bxor_vbuc1 
    txa
    eor #1
    tax
    // for( byte column: 0..7)
    // [10] (byte) main::column#1 ← ++ (byte) main::column#2 -- vbuyy=_inc_vbuyy 
    iny
    // [11] if((byte) main::column#1!=(byte) 8) goto main::@2 -- vbuyy_neq_vbuc1_then_la1 
    cpy #8
    bne b2
    // main::@3
    // color = color^1
    // [12] (byte) main::color#2 ← (byte) main::color#1 ^ (byte) 1 -- vbuxx=vbuxx_bxor_vbuc1 
    txa
    eor #1
    tax
    // screen = screen+40
    // [13] (byte*) main::screen#1 ← (byte*) main::screen#4 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 
    lda #$28
    clc
    adc.z screen
    sta.z screen
    bcc !+
    inc.z screen+1
  !:
    // colors = colors+40
    // [14] (byte*) main::colors#1 ← (byte*) main::colors#4 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 
    lda #$28
    clc
    adc.z colors
    sta.z colors
    bcc !+
    inc.z colors+1
  !:
    // for( byte row: 0..7)
    // [15] (byte) main::row#1 ← ++ (byte) main::row#4 -- vbuz1=_inc_vbuz1 
    inc.z row
    // [16] if((byte) main::row#1!=(byte) 8) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #8
    cmp.z row
    bne b1
    // main::@return
    // }
    // [17] return 
    rts
}
  // File Data

