Inlined call call __init

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start::@1
  idx#16 = phi( __start::@1/idx#17 )
  main::p1_x#0 = 0
  main::p1_y#0 = 0
  main::p1_x#1 = 1
  main::p1_y#1 = 4
  print::p_x#0 = main::p1_x#1
  print::p_y#0 = main::p1_y#1
  call print
  to:main::@1
main::@1: scope:[main]  from main
  main::p1_y#2 = phi( main/main::p1_y#1 )
  idx#9 = phi( main/idx#5 )
  idx#0 = idx#9
  main::p1_x#2 = 2
  print::p_x#1 = main::p1_x#2
  print::p_y#1 = main::p1_y#2
  call print
  to:main::@2
main::@2: scope:[main]  from main::@1
  idx#10 = phi( main::@1/idx#5 )
  idx#1 = idx#10
  to:main::@return
main::@return: scope:[main]  from main::@2
  idx#11 = phi( main::@2/idx#1 )
  idx#2 = idx#11
  return 
  to:@return

void print(char p_x , char p_y)
print: scope:[print]  from main main::@1
  print::p_y#2 = phi( main/print::p_y#0, main::@1/print::p_y#1 )
  idx#12 = phi( main/idx#16, main::@1/idx#0 )
  print::p_x#2 = phi( main/print::p_x#0, main::@1/print::p_x#1 )
  SCREEN[idx#12] = print::p_x#2
  idx#3 = ++ idx#12
  SCREEN[idx#3] = print::p_y#2
  idx#4 = ++ idx#3
  to:print::@return
print::@return: scope:[print]  from print
  idx#13 = phi( print/idx#4 )
  idx#5 = idx#13
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  to:__start::__init1
__start::__init1: scope:[__start]  from __start
  idx#6 = 0
  to:__start::@1
__start::@1: scope:[__start]  from __start::__init1
  idx#17 = phi( __start::__init1/idx#6 )
  call main
  to:__start::@2
__start::@2: scope:[__start]  from __start::@1
  idx#14 = phi( __start::@1/idx#2 )
  idx#7 = idx#14
  to:__start::@return
__start::@return: scope:[__start]  from __start::@2
  idx#15 = phi( __start::@2/idx#7 )
  idx#8 = idx#15
  return 
  to:@return

SYMBOL TABLE SSA
__constant char * const SCREEN = (char *)$400
void __start()
char idx
char idx#0
char idx#1
char idx#10
char idx#11
char idx#12
char idx#13
char idx#14
char idx#15
char idx#16
char idx#17
char idx#2
char idx#3
char idx#4
char idx#5
char idx#6
char idx#7
char idx#8
char idx#9
void main()
char main::p1_x
char main::p1_x#0
char main::p1_x#1
char main::p1_x#2
char main::p1_y
char main::p1_y#0
char main::p1_y#1
char main::p1_y#2
void print(char p_x , char p_y)
struct Point print::p
char print::p_x
char print::p_x#0
char print::p_x#1
char print::p_x#2
char print::p_y
char print::p_y#0
char print::p_y#1
char print::p_y#2

Adding number conversion cast (unumber) 1 in main::p1_x#1 = 1
Adding number conversion cast (unumber) 4 in main::p1_y#1 = 4
Adding number conversion cast (unumber) 2 in main::p1_x#2 = 2
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast main::p1_x#1 = (unumber)1
Inlining cast main::p1_y#1 = (unumber)4
Inlining cast main::p1_x#2 = (unumber)2
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 1
Simplifying constant integer cast 4
Simplifying constant integer cast 2
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 4
Finalized unsigned number type (char) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias main::p1_y#1 = main::p1_y#2 
Alias idx#0 = idx#9 
Alias idx#1 = idx#10 idx#11 idx#2 
Alias idx#13 = idx#4 idx#5 
Alias idx#17 = idx#6 
Alias idx#14 = idx#7 idx#15 idx#8 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values idx#16 idx#17
Identical Phi Values idx#0 idx#13
Identical Phi Values idx#1 idx#13
Identical Phi Values idx#14 idx#1
Successful SSA optimization Pass2IdenticalPhiElimination
Constant main::p1_x#0 = 0
Constant main::p1_y#0 = 0
Constant main::p1_x#1 = 1
Constant main::p1_y#1 = 4
Constant main::p1_x#2 = 2
Constant idx#17 = 0
Successful SSA optimization Pass2ConstantIdentification
Constant print::p_x#0 = main::p1_x#1
Constant print::p_y#0 = main::p1_y#1
Constant print::p_x#1 = main::p1_x#2
Constant print::p_y#1 = main::p1_y#1
Successful SSA optimization Pass2ConstantIdentification
Eliminating unused constant main::p1_x#0
Eliminating unused constant main::p1_y#0
Successful SSA optimization PassNEliminateUnusedVars
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 different constant siblings main::p1_x#1
Inlining constant with different constant siblings main::p1_x#2
Inlining constant with var siblings print::p_x#0
Inlining constant with var siblings print::p_y#0
Inlining constant with var siblings print::p_x#1
Inlining constant with var siblings print::p_y#1
Inlining constant with var siblings idx#17
Constant inlined print::p_x#0 = 1
Constant inlined print::p_y#1 = main::p1_y#1
Constant inlined print::p_y#0 = main::p1_y#1
Constant inlined print::p_x#1 = 2
Constant inlined idx#17 = 0
Constant inlined main::p1_x#2 = 2
Constant inlined main::p1_x#1 = 1
Successful SSA optimization Pass2ConstantInlining
Identical Phi Values print::p_y#2 main::p1_y#1
Successful SSA optimization Pass2IdenticalPhiElimination
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@2
CALL GRAPH
Calls in [main] to print:1 print:3 

Created 2 initial phi equivalence classes
Coalesced [2] idx#18 = idx#13
Coalesced down to 2 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 print
  to:main::@1
main::@1: scope:[main]  from main
  [2] phi()
  [3] call print
  to:main::@return
main::@return: scope:[main]  from main::@1
  [4] return 
  to:@return

void print(char p_x , char p_y)
print: scope:[print]  from main main::@1
  [5] idx#12 = phi( main/0, main::@1/idx#13 )
  [5] print::p_x#2 = phi( main/1, main::@1/2 )
  [6] SCREEN[idx#12] = print::p_x#2
  [7] idx#3 = ++ idx#12
  [8] SCREEN[idx#3] = main::p1_y#1
  [9] idx#13 = ++ idx#3
  to:print::@return
print::@return: scope:[print]  from print
  [10] return 
  to:@return


VARIABLE REGISTER WEIGHTS
char idx
char idx#12 // 12.0
char idx#13 // 3.25
char idx#3 // 16.5
void main()
char main::p1_x
char main::p1_y
void print(char p_x , char p_y)
struct Point print::p
char print::p_x
char print::p_x#2 // 11.0
char print::p_y

Initial phi equivalence classes
[ print::p_x#2 ]
[ idx#12 idx#13 ]
Added variable idx#3 to live range equivalence class [ idx#3 ]
Complete equivalence classes
[ print::p_x#2 ]
[ idx#12 idx#13 ]
[ idx#3 ]
Allocated zp[1]:2 [ idx#3 ]
Allocated zp[1]:3 [ idx#12 idx#13 ]
Allocated zp[1]:4 [ print::p_x#2 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [8] SCREEN[idx#3] = main::p1_y#1 [ idx#3 ] ( print:1 [ idx#3 ] { }  print:3 [ idx#3 ] { { idx#12 = idx#13 } }  ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:2 [ idx#3 ]
Statement [8] SCREEN[idx#3] = main::p1_y#1 [ idx#3 ] ( print:1 [ idx#3 ] { }  print:3 [ idx#3 ] { { idx#12 = idx#13 } }  ) always clobbers reg byte a 
Potential registers zp[1]:4 [ print::p_x#2 ] : zp[1]:4 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ idx#12 idx#13 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:2 [ idx#3 ] : zp[1]:2 , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [] 16.5: zp[1]:2 [ idx#3 ] 15.25: zp[1]:3 [ idx#12 idx#13 ] 
Uplift Scope [print] 11: zp[1]:4 [ print::p_x#2 ] 
Uplift Scope [Point] 
Uplift Scope [main] 

Uplifting [] best 64 combination reg byte x [ idx#3 ] reg byte x [ idx#12 idx#13 ] 
Uplifting [print] best 55 combination reg byte a [ print::p_x#2 ] 
Uplifting [Point] best 55 combination 
Uplifting [main] best 55 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Minimal struct - passing struct value parameter
  // Upstart
  // Commodore 64 PRG executable file
.file [name="struct-3.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: {
    .label p1_y = 4
    // [1] call print
    // [5] phi from main to print [phi:main->print]
  print_from_main:
    // [5] phi idx#12 = 0 [phi:main->print#0] -- vbuxx=vbuc1 
    ldx #0
    // [5] phi print::p_x#2 = 1 [phi:main->print#1] -- vbuaa=vbuc1 
    lda #1
    jsr print
    // [2] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    jmp __b1
    // main::@1
  __b1:
    // [3] call print
    // [5] phi from main::@1 to print [phi:main::@1->print]
  print_from___b1:
    // [5] phi idx#12 = idx#13 [phi:main::@1->print#0] -- register_copy 
    // [5] phi print::p_x#2 = 2 [phi:main::@1->print#1] -- vbuaa=vbuc1 
    lda #2
    jsr print
    jmp __breturn
    // main::@return
  __breturn:
    // [4] return 
    rts
}
  // print
// void print(__register(A) char p_x, char p_y)
print: {
    // [6] SCREEN[idx#12] = print::p_x#2 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN,x
    // [7] idx#3 = ++ idx#12 -- vbuxx=_inc_vbuxx 
    inx
    // [8] SCREEN[idx#3] = main::p1_y#1 -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #main.p1_y
    sta SCREEN,x
    // [9] idx#13 = ++ idx#3 -- vbuxx=_inc_vbuxx 
    inx
    jmp __breturn
    // print::@return
  __breturn:
    // [10] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1_from_main:
Removing instruction print_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction print_from_main:
Removing instruction __b1:
Removing instruction __breturn:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
__constant char * const SCREEN = (char *) 1024
char idx
char idx#12 // reg byte x 12.0
char idx#13 // reg byte x 3.25
char idx#3 // reg byte x 16.5
void main()
char main::p1_x
char main::p1_y
__constant char main::p1_y#1 = 4 // p1_y
void print(char p_x , char p_y)
struct Point print::p
char print::p_x
char print::p_x#2 // reg byte a 11.0
char print::p_y

reg byte a [ print::p_x#2 ]
reg byte x [ idx#12 idx#13 ]
reg byte x [ idx#3 ]


FINAL ASSEMBLER
Score: 46

  // File Comments
// Minimal struct - passing struct value parameter
  // Upstart
  // Commodore 64 PRG executable file
.file [name="struct-3.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: {
    .label p1_y = 4
    // print(p1)
    // [1] call print
    // [5] phi from main to print [phi:main->print]
    // [5] phi idx#12 = 0 [phi:main->print#0] -- vbuxx=vbuc1 
    ldx #0
    // [5] phi print::p_x#2 = 1 [phi:main->print#1] -- vbuaa=vbuc1 
    lda #1
    jsr print
    // [2] phi from main to main::@1 [phi:main->main::@1]
    // main::@1
    // print(p1)
    // [3] call print
    // [5] phi from main::@1 to print [phi:main::@1->print]
    // [5] phi idx#12 = idx#13 [phi:main::@1->print#0] -- register_copy 
    // [5] phi print::p_x#2 = 2 [phi:main::@1->print#1] -- vbuaa=vbuc1 
    lda #2
    jsr print
    // main::@return
    // }
    // [4] return 
    rts
}
  // print
// void print(__register(A) char p_x, char p_y)
print: {
    // SCREEN[idx++] = p.x
    // [6] SCREEN[idx#12] = print::p_x#2 -- pbuc1_derefidx_vbuxx=vbuaa 
    sta SCREEN,x
    // SCREEN[idx++] = p.x;
    // [7] idx#3 = ++ idx#12 -- vbuxx=_inc_vbuxx 
    inx
    // SCREEN[idx++] = p.y
    // [8] SCREEN[idx#3] = main::p1_y#1 -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #main.p1_y
    sta SCREEN,x
    // SCREEN[idx++] = p.y;
    // [9] idx#13 = ++ idx#3 -- vbuxx=_inc_vbuxx 
    inx
    // print::@return
    // }
    // [10] return 
    rts
}
  // File Data

