Culled Empty Block (label) main::@6
Culled Empty Block (label) main::@7
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@9
Culled Empty Block (label) main::@10

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@1

(void()) main()
main: scope:[main]  from @1
  (byte) main::i#0 ← (byte) $64
  (byte) main::s#0 ← (byte) 0
  to:main::@1
main::@1: scope:[main]  from main main::@4 main::@8
  (byte) main::s#6 ← phi( main/(byte) main::s#0 main::@4/(byte) main::s#1 main::@8/(byte) main::s#2 )
  (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@4/(byte) main::i#4 main::@8/(byte) main::i#5 )
  (byte) main::i#1 ← -- (byte) main::i#2
  (bool~) main::$0 ← (byte) main::i#1 > (number) 0
  if((bool~) main::$0) goto main::@2
  to:main::@3
main::@2: scope:[main]  from main::@1
  (byte) main::s#7 ← phi( main::@1/(byte) main::s#6 )
  (byte) main::i#3 ← phi( main::@1/(byte) main::i#1 )
  (bool~) main::$1 ← (byte) main::i#3 > (number) $32
  if((bool~) main::$1) goto main::@4
  to:main::@8
main::@3: scope:[main]  from main::@1
  (byte) main::s#3 ← phi( main::@1/(byte) main::s#6 )
  *((const byte*) main::SCREEN) ← (byte) main::s#3
  to:main::@return
main::@4: scope:[main]  from main::@2
  (byte) main::i#4 ← phi( main::@2/(byte) main::i#3 )
  (byte) main::s#4 ← phi( main::@2/(byte) main::s#7 )
  (byte) main::s#1 ← ++ (byte) main::s#4
  to:main::@1
main::@8: scope:[main]  from main::@2
  (byte) main::i#5 ← phi( main::@2/(byte) main::i#3 )
  (byte) main::s#5 ← phi( main::@2/(byte) main::s#7 )
  (byte) main::s#2 ← -- (byte) main::s#5
  to:main::@1
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
(void()) main()
(bool~) main::$0
(bool~) main::$1
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@8
(label) main::@return
(const byte*) main::SCREEN = (byte*)(number) $400
(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
(byte) main::s
(byte) main::s#0
(byte) main::s#1
(byte) main::s#2
(byte) main::s#3
(byte) main::s#4
(byte) main::s#5
(byte) main::s#6
(byte) main::s#7

Adding number conversion cast (unumber) 0 in (bool~) main::$0 ← (byte) main::i#1 > (number) 0
Adding number conversion cast (unumber) $32 in (bool~) main::$1 ← (byte) main::i#3 > (number) $32
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast $32
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $32
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte) main::i#1 = (byte) main::i#3 (byte) main::i#4 (byte) main::i#5 
Alias (byte) main::s#3 = (byte) main::s#7 (byte) main::s#6 (byte) main::s#4 (byte) main::s#5 
Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) main::$0 [5] if((byte) main::i#1>(byte) 0) goto main::@2
Simple Condition (bool~) main::$1 [7] if((byte) main::i#1>(byte) $32) goto main::@4
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) main::i#0 = $64
Constant (const byte) main::s#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Rewriting conditional comparison [7] if((byte) main::i#1>(byte) $32) goto main::@4
Adding number conversion cast (unumber) $32+1 in if((byte) main::i#1>=(byte) $32+(number) 1) goto main::@4
Adding number conversion cast (unumber) 1 in if((byte) main::i#1>=(unumber)(byte) $32+(number) 1) goto main::@4
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast (byte) $32+(unumber)(number) 1
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inlining constant with var siblings (const byte) main::i#0
Inlining constant with var siblings (const byte) main::s#0
Constant inlined main::i#0 = (byte) $64
Constant inlined main::s#0 = (byte) 0
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 2 initial phi equivalence classes
Coalesced [13] main::i#7 ← main::i#1
Coalesced [14] main::s#9 ← main::s#2
Coalesced (already) [16] main::i#6 ← main::i#1
Coalesced [17] main::s#8 ← main::s#1
Coalesced down to 2 phi equivalence classes
Culled Empty Block (label) @2
Renumbering block main::@8 to main::@5
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::@4 main::@5
  [5] (byte) main::s#3 ← phi( main/(byte) 0 main::@4/(byte) main::s#1 main::@5/(byte) main::s#2 )
  [5] (byte) main::i#2 ← phi( main/(byte) $64 main::@4/(byte) main::i#1 main::@5/(byte) main::i#1 )
  [6] (byte) main::i#1 ← -- (byte) main::i#2
  [7] if((byte) main::i#1>(byte) 0) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@1
  [8] *((const byte*) main::SCREEN) ← (byte) main::s#3
  to:main::@return
main::@return: scope:[main]  from main::@3
  [9] return 
  to:@return
main::@2: scope:[main]  from main::@1
  [10] if((byte) main::i#1>=(byte) $32+(byte) 1) goto main::@4
  to:main::@5
main::@5: scope:[main]  from main::@2
  [11] (byte) main::s#2 ← -- (byte) main::s#3
  to:main::@1
main::@4: scope:[main]  from main::@2
  [12] (byte) main::s#1 ← ++ (byte) main::s#3
  to:main::@1


VARIABLE REGISTER WEIGHTS
(void()) main()
(byte) main::i
(byte) main::i#1 11.0
(byte) main::i#2 33.0
(byte) main::s
(byte) main::s#1 22.0
(byte) main::s#2 22.0
(byte) main::s#3 11.5

Initial phi equivalence classes
[ main::i#2 main::i#1 ]
[ main::s#3 main::s#1 main::s#2 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ main::s#3 main::s#1 main::s#2 ]
Allocated zp[1]:2 [ main::i#2 main::i#1 ]
Allocated zp[1]:3 [ main::s#3 main::s#1 main::s#2 ]

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: {
    .label SCREEN = $400
    .label i = 2
    .label s = 3
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (byte) main::s#3 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z s
    // [5] phi (byte) main::i#2 = (byte) $64 [phi:main->main::@1#1] -- vbuz1=vbuc1 
    lda #$64
    sta.z i
    jmp __b1
    // main::@1
  __b1:
    // [6] (byte) main::i#1 ← -- (byte) main::i#2 -- vbuz1=_dec_vbuz1 
    dec.z i
    // [7] if((byte) main::i#1>(byte) 0) goto main::@2 -- vbuz1_gt_0_then_la1 
    lda.z i
    bne __b2
    jmp __b3
    // main::@3
  __b3:
    // [8] *((const byte*) main::SCREEN) ← (byte) main::s#3 -- _deref_pbuc1=vbuz1 
    lda.z s
    sta SCREEN
    jmp __breturn
    // main::@return
  __breturn:
    // [9] return 
    rts
    // main::@2
  __b2:
    // [10] if((byte) main::i#1>=(byte) $32+(byte) 1) goto main::@4 -- vbuz1_ge_vbuc1_then_la1 
    lda.z i
    cmp #$32+1
    bcs __b4
    jmp __b5
    // main::@5
  __b5:
    // [11] (byte) main::s#2 ← -- (byte) main::s#3 -- vbuz1=_dec_vbuz1 
    dec.z s
    // [5] phi from main::@4 main::@5 to main::@1 [phi:main::@4/main::@5->main::@1]
  __b1_from___b4:
  __b1_from___b5:
    // [5] phi (byte) main::s#3 = (byte) main::s#1 [phi:main::@4/main::@5->main::@1#0] -- register_copy 
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4/main::@5->main::@1#1] -- register_copy 
    jmp __b1
    // main::@4
  __b4:
    // [12] (byte) main::s#1 ← ++ (byte) main::s#3 -- vbuz1=_inc_vbuz1 
    inc.z s
    jmp __b1_from___b4
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ main::s#3 main::s#1 main::s#2 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 55.5: zp[1]:3 [ main::s#3 main::s#1 main::s#2 ] 44: zp[1]:2 [ main::i#2 main::i#1 ] 
Uplift Scope [] 

Uplifting [main] best 365 combination reg byte y [ main::s#3 main::s#1 main::s#2 ] reg byte x [ main::i#2 main::i#1 ] 
Uplifting [] best 365 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: {
    .label SCREEN = $400
    // [5] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [5] phi (byte) main::s#3 = (byte) 0 [phi:main->main::@1#0] -- vbuyy=vbuc1 
    ldy #0
    // [5] phi (byte) main::i#2 = (byte) $64 [phi:main->main::@1#1] -- vbuxx=vbuc1 
    ldx #$64
    jmp __b1
    // main::@1
  __b1:
    // [6] (byte) main::i#1 ← -- (byte) main::i#2 -- vbuxx=_dec_vbuxx 
    dex
    // [7] if((byte) main::i#1>(byte) 0) goto main::@2 -- vbuxx_gt_0_then_la1 
    cpx #0
    bne __b2
    jmp __b3
    // main::@3
  __b3:
    // [8] *((const byte*) main::SCREEN) ← (byte) main::s#3 -- _deref_pbuc1=vbuyy 
    sty SCREEN
    jmp __breturn
    // main::@return
  __breturn:
    // [9] return 
    rts
    // main::@2
  __b2:
    // [10] if((byte) main::i#1>=(byte) $32+(byte) 1) goto main::@4 -- vbuxx_ge_vbuc1_then_la1 
    cpx #$32+1
    bcs __b4
    jmp __b5
    // main::@5
  __b5:
    // [11] (byte) main::s#2 ← -- (byte) main::s#3 -- vbuyy=_dec_vbuyy 
    dey
    // [5] phi from main::@4 main::@5 to main::@1 [phi:main::@4/main::@5->main::@1]
  __b1_from___b4:
  __b1_from___b5:
    // [5] phi (byte) main::s#3 = (byte) main::s#1 [phi:main::@4/main::@5->main::@1#0] -- register_copy 
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4/main::@5->main::@1#1] -- register_copy 
    jmp __b1
    // main::@4
  __b4:
    // [12] (byte) main::s#1 ← ++ (byte) main::s#3 -- vbuyy=_inc_vbuyy 
    iny
    jmp __b1_from___b4
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __b3
Removing instruction jmp __breturn
Removing instruction jmp __b5
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __bbegin with __b1
Replacing label __b1_from___b4 with __b1_from___b5
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Removing instruction __b1_from___b4:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __b1_from_main:
Removing instruction __b3:
Removing instruction __breturn:
Removing instruction __b5:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Skipping double jump to __b1 in jmp __b1_from___b5
Succesful ASM optimization Pass5DoubleJumpElimination
Relabelling long label __b1_from___b5 to b1
Succesful ASM optimization Pass5RelabelLongLabels
Removing instruction __b1:
Removing instruction b1:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@return
(const byte*) main::SCREEN = (byte*) 1024
(byte) main::i
(byte) main::i#1 reg byte x 11.0
(byte) main::i#2 reg byte x 33.0
(byte) main::s
(byte) main::s#1 reg byte y 22.0
(byte) main::s#2 reg byte y 22.0
(byte) main::s#3 reg byte y 11.5

reg byte x [ main::i#2 main::i#1 ]
reg byte y [ main::s#3 main::s#1 main::s#2 ]


FINAL ASSEMBLER
Score: 260

  // 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: {
    .label SCREEN = $400
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // [5] phi (byte) main::s#3 = (byte) 0 [phi:main->main::@1#0] -- vbuyy=vbuc1 
    ldy #0
    // [5] phi (byte) main::i#2 = (byte) $64 [phi:main->main::@1#1] -- vbuxx=vbuc1 
    ldx #$64
    // main::@1
  __b1:
    // while(--i>0)
    // [6] (byte) main::i#1 ← -- (byte) main::i#2 -- vbuxx=_dec_vbuxx 
    dex
    // [7] if((byte) main::i#1>(byte) 0) goto main::@2 -- vbuxx_gt_0_then_la1 
    cpx #0
    bne __b2
    // main::@3
    // *SCREEN = s
    // [8] *((const byte*) main::SCREEN) ← (byte) main::s#3 -- _deref_pbuc1=vbuyy 
    sty SCREEN
    // main::@return
    // }
    // [9] return 
    rts
    // main::@2
  __b2:
    // if(i>50)
    // [10] if((byte) main::i#1>=(byte) $32+(byte) 1) goto main::@4 -- vbuxx_ge_vbuc1_then_la1 
    cpx #$32+1
    bcs __b4
    // main::@5
    // s--;
    // [11] (byte) main::s#2 ← -- (byte) main::s#3 -- vbuyy=_dec_vbuyy 
    dey
    // [5] phi from main::@4 main::@5 to main::@1 [phi:main::@4/main::@5->main::@1]
    // [5] phi (byte) main::s#3 = (byte) main::s#1 [phi:main::@4/main::@5->main::@1#0] -- register_copy 
    // [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@4/main::@5->main::@1#1] -- register_copy 
    jmp __b1
    // main::@4
  __b4:
    // s++;
    // [12] (byte) main::s#1 ← ++ (byte) main::s#3 -- vbuyy=_inc_vbuyy 
    iny
    jmp __b1
}
  // File Data

