Identified constant variable (byte*) RASTER
Identified constant variable (byte*) SCREEN
Identified constant variable (byte) RATE
Culled Empty Block (label) main::@2
Culled Empty Block (label) main::@12
Culled Empty Block (label) main::@3
Culled Empty Block (label) main::@13
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@7
Culled Empty Block (label) main::@8
Culled Empty Block (label) main::@9
Culled Empty Block (label) main::@11
Culled Empty Block (label) main::@14

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte) ypos#0 ← (byte) 0
  (byte) counter#0 ← (const byte) RATE
  to:@1

(void()) main()
main: scope:[main]  from @1
  (byte) ypos#10 ← phi( @1/(byte) ypos#9 )
  (byte) counter#11 ← phi( @1/(byte) counter#10 )
  to:main::@1
main::@1: scope:[main]  from main main::@10 main::@6
  (byte) ypos#8 ← phi( main/(byte) ypos#10 main::@10/(byte) ypos#1 main::@6/(byte) ypos#7 )
  (byte) counter#9 ← phi( main/(byte) counter#11 main::@10/(byte) counter#2 main::@6/(byte) counter#1 )
  if(true) goto main::@4
  to:main::@return
main::@4: scope:[main]  from main::@1 main::@4
  (byte) ypos#11 ← phi( main::@1/(byte) ypos#8 main::@4/(byte) ypos#11 )
  (byte) counter#8 ← phi( main::@1/(byte) counter#9 main::@4/(byte) counter#8 )
  (bool~) main::$0 ← *((const byte*) RASTER) != (number) $ff
  if((bool~) main::$0) goto main::@4
  to:main::@6
main::@6: scope:[main]  from main::@4
  (byte) ypos#7 ← phi( main::@4/(byte) ypos#11 )
  (byte) counter#5 ← phi( main::@4/(byte) counter#8 )
  (byte) counter#1 ← -- (byte) counter#5
  (bool~) main::$1 ← (byte) counter#1 == (number) 0
  (bool~) main::$2 ← ! (bool~) main::$1
  if((bool~) main::$2) goto main::@1
  to:main::@10
main::@10: scope:[main]  from main::@6
  (byte) ypos#4 ← phi( main::@6/(byte) ypos#7 )
  (byte) counter#2 ← (const byte) RATE
  (byte) ypos#1 ← ++ (byte) ypos#4
  *((const byte*) SCREEN) ← (byte) ypos#1
  to:main::@1
main::@return: scope:[main]  from main::@1
  (byte) ypos#5 ← phi( main::@1/(byte) ypos#8 )
  (byte) counter#6 ← phi( main::@1/(byte) counter#9 )
  (byte) counter#3 ← (byte) counter#6
  (byte) ypos#2 ← (byte) ypos#5
  return 
  to:@return
@1: scope:[]  from @begin
  (byte) ypos#9 ← phi( @begin/(byte) ypos#0 )
  (byte) counter#10 ← phi( @begin/(byte) counter#0 )
  call main 
  to:@2
@2: scope:[]  from @1
  (byte) ypos#6 ← phi( @1/(byte) ypos#2 )
  (byte) counter#7 ← phi( @1/(byte) counter#3 )
  (byte) counter#4 ← (byte) counter#7
  (byte) ypos#3 ← (byte) ypos#6
  to:@end
@end: scope:[]  from @2

SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(const byte*) RASTER = (byte*)(number) $d012
(const byte) RATE = (byte) $32
(const byte*) SCREEN = (byte*)(number) $400
(byte) counter
(byte) counter#0
(byte) counter#1
(byte) counter#10
(byte) counter#11
(byte) counter#2
(byte) counter#3
(byte) counter#4
(byte) counter#5
(byte) counter#6
(byte) counter#7
(byte) counter#8
(byte) counter#9
(void()) main()
(bool~) main::$0
(bool~) main::$1
(bool~) main::$2
(label) main::@1
(label) main::@10
(label) main::@4
(label) main::@6
(label) main::@return
(byte) ypos
(byte) ypos#0
(byte) ypos#1
(byte) ypos#10
(byte) ypos#11
(byte) ypos#2
(byte) ypos#3
(byte) ypos#4
(byte) ypos#5
(byte) ypos#6
(byte) ypos#7
(byte) ypos#8
(byte) ypos#9

Adding number conversion cast (unumber) $ff in (bool~) main::$0 ← *((const byte*) RASTER) != (number) $ff
Adding number conversion cast (unumber) 0 in (bool~) main::$1 ← (byte) counter#1 == (number) 0
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 53266
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast $ff
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $ff
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inversing boolean not [11] (bool~) main::$2 ← (byte) counter#1 != (byte) 0 from [10] (bool~) main::$1 ← (byte) counter#1 == (byte) 0
Successful SSA optimization Pass2UnaryNotSimplification
Alias (byte) counter#5 = (byte) counter#8 
Alias (byte) ypos#11 = (byte) ypos#7 (byte) ypos#4 
Alias (byte) counter#3 = (byte) counter#6 (byte) counter#9 
Alias (byte) ypos#2 = (byte) ypos#5 (byte) ypos#8 
Alias (byte) counter#0 = (byte) counter#10 
Alias (byte) ypos#0 = (byte) ypos#9 
Alias (byte) counter#4 = (byte) counter#7 
Alias (byte) ypos#3 = (byte) ypos#6 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) counter#11 (byte) counter#0
Identical Phi Values (byte) ypos#10 (byte) ypos#0
Identical Phi Values (byte) counter#5 (byte) counter#3
Identical Phi Values (byte) ypos#11 (byte) ypos#2
Identical Phi Values (byte) counter#4 (byte) counter#3
Identical Phi Values (byte) ypos#3 (byte) ypos#2
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$0 [7] if(*((const byte*) RASTER)!=(byte) $ff) goto main::@4
Simple Condition (bool~) main::$2 [12] if((byte) counter#1!=(byte) 0) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) ypos#0 = 0
Constant (const byte) counter#0 = RATE
Constant (const byte) counter#2 = RATE
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [4] if(true) goto main::@4
Successful SSA optimization Pass2ConstantIfs
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Inlining constant with var siblings (const byte) ypos#0
Inlining constant with var siblings (const byte) counter#0
Inlining constant with var siblings (const byte) counter#2
Constant inlined counter#0 = (const byte) RATE
Constant inlined ypos#0 = (byte) 0
Constant inlined counter#2 = (const byte) RATE
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@15(between main::@6 and main::@1)
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 [12] ypos#12 ← ypos#1
Coalesced [13] counter#12 ← counter#1
Coalesced (already) [14] ypos#13 ← ypos#2
Coalesced down to 2 phi equivalence classes
Culled Empty Block (label) @2
Culled Empty Block (label) main::@15
Renumbering block main::@4 to main::@2
Renumbering block main::@6 to main::@3
Renumbering block main::@10 to main::@4
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::@3 main::@4
  [5] (byte) ypos#2 ← phi( main/(byte) 0 main::@4/(byte) ypos#1 main::@3/(byte) ypos#2 )
  [5] (byte) counter#3 ← phi( main/(const byte) RATE main::@4/(const byte) RATE main::@3/(byte) counter#1 )
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@2
  [6] if(*((const byte*) RASTER)!=(byte) $ff) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@2
  [7] (byte) counter#1 ← -- (byte) counter#3
  [8] if((byte) counter#1!=(byte) 0) goto main::@1
  to:main::@4
main::@4: scope:[main]  from main::@3
  [9] (byte) ypos#1 ← ++ (byte) ypos#2
  [10] *((const byte*) SCREEN) ← (byte) ypos#1
  to:main::@1


VARIABLE REGISTER WEIGHTS
(byte) counter
(byte) counter#1 151.5
(byte) counter#3 101.0
(void()) main()
(byte) ypos
(byte) ypos#1 16.5
(byte) ypos#2 56.0

Initial phi equivalence classes
[ counter#3 counter#1 ]
[ ypos#2 ypos#1 ]
Complete equivalence classes
[ counter#3 counter#1 ]
[ ypos#2 ypos#1 ]
Allocated zp[1]:2 [ counter#3 counter#1 ]
Allocated zp[1]:3 [ ypos#2 ypos#1 ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// NullPointerException using current_movedown_rate in the main loop
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label RASTER = $d012
  .label SCREEN = $400
  .const RATE = $32
  .label counter = 2
  .label ypos = 3
  // @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) ypos#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z ypos
    // [5] phi (byte) counter#3 = (const byte) RATE [phi:main->main::@1#1] -- vbuz1=vbuc1 
    lda #RATE
    sta.z counter
    jmp __b1
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  __b1_from___b3:
    // [5] phi (byte) ypos#2 = (byte) ypos#2 [phi:main::@3->main::@1#0] -- register_copy 
    // [5] phi (byte) counter#3 = (byte) counter#1 [phi:main::@3->main::@1#1] -- register_copy 
    jmp __b1
    // main::@1
  __b1:
    jmp __b2
    // main::@2
  __b2:
    // [6] if(*((const byte*) RASTER)!=(byte) $ff) goto main::@2 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$ff
    cmp RASTER
    bne __b2
    jmp __b3
    // main::@3
  __b3:
    // [7] (byte) counter#1 ← -- (byte) counter#3 -- vbuz1=_dec_vbuz1 
    dec.z counter
    // [8] if((byte) counter#1!=(byte) 0) goto main::@1 -- vbuz1_neq_0_then_la1 
    lda.z counter
    cmp #0
    bne __b1_from___b3
    jmp __b4
    // main::@4
  __b4:
    // [9] (byte) ypos#1 ← ++ (byte) ypos#2 -- vbuz1=_inc_vbuz1 
    inc.z ypos
    // [10] *((const byte*) SCREEN) ← (byte) ypos#1 -- _deref_pbuc1=vbuz1 
    lda.z ypos
    sta SCREEN
    // [5] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
  __b1_from___b4:
    // [5] phi (byte) ypos#2 = (byte) ypos#1 [phi:main::@4->main::@1#0] -- register_copy 
    // [5] phi (byte) counter#3 = (const byte) RATE [phi:main::@4->main::@1#1] -- vbuz1=vbuc1 
    lda #RATE
    sta.z counter
    jmp __b1
}
  // File Data

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] if(*((const byte*) RASTER)!=(byte) $ff) goto main::@2 [ counter#3 ypos#2 ] ( main:2 [ counter#3 ypos#2 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:2 [ counter#3 counter#1 ]
Removing always clobbered register reg byte a as potential for zp[1]:3 [ ypos#2 ypos#1 ]
Statement [6] if(*((const byte*) RASTER)!=(byte) $ff) goto main::@2 [ counter#3 ypos#2 ] ( main:2 [ counter#3 ypos#2 ] ) always clobbers reg byte a 
Potential registers zp[1]:2 [ counter#3 counter#1 ] : zp[1]:2 , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ ypos#2 ypos#1 ] : zp[1]:3 , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [] 252.5: zp[1]:2 [ counter#3 counter#1 ] 72.5: zp[1]:3 [ ypos#2 ypos#1 ] 
Uplift Scope [main] 

Uplifting [] best 14052 combination reg byte y [ counter#3 counter#1 ] reg byte x [ ypos#2 ypos#1 ] 
Uplifting [main] best 14052 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// NullPointerException using current_movedown_rate in the main loop
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label RASTER = $d012
  .label SCREEN = $400
  .const RATE = $32
  // @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) ypos#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // [5] phi (byte) counter#3 = (const byte) RATE [phi:main->main::@1#1] -- vbuyy=vbuc1 
    ldy #RATE
    jmp __b1
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  __b1_from___b3:
    // [5] phi (byte) ypos#2 = (byte) ypos#2 [phi:main::@3->main::@1#0] -- register_copy 
    // [5] phi (byte) counter#3 = (byte) counter#1 [phi:main::@3->main::@1#1] -- register_copy 
    jmp __b1
    // main::@1
  __b1:
    jmp __b2
    // main::@2
  __b2:
    // [6] if(*((const byte*) RASTER)!=(byte) $ff) goto main::@2 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$ff
    cmp RASTER
    bne __b2
    jmp __b3
    // main::@3
  __b3:
    // [7] (byte) counter#1 ← -- (byte) counter#3 -- vbuyy=_dec_vbuyy 
    dey
    // [8] if((byte) counter#1!=(byte) 0) goto main::@1 -- vbuyy_neq_0_then_la1 
    cpy #0
    bne __b1_from___b3
    jmp __b4
    // main::@4
  __b4:
    // [9] (byte) ypos#1 ← ++ (byte) ypos#2 -- vbuxx=_inc_vbuxx 
    inx
    // [10] *((const byte*) SCREEN) ← (byte) ypos#1 -- _deref_pbuc1=vbuxx 
    stx SCREEN
    // [5] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
  __b1_from___b4:
    // [5] phi (byte) ypos#2 = (byte) ypos#1 [phi:main::@4->main::@1#0] -- register_copy 
    // [5] phi (byte) counter#3 = (const byte) RATE [phi:main::@4->main::@1#1] -- vbuyy=vbuc1 
    ldy #RATE
    jmp __b1
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __b3
Removing instruction jmp __b4
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __bbegin with __b1
Replacing label __b1 with __b2
Replacing label __b1_from___b3 with __b2
Replacing label __b1 with __b2
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Removing instruction __b1_from___b3:
Removing instruction __b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __b1_from_main:
Removing instruction __b3:
Removing instruction __b4:
Removing instruction __b1_from___b4:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction jmp __b2
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(const byte*) RASTER = (byte*) 53266
(const byte) RATE = (byte) $32
(const byte*) SCREEN = (byte*) 1024
(byte) counter
(byte) counter#1 reg byte y 151.5
(byte) counter#3 reg byte y 101.0
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(byte) ypos
(byte) ypos#1 reg byte x 16.5
(byte) ypos#2 reg byte x 56.0

reg byte y [ counter#3 counter#1 ]
reg byte x [ ypos#2 ypos#1 ]


FINAL ASSEMBLER
Score: 10110

  // File Comments
// NullPointerException using current_movedown_rate in the main loop
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // Global Constants & labels
  .label RASTER = $d012
  .label SCREEN = $400
  .const RATE = $32
  // @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) ypos#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // [5] phi (byte) counter#3 = (const byte) RATE [phi:main->main::@1#1] -- vbuyy=vbuc1 
    ldy #RATE
    // [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
    // [5] phi (byte) ypos#2 = (byte) ypos#2 [phi:main::@3->main::@1#0] -- register_copy 
    // [5] phi (byte) counter#3 = (byte) counter#1 [phi:main::@3->main::@1#1] -- register_copy 
    // main::@1
    // main::@2
  __b2:
    // while(*RASTER!=$ff)
    // [6] if(*((const byte*) RASTER)!=(byte) $ff) goto main::@2 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$ff
    cmp RASTER
    bne __b2
    // main::@3
    // if(--counter==0)
    // [7] (byte) counter#1 ← -- (byte) counter#3 -- vbuyy=_dec_vbuyy 
    dey
    // [8] if((byte) counter#1!=(byte) 0) goto main::@1 -- vbuyy_neq_0_then_la1 
    cpy #0
    bne __b2
    // main::@4
    // ypos++;
    // [9] (byte) ypos#1 ← ++ (byte) ypos#2 -- vbuxx=_inc_vbuxx 
    inx
    // *SCREEN = ypos
    // [10] *((const byte*) SCREEN) ← (byte) ypos#1 -- _deref_pbuc1=vbuxx 
    stx SCREEN
    // [5] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
    // [5] phi (byte) ypos#2 = (byte) ypos#1 [phi:main::@4->main::@1#0] -- register_copy 
    // [5] phi (byte) counter#3 = (const byte) RATE [phi:main::@4->main::@1#1] -- vbuyy=vbuc1 
    ldy #RATE
    jmp __b2
}
  // File Data

