Culled Empty Block (label) main::@2

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) screen#0 ← ((byte*)) (number) $400
  to:@1
main: scope:[main]  from @1
  (byte) main::j#0 ← (byte) 0
  to:main::@1
main::@1: scope:[main]  from main main::@1
  (byte) main::j#2 ← phi( main/(byte) main::j#0 main::@1/(byte) main::j#1 )
  (number~) main::$0 ← (number) $28 * (byte) main::j#2
  (byte*~) main::$1 ← (byte*) screen#0 + (number~) main::$0
  (byte*~) main::$2 ← (byte*~) main::$1 + (number) $27
  *((byte*~) main::$2) ← (number) 0
  (number~) main::$3 ← (number) $28 * (byte) main::j#2
  (number~) main::$4 ← (number~) main::$3 + (number) $25
  *((byte*) screen#0 + (number~) main::$4) ← (number) 0
  (byte) main::j#1 ← (byte) main::j#2 + rangenext(0,1)
  (bool~) main::$5 ← (byte) main::j#1 != rangelast(0,1)
  unroll if((bool~) main::$5) goto main::@1
  to:main::@return
main::@return: scope:[main]  from main::@1
  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
(void()) main()
(number~) main::$0
(byte*~) main::$1
(byte*~) main::$2
(number~) main::$3
(number~) main::$4
(bool~) main::$5
(label) main::@1
(label) main::@return
(byte) main::j
(byte) main::j#0
(byte) main::j#1
(byte) main::j#2
(byte*) screen
(byte*) screen#0

Adding number conversion cast (unumber) $28 in (number~) main::$0 ← (number) $28 * (byte) main::j#2
Adding number conversion cast (unumber) main::$0 in (number~) main::$0 ← (unumber)(number) $28 * (byte) main::j#2
Adding number conversion cast (unumber) $27 in (byte*~) main::$2 ← (byte*~) main::$1 + (number) $27
Adding number conversion cast (unumber) 0 in *((byte*~) main::$2) ← (number) 0
Adding number conversion cast (unumber) $28 in (number~) main::$3 ← (number) $28 * (byte) main::j#2
Adding number conversion cast (unumber) main::$3 in (number~) main::$3 ← (unumber)(number) $28 * (byte) main::j#2
Adding number conversion cast (unumber) $25 in (number~) main::$4 ← (unumber~) main::$3 + (number) $25
Adding number conversion cast (unumber) main::$4 in (number~) main::$4 ← (unumber~) main::$3 + (unumber)(number) $25
Adding number conversion cast (unumber) 0 in *((byte*) screen#0 + (unumber~) main::$4) ← (number) 0
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) screen#0 ← (byte*)(number) $400
Inlining cast *((byte*~) main::$2) ← (unumber)(number) 0
Inlining cast *((byte*) screen#0 + (unumber~) main::$4) ← (unumber)(number) 0
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast $28
Simplifying constant integer cast $27
Simplifying constant integer cast 0
Simplifying constant integer cast $28
Simplifying constant integer cast $25
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $28
Finalized unsigned number type (byte) $27
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $28
Finalized unsigned number type (byte) $25
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) main::$0 ← (byte) $28 * (byte) main::j#2
Inferred type updated to byte in (unumber~) main::$3 ← (byte) $28 * (byte) main::j#2
Inferred type updated to byte in (unumber~) main::$4 ← (byte~) main::$3 + (byte) $25
Identified duplicate assignment right side [7] (byte~) main::$3 ← (byte) $28 * (byte) main::j#2
Successful SSA optimization Pass2DuplicateRValueIdentification
Simple Condition (bool~) main::$5 [12] unroll if((byte) main::j#1!=rangelast(0,1)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) screen#0 = (byte*) 1024
Constant (const byte) main::j#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Resolved ranged next value [10] main::j#1 ← ++ main::j#2 to ++
Resolved ranged comparison value [12] unroll if(main::j#1!=rangelast(0,1)) goto main::@1 to (number) 2
Converting *(pointer+n) to pointer[n] [6] *((byte*~) main::$2) ← (byte) 0  -- *(main::$1 + $27)
Successful SSA optimization Pass2InlineDerefIdx
Eliminating unused variable (byte*~) main::$2 and assignment [3] (byte*~) main::$2 ← (byte*~) main::$1 + (byte) $27
Successful SSA optimization PassNEliminateUnusedVars
Adding number conversion cast (unumber) 2 in unroll if((byte) main::j#1!=(number) 2) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 2
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte~) main::$3 = (byte~) main::$0 
Successful SSA optimization Pass2AliasElimination
Unrolling loop Loop head: main::@1 tails: main::@1 blocks: main::@1 
Successful SSA optimization Pass2LoopUnroll
Identical Phi Values (byte) main::j#2 (const byte) main::j#0
Successful SSA optimization Pass2IdenticalPhiElimination
Negating conditional jump and destination [7] if((byte) main::j#1==(byte) 2) goto main::@return
Successful SSA optimization Pass2ConditionalJumpSequenceImprovement
Constant right-side identified [1] (byte~) main::$3 ← (byte) $28 * (const byte) main::j#0
Constant right-side identified [6] (byte) main::j#1 ← ++ (const byte) main::j#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::$3 = $28*main::j#0
Constant (const byte) main::j#1 = ++main::j#0
Successful SSA optimization Pass2ConstantIdentification
if() condition always false - eliminating [7] if((const byte) main::j#1==(byte) 2) goto main::@return
Successful SSA optimization Pass2ConstantIfs
Simplifying constant evaluating to zero (byte) $28*(const byte) main::j#0 in 
Successful SSA optimization PassNSimplifyConstantZero
Simplifying expression containing zero screen#0 in [2] (byte*~) main::$1 ← (const byte*) screen#0 + (const byte) main::$3
Simplifying expression containing zero $25 in [4] (byte~) main::$4 ← (const byte) main::$3 + (byte) $25
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant (const byte) main::$3
Successful SSA optimization PassNEliminateUnusedVars
Constant (const byte*) main::$1 = screen#0
Constant (const byte) main::$4 = $25
Successful SSA optimization Pass2ConstantIdentification
Unrolling loop Loop head: main::@1_1 tails: main::@1_1 blocks: main::@1_1 
Successful SSA optimization Pass2LoopUnroll
Identical Phi Values (byte) main::j#3 (const byte) main::j#1
Successful SSA optimization Pass2IdenticalPhiElimination
Negating conditional jump and destination [10] if((byte) main::j#4==(byte) 2) goto main::@return
Successful SSA optimization Pass2ConditionalJumpSequenceImprovement
Constant right-side identified [4] (byte~) main::$6 ← (byte) $28 * (const byte) main::j#1
Constant right-side identified [9] (byte) main::j#4 ← ++ (const byte) main::j#1
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::$6 = $28*main::j#1
Constant (const byte) main::j#4 = ++main::j#1
Successful SSA optimization Pass2ConstantIdentification
Removing PHI-reference to removed block (main::@1_1) in block main::@1_2
if() condition always true - replacing block destination [10] if((const byte) main::j#4==(byte) 2) goto main::@return
Successful SSA optimization Pass2ConstantIfs
Eliminating unused constant (const byte) main::j#4
Successful SSA optimization PassNEliminateUnusedVars
Eliminating variable (byte) main::j#5 from unused block main::@1_2
Eliminating variable (byte~) main::$9 from unused block main::@1_2
Eliminating variable (byte*~) main::$10 from unused block main::@1_2
Eliminating variable (byte~) main::$11 from unused block main::@1_2
Eliminating variable (byte) main::j#6 from unused block main::@1_2
Removing unused block main::@1_2
Successful SSA optimization Pass2EliminateUnusedBlocks
Constant right-side identified [3] (byte*~) main::$7 ← (const byte*) screen#0 + (const byte) main::$6
Constant right-side identified [5] (byte~) main::$8 ← (const byte) main::$6 + (byte) $25
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) main::$7 = screen#0+main::$6
Constant (const byte) main::$8 = main::$6+$25
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with different constant siblings (const byte) main::j#0
Inlining constant with different constant siblings (const byte) main::j#1
Constant inlined main::$1 = (const byte*) screen#0
Constant inlined main::$6 = (byte) $28*++(byte) 0
Constant inlined main::j#1 = ++(byte) 0
Constant inlined main::$4 = (byte) $25
Constant inlined main::j#0 = (byte) 0
Constant inlined main::$7 = (const byte*) screen#0+(byte) $28*++(byte) 0
Constant inlined main::$8 = (byte) $28*++(byte) 0+(byte) $25
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(screen#0+$27)
Consolidated array index constant in *(screen#0+$25)
Consolidated array index constant in *(screen#0+$28*++0+$27)
Consolidated array index constant in *(screen#0+$28*++0+$25)
Successful SSA optimization Pass2ConstantAdditionElimination
Simplifying constant integer increment ++0
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
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
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) $27) ← (byte) 0
  [6] *((const byte*) screen#0+(byte) $25) ← (byte) 0
  to:main::@1_1
main::@1_1: scope:[main]  from main::@1
  [7] *((const byte*) screen#0+(byte) $28*(byte) 1+(byte) $27) ← (byte) 0
  [8] *((const byte*) screen#0+(byte) $28*(byte) 1+(byte) $25) ← (byte) 0
  to:main::@return
main::@return: scope:[main]  from main::@1_1
  [9] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(void()) main()
(byte) main::j
(byte*) screen

Initial phi equivalence classes
Complete equivalence classes

INITIAL ASM
Target platform is c64basic
  // File Comments
  // 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) $27) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta screen+$27
    // [6] *((const byte*) screen#0+(byte) $25) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta screen+$25
    jmp b1_1
    // main::@1_1
  b1_1:
    // [7] *((const byte*) screen#0+(byte) $28*(byte) 1+(byte) $27) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta screen+$28*1+$27
    // [8] *((const byte*) screen#0+(byte) $28*(byte) 1+(byte) $25) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta screen+$28*1+$25
    jmp breturn
    // main::@return
  breturn:
    // [9] return 
    rts
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [5] *((const byte*) screen#0+(byte) $27) ← (byte) 0 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [6] *((const byte*) screen#0+(byte) $25) ← (byte) 0 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [7] *((const byte*) screen#0+(byte) $28*(byte) 1+(byte) $27) ← (byte) 0 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [8] *((const byte*) screen#0+(byte) $28*(byte) 1+(byte) $25) ← (byte) 0 [ ] ( main:2 [ ] ) always clobbers reg byte a 

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

Uplifting [main] best 78 combination 
Uplifting [] best 78 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
  // 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) $27) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta screen+$27
    // [6] *((const byte*) screen#0+(byte) $25) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta screen+$25
    jmp b1_1
    // main::@1_1
  b1_1:
    // [7] *((const byte*) screen#0+(byte) $28*(byte) 1+(byte) $27) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta screen+$28*1+$27
    // [8] *((const byte*) screen#0+(byte) $28*(byte) 1+(byte) $25) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta screen+$28*1+$25
    jmp breturn
    // main::@return
  breturn:
    // [9] return 
    rts
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b1_1
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda #0
Removing instruction lda #0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
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 b1_1:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction lda #0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(label) main::@1
(label) main::@1_1
(label) main::@return
(byte) main::j
(byte*) screen
(const byte*) screen#0 screen = (byte*) 1024



FINAL ASSEMBLER
Score: 24

  // File Comments
  // 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+40*j+39) = 0
    // [5] *((const byte*) screen#0+(byte) $27) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta screen+$27
    // screen[40*j+37] = 0
    // [6] *((const byte*) screen#0+(byte) $25) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    sta screen+$25
    // main::@1_1
    // *(screen+40*j+39) = 0
    // [7] *((const byte*) screen#0+(byte) $28*(byte) 1+(byte) $27) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    sta screen+$28*1+$27
    // screen[40*j+37] = 0
    // [8] *((const byte*) screen#0+(byte) $28*(byte) 1+(byte) $25) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    sta screen+$28*1+$25
    // main::@return
    // }
    // [9] return 
    rts
}
  // File Data

