Inlined call call __init

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start::@1
  main::x#0 = 0
  to:main::@1
main::@1: scope:[main]  from main main::@3
  main::x#2 = phi( main/main::x#0, main::@3/main::x#1 )
  main::$0 = main::x#2 < $fe
  if(main::$0) goto main::@2
  to:main::@return
main::@2: scope:[main]  from main::@1
  main::x#4 = phi( main::@1/main::x#2 )
  incscreen::ptr#0 = main::offset
  call incscreen
  to:main::@3
main::@3: scope:[main]  from main::@2
  main::x#3 = phi( main::@2/main::x#4 )
  main::x#1 = ++ main::x#3
  to:main::@1
main::@return: scope:[main]  from main::@1
  return 
  to:@return

void incscreen(unsigned int ptr)
incscreen: scope:[incscreen]  from main::@2
  incscreen::ptr#1 = phi( main::@2/incscreen::ptr#0 )
  incscreen::$0 = screen + incscreen::ptr#1
  *incscreen::$0 = -- *incscreen::$0
  incscreen::$9 = screen + incscreen::ptr#1
  incscreen::$10 = incscreen::$9 + 1
  *incscreen::$10 = -- *incscreen::$10
  incscreen::$11 = screen + incscreen::ptr#1
  *incscreen::$11 = ++ *incscreen::$11
  incscreen::$20 = screen + incscreen::ptr#1
  incscreen::$21 = incscreen::$20 + 1
  *incscreen::$21 = ++ *incscreen::$21
  to:incscreen::@return
incscreen::@return: scope:[incscreen]  from incscreen
  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 incscreen(unsigned int ptr)
char *incscreen::$0
char *incscreen::$10
char *incscreen::$11
char *incscreen::$20
char *incscreen::$21
char *incscreen::$9
unsigned int incscreen::ptr
unsigned int incscreen::ptr#0
unsigned int incscreen::ptr#1
void main()
bool main::$0
__constant unsigned int main::offset = (unsigned int)$28*$a
char main::x
char main::x#0
char main::x#1
char main::x#2
char main::x#3
char main::x#4
__constant char *screen = (char *)$400

Adding number conversion cast (unumber) $fe in main::$0 = main::x#2 < $fe
Adding number conversion cast (unumber) 1 in incscreen::$10 = incscreen::$9 + 1
Adding number conversion cast (unumber) 1 in incscreen::$21 = incscreen::$20 + 1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast $fe
Simplifying constant integer cast 1
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) $fe
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias main::x#2 = main::x#4 main::x#3 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values incscreen::ptr#1 incscreen::ptr#0
Successful SSA optimization Pass2IdenticalPhiElimination
Identified duplicate assignment right side [13] incscreen::$9 = screen + incscreen::ptr#0
Identified duplicate assignment right side [16] incscreen::$11 = screen + incscreen::ptr#0
Identified duplicate assignment right side [18] incscreen::$20 = screen + incscreen::ptr#0
Successful SSA optimization Pass2DuplicateRValueIdentification
Simple Condition main::$0 [3] if(main::x#2<$fe) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant main::x#0 = 0
Constant incscreen::ptr#0 = main::offset
Successful SSA optimization Pass2ConstantIdentification
Converting *(pointer+n) to pointer[n] [13] *incscreen::$10 = -- *incscreen::$10  -- incscreen::$9[1]
Converting *(pointer+n) to pointer[n] [13] *incscreen::$10 = -- incscreen::$9[1]  -- incscreen::$9[1]
Converting *(pointer+n) to pointer[n] [18] *incscreen::$21 = ++ *incscreen::$21  -- incscreen::$20[1]
Converting *(pointer+n) to pointer[n] [18] *incscreen::$21 = ++ incscreen::$20[1]  -- incscreen::$20[1]
Successful SSA optimization Pass2InlineDerefIdx
Eliminating unused variable incscreen::$10 and assignment [8] incscreen::$10 = incscreen::$9 + 1
Eliminating unused variable incscreen::$21 and assignment [13] incscreen::$21 = incscreen::$20 + 1
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
Alias incscreen::$9 = incscreen::$0 incscreen::$11 incscreen::$20 
Successful SSA optimization Pass2AliasElimination
Constant right-side identified [5] incscreen::$9 = screen + incscreen::ptr#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant incscreen::$9 = screen+incscreen::ptr#0
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with var siblings main::x#0
Constant inlined incscreen::ptr#0 = main::offset
Constant inlined incscreen::$9 = screen+main::offset
Constant inlined main::x#0 = 0
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(screen+main::offset+1)
Consolidated array index constant in *(screen+main::offset+1)
Consolidated array index constant in *(screen+main::offset+1)
Consolidated array index constant in *(screen+main::offset+1)
Successful SSA optimization Pass2ConstantAdditionElimination
Finalized unsigned number type (char) $28
Finalized unsigned number type (char) $a
Successful SSA optimization PassNFinalizeNumberTypeConversions
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@2
CALL GRAPH
Calls in [main] to incscreen:5 

Created 1 initial phi equivalence classes
Coalesced [7] main::x#5 = main::x#1
Coalesced down to 1 phi equivalence classes
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@2

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@3
  [1] main::x#2 = phi( main/0, main::@3/main::x#1 )
  [2] if(main::x#2<$fe) goto main::@2
  to:main::@return
main::@return: scope:[main]  from main::@1
  [3] return 
  to:@return
main::@2: scope:[main]  from main::@1
  [4] phi()
  [5] call incscreen
  to:main::@3
main::@3: scope:[main]  from main::@2
  [6] main::x#1 = ++ main::x#2
  to:main::@1

void incscreen(unsigned int ptr)
incscreen: scope:[incscreen]  from main::@2
  [7] *(screen+main::offset) = -- *(screen+main::offset)
  [8] *(screen+main::offset+1) = -- *(screen+main::offset+1)
  [9] *(screen+main::offset) = ++ *(screen+main::offset)
  [10] *(screen+main::offset+1) = ++ *(screen+main::offset+1)
  to:incscreen::@return
incscreen::@return: scope:[incscreen]  from incscreen
  [11] return 
  to:@return


VARIABLE REGISTER WEIGHTS
void incscreen(unsigned int ptr)
unsigned int incscreen::ptr
void main()
char main::x
char main::x#1 // 22.0
char main::x#2 // 8.25

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

REGISTER UPLIFT SCOPES
Uplift Scope [main] 30.25: zp[1]:2 [ main::x#2 main::x#1 ] 
Uplift Scope [incscreen] 
Uplift Scope [] 

Uplifting [main] best 334 combination reg byte x [ main::x#2 main::x#1 ] 
Uplifting [incscreen] best 334 combination 
Uplifting [] best 334 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
  // Upstart
  // Commodore 64 PRG executable file
.file [name="post-increment-problem-2.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 offset = $28*$a
    // [1] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [1] phi main::x#2 = 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    jmp __b1
    // main::@1
  __b1:
    // [2] if(main::x#2<$fe) goto main::@2 -- vbuxx_lt_vbuc1_then_la1 
    cpx #$fe
    bcc __b2_from___b1
    jmp __breturn
    // main::@return
  __breturn:
    // [3] return 
    rts
    // [4] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  __b2_from___b1:
    jmp __b2
    // main::@2
  __b2:
    // [5] call incscreen
    jsr incscreen
    jmp __b3
    // main::@3
  __b3:
    // [6] main::x#1 = ++ main::x#2 -- vbuxx=_inc_vbuxx 
    inx
    // [1] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  __b1_from___b3:
    // [1] phi main::x#2 = main::x#1 [phi:main::@3->main::@1#0] -- register_copy 
    jmp __b1
}
  // incscreen
// void incscreen(unsigned int ptr)
incscreen: {
    // [7] *(screen+main::offset) = -- *(screen+main::offset) -- _deref_pbuc1=_dec__deref_pbuc1 
    dec screen+main.offset
    // [8] *(screen+main::offset+1) = -- *(screen+main::offset+1) -- _deref_pbuc1=_dec__deref_pbuc1 
    dec screen+main.offset+1
    // [9] *(screen+main::offset) = ++ *(screen+main::offset) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc screen+main.offset
    // [10] *(screen+main::offset+1) = ++ *(screen+main::offset+1) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc screen+main.offset+1
    jmp __breturn
    // incscreen::@return
  __breturn:
    // [11] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __b2
Removing instruction jmp __b3
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __b2_from___b1 with __b2
Removing instruction __b2_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1_from_main:
Removing instruction __breturn:
Removing instruction __b3:
Removing instruction __b1_from___b3:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
void incscreen(unsigned int ptr)
unsigned int incscreen::ptr
void main()
__constant unsigned int main::offset = (unsigned int)$28*$a
char main::x
char main::x#1 // reg byte x 22.0
char main::x#2 // reg byte x 8.25
__constant char *screen = (char *) 1024

reg byte x [ main::x#2 main::x#1 ]


FINAL ASSEMBLER
Score: 211

  // File Comments
  // Upstart
  // Commodore 64 PRG executable file
.file [name="post-increment-problem-2.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 offset = $28*$a
    // [1] phi from main to main::@1 [phi:main->main::@1]
    // [1] phi main::x#2 = 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // main::@1
  __b1:
    // for (char x=0;x<254;x++)
    // [2] if(main::x#2<$fe) goto main::@2 -- vbuxx_lt_vbuc1_then_la1 
    cpx #$fe
    bcc __b2
    // main::@return
    // }
    // [3] return 
    rts
    // [4] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
    // main::@2
  __b2:
    // incscreen(offset)
    // [5] call incscreen
    jsr incscreen
    // main::@3
    // for (char x=0;x<254;x++)
    // [6] main::x#1 = ++ main::x#2 -- vbuxx=_inc_vbuxx 
    inx
    // [1] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
    // [1] phi main::x#2 = main::x#1 [phi:main::@3->main::@1#0] -- register_copy 
    jmp __b1
}
  // incscreen
// void incscreen(unsigned int ptr)
incscreen: {
    // --(*(screen+ptr));
    // [7] *(screen+main::offset) = -- *(screen+main::offset) -- _deref_pbuc1=_dec__deref_pbuc1 
    dec screen+main.offset
    // (*(screen+ptr+1))--;
    // [8] *(screen+main::offset+1) = -- *(screen+main::offset+1) -- _deref_pbuc1=_dec__deref_pbuc1 
    dec screen+main.offset+1
    // ++(*(screen+ptr));
    // [9] *(screen+main::offset) = ++ *(screen+main::offset) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc screen+main.offset
    // (*(screen+ptr+1))++;
    // [10] *(screen+main::offset+1) = ++ *(screen+main::offset+1) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc screen+main.offset+1
    // incscreen::@return
    // }
    // [11] return 
    rts
}
  // File Data

