Inlined call main::$1 = call toD018(screen, charset1)
Inlined call main::$3 = call toD018(screen, charset2)
Inlined call call __init

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start::@1
  asm { sei  }
  to:main::@1
main::@1: scope:[main]  from main main::@7
  if(true) goto main::@2
  to:main::@return
main::@2: scope:[main]  from main::@1 main::@2
  main::$0 = *RASTER != $ff
  if(main::$0) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@2
  main::toD0181_screen#0 = screen
  main::toD0181_charset#0 = charset1
  to:main::toD0181
main::toD0181: scope:[main]  from main::@3
  main::toD0181_charset#1 = phi( main::@3/main::toD0181_charset#0 )
  main::toD0181_screen#1 = phi( main::@3/main::toD0181_screen#0 )
  main::toD0181_$3 = (unsigned int)main::toD0181_screen#1
  main::toD0181_$0 = main::toD0181_$3 / $40
  main::toD0181_$4 = (unsigned int)main::toD0181_charset#1
  main::toD0181_$1 = main::toD0181_$4 / $400
  main::toD0181_$2 = main::toD0181_$0 | main::toD0181_$1
  main::toD0181_return#0 = (char)main::toD0181_$2
  to:main::toD0181_@return
main::toD0181_@return: scope:[main]  from main::toD0181
  main::toD0181_return#2 = phi( main::toD0181/main::toD0181_return#0 )
  main::toD0181_return#1 = main::toD0181_return#2
  to:main::@6
main::@6: scope:[main]  from main::toD0181_@return
  main::toD0181_return#3 = phi( main::toD0181_@return/main::toD0181_return#1 )
  main::$1 = main::toD0181_return#3
  *D018 = main::$1
  *BG_COLOR = 6
  to:main::@4
main::@4: scope:[main]  from main::@4 main::@6
  main::$2 = *RASTER != $62
  if(main::$2) goto main::@4
  to:main::@5
main::@5: scope:[main]  from main::@4
  main::toD0182_screen#0 = screen
  main::toD0182_charset#0 = charset2
  to:main::toD0182
main::toD0182: scope:[main]  from main::@5
  main::toD0182_charset#1 = phi( main::@5/main::toD0182_charset#0 )
  main::toD0182_screen#1 = phi( main::@5/main::toD0182_screen#0 )
  main::toD0182_$3 = (unsigned int)main::toD0182_screen#1
  main::toD0182_$0 = main::toD0182_$3 / $40
  main::toD0182_$4 = (unsigned int)main::toD0182_charset#1
  main::toD0182_$1 = main::toD0182_$4 / $400
  main::toD0182_$2 = main::toD0182_$0 | main::toD0182_$1
  main::toD0182_return#0 = (char)main::toD0182_$2
  to:main::toD0182_@return
main::toD0182_@return: scope:[main]  from main::toD0182
  main::toD0182_return#2 = phi( main::toD0182/main::toD0182_return#0 )
  main::toD0182_return#1 = main::toD0182_return#2
  to:main::@7
main::@7: scope:[main]  from main::toD0182_@return
  main::toD0182_return#3 = phi( main::toD0182_@return/main::toD0182_return#1 )
  main::$3 = main::toD0182_return#3
  *D018 = main::$3
  *BG_COLOR = $b
  to:main::@1
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 *BG_COLOR = (char *)$d021
__constant char *D018 = (char *)$d018
__constant char *RASTER = (char *)$d012
void __start()
__constant char *charset1 = (char *)$1000
__constant char *charset2 = (char *)$1800
void main()
bool main::$0
char main::$1
bool main::$2
char main::$3
number main::toD0181_$0
number main::toD0181_$1
number main::toD0181_$2
unsigned int main::toD0181_$3
unsigned int main::toD0181_$4
char *main::toD0181_charset
char *main::toD0181_charset#0
char *main::toD0181_charset#1
char main::toD0181_return
char main::toD0181_return#0
char main::toD0181_return#1
char main::toD0181_return#2
char main::toD0181_return#3
char *main::toD0181_screen
char *main::toD0181_screen#0
char *main::toD0181_screen#1
number main::toD0182_$0
number main::toD0182_$1
number main::toD0182_$2
unsigned int main::toD0182_$3
unsigned int main::toD0182_$4
char *main::toD0182_charset
char *main::toD0182_charset#0
char *main::toD0182_charset#1
char main::toD0182_return
char main::toD0182_return#0
char main::toD0182_return#1
char main::toD0182_return#2
char main::toD0182_return#3
char *main::toD0182_screen
char *main::toD0182_screen#0
char *main::toD0182_screen#1
__constant char *screen = (char *)$400

Adding number conversion cast (unumber) $ff in main::$0 = *RASTER != $ff
Adding number conversion cast (unumber) $40 in main::toD0181_$0 = main::toD0181_$3 / $40
Adding number conversion cast (unumber) main::toD0181_$0 in main::toD0181_$0 = main::toD0181_$3 / (unumber)$40
Adding number conversion cast (unumber) $400 in main::toD0181_$1 = main::toD0181_$4 / $400
Adding number conversion cast (unumber) main::toD0181_$1 in main::toD0181_$1 = main::toD0181_$4 / (unumber)$400
Adding number conversion cast (unumber) main::toD0181_$2 in main::toD0181_$2 = main::toD0181_$0 | main::toD0181_$1
Adding number conversion cast (unumber) 6 in *BG_COLOR = 6
Adding number conversion cast (unumber) $62 in main::$2 = *RASTER != $62
Adding number conversion cast (unumber) $40 in main::toD0182_$0 = main::toD0182_$3 / $40
Adding number conversion cast (unumber) main::toD0182_$0 in main::toD0182_$0 = main::toD0182_$3 / (unumber)$40
Adding number conversion cast (unumber) $400 in main::toD0182_$1 = main::toD0182_$4 / $400
Adding number conversion cast (unumber) main::toD0182_$1 in main::toD0182_$1 = main::toD0182_$4 / (unumber)$400
Adding number conversion cast (unumber) main::toD0182_$2 in main::toD0182_$2 = main::toD0182_$0 | main::toD0182_$1
Adding number conversion cast (unumber) $b in *BG_COLOR = $b
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast *BG_COLOR = (unumber)6
Inlining cast *BG_COLOR = (unumber)$b
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (char *) 53266
Simplifying constant pointer cast (char *) 53272
Simplifying constant pointer cast (char *) 53281
Simplifying constant pointer cast (char *) 1024
Simplifying constant pointer cast (char *) 4096
Simplifying constant pointer cast (char *) 6144
Simplifying constant integer cast $ff
Simplifying constant integer cast $40
Simplifying constant integer cast $400
Simplifying constant integer cast 6
Simplifying constant integer cast $62
Simplifying constant integer cast $40
Simplifying constant integer cast $400
Simplifying constant integer cast $b
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) $ff
Finalized unsigned number type (char) $40
Finalized unsigned number type (unsigned int) $400
Finalized unsigned number type (char) 6
Finalized unsigned number type (char) $62
Finalized unsigned number type (char) $40
Finalized unsigned number type (unsigned int) $400
Finalized unsigned number type (char) $b
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to unsigned int in main::toD0181_$0 = main::toD0181_$3 / $40
Inferred type updated to unsigned int in main::toD0181_$1 = main::toD0181_$4 / $400
Inferred type updated to unsigned int in main::toD0181_$2 = main::toD0181_$0 | main::toD0181_$1
Inferred type updated to unsigned int in main::toD0182_$0 = main::toD0182_$3 / $40
Inferred type updated to unsigned int in main::toD0182_$1 = main::toD0182_$4 / $400
Inferred type updated to unsigned int in main::toD0182_$2 = main::toD0182_$0 | main::toD0182_$1
Alias main::toD0181_screen#0 = main::toD0181_screen#1 
Alias main::toD0181_charset#0 = main::toD0181_charset#1 
Alias main::toD0181_return#0 = main::toD0181_return#2 main::toD0181_return#1 main::toD0181_return#3 main::$1 
Alias main::toD0182_screen#0 = main::toD0182_screen#1 
Alias main::toD0182_charset#0 = main::toD0182_charset#1 
Alias main::toD0182_return#0 = main::toD0182_return#2 main::toD0182_return#1 main::toD0182_return#3 main::$3 
Successful SSA optimization Pass2AliasElimination
Simple Condition main::$0 [3] if(*RASTER!=$ff) goto main::@2
Simple Condition main::$2 [15] if(*RASTER!=$62) goto main::@4
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant main::toD0181_screen#0 = screen
Constant main::toD0181_charset#0 = charset1
Constant main::toD0182_screen#0 = screen
Constant main::toD0182_charset#0 = charset2
Successful SSA optimization Pass2ConstantIdentification
Constant main::toD0181_$3 = (unsigned int)main::toD0181_screen#0
Constant main::toD0181_$4 = (unsigned int)main::toD0181_charset#0
Constant main::toD0182_$3 = (unsigned int)main::toD0182_screen#0
Constant main::toD0182_$4 = (unsigned int)main::toD0182_charset#0
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [1] if(true) goto main::@2
Successful SSA optimization Pass2ConstantIfs
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
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 [2] main::toD0181_$0 = main::toD0181_$3 / $40
Constant right-side identified [3] main::toD0181_$1 = main::toD0181_$4 / $400
Constant right-side identified [9] main::toD0182_$0 = main::toD0182_$3 / $40
Constant right-side identified [10] main::toD0182_$1 = main::toD0182_$4 / $400
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::toD0181_$0 = main::toD0181_$3/$40
Constant main::toD0181_$1 = main::toD0181_$4/$400
Constant main::toD0182_$0 = main::toD0182_$3/$40
Constant main::toD0182_$1 = main::toD0182_$4/$400
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [2] main::toD0181_$2 = main::toD0181_$0 | main::toD0181_$1
Constant right-side identified [7] main::toD0182_$2 = main::toD0182_$0 | main::toD0182_$1
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::toD0181_$2 = main::toD0181_$0|main::toD0181_$1
Constant main::toD0182_$2 = main::toD0182_$0|main::toD0182_$1
Successful SSA optimization Pass2ConstantIdentification
Constant main::toD0181_return#0 = (char)main::toD0181_$2
Constant main::toD0182_return#0 = (char)main::toD0182_$2
Successful SSA optimization Pass2ConstantIdentification
Constant inlined main::toD0181_screen#0 = screen
Constant inlined main::toD0182_charset#0 = charset2
Constant inlined main::toD0182_$4 = (unsigned int)charset2
Constant inlined main::toD0181_$2 = (unsigned int)screen/$40|(unsigned int)charset1/$400
Constant inlined main::toD0181_$1 = (unsigned int)charset1/$400
Constant inlined main::toD0181_$0 = (unsigned int)screen/$40
Constant inlined main::toD0182_$0 = (unsigned int)screen/$40
Constant inlined main::toD0182_$1 = (unsigned int)charset2/$400
Constant inlined main::toD0181_$4 = (unsigned int)charset1
Constant inlined main::toD0182_$2 = (unsigned int)screen/$40|(unsigned int)charset2/$400
Constant inlined main::toD0181_$3 = (unsigned int)screen
Constant inlined main::toD0182_$3 = (unsigned int)screen
Constant inlined main::toD0182_screen#0 = screen
Constant inlined main::toD0181_charset#0 = charset1
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of main::@1
Adding NOP phi() at start of main::@3
Adding NOP phi() at start of main::toD0181
Adding NOP phi() at start of main::toD0181_@return
Adding NOP phi() at start of main::@5
Adding NOP phi() at start of main::toD0182
Adding NOP phi() at start of main::toD0182_@return
CALL GRAPH

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block label main::@1
Culled Empty Block label main::@3
Culled Empty Block label main::toD0181_@return
Culled Empty Block label main::@5
Culled Empty Block label main::toD0182_@return
Renumbering block main::@2 to main::@1
Renumbering block main::@4 to main::@2
Renumbering block main::@6 to main::@3
Renumbering block main::@7 to main::@4
Adding NOP phi() at start of main::toD0181
Adding NOP phi() at start of main::toD0182

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  asm { sei  }
  to:main::@1
main::@1: scope:[main]  from main main::@1 main::@4
  [1] if(*RASTER!=$ff) goto main::@1
  to:main::toD0181
main::toD0181: scope:[main]  from main::@1
  [2] phi()
  to:main::@3
main::@3: scope:[main]  from main::toD0181
  [3] *D018 = main::toD0181_return#0
  [4] *BG_COLOR = 6
  to:main::@2
main::@2: scope:[main]  from main::@2 main::@3
  [5] if(*RASTER!=$62) goto main::@2
  to:main::toD0182
main::toD0182: scope:[main]  from main::@2
  [6] phi()
  to:main::@4
main::@4: scope:[main]  from main::toD0182
  [7] *D018 = main::toD0182_return#0
  [8] *BG_COLOR = $b
  to:main::@1


VARIABLE REGISTER WEIGHTS
void main()
char *main::toD0181_charset
char main::toD0181_return
char *main::toD0181_screen
char *main::toD0182_charset
char main::toD0182_return
char *main::toD0182_screen

Initial phi equivalence classes
Complete equivalence classes
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [1] if(*RASTER!=$ff) goto main::@1 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [3] *D018 = main::toD0181_return#0 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [4] *BG_COLOR = 6 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [5] if(*RASTER!=$62) goto main::@2 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [7] *D018 = main::toD0182_return#0 [ ] (  [ ] { }  ) always clobbers reg byte a 
Statement [8] *BG_COLOR = $b [ ] (  [ ] { }  ) always clobbers reg byte a 

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

Uplifting [main] best 2125 combination 
Uplifting [] best 2125 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test inline function
// Splits screen so upper half is lower case and lower half lower case
  // Upstart
  // Commodore 64 PRG executable file
.file [name="inline-function.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 RASTER = $d012
  .label D018 = $d018
  .label BG_COLOR = $d021
  .label screen = $400
  .label charset1 = $1000
  .label charset2 = $1800
.segment Code
  // main
main: {
    .const toD0181_return = screen/$40|charset1/$400
    .const toD0182_return = screen/$40|charset2/$400
    // asm { sei  }
    sei
    jmp __b1
    // main::@1
  __b1:
    // [1] if(*RASTER!=$ff) goto main::@1 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$ff
    cmp RASTER
    bne __b1
    // [2] phi from main::@1 to main::toD0181 [phi:main::@1->main::toD0181]
  toD0181_from___b1:
    jmp toD0181
    // main::toD0181
  toD0181:
    jmp __b3
    // main::@3
  __b3:
    // [3] *D018 = main::toD0181_return#0 -- _deref_pbuc1=vbuc2 
    lda #toD0181_return
    sta D018
    // [4] *BG_COLOR = 6 -- _deref_pbuc1=vbuc2 
    lda #6
    sta BG_COLOR
    jmp __b2
    // main::@2
  __b2:
    // [5] if(*RASTER!=$62) goto main::@2 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$62
    cmp RASTER
    bne __b2
    // [6] phi from main::@2 to main::toD0182 [phi:main::@2->main::toD0182]
  toD0182_from___b2:
    jmp toD0182
    // main::toD0182
  toD0182:
    jmp __b4
    // main::@4
  __b4:
    // [7] *D018 = main::toD0182_return#0 -- _deref_pbuc1=vbuc2 
    lda #toD0182_return
    sta D018
    // [8] *BG_COLOR = $b -- _deref_pbuc1=vbuc2 
    lda #$b
    sta BG_COLOR
    jmp __b1
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp toD0181
Removing instruction jmp __b3
Removing instruction jmp __b2
Removing instruction jmp toD0182
Removing instruction jmp __b4
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction toD0181_from___b1:
Removing instruction toD0181:
Removing instruction toD0182_from___b2:
Removing instruction toD0182:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b3:
Removing instruction __b4:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
__constant char *BG_COLOR = (char *) 53281
__constant char *D018 = (char *) 53272
__constant char *RASTER = (char *) 53266
__constant char *charset1 = (char *) 4096
__constant char *charset2 = (char *) 6144
void main()
char *main::toD0181_charset
char main::toD0181_return
__constant char main::toD0181_return#0 = (char)(unsigned int)screen/$40|(unsigned int)charset1/$400 // toD0181_return
char *main::toD0181_screen
char *main::toD0182_charset
char main::toD0182_return
__constant char main::toD0182_return#0 = (char)(unsigned int)screen/$40|(unsigned int)charset2/$400 // toD0182_return
char *main::toD0182_screen
__constant char *screen = (char *) 1024



FINAL ASSEMBLER
Score: 1972

  // File Comments
// Test inline function
// Splits screen so upper half is lower case and lower half lower case
  // Upstart
  // Commodore 64 PRG executable file
.file [name="inline-function.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 RASTER = $d012
  .label D018 = $d018
  .label BG_COLOR = $d021
  .label screen = $400
  .label charset1 = $1000
  .label charset2 = $1800
.segment Code
  // main
main: {
    .const toD0181_return = screen/$40|charset1/$400
    .const toD0182_return = screen/$40|charset2/$400
    // asm
    // asm { sei  }
    sei
    // main::@1
  __b1:
    // while(*RASTER!=$ff)
    // [1] if(*RASTER!=$ff) goto main::@1 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$ff
    cmp RASTER
    bne __b1
    // [2] phi from main::@1 to main::toD0181 [phi:main::@1->main::toD0181]
    // main::toD0181
    // main::@3
    // *D018 = toD018(screen, charset1)
    // [3] *D018 = main::toD0181_return#0 -- _deref_pbuc1=vbuc2 
    lda #toD0181_return
    sta D018
    // *BG_COLOR = $6
    // [4] *BG_COLOR = 6 -- _deref_pbuc1=vbuc2 
    lda #6
    sta BG_COLOR
    // main::@2
  __b2:
    // while(*RASTER!=$62)
    // [5] if(*RASTER!=$62) goto main::@2 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$62
    cmp RASTER
    bne __b2
    // [6] phi from main::@2 to main::toD0182 [phi:main::@2->main::toD0182]
    // main::toD0182
    // main::@4
    // *D018 = toD018(screen, charset2)
    // [7] *D018 = main::toD0182_return#0 -- _deref_pbuc1=vbuc2 
    lda #toD0182_return
    sta D018
    // *BG_COLOR = $b
    // [8] *BG_COLOR = $b -- _deref_pbuc1=vbuc2 
    lda #$b
    sta BG_COLOR
    jmp __b1
}
  // File Data

