
CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start
  puta::ph#0 = 4
  puta::pl#0 = 0
  call puta
  to:main::@1
main::@1: scope:[main]  from main
  puta::ph#1 = 5
  puta::pl#1 = $18
  call puta
  to:main::@2
main::@2: scope:[main]  from main::@1
  to:main::@return
main::@return: scope:[main]  from main::@2
  return 
  to:@return

void puta(char ph , char pl)
puta: scope:[puta]  from main main::@1
  puta::pl#2 = phi( main/puta::pl#0, main::@1/puta::pl#1 )
  puta::ph#2 = phi( main/puta::ph#0, main::@1/puta::ph#1 )
  puta::$0 = puta::ph#2 w= puta::pl#2
  puta::screen#0 = (char *)puta::$0
  *puta::screen#0 = 'a'
  to:puta::@return
puta::@return: scope:[puta]  from puta
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  call main
  to:__start::@1
__start::@1: scope:[__start]  from __start
  to:__start::@return
__start::@return: scope:[__start]  from __start::@1
  return 
  to:@return

SYMBOL TABLE SSA
void __start()
void main()
void puta(char ph , char pl)
unsigned int puta::$0
char puta::ph
char puta::ph#0
char puta::ph#1
char puta::ph#2
char puta::pl
char puta::pl#0
char puta::pl#1
char puta::pl#2
char *puta::screen
char *puta::screen#0

Adding number conversion cast (unumber) 4 in puta::ph#0 = 4
Adding number conversion cast (unumber) 0 in puta::pl#0 = 0
Adding number conversion cast (unumber) 5 in puta::ph#1 = 5
Adding number conversion cast (unumber) $18 in puta::pl#1 = $18
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast puta::ph#0 = (unumber)4
Inlining cast puta::pl#0 = (unumber)0
Inlining cast puta::ph#1 = (unumber)5
Inlining cast puta::pl#1 = (unumber)$18
Successful SSA optimization Pass2InlineCast
Simplifying constant integer cast 4
Simplifying constant integer cast 0
Simplifying constant integer cast 5
Simplifying constant integer cast $18
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 4
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 5
Finalized unsigned number type (char) $18
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant puta::ph#0 = 4
Constant puta::pl#0 = 0
Constant puta::ph#1 = 5
Constant puta::pl#1 = $18
Successful SSA optimization Pass2ConstantIdentification
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::@1
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Inlining Noop Cast [5] puta::screen#0 = (char *)puta::$0 keeping puta::screen#0
Successful SSA optimization Pass2NopCastInlining
Inlining constant with var siblings puta::ph#0
Inlining constant with var siblings puta::pl#0
Inlining constant with var siblings puta::ph#1
Inlining constant with var siblings puta::pl#1
Constant inlined puta::pl#0 = 0
Constant inlined puta::ph#1 = 5
Constant inlined puta::ph#0 = 4
Constant inlined puta::pl#1 = $18
Successful SSA optimization Pass2ConstantInlining
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 puta:1 puta:3 

Created 2 initial phi equivalence classes
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 puta
  to:main::@1
main::@1: scope:[main]  from main
  [2] phi()
  [3] call puta
  to:main::@return
main::@return: scope:[main]  from main::@1
  [4] return 
  to:@return

void puta(char ph , char pl)
puta: scope:[puta]  from main main::@1
  [5] puta::pl#2 = phi( main/0, main::@1/$18 )
  [5] puta::ph#2 = phi( main/4, main::@1/5 )
  [6] puta::screen#0 = puta::ph#2 w= puta::pl#2
  [7] *((char *)puta::screen#0) = 'a'
  to:puta::@return
puta::@return: scope:[puta]  from puta
  [8] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void main()
void puta(char ph , char pl)
char puta::ph
char puta::ph#2 // 11.0
char puta::pl
char puta::pl#2 // 11.0
char *puta::screen
unsigned int puta::screen#0 // 11.0

Initial phi equivalence classes
[ puta::ph#2 ]
[ puta::pl#2 ]
Added variable puta::screen#0 to live range equivalence class [ puta::screen#0 ]
Complete equivalence classes
[ puta::ph#2 ]
[ puta::pl#2 ]
[ puta::screen#0 ]
Allocated zp[1]:2 [ puta::ph#2 ]
Allocated zp[1]:3 [ puta::pl#2 ]
Allocated zp[2]:4 [ puta::screen#0 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [7] *((char *)puta::screen#0) = 'a' [ ] ( puta:1 [ ] { }  puta:3 [ ] { }  ) always clobbers reg byte a reg byte y 
Potential registers zp[1]:2 [ puta::ph#2 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ puta::pl#2 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[2]:4 [ puta::screen#0 ] : zp[2]:4 , 

REGISTER UPLIFT SCOPES
Uplift Scope [puta] 11: zp[1]:2 [ puta::ph#2 ] 11: zp[1]:3 [ puta::pl#2 ] 11: zp[2]:4 [ puta::screen#0 ] 
Uplift Scope [main] 
Uplift Scope [] 

Uplifting [puta] best 57 combination reg byte x [ puta::ph#2 ] reg byte a [ puta::pl#2 ] zp[2]:4 [ puta::screen#0 ] 
Uplifting [main] best 57 combination 
Uplifting [] best 57 combination 
Allocated (was zp[2]:4) zp[2]:2 [ puta::screen#0 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Tests creating a literal pointer from two bytes
  // Upstart
  // Commodore 64 PRG executable file
.file [name="inline-pointer-1.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
.segment Code
  // main
main: {
    // [1] call puta
    // [5] phi from main to puta [phi:main->puta]
  puta_from_main:
    // [5] phi puta::pl#2 = 0 [phi:main->puta#0] -- vbuaa=vbuc1 
    lda #0
    // [5] phi puta::ph#2 = 4 [phi:main->puta#1] -- vbuxx=vbuc1 
    ldx #4
    jsr puta
    // [2] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    jmp __b1
    // main::@1
  __b1:
    // [3] call puta
    // [5] phi from main::@1 to puta [phi:main::@1->puta]
  puta_from___b1:
    // [5] phi puta::pl#2 = $18 [phi:main::@1->puta#0] -- vbuaa=vbuc1 
    lda #$18
    // [5] phi puta::ph#2 = 5 [phi:main::@1->puta#1] -- vbuxx=vbuc1 
    ldx #5
    jsr puta
    jmp __breturn
    // main::@return
  __breturn:
    // [4] return 
    rts
}
  // puta
// void puta(__register(X) char ph, __register(A) char pl)
puta: {
    .label screen = 2
    // [6] puta::screen#0 = puta::ph#2 w= puta::pl#2 -- vwuz1=vbuxx_word_vbuaa 
    stx.z screen+1
    sta.z screen
    // [7] *((char *)puta::screen#0) = 'a' -- _deref_pbuz1=vbuc1 
    lda #'a'
    ldy #0
    sta (screen),y
    jmp __breturn
    // puta::@return
  __breturn:
    // [8] 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 puta_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction puta_from_main:
Removing instruction __b1:
Removing instruction __breturn:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
void main()
void puta(char ph , char pl)
char puta::ph
char puta::ph#2 // reg byte x 11.0
char puta::pl
char puta::pl#2 // reg byte a 11.0
char *puta::screen
unsigned int puta::screen#0 // screen zp[2]:2 11.0

reg byte x [ puta::ph#2 ]
reg byte a [ puta::pl#2 ]
zp[2]:2 [ puta::screen#0 ]


FINAL ASSEMBLER
Score: 48

  // File Comments
// Tests creating a literal pointer from two bytes
  // Upstart
  // Commodore 64 PRG executable file
.file [name="inline-pointer-1.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
.segment Code
  // main
main: {
    // puta(4, 0x00)
    // [1] call puta
    // [5] phi from main to puta [phi:main->puta]
    // [5] phi puta::pl#2 = 0 [phi:main->puta#0] -- vbuaa=vbuc1 
    lda #0
    // [5] phi puta::ph#2 = 4 [phi:main->puta#1] -- vbuxx=vbuc1 
    ldx #4
    jsr puta
    // [2] phi from main to main::@1 [phi:main->main::@1]
    // main::@1
    // puta(5, 0x18)
    // [3] call puta
    // [5] phi from main::@1 to puta [phi:main::@1->puta]
    // [5] phi puta::pl#2 = $18 [phi:main::@1->puta#0] -- vbuaa=vbuc1 
    lda #$18
    // [5] phi puta::ph#2 = 5 [phi:main::@1->puta#1] -- vbuxx=vbuc1 
    ldx #5
    jsr puta
    // main::@return
    // }
    // [4] return 
    rts
}
  // puta
// void puta(__register(X) char ph, __register(A) char pl)
puta: {
    .label screen = 2
    // MAKEWORD( ph, pl )
    // [6] puta::screen#0 = puta::ph#2 w= puta::pl#2 -- vwuz1=vbuxx_word_vbuaa 
    stx.z screen+1
    sta.z screen
    // *screen = 'a'
    // [7] *((char *)puta::screen#0) = 'a' -- _deref_pbuz1=vbuc1 
    lda #'a'
    ldy #0
    sta (screen),y
    // puta::@return
    // }
    // [8] return 
    rts
}
  // File Data

