Inlined call call __init

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start::@1
  main::i#0 = $64
  to:main::@1
main::@1: scope:[main]  from main main::@2
  main::i#3 = phi( main/main::i#0, main::@2/main::i#1 )
  call nest
  to:main::@2
main::@2: scope:[main]  from main::@1
  main::i#2 = phi( main::@1/main::i#3 )
  main::i#1 = -- main::i#2
  main::$1 = main::i#1 > 0
  if(main::$1) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@2
  return 
  to:@return

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

Adding number conversion cast (unumber) 0 in main::$1 = main::i#1 > 0
Adding number conversion cast (unumber) 0 in nest::$0 = nest::j#1 > 0
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias main::i#2 = main::i#3 
Successful SSA optimization Pass2AliasElimination
Simple Condition main::$1 [5] if(main::i#1>0) goto main::@1
Simple Condition nest::$0 [12] if(nest::j#1>0) goto nest::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant main::i#0 = $64
Constant nest::j#0 = $64
Successful SSA optimization Pass2ConstantIdentification
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 main::i#0
Inlining constant with var siblings nest::j#0
Constant inlined main::i#0 = $64
Constant inlined nest::j#0 = $64
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@3(between main::@2 and main::@1)
Added new block during phi lifting nest::@2(between nest::@1 and nest::@1)
Adding NOP phi() at start of main
Adding NOP phi() at start of nest
CALL GRAPH
Calls in [main] to nest:2 

Created 2 initial phi equivalence classes
Coalesced [6] main::i#4 = main::i#1
Coalesced [13] nest::j#3 = nest::j#1
Coalesced down to 2 phi equivalence classes
Culled Empty Block label main::@3
Culled Empty Block label nest::@2
Adding NOP phi() at start of main
Adding NOP phi() at start of nest

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@2
  [1] main::i#2 = phi( main/$64, main::@2/main::i#1 )
  [2] call nest
  to:main::@2
main::@2: scope:[main]  from main::@1
  [3] main::i#1 = -- main::i#2
  [4] if(main::i#1>0) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@2
  [5] return 
  to:@return

void nest()
nest: scope:[nest]  from main::@1
  [6] phi()
  to:nest::@1
nest::@1: scope:[nest]  from nest nest::@1
  [7] nest::j#2 = phi( nest/$64, nest::@1/nest::j#1 )
  [8] *SCREEN = nest::j#2
  [9] nest::j#1 = -- nest::j#2
  [10] if(nest::j#1>0) goto nest::@1
  to:nest::@return
nest::@return: scope:[nest]  from nest::@1
  [11] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
char main::i
char main::i#1 // 16.5
char main::i#2 // 11.0
void nest()
char nest::j
char nest::j#1 // 15001.5
char nest::j#2 // 15001.5

Initial phi equivalence classes
[ main::i#2 main::i#1 ]
[ nest::j#2 nest::j#1 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ nest::j#2 nest::j#1 ]
Allocated zp[1]:2 [ nest::j#2 nest::j#1 ]
Allocated zp[1]:3 [ main::i#2 main::i#1 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Potential registers zp[1]:3 [ main::i#2 main::i#1 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:2 [ nest::j#2 nest::j#1 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [nest] 30,003: zp[1]:2 [ nest::j#2 nest::j#1 ] 
Uplift Scope [main] 27.5: zp[1]:3 [ main::i#2 main::i#1 ] 
Uplift Scope [] 

Uplifting [nest] best 2416 combination reg byte x [ nest::j#2 nest::j#1 ] 
Uplifting [main] best 2346 combination reg byte y [ main::i#2 main::i#1 ] 
Uplifting [] best 2346 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
  // Upstart
  // Commodore 64 PRG executable file
.file [name="loopnest.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 = $64 [phi:main->main::@1#0] -- vbuyy=vbuc1 
    ldy #$64
    jmp __b1
    // [1] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  __b1_from___b2:
    // [1] phi main::i#2 = main::i#1 [phi:main::@2->main::@1#0] -- register_copy 
    jmp __b1
    // main::@1
  __b1:
    // [2] call nest
    // [6] phi from main::@1 to nest [phi:main::@1->nest]
  nest_from___b1:
    jsr nest
    jmp __b2
    // main::@2
  __b2:
    // [3] main::i#1 = -- main::i#2 -- vbuyy=_dec_vbuyy 
    dey
    // [4] if(main::i#1>0) goto main::@1 -- vbuyy_gt_0_then_la1 
    cpy #0
    bne __b1_from___b2
    jmp __breturn
    // main::@return
  __breturn:
    // [5] return 
    rts
}
  // nest
nest: {
    // [7] phi from nest to nest::@1 [phi:nest->nest::@1]
  __b1_from_nest:
    // [7] phi nest::j#2 = $64 [phi:nest->nest::@1#0] -- vbuxx=vbuc1 
    ldx #$64
    jmp __b1
    // [7] phi from nest::@1 to nest::@1 [phi:nest::@1->nest::@1]
  __b1_from___b1:
    // [7] phi nest::j#2 = nest::j#1 [phi:nest::@1->nest::@1#0] -- register_copy 
    jmp __b1
    // nest::@1
  __b1:
    // [8] *SCREEN = nest::j#2 -- _deref_pbuc1=vbuxx 
    stx SCREEN
    // [9] nest::j#1 = -- nest::j#2 -- vbuxx=_dec_vbuxx 
    dex
    // [10] if(nest::j#1>0) goto nest::@1 -- vbuxx_gt_0_then_la1 
    cpx #0
    bne __b1_from___b1
    jmp __breturn
    // nest::@return
  __breturn:
    // [11] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __b1_from___b2 with __b1
Replacing label __b1_from___b1 with __b1
Removing instruction __b1_from___b2:
Removing instruction nest_from___b1:
Removing instruction __b1_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1_from_main:
Removing instruction __b2:
Removing instruction __breturn:
Removing instruction __b1_from_nest:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jmp __b1
Removing instruction jmp __b1
Succesful ASM optimization Pass5NextJumpElimination

FINAL SYMBOL TABLE
__constant char *SCREEN = (char *) 1024
void main()
char main::i
char main::i#1 // reg byte y 16.5
char main::i#2 // reg byte y 11.0
void nest()
char nest::j
char nest::j#1 // reg byte x 15001.5
char nest::j#2 // reg byte x 15001.5

reg byte y [ main::i#2 main::i#1 ]
reg byte x [ nest::j#2 nest::j#1 ]


FINAL ASSEMBLER
Score: 1353

  // File Comments
  // Upstart
  // Commodore 64 PRG executable file
.file [name="loopnest.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 = $64 [phi:main->main::@1#0] -- vbuyy=vbuc1 
    ldy #$64
    // [1] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
    // [1] phi main::i#2 = main::i#1 [phi:main::@2->main::@1#0] -- register_copy 
    // main::@1
  __b1:
    // nest()
    // [2] call nest
    // [6] phi from main::@1 to nest [phi:main::@1->nest]
    jsr nest
    // main::@2
    // while (--i>0)
    // [3] main::i#1 = -- main::i#2 -- vbuyy=_dec_vbuyy 
    dey
    // [4] if(main::i#1>0) goto main::@1 -- vbuyy_gt_0_then_la1 
    cpy #0
    bne __b1
    // main::@return
    // }
    // [5] return 
    rts
}
  // nest
nest: {
    // [7] phi from nest to nest::@1 [phi:nest->nest::@1]
    // [7] phi nest::j#2 = $64 [phi:nest->nest::@1#0] -- vbuxx=vbuc1 
    ldx #$64
    // [7] phi from nest::@1 to nest::@1 [phi:nest::@1->nest::@1]
    // [7] phi nest::j#2 = nest::j#1 [phi:nest::@1->nest::@1#0] -- register_copy 
    // nest::@1
  __b1:
    // *SCREEN = j
    // [8] *SCREEN = nest::j#2 -- _deref_pbuc1=vbuxx 
    stx SCREEN
    // while (--j>0)
    // [9] nest::j#1 = -- nest::j#2 -- vbuxx=_dec_vbuxx 
    dex
    // [10] if(nest::j#1>0) goto nest::@1 -- vbuxx_gt_0_then_la1 
    cpx #0
    bne __b1
    // nest::@return
    // }
    // [11] return 
    rts
}
  // File Data

