Culled Empty Block (label) main::@2
Culled Empty Block (label) main::@4
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@6

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte) x ← (byte) $c
  to:@1

(void()) main()
main: scope:[main]  from @1
  to:main::@1
main::@1: scope:[main]  from main main::@1
  (byte) x ← ++ (byte) x
  (bool~) main::$0 ← (byte) x < (number) $32
  if((bool~) main::$0) goto main::@1
  to:main::@3
main::@3: scope:[main]  from main::@1
  (byte) x ← (number) 0
  to:main::@return
main::@return: scope:[main]  from main::@3
  return 
  to:@return
@1: scope:[]  from @begin
  call main 
  to:@2
@2: scope:[]  from @1
  to:@end
@end: scope:[]  from @2

SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(void()) main()
(bool~) main::$0
(label) main::@1
(label) main::@3
(label) main::@return
(byte) x loadstore

Adding number conversion cast (unumber) $32 in (bool~) main::$0 ← (byte) x < (number) $32
Adding number conversion cast (unumber) 0 in (byte) x ← (number) 0
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte) x ← (unumber)(number) 0
Successful SSA optimization Pass2InlineCast
Simplifying constant integer cast $32
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $32
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simple Condition (bool~) main::$0 [3] if((byte) x<(byte) $32) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Adding NOP phi() at start of @1
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
CALL GRAPH
Calls in [] to main:2 

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block (label) @2
Renumbering block main::@3 to main::@2
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
Adding NOP phi() at start of main

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] (byte) x ← (byte) $c
  to:@1
@1: scope:[]  from @begin
  [1] phi()
  [2] call main 
  to:@end
@end: scope:[]  from @1
  [3] phi()

(void()) main()
main: scope:[main]  from @1
  [4] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@1
  [5] (byte) x ← ++ (byte) x
  [6] if((byte) x<(byte) $32) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1
  [7] (byte) x ← (byte) 0
  to:main::@return
main::@return: scope:[main]  from main::@2
  [8] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(byte) x loadstore 37.0

Initial phi equivalence classes
Added variable x to live range equivalence class [ x ]
Complete equivalence classes
[ x ]
Allocated zp[1]:2 [ x ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// Illustrates a problem where volatiles with initializers are initialized outside the main()-routine
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label x = 2
  // @begin
__bbegin:
  // [0] (byte) x ← (byte) $c -- vbuz1=vbuc1 
  lda #$c
  sta.z x
  // [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
  jmp __b1
  // @1
__b1:
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
main_from___b1:
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
  jmp __bend
  // @end
__bend:
  // main
main: {
    jmp __b1
    // main::@1
  __b1:
    // [5] (byte) x ← ++ (byte) x -- vbuz1=_inc_vbuz1 
    inc.z x
    // [6] if((byte) x<(byte) $32) goto main::@1 -- vbuz1_lt_vbuc1_then_la1 
    lda.z x
    cmp #$32
    bcc __b1
    jmp __b2
    // main::@2
  __b2:
    // [7] (byte) x ← (byte) 0 -- vbuz1=vbuc1 
    lda #0
    sta.z x
    jmp __breturn
    // main::@return
  __breturn:
    // [8] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] (byte) x ← (byte) $c [ ] (  [ ] ) always clobbers reg byte a 
Statement [6] if((byte) x<(byte) $32) goto main::@1 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [7] (byte) x ← (byte) 0 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Potential registers zp[1]:2 [ x ] : zp[1]:2 , 

REGISTER UPLIFT SCOPES
Uplift Scope [] 37: zp[1]:2 [ x ] 
Uplift Scope [main] 

Uplifting [] best 216 combination zp[1]:2 [ x ] 
Uplifting [main] best 216 combination 
Attempting to uplift remaining variables inzp[1]:2 [ x ]
Uplifting [] best 216 combination zp[1]:2 [ x ] 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Illustrates a problem where volatiles with initializers are initialized outside the main()-routine
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label x = 2
  // @begin
__bbegin:
  // [0] (byte) x ← (byte) $c -- vbuz1=vbuc1 
  lda #$c
  sta.z x
  // [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
  jmp __b1
  // @1
__b1:
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
main_from___b1:
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
  jmp __bend
  // @end
__bend:
  // main
main: {
    jmp __b1
    // main::@1
  __b1:
    // [5] (byte) x ← ++ (byte) x -- vbuz1=_inc_vbuz1 
    inc.z x
    // [6] if((byte) x<(byte) $32) goto main::@1 -- vbuz1_lt_vbuc1_then_la1 
    lda.z x
    cmp #$32
    bcc __b1
    jmp __b2
    // main::@2
  __b2:
    // [7] (byte) x ← (byte) 0 -- vbuz1=vbuc1 
    lda #0
    sta.z x
    jmp __breturn
    // main::@return
  __breturn:
    // [8] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1:
Removing instruction __bend:
Removing instruction __b2:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Adding RTS to root block 
Succesful ASM optimization Pass5AddMainRts

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(byte) x loadstore zp[1]:2 37.0

zp[1]:2 [ x ]


FINAL ASSEMBLER
Score: 153

  // File Comments
// Illustrates a problem where volatiles with initializers are initialized outside the main()-routine
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label x = 2
  // @begin
__bbegin:
  // x = 12
  // [0] (byte) x ← (byte) $c -- vbuz1=vbuc1 
  lda #$c
  sta.z x
  // [1] phi from @begin to @1 [phi:@begin->@1]
  // @1
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
  jsr main
  rts
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    // main::@1
  __b1:
    // while(++x<50)
    // [5] (byte) x ← ++ (byte) x -- vbuz1=_inc_vbuz1 
    inc.z x
    // [6] if((byte) x<(byte) $32) goto main::@1 -- vbuz1_lt_vbuc1_then_la1 
    lda.z x
    cmp #$32
    bcc __b1
    // main::@2
    // x = 0
    // [7] (byte) x ← (byte) 0 -- vbuz1=vbuc1 
    lda #0
    sta.z x
    // main::@return
    // }
    // [8] return 
    rts
}
  // File Data

