Inlined call call __init

CONTROL FLOW GRAPH SSA

unsigned int strlen(char *str)
strlen: scope:[strlen]  from main
  strlen::return#0 = 'x'
  to:strlen::@return
strlen::@return: scope:[strlen]  from strlen
  strlen::return#3 = phi( strlen/strlen::return#0 )
  strlen::return#1 = strlen::return#3
  return 
  to:@return

void main()
main: scope:[main]  from __start::@1
  strlen::str#0 = STR
  call strlen
  strlen::return#2 = strlen::return#1
  to:main::@1
main::@1: scope:[main]  from main
  strlen::return#4 = phi( main/strlen::return#2 )
  main::$0 = strlen::return#4
  SCREEN[0] = (char)main::$0
  to:main::@return
main::@return: scope:[main]  from main::@1
  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
__constant char * const SCREEN = (char *)$400
__constant char *STR = "camelot!"
void __start()
void main()
unsigned int main::$0
unsigned int strlen(char *str)
unsigned int strlen::return
unsigned int strlen::return#0
unsigned int strlen::return#1
unsigned int strlen::return#2
unsigned int strlen::return#3
unsigned int strlen::return#4
char *strlen::str
char *strlen::str#0

Adding number conversion cast (unumber) 0 in SCREEN[0] = (char)main::$0
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias strlen::return#0 = strlen::return#3 strlen::return#1 
Alias strlen::return#2 = strlen::return#4 
Successful SSA optimization Pass2AliasElimination
Constant strlen::return#0 = 'x'
Constant strlen::str#0 = STR
Successful SSA optimization Pass2ConstantIdentification
Constant strlen::return#2 = strlen::return#0
Successful SSA optimization Pass2ConstantIdentification
Constant main::$0 = strlen::return#2
Successful SSA optimization Pass2ConstantIdentification
Constant value identified (char)main::$0 in [6] SCREEN[0] = (char)main::$0
Successful SSA optimization Pass2ConstantValues
Simplifying expression containing zero SCREEN in [6] SCREEN[0] = (char)main::$0
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant strlen::str#0
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused constant STR
Successful SSA optimization PassNEliminateUnusedVars
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
Inlining constant with different constant siblings strlen::return#2
Constant inlined strlen::return#2 = strlen::return#0
Constant inlined main::$0 = strlen::return#0
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of main
Adding NOP phi() at start of strlen
CALL GRAPH
Calls in [main] to strlen:1 

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Adding NOP phi() at start of main
Adding NOP phi() at start of strlen

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] phi()
  [1] call strlen
  to:main::@1
main::@1: scope:[main]  from main
  [2] *SCREEN = (char)strlen::return#0
  to:main::@return
main::@return: scope:[main]  from main::@1
  [3] return 
  to:@return

unsigned int strlen(char *str)
strlen: scope:[strlen]  from main
  [4] phi()
  to:strlen::@return
strlen::@return: scope:[strlen]  from strlen
  [5] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
unsigned int strlen(char *str)
unsigned int strlen::return
char *strlen::str

Initial phi equivalence classes
Complete equivalence classes
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [2] *SCREEN = (char)strlen::return#0 [ ] (  [ ] { }  ) always clobbers reg byte a 

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

Uplifting [strlen] best 60 combination 
Uplifting [main] best 60 combination 
Uplifting [] best 60 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Includes a local file with the same name as a system library
  // Upstart
  // Commodore 64 PRG executable file
.file [name="includes-2.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: {
    // [1] call strlen
    // [4] phi from main to strlen [phi:main->strlen]
  strlen_from_main:
    jsr strlen
    jmp __b1
    // main::@1
  __b1:
    // [2] *SCREEN = (char)strlen::return#0 -- _deref_pbuc1=vbuc2 
    lda #strlen.return
    sta SCREEN
    jmp __breturn
    // main::@return
  __breturn:
    // [3] return 
    rts
}
  // strlen
// A local stdlib include file
// unsigned int strlen(char *str)
strlen: {
    .label return = 'x'
    jmp __breturn
    // strlen::@return
  __breturn:
    // [5] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction strlen_from_main:
Removing instruction __b1:
Removing instruction __breturn:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
__constant char * const SCREEN = (char *) 1024
void main()
unsigned int strlen(char *str)
unsigned int strlen::return
__constant unsigned int strlen::return#0 = 'x' // return
char *strlen::str



FINAL ASSEMBLER
Score: 24

  // File Comments
// Includes a local file with the same name as a system library
  // Upstart
  // Commodore 64 PRG executable file
.file [name="includes-2.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: {
    // strlen(STR)
    // [1] call strlen
    // [4] phi from main to strlen [phi:main->strlen]
    jsr strlen
    // main::@1
    // SCREEN [0] = (char) strlen(STR)
    // [2] *SCREEN = (char)strlen::return#0 -- _deref_pbuc1=vbuc2 
    lda #strlen.return
    sta SCREEN
    // main::@return
    // }
    // [3] return 
    rts
}
  // strlen
// A local stdlib include file
// unsigned int strlen(char *str)
strlen: {
    .label return = 'x'
    // strlen::@return
    // [5] return 
    rts
}
  // File Data

