Inlined call call __init

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start::@1
  main::i#0 = 0
  to:main::@1
main::@1: scope:[main]  from main main::@6
  main::i#2 = phi( main/main::i#0, main::@6/main::i#1 )
  plot::x#0 = main::i#2
  call plot
  to:main::@6
main::@6: scope:[main]  from main::@1
  main::i#3 = phi( main::@1/main::i#2 )
  main::i#1 = main::i#3 + rangenext(0,$a)
  main::$1 = main::i#1 != rangelast(0,$a)
  if(main::$1) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@6
  main::j#0 = 0
  to:main::@3
main::@3: scope:[main]  from main::@2 main::@7
  main::j#2 = phi( main::@2/main::j#0, main::@7/main::j#1 )
  plot::x#1 = main::j#2
  call plot
  to:main::@7
main::@7: scope:[main]  from main::@3
  main::j#3 = phi( main::@3/main::j#2 )
  main::j#1 = main::j#3 + rangenext(0,$a)
  main::$3 = main::j#1 != rangelast(0,$a)
  if(main::$3) goto main::@3
  to:main::@4
main::@4: scope:[main]  from main::@7
  main::k#0 = 0
  to:main::@5
main::@5: scope:[main]  from main::@4 main::@8
  main::k#2 = phi( main::@4/main::k#0, main::@8/main::k#1 )
  plot::x#2 = main::k#2
  call plot
  to:main::@8
main::@8: scope:[main]  from main::@5
  main::k#3 = phi( main::@5/main::k#2 )
  main::k#1 = main::k#3 + rangenext(0,$a)
  main::$5 = main::k#1 != rangelast(0,$a)
  if(main::$5) goto main::@5
  to:main::@return
main::@return: scope:[main]  from main::@8
  return 
  to:@return

void plot(char x)
plot: scope:[plot]  from main::@1 main::@3 main::@5
  plot::x#3 = phi( main::@1/plot::x#0, main::@3/plot::x#1, main::@5/plot::x#2 )
  SCREEN[plot::x#3] = '*'
  to:plot::@return
plot::@return: scope:[plot]  from plot
  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 *SCREEN = (char *)$400
void __start()
void main()
bool main::$1
bool main::$3
bool main::$5
char main::i
char main::i#0
char main::i#1
char main::i#2
char main::i#3
char main::j
char main::j#0
char main::j#1
char main::j#2
char main::j#3
char main::k
char main::k#0
char main::k#1
char main::k#2
char main::k#3
void plot(char x)
char plot::x
char plot::x#0
char plot::x#1
char plot::x#2
char plot::x#3

Simplifying constant pointer cast (char *) 1024
Successful SSA optimization PassNCastSimplification
Alias main::i#2 = main::i#3 
Alias main::j#2 = main::j#3 
Alias main::k#2 = main::k#3 
Successful SSA optimization Pass2AliasElimination
Simple Condition main::$1 [6] if(main::i#1!=rangelast(0,$a)) goto main::@1
Simple Condition main::$3 [13] if(main::j#1!=rangelast(0,$a)) goto main::@3
Simple Condition main::$5 [20] if(main::k#1!=rangelast(0,$a)) goto main::@5
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant main::i#0 = 0
Constant main::j#0 = 0
Constant main::k#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [4] main::i#1 = ++ main::i#2 to ++
Resolved ranged comparison value [6] if(main::i#1!=rangelast(0,$a)) goto main::@1 to $b
Resolved ranged next value [11] main::j#1 = ++ main::j#2 to ++
Resolved ranged comparison value [13] if(main::j#1!=rangelast(0,$a)) goto main::@3 to $b
Resolved ranged next value [18] main::k#1 = ++ main::k#2 to ++
Resolved ranged comparison value [20] if(main::k#1!=rangelast(0,$a)) goto main::@5 to $b
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
Adding number conversion cast (unumber) $b in [4] if(main::i#1!=$b) goto main::@1
Adding number conversion cast (unumber) $b in [9] if(main::j#1!=$b) goto main::@3
Adding number conversion cast (unumber) $b in [14] if(main::k#1!=$b) goto main::@5
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast $b
Simplifying constant integer cast $b
Simplifying constant integer cast $b
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) $b
Finalized unsigned number type (char) $b
Finalized unsigned number type (char) $b
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inlining constant with var siblings main::i#0
Inlining constant with var siblings main::j#0
Inlining constant with var siblings main::k#0
Constant inlined main::i#0 = 0
Constant inlined main::k#0 = 0
Constant inlined main::j#0 = 0
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@9(between main::@6 and main::@1)
Added new block during phi lifting main::@10(between main::@7 and main::@3)
Added new block during phi lifting main::@11(between main::@8 and main::@5)
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@2
Adding NOP phi() at start of main::@4
CALL GRAPH
Calls in [main] to plot:4 plot:11 plot:18 

Created 4 initial phi equivalence classes
Coalesced [3] plot::x#4 = plot::x#0
Coalesced [10] plot::x#5 = plot::x#1
Coalesced [17] plot::x#6 = plot::x#2
Coalesced [22] main::k#4 = main::k#1
Coalesced [23] main::j#4 = main::j#1
Coalesced [24] main::i#4 = main::i#1
Coalesced down to 4 phi equivalence classes
Culled Empty Block label main::@2
Culled Empty Block label main::@4
Culled Empty Block label main::@11
Culled Empty Block label main::@10
Culled Empty Block label main::@9
Renumbering block main::@3 to main::@2
Renumbering block main::@5 to main::@3
Renumbering block main::@6 to main::@4
Renumbering block main::@7 to main::@5
Renumbering block main::@8 to main::@6
Adding NOP phi() at start of main

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@4
  [1] main::i#2 = phi( main/0, main::@4/main::i#1 )
  [2] plot::x#0 = main::i#2
  [3] call plot
  to:main::@4
main::@4: scope:[main]  from main::@1
  [4] main::i#1 = ++ main::i#2
  [5] if(main::i#1!=$b) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@4 main::@5
  [6] main::j#2 = phi( main::@4/0, main::@5/main::j#1 )
  [7] plot::x#1 = main::j#2
  [8] call plot
  to:main::@5
main::@5: scope:[main]  from main::@2
  [9] main::j#1 = ++ main::j#2
  [10] if(main::j#1!=$b) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@5 main::@6
  [11] main::k#2 = phi( main::@5/0, main::@6/main::k#1 )
  [12] plot::x#2 = main::k#2
  [13] call plot
  to:main::@6
main::@6: scope:[main]  from main::@3
  [14] main::k#1 = ++ main::k#2
  [15] if(main::k#1!=$b) goto main::@3
  to:main::@return
main::@return: scope:[main]  from main::@6
  [16] return 
  to:@return

void plot(char x)
plot: scope:[plot]  from main::@1 main::@2 main::@3
  [17] plot::x#3 = phi( main::@1/plot::x#0, main::@2/plot::x#1, main::@3/plot::x#2 )
  [18] SCREEN[plot::x#3] = '*'
  to:plot::@return
plot::@return: scope:[plot]  from plot
  [19] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
char main::i
char main::i#1 // 16.5
char main::i#2 // 11.0
char main::j
char main::j#1 // 16.5
char main::j#2 // 11.0
char main::k
char main::k#1 // 16.5
char main::k#2 // 11.0
void plot(char x)
char plot::x
char plot::x#0 // 22.0
char plot::x#1 // 22.0
char plot::x#2 // 22.0
char plot::x#3 // 134.0

Initial phi equivalence classes
[ main::i#2 main::i#1 ]
[ main::j#2 main::j#1 ]
[ main::k#2 main::k#1 ]
[ plot::x#3 plot::x#0 plot::x#1 plot::x#2 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ main::j#2 main::j#1 ]
[ main::k#2 main::k#1 ]
[ plot::x#3 plot::x#0 plot::x#1 plot::x#2 ]
Allocated zp[1]:2 [ plot::x#3 plot::x#0 plot::x#1 plot::x#2 ]
Allocated zp[1]:3 [ main::i#2 main::i#1 ]
Allocated zp[1]:4 [ main::j#2 main::j#1 ]
Allocated zp[1]:5 [ main::k#2 main::k#1 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [18] SCREEN[plot::x#3] = '*' [ ] ( plot:3 [ main::i#2 ] { { plot::x#0 = plot::x#3 main::i#2 } }  plot:8 [ main::j#2 ] { { plot::x#1 = plot::x#3 main::j#2 } }  plot:13 [ main::k#2 ] { { plot::x#2 = plot::x#3 main::k#2 } }  ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:3 [ main::i#2 main::i#1 ]
Removing always clobbered register reg byte a as potential for zp[1]:4 [ main::j#2 main::j#1 ]
Removing always clobbered register reg byte a as potential for zp[1]:5 [ main::k#2 main::k#1 ]
Statement [18] SCREEN[plot::x#3] = '*' [ ] ( plot:3 [ main::i#2 ] { { plot::x#0 = plot::x#3 main::i#2 } }  plot:8 [ main::j#2 ] { { plot::x#1 = plot::x#3 main::j#2 } }  plot:13 [ main::k#2 ] { { plot::x#2 = plot::x#3 main::k#2 } }  ) always clobbers reg byte a 
Potential registers zp[1]:3 [ main::i#2 main::i#1 ] : zp[1]:3 , reg byte x , reg byte y , 
Potential registers zp[1]:4 [ main::j#2 main::j#1 ] : zp[1]:4 , reg byte x , reg byte y , 
Potential registers zp[1]:5 [ main::k#2 main::k#1 ] : zp[1]:5 , reg byte x , reg byte y , 
Potential registers zp[1]:2 [ plot::x#3 plot::x#0 plot::x#1 plot::x#2 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [plot] 200: zp[1]:2 [ plot::x#3 plot::x#0 plot::x#1 plot::x#2 ] 
Uplift Scope [main] 27.5: zp[1]:3 [ main::i#2 main::i#1 ] 27.5: zp[1]:4 [ main::j#2 main::j#1 ] 27.5: zp[1]:5 [ main::k#2 main::k#1 ] 
Uplift Scope [] 

Uplifting [plot] best 874 combination reg byte x [ plot::x#3 plot::x#0 plot::x#1 plot::x#2 ] 
Uplifting [main] best 514 combination reg byte x [ main::i#2 main::i#1 ] reg byte x [ main::j#2 main::j#1 ] reg byte x [ main::k#2 main::k#1 ] 
Uplifting [] best 514 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Allocates ZP to j/k-variables even though all of i, j, k could be allocates to x and be more efficient.
// Reason: Pass4RegisterUpliftCombinations.isAllocationOverlapping() believes i/j/k variables overlaps insode plot()
  // Upstart
  // Commodore 64 PRG executable file
.file [name="overlap-allocation.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] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [1] phi main::i#2 = 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    jmp __b1
    // [1] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
  __b1_from___b4:
    // [1] phi main::i#2 = main::i#1 [phi:main::@4->main::@1#0] -- register_copy 
    jmp __b1
    // main::@1
  __b1:
    // [2] plot::x#0 = main::i#2
    // [3] call plot
    // [17] phi from main::@1 to plot [phi:main::@1->plot]
  plot_from___b1:
    // [17] phi plot::x#3 = plot::x#0 [phi:main::@1->plot#0] -- register_copy 
    jsr plot
    jmp __b4
    // main::@4
  __b4:
    // [4] main::i#1 = ++ main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [5] if(main::i#1!=$b) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne __b1_from___b4
    // [6] phi from main::@4 to main::@2 [phi:main::@4->main::@2]
  __b2_from___b4:
    // [6] phi main::j#2 = 0 [phi:main::@4->main::@2#0] -- vbuxx=vbuc1 
    ldx #0
    jmp __b2
    // [6] phi from main::@5 to main::@2 [phi:main::@5->main::@2]
  __b2_from___b5:
    // [6] phi main::j#2 = main::j#1 [phi:main::@5->main::@2#0] -- register_copy 
    jmp __b2
    // main::@2
  __b2:
    // [7] plot::x#1 = main::j#2
    // [8] call plot
    // [17] phi from main::@2 to plot [phi:main::@2->plot]
  plot_from___b2:
    // [17] phi plot::x#3 = plot::x#1 [phi:main::@2->plot#0] -- register_copy 
    jsr plot
    jmp __b5
    // main::@5
  __b5:
    // [9] main::j#1 = ++ main::j#2 -- vbuxx=_inc_vbuxx 
    inx
    // [10] if(main::j#1!=$b) goto main::@2 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne __b2_from___b5
    // [11] phi from main::@5 to main::@3 [phi:main::@5->main::@3]
  __b3_from___b5:
    // [11] phi main::k#2 = 0 [phi:main::@5->main::@3#0] -- vbuxx=vbuc1 
    ldx #0
    jmp __b3
    // [11] phi from main::@6 to main::@3 [phi:main::@6->main::@3]
  __b3_from___b6:
    // [11] phi main::k#2 = main::k#1 [phi:main::@6->main::@3#0] -- register_copy 
    jmp __b3
    // main::@3
  __b3:
    // [12] plot::x#2 = main::k#2
    // [13] call plot
    // [17] phi from main::@3 to plot [phi:main::@3->plot]
  plot_from___b3:
    // [17] phi plot::x#3 = plot::x#2 [phi:main::@3->plot#0] -- register_copy 
    jsr plot
    jmp __b6
    // main::@6
  __b6:
    // [14] main::k#1 = ++ main::k#2 -- vbuxx=_inc_vbuxx 
    inx
    // [15] if(main::k#1!=$b) goto main::@3 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne __b3_from___b6
    jmp __breturn
    // main::@return
  __breturn:
    // [16] return 
    rts
}
  // plot
// void plot(__register(X) char x)
plot: {
    // [18] SCREEN[plot::x#3] = '*' -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #'*'
    sta SCREEN,x
    jmp __breturn
    // plot::@return
  __breturn:
    // [19] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __b4
Removing instruction jmp __b2
Removing instruction jmp __b5
Removing instruction jmp __b3
Removing instruction jmp __b6
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __b1_from___b4 with __b1
Replacing label __b2_from___b5 with __b2
Replacing label __b3_from___b6 with __b3
Removing instruction __b1_from___b4:
Removing instruction plot_from___b1:
Removing instruction __b2_from___b5:
Removing instruction plot_from___b2:
Removing instruction __b3_from___b6:
Removing instruction plot_from___b3:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1_from_main:
Removing instruction __b4:
Removing instruction __b2_from___b4:
Removing instruction __b5:
Removing instruction __b3_from___b5:
Removing instruction __b6:
Removing instruction __breturn:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __b3
Succesful ASM optimization Pass5NextJumpElimination

FINAL SYMBOL TABLE
__constant char *SCREEN = (char *) 1024
void main()
char main::i
char main::i#1 // reg byte x 16.5
char main::i#2 // reg byte x 11.0
char main::j
char main::j#1 // reg byte x 16.5
char main::j#2 // reg byte x 11.0
char main::k
char main::k#1 // reg byte x 16.5
char main::k#2 // reg byte x 11.0
void plot(char x)
char plot::x
char plot::x#0 // reg byte x 22.0
char plot::x#1 // reg byte x 22.0
char plot::x#2 // reg byte x 22.0
char plot::x#3 // reg byte x 134.0

reg byte x [ main::i#2 main::i#1 ]
reg byte x [ main::j#2 main::j#1 ]
reg byte x [ main::k#2 main::k#1 ]
reg byte x [ plot::x#3 plot::x#0 plot::x#1 plot::x#2 ]


FINAL ASSEMBLER
Score: 292

  // File Comments
// Allocates ZP to j/k-variables even though all of i, j, k could be allocates to x and be more efficient.
// Reason: Pass4RegisterUpliftCombinations.isAllocationOverlapping() believes i/j/k variables overlaps insode plot()
  // Upstart
  // Commodore 64 PRG executable file
.file [name="overlap-allocation.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] phi from main to main::@1 [phi:main->main::@1]
    // [1] phi main::i#2 = 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // [1] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
    // [1] phi main::i#2 = main::i#1 [phi:main::@4->main::@1#0] -- register_copy 
    // main::@1
  __b1:
    // plot(i)
    // [2] plot::x#0 = main::i#2
    // [3] call plot
    // [17] phi from main::@1 to plot [phi:main::@1->plot]
    // [17] phi plot::x#3 = plot::x#0 [phi:main::@1->plot#0] -- register_copy 
    jsr plot
    // main::@4
    // for(byte i : 0..10)
    // [4] main::i#1 = ++ main::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [5] if(main::i#1!=$b) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne __b1
    // [6] phi from main::@4 to main::@2 [phi:main::@4->main::@2]
    // [6] phi main::j#2 = 0 [phi:main::@4->main::@2#0] -- vbuxx=vbuc1 
    ldx #0
    // [6] phi from main::@5 to main::@2 [phi:main::@5->main::@2]
    // [6] phi main::j#2 = main::j#1 [phi:main::@5->main::@2#0] -- register_copy 
    // main::@2
  __b2:
    // plot(j)
    // [7] plot::x#1 = main::j#2
    // [8] call plot
    // [17] phi from main::@2 to plot [phi:main::@2->plot]
    // [17] phi plot::x#3 = plot::x#1 [phi:main::@2->plot#0] -- register_copy 
    jsr plot
    // main::@5
    // for(byte j : 0..10)
    // [9] main::j#1 = ++ main::j#2 -- vbuxx=_inc_vbuxx 
    inx
    // [10] if(main::j#1!=$b) goto main::@2 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne __b2
    // [11] phi from main::@5 to main::@3 [phi:main::@5->main::@3]
    // [11] phi main::k#2 = 0 [phi:main::@5->main::@3#0] -- vbuxx=vbuc1 
    ldx #0
    // [11] phi from main::@6 to main::@3 [phi:main::@6->main::@3]
    // [11] phi main::k#2 = main::k#1 [phi:main::@6->main::@3#0] -- register_copy 
    // main::@3
  __b3:
    // plot(k)
    // [12] plot::x#2 = main::k#2
    // [13] call plot
    // [17] phi from main::@3 to plot [phi:main::@3->plot]
    // [17] phi plot::x#3 = plot::x#2 [phi:main::@3->plot#0] -- register_copy 
    jsr plot
    // main::@6
    // for(byte k : 0..10)
    // [14] main::k#1 = ++ main::k#2 -- vbuxx=_inc_vbuxx 
    inx
    // [15] if(main::k#1!=$b) goto main::@3 -- vbuxx_neq_vbuc1_then_la1 
    cpx #$b
    bne __b3
    // main::@return
    // }
    // [16] return 
    rts
}
  // plot
// void plot(__register(X) char x)
plot: {
    // SCREEN[x] = '*'
    // [18] SCREEN[plot::x#3] = '*' -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #'*'
    sta SCREEN,x
    // plot::@return
    // }
    // [19] return 
    rts
}
  // File Data

