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
  to:@1

(void()) main()
main: scope:[main]  from @1
  (byte) main::b#0 ← (byte) 0
  to:main::@1
main::@1: scope:[main]  from main main::@2
  (byte) main::b#2 ← phi( main/(byte) main::b#0 main::@2/(byte) main::b#1 )
  (bool~) main::$1 ← *((const byte*) str + (byte) main::b#2) != (number) 0
  if((bool~) main::$1) goto main::@2
  to:main::@3
main::@2: scope:[main]  from main::@1
  (byte) main::b#3 ← phi( main::@1/(byte) main::b#2 )
  (byte) main::b#1 ← ++ (byte) main::b#3
  to:main::@1
main::@3: scope:[main]  from main::@1
  (byte) main::b#4 ← phi( main::@1/(byte) main::b#2 )
  (byte~) main::$0 ← (byte) '0' + (byte) main::b#4
  *((const byte*) SCREEN + (number) 0) ← (byte~) main::$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
(const byte*) SCREEN = (byte*)(number) $400
(void()) main()
(byte~) main::$0
(bool~) main::$1
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte) main::b
(byte) main::b#0
(byte) main::b#1
(byte) main::b#2
(byte) main::b#3
(byte) main::b#4
(const byte*) str[]  = (byte*) "Hello!"

Adding number conversion cast (unumber) 0 in (bool~) main::$1 ← *((const byte*) str + (byte) main::b#2) != (number) 0
Adding number conversion cast (unumber) 0 in *((const byte*) SCREEN + (number) 0) ← (byte~) main::$0
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte) main::b#2 = (byte) main::b#3 (byte) main::b#4 
Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) main::$1 [3] if(*((const byte*) str + (byte) main::b#2)!=(byte) 0) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) main::b#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero SCREEN in [6] *((const byte*) SCREEN + (byte) 0) ← (byte~) main::$0
Successful SSA optimization PassNSimplifyExpressionWithZero
Inlining constant with var siblings (const byte) main::b#0
Constant inlined main::b#0 = (byte) 0
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of @begin
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 1 initial phi equivalence classes
Coalesced [12] main::b#5 ← main::b#1
Coalesced down to 1 phi equivalence classes
Culled Empty Block (label) @2
Adding NOP phi() at start of @begin
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] phi()
  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::@2
  [5] (byte) main::b#2 ← phi( main/(byte) 0 main::@2/(byte) main::b#1 )
  [6] if(*((const byte*) str + (byte) main::b#2)!=(byte) 0) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@1
  [7] (byte~) main::$0 ← (byte) '0' + (byte) main::b#2
  [8] *((const byte*) SCREEN) ← (byte~) main::$0
  to:main::@return
main::@return: scope:[main]  from main::@3
  [9] return 
  to:@return
main::@2: scope:[main]  from main::@1
  [10] (byte) main::b#1 ← ++ (byte) main::b#2
  to:main::@1


VARIABLE REGISTER WEIGHTS
(void()) main()
(byte~) main::$0 4.0
(byte) main::b
(byte) main::b#1 22.0
(byte) main::b#2 17.5

Initial phi equivalence classes
[ main::b#2 main::b#1 ]
Added variable main::$0 to live range equivalence class [ main::$0 ]
Complete equivalence classes
[ main::b#2 main::b#1 ]
[ main::$0 ]
Allocated zp[1]:2 [ main::b#2 main::b#1 ]
Allocated zp[1]:3 [ main::$0 ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// Test a for-loop with an empty body
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  // @begin
__bbegin:
  // [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: {
    .label __0 = 3
    .label b = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (byte) main::b#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z b
    jmp __b1
    // main::@1
  __b1:
    // [6] if(*((const byte*) str + (byte) main::b#2)!=(byte) 0) goto main::@2 -- pbuc1_derefidx_vbuz1_neq_0_then_la1 
    ldy.z b
    lda str,y
    cmp #0
    bne __b2
    jmp __b3
    // main::@3
  __b3:
    // [7] (byte~) main::$0 ← (byte) '0' + (byte) main::b#2 -- vbuz1=vbuc1_plus_vbuz2 
    lax.z b
    axs #-['0']
    stx.z __0
    // [8] *((const byte*) SCREEN) ← (byte~) main::$0 -- _deref_pbuc1=vbuz1 
    // Empty body
    lda.z __0
    sta SCREEN
    jmp __breturn
    // main::@return
  __breturn:
    // [9] return 
    rts
    // main::@2
  __b2:
    // [10] (byte) main::b#1 ← ++ (byte) main::b#2 -- vbuz1=_inc_vbuz1 
    inc.z b
    // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  __b1_from___b2:
    // [5] phi (byte) main::b#2 = (byte) main::b#1 [phi:main::@2->main::@1#0] -- register_copy 
    jmp __b1
}
  // File Data
  str: .text "Hello!"
  .byte 0

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] if(*((const byte*) str + (byte) main::b#2)!=(byte) 0) goto main::@2 [ main::b#2 ] ( main:2 [ main::b#2 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::b#2 main::b#1 ]
Statement [7] (byte~) main::$0 ← (byte) '0' + (byte) main::b#2 [ main::$0 ] ( main:2 [ main::$0 ] ) always clobbers reg byte a 
Statement [6] if(*((const byte*) str + (byte) main::b#2)!=(byte) 0) goto main::@2 [ main::b#2 ] ( main:2 [ main::b#2 ] ) always clobbers reg byte a 
Statement [7] (byte~) main::$0 ← (byte) '0' + (byte) main::b#2 [ main::$0 ] ( main:2 [ main::$0 ] ) always clobbers reg byte a 
Potential registers zp[1]:2 [ main::b#2 main::b#1 ] : zp[1]:2 , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ main::$0 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 39.5: zp[1]:2 [ main::b#2 main::b#1 ] 4: zp[1]:3 [ main::$0 ] 
Uplift Scope [] 

Uplifting [main] best 249 combination reg byte x [ main::b#2 main::b#1 ] reg byte x [ main::$0 ] 
Uplifting [] best 249 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test a for-loop with an empty body
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  // @begin
__bbegin:
  // [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: {
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (byte) main::b#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    jmp __b1
    // main::@1
  __b1:
    // [6] if(*((const byte*) str + (byte) main::b#2)!=(byte) 0) goto main::@2 -- pbuc1_derefidx_vbuxx_neq_0_then_la1 
    lda str,x
    cmp #0
    bne __b2
    jmp __b3
    // main::@3
  __b3:
    // [7] (byte~) main::$0 ← (byte) '0' + (byte) main::b#2 -- vbuxx=vbuc1_plus_vbuxx 
    txa
    axs #-['0']
    // [8] *((const byte*) SCREEN) ← (byte~) main::$0 -- _deref_pbuc1=vbuxx 
    // Empty body
    stx SCREEN
    jmp __breturn
    // main::@return
  __breturn:
    // [9] return 
    rts
    // main::@2
  __b2:
    // [10] (byte) main::b#1 ← ++ (byte) main::b#2 -- vbuxx=_inc_vbuxx 
    inx
    // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  __b1_from___b2:
    // [5] phi (byte) main::b#2 = (byte) main::b#1 [phi:main::@2->main::@1#0] -- register_copy 
    jmp __b1
}
  // File Data
  str: .text "Hello!"
  .byte 0

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __b3
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __bbegin with __b1
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __b1_from_main:
Removing instruction __b3:
Removing instruction __breturn:
Removing instruction __b1_from___b2:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction __b1:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(const byte*) SCREEN = (byte*) 1024
(void()) main()
(byte~) main::$0 reg byte x 4.0
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte) main::b
(byte) main::b#1 reg byte x 22.0
(byte) main::b#2 reg byte x 17.5
(const byte*) str[]  = (byte*) "Hello!"

reg byte x [ main::b#2 main::b#1 ]
reg byte x [ main::$0 ]


FINAL ASSEMBLER
Score: 174

  // File Comments
// Test a for-loop with an empty body
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .label SCREEN = $400
  // @begin
  // [1] phi from @begin to @1 [phi:@begin->@1]
  // @1
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // [5] phi (byte) main::b#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // main::@1
  __b1:
    // for (; str[b] != 0; ++b)
    // [6] if(*((const byte*) str + (byte) main::b#2)!=(byte) 0) goto main::@2 -- pbuc1_derefidx_vbuxx_neq_0_then_la1 
    lda str,x
    cmp #0
    bne __b2
    // main::@3
    // '0'+b
    // [7] (byte~) main::$0 ← (byte) '0' + (byte) main::b#2 -- vbuxx=vbuc1_plus_vbuxx 
    txa
    axs #-['0']
    // SCREEN[0] = '0'+b
    // [8] *((const byte*) SCREEN) ← (byte~) main::$0 -- _deref_pbuc1=vbuxx 
    // Empty body
    stx SCREEN
    // main::@return
    // }
    // [9] return 
    rts
    // main::@2
  __b2:
    // for (; str[b] != 0; ++b)
    // [10] (byte) main::b#1 ← ++ (byte) main::b#2 -- vbuxx=_inc_vbuxx 
    inx
    // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
    // [5] phi (byte) main::b#2 = (byte) main::b#1 [phi:main::@2->main::@1#0] -- register_copy 
    jmp __b1
}
  // File Data
  str: .text "Hello!"
  .byte 0

