Identified constant variable (byte*) screen
Culled Empty Block (label) @1
Culled Empty Block (label) sum::@1

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

(void()) main()
main: scope:[main]  from @2
  (byte) sum::a#0 ← (number) 1
  (byte) sum::b#0 ← (number) 2
  call sum 
  (byte) sum::return#0 ← (byte) sum::return#4
  to:main::@1
main::@1: scope:[main]  from main
  (byte) sum::return#5 ← phi( main/(byte) sum::return#0 )
  (byte~) main::$0 ← (byte) sum::return#5
  (byte) main::s1#0 ← (byte~) main::$0
  (byte) sum::a#1 ← (number) 3
  (byte) sum::b#1 ← (number) 4
  call sum 
  (byte) sum::return#1 ← (byte) sum::return#4
  to:main::@2
main::@2: scope:[main]  from main::@1
  (byte) main::s1#2 ← phi( main::@1/(byte) main::s1#0 )
  (byte) sum::return#6 ← phi( main::@1/(byte) sum::return#1 )
  (byte~) main::$1 ← (byte) sum::return#6
  (byte) main::s2#0 ← (byte~) main::$1
  (byte) sum::a#2 ← (number) 9
  (byte) sum::b#2 ← (number) $d
  call sum 
  (byte) sum::return#2 ← (byte) sum::return#4
  to:main::@3
main::@3: scope:[main]  from main::@2
  (byte) main::s2#1 ← phi( main::@2/(byte) main::s2#0 )
  (byte) main::s1#1 ← phi( main::@2/(byte) main::s1#2 )
  (byte) sum::return#7 ← phi( main::@2/(byte) sum::return#2 )
  (byte~) main::$2 ← (byte) sum::return#7
  (byte) main::s3#0 ← (byte~) main::$2
  (byte~) main::$3 ← (byte) main::s1#1 + (byte) main::s2#1
  (byte~) main::$4 ← (byte~) main::$3 + (byte) main::s3#0
  (byte) main::s4#0 ← (byte~) main::$4
  *((const byte*) screen) ← (byte) main::s4#0
  to:main::@return
main::@return: scope:[main]  from main::@3
  return 
  to:@return

(byte()) sum((byte) sum::a , (byte) sum::b)
sum: scope:[sum]  from main main::@1 main::@2
  (byte) sum::b#3 ← phi( main/(byte) sum::b#0 main::@1/(byte) sum::b#1 main::@2/(byte) sum::b#2 )
  (byte) sum::a#3 ← phi( main/(byte) sum::a#0 main::@1/(byte) sum::a#1 main::@2/(byte) sum::a#2 )
  (byte~) sum::$0 ← (byte) sum::a#3 + (byte) sum::b#3
  (byte) sum::return#3 ← (byte~) sum::$0
  to:sum::@return
sum::@return: scope:[sum]  from sum
  (byte) sum::return#8 ← phi( sum/(byte) sum::return#3 )
  (byte) sum::return#4 ← (byte) sum::return#8
  return 
  to:@return
@2: scope:[]  from @begin
  call main 
  to:@3
@3: scope:[]  from @2
  to:@end
@end: scope:[]  from @3

SYMBOL TABLE SSA
(label) @2
(label) @3
(label) @begin
(label) @end
(void()) main()
(byte~) main::$0
(byte~) main::$1
(byte~) main::$2
(byte~) main::$3
(byte~) main::$4
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte) main::s1
(byte) main::s1#0
(byte) main::s1#1
(byte) main::s1#2
(byte) main::s2
(byte) main::s2#0
(byte) main::s2#1
(byte) main::s3
(byte) main::s3#0
(byte) main::s4
(byte) main::s4#0
(const byte*) screen = (byte*)(number) $400
(byte()) sum((byte) sum::a , (byte) sum::b)
(byte~) sum::$0
(label) sum::@return
(byte) sum::a
(byte) sum::a#0
(byte) sum::a#1
(byte) sum::a#2
(byte) sum::a#3
(byte) sum::b
(byte) sum::b#0
(byte) sum::b#1
(byte) sum::b#2
(byte) sum::b#3
(byte) sum::return
(byte) sum::return#0
(byte) sum::return#1
(byte) sum::return#2
(byte) sum::return#3
(byte) sum::return#4
(byte) sum::return#5
(byte) sum::return#6
(byte) sum::return#7
(byte) sum::return#8

Adding number conversion cast (unumber) 1 in (byte) sum::a#0 ← (number) 1
Adding number conversion cast (unumber) 2 in (byte) sum::b#0 ← (number) 2
Adding number conversion cast (unumber) 3 in (byte) sum::a#1 ← (number) 3
Adding number conversion cast (unumber) 4 in (byte) sum::b#1 ← (number) 4
Adding number conversion cast (unumber) 9 in (byte) sum::a#2 ← (number) 9
Adding number conversion cast (unumber) $d in (byte) sum::b#2 ← (number) $d
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte) sum::a#0 ← (unumber)(number) 1
Inlining cast (byte) sum::b#0 ← (unumber)(number) 2
Inlining cast (byte) sum::a#1 ← (unumber)(number) 3
Inlining cast (byte) sum::b#1 ← (unumber)(number) 4
Inlining cast (byte) sum::a#2 ← (unumber)(number) 9
Inlining cast (byte) sum::b#2 ← (unumber)(number) $d
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 1
Simplifying constant integer cast 2
Simplifying constant integer cast 3
Simplifying constant integer cast 4
Simplifying constant integer cast 9
Simplifying constant integer cast $d
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 3
Finalized unsigned number type (byte) 4
Finalized unsigned number type (byte) 9
Finalized unsigned number type (byte) $d
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte) sum::return#0 = (byte) sum::return#5 
Alias (byte) main::s1#0 = (byte~) main::$0 (byte) main::s1#2 (byte) main::s1#1 
Alias (byte) sum::return#1 = (byte) sum::return#6 
Alias (byte) main::s2#0 = (byte~) main::$1 (byte) main::s2#1 
Alias (byte) sum::return#2 = (byte) sum::return#7 
Alias (byte) main::s3#0 = (byte~) main::$2 
Alias (byte) main::s4#0 = (byte~) main::$4 
Alias (byte) sum::return#3 = (byte~) sum::$0 (byte) sum::return#8 (byte) sum::return#4 
Successful SSA optimization Pass2AliasElimination
Constant (const byte) sum::a#0 = 1
Constant (const byte) sum::b#0 = 2
Constant (const byte) sum::a#1 = 3
Constant (const byte) sum::b#1 = 4
Constant (const byte) sum::a#2 = 9
Constant (const byte) sum::b#2 = $d
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with var siblings (const byte) sum::a#0
Inlining constant with var siblings (const byte) sum::b#0
Inlining constant with var siblings (const byte) sum::a#1
Inlining constant with var siblings (const byte) sum::b#1
Inlining constant with var siblings (const byte) sum::a#2
Inlining constant with var siblings (const byte) sum::b#2
Constant inlined sum::b#1 = (byte) 4
Constant inlined sum::a#2 = (byte) 9
Constant inlined sum::b#0 = (byte) 2
Constant inlined sum::a#1 = (byte) 3
Constant inlined sum::b#2 = (byte) $d
Constant inlined sum::a#0 = (byte) 1
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @3
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to sum:6 sum:9 sum:12 

Created 2 initial phi equivalence classes
Coalesced down to 2 phi equivalence classes
Culled Empty Block (label) @3
Renumbering block @2 to @1
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()
  [5] call sum 
  [6] (byte) sum::return#0 ← (byte) sum::return#3
  to:main::@1
main::@1: scope:[main]  from main
  [7] (byte) main::s1#0 ← (byte) sum::return#0
  [8] call sum 
  [9] (byte) sum::return#1 ← (byte) sum::return#3
  to:main::@2
main::@2: scope:[main]  from main::@1
  [10] (byte) main::s2#0 ← (byte) sum::return#1
  [11] call sum 
  [12] (byte) sum::return#2 ← (byte) sum::return#3
  to:main::@3
main::@3: scope:[main]  from main::@2
  [13] (byte) main::s3#0 ← (byte) sum::return#2
  [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0
  [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0
  [16] *((const byte*) screen) ← (byte) main::s4#0
  to:main::@return
main::@return: scope:[main]  from main::@3
  [17] return 
  to:@return

(byte()) sum((byte) sum::a , (byte) sum::b)
sum: scope:[sum]  from main main::@1 main::@2
  [18] (byte) sum::b#3 ← phi( main/(byte) 2 main::@1/(byte) 4 main::@2/(byte) $d )
  [18] (byte) sum::a#3 ← phi( main/(byte) 1 main::@1/(byte) 3 main::@2/(byte) 9 )
  [19] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3
  to:sum::@return
sum::@return: scope:[sum]  from sum
  [20] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(byte~) main::$3 4.0
(byte) main::s1
(byte) main::s1#0 0.5714285714285714
(byte) main::s2
(byte) main::s2#0 1.0
(byte) main::s3
(byte) main::s3#0 2.0
(byte) main::s4
(byte) main::s4#0 4.0
(byte()) sum((byte) sum::a , (byte) sum::b)
(byte) sum::a
(byte) sum::a#3 2.0
(byte) sum::b
(byte) sum::b#3 2.0
(byte) sum::return
(byte) sum::return#0 4.0
(byte) sum::return#1 4.0
(byte) sum::return#2 4.0
(byte) sum::return#3 1.6

Initial phi equivalence classes
[ sum::a#3 ]
[ sum::b#3 ]
Added variable sum::return#0 to live range equivalence class [ sum::return#0 ]
Added variable main::s1#0 to live range equivalence class [ main::s1#0 ]
Added variable sum::return#1 to live range equivalence class [ sum::return#1 ]
Added variable main::s2#0 to live range equivalence class [ main::s2#0 ]
Added variable sum::return#2 to live range equivalence class [ sum::return#2 ]
Added variable main::s3#0 to live range equivalence class [ main::s3#0 ]
Added variable main::$3 to live range equivalence class [ main::$3 ]
Added variable main::s4#0 to live range equivalence class [ main::s4#0 ]
Added variable sum::return#3 to live range equivalence class [ sum::return#3 ]
Complete equivalence classes
[ sum::a#3 ]
[ sum::b#3 ]
[ sum::return#0 ]
[ main::s1#0 ]
[ sum::return#1 ]
[ main::s2#0 ]
[ sum::return#2 ]
[ main::s3#0 ]
[ main::$3 ]
[ main::s4#0 ]
[ sum::return#3 ]
Allocated zp[1]:2 [ sum::a#3 ]
Allocated zp[1]:3 [ sum::b#3 ]
Allocated zp[1]:4 [ sum::return#0 ]
Allocated zp[1]:5 [ main::s1#0 ]
Allocated zp[1]:6 [ sum::return#1 ]
Allocated zp[1]:7 [ main::s2#0 ]
Allocated zp[1]:8 [ sum::return#2 ]
Allocated zp[1]:9 [ main::s3#0 ]
Allocated zp[1]:10 [ main::$3 ]
Allocated zp[1]:11 [ main::s4#0 ]
Allocated zp[1]:12 [ sum::return#3 ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label screen = $400
  // @begin
__bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
  jmp __b1
  // @1
__b1:
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
main_from___b1:
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
  jmp __bend
  // @end
__bend:
  // main
main: {
    .label __3 = $a
    .label s1 = 5
    .label s2 = 7
    .label s3 = 9
    .label s4 = $b
    // [5] call sum 
    // [18] phi from main to sum [phi:main->sum]
  sum_from_main:
    // [18] phi (byte) sum::b#3 = (byte) 2 [phi:main->sum#0] -- vbuz1=vbuc1 
    lda #2
    sta.z sum.b
    // [18] phi (byte) sum::a#3 = (byte) 1 [phi:main->sum#1] -- vbuz1=vbuc1 
    lda #1
    sta.z sum.a
    jsr sum
    // [6] (byte) sum::return#0 ← (byte) sum::return#3 -- vbuz1=vbuz2 
    lda.z sum.return_3
    sta.z sum.return
    jmp __b1
    // main::@1
  __b1:
    // [7] (byte) main::s1#0 ← (byte) sum::return#0 -- vbuz1=vbuz2 
    lda.z sum.return
    sta.z s1
    // [8] call sum 
    // [18] phi from main::@1 to sum [phi:main::@1->sum]
  sum_from___b1:
    // [18] phi (byte) sum::b#3 = (byte) 4 [phi:main::@1->sum#0] -- vbuz1=vbuc1 
    lda #4
    sta.z sum.b
    // [18] phi (byte) sum::a#3 = (byte) 3 [phi:main::@1->sum#1] -- vbuz1=vbuc1 
    lda #3
    sta.z sum.a
    jsr sum
    // [9] (byte) sum::return#1 ← (byte) sum::return#3 -- vbuz1=vbuz2 
    lda.z sum.return_3
    sta.z sum.return_1
    jmp __b2
    // main::@2
  __b2:
    // [10] (byte) main::s2#0 ← (byte) sum::return#1 -- vbuz1=vbuz2 
    lda.z sum.return_1
    sta.z s2
    // [11] call sum 
    // [18] phi from main::@2 to sum [phi:main::@2->sum]
  sum_from___b2:
    // [18] phi (byte) sum::b#3 = (byte) $d [phi:main::@2->sum#0] -- vbuz1=vbuc1 
    lda #$d
    sta.z sum.b
    // [18] phi (byte) sum::a#3 = (byte) 9 [phi:main::@2->sum#1] -- vbuz1=vbuc1 
    lda #9
    sta.z sum.a
    jsr sum
    // [12] (byte) sum::return#2 ← (byte) sum::return#3 -- vbuz1=vbuz2 
    lda.z sum.return_3
    sta.z sum.return_2
    jmp __b3
    // main::@3
  __b3:
    // [13] (byte) main::s3#0 ← (byte) sum::return#2 -- vbuz1=vbuz2 
    lda.z sum.return_2
    sta.z s3
    // [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 -- vbuz1=vbuz2_plus_vbuz3 
    lda.z s1
    clc
    adc.z s2
    sta.z __3
    // [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 -- vbuz1=vbuz2_plus_vbuz3 
    lda.z __3
    clc
    adc.z s3
    sta.z s4
    // [16] *((const byte*) screen) ← (byte) main::s4#0 -- _deref_pbuc1=vbuz1 
    lda.z s4
    sta screen
    jmp __breturn
    // main::@return
  __breturn:
    // [17] return 
    rts
}
  // sum
// sum(byte zp(2) a, byte zp(3) b)
sum: {
    .label return = 4
    .label return_1 = 6
    .label return_2 = 8
    .label return_3 = $c
    .label a = 2
    .label b = 3
    // [19] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 -- vbuz1=vbuz2_plus_vbuz3 
    lda.z a
    clc
    adc.z b
    sta.z return_3
    jmp __breturn
    // sum::@return
  __breturn:
    // [20] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 [ main::s3#0 main::$3 ] ( main:2 [ main::s3#0 main::$3 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:9 [ main::s3#0 ]
Statement [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ main::s4#0 ] ( main:2 [ main::s4#0 ] ) always clobbers reg byte a 
Statement [19] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:5 [ main::s1#0 ]
Removing always clobbered register reg byte a as potential for zp[1]:7 [ main::s2#0 ]
Statement [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 [ main::s3#0 main::$3 ] ( main:2 [ main::s3#0 main::$3 ] ) always clobbers reg byte a 
Statement [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 [ main::s4#0 ] ( main:2 [ main::s4#0 ] ) always clobbers reg byte a 
Statement [19] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 [ sum::return#3 ] ( main:2::sum:5 [ sum::return#3 ] main:2::sum:8 [ main::s1#0 sum::return#3 ] main:2::sum:11 [ main::s1#0 main::s2#0 sum::return#3 ] ) always clobbers reg byte a 
Potential registers zp[1]:2 [ sum::a#3 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ sum::b#3 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:4 [ sum::return#0 ] : zp[1]:4 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:5 [ main::s1#0 ] : zp[1]:5 , reg byte x , reg byte y , 
Potential registers zp[1]:6 [ sum::return#1 ] : zp[1]:6 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:7 [ main::s2#0 ] : zp[1]:7 , reg byte x , reg byte y , 
Potential registers zp[1]:8 [ sum::return#2 ] : zp[1]:8 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:9 [ main::s3#0 ] : zp[1]:9 , reg byte x , reg byte y , 
Potential registers zp[1]:10 [ main::$3 ] : zp[1]:10 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:11 [ main::s4#0 ] : zp[1]:11 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:12 [ sum::return#3 ] : zp[1]:12 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [sum] 4: zp[1]:4 [ sum::return#0 ] 4: zp[1]:6 [ sum::return#1 ] 4: zp[1]:8 [ sum::return#2 ] 2: zp[1]:2 [ sum::a#3 ] 2: zp[1]:3 [ sum::b#3 ] 1.6: zp[1]:12 [ sum::return#3 ] 
Uplift Scope [main] 4: zp[1]:10 [ main::$3 ] 4: zp[1]:11 [ main::s4#0 ] 2: zp[1]:9 [ main::s3#0 ] 1: zp[1]:7 [ main::s2#0 ] 0.57: zp[1]:5 [ main::s1#0 ] 
Uplift Scope [] 

Uplifting [sum] best 145 combination reg byte a [ sum::return#0 ] reg byte a [ sum::return#1 ] reg byte a [ sum::return#2 ] zp[1]:2 [ sum::a#3 ] zp[1]:3 [ sum::b#3 ] zp[1]:12 [ sum::return#3 ] 
Limited combination testing to 100 combinations of 4096 possible.
Uplifting [main] best 131 combination reg byte a [ main::$3 ] reg byte a [ main::s4#0 ] zp[1]:9 [ main::s3#0 ] reg byte x [ main::s2#0 ] zp[1]:5 [ main::s1#0 ] 
Limited combination testing to 100 combinations of 432 possible.
Uplifting [] best 131 combination 
Attempting to uplift remaining variables inzp[1]:2 [ sum::a#3 ]
Uplifting [sum] best 121 combination reg byte y [ sum::a#3 ] 
Attempting to uplift remaining variables inzp[1]:3 [ sum::b#3 ]
Uplifting [sum] best 113 combination reg byte a [ sum::b#3 ] 
Attempting to uplift remaining variables inzp[1]:9 [ main::s3#0 ]
Uplifting [main] best 113 combination zp[1]:9 [ main::s3#0 ] 
Attempting to uplift remaining variables inzp[1]:12 [ sum::return#3 ]
Uplifting [sum] best 101 combination reg byte a [ sum::return#3 ] 
Attempting to uplift remaining variables inzp[1]:5 [ main::s1#0 ]
Uplifting [main] best 101 combination zp[1]:5 [ main::s1#0 ] 
Allocated (was zp[1]:5) zp[1]:2 [ main::s1#0 ]
Allocated (was zp[1]:9) zp[1]:3 [ main::s3#0 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label screen = $400
  // @begin
__bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
  jmp __b1
  // @1
__b1:
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
main_from___b1:
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
  jmp __bend
  // @end
__bend:
  // main
main: {
    .label s1 = 2
    .label s3 = 3
    // [5] call sum 
    // [18] phi from main to sum [phi:main->sum]
  sum_from_main:
    // [18] phi (byte) sum::b#3 = (byte) 2 [phi:main->sum#0] -- vbuaa=vbuc1 
    lda #2
    // [18] phi (byte) sum::a#3 = (byte) 1 [phi:main->sum#1] -- vbuyy=vbuc1 
    ldy #1
    jsr sum
    // [6] (byte) sum::return#0 ← (byte) sum::return#3
    jmp __b1
    // main::@1
  __b1:
    // [7] (byte) main::s1#0 ← (byte) sum::return#0 -- vbuz1=vbuaa 
    sta.z s1
    // [8] call sum 
    // [18] phi from main::@1 to sum [phi:main::@1->sum]
  sum_from___b1:
    // [18] phi (byte) sum::b#3 = (byte) 4 [phi:main::@1->sum#0] -- vbuaa=vbuc1 
    lda #4
    // [18] phi (byte) sum::a#3 = (byte) 3 [phi:main::@1->sum#1] -- vbuyy=vbuc1 
    ldy #3
    jsr sum
    // [9] (byte) sum::return#1 ← (byte) sum::return#3
    jmp __b2
    // main::@2
  __b2:
    // [10] (byte) main::s2#0 ← (byte) sum::return#1 -- vbuxx=vbuaa 
    tax
    // [11] call sum 
    // [18] phi from main::@2 to sum [phi:main::@2->sum]
  sum_from___b2:
    // [18] phi (byte) sum::b#3 = (byte) $d [phi:main::@2->sum#0] -- vbuaa=vbuc1 
    lda #$d
    // [18] phi (byte) sum::a#3 = (byte) 9 [phi:main::@2->sum#1] -- vbuyy=vbuc1 
    ldy #9
    jsr sum
    // [12] (byte) sum::return#2 ← (byte) sum::return#3
    jmp __b3
    // main::@3
  __b3:
    // [13] (byte) main::s3#0 ← (byte) sum::return#2 -- vbuz1=vbuaa 
    sta.z s3
    // [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 -- vbuaa=vbuz1_plus_vbuxx 
    txa
    clc
    adc.z s1
    // [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 -- vbuaa=vbuaa_plus_vbuz1 
    clc
    adc.z s3
    // [16] *((const byte*) screen) ← (byte) main::s4#0 -- _deref_pbuc1=vbuaa 
    sta screen
    jmp __breturn
    // main::@return
  __breturn:
    // [17] return 
    rts
}
  // sum
// sum(byte register(Y) a, byte register(A) b)
sum: {
    // [19] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 -- vbuaa=vbuyy_plus_vbuaa 
    sty.z $ff
    clc
    adc.z $ff
    jmp __breturn
    // sum::@return
  __breturn:
    // [20] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __b3
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __bbegin with __b1
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction sum_from_main:
Removing instruction __b1:
Removing instruction sum_from___b1:
Removing instruction __b2:
Removing instruction sum_from___b2:
Removing instruction __b3:
Removing instruction __breturn:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction __b1:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(byte~) main::$3 reg byte a 4.0
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte) main::s1
(byte) main::s1#0 s1 zp[1]:2 0.5714285714285714
(byte) main::s2
(byte) main::s2#0 reg byte x 1.0
(byte) main::s3
(byte) main::s3#0 s3 zp[1]:3 2.0
(byte) main::s4
(byte) main::s4#0 reg byte a 4.0
(const byte*) screen = (byte*) 1024
(byte()) sum((byte) sum::a , (byte) sum::b)
(label) sum::@return
(byte) sum::a
(byte) sum::a#3 reg byte y 2.0
(byte) sum::b
(byte) sum::b#3 reg byte a 2.0
(byte) sum::return
(byte) sum::return#0 reg byte a 4.0
(byte) sum::return#1 reg byte a 4.0
(byte) sum::return#2 reg byte a 4.0
(byte) sum::return#3 reg byte a 1.6

reg byte y [ sum::a#3 ]
reg byte a [ sum::b#3 ]
reg byte a [ sum::return#0 ]
zp[1]:2 [ main::s1#0 ]
reg byte a [ sum::return#1 ]
reg byte x [ main::s2#0 ]
reg byte a [ sum::return#2 ]
zp[1]:3 [ main::s3#0 ]
reg byte a [ main::$3 ]
reg byte a [ main::s4#0 ]
reg byte a [ sum::return#3 ]


FINAL ASSEMBLER
Score: 74

  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .label screen = $400
  // @begin
  // [1] phi from @begin to @1 [phi:@begin->@1]
  // @1
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    .label s1 = 2
    .label s3 = 3
    // sum(1,2)
    // [5] call sum 
    // [18] phi from main to sum [phi:main->sum]
    // [18] phi (byte) sum::b#3 = (byte) 2 [phi:main->sum#0] -- vbuaa=vbuc1 
    lda #2
    // [18] phi (byte) sum::a#3 = (byte) 1 [phi:main->sum#1] -- vbuyy=vbuc1 
    ldy #1
    jsr sum
    // sum(1,2)
    // [6] (byte) sum::return#0 ← (byte) sum::return#3
    // main::@1
    // s1=sum(1,2)
    // [7] (byte) main::s1#0 ← (byte) sum::return#0 -- vbuz1=vbuaa 
    sta.z s1
    // sum(3,4)
    // [8] call sum 
    // [18] phi from main::@1 to sum [phi:main::@1->sum]
    // [18] phi (byte) sum::b#3 = (byte) 4 [phi:main::@1->sum#0] -- vbuaa=vbuc1 
    lda #4
    // [18] phi (byte) sum::a#3 = (byte) 3 [phi:main::@1->sum#1] -- vbuyy=vbuc1 
    ldy #3
    jsr sum
    // sum(3,4)
    // [9] (byte) sum::return#1 ← (byte) sum::return#3
    // main::@2
    // s2=sum(3,4)
    // [10] (byte) main::s2#0 ← (byte) sum::return#1 -- vbuxx=vbuaa 
    tax
    // sum(9,13)
    // [11] call sum 
    // [18] phi from main::@2 to sum [phi:main::@2->sum]
    // [18] phi (byte) sum::b#3 = (byte) $d [phi:main::@2->sum#0] -- vbuaa=vbuc1 
    lda #$d
    // [18] phi (byte) sum::a#3 = (byte) 9 [phi:main::@2->sum#1] -- vbuyy=vbuc1 
    ldy #9
    jsr sum
    // sum(9,13)
    // [12] (byte) sum::return#2 ← (byte) sum::return#3
    // main::@3
    // s3=sum(9,13)
    // [13] (byte) main::s3#0 ← (byte) sum::return#2 -- vbuz1=vbuaa 
    sta.z s3
    // s1+s2
    // [14] (byte~) main::$3 ← (byte) main::s1#0 + (byte) main::s2#0 -- vbuaa=vbuz1_plus_vbuxx 
    txa
    clc
    adc.z s1
    // s4=s1+s2+s3
    // [15] (byte) main::s4#0 ← (byte~) main::$3 + (byte) main::s3#0 -- vbuaa=vbuaa_plus_vbuz1 
    clc
    adc.z s3
    // *screen = s4
    // [16] *((const byte*) screen) ← (byte) main::s4#0 -- _deref_pbuc1=vbuaa 
    sta screen
    // main::@return
    // }
    // [17] return 
    rts
}
  // sum
// sum(byte register(Y) a, byte register(A) b)
sum: {
    // a+b
    // [19] (byte) sum::return#3 ← (byte) sum::a#3 + (byte) sum::b#3 -- vbuaa=vbuyy_plus_vbuaa 
    sty.z $ff
    clc
    adc.z $ff
    // sum::@return
    // }
    // [20] return 
    rts
}
  // File Data

