Inlined call call __init

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start::@1
  to:main::@1
main::@1: scope:[main]  from main main::@1 main::@2
  key#0 = *DC00
  main::$0 = key#0 == 0
  main::$1 = key#0 & $1f
  main::$2 = main::$1 == $1f
  main::$3 = main::$0 && main::$2
  if(main::$3) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1
  key#8 = phi( main::@1/key#0 )
  if(true) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@2
  key#5 = phi( main::@2/key#8 )
  key#1 = key#5
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  to:__start::__init1
__start::__init1: scope:[__start]  from __start
  key#2 = 0
  to:__start::@1
__start::@1: scope:[__start]  from __start::__init1
  key#9 = phi( __start::__init1/key#2 )
  call main
  to:__start::@2
__start::@2: scope:[__start]  from __start::@1
  key#6 = phi( __start::@1/key#1 )
  key#3 = key#6
  to:__start::@return
__start::@return: scope:[__start]  from __start::@2
  key#7 = phi( __start::@2/key#3 )
  key#4 = key#7
  return 
  to:@return

SYMBOL TABLE SSA
__constant char * const DC00 = (char *)$dc00
void __start()
char key
char key#0
char key#1
char key#2
char key#3
char key#4
char key#5
char key#6
char key#7
char key#8
char key#9
void main()
bool main::$0
number main::$1
bool main::$2
bool main::$3

Adding number conversion cast (unumber) 0 in main::$0 = key#0 == 0
Adding number conversion cast (unumber) $1f in main::$1 = key#0 & $1f
Adding number conversion cast (unumber) main::$1 in main::$1 = key#0 & (unumber)$1f
Adding number conversion cast (unumber) $1f in main::$2 = main::$1 == $1f
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (char *) 56320
Simplifying constant integer cast 0
Simplifying constant integer cast $1f
Simplifying constant integer cast $1f
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) $1f
Finalized unsigned number type (char) $1f
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to char in main::$1 = key#0 & $1f
Alias key#0 = key#8 key#5 key#1 
Alias key#2 = key#9 
Alias key#3 = key#6 key#7 key#4 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values key#3 key#0
Successful SSA optimization Pass2IdenticalPhiElimination
Rewriting && if()-condition to two if()s [4] main::$3 = main::$0 && main::$2
Successful SSA optimization Pass2ConditionalAndOrRewriting
Constant key#2 = 0
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [6] if(true) goto main::@1
Successful SSA optimization Pass2ConstantIfs
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Eliminating unused constant key#2
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
Simple Condition main::$0 [4] if(key#0==0) goto main::@3
Simple Condition main::$2 [5] if(main::$1==$1f) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Negating conditional jump and destination [4] if(key#0!=0) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSequenceImprovement
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@2
CALL GRAPH

Created 0 initial phi equivalence classes
Coalesced down to 0 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::@2 main::@3
  [1] key#0 = *DC00
  [2] main::$1 = key#0 & $1f
  [3] if(key#0!=0) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@1
  [4] if(main::$1==$1f) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@3
  [5] phi()
  to:main::@1


VARIABLE REGISTER WEIGHTS
char key
char key#0 // 151.5
void main()
char main::$1 // 101.0

Initial phi equivalence classes
Added variable key#0 to live range equivalence class [ key#0 ]
Added variable main::$1 to live range equivalence class [ main::$1 ]
Complete equivalence classes
[ key#0 ]
[ main::$1 ]
Allocated zp[1]:2 [ key#0 ]
Allocated zp[1]:3 [ main::$1 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Potential registers zp[1]:2 [ key#0 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ main::$1 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [] 151.5: zp[1]:2 [ key#0 ] 
Uplift Scope [main] 101: zp[1]:3 [ main::$1 ] 

Uplifting [] best 2490 combination reg byte x [ key#0 ] 
Uplifting [main] best 2090 combination reg byte a [ main::$1 ] 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Duplicate Loop Problem from Richard-William Loerakker
// Resulted in infinite loop in loop depth analysis
  // Upstart
  // Commodore 64 PRG executable file
.file [name="duplicate-loop-problem.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 DC00 = $dc00
.segment Code
  // main
main: {
    jmp __b1
    // main::@1
  __b1:
    // [1] key#0 = *DC00 -- vbuxx=_deref_pbuc1 
    ldx DC00
    // [2] main::$1 = key#0 & $1f -- vbuaa=vbuxx_band_vbuc1 
    txa
    and #$1f
    // [3] if(key#0!=0) goto main::@2 -- vbuxx_neq_0_then_la1 
    cpx #0
    bne __b2_from___b1
    jmp __b3
    // main::@3
  __b3:
    // [4] if(main::$1==$1f) goto main::@1 -- vbuaa_eq_vbuc1_then_la1 
    cmp #$1f
    beq __b1
    // [5] phi from main::@1 main::@3 to main::@2 [phi:main::@1/main::@3->main::@2]
  __b2_from___b1:
  __b2_from___b3:
    jmp __b2
    // main::@2
  __b2:
    jmp __b1
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __b3
Removing instruction jmp __b2
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __b2_from___b1 with __b2
Removing instruction __b2_from___b1:
Removing instruction __b2_from___b3:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b3:
Succesful ASM optimization Pass5UnusedLabelElimination
Skipping double jump to __b1 in bne __b2
Succesful ASM optimization Pass5DoubleJumpElimination
Removing instruction __b2:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
__constant char * const DC00 = (char *) 56320
char key
char key#0 // reg byte x 151.5
void main()
char main::$1 // reg byte a 101.0

reg byte x [ key#0 ]
reg byte a [ main::$1 ]


FINAL ASSEMBLER
Score: 1730

  // File Comments
// Duplicate Loop Problem from Richard-William Loerakker
// Resulted in infinite loop in loop depth analysis
  // Upstart
  // Commodore 64 PRG executable file
.file [name="duplicate-loop-problem.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 DC00 = $dc00
.segment Code
  // main
main: {
    // main::@1
  __b1:
    // key = *DC00
    // [1] key#0 = *DC00 -- vbuxx=_deref_pbuc1 
    ldx DC00
    // key & %00011111
    // [2] main::$1 = key#0 & $1f -- vbuaa=vbuxx_band_vbuc1 
    txa
    and #$1f
    // while(key == 0 && ((key & %00011111) == %00011111))
    // [3] if(key#0!=0) goto main::@2 -- vbuxx_neq_0_then_la1 
    cpx #0
    bne __b1
    // main::@3
    // [4] if(main::$1==$1f) goto main::@1 -- vbuaa_eq_vbuc1_then_la1 
    cmp #$1f
    beq __b1
    // [5] phi from main::@1 main::@3 to main::@2 [phi:main::@1/main::@3->main::@2]
    // main::@2
    jmp __b1
}
  // File Data

