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

(void()) main()
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 )
  *((const byte*) SCREEN + (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 )
  *((const byte*) SCREEN + (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
(const byte*) SCREEN = (byte*)(number) $400
(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) 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 [5] if((byte) main::i#3<(byte) 7) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
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
Inlining constant with var siblings (const byte) main::i#1
Constant inlined main::i#1 = (byte) 7
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
Not coalescing [12] main::i#6 ← main::i#2
Coalesced down to 2 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::i#3 ← phi( main/(byte) 7 main::@2/(byte) main::i#6 )
  [6] (byte) main::i#2 ← ++ (byte) main::i#3
  [7] if((byte) main::i#3<(byte) 7) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@1
  [8] *((const byte*) SCREEN + (byte) main::i#2) ← (byte) 'x'
  to:main::@return
main::@return: scope:[main]  from main::@3
  [9] return 
  to:@return
main::@2: scope:[main]  from main::@1
  [10] *((const byte*) SCREEN + (byte) main::i#2) ← (byte) main::i#2
  [11] (byte) main::i#6 ← (byte) main::i#2
  to:main::@1


VARIABLE REGISTER WEIGHTS
(void()) main()
(byte) main::i
(byte) main::i#2 15.333333333333332
(byte) main::i#3 16.5
(byte) main::i#6 22.0

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

INITIAL ASM
Target platform is c64basic / MOS6502X
  // 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: {
    .label i = 3
    .label i_1 = 2
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (byte) main::i#3 = (byte) 7 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #7
    sta.z i_1
    jmp __b1
    // main::@1
  __b1:
    // [6] (byte) main::i#2 ← ++ (byte) main::i#3 -- vbuz1=_inc_vbuz2 
    ldy.z i_1
    iny
    sty.z i
    // [7] if((byte) main::i#3<(byte) 7) goto main::@2 -- vbuz1_lt_vbuc1_then_la1 
    lda.z i_1
    cmp #7
    bcc __b2
    jmp __b3
    // main::@3
  __b3:
    // [8] *((const byte*) SCREEN + (byte) main::i#2) ← (byte) 'x' -- pbuc1_derefidx_vbuz1=vbuc2 
    // The condition-evaluation should increment i - even if when it is not met - x should end up in 0x0408
    lda #'x'
    ldy.z i
    sta SCREEN,y
    jmp __breturn
    // main::@return
  __breturn:
    // [9] return 
    rts
    // main::@2
  __b2:
    // [10] *((const byte*) SCREEN + (byte) main::i#2) ← (byte) main::i#2 -- pbuc1_derefidx_vbuz1=vbuz1 
    ldy.z i
    tya
    sta SCREEN,y
    // [11] (byte) main::i#6 ← (byte) main::i#2 -- vbuz1=vbuz2 
    lda.z i
    sta.z i_1
    // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  __b1_from___b2:
    // [5] phi (byte) main::i#3 = (byte) main::i#6 [phi:main::@2->main::@1#0] -- register_copy 
    jmp __b1
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [8] *((const byte*) SCREEN + (byte) main::i#2) ← (byte) 'x' [ ] ( main:2 [ ] ) always clobbers reg byte a 
Potential registers zp[1]:2 [ main::i#3 main::i#6 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ main::i#2 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 38.5: zp[1]:2 [ main::i#3 main::i#6 ] 15.33: zp[1]:3 [ main::i#2 ] 
Uplift Scope [] 

Uplifting [main] best 313 combination reg byte a [ main::i#3 main::i#6 ] reg byte x [ main::i#2 ] 
Uplifting [] best 313 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: {
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (byte) main::i#3 = (byte) 7 [phi:main->main::@1#0] -- vbuaa=vbuc1 
    lda #7
    jmp __b1
    // main::@1
  __b1:
    // [6] (byte) main::i#2 ← ++ (byte) main::i#3 -- vbuxx=_inc_vbuaa 
    tax
    inx
    // [7] if((byte) main::i#3<(byte) 7) goto main::@2 -- vbuaa_lt_vbuc1_then_la1 
    cmp #7
    bcc __b2
    jmp __b3
    // main::@3
  __b3:
    // [8] *((const byte*) SCREEN + (byte) main::i#2) ← (byte) 'x' -- pbuc1_derefidx_vbuxx=vbuc2 
    // The condition-evaluation should increment i - even if when it is not met - x should end up in 0x0408
    lda #'x'
    sta SCREEN,x
    jmp __breturn
    // main::@return
  __breturn:
    // [9] return 
    rts
    // main::@2
  __b2:
    // [10] *((const byte*) SCREEN + (byte) main::i#2) ← (byte) main::i#2 -- pbuc1_derefidx_vbuxx=vbuxx 
    txa
    sta SCREEN,x
    // [11] (byte) main::i#6 ← (byte) main::i#2 -- vbuaa=vbuxx 
    txa
    // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
  __b1_from___b2:
    // [5] phi (byte) main::i#3 = (byte) main::i#6 [phi:main::@2->main::@1#0] -- register_copy 
    jmp __b1
}
  // File Data

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()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(byte) main::i
(byte) main::i#2 reg byte x 15.333333333333332
(byte) main::i#3 reg byte a 16.5
(byte) main::i#6 reg byte a 22.0

reg byte a [ main::i#3 main::i#6 ]
reg byte x [ main::i#2 ]


FINAL ASSEMBLER
Score: 238

  // 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: {
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // [5] phi (byte) main::i#3 = (byte) 7 [phi:main->main::@1#0] -- vbuaa=vbuc1 
    lda #7
    // main::@1
  __b1:
    // for(i=7;i++<7;)
    // [6] (byte) main::i#2 ← ++ (byte) main::i#3 -- vbuxx=_inc_vbuaa 
    tax
    inx
    // [7] if((byte) main::i#3<(byte) 7) goto main::@2 -- vbuaa_lt_vbuc1_then_la1 
    cmp #7
    bcc __b2
    // main::@3
    // (SCREEN)[i] = 'x'
    // [8] *((const byte*) SCREEN + (byte) main::i#2) ← (byte) 'x' -- pbuc1_derefidx_vbuxx=vbuc2 
    // The condition-evaluation should increment i - even if when it is not met - x should end up in 0x0408
    lda #'x'
    sta SCREEN,x
    // main::@return
    // }
    // [9] return 
    rts
    // main::@2
  __b2:
    // SCREEN[i] = i
    // [10] *((const byte*) SCREEN + (byte) main::i#2) ← (byte) main::i#2 -- pbuc1_derefidx_vbuxx=vbuxx 
    txa
    sta SCREEN,x
    // [11] (byte) main::i#6 ← (byte) main::i#2 -- vbuaa=vbuxx 
    txa
    // [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
    // [5] phi (byte) main::i#3 = (byte) main::i#6 [phi:main::@2->main::@1#0] -- register_copy 
    jmp __b1
}
  // File Data

