Inlined call (byte~) main::$0 ← call sum (byte/signed byte/word/signed word/dword/signed dword) 2 (byte/signed byte/word/signed word/dword/signed dword) 1 
Inlined call (byte~) main::$1 ← call sum (byte/signed byte/word/signed word/dword/signed dword) 10 (byte/signed byte/word/signed word/dword/signed dword) 3 
Inlined call (byte~) main::$2 ← call sum (byte/signed byte/word/signed word/dword/signed dword) 4 (byte/signed byte/word/signed word/dword/signed dword) 8 

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) screen#0 ← ((byte*)) (word/signed word/dword/signed dword) 1024
  to:@2
main: scope:[main]  from @2
  (byte*) screen#10 ← phi( @2/(byte*) screen#11 )
  (byte) main::sum1_a#0 ← (byte/signed byte/word/signed word/dword/signed dword) 2
  (byte) main::sum1_b#0 ← (byte/signed byte/word/signed word/dword/signed dword) 1
  to:main::sum1
main::sum1: scope:[main]  from main
  (byte*) screen#7 ← phi( main/(byte*) screen#10 )
  (byte) main::sum1_b#1 ← phi( main/(byte) main::sum1_b#0 )
  (byte) main::sum1_a#1 ← phi( main/(byte) main::sum1_a#0 )
  (byte) main::sum1_$0#0 ← (byte) main::sum1_a#1 + (byte) main::sum1_b#1
  (byte) main::sum1_return#0 ← (byte) main::sum1_$0#0
  to:main::sum1_@return
main::sum1_@return: scope:[main]  from main::sum1
  (byte*) screen#4 ← phi( main::sum1/(byte*) screen#7 )
  (byte) main::sum1_return#2 ← phi( main::sum1/(byte) main::sum1_return#0 )
  (byte) main::sum1_return#1 ← (byte) main::sum1_return#2
  to:main::@1
main::@1: scope:[main]  from main::sum1_@return
  (byte*) screen#1 ← phi( main::sum1_@return/(byte*) screen#4 )
  (byte) main::sum1_return#3 ← phi( main::sum1_@return/(byte) main::sum1_return#1 )
  (byte~) main::$0 ← (byte) main::sum1_return#3
  *((byte*) screen#1 + (byte/signed byte/word/signed word/dword/signed dword) 0) ← (byte~) main::$0
  (byte) main::sum2_a#0 ← (byte/signed byte/word/signed word/dword/signed dword) 10
  (byte) main::sum2_b#0 ← (byte/signed byte/word/signed word/dword/signed dword) 3
  to:main::sum2
main::sum2: scope:[main]  from main::@1
  (byte*) screen#8 ← phi( main::@1/(byte*) screen#1 )
  (byte) main::sum2_b#1 ← phi( main::@1/(byte) main::sum2_b#0 )
  (byte) main::sum2_a#1 ← phi( main::@1/(byte) main::sum2_a#0 )
  (byte) main::sum2_$0#0 ← (byte) main::sum2_a#1 + (byte) main::sum2_b#1
  (byte) main::sum2_return#0 ← (byte) main::sum2_$0#0
  to:main::sum2_@return
main::sum2_@return: scope:[main]  from main::sum2
  (byte*) screen#5 ← phi( main::sum2/(byte*) screen#8 )
  (byte) main::sum2_return#2 ← phi( main::sum2/(byte) main::sum2_return#0 )
  (byte) main::sum2_return#1 ← (byte) main::sum2_return#2
  to:main::@2
main::@2: scope:[main]  from main::sum2_@return
  (byte*) screen#2 ← phi( main::sum2_@return/(byte*) screen#5 )
  (byte) main::sum2_return#3 ← phi( main::sum2_@return/(byte) main::sum2_return#1 )
  (byte~) main::$1 ← (byte) main::sum2_return#3
  *((byte*) screen#2 + (byte/signed byte/word/signed word/dword/signed dword) 1) ← (byte~) main::$1
  (byte) main::sum3_a#0 ← (byte/signed byte/word/signed word/dword/signed dword) 4
  (byte) main::sum3_b#0 ← (byte/signed byte/word/signed word/dword/signed dword) 8
  to:main::sum3
main::sum3: scope:[main]  from main::@2
  (byte*) screen#9 ← phi( main::@2/(byte*) screen#2 )
  (byte) main::sum3_b#1 ← phi( main::@2/(byte) main::sum3_b#0 )
  (byte) main::sum3_a#1 ← phi( main::@2/(byte) main::sum3_a#0 )
  (byte) main::sum3_$0#0 ← (byte) main::sum3_a#1 + (byte) main::sum3_b#1
  (byte) main::sum3_return#0 ← (byte) main::sum3_$0#0
  to:main::sum3_@return
main::sum3_@return: scope:[main]  from main::sum3
  (byte*) screen#6 ← phi( main::sum3/(byte*) screen#9 )
  (byte) main::sum3_return#2 ← phi( main::sum3/(byte) main::sum3_return#0 )
  (byte) main::sum3_return#1 ← (byte) main::sum3_return#2
  to:main::@3
main::@3: scope:[main]  from main::sum3_@return
  (byte*) screen#3 ← phi( main::sum3_@return/(byte*) screen#6 )
  (byte) main::sum3_return#3 ← phi( main::sum3_@return/(byte) main::sum3_return#1 )
  (byte~) main::$2 ← (byte) main::sum3_return#3
  *((byte*) screen#3 + (byte/signed byte/word/signed word/dword/signed dword) 2) ← (byte~) main::$2
  to:main::@return
main::@return: scope:[main]  from main::@3
  return 
  to:@return
@2: scope:[]  from @begin
  (byte*) screen#11 ← phi( @begin/(byte*) screen#0 )
  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
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(label) main::sum1
(byte~) main::sum1_$0
(byte) main::sum1_$0#0
(label) main::sum1_@return
(byte) main::sum1_a
(byte) main::sum1_a#0
(byte) main::sum1_a#1
(byte) main::sum1_b
(byte) main::sum1_b#0
(byte) main::sum1_b#1
(byte) main::sum1_return
(byte) main::sum1_return#0
(byte) main::sum1_return#1
(byte) main::sum1_return#2
(byte) main::sum1_return#3
(label) main::sum2
(byte~) main::sum2_$0
(byte) main::sum2_$0#0
(label) main::sum2_@return
(byte) main::sum2_a
(byte) main::sum2_a#0
(byte) main::sum2_a#1
(byte) main::sum2_b
(byte) main::sum2_b#0
(byte) main::sum2_b#1
(byte) main::sum2_return
(byte) main::sum2_return#0
(byte) main::sum2_return#1
(byte) main::sum2_return#2
(byte) main::sum2_return#3
(label) main::sum3
(byte~) main::sum3_$0
(byte) main::sum3_$0#0
(label) main::sum3_@return
(byte) main::sum3_a
(byte) main::sum3_a#0
(byte) main::sum3_a#1
(byte) main::sum3_b
(byte) main::sum3_b#0
(byte) main::sum3_b#1
(byte) main::sum3_return
(byte) main::sum3_return#0
(byte) main::sum3_return#1
(byte) main::sum3_return#2
(byte) main::sum3_return#3
(byte*) screen
(byte*) screen#0
(byte*) screen#1
(byte*) screen#10
(byte*) screen#11
(byte*) screen#2
(byte*) screen#3
(byte*) screen#4
(byte*) screen#5
(byte*) screen#6
(byte*) screen#7
(byte*) screen#8
(byte*) screen#9

Culled Empty Block (label) @3
Successful SSA optimization Pass2CullEmptyBlocks
Alias (byte) main::sum1_a#0 = (byte) main::sum1_a#1 
Alias (byte) main::sum1_b#0 = (byte) main::sum1_b#1 
Alias (byte*) screen#1 = (byte*) screen#7 (byte*) screen#10 (byte*) screen#4 (byte*) screen#8 (byte*) screen#5 (byte*) screen#2 (byte*) screen#9 (byte*) screen#6 (byte*) screen#3 
Alias (byte) main::sum1_return#0 = (byte) main::sum1_$0#0 (byte) main::sum1_return#2 (byte) main::sum1_return#1 (byte) main::sum1_return#3 (byte~) main::$0 
Alias (byte) main::sum2_a#0 = (byte) main::sum2_a#1 
Alias (byte) main::sum2_b#0 = (byte) main::sum2_b#1 
Alias (byte) main::sum2_return#0 = (byte) main::sum2_$0#0 (byte) main::sum2_return#2 (byte) main::sum2_return#1 (byte) main::sum2_return#3 (byte~) main::$1 
Alias (byte) main::sum3_a#0 = (byte) main::sum3_a#1 
Alias (byte) main::sum3_b#0 = (byte) main::sum3_b#1 
Alias (byte) main::sum3_return#0 = (byte) main::sum3_$0#0 (byte) main::sum3_return#2 (byte) main::sum3_return#1 (byte) main::sum3_return#3 (byte~) main::$2 
Alias (byte*) screen#0 = (byte*) screen#11 
Successful SSA optimization Pass2AliasElimination
Redundant Phi (byte*) screen#1 (byte*) screen#0
Successful SSA optimization Pass2RedundantPhiElimination
Constant (const byte*) screen#0 = ((byte*))1024
Constant (const byte) main::sum1_a#0 = 2
Constant (const byte) main::sum1_b#0 = 1
Constant (const byte) main::sum2_a#0 = 10
Constant (const byte) main::sum2_b#0 = 3
Constant (const byte) main::sum3_a#0 = 4
Constant (const byte) main::sum3_b#0 = 8
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte) main::sum1_return#0 = main::sum1_a#0+main::sum1_b#0
Constant (const byte) main::sum2_return#0 = main::sum2_a#0+main::sum2_b#0
Constant (const byte) main::sum3_return#0 = main::sum3_a#0+main::sum3_b#0
Successful SSA optimization Pass2ConstantIdentification
Consolidated array index constant in *(screen#0+0)
Consolidated array index constant in *(screen#0+1)
Consolidated array index constant in *(screen#0+2)
Successful SSA optimization Pass2ConstantAdditionElimination
Culled Empty Block (label) main::sum1_@return
Culled Empty Block (label) main::sum2_@return
Culled Empty Block (label) main::sum3_@return
Successful SSA optimization Pass2CullEmptyBlocks
Simplifying constant plus zero screen#0+0
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
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
CALL GRAPH
Calls in [] to main:2 

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
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
@begin: scope:[]  from
  [0] phi()
  to:@2
@2: scope:[]  from @begin
  [1] phi()
  [2] call main 
  to:@end
@end: scope:[]  from @2
  [3] phi()
main: scope:[main]  from @2
  [4] phi()
  to:main::sum1
main::sum1: scope:[main]  from main
  [5] phi()
  to:main::@1
main::@1: scope:[main]  from main::sum1
  [6] *((const byte*) screen#0) ← (const byte) main::sum1_return#0
  to:main::sum2
main::sum2: scope:[main]  from main::@1
  [7] phi()
  to:main::@2
main::@2: scope:[main]  from main::sum2
  [8] *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (const byte) main::sum2_return#0
  to:main::sum3
main::sum3: scope:[main]  from main::@2
  [9] phi()
  to:main::@3
main::@3: scope:[main]  from main::sum3
  [10] *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (const byte) main::sum3_return#0
  to:main::@return
main::@return: scope:[main]  from main::@3
  [11] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(byte~) main::sum1_$0
(byte) main::sum1_a
(byte) main::sum1_b
(byte) main::sum1_return
(byte~) main::sum2_$0
(byte) main::sum2_a
(byte) main::sum2_b
(byte) main::sum2_return
(byte~) main::sum3_$0
(byte) main::sum3_a
(byte) main::sum3_b
(byte) main::sum3_return
(byte*) screen

Initial phi equivalence classes
Complete equivalence classes

INITIAL ASM
//SEG0 File Comments
// Test minimal inline function
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label screen = $400
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @2 [phi:@begin->@2]
b2_from_bbegin:
  jmp b2
//SEG5 @2
b2:
//SEG6 [2] call main 
//SEG7 [4] phi from @2 to main [phi:@2->main]
main_from_b2:
  jsr main
//SEG8 [3] phi from @2 to @end [phi:@2->@end]
bend_from_b2:
  jmp bend
//SEG9 @end
bend:
//SEG10 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
  //SEG11 [5] phi from main to main::sum1 [phi:main->main::sum1]
  sum1_from_main:
    jmp sum1
  //SEG12 main::sum1
  sum1:
    jmp b1
  //SEG13 main::@1
  b1:
  //SEG14 [6] *((const byte*) screen#0) ← (const byte) main::sum1_return#0 -- _deref_pbuc1=vbuc2 
    lda #sum1_return
    sta screen
  //SEG15 [7] phi from main::@1 to main::sum2 [phi:main::@1->main::sum2]
  sum2_from_b1:
    jmp sum2
  //SEG16 main::sum2
  sum2:
    jmp b2
  //SEG17 main::@2
  b2:
  //SEG18 [8] *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (const byte) main::sum2_return#0 -- _deref_pbuc1=vbuc2 
    lda #sum2_return
    sta screen+1
  //SEG19 [9] phi from main::@2 to main::sum3 [phi:main::@2->main::sum3]
  sum3_from_b2:
    jmp sum3
  //SEG20 main::sum3
  sum3:
    jmp b3
  //SEG21 main::@3
  b3:
  //SEG22 [10] *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (const byte) main::sum3_return#0 -- _deref_pbuc1=vbuc2 
    lda #sum3_return
    sta screen+2
    jmp breturn
  //SEG23 main::@return
  breturn:
  //SEG24 [11] return 
    rts
}

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] *((const byte*) screen#0) ← (const byte) main::sum1_return#0 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [8] *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (const byte) main::sum2_return#0 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [10] *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (const byte) main::sum3_return#0 [ ] ( main:2 [ ] ) always clobbers reg byte a 

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

Uplifting [main] best 138 combination 
Uplifting [] best 138 combination 

ASSEMBLER BEFORE OPTIMIZATION
//SEG0 File Comments
// Test minimal inline function
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label screen = $400
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @2 [phi:@begin->@2]
b2_from_bbegin:
  jmp b2
//SEG5 @2
b2:
//SEG6 [2] call main 
//SEG7 [4] phi from @2 to main [phi:@2->main]
main_from_b2:
  jsr main
//SEG8 [3] phi from @2 to @end [phi:@2->@end]
bend_from_b2:
  jmp bend
//SEG9 @end
bend:
//SEG10 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
  //SEG11 [5] phi from main to main::sum1 [phi:main->main::sum1]
  sum1_from_main:
    jmp sum1
  //SEG12 main::sum1
  sum1:
    jmp b1
  //SEG13 main::@1
  b1:
  //SEG14 [6] *((const byte*) screen#0) ← (const byte) main::sum1_return#0 -- _deref_pbuc1=vbuc2 
    lda #sum1_return
    sta screen
  //SEG15 [7] phi from main::@1 to main::sum2 [phi:main::@1->main::sum2]
  sum2_from_b1:
    jmp sum2
  //SEG16 main::sum2
  sum2:
    jmp b2
  //SEG17 main::@2
  b2:
  //SEG18 [8] *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (const byte) main::sum2_return#0 -- _deref_pbuc1=vbuc2 
    lda #sum2_return
    sta screen+1
  //SEG19 [9] phi from main::@2 to main::sum3 [phi:main::@2->main::sum3]
  sum3_from_b2:
    jmp sum3
  //SEG20 main::sum3
  sum3:
    jmp b3
  //SEG21 main::@3
  b3:
  //SEG22 [10] *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (const byte) main::sum3_return#0 -- _deref_pbuc1=vbuc2 
    lda #sum3_return
    sta screen+2
    jmp breturn
  //SEG23 main::@return
  breturn:
  //SEG24 [11] return 
    rts
}

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b2
Removing instruction jmp bend
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 b2_from_bbegin:
Removing instruction b2:
Removing instruction main_from_b2:
Removing instruction bend_from_b2:
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 bend:
Removing instruction b1:
Removing instruction b2:
Removing instruction b3:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @2
(label) @begin
(label) @end
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(label) main::sum1
(byte~) main::sum1_$0
(byte) main::sum1_a
(const byte) main::sum1_a#0 sum1_a = (byte/signed byte/word/signed word/dword/signed dword) 2
(byte) main::sum1_b
(const byte) main::sum1_b#0 sum1_b = (byte/signed byte/word/signed word/dword/signed dword) 1
(byte) main::sum1_return
(const byte) main::sum1_return#0 sum1_return = (const byte) main::sum1_a#0+(const byte) main::sum1_b#0
(label) main::sum2
(byte~) main::sum2_$0
(byte) main::sum2_a
(const byte) main::sum2_a#0 sum2_a = (byte/signed byte/word/signed word/dword/signed dword) 10
(byte) main::sum2_b
(const byte) main::sum2_b#0 sum2_b = (byte/signed byte/word/signed word/dword/signed dword) 3
(byte) main::sum2_return
(const byte) main::sum2_return#0 sum2_return = (const byte) main::sum2_a#0+(const byte) main::sum2_b#0
(label) main::sum3
(byte~) main::sum3_$0
(byte) main::sum3_a
(const byte) main::sum3_a#0 sum3_a = (byte/signed byte/word/signed word/dword/signed dword) 4
(byte) main::sum3_b
(const byte) main::sum3_b#0 sum3_b = (byte/signed byte/word/signed word/dword/signed dword) 8
(byte) main::sum3_return
(const byte) main::sum3_return#0 sum3_return = (const byte) main::sum3_a#0+(const byte) main::sum3_b#0
(byte*) screen
(const byte*) screen#0 screen = ((byte*))(word/signed word/dword/signed dword) 1024



FINAL ASSEMBLER
Score: 24

//SEG0 File Comments
// Test minimal inline function
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label screen = $400
//SEG3 @begin
//SEG4 [1] phi from @begin to @2 [phi:@begin->@2]
//SEG5 @2
//SEG6 [2] call main 
//SEG7 [4] phi from @2 to main [phi:@2->main]
//SEG8 [3] phi from @2 to @end [phi:@2->@end]
//SEG9 @end
//SEG10 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
  //SEG11 [5] phi from main to main::sum1 [phi:main->main::sum1]
  //SEG12 main::sum1
  //SEG13 main::@1
  //SEG14 [6] *((const byte*) screen#0) ← (const byte) main::sum1_return#0 -- _deref_pbuc1=vbuc2 
    lda #sum1_return
    sta screen
  //SEG15 [7] phi from main::@1 to main::sum2 [phi:main::@1->main::sum2]
  //SEG16 main::sum2
  //SEG17 main::@2
  //SEG18 [8] *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 1) ← (const byte) main::sum2_return#0 -- _deref_pbuc1=vbuc2 
    lda #sum2_return
    sta screen+1
  //SEG19 [9] phi from main::@2 to main::sum3 [phi:main::@2->main::sum3]
  //SEG20 main::sum3
  //SEG21 main::@3
  //SEG22 [10] *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 2) ← (const byte) main::sum3_return#0 -- _deref_pbuc1=vbuc2 
    lda #sum3_return
    sta screen+2
  //SEG23 main::@return
  //SEG24 [11] return 
    rts
}

