Culled Empty Block (label) main::@2

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

(void()) main()
main: scope:[main]  from @1
  (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 )
  (number~) main::$0 ← (byte) main::i#2 / (number) 1
  *((const byte*) main::SCREEN+(number) $28*(number) 0 + (byte) main::i#2) ← (number~) main::$0
  (number~) main::$1 ← (byte) main::i#2 / (number) 2
  *((const byte*) main::SCREEN+(number) $28*(number) 1 + (byte) main::i#2) ← (number~) main::$1
  (number~) main::$2 ← (byte) main::i#2 / (number) 4
  *((const byte*) main::SCREEN+(number) $28*(number) 2 + (byte) main::i#2) ← (number~) main::$2
  (number~) main::$3 ← (byte) main::i#2 / (number) 8
  *((const byte*) main::SCREEN+(number) $28*(number) 3 + (byte) main::i#2) ← (number~) main::$3
  (signed byte~) main::$4 ← ((signed byte)) (byte) main::i#2
  (signed byte~) main::$5 ← - (signed byte~) main::$4
  (signed byte) main::sb#0 ← (signed byte~) main::$5
  (number~) main::$6 ← (signed byte) main::sb#0 / (number) 2
  (byte~) main::$7 ← ((byte)) (number~) main::$6
  *((const byte*) main::SCREEN+(number) $28*(number) 5 + (byte) main::i#2) ← (byte~) main::$7
  (byte) main::i#1 ← (byte) main::i#2 + rangenext(0,$a)
  (bool~) main::$8 ← (byte) main::i#1 != rangelast(0,$a)
  if((bool~) main::$8) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@1
  return 
  to:@return
@1: scope:[]  from @begin
  call main 
  to:@2
@2: scope:[]  from @1
  to:@end
@end: scope:[]  from @2

SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(void()) main()
(number~) main::$0
(number~) main::$1
(number~) main::$2
(number~) main::$3
(signed byte~) main::$4
(signed byte~) main::$5
(number~) main::$6
(byte~) main::$7
(bool~) main::$8
(label) main::@1
(label) main::@return
(const byte*) main::SCREEN = (byte*)(number) $400
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(signed byte) main::sb
(signed byte) main::sb#0

Adding number conversion cast (unumber) 1 in (number~) main::$0 ← (byte) main::i#2 / (number) 1
Adding number conversion cast (unumber) main::$0 in (number~) main::$0 ← (byte) main::i#2 / (unumber)(number) 1
Adding number conversion cast (unumber) $28*0 in *((const byte*) main::SCREEN+(number) $28*(number) 0 + (byte) main::i#2) ← (unumber~) main::$0
Adding number conversion cast (unumber) 2 in (number~) main::$1 ← (byte) main::i#2 / (number) 2
Adding number conversion cast (unumber) main::$1 in (number~) main::$1 ← (byte) main::i#2 / (unumber)(number) 2
Adding number conversion cast (unumber) $28*1 in *((const byte*) main::SCREEN+(number) $28*(number) 1 + (byte) main::i#2) ← (unumber~) main::$1
Adding number conversion cast (unumber) 4 in (number~) main::$2 ← (byte) main::i#2 / (number) 4
Adding number conversion cast (unumber) main::$2 in (number~) main::$2 ← (byte) main::i#2 / (unumber)(number) 4
Adding number conversion cast (unumber) $28*2 in *((const byte*) main::SCREEN+(number) $28*(number) 2 + (byte) main::i#2) ← (unumber~) main::$2
Adding number conversion cast (unumber) 8 in (number~) main::$3 ← (byte) main::i#2 / (number) 8
Adding number conversion cast (unumber) main::$3 in (number~) main::$3 ← (byte) main::i#2 / (unumber)(number) 8
Adding number conversion cast (unumber) $28*3 in *((const byte*) main::SCREEN+(number) $28*(number) 3 + (byte) main::i#2) ← (unumber~) main::$3
Adding number conversion cast (snumber) 2 in (number~) main::$6 ← (signed byte) main::sb#0 / (number) 2
Adding number conversion cast (snumber) main::$6 in (number~) main::$6 ← (signed byte) main::sb#0 / (snumber)(number) 2
Adding number conversion cast (unumber) $28*5 in *((const byte*) main::SCREEN+(number) $28*(number) 5 + (byte) main::i#2) ← (byte~) main::$7
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (signed byte~) main::$4 ← (signed byte)(byte) main::i#2
Inlining cast (byte~) main::$7 ← (byte)(snumber~) main::$6
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 1
Simplifying constant integer cast 2
Simplifying constant integer cast 4
Simplifying constant integer cast 8
Simplifying constant integer cast 2
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) 8
Finalized signed number type (signed byte) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) main::$0 ← (byte) main::i#2 / (byte) 1
Inferred type updated to byte in (unumber~) main::$1 ← (byte) main::i#2 / (byte) 2
Inferred type updated to byte in (unumber~) main::$2 ← (byte) main::i#2 / (byte) 4
Inferred type updated to byte in (unumber~) main::$3 ← (byte) main::i#2 / (byte) 8
Inferred type updated to signed byte in (snumber~) main::$6 ← (signed byte) main::sb#0 / (signed byte) 2
Alias (signed byte) main::sb#0 = (signed byte~) main::$5 
Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) main::$8 [18] if((byte) main::i#1!=rangelast(0,$a)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) main::i#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [16] main::i#1 ← ++ main::i#2 to ++
Resolved ranged comparison value [18] if(main::i#1!=rangelast(0,$a)) goto main::@1 to (number) $b
Simplifying constant evaluating to zero (byte)(number) $28*(number) 0 in [3] *((const byte*) main::SCREEN+(byte)(number) $28*(number) 0 + (byte) main::i#2) ← (byte~) main::$0
Successful SSA optimization PassNSimplifyConstantZero
Simplifying expression containing zero main::SCREEN in [3] *((const byte*) main::SCREEN+(byte) 0 + (byte) main::i#2) ← (byte~) main::$0
Successful SSA optimization PassNSimplifyExpressionWithZero
Adding number conversion cast (unumber) $b in if((byte) main::i#1!=(number) $b) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast $b
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $b
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inlining Noop Cast [9] (signed byte~) main::$4 ← (signed byte)(byte) main::i#2 keeping main::i#2
Successful SSA optimization Pass2NopCastInlining
Inlining Noop Cast [12] (byte~) main::$7 ← (byte)(signed byte~) main::$6 keeping main::$7
Successful SSA optimization Pass2NopCastInlining
Rewriting multiplication to remove identity multiply/divide [1] (byte~) main::$0 ← (byte) main::i#2 / (byte) 1
Rewriting division to use shift [3] (byte~) main::$1 ← (byte) main::i#2 / (byte) 2
Rewriting division to use shift [5] (byte~) main::$2 ← (byte) main::i#2 / (byte) 4
Rewriting division to use shift [7] (byte~) main::$3 ← (byte) main::i#2 / (byte) 8
Rewriting division to use shift [11] (signed byte~) main::$7 ← (signed byte) main::sb#0 / (signed byte) 2
Successful SSA optimization Pass2MultiplyToShiftRewriting
Inlining constant with var siblings (const byte) main::i#0
Constant inlined main::i#0 = (byte) 0
Successful SSA optimization Pass2ConstantInlining
Alias (byte) main::i#2 = (byte~) main::$0 
Successful SSA optimization Pass2AliasElimination
Added new block during phi lifting main::@3(between main::@1 and main::@1)
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 1 initial phi equivalence classes
Coalesced [20] main::i#3 ← main::i#1
Coalesced down to 1 phi equivalence classes
Culled Empty Block (label) @2
Culled Empty Block (label) main::@3
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::@1
  [5] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 )
  [6] *((const byte*) main::SCREEN + (byte) main::i#2) ← (byte) main::i#2
  [7] (byte~) main::$1 ← (byte) main::i#2 >> (byte) 1
  [8] *((const byte*) main::SCREEN+(byte)(number) $28*(number) 1 + (byte) main::i#2) ← (byte~) main::$1
  [9] (byte~) main::$2 ← (byte) main::i#2 >> (byte) 2
  [10] *((const byte*) main::SCREEN+(byte)(number) $28*(number) 2 + (byte) main::i#2) ← (byte~) main::$2
  [11] (byte~) main::$3 ← (byte) main::i#2 >> (byte) 3
  [12] *((const byte*) main::SCREEN+(byte)(number) $28*(number) 3 + (byte) main::i#2) ← (byte~) main::$3
  [13] (signed byte) main::sb#0 ← - (signed byte)(byte) main::i#2
  [14] (signed byte~) main::$7 ← (signed byte) main::sb#0 >> (byte) 1
  [15] *((const byte*) main::SCREEN+(byte)(number) $28*(number) 5 + (byte) main::i#2) ← (byte)(signed byte~) main::$7
  [16] (byte) main::i#1 ← ++ (byte) main::i#2
  [17] if((byte) main::i#1!=(byte) $b) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@1
  [18] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(byte~) main::$1 22.0
(byte~) main::$2 22.0
(byte~) main::$3 22.0
(signed byte~) main::$7 11.0
(byte) main::i
(byte) main::i#1 16.5
(byte) main::i#2 11.0
(signed byte) main::sb
(signed byte) main::sb#0 22.0

Initial phi equivalence classes
[ main::i#2 main::i#1 ]
Added variable main::$1 to live range equivalence class [ main::$1 ]
Added variable main::$2 to live range equivalence class [ main::$2 ]
Added variable main::$3 to live range equivalence class [ main::$3 ]
Added variable main::sb#0 to live range equivalence class [ main::sb#0 ]
Added variable main::$7 to live range equivalence class [ main::$7 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ main::$1 ]
[ main::$2 ]
[ main::$3 ]
[ main::sb#0 ]
[ main::$7 ]
Allocated zp[1]:2 [ main::i#2 main::i#1 ]
Allocated zp[1]:3 [ main::$1 ]
Allocated zp[1]:4 [ main::$2 ]
Allocated zp[1]:5 [ main::$3 ]
Allocated zp[1]:6 [ main::sb#0 ]
Allocated zp[1]:7 [ main::$7 ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// Check that division by factors of 2 is converted to shifts
  // 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 = $400
    .label __1 = 3
    .label __2 = 4
    .label __3 = 5
    .label __7 = 7
    .label sb = 6
    .label i = 2
    // [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.z i
    jmp __b1
    // [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 + (byte) main::i#2) ← (byte) main::i#2 -- pbuc1_derefidx_vbuz1=vbuz1 
    ldy.z i
    tya
    sta SCREEN,y
    // [7] (byte~) main::$1 ← (byte) main::i#2 >> (byte) 1 -- vbuz1=vbuz2_ror_1 
    lda.z i
    lsr
    sta.z __1
    // [8] *((const byte*) main::SCREEN+(byte)(number) $28*(number) 1 + (byte) main::i#2) ← (byte~) main::$1 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda.z __1
    ldy.z i
    sta SCREEN+$28*1,y
    // [9] (byte~) main::$2 ← (byte) main::i#2 >> (byte) 2 -- vbuz1=vbuz2_ror_2 
    lda.z i
    lsr
    lsr
    sta.z __2
    // [10] *((const byte*) main::SCREEN+(byte)(number) $28*(number) 2 + (byte) main::i#2) ← (byte~) main::$2 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda.z __2
    ldy.z i
    sta SCREEN+$28*2,y
    // [11] (byte~) main::$3 ← (byte) main::i#2 >> (byte) 3 -- vbuz1=vbuz2_ror_3 
    lda.z i
    lsr
    lsr
    lsr
    sta.z __3
    // [12] *((const byte*) main::SCREEN+(byte)(number) $28*(number) 3 + (byte) main::i#2) ← (byte~) main::$3 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda.z __3
    ldy.z i
    sta SCREEN+$28*3,y
    // [13] (signed byte) main::sb#0 ← - (signed byte)(byte) main::i#2 -- vbsz1=_neg_vbsz2 
    lda.z i
    eor #$ff
    clc
    adc #1
    sta.z sb
    // [14] (signed byte~) main::$7 ← (signed byte) main::sb#0 >> (byte) 1 -- vbsz1=vbsz2_ror_1 
    lda.z sb
    cmp #$80
    ror
    sta.z __7
    // [15] *((const byte*) main::SCREEN+(byte)(number) $28*(number) 5 + (byte) main::i#2) ← (byte)(signed byte~) main::$7 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda.z __7
    ldy.z i
    sta SCREEN+$28*5,y
    // [16] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 
    inc.z i
    // [17] if((byte) main::i#1!=(byte) $b) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #$b
    cmp.z i
    bne __b1_from___b1
    jmp __breturn
    // main::@return
  __breturn:
    // [18] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [7] (byte~) main::$1 ← (byte) main::i#2 >> (byte) 1 [ main::i#2 main::$1 ] ( main:2 [ main::i#2 main::$1 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::i#2 main::i#1 ]
Statement [9] (byte~) main::$2 ← (byte) main::i#2 >> (byte) 2 [ main::i#2 main::$2 ] ( main:2 [ main::i#2 main::$2 ] ) always clobbers reg byte a 
Statement [11] (byte~) main::$3 ← (byte) main::i#2 >> (byte) 3 [ main::i#2 main::$3 ] ( main:2 [ main::i#2 main::$3 ] ) always clobbers reg byte a 
Statement [13] (signed byte) main::sb#0 ← - (signed byte)(byte) main::i#2 [ main::i#2 main::sb#0 ] ( main:2 [ main::i#2 main::sb#0 ] ) always clobbers reg byte a 
Statement [14] (signed byte~) main::$7 ← (signed byte) main::sb#0 >> (byte) 1 [ main::i#2 main::$7 ] ( main:2 [ main::i#2 main::$7 ] ) always clobbers reg byte a 
Statement [6] *((const byte*) main::SCREEN + (byte) main::i#2) ← (byte) main::i#2 [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte a 
Statement [7] (byte~) main::$1 ← (byte) main::i#2 >> (byte) 1 [ main::i#2 main::$1 ] ( main:2 [ main::i#2 main::$1 ] ) always clobbers reg byte a 
Statement [9] (byte~) main::$2 ← (byte) main::i#2 >> (byte) 2 [ main::i#2 main::$2 ] ( main:2 [ main::i#2 main::$2 ] ) always clobbers reg byte a 
Statement [11] (byte~) main::$3 ← (byte) main::i#2 >> (byte) 3 [ main::i#2 main::$3 ] ( main:2 [ main::i#2 main::$3 ] ) always clobbers reg byte a 
Statement [13] (signed byte) main::sb#0 ← - (signed byte)(byte) main::i#2 [ main::i#2 main::sb#0 ] ( main:2 [ main::i#2 main::sb#0 ] ) always clobbers reg byte a 
Statement [14] (signed byte~) main::$7 ← (signed byte) main::sb#0 >> (byte) 1 [ main::i#2 main::$7 ] ( main:2 [ main::i#2 main::$7 ] ) always clobbers reg byte a 
Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ main::$1 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:4 [ main::$2 ] : zp[1]:4 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:5 [ main::$3 ] : zp[1]:5 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:6 [ main::sb#0 ] : zp[1]:6 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:7 [ main::$7 ] : zp[1]:7 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 27.5: zp[1]:2 [ main::i#2 main::i#1 ] 22: zp[1]:3 [ main::$1 ] 22: zp[1]:4 [ main::$2 ] 22: zp[1]:5 [ main::$3 ] 22: zp[1]:6 [ main::sb#0 ] 11: zp[1]:7 [ main::$7 ] 
Uplift Scope [] 

Uplifting [main] best 883 combination reg byte x [ main::i#2 main::i#1 ] reg byte a [ main::$1 ] reg byte a [ main::$2 ] reg byte a [ main::$3 ] zp[1]:6 [ main::sb#0 ] zp[1]:7 [ main::$7 ] 
Limited combination testing to 100 combinations of 3072 possible.
Uplifting [] best 883 combination 
Attempting to uplift remaining variables inzp[1]:6 [ main::sb#0 ]
Uplifting [main] best 823 combination reg byte a [ main::sb#0 ] 
Attempting to uplift remaining variables inzp[1]:7 [ main::$7 ]
Uplifting [main] best 763 combination reg byte a [ main::$7 ] 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Check that division by factors of 2 is converted to shifts
  // 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 = $400
    // [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
    // [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 + (byte) main::i#2) ← (byte) main::i#2 -- pbuc1_derefidx_vbuxx=vbuxx 
    txa
    sta SCREEN,x
    // [7] (byte~) main::$1 ← (byte) main::i#2 >> (byte) 1 -- vbuaa=vbuxx_ror_1 
    txa
    lsr
    // [8] *((const byte*) main::SCREEN+(byte)(number) $28*(number) 1 + (byte) main::i#2) ← (byte~) main::$1 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN+$28*1,x
    // [9] (byte~) main::$2 ← (byte) main::i#2 >> (byte) 2 -- vbuaa=vbuxx_ror_2 
    txa
    lsr
    lsr
    // [10] *((const byte*) main::SCREEN+(byte)(number) $28*(number) 2 + (byte) main::i#2) ← (byte~) main::$2 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN+$28*2,x
    // [11] (byte~) main::$3 ← (byte) main::i#2 >> (byte) 3 -- vbuaa=vbuxx_ror_3 
    txa
    lsr
    lsr
    lsr
    // [12] *((const byte*) main::SCREEN+(byte)(number) $28*(number) 3 + (byte) main::i#2) ← (byte~) main::$3 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN+$28*3,x
    // [13] (signed byte) main::sb#0 ← - (signed byte)(byte) main::i#2 -- vbsaa=_neg_vbsxx 
    txa
    eor #$ff
    clc
    adc #1
    // [14] (signed byte~) main::$7 ← (signed byte) main::sb#0 >> (byte) 1 -- vbsaa=vbsaa_ror_1 
    cmp #$80
    ror
    // [15] *((const byte*) main::SCREEN+(byte)(number) $28*(number) 5 + (byte) main::i#2) ← (byte)(signed byte~) main::$7 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN+$28*5,x
    // [16] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [17] if((byte) main::i#1!=(byte) $b) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne __b1_from___b1
    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 __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __bbegin with __b1
Replacing label __b1_from___b1 with __b1
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Removing instruction __b1_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __b1_from_main:
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
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(byte~) main::$1 reg byte a 22.0
(byte~) main::$2 reg byte a 22.0
(byte~) main::$3 reg byte a 22.0
(signed byte~) main::$7 reg byte a 11.0
(label) main::@1
(label) main::@return
(const byte*) main::SCREEN = (byte*) 1024
(byte) main::i
(byte) main::i#1 reg byte x 16.5
(byte) main::i#2 reg byte x 11.0
(signed byte) main::sb
(signed byte) main::sb#0 reg byte a 22.0

reg byte x [ main::i#2 main::i#1 ]
reg byte a [ main::$1 ]
reg byte a [ main::$2 ]
reg byte a [ main::$3 ]
reg byte a [ main::sb#0 ]
reg byte a [ main::$7 ]


FINAL ASSEMBLER
Score: 661

  // File Comments
// Check that division by factors of 2 is converted to shifts
  // 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 = $400
    // [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
    // [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+40*0)[i] = i/1
    // [6] *((const byte*) main::SCREEN + (byte) main::i#2) ← (byte) main::i#2 -- pbuc1_derefidx_vbuxx=vbuxx 
    txa
    sta SCREEN,x
    // i/2
    // [7] (byte~) main::$1 ← (byte) main::i#2 >> (byte) 1 -- vbuaa=vbuxx_ror_1 
    txa
    lsr
    // (SCREEN+40*1)[i] = i/2
    // [8] *((const byte*) main::SCREEN+(byte)(number) $28*(number) 1 + (byte) main::i#2) ← (byte~) main::$1 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN+$28*1,x
    // i/4
    // [9] (byte~) main::$2 ← (byte) main::i#2 >> (byte) 2 -- vbuaa=vbuxx_ror_2 
    txa
    lsr
    lsr
    // (SCREEN+40*2)[i] = i/4
    // [10] *((const byte*) main::SCREEN+(byte)(number) $28*(number) 2 + (byte) main::i#2) ← (byte~) main::$2 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN+$28*2,x
    // i/8
    // [11] (byte~) main::$3 ← (byte) main::i#2 >> (byte) 3 -- vbuaa=vbuxx_ror_3 
    txa
    lsr
    lsr
    lsr
    // (SCREEN+40*3)[i] = i/8
    // [12] *((const byte*) main::SCREEN+(byte)(number) $28*(number) 3 + (byte) main::i#2) ← (byte~) main::$3 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN+$28*3,x
    // sb = -(signed byte)i
    // [13] (signed byte) main::sb#0 ← - (signed byte)(byte) main::i#2 -- vbsaa=_neg_vbsxx 
    txa
    eor #$ff
    clc
    adc #1
    // sb/2
    // [14] (signed byte~) main::$7 ← (signed byte) main::sb#0 >> (byte) 1 -- vbsaa=vbsaa_ror_1 
    cmp #$80
    ror
    // (SCREEN+40*5)[i] = (byte)(sb/2)
    // [15] *((const byte*) main::SCREEN+(byte)(number) $28*(number) 5 + (byte) main::i#2) ← (byte)(signed byte~) main::$7 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN+$28*5,x
    // for(byte i: 0..10)
    // [16] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [17] if((byte) main::i#1!=(byte) $b) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne __b1
    // main::@return
    // }
    // [18] return 
    rts
}
  // File Data

