Inlined call call __init

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start::@1
  print2::at#0 = screen
  print2::msg#0 = main::hello
  call print2
  to:main::@1
main::@1: scope:[main]  from main
  main::$1 = screen + $50
  print2::at#1 = main::$1
  print2::msg#1 = main::hello
  call print2
  to:main::@2
main::@2: scope:[main]  from main::@1
  to:main::@return
main::@return: scope:[main]  from main::@2
  return 
  to:@return

void print2(char *at , char *msg)
print2: scope:[print2]  from main main::@1
  print2::at#4 = phi( main/print2::at#0, main::@1/print2::at#1 )
  print2::msg#4 = phi( main/print2::msg#0, main::@1/print2::msg#1 )
  print2::j#0 = 0
  print2::i#0 = 0
  to:print2::@1
print2::@1: scope:[print2]  from print2 print2::@2
  print2::j#3 = phi( print2/print2::j#0, print2::@2/print2::j#1 )
  print2::at#3 = phi( print2/print2::at#4, print2::@2/print2::at#2 )
  print2::i#2 = phi( print2/print2::i#0, print2::@2/print2::i#1 )
  print2::msg#2 = phi( print2/print2::msg#4, print2::@2/print2::msg#3 )
  print2::$0 = 0 != print2::msg#2[print2::i#2]
  if(print2::$0) goto print2::@2
  to:print2::@return
print2::@2: scope:[print2]  from print2::@1
  print2::j#2 = phi( print2::@1/print2::j#3 )
  print2::at#2 = phi( print2::@1/print2::at#3 )
  print2::i#3 = phi( print2::@1/print2::i#2 )
  print2::msg#3 = phi( print2::@1/print2::msg#2 )
  print2::at#2[print2::j#2] = print2::msg#3[print2::i#3]
  print2::j#1 = print2::j#2 + 2
  print2::i#1 = ++ print2::i#3
  to:print2::@1
print2::@return: scope:[print2]  from print2::@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
void __start()
void main()
char *main::$1
__constant char *main::hello = "hello world!"
void print2(char *at , char *msg)
bool print2::$0
char *print2::at
char *print2::at#0
char *print2::at#1
char *print2::at#2
char *print2::at#3
char *print2::at#4
char print2::i
char print2::i#0
char print2::i#1
char print2::i#2
char print2::i#3
char print2::j
char print2::j#0
char print2::j#1
char print2::j#2
char print2::j#3
char *print2::msg
char *print2::msg#0
char *print2::msg#1
char *print2::msg#2
char *print2::msg#3
char *print2::msg#4
__constant char *screen = (char *)$400

Adding number conversion cast (unumber) $50 in main::$1 = screen + $50
Adding number conversion cast (unumber) 0 in print2::$0 = 0 != print2::msg#2[print2::i#2]
Adding number conversion cast (unumber) 2 in print2::j#1 = print2::j#2 + 2
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast $50
Simplifying constant integer cast 0
Simplifying constant integer cast 2
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) $50
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias print2::at#1 = main::$1 
Alias print2::msg#2 = print2::msg#3 
Alias print2::i#2 = print2::i#3 
Alias print2::at#2 = print2::at#3 
Alias print2::j#2 = print2::j#3 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values print2::msg#2 print2::msg#4
Identical Phi Values print2::at#2 print2::at#4
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition print2::$0 [12] if(0!=print2::msg#4[print2::i#2]) goto print2::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant right-side identified [3] print2::at#1 = screen + $50
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant print2::at#0 = screen
Constant print2::msg#0 = main::hello
Constant print2::at#1 = screen+$50
Constant print2::msg#1 = main::hello
Constant print2::j#0 = 0
Constant print2::i#0 = 0
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 print2::at#0
Inlining constant with var siblings print2::msg#0
Inlining constant with var siblings print2::at#1
Inlining constant with var siblings print2::msg#1
Inlining constant with var siblings print2::j#0
Inlining constant with var siblings print2::i#0
Constant inlined print2::at#1 = screen+$50
Constant inlined print2::at#0 = screen
Constant inlined print2::msg#1 = main::hello
Constant inlined print2::j#0 = 0
Constant inlined print2::msg#0 = main::hello
Constant inlined print2::i#0 = 0
Successful SSA optimization Pass2ConstantInlining
Identical Phi Values print2::msg#4 main::hello
Successful SSA optimization Pass2IdenticalPhiElimination
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@1
Adding NOP phi() at start of main::@2
CALL GRAPH
Calls in [main] to print2:1 print2:3 

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

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] phi()
  [1] call print2
  to:main::@1
main::@1: scope:[main]  from main
  [2] phi()
  [3] call print2
  to:main::@return
main::@return: scope:[main]  from main::@1
  [4] return 
  to:@return

void print2(char *at , char *msg)
print2: scope:[print2]  from main main::@1
  [5] print2::at#4 = phi( main/screen, main::@1/screen+$50 )
  to:print2::@1
print2::@1: scope:[print2]  from print2 print2::@2
  [6] print2::j#2 = phi( print2/0, print2::@2/print2::j#1 )
  [6] print2::i#2 = phi( print2/0, print2::@2/print2::i#1 )
  [7] if(0!=main::hello[print2::i#2]) goto print2::@2
  to:print2::@return
print2::@return: scope:[print2]  from print2::@1
  [8] return 
  to:@return
print2::@2: scope:[print2]  from print2::@1
  [9] print2::at#4[print2::j#2] = main::hello[print2::i#2]
  [10] print2::j#1 = print2::j#2 + 2
  [11] print2::i#1 = ++ print2::i#2
  to:print2::@1


VARIABLE REGISTER WEIGHTS
void main()
void print2(char *at , char *msg)
char *print2::at
char *print2::at#4 // 16.833333333333332
char print2::i
char print2::i#1 // 202.0
char print2::i#2 // 101.0
char print2::j
char print2::j#1 // 101.0
char print2::j#2 // 101.0
char *print2::msg

Initial phi equivalence classes
[ print2::at#4 ]
[ print2::i#2 print2::i#1 ]
[ print2::j#2 print2::j#1 ]
Complete equivalence classes
[ print2::at#4 ]
[ print2::i#2 print2::i#1 ]
[ print2::j#2 print2::j#1 ]
Allocated zp[1]:2 [ print2::i#2 print2::i#1 ]
Allocated zp[1]:3 [ print2::j#2 print2::j#1 ]
Allocated zp[2]:4 [ print2::at#4 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [7] if(0!=main::hello[print2::i#2]) goto print2::@2 [ print2::at#4 print2::i#2 print2::j#2 ] ( print2:1 [ print2::at#4 print2::i#2 print2::j#2 ] { }  print2:3 [ print2::at#4 print2::i#2 print2::j#2 ] { }  ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:2 [ print2::i#2 print2::i#1 ]
Removing always clobbered register reg byte a as potential for zp[1]:3 [ print2::j#2 print2::j#1 ]
Statement [9] print2::at#4[print2::j#2] = main::hello[print2::i#2] [ print2::at#4 print2::i#2 print2::j#2 ] ( print2:1 [ print2::at#4 print2::i#2 print2::j#2 ] { }  print2:3 [ print2::at#4 print2::i#2 print2::j#2 ] { }  ) always clobbers reg byte a 
Statement [7] if(0!=main::hello[print2::i#2]) goto print2::@2 [ print2::at#4 print2::i#2 print2::j#2 ] ( print2:1 [ print2::at#4 print2::i#2 print2::j#2 ] { }  print2:3 [ print2::at#4 print2::i#2 print2::j#2 ] { }  ) always clobbers reg byte a 
Statement [9] print2::at#4[print2::j#2] = main::hello[print2::i#2] [ print2::at#4 print2::i#2 print2::j#2 ] ( print2:1 [ print2::at#4 print2::i#2 print2::j#2 ] { }  print2:3 [ print2::at#4 print2::i#2 print2::j#2 ] { }  ) always clobbers reg byte a 
Potential registers zp[2]:4 [ print2::at#4 ] : zp[2]:4 , 
Potential registers zp[1]:2 [ print2::i#2 print2::i#1 ] : zp[1]:2 , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ print2::j#2 print2::j#1 ] : zp[1]:3 , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [print2] 303: zp[1]:2 [ print2::i#2 print2::i#1 ] 202: zp[1]:3 [ print2::j#2 print2::j#1 ] 16.83: zp[2]:4 [ print2::at#4 ] 
Uplift Scope [main] 
Uplift Scope [] 

Uplifting [print2] best 435 combination reg byte x [ print2::i#2 print2::i#1 ] reg byte y [ print2::j#2 print2::j#1 ] zp[2]:4 [ print2::at#4 ] 
Uplifting [main] best 435 combination 
Uplifting [] best 435 combination 
Allocated (was zp[2]:4) zp[2]:2 [ print2::at#4 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
  // Upstart
  // Commodore 64 PRG executable file
.file [name="helloworld2.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 print2
    // [5] phi from main to print2 [phi:main->print2]
  print2_from_main:
    // [5] phi print2::at#4 = screen [phi:main->print2#0] -- pbuz1=pbuc1 
    lda #<screen
    sta.z print2.at
    lda #>screen
    sta.z print2.at+1
    jsr print2
    // [2] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    jmp __b1
    // main::@1
  __b1:
    // [3] call print2
    // [5] phi from main::@1 to print2 [phi:main::@1->print2]
  print2_from___b1:
    // [5] phi print2::at#4 = screen+$50 [phi:main::@1->print2#0] -- pbuz1=pbuc1 
    lda #<screen+$50
    sta.z print2.at
    lda #>screen+$50
    sta.z print2.at+1
    jsr print2
    jmp __breturn
    // main::@return
  __breturn:
    // [4] return 
    rts
  .segment Data
    hello: .text "hello world!"
    .byte 0
}
.segment Code
  // print2
// void print2(__zp(2) char *at, char *msg)
print2: {
    .label at = 2
    // [6] phi from print2 to print2::@1 [phi:print2->print2::@1]
  __b1_from_print2:
    // [6] phi print2::j#2 = 0 [phi:print2->print2::@1#0] -- vbuyy=vbuc1 
    ldy #0
    // [6] phi print2::i#2 = 0 [phi:print2->print2::@1#1] -- vbuxx=vbuc1 
    ldx #0
    jmp __b1
    // print2::@1
  __b1:
    // [7] if(0!=main::hello[print2::i#2]) goto print2::@2 -- 0_neq_pbuc1_derefidx_vbuxx_then_la1 
    lda main.hello,x
    cmp #0
    bne __b2
    jmp __breturn
    // print2::@return
  __breturn:
    // [8] return 
    rts
    // print2::@2
  __b2:
    // [9] print2::at#4[print2::j#2] = main::hello[print2::i#2] -- pbuz1_derefidx_vbuyy=pbuc1_derefidx_vbuxx 
    lda main.hello,x
    sta (at),y
    // [10] print2::j#1 = print2::j#2 + 2 -- vbuyy=vbuyy_plus_2 
    iny
    iny
    // [11] print2::i#1 = ++ print2::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [6] phi from print2::@2 to print2::@1 [phi:print2::@2->print2::@1]
  __b1_from___b2:
    // [6] phi print2::j#2 = print2::j#1 [phi:print2::@2->print2::@1#0] -- register_copy 
    // [6] phi print2::i#2 = print2::i#1 [phi:print2::@2->print2::@1#1] -- register_copy 
    jmp __b1
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1_from_main:
Removing instruction print2_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction print2_from_main:
Removing instruction __b1:
Removing instruction __breturn:
Removing instruction __b1_from_print2:
Removing instruction __breturn:
Removing instruction __b1_from___b2:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
void main()
__constant char *main::hello = "hello world!"
void print2(char *at , char *msg)
char *print2::at
char *print2::at#4 // at zp[2]:2 16.833333333333332
char print2::i
char print2::i#1 // reg byte x 202.0
char print2::i#2 // reg byte x 101.0
char print2::j
char print2::j#1 // reg byte y 101.0
char print2::j#2 // reg byte y 101.0
char *print2::msg
__constant char *screen = (char *) 1024

zp[2]:2 [ print2::at#4 ]
reg byte x [ print2::i#2 print2::i#1 ]
reg byte y [ print2::j#2 print2::j#1 ]


FINAL ASSEMBLER
Score: 369

  // File Comments
  // Upstart
  // Commodore 64 PRG executable file
.file [name="helloworld2.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: {
    // print2(screen, hello)
    // [1] call print2
    // [5] phi from main to print2 [phi:main->print2]
    // [5] phi print2::at#4 = screen [phi:main->print2#0] -- pbuz1=pbuc1 
    lda #<screen
    sta.z print2.at
    lda #>screen
    sta.z print2.at+1
    jsr print2
    // [2] phi from main to main::@1 [phi:main->main::@1]
    // main::@1
    // print2(screen+80, hello)
    // [3] call print2
    // [5] phi from main::@1 to print2 [phi:main::@1->print2]
    // [5] phi print2::at#4 = screen+$50 [phi:main::@1->print2#0] -- pbuz1=pbuc1 
    lda #<screen+$50
    sta.z print2.at
    lda #>screen+$50
    sta.z print2.at+1
    jsr print2
    // main::@return
    // }
    // [4] return 
    rts
  .segment Data
    hello: .text "hello world!"
    .byte 0
}
.segment Code
  // print2
// void print2(__zp(2) char *at, char *msg)
print2: {
    .label at = 2
    // [6] phi from print2 to print2::@1 [phi:print2->print2::@1]
    // [6] phi print2::j#2 = 0 [phi:print2->print2::@1#0] -- vbuyy=vbuc1 
    ldy #0
    // [6] phi print2::i#2 = 0 [phi:print2->print2::@1#1] -- vbuxx=vbuc1 
    ldx #0
    // print2::@1
  __b1:
    // for(byte i=0; msg[i]; i++)
    // [7] if(0!=main::hello[print2::i#2]) goto print2::@2 -- 0_neq_pbuc1_derefidx_vbuxx_then_la1 
    lda main.hello,x
    cmp #0
    bne __b2
    // print2::@return
    // }
    // [8] return 
    rts
    // print2::@2
  __b2:
    // at[j] = msg[i]
    // [9] print2::at#4[print2::j#2] = main::hello[print2::i#2] -- pbuz1_derefidx_vbuyy=pbuc1_derefidx_vbuxx 
    lda main.hello,x
    sta (at),y
    // j += 2
    // [10] print2::j#1 = print2::j#2 + 2 -- vbuyy=vbuyy_plus_2 
    iny
    iny
    // for(byte i=0; msg[i]; i++)
    // [11] print2::i#1 = ++ print2::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [6] phi from print2::@2 to print2::@1 [phi:print2::@2->print2::@1]
    // [6] phi print2::j#2 = print2::j#1 [phi:print2::@2->print2::@1#0] -- register_copy 
    // [6] phi print2::i#2 = print2::i#1 [phi:print2::@2->print2::@1#1] -- register_copy 
    jmp __b1
}
  // File Data

