Inlined call call __init

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start::@1
  cnt#17 = phi( __start::@1/cnt#18 )
  call inccnt
  to:main::@1
main::@1: scope:[main]  from main
  cnt#10 = phi( main/cnt#6 )
  cnt#0 = cnt#10
  SCREEN[0] = cnt#0
  cnt#1 = ++ cnt#0
  call inccnt
  to:main::@2
main::@2: scope:[main]  from main::@1
  cnt#11 = phi( main::@1/cnt#6 )
  cnt#2 = cnt#11
  cnt#3 = ++ cnt#2
  SCREEN[1] = cnt#3
  to:main::@return
main::@return: scope:[main]  from main::@2
  cnt#12 = phi( main::@2/cnt#3 )
  cnt#4 = cnt#12
  return 
  to:@return

void inccnt()
inccnt: scope:[inccnt]  from main main::@1
  cnt#13 = phi( main/cnt#17, main::@1/cnt#1 )
  cnt#5 = ++ cnt#13
  to:inccnt::@return
inccnt::@return: scope:[inccnt]  from inccnt
  cnt#14 = phi( inccnt/cnt#5 )
  cnt#6 = cnt#14
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  to:__start::__init1
__start::__init1: scope:[__start]  from __start
  cnt#7 = 0
  to:__start::@1
__start::@1: scope:[__start]  from __start::__init1
  cnt#18 = phi( __start::__init1/cnt#7 )
  call main
  to:__start::@2
__start::@2: scope:[__start]  from __start::@1
  cnt#15 = phi( __start::@1/cnt#4 )
  cnt#8 = cnt#15
  to:__start::@return
__start::@return: scope:[__start]  from __start::@2
  cnt#16 = phi( __start::@2/cnt#8 )
  cnt#9 = cnt#16
  return 
  to:@return

SYMBOL TABLE SSA
__constant char SCREEN[$100] = (char *)$400
void __start()
char cnt
char cnt#0
char cnt#1
char cnt#10
char cnt#11
char cnt#12
char cnt#13
char cnt#14
char cnt#15
char cnt#16
char cnt#17
char cnt#18
char cnt#2
char cnt#3
char cnt#4
char cnt#5
char cnt#6
char cnt#7
char cnt#8
char cnt#9
void inccnt()
void main()

Adding number conversion cast (unumber) 0 in SCREEN[0] = cnt#0
Adding number conversion cast (unumber) 1 in SCREEN[1] = cnt#3
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias cnt#0 = cnt#10 
Alias cnt#11 = cnt#2 
Alias cnt#12 = cnt#3 cnt#4 
Alias cnt#14 = cnt#5 cnt#6 
Alias cnt#18 = cnt#7 
Alias cnt#15 = cnt#8 cnt#16 cnt#9 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values cnt#17 cnt#18
Identical Phi Values cnt#0 cnt#14
Identical Phi Values cnt#11 cnt#14
Identical Phi Values cnt#15 cnt#12
Successful SSA optimization Pass2IdenticalPhiElimination
Constant cnt#18 = 0
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero SCREEN in [3] SCREEN[0] = cnt#14
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
Inlining constant with var siblings cnt#18
Constant inlined cnt#18 = 0
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(SCREEN+1)
Successful SSA optimization Pass2ConstantAdditionElimination
Finalized unsigned number type (unsigned int) $100
Successful SSA optimization PassNFinalizeNumberTypeConversions
Adding NOP phi() at start of main
CALL GRAPH
Calls in [main] to inccnt:1 inccnt:5 

Created 1 initial phi equivalence classes
Coalesced [4] cnt#19 = cnt#1
Coalesced down to 1 phi equivalence classes
Adding NOP phi() at start of main

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] phi()
  [1] call inccnt
  to:main::@1
main::@1: scope:[main]  from main
  [2] *SCREEN = cnt#14
  [3] cnt#1 = ++ cnt#14
  [4] call inccnt
  to:main::@2
main::@2: scope:[main]  from main::@1
  [5] cnt#12 = ++ cnt#14
  [6] *(SCREEN+1) = cnt#12
  to:main::@return
main::@return: scope:[main]  from main::@2
  [7] return 
  to:@return

void inccnt()
inccnt: scope:[inccnt]  from main main::@1
  [8] cnt#13 = phi( main/0, main::@1/cnt#1 )
  [9] cnt#14 = ++ cnt#13
  to:inccnt::@return
inccnt::@return: scope:[inccnt]  from inccnt
  [10] return 
  to:@return


VARIABLE REGISTER WEIGHTS
char cnt
char cnt#1 // 4.0
char cnt#12 // 4.0
char cnt#13 // 13.0
char cnt#14 // 3.4000000000000004
void inccnt()
void main()

Initial phi equivalence classes
[ cnt#13 cnt#1 ]
Added variable cnt#12 to live range equivalence class [ cnt#12 ]
Added variable cnt#14 to live range equivalence class [ cnt#14 ]
Complete equivalence classes
[ cnt#13 cnt#1 ]
[ cnt#12 ]
[ cnt#14 ]
Allocated zp[1]:2 [ cnt#13 cnt#1 ]
Allocated zp[1]:3 [ cnt#12 ]
Allocated zp[1]:4 [ cnt#14 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Potential registers zp[1]:2 [ cnt#13 cnt#1 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ cnt#12 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:4 [ cnt#14 ] : zp[1]:4 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [] 17: zp[1]:2 [ cnt#13 cnt#1 ] 4: zp[1]:3 [ cnt#12 ] 3.4: zp[1]:4 [ cnt#14 ] 
Uplift Scope [main] 
Uplift Scope [inccnt] 

Uplifting [] best 52 combination reg byte x [ cnt#13 cnt#1 ] reg byte x [ cnt#12 ] reg byte x [ cnt#14 ] 
Uplifting [main] best 52 combination 
Uplifting [inccnt] best 52 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
  // Upstart
  // Commodore 64 PRG executable file
.file [name="modglobalmin.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 inccnt
    // [8] phi from main to inccnt [phi:main->inccnt]
  inccnt_from_main:
    // [8] phi cnt#13 = 0 [phi:main->inccnt#0] -- vbuxx=vbuc1 
    ldx #0
    jsr inccnt
    jmp __b1
    // main::@1
  __b1:
    // [2] *SCREEN = cnt#14 -- _deref_pbuc1=vbuxx 
    stx SCREEN
    // [3] cnt#1 = ++ cnt#14 -- vbuxx=_inc_vbuxx 
    inx
    // [4] call inccnt
    // [8] phi from main::@1 to inccnt [phi:main::@1->inccnt]
  inccnt_from___b1:
    // [8] phi cnt#13 = cnt#1 [phi:main::@1->inccnt#0] -- register_copy 
    jsr inccnt
    jmp __b2
    // main::@2
  __b2:
    // [5] cnt#12 = ++ cnt#14 -- vbuxx=_inc_vbuxx 
    inx
    // [6] *(SCREEN+1) = cnt#12 -- _deref_pbuc1=vbuxx 
    stx SCREEN+1
    jmp __breturn
    // main::@return
  __breturn:
    // [7] return 
    rts
}
  // inccnt
inccnt: {
    // [9] cnt#14 = ++ cnt#13 -- vbuxx=_inc_vbuxx 
    inx
    jmp __breturn
    // inccnt::@return
  __breturn:
    // [10] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction inccnt_from_main:
Removing instruction __b1:
Removing instruction inccnt_from___b1:
Removing instruction __b2:
Removing instruction __breturn:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
__constant char SCREEN[$100] = (char *) 1024
char cnt
char cnt#1 // reg byte x 4.0
char cnt#12 // reg byte x 4.0
char cnt#13 // reg byte x 13.0
char cnt#14 // reg byte x 3.4000000000000004
void inccnt()
void main()

reg byte x [ cnt#13 cnt#1 ]
reg byte x [ cnt#12 ]
reg byte x [ cnt#14 ]


FINAL ASSEMBLER
Score: 40

  // File Comments
  // Upstart
  // Commodore 64 PRG executable file
.file [name="modglobalmin.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: {
    // inccnt()
    // [1] call inccnt
    // [8] phi from main to inccnt [phi:main->inccnt]
    // [8] phi cnt#13 = 0 [phi:main->inccnt#0] -- vbuxx=vbuc1 
    ldx #0
    jsr inccnt
    // main::@1
    // SCREEN[0]=cnt++
    // [2] *SCREEN = cnt#14 -- _deref_pbuc1=vbuxx 
    stx SCREEN
    // SCREEN[0]=cnt++;
    // [3] cnt#1 = ++ cnt#14 -- vbuxx=_inc_vbuxx 
    inx
    // inccnt()
    // [4] call inccnt
    // [8] phi from main::@1 to inccnt [phi:main::@1->inccnt]
    // [8] phi cnt#13 = cnt#1 [phi:main::@1->inccnt#0] -- register_copy 
    jsr inccnt
    // main::@2
    // SCREEN[1]=++cnt;
    // [5] cnt#12 = ++ cnt#14 -- vbuxx=_inc_vbuxx 
    inx
    // SCREEN[1]=++cnt
    // [6] *(SCREEN+1) = cnt#12 -- _deref_pbuc1=vbuxx 
    stx SCREEN+1
    // main::@return
    // }
    // [7] return 
    rts
}
  // inccnt
inccnt: {
    // ++cnt;
    // [9] cnt#14 = ++ cnt#13 -- vbuxx=_inc_vbuxx 
    inx
    // inccnt::@return
    // }
    // [10] return 
    rts
}
  // File Data

