Inlined call main::$0 = call sum(2, 1)
Inlined call main::$1 = call sum($a, 3)
Inlined call main::$2 = call sum(4, 8)
Inlined call call __init

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start::@1
  main::sum1_a#0 = 2
  main::sum1_b#0 = 1
  to:main::sum1
main::sum1: scope:[main]  from main
  main::sum1_b#1 = phi( main/main::sum1_b#0 )
  main::sum1_a#1 = phi( main/main::sum1_a#0 )
  main::sum1_$0 = main::sum1_a#1 + main::sum1_b#1
  main::sum1_return#0 = main::sum1_$0
  to:main::sum1_@return
main::sum1_@return: scope:[main]  from main::sum1
  main::sum1_return#2 = phi( main::sum1/main::sum1_return#0 )
  main::sum1_return#1 = main::sum1_return#2
  to:main::@1
main::@1: scope:[main]  from main::sum1_@return
  main::sum1_return#3 = phi( main::sum1_@return/main::sum1_return#1 )
  main::$0 = main::sum1_return#3
  screen[0] = main::$0
  main::sum2_a#0 = $a
  main::sum2_b#0 = 3
  to:main::sum2
main::sum2: scope:[main]  from main::@1
  main::sum2_b#1 = phi( main::@1/main::sum2_b#0 )
  main::sum2_a#1 = phi( main::@1/main::sum2_a#0 )
  main::sum2_$0 = main::sum2_a#1 + main::sum2_b#1
  main::sum2_return#0 = main::sum2_$0
  to:main::sum2_@return
main::sum2_@return: scope:[main]  from main::sum2
  main::sum2_return#2 = phi( main::sum2/main::sum2_return#0 )
  main::sum2_return#1 = main::sum2_return#2
  to:main::@2
main::@2: scope:[main]  from main::sum2_@return
  main::sum2_return#3 = phi( main::sum2_@return/main::sum2_return#1 )
  main::$1 = main::sum2_return#3
  screen[1] = main::$1
  main::sum3_a#0 = 4
  main::sum3_b#0 = 8
  to:main::sum3
main::sum3: scope:[main]  from main::@2
  main::sum3_b#1 = phi( main::@2/main::sum3_b#0 )
  main::sum3_a#1 = phi( main::@2/main::sum3_a#0 )
  main::sum3_$0 = main::sum3_a#1 + main::sum3_b#1
  main::sum3_return#0 = main::sum3_$0
  to:main::sum3_@return
main::sum3_@return: scope:[main]  from main::sum3
  main::sum3_return#2 = phi( main::sum3/main::sum3_return#0 )
  main::sum3_return#1 = main::sum3_return#2
  to:main::@3
main::@3: scope:[main]  from main::sum3_@return
  main::sum3_return#3 = phi( main::sum3_@return/main::sum3_return#1 )
  main::$2 = main::sum3_return#3
  screen[2] = main::$2
  to:main::@return
main::@return: scope:[main]  from main::@3
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  to:__start::__init1
__start::__init1: scope:[__start]  from __start
  to:__start::@1
__start::@1: scope:[__start]  from __start::__init1
  call main
  to:__start::@2
__start::@2: scope:[__start]  from __start::@1
  to:__start::@return
__start::@return: scope:[__start]  from __start::@2
  return 
  to:@return

SYMBOL TABLE SSA
void __start()
void main()
char main::$0
char main::$1
char main::$2
char main::sum1_$0
char main::sum1_a
char main::sum1_a#0
char main::sum1_a#1
char main::sum1_b
char main::sum1_b#0
char main::sum1_b#1
char main::sum1_return
char main::sum1_return#0
char main::sum1_return#1
char main::sum1_return#2
char main::sum1_return#3
char main::sum2_$0
char main::sum2_a
char main::sum2_a#0
char main::sum2_a#1
char main::sum2_b
char main::sum2_b#0
char main::sum2_b#1
char main::sum2_return
char main::sum2_return#0
char main::sum2_return#1
char main::sum2_return#2
char main::sum2_return#3
char main::sum3_$0
char main::sum3_a
char main::sum3_a#0
char main::sum3_a#1
char main::sum3_b
char main::sum3_b#0
char main::sum3_b#1
char main::sum3_return
char main::sum3_return#0
char main::sum3_return#1
char main::sum3_return#2
char main::sum3_return#3
__constant char *screen = (char *)$400

Adding number conversion cast (unumber) 2 in main::sum1_a#0 = 2
Adding number conversion cast (unumber) 1 in main::sum1_b#0 = 1
Adding number conversion cast (unumber) 0 in screen[0] = main::$0
Adding number conversion cast (unumber) $a in main::sum2_a#0 = $a
Adding number conversion cast (unumber) 3 in main::sum2_b#0 = 3
Adding number conversion cast (unumber) 1 in screen[1] = main::$1
Adding number conversion cast (unumber) 4 in main::sum3_a#0 = 4
Adding number conversion cast (unumber) 8 in main::sum3_b#0 = 8
Adding number conversion cast (unumber) 2 in screen[2] = main::$2
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast main::sum1_a#0 = (unumber)2
Inlining cast main::sum1_b#0 = (unumber)1
Inlining cast main::sum2_a#0 = (unumber)$a
Inlining cast main::sum2_b#0 = (unumber)3
Inlining cast main::sum3_a#0 = (unumber)4
Inlining cast main::sum3_b#0 = (unumber)8
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 2
Simplifying constant integer cast 1
Simplifying constant integer cast 0
Simplifying constant integer cast $a
Simplifying constant integer cast 3
Simplifying constant integer cast 1
Simplifying constant integer cast 4
Simplifying constant integer cast 8
Simplifying constant integer cast 2
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 2
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) $a
Finalized unsigned number type (char) 3
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 4
Finalized unsigned number type (char) 8
Finalized unsigned number type (char) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias main::sum1_a#0 = main::sum1_a#1 
Alias main::sum1_b#0 = main::sum1_b#1 
Alias main::sum1_return#0 = main::sum1_$0 main::sum1_return#2 main::sum1_return#1 main::sum1_return#3 main::$0 
Alias main::sum2_a#0 = main::sum2_a#1 
Alias main::sum2_b#0 = main::sum2_b#1 
Alias main::sum2_return#0 = main::sum2_$0 main::sum2_return#2 main::sum2_return#1 main::sum2_return#3 main::$1 
Alias main::sum3_a#0 = main::sum3_a#1 
Alias main::sum3_b#0 = main::sum3_b#1 
Alias main::sum3_return#0 = main::sum3_$0 main::sum3_return#2 main::sum3_return#1 main::sum3_return#3 main::$2 
Successful SSA optimization Pass2AliasElimination
Constant main::sum1_a#0 = 2
Constant main::sum1_b#0 = 1
Constant main::sum2_a#0 = $a
Constant main::sum2_b#0 = 3
Constant main::sum3_a#0 = 4
Constant main::sum3_b#0 = 8
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero screen in [3] screen[0] = main::sum1_return#0
Successful SSA optimization PassNSimplifyExpressionWithZero
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::__init1
Removing unused procedure block __start::@1
Removing unused procedure block __start::@2
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Constant right-side identified [0] main::sum1_return#0 = main::sum1_a#0 + main::sum1_b#0
Constant right-side identified [2] main::sum2_return#0 = main::sum2_a#0 + main::sum2_b#0
Constant right-side identified [4] main::sum3_return#0 = main::sum3_a#0 + main::sum3_b#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::sum1_return#0 = main::sum1_a#0+main::sum1_b#0
Constant main::sum2_return#0 = main::sum2_a#0+main::sum2_b#0
Constant main::sum3_return#0 = main::sum3_a#0+main::sum3_b#0
Successful SSA optimization Pass2ConstantIdentification
Consolidated array index constant in *(screen+1)
Consolidated array index constant in *(screen+2)
Successful SSA optimization Pass2ConstantAdditionElimination
Adding NOP phi() at start of main
Adding NOP phi() at start of main::sum1
Adding NOP phi() at start of main::sum1_@return
Adding NOP phi() at start of main::sum2
Adding NOP phi() at start of main::sum2_@return
Adding NOP phi() at start of main::sum3
Adding NOP phi() at start of main::sum3_@return
CALL GRAPH

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block label main::sum1_@return
Culled Empty Block label main::sum2_@return
Culled Empty Block label main::sum3_@return
Adding NOP phi() at start of main
Adding NOP phi() at start of main::sum1
Adding NOP phi() at start of main::sum2
Adding NOP phi() at start of main::sum3

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] phi()
  to:main::sum1
main::sum1: scope:[main]  from main
  [1] phi()
  to:main::@1
main::@1: scope:[main]  from main::sum1
  [2] *screen = main::sum1_return#0
  to:main::sum2
main::sum2: scope:[main]  from main::@1
  [3] phi()
  to:main::@2
main::@2: scope:[main]  from main::sum2
  [4] *(screen+1) = main::sum2_return#0
  to:main::sum3
main::sum3: scope:[main]  from main::@2
  [5] phi()
  to:main::@3
main::@3: scope:[main]  from main::sum3
  [6] *(screen+2) = main::sum3_return#0
  to:main::@return
main::@return: scope:[main]  from main::@3
  [7] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
char main::sum1_a
char main::sum1_b
char main::sum1_return
char main::sum2_a
char main::sum2_b
char main::sum2_return
char main::sum3_a
char main::sum3_b
char main::sum3_return

Initial phi equivalence classes
Complete equivalence classes
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [2] *screen = main::sum1_return#0 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [4] *(screen+1) = main::sum2_return#0 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [6] *(screen+2) = main::sum3_return#0 [ ] (  [ ] { }  ) always clobbers reg byte a 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 
Uplift Scope [] 

Uplifting [main] best 126 combination 
Uplifting [] best 126 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test minimal inline function
  // Upstart
  // Commodore 64 PRG executable file
.file [name="inline-function-min.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
  // Global Constants & labels
  .label screen = $400
.segment Code
  // main
main: {
    .const sum1_a = 2
    .const sum1_b = 1
    .const sum2_a = $a
    .const sum2_b = 3
    .const sum3_a = 4
    .const sum3_b = 8
    .const sum1_return = sum1_a+sum1_b
    .const sum2_return = sum2_a+sum2_b
    .const sum3_return = sum3_a+sum3_b
    // [1] phi from main to main::sum1 [phi:main->main::sum1]
  sum1_from_main:
    jmp sum1
    // main::sum1
  sum1:
    jmp __b1
    // main::@1
  __b1:
    // [2] *screen = main::sum1_return#0 -- _deref_pbuc1=vbuc2 
    lda #sum1_return
    sta screen
    // [3] phi from main::@1 to main::sum2 [phi:main::@1->main::sum2]
  sum2_from___b1:
    jmp sum2
    // main::sum2
  sum2:
    jmp __b2
    // main::@2
  __b2:
    // [4] *(screen+1) = main::sum2_return#0 -- _deref_pbuc1=vbuc2 
    lda #sum2_return
    sta screen+1
    // [5] phi from main::@2 to main::sum3 [phi:main::@2->main::sum3]
  sum3_from___b2:
    jmp sum3
    // main::sum3
  sum3:
    jmp __b3
    // main::@3
  __b3:
    // [6] *(screen+2) = main::sum3_return#0 -- _deref_pbuc1=vbuc2 
    lda #sum3_return
    sta screen+2
    jmp __breturn
    // main::@return
  __breturn:
    // [7] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp sum1
Removing instruction jmp __b1
Removing instruction jmp sum2
Removing instruction jmp __b2
Removing instruction jmp sum3
Removing instruction jmp __b3
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction sum1_from_main:
Removing instruction sum1:
Removing instruction sum2_from___b1:
Removing instruction sum2:
Removing instruction sum3_from___b2:
Removing instruction sum3:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1:
Removing instruction __b2:
Removing instruction __b3:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
void main()
char main::sum1_a
__constant char main::sum1_a#0 = 2 // sum1_a
char main::sum1_b
__constant char main::sum1_b#0 = 1 // sum1_b
char main::sum1_return
__constant char main::sum1_return#0 = main::sum1_a#0+main::sum1_b#0 // sum1_return
char main::sum2_a
__constant char main::sum2_a#0 = $a // sum2_a
char main::sum2_b
__constant char main::sum2_b#0 = 3 // sum2_b
char main::sum2_return
__constant char main::sum2_return#0 = main::sum2_a#0+main::sum2_b#0 // sum2_return
char main::sum3_a
__constant char main::sum3_a#0 = 4 // sum3_a
char main::sum3_b
__constant char main::sum3_b#0 = 8 // sum3_b
char main::sum3_return
__constant char main::sum3_return#0 = main::sum3_a#0+main::sum3_b#0 // sum3_return
__constant char *screen = (char *) 1024



FINAL ASSEMBLER
Score: 24

  // File Comments
// Test minimal inline function
  // Upstart
  // Commodore 64 PRG executable file
.file [name="inline-function-min.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
  // Global Constants & labels
  .label screen = $400
.segment Code
  // main
main: {
    .const sum1_a = 2
    .const sum1_b = 1
    .const sum2_a = $a
    .const sum2_b = 3
    .const sum3_a = 4
    .const sum3_b = 8
    .const sum1_return = sum1_a+sum1_b
    .const sum2_return = sum2_a+sum2_b
    .const sum3_return = sum3_a+sum3_b
    // [1] phi from main to main::sum1 [phi:main->main::sum1]
    // main::sum1
    // main::@1
    // screen[0] = sum(2, 1)
    // [2] *screen = main::sum1_return#0 -- _deref_pbuc1=vbuc2 
    lda #sum1_return
    sta screen
    // [3] phi from main::@1 to main::sum2 [phi:main::@1->main::sum2]
    // main::sum2
    // main::@2
    // screen[1] = sum(10, 3)
    // [4] *(screen+1) = main::sum2_return#0 -- _deref_pbuc1=vbuc2 
    lda #sum2_return
    sta screen+1
    // [5] phi from main::@2 to main::sum3 [phi:main::@2->main::sum3]
    // main::sum3
    // main::@3
    // screen[2] = sum(4, 8)
    // [6] *(screen+2) = main::sum3_return#0 -- _deref_pbuc1=vbuc2 
    lda #sum3_return
    sta screen+2
    // main::@return
    // }
    // [7] return 
    rts
}
  // File Data

