Identified constant variable (byte*) filesEnd
Identified constant variable (byte*) file
Culled Empty Block (label) main::@3

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) fileCur#0 ← (byte*) 0
  (byte*) fileTop#0 ← (byte*) 0
  to:@1

(void()) main()
main: scope:[main]  from @1
  (byte*) fileCur#10 ← phi( @1/(byte*) fileCur#12 )
  (byte*) fileTop#4 ← phi( @1/(byte*) fileTop#10 )
  (bool~) main::$0 ← (byte*) fileTop#4 == (const byte*) filesEnd
  (bool~) main::$1 ← ! (bool~) main::$0
  if((bool~) main::$1) goto main::@1
  to:main::@4
main::@1: scope:[main]  from main main::@4
  (byte*) fileTop#11 ← phi( main/(byte*) fileTop#4 main::@4/(byte*) fileTop#1 )
  (byte*) fileCur#5 ← phi( main/(byte*) fileCur#10 main::@4/(byte*) fileCur#11 )
  (bool~) main::$2 ← (const byte*) file <= (byte*) fileCur#5
  (bool~) main::$3 ← ! (bool~) main::$2
  if((bool~) main::$3) goto main::@2
  to:main::@5
main::@4: scope:[main]  from main
  (byte*) fileCur#11 ← phi( main/(byte*) fileCur#10 )
  (byte*) fileTop#5 ← phi( main/(byte*) fileTop#4 )
  (byte*) fileTop#1 ← -- (byte*) fileTop#5
  to:main::@1
main::@2: scope:[main]  from main::@1 main::@5
  (byte*) fileTop#6 ← phi( main::@1/(byte*) fileTop#11 main::@5/(byte*) fileTop#12 )
  (byte*) fileCur#6 ← phi( main::@1/(byte*) fileCur#5 main::@5/(byte*) fileCur#1 )
  (bool~) main::$4 ← (byte*) fileCur#6 < (byte*) fileTop#6
  (bool~) main::$5 ← ! (bool~) main::$4
  if((bool~) main::$5) goto main::@return
  to:main::@6
main::@5: scope:[main]  from main::@1
  (byte*) fileTop#12 ← phi( main::@1/(byte*) fileTop#11 )
  (byte*) fileCur#7 ← phi( main::@1/(byte*) fileCur#5 )
  (byte*) fileCur#1 ← -- (byte*) fileCur#7
  to:main::@2
main::@6: scope:[main]  from main::@2
  (byte*) fileTop#7 ← phi( main::@2/(byte*) fileTop#6 )
  (byte*) fileCur#2 ← (byte*) fileTop#7
  to:main::@return
main::@return: scope:[main]  from main::@2 main::@6
  (byte*) fileCur#8 ← phi( main::@2/(byte*) fileCur#6 main::@6/(byte*) fileCur#2 )
  (byte*) fileTop#8 ← phi( main::@2/(byte*) fileTop#6 main::@6/(byte*) fileTop#7 )
  (byte*) fileTop#2 ← (byte*) fileTop#8
  (byte*) fileCur#3 ← (byte*) fileCur#8
  return 
  to:@return
@1: scope:[]  from @begin
  (byte*) fileCur#12 ← phi( @begin/(byte*) fileCur#0 )
  (byte*) fileTop#10 ← phi( @begin/(byte*) fileTop#0 )
  call main 
  to:@2
@2: scope:[]  from @1
  (byte*) fileCur#9 ← phi( @1/(byte*) fileCur#3 )
  (byte*) fileTop#9 ← phi( @1/(byte*) fileTop#2 )
  (byte*) fileTop#3 ← (byte*) fileTop#9
  (byte*) fileCur#4 ← (byte*) fileCur#9
  to:@end
@end: scope:[]  from @2

SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(const byte*) file = (byte*) 0
(byte*) fileCur
(byte*) fileCur#0
(byte*) fileCur#1
(byte*) fileCur#10
(byte*) fileCur#11
(byte*) fileCur#12
(byte*) fileCur#2
(byte*) fileCur#3
(byte*) fileCur#4
(byte*) fileCur#5
(byte*) fileCur#6
(byte*) fileCur#7
(byte*) fileCur#8
(byte*) fileCur#9
(byte*) fileTop
(byte*) fileTop#0
(byte*) fileTop#1
(byte*) fileTop#10
(byte*) fileTop#11
(byte*) fileTop#12
(byte*) fileTop#2
(byte*) fileTop#3
(byte*) fileTop#4
(byte*) fileTop#5
(byte*) fileTop#6
(byte*) fileTop#7
(byte*) fileTop#8
(byte*) fileTop#9
(const byte*) filesEnd = (byte*) 0
(void()) main()
(bool~) main::$0
(bool~) main::$1
(bool~) main::$2
(bool~) main::$3
(bool~) main::$4
(bool~) main::$5
(label) main::@1
(label) main::@2
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@return

Inversing boolean not [4] (bool~) main::$1 ← (byte*) fileTop#4 != (const byte*) filesEnd from [3] (bool~) main::$0 ← (byte*) fileTop#4 == (const byte*) filesEnd
Inversing boolean not [8] (bool~) main::$3 ← (const byte*) file > (byte*) fileCur#5 from [7] (bool~) main::$2 ← (const byte*) file <= (byte*) fileCur#5
Inversing boolean not [14] (bool~) main::$5 ← (byte*) fileCur#6 >= (byte*) fileTop#6 from [13] (bool~) main::$4 ← (byte*) fileCur#6 < (byte*) fileTop#6
Successful SSA optimization Pass2UnaryNotSimplification
Alias (byte*) fileTop#4 = (byte*) fileTop#5 
Alias (byte*) fileCur#10 = (byte*) fileCur#11 
Alias (byte*) fileCur#5 = (byte*) fileCur#7 
Alias (byte*) fileTop#11 = (byte*) fileTop#12 
Alias (byte*) fileTop#6 = (byte*) fileTop#7 (byte*) fileCur#2 
Alias (byte*) fileTop#2 = (byte*) fileTop#8 
Alias (byte*) fileCur#3 = (byte*) fileCur#8 
Alias (byte*) fileTop#0 = (byte*) fileTop#10 
Alias (byte*) fileCur#0 = (byte*) fileCur#12 
Alias (byte*) fileTop#3 = (byte*) fileTop#9 
Alias (byte*) fileCur#4 = (byte*) fileCur#9 
Successful SSA optimization Pass2AliasElimination
Alias candidate removed (phi-usage) (byte*) fileTop#11 = (byte*) fileTop#6 (byte*) fileTop#2 
Alias (byte*) fileCur#10 = (byte*) fileCur#5 
Successful SSA optimization Pass2AliasElimination
Alias candidate removed (phi-usage) (byte*) fileTop#11 = (byte*) fileTop#6 (byte*) fileTop#2 
Identical Phi Values (byte*) fileTop#4 (byte*) fileTop#0
Identical Phi Values (byte*) fileCur#10 (byte*) fileCur#0
Identical Phi Values (byte*) fileTop#6 (byte*) fileTop#11
Identical Phi Values (byte*) fileTop#2 (byte*) fileTop#6
Identical Phi Values (byte*) fileTop#3 (byte*) fileTop#2
Identical Phi Values (byte*) fileCur#4 (byte*) fileCur#3
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$1 [5] if((byte*) fileTop#0!=(const byte*) filesEnd) goto main::@1
Simple Condition (bool~) main::$3 [9] if((const byte*) file>(byte*) fileCur#0) goto main::@2
Simple Condition (bool~) main::$5 [15] if((byte*) fileCur#6>=(byte*) fileTop#11) goto main::@return
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) fileCur#0 = (byte*) 0
Constant (const byte*) fileTop#0 = (byte*) 0
Successful SSA optimization Pass2ConstantIdentification
Removing PHI-reference to removed block (main) in block main::@1
if() condition always false - eliminating [5] if((const byte*) fileTop#0!=(const byte*) filesEnd) goto main::@1
Removing PHI-reference to removed block (main::@1) in block main::@2
if() condition always false - eliminating [9] if((const byte*) file>(const byte*) fileCur#0) goto main::@2
Successful SSA optimization Pass2ConstantIfs
Eliminating unused variable - keeping the phi block (byte*) fileCur#3
Eliminating unused constant (const byte*) filesEnd
Eliminating unused constant (const byte*) file
Successful SSA optimization PassNEliminateUnusedVars
Alias (byte*) fileTop#1 = (byte*) fileTop#11 
Alias (byte*) fileCur#1 = (byte*) fileCur#6 
Successful SSA optimization Pass2AliasElimination
Constant right-side identified [1] (byte*) fileTop#1 ← -- (const byte*) fileTop#0
Constant right-side identified [4] (byte*) fileCur#1 ← -- (const byte*) fileCur#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) fileTop#1 = --fileTop#0
Constant (const byte*) fileCur#1 = --fileCur#0
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [3] if((const byte*) fileCur#1>=(const byte*) fileTop#1) goto main::@return
Successful SSA optimization Pass2ConstantIfs
Eliminating unused constant (const byte*) fileTop#1
Eliminating unused constant (const byte*) fileCur#1
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused constant (const byte*) fileCur#0
Eliminating unused constant (const byte*) fileTop#0
Successful SSA optimization PassNEliminateUnusedVars
Removing unused block main::@6
Successful SSA optimization Pass2EliminateUnusedBlocks
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
Adding NOP phi() at start of main::@4
Adding NOP phi() at start of main::@1
Adding NOP phi() at start of main::@5
Adding NOP phi() at start of main::@2
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
Culled Empty Block (label) main::@4
Culled Empty Block (label) main::@1
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@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::@return
main::@return: scope:[main]  from main
  [5] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte*) fileCur
(byte*) fileTop
(void()) main()

Initial phi equivalence classes
Complete equivalence classes

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  // @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: {
    jmp __breturn
    // main::@return
  __breturn:
    // [5] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS

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

Uplifting [main] best 48 combination 
Uplifting [] best 48 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  // @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: {
    jmp __breturn
    // main::@return
  __breturn:
    // [5] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
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 __breturn:
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
(byte*) fileCur
(byte*) fileTop
(void()) main()
(label) main::@return



FINAL ASSEMBLER
Score: 6

  // File Comments
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  // @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: {
    // main::@return
    // }
    // [5] return 
    rts
}
  // File Data

