Identified constant variable (byte*) SCREEN
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*) SCREEN#0 ← ((byte*)) (number) $400
  to:@1
main: scope:[main]  from @1
  (byte) main::i#0 ← (byte) 0
  (byte) main::i#1 ← (number) 7
  to:main::@1
main::@1: scope:[main]  from main main::@2
  (byte) main::i#3 ← phi( main/(byte) main::i#1 main::@2/(byte) main::i#4 )
  (bool~) main::$0 ← (byte) main::i#3 < (number) 7
  (byte) main::i#2 ← ++ (byte) main::i#3
  if((bool~) main::$0) goto main::@2
  to:main::@3
main::@2: scope:[main]  from main::@1
  (byte) main::i#4 ← phi( main::@1/(byte) main::i#2 )
  *((byte*) SCREEN#0 + (byte) main::i#4) ← (byte) main::i#4
  to:main::@1
main::@3: scope:[main]  from main::@1
  (byte) main::i#5 ← phi( main::@1/(byte) main::i#2 )
  *((byte*) SCREEN#0 + (byte) main::i#5) ← (byte) 'x'
  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
(byte*) SCREEN
(byte*) SCREEN#0
(void()) main()
(bool~) main::$0
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(byte) main::i#3
(byte) main::i#4
(byte) main::i#5

Adding number conversion cast (unumber) 7 in (byte) main::i#1 ← (number) 7
Adding number conversion cast (unumber) 7 in (bool~) main::$0 ← (byte) main::i#3 < (number) 7
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
Inlining cast (byte) main::i#1 ← (unumber)(number) 7
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 7
Simplifying constant integer cast 7
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 7
Finalized unsigned number type (byte) 7
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte) main::i#2 = (byte) main::i#4 (byte) main::i#5 
Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) main::$0 [6] if((byte) main::i#3<(byte) 7) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) SCREEN#0 = (byte*) 1024
Constant (const byte) main::i#0 = 0
Constant (const byte) main::i#1 = 7
Successful SSA optimization Pass2ConstantIdentification
Eliminating unused constant (const byte) main::i#0
Successful SSA optimization PassNEliminateUnusedVars
Successful SSA optimization Pass2LoopHeadConstantIdentification
Alias (byte) main::i#3 = (byte) main::i#6 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) main::i#8 (const byte) main::i#1
Successful SSA optimization Pass2IdenticalPhiElimination
Constant right-side identified [10] (byte) main::i#9 ← ++ (const byte) main::i#1
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::i#9 = ++main::i#1
Successful SSA optimization Pass2ConstantIdentification
Removing PHI-reference to removed block (main::@1_1) in block main::@2
if() condition always false - eliminating [11] if((const byte) main::i#1<(byte) 7) goto main::@2
Successful SSA optimization Pass2ConstantIfs
Eliminating variable (byte) main::i#2 from unused block main::@1
Eliminating variable (byte) main::i#3 from unused block main::@2
Removing PHI-reference to removed block (main::@1) in block main::@2
Removing PHI-reference to removed block (main::@1) in block main::@3
Removing unused block main::@1
Removing unused block main::@2
Successful SSA optimization Pass2EliminateUnusedBlocks
Identical Phi Values (byte) main::i#7 (const byte) main::i#9
Successful SSA optimization Pass2IdenticalPhiElimination
Inlining constant with different constant siblings (const byte) main::i#1
Inlining constant with different constant siblings (const byte) main::i#9
Constant inlined main::i#9 = ++(byte) 7
Constant inlined main::i#1 = (byte) 7
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(SCREEN#0+++7)
Successful SSA optimization Pass2ConstantAdditionElimination
Simplifying constant integer increment ++7
Successful SSA optimization Pass2ConstantSimplification
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::@1_1
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::@1_1
Renumbering block main::@3 to main::@1
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()
main: scope:[main]  from @1
  [4] phi()
  to:main::@1
main::@1: scope:[main]  from main
  [5] *((const byte*) SCREEN#0+(byte) 8) ← (byte) 'x'
  to:main::@return
main::@return: scope:[main]  from main::@1
  [6] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte*) SCREEN
(void()) main()
(byte) main::i

Initial phi equivalence classes
Complete equivalence classes

INITIAL ASM
Target platform is c64basic
  // File Comments
// Test a for()-loop where the condition has a side-effect
// Currently not standard C compliant (since the condition is not evaluated before the 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: {
    jmp b1
    // main::@1
  b1:
    // [5] *((const byte*) SCREEN#0+(byte) 8) ← (byte) 'x' -- _deref_pbuc1=vbuc2 
    // The condition-evaluation should increment i - even if when it is not met - x should end up in 0x0408
    lda #'x'
    sta SCREEN+8
    jmp breturn
    // main::@return
  breturn:
    // [6] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [5] *((const byte*) SCREEN#0+(byte) 8) ← (byte) 'x' [ ] ( main:2 [ ] ) always clobbers reg byte a 

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

Uplifting [main] best 57 combination 
Uplifting [] best 57 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test a for()-loop where the condition has a side-effect
// Currently not standard C compliant (since the condition is not evaluated before the 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: {
    jmp b1
    // main::@1
  b1:
    // [5] *((const byte*) SCREEN#0+(byte) 8) ← (byte) 'x' -- _deref_pbuc1=vbuc2 
    // The condition-evaluation should increment i - even if when it is not met - x should end up in 0x0408
    lda #'x'
    sta SCREEN+8
    jmp breturn
    // main::@return
  breturn:
    // [6] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b1:
Removing instruction breturn:
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*) SCREEN
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
(void()) main()
(label) main::@1
(label) main::@return
(byte) main::i



FINAL ASSEMBLER
Score: 12

  // File Comments
// Test a for()-loop where the condition has a side-effect
// Currently not standard C compliant (since the condition is not evaluated before the 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: {
    // main::@1
    // (SCREEN)[i] = 'x'
    // [5] *((const byte*) SCREEN#0+(byte) 8) ← (byte) 'x' -- _deref_pbuc1=vbuc2 
    // The condition-evaluation should increment i - even if when it is not met - x should end up in 0x0408
    lda #'x'
    sta SCREEN+8
    // main::@return
    // }
    // [6] return 
    rts
}
  // File Data

