Fixing pointer array-indexing *((const word*) main::screen + (byte) main::i)
Culled Empty Block (label) mul8u::@5
Culled Empty Block (label) mul8u::@6
Culled Empty Block (label) mul8u::@8
Culled Empty Block (label) mul8u::@9
Culled Empty Block (label) @1
Culled Empty Block (label) @2
Culled Empty Block (label) @3
Culled Empty Block (label) @4
Culled Empty Block (label) @5
Culled Empty Block (label) main::@4

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

(word()) mul8u((byte) mul8u::a , (byte) mul8u::b)
mul8u: scope:[mul8u]  from main::@2
  (byte) mul8u::a#5 ← phi( main::@2/(byte) mul8u::a#1 )
  (byte) mul8u::b#1 ← phi( main::@2/(byte) mul8u::b#0 )
  (word) mul8u::res#0 ← (word) 0
  (word) mul8u::mb#0 ← (word)(byte) mul8u::b#1
  to:mul8u::@1
mul8u::@1: scope:[mul8u]  from mul8u mul8u::@4
  (word) mul8u::mb#5 ← phi( mul8u/(word) mul8u::mb#0 mul8u::@4/(word) mul8u::mb#1 )
  (word) mul8u::res#4 ← phi( mul8u/(word) mul8u::res#0 mul8u::@4/(word) mul8u::res#6 )
  (byte) mul8u::a#2 ← phi( mul8u/(byte) mul8u::a#5 mul8u::@4/(byte) mul8u::a#0 )
  (bool~) mul8u::$0 ← (byte) mul8u::a#2 != (number) 0
  if((bool~) mul8u::$0) goto mul8u::@2
  to:mul8u::@3
mul8u::@2: scope:[mul8u]  from mul8u::@1
  (word) mul8u::res#5 ← phi( mul8u::@1/(word) mul8u::res#4 )
  (word) mul8u::mb#4 ← phi( mul8u::@1/(word) mul8u::mb#5 )
  (byte) mul8u::a#3 ← phi( mul8u::@1/(byte) mul8u::a#2 )
  (number~) mul8u::$1 ← (byte) mul8u::a#3 & (number) 1
  (bool~) mul8u::$2 ← (number~) mul8u::$1 != (number) 0
  (bool~) mul8u::$3 ← ! (bool~) mul8u::$2
  if((bool~) mul8u::$3) goto mul8u::@4
  to:mul8u::@7
mul8u::@3: scope:[mul8u]  from mul8u::@1
  (word) mul8u::res#2 ← phi( mul8u::@1/(word) mul8u::res#4 )
  (word) mul8u::return#0 ← (word) mul8u::res#2
  to:mul8u::@return
mul8u::@4: scope:[mul8u]  from mul8u::@2 mul8u::@7
  (word) mul8u::res#6 ← phi( mul8u::@2/(word) mul8u::res#5 mul8u::@7/(word) mul8u::res#1 )
  (word) mul8u::mb#2 ← phi( mul8u::@2/(word) mul8u::mb#4 mul8u::@7/(word) mul8u::mb#3 )
  (byte) mul8u::a#4 ← phi( mul8u::@2/(byte) mul8u::a#3 mul8u::@7/(byte) mul8u::a#6 )
  (byte~) mul8u::$5 ← (byte) mul8u::a#4 >> (number) 1
  (byte) mul8u::a#0 ← (byte~) mul8u::$5
  (word~) mul8u::$6 ← (word) mul8u::mb#2 << (number) 1
  (word) mul8u::mb#1 ← (word~) mul8u::$6
  to:mul8u::@1
mul8u::@7: scope:[mul8u]  from mul8u::@2
  (byte) mul8u::a#6 ← phi( mul8u::@2/(byte) mul8u::a#3 )
  (word) mul8u::mb#3 ← phi( mul8u::@2/(word) mul8u::mb#4 )
  (word) mul8u::res#3 ← phi( mul8u::@2/(word) mul8u::res#5 )
  (word~) mul8u::$4 ← (word) mul8u::res#3 + (word) mul8u::mb#3
  (word) mul8u::res#1 ← (word~) mul8u::$4
  to:mul8u::@4
mul8u::@return: scope:[mul8u]  from mul8u::@3
  (word) mul8u::return#3 ← phi( mul8u::@3/(word) mul8u::return#0 )
  (word) mul8u::return#1 ← (word) mul8u::return#3
  return 
  to:@return

(void()) main()
main: scope:[main]  from @6
  (byte) main::i#0 ← (byte) 0
  (byte) main::a#0 ← (byte) 0
  to:main::@1
main::@1: scope:[main]  from main main::@3
  (byte) main::i#4 ← phi( main/(byte) main::i#0 main::@3/(byte) main::i#5 )
  (byte) main::a#4 ← phi( main/(byte) main::a#0 main::@3/(byte) main::a#1 )
  (byte) main::b#0 ← (byte) 0
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@5
  (byte) main::i#3 ← phi( main::@1/(byte) main::i#4 main::@5/(byte) main::i#1 )
  (byte) main::b#2 ← phi( main::@1/(byte) main::b#0 main::@5/(byte) main::b#1 )
  (byte) main::a#2 ← phi( main::@1/(byte) main::a#4 main::@5/(byte) main::a#5 )
  (byte) mul8u::a#1 ← (byte) main::a#2
  (byte) mul8u::b#0 ← (byte) main::b#2
  call mul8u 
  (word) mul8u::return#2 ← (word) mul8u::return#1
  to:main::@5
main::@5: scope:[main]  from main::@2
  (byte) main::a#5 ← phi( main::@2/(byte) main::a#2 )
  (byte) main::b#3 ← phi( main::@2/(byte) main::b#2 )
  (byte) main::i#2 ← phi( main::@2/(byte) main::i#3 )
  (word) mul8u::return#4 ← phi( main::@2/(word) mul8u::return#2 )
  (word~) main::$0 ← (word) mul8u::return#4
  (byte~) main::$3 ← (byte) main::i#2 * (const byte) SIZEOF_WORD
  *((const word*) main::screen + (byte~) main::$3) ← (word~) main::$0
  (byte) main::i#1 ← ++ (byte) main::i#2
  (byte) main::b#1 ← (byte) main::b#3 + rangenext(0,5)
  (bool~) main::$1 ← (byte) main::b#1 != rangelast(0,5)
  if((bool~) main::$1) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@5
  (byte) main::i#5 ← phi( main::@5/(byte) main::i#1 )
  (byte) main::a#3 ← phi( main::@5/(byte) main::a#5 )
  (byte) main::a#1 ← (byte) main::a#3 + rangenext(0,5)
  (bool~) main::$2 ← (byte) main::a#1 != rangelast(0,5)
  if((bool~) main::$2) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@3
  return 
  to:@return
@6: scope:[]  from @begin
  call main 
  to:@7
@7: scope:[]  from @6
  to:@end
@end: scope:[]  from @7

SYMBOL TABLE SSA
(label) @6
(label) @7
(label) @begin
(label) @end
(const byte) SIZEOF_WORD = (byte) 2
(void()) main()
(word~) main::$0
(bool~) main::$1
(bool~) main::$2
(byte~) main::$3
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@5
(label) main::@return
(byte) main::a
(byte) main::a#0
(byte) main::a#1
(byte) main::a#2
(byte) main::a#3
(byte) main::a#4
(byte) main::a#5
(byte) main::b
(byte) main::b#0
(byte) main::b#1
(byte) main::b#2
(byte) main::b#3
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(byte) main::i#3
(byte) main::i#4
(byte) main::i#5
(const word*) main::screen = (word*)(number) $400
(word()) mul8u((byte) mul8u::a , (byte) mul8u::b)
(bool~) mul8u::$0
(number~) mul8u::$1
(bool~) mul8u::$2
(bool~) mul8u::$3
(word~) mul8u::$4
(byte~) mul8u::$5
(word~) mul8u::$6
(label) mul8u::@1
(label) mul8u::@2
(label) mul8u::@3
(label) mul8u::@4
(label) mul8u::@7
(label) mul8u::@return
(byte) mul8u::a
(byte) mul8u::a#0
(byte) mul8u::a#1
(byte) mul8u::a#2
(byte) mul8u::a#3
(byte) mul8u::a#4
(byte) mul8u::a#5
(byte) mul8u::a#6
(byte) mul8u::b
(byte) mul8u::b#0
(byte) mul8u::b#1
(word) mul8u::mb
(word) mul8u::mb#0
(word) mul8u::mb#1
(word) mul8u::mb#2
(word) mul8u::mb#3
(word) mul8u::mb#4
(word) mul8u::mb#5
(word) mul8u::res
(word) mul8u::res#0
(word) mul8u::res#1
(word) mul8u::res#2
(word) mul8u::res#3
(word) mul8u::res#4
(word) mul8u::res#5
(word) mul8u::res#6
(word) mul8u::return
(word) mul8u::return#0
(word) mul8u::return#1
(word) mul8u::return#2
(word) mul8u::return#3
(word) mul8u::return#4

Adding number conversion cast (unumber) 0 in (bool~) mul8u::$0 ← (byte) mul8u::a#2 != (number) 0
Adding number conversion cast (unumber) 1 in (number~) mul8u::$1 ← (byte) mul8u::a#3 & (number) 1
Adding number conversion cast (unumber) mul8u::$1 in (number~) mul8u::$1 ← (byte) mul8u::a#3 & (unumber)(number) 1
Adding number conversion cast (unumber) 0 in (bool~) mul8u::$2 ← (unumber~) mul8u::$1 != (number) 0
Adding number conversion cast (unumber) 1 in (byte~) mul8u::$5 ← (byte) mul8u::a#4 >> (number) 1
Adding number conversion cast (unumber) 1 in (word~) mul8u::$6 ← (word) mul8u::mb#2 << (number) 1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (word*) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) mul8u::$1 ← (byte) mul8u::a#3 & (byte) 1
Inversing boolean not [9] (bool~) mul8u::$3 ← (byte~) mul8u::$1 == (byte) 0 from [8] (bool~) mul8u::$2 ← (byte~) mul8u::$1 != (byte) 0
Successful SSA optimization Pass2UnaryNotSimplification
Alias (byte) mul8u::a#2 = (byte) mul8u::a#3 (byte) mul8u::a#6 
Alias (word) mul8u::mb#3 = (word) mul8u::mb#4 (word) mul8u::mb#5 
Alias (word) mul8u::res#2 = (word) mul8u::res#5 (word) mul8u::res#4 (word) mul8u::return#0 (word) mul8u::res#3 (word) mul8u::return#3 (word) mul8u::return#1 
Alias (byte) mul8u::a#0 = (byte~) mul8u::$5 
Alias (word) mul8u::mb#1 = (word~) mul8u::$6 
Alias (word) mul8u::res#1 = (word~) mul8u::$4 
Alias (word) mul8u::return#2 = (word) mul8u::return#4 
Alias (byte) main::i#2 = (byte) main::i#3 
Alias (byte) main::b#2 = (byte) main::b#3 
Alias (byte) main::a#2 = (byte) main::a#5 (byte) main::a#3 
Alias (byte) main::i#1 = (byte) main::i#5 
Successful SSA optimization Pass2AliasElimination
Alias (byte) mul8u::a#2 = (byte) mul8u::a#4 
Alias (word) mul8u::mb#2 = (word) mul8u::mb#3 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) mul8u::b#1 (byte) mul8u::b#0
Identical Phi Values (byte) mul8u::a#5 (byte) mul8u::a#1
Identical Phi Values (byte) main::a#2 (byte) main::a#4
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) mul8u::$0 [5] if((byte) mul8u::a#2!=(byte) 0) goto mul8u::@2
Simple Condition (bool~) mul8u::$3 [8] if((byte~) mul8u::$1==(byte) 0) goto mul8u::@4
Simple Condition (bool~) main::$1 [29] if((byte) main::b#1!=rangelast(0,5)) goto main::@2
Simple Condition (bool~) main::$2 [32] if((byte) main::a#1!=rangelast(0,5)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const word) mul8u::res#0 = 0
Constant (const byte) main::i#0 = 0
Constant (const byte) main::a#0 = 0
Constant (const byte) main::b#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [27] main::b#1 ← ++ main::b#2 to ++
Resolved ranged comparison value [29] if(main::b#1!=rangelast(0,5)) goto main::@2 to (number) 6
Resolved ranged next value [30] main::a#1 ← ++ main::a#4 to ++
Resolved ranged comparison value [32] if(main::a#1!=rangelast(0,5)) goto main::@1 to (number) 6
Adding number conversion cast (unumber) 6 in if((byte) main::b#1!=(number) 6) goto main::@2
Adding number conversion cast (unumber) 6 in if((byte) main::a#1!=(number) 6) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 6
Simplifying constant integer cast 6
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 6
Finalized unsigned number type (byte) 6
Successful SSA optimization PassNFinalizeNumberTypeConversions
Rewriting multiplication to use shift [17] (byte~) main::$3 ← (byte) main::i#2 * (const byte) SIZEOF_WORD
Successful SSA optimization Pass2MultiplyToShiftRewriting
Inlining constant with var siblings (const word) mul8u::res#0
Inlining constant with var siblings (const byte) main::i#0
Inlining constant with var siblings (const byte) main::a#0
Inlining constant with var siblings (const byte) main::b#0
Constant inlined main::a#0 = (byte) 0
Constant inlined main::i#0 = (byte) 0
Constant inlined mul8u::res#0 = (word) 0
Constant inlined main::b#0 = (byte) 0
Successful SSA optimization Pass2ConstantInlining
Eliminating unused constant (const byte) SIZEOF_WORD
Successful SSA optimization PassNEliminateUnusedVars
Added new block during phi lifting mul8u::@10(between mul8u::@2 and mul8u::@4)
Added new block during phi lifting main::@6(between main::@3 and main::@1)
Added new block during phi lifting main::@7(between main::@5 and main::@2)
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @6
Adding NOP phi() at start of @7
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of mul8u::@3
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to mul8u:11 

Created 8 initial phi equivalence classes
Coalesced [7] main::i#7 ← main::i#4
Coalesced [22] main::a#6 ← main::a#1
Coalesced [23] main::i#6 ← main::i#1
Coalesced [24] main::b#4 ← main::b#1
Coalesced (already) [25] main::i#8 ← main::i#1
Coalesced [27] mul8u::a#7 ← mul8u::a#1
Coalesced [28] mul8u::mb#6 ← mul8u::mb#0
Coalesced [36] mul8u::res#9 ← mul8u::res#1
Coalesced [40] mul8u::a#8 ← mul8u::a#0
Coalesced [41] mul8u::res#7 ← mul8u::res#6
Coalesced [42] mul8u::mb#7 ← mul8u::mb#1
Coalesced (already) [43] mul8u::res#8 ← mul8u::res#2
Coalesced down to 6 phi equivalence classes
Culled Empty Block (label) @7
Culled Empty Block (label) main::@6
Culled Empty Block (label) main::@7
Culled Empty Block (label) mul8u::@3
Culled Empty Block (label) mul8u::@10
Renumbering block @6 to @1
Renumbering block mul8u::@4 to mul8u::@3
Renumbering block mul8u::@7 to mul8u::@4
Renumbering block main::@5 to main::@4
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::i#4 ← phi( main/(byte) 0 main::@3/(byte) main::i#1 )
  [5] (byte) main::a#4 ← phi( main/(byte) 0 main::@3/(byte) main::a#1 )
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@4
  [6] (byte) main::i#2 ← phi( main::@1/(byte) main::i#4 main::@4/(byte) main::i#1 )
  [6] (byte) main::b#2 ← phi( main::@1/(byte) 0 main::@4/(byte) main::b#1 )
  [7] (byte) mul8u::a#1 ← (byte) main::a#4
  [8] (byte) mul8u::b#0 ← (byte) main::b#2
  [9] call mul8u 
  [10] (word) mul8u::return#2 ← (word) mul8u::res#2
  to:main::@4
main::@4: scope:[main]  from main::@2
  [11] (word~) main::$0 ← (word) mul8u::return#2
  [12] (byte~) main::$3 ← (byte) main::i#2 << (byte) 1
  [13] *((const word*) main::screen + (byte~) main::$3) ← (word~) main::$0
  [14] (byte) main::i#1 ← ++ (byte) main::i#2
  [15] (byte) main::b#1 ← ++ (byte) main::b#2
  [16] if((byte) main::b#1!=(byte) 6) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@4
  [17] (byte) main::a#1 ← ++ (byte) main::a#4
  [18] if((byte) main::a#1!=(byte) 6) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@3
  [19] return 
  to:@return

(word()) mul8u((byte) mul8u::a , (byte) mul8u::b)
mul8u: scope:[mul8u]  from main::@2
  [20] (word) mul8u::mb#0 ← (word)(byte) mul8u::b#0
  to:mul8u::@1
mul8u::@1: scope:[mul8u]  from mul8u mul8u::@3
  [21] (word) mul8u::mb#2 ← phi( mul8u/(word) mul8u::mb#0 mul8u::@3/(word) mul8u::mb#1 )
  [21] (word) mul8u::res#2 ← phi( mul8u/(word) 0 mul8u::@3/(word) mul8u::res#6 )
  [21] (byte) mul8u::a#2 ← phi( mul8u/(byte) mul8u::a#1 mul8u::@3/(byte) mul8u::a#0 )
  [22] if((byte) mul8u::a#2!=(byte) 0) goto mul8u::@2
  to:mul8u::@return
mul8u::@return: scope:[mul8u]  from mul8u::@1
  [23] return 
  to:@return
mul8u::@2: scope:[mul8u]  from mul8u::@1
  [24] (byte~) mul8u::$1 ← (byte) mul8u::a#2 & (byte) 1
  [25] if((byte~) mul8u::$1==(byte) 0) goto mul8u::@3
  to:mul8u::@4
mul8u::@4: scope:[mul8u]  from mul8u::@2
  [26] (word) mul8u::res#1 ← (word) mul8u::res#2 + (word) mul8u::mb#2
  to:mul8u::@3
mul8u::@3: scope:[mul8u]  from mul8u::@2 mul8u::@4
  [27] (word) mul8u::res#6 ← phi( mul8u::@2/(word) mul8u::res#2 mul8u::@4/(word) mul8u::res#1 )
  [28] (byte) mul8u::a#0 ← (byte) mul8u::a#2 >> (byte) 1
  [29] (word) mul8u::mb#1 ← (word) mul8u::mb#2 << (byte) 1
  to:mul8u::@1


VARIABLE REGISTER WEIGHTS
(void()) main()
(word~) main::$0 101.0
(byte~) main::$3 202.0
(byte) main::a
(byte) main::a#1 16.5
(byte) main::a#4 10.249999999999998
(byte) main::b
(byte) main::b#1 151.5
(byte) main::b#2 33.666666666666664
(byte) main::i
(byte) main::i#1 42.599999999999994
(byte) main::i#2 39.25
(byte) main::i#4 22.0
(word()) mul8u((byte) mul8u::a , (byte) mul8u::b)
(byte~) mul8u::$1 2002.0
(byte) mul8u::a
(byte) mul8u::a#0 1001.0
(byte) mul8u::a#1 34.33333333333333
(byte) mul8u::a#2 667.6666666666667
(byte) mul8u::b
(byte) mul8u::b#0 101.0
(word) mul8u::mb
(word) mul8u::mb#0 4.0
(word) mul8u::mb#1 2002.0
(word) mul8u::mb#2 429.2857142857143
(word) mul8u::res
(word) mul8u::res#1 2002.0
(word) mul8u::res#2 517.3333333333334
(word) mul8u::res#6 1001.0
(word) mul8u::return
(word) mul8u::return#2 202.0

Initial phi equivalence classes
[ main::a#4 main::a#1 ]
[ main::b#2 main::b#1 ]
[ main::i#2 main::i#4 main::i#1 ]
[ mul8u::a#2 mul8u::a#1 mul8u::a#0 ]
[ mul8u::res#2 mul8u::res#6 mul8u::res#1 ]
[ mul8u::mb#2 mul8u::mb#0 mul8u::mb#1 ]
Added variable mul8u::b#0 to live range equivalence class [ mul8u::b#0 ]
Added variable mul8u::return#2 to live range equivalence class [ mul8u::return#2 ]
Added variable main::$0 to live range equivalence class [ main::$0 ]
Added variable main::$3 to live range equivalence class [ main::$3 ]
Added variable mul8u::$1 to live range equivalence class [ mul8u::$1 ]
Complete equivalence classes
[ main::a#4 main::a#1 ]
[ main::b#2 main::b#1 ]
[ main::i#2 main::i#4 main::i#1 ]
[ mul8u::a#2 mul8u::a#1 mul8u::a#0 ]
[ mul8u::res#2 mul8u::res#6 mul8u::res#1 ]
[ mul8u::mb#2 mul8u::mb#0 mul8u::mb#1 ]
[ mul8u::b#0 ]
[ mul8u::return#2 ]
[ main::$0 ]
[ main::$3 ]
[ mul8u::$1 ]
Allocated zp[1]:2 [ main::a#4 main::a#1 ]
Allocated zp[1]:3 [ main::b#2 main::b#1 ]
Allocated zp[1]:4 [ main::i#2 main::i#4 main::i#1 ]
Allocated zp[1]:5 [ mul8u::a#2 mul8u::a#1 mul8u::a#0 ]
Allocated zp[2]:6 [ mul8u::res#2 mul8u::res#6 mul8u::res#1 ]
Allocated zp[2]:8 [ mul8u::mb#2 mul8u::mb#0 mul8u::mb#1 ]
Allocated zp[1]:10 [ mul8u::b#0 ]
Allocated zp[2]:11 [ mul8u::return#2 ]
Allocated zp[2]:13 [ main::$0 ]
Allocated zp[1]:15 [ main::$3 ]
Allocated zp[1]:16 [ mul8u::$1 ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// Minimal test of mul8u
  // 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 __0 = $d
    .label __3 = $f
    .label i = 4
    .label b = 3
    .label a = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (byte) main::i#4 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z i
    // [5] phi (byte) main::a#4 = (byte) 0 [phi:main->main::@1#1] -- vbuz1=vbuc1 
    lda #0
    sta.z a
    jmp __b1
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  __b1_from___b3:
    // [5] phi (byte) main::i#4 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy 
    // [5] phi (byte) main::a#4 = (byte) main::a#1 [phi:main::@3->main::@1#1] -- 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::i#2 = (byte) main::i#4 [phi:main::@1->main::@2#0] -- register_copy 
    // [6] phi (byte) main::b#2 = (byte) 0 [phi:main::@1->main::@2#1] -- vbuz1=vbuc1 
    lda #0
    sta.z b
    jmp __b2
    // [6] phi from main::@4 to main::@2 [phi:main::@4->main::@2]
  __b2_from___b4:
    // [6] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4->main::@2#0] -- register_copy 
    // [6] phi (byte) main::b#2 = (byte) main::b#1 [phi:main::@4->main::@2#1] -- register_copy 
    jmp __b2
    // main::@2
  __b2:
    // [7] (byte) mul8u::a#1 ← (byte) main::a#4 -- vbuz1=vbuz2 
    lda.z a
    sta.z mul8u.a
    // [8] (byte) mul8u::b#0 ← (byte) main::b#2 -- vbuz1=vbuz2 
    lda.z b
    sta.z mul8u.b
    // [9] call mul8u 
    jsr mul8u
    // [10] (word) mul8u::return#2 ← (word) mul8u::res#2 -- vwuz1=vwuz2 
    lda.z mul8u.res
    sta.z mul8u.return
    lda.z mul8u.res+1
    sta.z mul8u.return+1
    jmp __b4
    // main::@4
  __b4:
    // [11] (word~) main::$0 ← (word) mul8u::return#2 -- vwuz1=vwuz2 
    lda.z mul8u.return
    sta.z __0
    lda.z mul8u.return+1
    sta.z __0+1
    // [12] (byte~) main::$3 ← (byte) main::i#2 << (byte) 1 -- vbuz1=vbuz2_rol_1 
    lda.z i
    asl
    sta.z __3
    // [13] *((const word*) main::screen + (byte~) main::$3) ← (word~) main::$0 -- pwuc1_derefidx_vbuz1=vwuz2 
    ldy.z __3
    lda.z __0
    sta screen,y
    lda.z __0+1
    sta screen+1,y
    // [14] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 
    inc.z i
    // [15] (byte) main::b#1 ← ++ (byte) main::b#2 -- vbuz1=_inc_vbuz1 
    inc.z b
    // [16] if((byte) main::b#1!=(byte) 6) goto main::@2 -- vbuz1_neq_vbuc1_then_la1 
    lda #6
    cmp.z b
    bne __b2_from___b4
    jmp __b3
    // main::@3
  __b3:
    // [17] (byte) main::a#1 ← ++ (byte) main::a#4 -- vbuz1=_inc_vbuz1 
    inc.z a
    // [18] if((byte) main::a#1!=(byte) 6) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #6
    cmp.z a
    bne __b1_from___b3
    jmp __breturn
    // main::@return
  __breturn:
    // [19] return 
    rts
}
  // mul8u
// Perform binary multiplication of two unsigned 8-bit bytes into a 16-bit unsigned word
// mul8u(byte zp(5) a, byte zp($a) b)
mul8u: {
    .label __1 = $10
    .label mb = 8
    .label a = 5
    .label res = 6
    .label b = $a
    .label return = $b
    // [20] (word) mul8u::mb#0 ← (word)(byte) mul8u::b#0 -- vwuz1=_word_vbuz2 
    lda.z b
    sta.z mb
    lda #0
    sta.z mb+1
    // [21] phi from mul8u to mul8u::@1 [phi:mul8u->mul8u::@1]
  __b1_from_mul8u:
    // [21] phi (word) mul8u::mb#2 = (word) mul8u::mb#0 [phi:mul8u->mul8u::@1#0] -- register_copy 
    // [21] phi (word) mul8u::res#2 = (word) 0 [phi:mul8u->mul8u::@1#1] -- vwuz1=vwuc1 
    lda #<0
    sta.z res
    lda #>0
    sta.z res+1
    // [21] phi (byte) mul8u::a#2 = (byte) mul8u::a#1 [phi:mul8u->mul8u::@1#2] -- register_copy 
    jmp __b1
    // mul8u::@1
  __b1:
    // [22] if((byte) mul8u::a#2!=(byte) 0) goto mul8u::@2 -- vbuz1_neq_0_then_la1 
    lda.z a
    cmp #0
    bne __b2
    jmp __breturn
    // mul8u::@return
  __breturn:
    // [23] return 
    rts
    // mul8u::@2
  __b2:
    // [24] (byte~) mul8u::$1 ← (byte) mul8u::a#2 & (byte) 1 -- vbuz1=vbuz2_band_vbuc1 
    lda #1
    and.z a
    sta.z __1
    // [25] if((byte~) mul8u::$1==(byte) 0) goto mul8u::@3 -- vbuz1_eq_0_then_la1 
    lda.z __1
    cmp #0
    beq __b3_from___b2
    jmp __b4
    // mul8u::@4
  __b4:
    // [26] (word) mul8u::res#1 ← (word) mul8u::res#2 + (word) mul8u::mb#2 -- vwuz1=vwuz1_plus_vwuz2 
    lda.z res
    clc
    adc.z mb
    sta.z res
    lda.z res+1
    adc.z mb+1
    sta.z res+1
    // [27] phi from mul8u::@2 mul8u::@4 to mul8u::@3 [phi:mul8u::@2/mul8u::@4->mul8u::@3]
  __b3_from___b2:
  __b3_from___b4:
    // [27] phi (word) mul8u::res#6 = (word) mul8u::res#2 [phi:mul8u::@2/mul8u::@4->mul8u::@3#0] -- register_copy 
    jmp __b3
    // mul8u::@3
  __b3:
    // [28] (byte) mul8u::a#0 ← (byte) mul8u::a#2 >> (byte) 1 -- vbuz1=vbuz1_ror_1 
    lsr.z a
    // [29] (word) mul8u::mb#1 ← (word) mul8u::mb#2 << (byte) 1 -- vwuz1=vwuz1_rol_1 
    asl.z mb
    rol.z mb+1
    // [21] phi from mul8u::@3 to mul8u::@1 [phi:mul8u::@3->mul8u::@1]
  __b1_from___b3:
    // [21] phi (word) mul8u::mb#2 = (word) mul8u::mb#1 [phi:mul8u::@3->mul8u::@1#0] -- register_copy 
    // [21] phi (word) mul8u::res#2 = (word) mul8u::res#6 [phi:mul8u::@3->mul8u::@1#1] -- register_copy 
    // [21] phi (byte) mul8u::a#2 = (byte) mul8u::a#0 [phi:mul8u::@3->mul8u::@1#2] -- register_copy 
    jmp __b1
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [10] (word) mul8u::return#2 ← (word) mul8u::res#2 [ main::a#4 main::b#2 main::i#2 mul8u::return#2 ] ( main:2 [ main::a#4 main::b#2 main::i#2 mul8u::return#2 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::a#4 main::a#1 ]
Removing always clobbered register reg byte a as potential for zp[1]:3 [ main::b#2 main::b#1 ]
Removing always clobbered register reg byte a as potential for zp[1]:4 [ main::i#2 main::i#4 main::i#1 ]
Statement [11] (word~) main::$0 ← (word) mul8u::return#2 [ main::a#4 main::b#2 main::i#2 main::$0 ] ( main:2 [ main::a#4 main::b#2 main::i#2 main::$0 ] ) always clobbers reg byte a 
Statement [12] (byte~) main::$3 ← (byte) main::i#2 << (byte) 1 [ main::a#4 main::b#2 main::i#2 main::$0 main::$3 ] ( main:2 [ main::a#4 main::b#2 main::i#2 main::$0 main::$3 ] ) always clobbers reg byte a 
Statement [13] *((const word*) main::screen + (byte~) main::$3) ← (word~) main::$0 [ main::a#4 main::b#2 main::i#2 ] ( main:2 [ main::a#4 main::b#2 main::i#2 ] ) always clobbers reg byte a 
Statement [20] (word) mul8u::mb#0 ← (word)(byte) mul8u::b#0 [ mul8u::a#1 mul8u::mb#0 ] ( main:2::mul8u:9 [ main::a#4 main::b#2 main::i#2 mul8u::a#1 mul8u::mb#0 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:5 [ mul8u::a#2 mul8u::a#1 mul8u::a#0 ]
Statement [24] (byte~) mul8u::$1 ← (byte) mul8u::a#2 & (byte) 1 [ mul8u::res#2 mul8u::a#2 mul8u::mb#2 mul8u::$1 ] ( main:2::mul8u:9 [ main::a#4 main::b#2 main::i#2 mul8u::res#2 mul8u::a#2 mul8u::mb#2 mul8u::$1 ] ) always clobbers reg byte a 
Statement [26] (word) mul8u::res#1 ← (word) mul8u::res#2 + (word) mul8u::mb#2 [ mul8u::a#2 mul8u::mb#2 mul8u::res#1 ] ( main:2::mul8u:9 [ main::a#4 main::b#2 main::i#2 mul8u::a#2 mul8u::mb#2 mul8u::res#1 ] ) always clobbers reg byte a 
Statement [10] (word) mul8u::return#2 ← (word) mul8u::res#2 [ main::a#4 main::b#2 main::i#2 mul8u::return#2 ] ( main:2 [ main::a#4 main::b#2 main::i#2 mul8u::return#2 ] ) always clobbers reg byte a 
Statement [11] (word~) main::$0 ← (word) mul8u::return#2 [ main::a#4 main::b#2 main::i#2 main::$0 ] ( main:2 [ main::a#4 main::b#2 main::i#2 main::$0 ] ) always clobbers reg byte a 
Statement [12] (byte~) main::$3 ← (byte) main::i#2 << (byte) 1 [ main::a#4 main::b#2 main::i#2 main::$0 main::$3 ] ( main:2 [ main::a#4 main::b#2 main::i#2 main::$0 main::$3 ] ) always clobbers reg byte a 
Statement [13] *((const word*) main::screen + (byte~) main::$3) ← (word~) main::$0 [ main::a#4 main::b#2 main::i#2 ] ( main:2 [ main::a#4 main::b#2 main::i#2 ] ) always clobbers reg byte a 
Statement [20] (word) mul8u::mb#0 ← (word)(byte) mul8u::b#0 [ mul8u::a#1 mul8u::mb#0 ] ( main:2::mul8u:9 [ main::a#4 main::b#2 main::i#2 mul8u::a#1 mul8u::mb#0 ] ) always clobbers reg byte a 
Statement [24] (byte~) mul8u::$1 ← (byte) mul8u::a#2 & (byte) 1 [ mul8u::res#2 mul8u::a#2 mul8u::mb#2 mul8u::$1 ] ( main:2::mul8u:9 [ main::a#4 main::b#2 main::i#2 mul8u::res#2 mul8u::a#2 mul8u::mb#2 mul8u::$1 ] ) always clobbers reg byte a 
Statement [26] (word) mul8u::res#1 ← (word) mul8u::res#2 + (word) mul8u::mb#2 [ mul8u::a#2 mul8u::mb#2 mul8u::res#1 ] ( main:2::mul8u:9 [ main::a#4 main::b#2 main::i#2 mul8u::a#2 mul8u::mb#2 mul8u::res#1 ] ) always clobbers reg byte a 
Potential registers zp[1]:2 [ main::a#4 main::a#1 ] : zp[1]:2 , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ main::b#2 main::b#1 ] : zp[1]:3 , reg byte x , reg byte y , 
Potential registers zp[1]:4 [ main::i#2 main::i#4 main::i#1 ] : zp[1]:4 , reg byte x , reg byte y , 
Potential registers zp[1]:5 [ mul8u::a#2 mul8u::a#1 mul8u::a#0 ] : zp[1]:5 , reg byte x , reg byte y , 
Potential registers zp[2]:6 [ mul8u::res#2 mul8u::res#6 mul8u::res#1 ] : zp[2]:6 , 
Potential registers zp[2]:8 [ mul8u::mb#2 mul8u::mb#0 mul8u::mb#1 ] : zp[2]:8 , 
Potential registers zp[1]:10 [ mul8u::b#0 ] : zp[1]:10 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[2]:11 [ mul8u::return#2 ] : zp[2]:11 , 
Potential registers zp[2]:13 [ main::$0 ] : zp[2]:13 , 
Potential registers zp[1]:15 [ main::$3 ] : zp[1]:15 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:16 [ mul8u::$1 ] : zp[1]:16 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [mul8u] 3,520.33: zp[2]:6 [ mul8u::res#2 mul8u::res#6 mul8u::res#1 ] 2,435.29: zp[2]:8 [ mul8u::mb#2 mul8u::mb#0 mul8u::mb#1 ] 2,002: zp[1]:16 [ mul8u::$1 ] 1,703: zp[1]:5 [ mul8u::a#2 mul8u::a#1 mul8u::a#0 ] 202: zp[2]:11 [ mul8u::return#2 ] 101: zp[1]:10 [ mul8u::b#0 ] 
Uplift Scope [main] 202: zp[1]:15 [ main::$3 ] 185.17: zp[1]:3 [ main::b#2 main::b#1 ] 103.85: zp[1]:4 [ main::i#2 main::i#4 main::i#1 ] 101: zp[2]:13 [ main::$0 ] 26.75: zp[1]:2 [ main::a#4 main::a#1 ] 
Uplift Scope [] 

Uplifting [mul8u] best 84097 combination zp[2]:6 [ mul8u::res#2 mul8u::res#6 mul8u::res#1 ] zp[2]:8 [ mul8u::mb#2 mul8u::mb#0 mul8u::mb#1 ] reg byte a [ mul8u::$1 ] reg byte x [ mul8u::a#2 mul8u::a#1 mul8u::a#0 ] zp[2]:11 [ mul8u::return#2 ] reg byte a [ mul8u::b#0 ] 
Uplifting [main] best 82697 combination reg byte x [ main::$3 ] reg byte y [ main::b#2 main::b#1 ] zp[1]:4 [ main::i#2 main::i#4 main::i#1 ] zp[2]:13 [ main::$0 ] zp[1]:2 [ main::a#4 main::a#1 ] 
Limited combination testing to 100 combinations of 108 possible.
Uplifting [] best 82697 combination 
Attempting to uplift remaining variables inzp[1]:4 [ main::i#2 main::i#4 main::i#1 ]
Uplifting [main] best 82697 combination zp[1]:4 [ main::i#2 main::i#4 main::i#1 ] 
Attempting to uplift remaining variables inzp[1]:2 [ main::a#4 main::a#1 ]
Uplifting [main] best 82697 combination zp[1]:2 [ main::a#4 main::a#1 ] 
Coalescing zero page register [ zp[2]:6 [ mul8u::res#2 mul8u::res#6 mul8u::res#1 ] ] with [ zp[2]:11 [ mul8u::return#2 ] ] - score: 1
Coalescing zero page register [ zp[2]:6 [ mul8u::res#2 mul8u::res#6 mul8u::res#1 mul8u::return#2 ] ] with [ zp[2]:13 [ main::$0 ] ] - score: 1
Allocated (was zp[1]:4) zp[1]:3 [ main::i#2 main::i#4 main::i#1 ]
Allocated (was zp[2]:6) zp[2]:4 [ mul8u::res#2 mul8u::res#6 mul8u::res#1 mul8u::return#2 main::$0 ]
Allocated (was zp[2]:8) zp[2]:6 [ mul8u::mb#2 mul8u::mb#0 mul8u::mb#1 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Minimal test of mul8u
  // 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 __0 = 4
    .label i = 3
    .label a = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (byte) main::i#4 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z i
    // [5] phi (byte) main::a#4 = (byte) 0 [phi:main->main::@1#1] -- vbuz1=vbuc1 
    lda #0
    sta.z a
    jmp __b1
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  __b1_from___b3:
    // [5] phi (byte) main::i#4 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy 
    // [5] phi (byte) main::a#4 = (byte) main::a#1 [phi:main::@3->main::@1#1] -- 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::i#2 = (byte) main::i#4 [phi:main::@1->main::@2#0] -- register_copy 
    // [6] phi (byte) main::b#2 = (byte) 0 [phi:main::@1->main::@2#1] -- vbuyy=vbuc1 
    ldy #0
    jmp __b2
    // [6] phi from main::@4 to main::@2 [phi:main::@4->main::@2]
  __b2_from___b4:
    // [6] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4->main::@2#0] -- register_copy 
    // [6] phi (byte) main::b#2 = (byte) main::b#1 [phi:main::@4->main::@2#1] -- register_copy 
    jmp __b2
    // main::@2
  __b2:
    // [7] (byte) mul8u::a#1 ← (byte) main::a#4 -- vbuxx=vbuz1 
    ldx.z a
    // [8] (byte) mul8u::b#0 ← (byte) main::b#2 -- vbuaa=vbuyy 
    tya
    // [9] call mul8u 
    jsr mul8u
    // [10] (word) mul8u::return#2 ← (word) mul8u::res#2
    jmp __b4
    // main::@4
  __b4:
    // [11] (word~) main::$0 ← (word) mul8u::return#2
    // [12] (byte~) main::$3 ← (byte) main::i#2 << (byte) 1 -- vbuxx=vbuz1_rol_1 
    lda.z i
    asl
    tax
    // [13] *((const word*) main::screen + (byte~) main::$3) ← (word~) main::$0 -- pwuc1_derefidx_vbuxx=vwuz1 
    lda.z __0
    sta screen,x
    lda.z __0+1
    sta screen+1,x
    // [14] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 
    inc.z i
    // [15] (byte) main::b#1 ← ++ (byte) main::b#2 -- vbuyy=_inc_vbuyy 
    iny
    // [16] if((byte) main::b#1!=(byte) 6) goto main::@2 -- vbuyy_neq_vbuc1_then_la1 
    cpy #6
    bne __b2_from___b4
    jmp __b3
    // main::@3
  __b3:
    // [17] (byte) main::a#1 ← ++ (byte) main::a#4 -- vbuz1=_inc_vbuz1 
    inc.z a
    // [18] if((byte) main::a#1!=(byte) 6) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #6
    cmp.z a
    bne __b1_from___b3
    jmp __breturn
    // main::@return
  __breturn:
    // [19] return 
    rts
}
  // mul8u
// Perform binary multiplication of two unsigned 8-bit bytes into a 16-bit unsigned word
// mul8u(byte register(X) a, byte register(A) b)
mul8u: {
    .label mb = 6
    .label res = 4
    .label return = 4
    // [20] (word) mul8u::mb#0 ← (word)(byte) mul8u::b#0 -- vwuz1=_word_vbuaa 
    sta.z mb
    lda #0
    sta.z mb+1
    // [21] phi from mul8u to mul8u::@1 [phi:mul8u->mul8u::@1]
  __b1_from_mul8u:
    // [21] phi (word) mul8u::mb#2 = (word) mul8u::mb#0 [phi:mul8u->mul8u::@1#0] -- register_copy 
    // [21] phi (word) mul8u::res#2 = (word) 0 [phi:mul8u->mul8u::@1#1] -- vwuz1=vwuc1 
    lda #<0
    sta.z res
    lda #>0
    sta.z res+1
    // [21] phi (byte) mul8u::a#2 = (byte) mul8u::a#1 [phi:mul8u->mul8u::@1#2] -- register_copy 
    jmp __b1
    // mul8u::@1
  __b1:
    // [22] if((byte) mul8u::a#2!=(byte) 0) goto mul8u::@2 -- vbuxx_neq_0_then_la1 
    cpx #0
    bne __b2
    jmp __breturn
    // mul8u::@return
  __breturn:
    // [23] return 
    rts
    // mul8u::@2
  __b2:
    // [24] (byte~) mul8u::$1 ← (byte) mul8u::a#2 & (byte) 1 -- vbuaa=vbuxx_band_vbuc1 
    txa
    and #1
    // [25] if((byte~) mul8u::$1==(byte) 0) goto mul8u::@3 -- vbuaa_eq_0_then_la1 
    cmp #0
    beq __b3_from___b2
    jmp __b4
    // mul8u::@4
  __b4:
    // [26] (word) mul8u::res#1 ← (word) mul8u::res#2 + (word) mul8u::mb#2 -- vwuz1=vwuz1_plus_vwuz2 
    lda.z res
    clc
    adc.z mb
    sta.z res
    lda.z res+1
    adc.z mb+1
    sta.z res+1
    // [27] phi from mul8u::@2 mul8u::@4 to mul8u::@3 [phi:mul8u::@2/mul8u::@4->mul8u::@3]
  __b3_from___b2:
  __b3_from___b4:
    // [27] phi (word) mul8u::res#6 = (word) mul8u::res#2 [phi:mul8u::@2/mul8u::@4->mul8u::@3#0] -- register_copy 
    jmp __b3
    // mul8u::@3
  __b3:
    // [28] (byte) mul8u::a#0 ← (byte) mul8u::a#2 >> (byte) 1 -- vbuxx=vbuxx_ror_1 
    txa
    lsr
    tax
    // [29] (word) mul8u::mb#1 ← (word) mul8u::mb#2 << (byte) 1 -- vwuz1=vwuz1_rol_1 
    asl.z mb
    rol.z mb+1
    // [21] phi from mul8u::@3 to mul8u::@1 [phi:mul8u::@3->mul8u::@1]
  __b1_from___b3:
    // [21] phi (word) mul8u::mb#2 = (word) mul8u::mb#1 [phi:mul8u::@3->mul8u::@1#0] -- register_copy 
    // [21] phi (word) mul8u::res#2 = (word) mul8u::res#6 [phi:mul8u::@3->mul8u::@1#1] -- register_copy 
    // [21] phi (byte) mul8u::a#2 = (byte) mul8u::a#0 [phi:mul8u::@3->mul8u::@1#2] -- register_copy 
    jmp __b1
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __b4
Removing instruction jmp __b3
Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __b4
Removing instruction jmp __b3
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda #0
Removing instruction lda #>0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Replacing label __bbegin with __b1
Replacing label __b2_from___b4 with __b2
Replacing label __b1_from___b3 with __b1
Replacing label __b3_from___b2 with __b3
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___b1:
Removing instruction __b2_from___b4:
Removing instruction __b3_from___b2:
Removing instruction __b3_from___b4:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __b1_from_main:
Removing instruction __b4:
Removing instruction __b3:
Removing instruction __breturn:
Removing instruction __b1_from_mul8u:
Removing instruction __breturn:
Removing instruction __b4:
Removing instruction __b1_from___b3:
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 lda #<0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Removing instruction __b1:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(word~) main::$0 zp[2]:4 101.0
(byte~) main::$3 reg byte x 202.0
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@return
(byte) main::a
(byte) main::a#1 a zp[1]:2 16.5
(byte) main::a#4 a zp[1]:2 10.249999999999998
(byte) main::b
(byte) main::b#1 reg byte y 151.5
(byte) main::b#2 reg byte y 33.666666666666664
(byte) main::i
(byte) main::i#1 i zp[1]:3 42.599999999999994
(byte) main::i#2 i zp[1]:3 39.25
(byte) main::i#4 i zp[1]:3 22.0
(const word*) main::screen = (word*) 1024
(word()) mul8u((byte) mul8u::a , (byte) mul8u::b)
(byte~) mul8u::$1 reg byte a 2002.0
(label) mul8u::@1
(label) mul8u::@2
(label) mul8u::@3
(label) mul8u::@4
(label) mul8u::@return
(byte) mul8u::a
(byte) mul8u::a#0 reg byte x 1001.0
(byte) mul8u::a#1 reg byte x 34.33333333333333
(byte) mul8u::a#2 reg byte x 667.6666666666667
(byte) mul8u::b
(byte) mul8u::b#0 reg byte a 101.0
(word) mul8u::mb
(word) mul8u::mb#0 mb zp[2]:6 4.0
(word) mul8u::mb#1 mb zp[2]:6 2002.0
(word) mul8u::mb#2 mb zp[2]:6 429.2857142857143
(word) mul8u::res
(word) mul8u::res#1 res zp[2]:4 2002.0
(word) mul8u::res#2 res zp[2]:4 517.3333333333334
(word) mul8u::res#6 res zp[2]:4 1001.0
(word) mul8u::return
(word) mul8u::return#2 return zp[2]:4 202.0

zp[1]:2 [ main::a#4 main::a#1 ]
reg byte y [ main::b#2 main::b#1 ]
zp[1]:3 [ main::i#2 main::i#4 main::i#1 ]
reg byte x [ mul8u::a#2 mul8u::a#1 mul8u::a#0 ]
zp[2]:4 [ mul8u::res#2 mul8u::res#6 mul8u::res#1 mul8u::return#2 main::$0 ]
zp[2]:6 [ mul8u::mb#2 mul8u::mb#0 mul8u::mb#1 ]
reg byte a [ mul8u::b#0 ]
reg byte x [ main::$3 ]
reg byte a [ mul8u::$1 ]


FINAL ASSEMBLER
Score: 62975

  // File Comments
// Minimal test of mul8u
  // 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
    .label __0 = 4
    .label i = 3
    .label a = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // [5] phi (byte) main::i#4 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z i
    // [5] phi (byte) main::a#4 = (byte) 0 [phi:main->main::@1#1] -- vbuz1=vbuc1 
    sta.z a
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
    // [5] phi (byte) main::i#4 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy 
    // [5] phi (byte) main::a#4 = (byte) main::a#1 [phi:main::@3->main::@1#1] -- register_copy 
    // main::@1
  __b1:
    // [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
    // [6] phi (byte) main::i#2 = (byte) main::i#4 [phi:main::@1->main::@2#0] -- register_copy 
    // [6] phi (byte) main::b#2 = (byte) 0 [phi:main::@1->main::@2#1] -- vbuyy=vbuc1 
    ldy #0
    // [6] phi from main::@4 to main::@2 [phi:main::@4->main::@2]
    // [6] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4->main::@2#0] -- register_copy 
    // [6] phi (byte) main::b#2 = (byte) main::b#1 [phi:main::@4->main::@2#1] -- register_copy 
    // main::@2
  __b2:
    // mul8u(a,b)
    // [7] (byte) mul8u::a#1 ← (byte) main::a#4 -- vbuxx=vbuz1 
    ldx.z a
    // [8] (byte) mul8u::b#0 ← (byte) main::b#2 -- vbuaa=vbuyy 
    tya
    // [9] call mul8u 
    jsr mul8u
    // [10] (word) mul8u::return#2 ← (word) mul8u::res#2
    // main::@4
    // [11] (word~) main::$0 ← (word) mul8u::return#2
    // screen[i++] = mul8u(a,b)
    // [12] (byte~) main::$3 ← (byte) main::i#2 << (byte) 1 -- vbuxx=vbuz1_rol_1 
    lda.z i
    asl
    tax
    // [13] *((const word*) main::screen + (byte~) main::$3) ← (word~) main::$0 -- pwuc1_derefidx_vbuxx=vwuz1 
    lda.z __0
    sta screen,x
    lda.z __0+1
    sta screen+1,x
    // screen[i++] = mul8u(a,b);
    // [14] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 
    inc.z i
    // for (byte b: 0..5)
    // [15] (byte) main::b#1 ← ++ (byte) main::b#2 -- vbuyy=_inc_vbuyy 
    iny
    // [16] if((byte) main::b#1!=(byte) 6) goto main::@2 -- vbuyy_neq_vbuc1_then_la1 
    cpy #6
    bne __b2
    // main::@3
    // for(byte a: 0..5)
    // [17] (byte) main::a#1 ← ++ (byte) main::a#4 -- vbuz1=_inc_vbuz1 
    inc.z a
    // [18] if((byte) main::a#1!=(byte) 6) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #6
    cmp.z a
    bne __b1
    // main::@return
    // }
    // [19] return 
    rts
}
  // mul8u
// Perform binary multiplication of two unsigned 8-bit bytes into a 16-bit unsigned word
// mul8u(byte register(X) a, byte register(A) b)
mul8u: {
    .label mb = 6
    .label res = 4
    .label return = 4
    // mb = b
    // [20] (word) mul8u::mb#0 ← (word)(byte) mul8u::b#0 -- vwuz1=_word_vbuaa 
    sta.z mb
    lda #0
    sta.z mb+1
    // [21] phi from mul8u to mul8u::@1 [phi:mul8u->mul8u::@1]
    // [21] phi (word) mul8u::mb#2 = (word) mul8u::mb#0 [phi:mul8u->mul8u::@1#0] -- register_copy 
    // [21] phi (word) mul8u::res#2 = (word) 0 [phi:mul8u->mul8u::@1#1] -- vwuz1=vwuc1 
    sta.z res
    sta.z res+1
    // [21] phi (byte) mul8u::a#2 = (byte) mul8u::a#1 [phi:mul8u->mul8u::@1#2] -- register_copy 
    // mul8u::@1
  __b1:
    // while(a!=0)
    // [22] if((byte) mul8u::a#2!=(byte) 0) goto mul8u::@2 -- vbuxx_neq_0_then_la1 
    cpx #0
    bne __b2
    // mul8u::@return
    // }
    // [23] return 
    rts
    // mul8u::@2
  __b2:
    // a&1
    // [24] (byte~) mul8u::$1 ← (byte) mul8u::a#2 & (byte) 1 -- vbuaa=vbuxx_band_vbuc1 
    txa
    and #1
    // if( (a&1) != 0)
    // [25] if((byte~) mul8u::$1==(byte) 0) goto mul8u::@3 -- vbuaa_eq_0_then_la1 
    cmp #0
    beq __b3
    // mul8u::@4
    // res = res + mb
    // [26] (word) mul8u::res#1 ← (word) mul8u::res#2 + (word) mul8u::mb#2 -- vwuz1=vwuz1_plus_vwuz2 
    lda.z res
    clc
    adc.z mb
    sta.z res
    lda.z res+1
    adc.z mb+1
    sta.z res+1
    // [27] phi from mul8u::@2 mul8u::@4 to mul8u::@3 [phi:mul8u::@2/mul8u::@4->mul8u::@3]
    // [27] phi (word) mul8u::res#6 = (word) mul8u::res#2 [phi:mul8u::@2/mul8u::@4->mul8u::@3#0] -- register_copy 
    // mul8u::@3
  __b3:
    // a = a>>1
    // [28] (byte) mul8u::a#0 ← (byte) mul8u::a#2 >> (byte) 1 -- vbuxx=vbuxx_ror_1 
    txa
    lsr
    tax
    // mb = mb<<1
    // [29] (word) mul8u::mb#1 ← (word) mul8u::mb#2 << (byte) 1 -- vwuz1=vwuz1_rol_1 
    asl.z mb
    rol.z mb+1
    // [21] phi from mul8u::@3 to mul8u::@1 [phi:mul8u::@3->mul8u::@1]
    // [21] phi (word) mul8u::mb#2 = (word) mul8u::mb#1 [phi:mul8u::@3->mul8u::@1#0] -- register_copy 
    // [21] phi (word) mul8u::res#2 = (word) mul8u::res#6 [phi:mul8u::@3->mul8u::@1#1] -- register_copy 
    // [21] phi (byte) mul8u::a#2 = (byte) mul8u::a#0 [phi:mul8u::@3->mul8u::@1#2] -- register_copy 
    jmp __b1
}
  // File Data

