Identified constant variable (byte*) SCREEN
Culled Empty Block (label) main::@4

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

(void()) main()
main: scope:[main]  from @1
  (byte) main::y#0 ← (byte) 5
  to:main::@1
main::@1: scope:[main]  from main main::@3
  (byte) main::y#2 ← phi( main/(byte) main::y#0 main::@3/(byte) main::y#1 )
  (word~) main::$0 ← ((word)) (byte) main::y#2
  (number~) main::$1 ← (word~) main::$0 * (number) $28
  (byte*~) main::$2 ← (const byte*) SCREEN + (number~) main::$1
  (byte*) main::line#0 ← (byte*~) main::$2
  (byte) main::x#0 ← (byte) 5
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@2
  (byte*) main::line#1 ← phi( main::@1/(byte*) main::line#0 main::@2/(byte*) main::line#1 )
  (byte) main::y#3 ← phi( main::@1/(byte) main::y#2 main::@2/(byte) main::y#3 )
  (byte) main::x#2 ← phi( main::@1/(byte) main::x#0 main::@2/(byte) main::x#1 )
  (byte~) main::$3 ← (byte) main::x#2 + (byte) main::y#3
  *((byte*) main::line#1 + (byte) main::x#2) ← (byte~) main::$3
  (byte) main::x#1 ← (byte) main::x#2 + rangenext(5,$f)
  (bool~) main::$4 ← (byte) main::x#1 != rangelast(5,$f)
  if((bool~) main::$4) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@2
  (byte) main::y#4 ← phi( main::@2/(byte) main::y#3 )
  (byte) main::y#1 ← (byte) main::y#4 + rangenext(5,$f)
  (bool~) main::$5 ← (byte) main::y#1 != rangelast(5,$f)
  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
(const byte*) SCREEN = (byte*)(number) $400
(void()) main()
(word~) main::$0
(number~) main::$1
(byte*~) main::$2
(byte~) main::$3
(bool~) main::$4
(bool~) main::$5
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte*) main::line
(byte*) main::line#0
(byte*) main::line#1
(byte) main::x
(byte) main::x#0
(byte) main::x#1
(byte) main::x#2
(byte) main::y
(byte) main::y#0
(byte) main::y#1
(byte) main::y#2
(byte) main::y#3
(byte) main::y#4

Adding number conversion cast (unumber) $28 in (number~) main::$1 ← (word~) main::$0 * (number) $28
Adding number conversion cast (unumber) main::$1 in (number~) main::$1 ← (word~) main::$0 * (unumber)(number) $28
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (word~) main::$0 ← (word)(byte) main::y#2
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast $28
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $28
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to word in (unumber~) main::$1 ← (word~) main::$0 * (byte) $28
Alias (byte*) main::line#0 = (byte*~) main::$2 
Alias (byte) main::y#3 = (byte) main::y#4 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) main::y#3 (byte) main::y#2
Identical Phi Values (byte*) main::line#1 (byte*) main::line#0
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$4 [11] if((byte) main::x#1!=rangelast(5,$f)) goto main::@2
Simple Condition (bool~) main::$5 [14] if((byte) main::y#1!=rangelast(5,$f)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) main::y#0 = 5
Constant (const byte) main::x#0 = 5
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [9] main::x#1 ← ++ main::x#2 to ++
Resolved ranged comparison value [11] if(main::x#1!=rangelast(5,$f)) goto main::@2 to (number) $10
Resolved ranged next value [12] main::y#1 ← ++ main::y#2 to ++
Resolved ranged comparison value [14] if(main::y#1!=rangelast(5,$f)) goto main::@1 to (number) $10
Adding number conversion cast (unumber) $10 in if((byte) main::x#1!=(number) $10) goto main::@2
Adding number conversion cast (unumber) $10 in if((byte) main::y#1!=(number) $10) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast $10
Simplifying constant integer cast $10
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $10
Finalized unsigned number type (byte) $10
Successful SSA optimization PassNFinalizeNumberTypeConversions
Rewriting multiplication to use shift and addition[2] (word~) main::$1 ← (word~) main::$0 * (byte) $28
Inlining constant with var siblings (const byte) main::y#0
Inlining constant with var siblings (const byte) main::x#0
Constant inlined main::x#0 = (byte) 5
Constant inlined main::y#0 = (byte) 5
Successful SSA optimization Pass2ConstantInlining
Alias (word~) main::$1 = (word~) main::$8 
Successful SSA optimization Pass2AliasElimination
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 2 initial phi equivalence classes
Coalesced [20] main::y#5 ← main::y#1
Coalesced [21] main::x#3 ← main::x#1
Coalesced down to 2 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()

(void()) main()
main: scope:[main]  from @1
  [4] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@3
  [5] (byte) main::y#2 ← phi( main/(byte) 5 main::@3/(byte) main::y#1 )
  [6] (word~) main::$0 ← (word)(byte) main::y#2
  [7] (word~) main::$6 ← (word~) main::$0 << (byte) 2
  [8] (word~) main::$7 ← (word~) main::$6 + (word~) main::$0
  [9] (word~) main::$1 ← (word~) main::$7 << (byte) 3
  [10] (byte*) main::line#0 ← (const byte*) SCREEN + (word~) main::$1
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@2
  [11] (byte) main::x#2 ← phi( main::@1/(byte) 5 main::@2/(byte) main::x#1 )
  [12] (byte~) main::$3 ← (byte) main::x#2 + (byte) main::y#2
  [13] *((byte*) main::line#0 + (byte) main::x#2) ← (byte~) main::$3
  [14] (byte) main::x#1 ← ++ (byte) main::x#2
  [15] if((byte) main::x#1!=(byte) $10) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@2
  [16] (byte) main::y#1 ← ++ (byte) main::y#2
  [17] if((byte) main::y#1!=(byte) $10) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@3
  [18] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(word~) main::$0 16.5
(word~) main::$1 22.0
(byte~) main::$3 202.0
(word~) main::$6 22.0
(word~) main::$7 22.0
(byte*) main::line
(byte*) main::line#0 18.666666666666664
(byte) main::x
(byte) main::x#1 151.5
(byte) main::x#2 134.66666666666666
(byte) main::y
(byte) main::y#1 16.5
(byte) main::y#2 11.181818181818182

Initial phi equivalence classes
[ main::y#2 main::y#1 ]
[ main::x#2 main::x#1 ]
Added variable main::$0 to live range equivalence class [ main::$0 ]
Added variable main::$6 to live range equivalence class [ main::$6 ]
Added variable main::$7 to live range equivalence class [ main::$7 ]
Added variable main::$1 to live range equivalence class [ main::$1 ]
Added variable main::line#0 to live range equivalence class [ main::line#0 ]
Added variable main::$3 to live range equivalence class [ main::$3 ]
Complete equivalence classes
[ main::y#2 main::y#1 ]
[ main::x#2 main::x#1 ]
[ main::$0 ]
[ main::$6 ]
[ main::$7 ]
[ main::$1 ]
[ main::line#0 ]
[ main::$3 ]
Allocated zp[1]:2 [ main::y#2 main::y#1 ]
Allocated zp[1]:3 [ main::x#2 main::x#1 ]
Allocated zp[2]:4 [ main::$0 ]
Allocated zp[2]:6 [ main::$6 ]
Allocated zp[2]:8 [ main::$7 ]
Allocated zp[2]:10 [ main::$1 ]
Allocated zp[2]:12 [ main::line#0 ]
Allocated zp[1]:14 [ main::$3 ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// Fill a square on the screen
  // 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: {
    .label __0 = 4
    .label __1 = $a
    .label __3 = $e
    .label line = $c
    .label x = 3
    .label y = 2
    .label __6 = 6
    .label __7 = 8
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (byte) main::y#2 = (byte) 5 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #5
    sta.z y
    jmp __b1
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  __b1_from___b3:
    // [5] phi (byte) main::y#2 = (byte) main::y#1 [phi:main::@3->main::@1#0] -- register_copy 
    jmp __b1
    // main::@1
  __b1:
    // [6] (word~) main::$0 ← (word)(byte) main::y#2 -- vwuz1=_word_vbuz2 
    lda.z y
    sta.z __0
    lda #0
    sta.z __0+1
    // [7] (word~) main::$6 ← (word~) main::$0 << (byte) 2 -- vwuz1=vwuz2_rol_2 
    lda.z __0
    asl
    sta.z __6
    lda.z __0+1
    rol
    sta.z __6+1
    asl.z __6
    rol.z __6+1
    // [8] (word~) main::$7 ← (word~) main::$6 + (word~) main::$0 -- vwuz1=vwuz2_plus_vwuz3 
    lda.z __6
    clc
    adc.z __0
    sta.z __7
    lda.z __6+1
    adc.z __0+1
    sta.z __7+1
    // [9] (word~) main::$1 ← (word~) main::$7 << (byte) 3 -- vwuz1=vwuz2_rol_3 
    lda.z __7
    asl
    sta.z __1
    lda.z __7+1
    rol
    sta.z __1+1
    asl.z __1
    rol.z __1+1
    asl.z __1
    rol.z __1+1
    // [10] (byte*) main::line#0 ← (const byte*) SCREEN + (word~) main::$1 -- pbuz1=pbuc1_plus_vwuz2 
    lda.z __1
    clc
    adc #<SCREEN
    sta.z line
    lda.z __1+1
    adc #>SCREEN
    sta.z line+1
    // [11] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  __b2_from___b1:
    // [11] phi (byte) main::x#2 = (byte) 5 [phi:main::@1->main::@2#0] -- vbuz1=vbuc1 
    lda #5
    sta.z x
    jmp __b2
    // [11] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
  __b2_from___b2:
    // [11] phi (byte) main::x#2 = (byte) main::x#1 [phi:main::@2->main::@2#0] -- register_copy 
    jmp __b2
    // main::@2
  __b2:
    // [12] (byte~) main::$3 ← (byte) main::x#2 + (byte) main::y#2 -- vbuz1=vbuz2_plus_vbuz3 
    lda.z x
    clc
    adc.z y
    sta.z __3
    // [13] *((byte*) main::line#0 + (byte) main::x#2) ← (byte~) main::$3 -- pbuz1_derefidx_vbuz2=vbuz3 
    lda.z __3
    ldy.z x
    sta (line),y
    // [14] (byte) main::x#1 ← ++ (byte) main::x#2 -- vbuz1=_inc_vbuz1 
    inc.z x
    // [15] if((byte) main::x#1!=(byte) $10) goto main::@2 -- vbuz1_neq_vbuc1_then_la1 
    lda #$10
    cmp.z x
    bne __b2_from___b2
    jmp __b3
    // main::@3
  __b3:
    // [16] (byte) main::y#1 ← ++ (byte) main::y#2 -- vbuz1=_inc_vbuz1 
    inc.z y
    // [17] if((byte) main::y#1!=(byte) $10) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #$10
    cmp.z y
    bne __b1_from___b3
    jmp __breturn
    // main::@return
  __breturn:
    // [18] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] (word~) main::$0 ← (word)(byte) main::y#2 [ main::y#2 main::$0 ] ( main:2 [ main::y#2 main::$0 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::y#2 main::y#1 ]
Statement [7] (word~) main::$6 ← (word~) main::$0 << (byte) 2 [ main::y#2 main::$0 main::$6 ] ( main:2 [ main::y#2 main::$0 main::$6 ] ) always clobbers reg byte a 
Statement [8] (word~) main::$7 ← (word~) main::$6 + (word~) main::$0 [ main::y#2 main::$7 ] ( main:2 [ main::y#2 main::$7 ] ) always clobbers reg byte a 
Statement [9] (word~) main::$1 ← (word~) main::$7 << (byte) 3 [ main::y#2 main::$1 ] ( main:2 [ main::y#2 main::$1 ] ) always clobbers reg byte a 
Statement [10] (byte*) main::line#0 ← (const byte*) SCREEN + (word~) main::$1 [ main::y#2 main::line#0 ] ( main:2 [ main::y#2 main::line#0 ] ) always clobbers reg byte a 
Statement [12] (byte~) main::$3 ← (byte) main::x#2 + (byte) main::y#2 [ main::y#2 main::line#0 main::x#2 main::$3 ] ( main:2 [ main::y#2 main::line#0 main::x#2 main::$3 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:3 [ main::x#2 main::x#1 ]
Statement [6] (word~) main::$0 ← (word)(byte) main::y#2 [ main::y#2 main::$0 ] ( main:2 [ main::y#2 main::$0 ] ) always clobbers reg byte a 
Statement [7] (word~) main::$6 ← (word~) main::$0 << (byte) 2 [ main::y#2 main::$0 main::$6 ] ( main:2 [ main::y#2 main::$0 main::$6 ] ) always clobbers reg byte a 
Statement [8] (word~) main::$7 ← (word~) main::$6 + (word~) main::$0 [ main::y#2 main::$7 ] ( main:2 [ main::y#2 main::$7 ] ) always clobbers reg byte a 
Statement [9] (word~) main::$1 ← (word~) main::$7 << (byte) 3 [ main::y#2 main::$1 ] ( main:2 [ main::y#2 main::$1 ] ) always clobbers reg byte a 
Statement [10] (byte*) main::line#0 ← (const byte*) SCREEN + (word~) main::$1 [ main::y#2 main::line#0 ] ( main:2 [ main::y#2 main::line#0 ] ) always clobbers reg byte a 
Statement [12] (byte~) main::$3 ← (byte) main::x#2 + (byte) main::y#2 [ main::y#2 main::line#0 main::x#2 main::$3 ] ( main:2 [ main::y#2 main::line#0 main::x#2 main::$3 ] ) always clobbers reg byte a 
Potential registers zp[1]:2 [ main::y#2 main::y#1 ] : zp[1]:2 , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ main::x#2 main::x#1 ] : zp[1]:3 , reg byte x , reg byte y , 
Potential registers zp[2]:4 [ main::$0 ] : zp[2]:4 , 
Potential registers zp[2]:6 [ main::$6 ] : zp[2]:6 , 
Potential registers zp[2]:8 [ main::$7 ] : zp[2]:8 , 
Potential registers zp[2]:10 [ main::$1 ] : zp[2]:10 , 
Potential registers zp[2]:12 [ main::line#0 ] : zp[2]:12 , 
Potential registers zp[1]:14 [ main::$3 ] : zp[1]:14 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 286.17: zp[1]:3 [ main::x#2 main::x#1 ] 202: zp[1]:14 [ main::$3 ] 27.68: zp[1]:2 [ main::y#2 main::y#1 ] 22: zp[2]:6 [ main::$6 ] 22: zp[2]:8 [ main::$7 ] 22: zp[2]:10 [ main::$1 ] 18.67: zp[2]:12 [ main::line#0 ] 16.5: zp[2]:4 [ main::$0 ] 
Uplift Scope [] 

Uplifting [main] best 4443 combination reg byte y [ main::x#2 main::x#1 ] reg byte a [ main::$3 ] zp[1]:2 [ main::y#2 main::y#1 ] zp[2]:6 [ main::$6 ] zp[2]:8 [ main::$7 ] zp[2]:10 [ main::$1 ] zp[2]:12 [ main::line#0 ] zp[2]:4 [ main::$0 ] 
Uplifting [] best 4443 combination 
Attempting to uplift remaining variables inzp[1]:2 [ main::y#2 main::y#1 ]
Uplifting [main] best 4443 combination zp[1]:2 [ main::y#2 main::y#1 ] 
Coalescing zero page register [ zp[2]:4 [ main::$0 ] ] with [ zp[2]:8 [ main::$7 ] ] - score: 1
Coalescing zero page register [ zp[2]:10 [ main::$1 ] ] with [ zp[2]:12 [ main::line#0 ] ] - score: 1
Coalescing zero page register [ zp[2]:4 [ main::$0 main::$7 ] ] with [ zp[2]:10 [ main::$1 main::line#0 ] ] - score: 1
Allocated (was zp[2]:4) zp[2]:3 [ main::$0 main::$7 main::$1 main::line#0 ]
Allocated (was zp[2]:6) zp[2]:5 [ main::$6 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Fill a square on the screen
  // 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: {
    .label __0 = 3
    .label __1 = 3
    .label line = 3
    .label y = 2
    .label __6 = 5
    .label __7 = 3
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (byte) main::y#2 = (byte) 5 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #5
    sta.z y
    jmp __b1
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  __b1_from___b3:
    // [5] phi (byte) main::y#2 = (byte) main::y#1 [phi:main::@3->main::@1#0] -- register_copy 
    jmp __b1
    // main::@1
  __b1:
    // [6] (word~) main::$0 ← (word)(byte) main::y#2 -- vwuz1=_word_vbuz2 
    lda.z y
    sta.z __0
    lda #0
    sta.z __0+1
    // [7] (word~) main::$6 ← (word~) main::$0 << (byte) 2 -- vwuz1=vwuz2_rol_2 
    lda.z __0
    asl
    sta.z __6
    lda.z __0+1
    rol
    sta.z __6+1
    asl.z __6
    rol.z __6+1
    // [8] (word~) main::$7 ← (word~) main::$6 + (word~) main::$0 -- vwuz1=vwuz2_plus_vwuz1 
    lda.z __7
    clc
    adc.z __6
    sta.z __7
    lda.z __7+1
    adc.z __6+1
    sta.z __7+1
    // [9] (word~) main::$1 ← (word~) main::$7 << (byte) 3 -- vwuz1=vwuz1_rol_3 
    asl.z __1
    rol.z __1+1
    asl.z __1
    rol.z __1+1
    asl.z __1
    rol.z __1+1
    // [10] (byte*) main::line#0 ← (const byte*) SCREEN + (word~) main::$1 -- pbuz1=pbuc1_plus_vwuz1 
    clc
    lda.z line
    adc #<SCREEN
    sta.z line
    lda.z line+1
    adc #>SCREEN
    sta.z line+1
    // [11] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  __b2_from___b1:
    // [11] phi (byte) main::x#2 = (byte) 5 [phi:main::@1->main::@2#0] -- vbuyy=vbuc1 
    ldy #5
    jmp __b2
    // [11] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
  __b2_from___b2:
    // [11] phi (byte) main::x#2 = (byte) main::x#1 [phi:main::@2->main::@2#0] -- register_copy 
    jmp __b2
    // main::@2
  __b2:
    // [12] (byte~) main::$3 ← (byte) main::x#2 + (byte) main::y#2 -- vbuaa=vbuyy_plus_vbuz1 
    tya
    clc
    adc.z y
    // [13] *((byte*) main::line#0 + (byte) main::x#2) ← (byte~) main::$3 -- pbuz1_derefidx_vbuyy=vbuaa 
    sta (line),y
    // [14] (byte) main::x#1 ← ++ (byte) main::x#2 -- vbuyy=_inc_vbuyy 
    iny
    // [15] if((byte) main::x#1!=(byte) $10) goto main::@2 -- vbuyy_neq_vbuc1_then_la1 
    cpy #$10
    bne __b2_from___b2
    jmp __b3
    // main::@3
  __b3:
    // [16] (byte) main::y#1 ← ++ (byte) main::y#2 -- vbuz1=_inc_vbuz1 
    inc.z y
    // [17] if((byte) main::y#1!=(byte) $10) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #$10
    cmp.z y
    bne __b1_from___b3
    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 __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __bbegin with __b1
Replacing label __b2_from___b2 with __b2
Replacing label __b1_from___b3 with __b1
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Removing instruction __b1_from___b3:
Removing instruction __b2_from___b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __b1_from_main:
Removing instruction __b2_from___b1:
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 __b1:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(const byte*) SCREEN = (byte*) 1024
(void()) main()
(word~) main::$0 zp[2]:3 16.5
(word~) main::$1 zp[2]:3 22.0
(byte~) main::$3 reg byte a 202.0
(word~) main::$6 zp[2]:5 22.0
(word~) main::$7 zp[2]:3 22.0
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte*) main::line
(byte*) main::line#0 line zp[2]:3 18.666666666666664
(byte) main::x
(byte) main::x#1 reg byte y 151.5
(byte) main::x#2 reg byte y 134.66666666666666
(byte) main::y
(byte) main::y#1 y zp[1]:2 16.5
(byte) main::y#2 y zp[1]:2 11.181818181818182

zp[1]:2 [ main::y#2 main::y#1 ]
reg byte y [ main::x#2 main::x#1 ]
zp[2]:3 [ main::$0 main::$7 main::$1 main::line#0 ]
zp[2]:5 [ main::$6 ]
reg byte a [ main::$3 ]


FINAL ASSEMBLER
Score: 3381

  // File Comments
// Fill a square on the screen
  // 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: {
    .label __0 = 3
    .label __1 = 3
    .label line = 3
    .label y = 2
    .label __6 = 5
    .label __7 = 3
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // [5] phi (byte) main::y#2 = (byte) 5 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #5
    sta.z y
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
    // [5] phi (byte) main::y#2 = (byte) main::y#1 [phi:main::@3->main::@1#0] -- register_copy 
    // main::@1
  __b1:
    // (word)y
    // [6] (word~) main::$0 ← (word)(byte) main::y#2 -- vwuz1=_word_vbuz2 
    lda.z y
    sta.z __0
    lda #0
    sta.z __0+1
    // (word)y*40
    // [7] (word~) main::$6 ← (word~) main::$0 << (byte) 2 -- vwuz1=vwuz2_rol_2 
    lda.z __0
    asl
    sta.z __6
    lda.z __0+1
    rol
    sta.z __6+1
    asl.z __6
    rol.z __6+1
    // [8] (word~) main::$7 ← (word~) main::$6 + (word~) main::$0 -- vwuz1=vwuz2_plus_vwuz1 
    lda.z __7
    clc
    adc.z __6
    sta.z __7
    lda.z __7+1
    adc.z __6+1
    sta.z __7+1
    // [9] (word~) main::$1 ← (word~) main::$7 << (byte) 3 -- vwuz1=vwuz1_rol_3 
    asl.z __1
    rol.z __1+1
    asl.z __1
    rol.z __1+1
    asl.z __1
    rol.z __1+1
    // line = SCREEN+(word)y*40
    // [10] (byte*) main::line#0 ← (const byte*) SCREEN + (word~) main::$1 -- pbuz1=pbuc1_plus_vwuz1 
    clc
    lda.z line
    adc #<SCREEN
    sta.z line
    lda.z line+1
    adc #>SCREEN
    sta.z line+1
    // [11] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
    // [11] phi (byte) main::x#2 = (byte) 5 [phi:main::@1->main::@2#0] -- vbuyy=vbuc1 
    ldy #5
    // [11] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
    // [11] phi (byte) main::x#2 = (byte) main::x#1 [phi:main::@2->main::@2#0] -- register_copy 
    // main::@2
  __b2:
    // x+y
    // [12] (byte~) main::$3 ← (byte) main::x#2 + (byte) main::y#2 -- vbuaa=vbuyy_plus_vbuz1 
    tya
    clc
    adc.z y
    // line[x] = x+y
    // [13] *((byte*) main::line#0 + (byte) main::x#2) ← (byte~) main::$3 -- pbuz1_derefidx_vbuyy=vbuaa 
    sta (line),y
    // for( byte x: 5..15)
    // [14] (byte) main::x#1 ← ++ (byte) main::x#2 -- vbuyy=_inc_vbuyy 
    iny
    // [15] if((byte) main::x#1!=(byte) $10) goto main::@2 -- vbuyy_neq_vbuc1_then_la1 
    cpy #$10
    bne __b2
    // main::@3
    // for( byte y: 5..15)
    // [16] (byte) main::y#1 ← ++ (byte) main::y#2 -- vbuz1=_inc_vbuz1 
    inc.z y
    // [17] if((byte) main::y#1!=(byte) $10) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #$10
    cmp.z y
    bne __b1
    // main::@return
    // }
    // [18] return 
    rts
}
  // File Data

