Fixing pointer array-indexing *((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
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 ← (number) 0
  (word) mul8u::mb#0 ← (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
main: scope:[main]  from @6
  (word*) main::screen#0 ← ((word*)) (number) $400
  (byte) main::i#0 ← (number) 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
  *((word*) main::screen#0 + (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
(word*) main::screen
(word*) main::screen#0
(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 (word) mul8u::res#0 ← (number) 0
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
Adding number conversion cast (unumber) 0 in (byte) main::i#0 ← (number) 0
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (word) mul8u::res#0 ← (unumber)(number) 0
Inlining cast (word*) main::screen#0 ← (word*)(number) $400
Inlining cast (byte) main::i#0 ← (unumber)(number) 0
Successful SSA optimization Pass2InlineCast
Simplifying constant integer cast 0
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
Simplifying constant pointer cast (word*) 1024
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
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
Finalized unsigned number type (byte) 0
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 (word) mul8u::mb#0 = (byte) mul8u::b#1 
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 (word) mul8u::mb#0 (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 [10] if((byte~) mul8u::$1==(byte) 0) goto mul8u::@4
Simple Condition (bool~) main::$1 [41] if((byte) main::b#1!=rangelast(0,5)) goto main::@2
Simple Condition (bool~) main::$2 [45] if((byte) main::a#1!=rangelast(0,5)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const word) mul8u::res#0 = 0
Constant (const word*) main::screen#0 = (word*) 1024
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 [39] main::b#1 ← ++ main::b#2 to ++
Resolved ranged comparison value [41] if(main::b#1!=rangelast(0,5)) goto main::@2 to (number) 6
Resolved ranged next value [43] main::a#1 ← ++ main::a#4 to ++
Resolved ranged comparison value [45] 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 [16] (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 = (byte) 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 [26] mul8u::a#7 ← mul8u::a#1
Coalesced [27] mul8u::mb#6 ← mul8u::b#0
Coalesced [35] mul8u::res#9 ← mul8u::res#1
Coalesced [39] mul8u::a#8 ← mul8u::a#0
Coalesced [40] mul8u::res#7 ← mul8u::res#6
Coalesced [41] mul8u::mb#7 ← mul8u::mb#1
Coalesced (already) [42] 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
Adding NOP phi() at start of mul8u

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::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#0 + (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
mul8u: scope:[mul8u]  from main::@2
  [20] phi()
  to:mul8u::@1
mul8u::@1: scope:[mul8u]  from mul8u mul8u::@3
  [21] (word) mul8u::mb#2 ← phi( mul8u/(byte) mul8u::b#0 mul8u::@3/(word) mul8u::mb#1 )
  [21] (word) mul8u::res#2 ← phi( mul8u/(byte) 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*) main::screen
(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 51.5
(word) mul8u::mb
(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

Not consolidating phi with different size mul8u::mb#2 mul8u::b#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#1 ]
[ mul8u::b#0 ]
Added variable mul8u::return#2 to zero page equivalence class [ mul8u::return#2 ]
Added variable main::$0 to zero page equivalence class [ main::$0 ]
Added variable main::$3 to zero page equivalence class [ main::$3 ]
Added variable mul8u::$1 to zero page 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#1 ]
[ mul8u::b#0 ]
[ mul8u::return#2 ]
[ main::$0 ]
[ main::$3 ]
[ mul8u::$1 ]
Allocated zp ZP_BYTE:2 [ main::a#4 main::a#1 ]
Allocated zp ZP_BYTE:3 [ main::b#2 main::b#1 ]
Allocated zp ZP_BYTE:4 [ main::i#2 main::i#4 main::i#1 ]
Allocated zp ZP_BYTE:5 [ mul8u::a#2 mul8u::a#1 mul8u::a#0 ]
Allocated zp ZP_WORD:6 [ mul8u::res#2 mul8u::res#6 mul8u::res#1 ]
Allocated zp ZP_WORD:8 [ mul8u::mb#2 mul8u::mb#1 ]
Allocated zp ZP_BYTE:10 [ mul8u::b#0 ]
Allocated zp ZP_WORD:11 [ mul8u::return#2 ]
Allocated zp ZP_WORD:13 [ main::$0 ]
Allocated zp ZP_BYTE:15 [ main::$3 ]
Allocated zp ZP_BYTE:16 [ mul8u::$1 ]

INITIAL ASM
Target platform is c64basic
  // 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 
    // [20] phi from main::@2 to mul8u [phi:main::@2->mul8u]
  mul8u_from_b2:
    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#0 + (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 zeropage(5) a, byte zeropage($a) b)
mul8u: {
    .label _1 = $10
    .label a = 5
    .label mb = 8
    .label res = 6
    .label b = $a
    .label return = $b
    // [21] phi from mul8u to mul8u::@1 [phi:mul8u->mul8u::@1]
  b1_from_mul8u:
    // [21] phi (word) mul8u::mb#2 = (byte) mul8u::b#0 [phi:mul8u->mul8u::@1#0] -- vwuz1=vbuz2 
    lda.z b
    sta.z mb
    lda #0
    sta.z mb+1
    // [21] phi (word) mul8u::res#2 = (byte) 0 [phi:mul8u->mul8u::@1#1] -- vwuz1=vbuc1 
    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 ZP_BYTE:2 [ main::a#4 main::a#1 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:3 [ main::b#2 main::b#1 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE: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#0 + (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 [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 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:5 [ mul8u::a#2 mul8u::a#1 mul8u::a#0 ]
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#0 + (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 [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 ZP_BYTE:2 [ main::a#4 main::a#1 ] : zp ZP_BYTE:2 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:3 [ main::b#2 main::b#1 ] : zp ZP_BYTE:3 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:4 [ main::i#2 main::i#4 main::i#1 ] : zp ZP_BYTE:4 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:5 [ mul8u::a#2 mul8u::a#1 mul8u::a#0 ] : zp ZP_BYTE:5 , reg byte x , reg byte y , 
Potential registers zp ZP_WORD:6 [ mul8u::res#2 mul8u::res#6 mul8u::res#1 ] : zp ZP_WORD:6 , 
Potential registers zp ZP_WORD:8 [ mul8u::mb#2 mul8u::mb#1 ] : zp ZP_WORD:8 , 
Potential registers zp ZP_BYTE:10 [ mul8u::b#0 ] : zp ZP_BYTE:10 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_WORD:11 [ mul8u::return#2 ] : zp ZP_WORD:11 , 
Potential registers zp ZP_WORD:13 [ main::$0 ] : zp ZP_WORD:13 , 
Potential registers zp ZP_BYTE:15 [ main::$3 ] : zp ZP_BYTE:15 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:16 [ mul8u::$1 ] : zp ZP_BYTE:16 , reg byte a , reg byte x , reg byte y , 

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

Uplifting [mul8u] best 91495 combination zp ZP_WORD:6 [ mul8u::res#2 mul8u::res#6 mul8u::res#1 ] zp ZP_WORD:8 [ mul8u::mb#2 mul8u::mb#1 ] reg byte a [ mul8u::$1 ] reg byte x [ mul8u::a#2 mul8u::a#1 mul8u::a#0 ] zp ZP_WORD:11 [ mul8u::return#2 ] reg byte a [ mul8u::b#0 ] 
Uplifting [main] best 90095 combination reg byte x [ main::$3 ] reg byte y [ main::b#2 main::b#1 ] zp ZP_BYTE:4 [ main::i#2 main::i#4 main::i#1 ] zp ZP_WORD:13 [ main::$0 ] zp ZP_BYTE:2 [ main::a#4 main::a#1 ] 
Limited combination testing to 100 combinations of 108 possible.
Uplifting [] best 90095 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:4 [ main::i#2 main::i#4 main::i#1 ]
Uplifting [main] best 90095 combination zp ZP_BYTE:4 [ main::i#2 main::i#4 main::i#1 ] 
Attempting to uplift remaining variables inzp ZP_BYTE:2 [ main::a#4 main::a#1 ]
Uplifting [main] best 90095 combination zp ZP_BYTE:2 [ main::a#4 main::a#1 ] 
Coalescing zero page register [ zp ZP_WORD:6 [ mul8u::res#2 mul8u::res#6 mul8u::res#1 ] ] with [ zp ZP_WORD:11 [ mul8u::return#2 ] ] - score: 1
Coalescing zero page register [ zp ZP_WORD:6 [ mul8u::res#2 mul8u::res#6 mul8u::res#1 mul8u::return#2 ] ] with [ zp ZP_WORD:13 [ main::$0 ] ] - score: 1
Allocated (was zp ZP_BYTE:4) zp ZP_BYTE:3 [ main::i#2 main::i#4 main::i#1 ]
Allocated (was zp ZP_WORD:6) zp ZP_WORD:4 [ mul8u::res#2 mul8u::res#6 mul8u::res#1 mul8u::return#2 main::$0 ]
Allocated (was zp ZP_WORD:8) zp ZP_WORD:6 [ mul8u::mb#2 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 
    // [20] phi from main::@2 to mul8u [phi:main::@2->mul8u]
  mul8u_from_b2:
    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#0 + (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
    // [21] phi from mul8u to mul8u::@1 [phi:mul8u->mul8u::@1]
  b1_from_mul8u:
    // [21] phi (word) mul8u::mb#2 = (byte) mul8u::b#0 [phi:mul8u->mul8u::@1#0] -- vwuz1=vbuaa 
    sta.z mb
    lda #0
    sta.z mb+1
    // [21] phi (word) mul8u::res#2 = (byte) 0 [phi:mul8u->mul8u::@1#1] -- vwuz1=vbuc1 
    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
Removing instruction lda #>0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Replacing label b2_from_b4 with b2
Replacing label b1_from_b3 with b1
Replacing label b3_from_b2 with b3
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_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 mul8u_from_b2:
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 bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(word~) main::$0 $0 zp ZP_WORD: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 ZP_BYTE:2 16.5
(byte) main::a#4 a zp ZP_BYTE: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 ZP_BYTE:3 42.599999999999994
(byte) main::i#2 i zp ZP_BYTE:3 39.25
(byte) main::i#4 i zp ZP_BYTE:3 22.0
(word*) main::screen
(const word*) main::screen#0 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 51.5
(word) mul8u::mb
(word) mul8u::mb#1 mb zp ZP_WORD:6 2002.0
(word) mul8u::mb#2 mb zp ZP_WORD:6 429.2857142857143
(word) mul8u::res
(word) mul8u::res#1 res zp ZP_WORD:4 2002.0
(word) mul8u::res#2 res zp ZP_WORD:4 517.3333333333334
(word) mul8u::res#6 res zp ZP_WORD:4 1001.0
(word) mul8u::return
(word) mul8u::return#2 return zp ZP_WORD:4 202.0

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


FINAL ASSEMBLER
Score: 70373

  // 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 
    // [20] phi from main::@2 to mul8u [phi:main::@2->mul8u]
    jsr mul8u
    // mul8u(a,b)
    // [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#0 + (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
    // [21] phi from mul8u to mul8u::@1 [phi:mul8u->mul8u::@1]
    // [21] phi (word) mul8u::mb#2 = (byte) mul8u::b#0 [phi:mul8u->mul8u::@1#0] -- vwuz1=vbuaa 
    sta.z mb
    lda #0
    sta.z mb+1
    // [21] phi (word) mul8u::res#2 = (byte) 0 [phi:mul8u->mul8u::@1#1] -- vwuz1=vbuc1 
    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

