Identified constant variable (byte*) B
Culled Empty Block (label) main::@4
Culled Empty Block (label) main::@3
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@6
Culled Empty Block (label) @1
Culled Empty Block (label) menu::@4
Culled Empty Block (label) menu::@3
Culled Empty Block (label) menu::@5
Culled Empty Block (label) menu::@6
Culled Empty Block (label) menu::@7
Culled Empty Block (label) mode::@5
Culled Empty Block (label) mode::@3
Culled Empty Block (label) mode::@6
Culled Empty Block (label) mode::@4
Culled Empty Block (label) mode::@8

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@2
main: scope:[main]  from @3
  to:main::@1
main::@1: scope:[main]  from main main::@7
  if(true) goto main::@2
  to:main::@return
main::@2: scope:[main]  from main::@1
  call menu 
  to:main::@7
main::@7: scope:[main]  from main::@2
  to:main::@1
main::@return: scope:[main]  from main::@1
  return 
  to:@return
menu: scope:[menu]  from main::@2
  to:menu::@1
menu::@1: scope:[menu]  from menu
  if(true) goto menu::@2
  to:menu::@return
menu::@2: scope:[menu]  from menu::@1
  call mode 
  to:menu::@8
menu::@8: scope:[menu]  from menu::@2
  to:menu::@return
menu::@return: scope:[menu]  from menu::@1 menu::@8
  return 
  to:@return
@2: scope:[]  from @begin
  (byte*) B#0 ← ((byte*)) (number) $1000
  to:@3
mode: scope:[mode]  from menu::@2
  to:mode::@1
mode::@1: scope:[mode]  from mode mode::@2 mode::@7
  if(true) goto mode::@2
  to:mode::@return
mode::@2: scope:[mode]  from mode::@1
  (bool~) mode::$0 ← *((byte*) B#0) == (number) 0
  (bool~) mode::$1 ← ! (bool~) mode::$0
  if((bool~) mode::$1) goto mode::@1
  to:mode::@7
mode::@7: scope:[mode]  from mode::@2
  to:mode::@1
mode::@return: scope:[mode]  from mode::@1
  return 
  to:@return
@3: scope:[]  from @2
  call main 
  to:@4
@4: scope:[]  from @3
  to:@end
@end: scope:[]  from @4

SYMBOL TABLE SSA
(label) @2
(label) @3
(label) @4
(label) @begin
(label) @end
(byte*) B
(byte*) B#0
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@7
(label) main::@return
(void()) menu()
(label) menu::@1
(label) menu::@2
(label) menu::@8
(label) menu::@return
(void()) mode()
(bool~) mode::$0
(bool~) mode::$1
(label) mode::@1
(label) mode::@2
(label) mode::@7
(label) mode::@return

Adding number conversion cast (unumber) 0 in (bool~) mode::$0 ← *((byte*) B#0) == (number) 0
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) B#0 ← (byte*)(number) $1000
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 4096
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inversing boolean not [9] (bool~) mode::$1 ← *((byte*) B#0) != (byte) 0 from [8] (bool~) mode::$0 ← *((byte*) B#0) == (byte) 0
Successful SSA optimization Pass2UnaryNotSimplification
Simple Condition (bool~) mode::$1 [10] if(*((byte*) B#0)!=(byte) 0) goto mode::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) B#0 = (byte*) 4096
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [0] if(true) goto main::@2
if() condition always true - replacing block destination [3] if(true) goto menu::@2
if() condition always true - replacing block destination [7] if(true) goto mode::@2
Successful SSA optimization Pass2ConstantIfs
Removing unused block main::@return
Removing unused block mode::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @2
Adding NOP phi() at start of @3
Adding NOP phi() at start of @4
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@1
Adding NOP phi() at start of main::@2
Adding NOP phi() at start of main::@7
Adding NOP phi() at start of menu
Adding NOP phi() at start of menu::@1
Adding NOP phi() at start of menu::@2
Adding NOP phi() at start of menu::@8
Adding NOP phi() at start of mode
Adding NOP phi() at start of mode::@1
Adding NOP phi() at start of mode::@7
CALL GRAPH
Calls in [] to main:3 
Calls in [main] to menu:9 
Calls in [menu] to mode:14 

Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block (label) @2
Culled Empty Block (label) @4
Culled Empty Block (label) main::@1
Culled Empty Block (label) main::@7
Culled Empty Block (label) menu::@1
Culled Empty Block (label) menu::@8
Culled Empty Block (label) mode::@1
Renumbering block @3 to @1
Renumbering block main::@2 to main::@1
Renumbering block menu::@2 to menu::@1
Renumbering block mode::@2 to mode::@1
Renumbering block mode::@7 to mode::@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
Adding NOP phi() at start of main::@1
Adding NOP phi() at start of menu
Adding NOP phi() at start of menu::@1
Adding NOP phi() at start of mode
Adding NOP phi() at start of mode::@2

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()
main: scope:[main]  from @1
  [4] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@1
  [5] phi()
  [6] call menu 
  to:main::@1
menu: scope:[menu]  from main::@1
  [7] phi()
  to:menu::@1
menu::@1: scope:[menu]  from menu
  [8] phi()
  [9] call mode 
  to:menu::@return
menu::@return: scope:[menu]  from menu::@1
  [10] return 
  to:@return
mode: scope:[mode]  from menu::@1
  [11] phi()
  to:mode::@1
mode::@1: scope:[mode]  from mode mode::@1 mode::@2
  [12] if(*((const byte*) B#0)!=(byte) 0) goto mode::@1
  to:mode::@2
mode::@2: scope:[mode]  from mode::@1
  [13] phi()
  to:mode::@1


VARIABLE REGISTER WEIGHTS
(byte*) B
(void()) main()
(void()) menu()
(void()) mode()

Initial phi equivalence classes
Complete equivalence classes

INITIAL ASM
Target platform is c64basic
  // File Comments
// Error cleaning up unused blocks
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label B = $1000
  // @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 main::@1 to main::@1 [phi:main/main::@1->main::@1]
  b1_from_main:
  b1_from_b1:
    jmp b1
    // main::@1
  b1:
    // [6] call menu 
    // [7] phi from main::@1 to menu [phi:main::@1->menu]
  menu_from_b1:
    jsr menu
    jmp b1_from_b1
}
  // menu
menu: {
    // [8] phi from menu to menu::@1 [phi:menu->menu::@1]
  b1_from_menu:
    jmp b1
    // menu::@1
  b1:
    // [9] call mode 
    // [11] phi from menu::@1 to mode [phi:menu::@1->mode]
  mode_from_b1:
    jsr mode
    jmp breturn
    // menu::@return
  breturn:
    // [10] return 
    rts
}
  // mode
mode: {
    jmp b1
    // mode::@1
  b1:
    // [12] if(*((const byte*) B#0)!=(byte) 0) goto mode::@1 -- _deref_pbuc1_neq_0_then_la1 
    lda B
    cmp #0
    bne b1
    // [13] phi from mode::@1 to mode::@2 [phi:mode::@1->mode::@2]
  b2_from_b1:
    jmp b2
    // mode::@2
  b2:
    jmp b1
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [12] if(*((const byte*) B#0)!=(byte) 0) goto mode::@1 [ ] ( main:2::menu:6::mode:9 [ ] ) always clobbers reg byte a 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 
Uplift Scope [menu] 
Uplift Scope [mode] 
Uplift Scope [] 

Uplifting [main] best 8929 combination 
Uplifting [menu] best 8929 combination 
Uplifting [mode] best 8929 combination 
Uplifting [] best 8929 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Error cleaning up unused blocks
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label B = $1000
  // @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 main::@1 to main::@1 [phi:main/main::@1->main::@1]
  b1_from_main:
  b1_from_b1:
    jmp b1
    // main::@1
  b1:
    // [6] call menu 
    // [7] phi from main::@1 to menu [phi:main::@1->menu]
  menu_from_b1:
    jsr menu
    jmp b1_from_b1
}
  // menu
menu: {
    // [8] phi from menu to menu::@1 [phi:menu->menu::@1]
  b1_from_menu:
    jmp b1
    // menu::@1
  b1:
    // [9] call mode 
    // [11] phi from menu::@1 to mode [phi:menu::@1->mode]
  mode_from_b1:
    jsr mode
    jmp breturn
    // menu::@return
  breturn:
    // [10] return 
    rts
}
  // mode
mode: {
    jmp b1
    // mode::@1
  b1:
    // [12] if(*((const byte*) B#0)!=(byte) 0) goto mode::@1 -- _deref_pbuc1_neq_0_then_la1 
    lda B
    cmp #0
    bne b1
    // [13] phi from mode::@1 to mode::@2 [phi:mode::@1->mode::@2]
  b2_from_b1:
    jmp b2
    // mode::@2
  b2:
    jmp b1
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b1
Removing instruction jmp breturn
Removing instruction jmp b1
Removing instruction jmp b2
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b1_from_b1 with b1
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_main:
Removing instruction b1_from_b1:
Removing instruction menu_from_b1:
Removing instruction b1_from_menu:
Removing instruction mode_from_b1:
Removing instruction b2_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b1:
Removing instruction breturn:
Removing instruction b2:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte*) B
(const byte*) B#0 B = (byte*) 4096
(void()) main()
(label) main::@1
(void()) menu()
(label) menu::@1
(label) menu::@return
(void()) mode()
(label) mode::@1
(label) mode::@2



FINAL ASSEMBLER
Score: 8551

  // File Comments
// Error cleaning up unused blocks
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .label B = $1000
  // @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 main::@1 to main::@1 [phi:main/main::@1->main::@1]
    // main::@1
  b1:
    // menu()
    // [6] call menu 
    // [7] phi from main::@1 to menu [phi:main::@1->menu]
    jsr menu
    jmp b1
}
  // menu
menu: {
    // [8] phi from menu to menu::@1 [phi:menu->menu::@1]
    // menu::@1
    // mode()
    // [9] call mode 
    // [11] phi from menu::@1 to mode [phi:menu::@1->mode]
    jsr mode
    // menu::@return
    // }
    // [10] return 
    rts
}
  // mode
mode: {
    // mode::@1
  b1:
    // if(*B == 0)
    // [12] if(*((const byte*) B#0)!=(byte) 0) goto mode::@1 -- _deref_pbuc1_neq_0_then_la1 
    lda B
    cmp #0
    bne b1
    // [13] phi from mode::@1 to mode::@2 [phi:mode::@1->mode::@2]
    // mode::@2
    jmp b1
}
  // File Data

