Inlined call call __init

CONTROL FLOW GRAPH SSA

void main()
main: scope:[main]  from __start::@1
  ypos#12 = phi( __start::@1/ypos#11 )
  counter#13 = phi( __start::@1/counter#12 )
  to:main::@1
main::@1: scope:[main]  from main main::@3 main::@4
  ypos#10 = phi( main/ypos#12, main::@3/ypos#9, main::@4/ypos#0 )
  counter#11 = phi( main/counter#13, main::@3/counter#0, main::@4/counter#1 )
  if(true) goto main::@2
  to:main::@return
main::@2: scope:[main]  from main::@1 main::@2
  ypos#13 = phi( main::@1/ypos#10, main::@2/ypos#13 )
  counter#10 = phi( main::@1/counter#11, main::@2/counter#10 )
  main::$0 = *RASTER != $ff
  if(main::$0) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@2
  ypos#9 = phi( main::@2/ypos#13 )
  counter#6 = phi( main::@2/counter#10 )
  counter#0 = -- counter#6
  main::$1 = counter#0 == 0
  main::$2 = ! main::$1
  if(main::$2) goto main::@1
  to:main::@4
main::@4: scope:[main]  from main::@3
  ypos#5 = phi( main::@3/ypos#9 )
  counter#1 = RATE
  ypos#0 = ++ ypos#5
  *SCREEN = ypos#0
  to:main::@1
main::@return: scope:[main]  from main::@1
  ypos#6 = phi( main::@1/ypos#10 )
  counter#7 = phi( main::@1/counter#11 )
  counter#2 = counter#7
  ypos#1 = ypos#6
  return 
  to:@return

void __start()
__start: scope:[__start]  from
  to:__start::__init1
__start::__init1: scope:[__start]  from __start
  ypos#2 = 0
  counter#3 = RATE
  to:__start::@1
__start::@1: scope:[__start]  from __start::__init1
  ypos#11 = phi( __start::__init1/ypos#2 )
  counter#12 = phi( __start::__init1/counter#3 )
  call main
  to:__start::@2
__start::@2: scope:[__start]  from __start::@1
  ypos#7 = phi( __start::@1/ypos#1 )
  counter#8 = phi( __start::@1/counter#2 )
  counter#4 = counter#8
  ypos#3 = ypos#7
  to:__start::@return
__start::@return: scope:[__start]  from __start::@2
  counter#9 = phi( __start::@2/counter#4 )
  ypos#8 = phi( __start::@2/ypos#3 )
  ypos#4 = ypos#8
  counter#5 = counter#9
  return 
  to:@return

SYMBOL TABLE SSA
__constant char *RASTER = (char *)$d012
__constant char RATE = $32
__constant char *SCREEN = (char *)$400
void __start()
char counter
char counter#0
char counter#1
char counter#10
char counter#11
char counter#12
char counter#13
char counter#2
char counter#3
char counter#4
char counter#5
char counter#6
char counter#7
char counter#8
char counter#9
void main()
bool main::$0
bool main::$1
bool main::$2
char ypos
char ypos#0
char ypos#1
char ypos#10
char ypos#11
char ypos#12
char ypos#13
char ypos#2
char ypos#3
char ypos#4
char ypos#5
char ypos#6
char ypos#7
char ypos#8
char ypos#9

Adding number conversion cast (unumber) $ff in main::$0 = *RASTER != $ff
Adding number conversion cast (unumber) 0 in main::$1 = counter#0 == 0
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (char *) 53266
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast $ff
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) $ff
Finalized unsigned number type (char) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inversing boolean not [9] main::$2 = counter#0 != 0 from [8] main::$1 = counter#0 == 0
Successful SSA optimization Pass2UnaryNotSimplification
Alias counter#10 = counter#6 
Alias ypos#13 = ypos#9 ypos#5 
Alias counter#11 = counter#7 counter#2 
Alias ypos#1 = ypos#6 ypos#10 
Alias counter#12 = counter#3 
Alias ypos#11 = ypos#2 
Alias counter#4 = counter#8 counter#9 counter#5 
Alias ypos#3 = ypos#7 ypos#8 ypos#4 
Successful SSA optimization Pass2AliasElimination
Identical Phi Values counter#13 counter#12
Identical Phi Values ypos#12 ypos#11
Identical Phi Values counter#10 counter#11
Identical Phi Values ypos#13 ypos#1
Identical Phi Values counter#4 counter#11
Identical Phi Values ypos#3 ypos#1
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition main::$0 [5] if(*RASTER!=$ff) goto main::@2
Simple Condition main::$2 [8] if(counter#0!=0) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant counter#1 = RATE
Constant ypos#11 = 0
Constant counter#12 = RATE
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [2] if(true) goto main::@2
Successful SSA optimization Pass2ConstantIfs
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::__init1
Removing unused procedure block __start::@1
Removing unused procedure block __start::@2
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Inlining constant with var siblings counter#1
Inlining constant with var siblings ypos#11
Inlining constant with var siblings counter#12
Constant inlined ypos#11 = 0
Constant inlined counter#1 = RATE
Constant inlined counter#12 = RATE
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@5(between main::@3 and main::@1)
Adding NOP phi() at start of main
CALL GRAPH

Created 2 initial phi equivalence classes
Coalesced [7] ypos#15 = ypos#0
Coalesced [8] counter#14 = counter#0
Coalesced (already) [9] ypos#14 = ypos#1
Coalesced down to 2 phi equivalence classes
Culled Empty Block label main::@5
Adding NOP phi() at start of main

FINAL CONTROL FLOW GRAPH

void main()
main: scope:[main]  from
  [0] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@3 main::@4
  [1] ypos#1 = phi( main/0, main::@3/ypos#1, main::@4/ypos#0 )
  [1] counter#11 = phi( main/RATE, main::@3/counter#0, main::@4/RATE )
  to:main::@2
main::@2: scope:[main]  from main::@1 main::@2
  [2] if(*RASTER!=$ff) goto main::@2
  to:main::@3
main::@3: scope:[main]  from main::@2
  [3] counter#0 = -- counter#11
  [4] if(counter#0!=0) goto main::@1
  to:main::@4
main::@4: scope:[main]  from main::@3
  [5] ypos#0 = ++ ypos#1
  [6] *SCREEN = ypos#0
  to:main::@1


VARIABLE REGISTER WEIGHTS
char counter
char counter#0 // 151.5
char counter#11 // 101.0
void main()
char ypos
char ypos#0 // 16.5
char ypos#1 // 56.0

Initial phi equivalence classes
[ counter#11 counter#0 ]
[ ypos#1 ypos#0 ]
Complete equivalence classes
[ counter#11 counter#0 ]
[ ypos#1 ypos#0 ]
Allocated zp[1]:2 [ counter#11 counter#0 ]
Allocated zp[1]:3 [ ypos#1 ypos#0 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [2] if(*RASTER!=$ff) goto main::@2 [ counter#11 ypos#1 ] (  [ counter#11 ypos#1 ] { }  ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:2 [ counter#11 counter#0 ]
Removing always clobbered register reg byte a as potential for zp[1]:3 [ ypos#1 ypos#0 ]
Statement [2] if(*RASTER!=$ff) goto main::@2 [ counter#11 ypos#1 ] (  [ counter#11 ypos#1 ] { }  ) always clobbers reg byte a 
Potential registers zp[1]:2 [ counter#11 counter#0 ] : zp[1]:2 , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ ypos#1 ypos#0 ] : zp[1]:3 , reg byte x , reg byte y , 

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

Uplifting [] best 14040 combination reg byte y [ counter#11 counter#0 ] reg byte x [ ypos#1 ypos#0 ] 
Uplifting [main] best 14040 combination 

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// NullPointerException using current_movedown_rate in the main loop
  // Upstart
  // Commodore 64 PRG executable file
.file [name="tetris-npe.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
  // Global Constants & labels
  .const RATE = $32
  .label RASTER = $d012
  .label SCREEN = $400
.segment Code
  // main
main: {
    // [1] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    // [1] phi ypos#1 = 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // [1] phi counter#11 = RATE [phi:main->main::@1#1] -- vbuyy=vbuc1 
    ldy #RATE
    jmp __b1
    // [1] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
  __b1_from___b3:
    // [1] phi ypos#1 = ypos#1 [phi:main::@3->main::@1#0] -- register_copy 
    // [1] phi counter#11 = counter#0 [phi:main::@3->main::@1#1] -- register_copy 
    jmp __b1
    // main::@1
  __b1:
    jmp __b2
    // main::@2
  __b2:
    // [2] if(*RASTER!=$ff) goto main::@2 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$ff
    cmp RASTER
    bne __b2
    jmp __b3
    // main::@3
  __b3:
    // [3] counter#0 = -- counter#11 -- vbuyy=_dec_vbuyy 
    dey
    // [4] if(counter#0!=0) goto main::@1 -- vbuyy_neq_0_then_la1 
    cpy #0
    bne __b1_from___b3
    jmp __b4
    // main::@4
  __b4:
    // [5] ypos#0 = ++ ypos#1 -- vbuxx=_inc_vbuxx 
    inx
    // [6] *SCREEN = ypos#0 -- _deref_pbuc1=vbuxx 
    stx SCREEN
    // [1] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
  __b1_from___b4:
    // [1] phi ypos#1 = ypos#0 [phi:main::@4->main::@1#0] -- register_copy 
    // [1] phi counter#11 = RATE [phi:main::@4->main::@1#1] -- vbuyy=vbuc1 
    ldy #RATE
    jmp __b1
}
  // File Data

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __b3
Removing instruction jmp __b4
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __b1 with __b2
Replacing label __b1_from___b3 with __b2
Replacing label __b1 with __b2
Removing instruction __b1_from___b3:
Removing instruction __b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1_from_main:
Removing instruction __b3:
Removing instruction __b4:
Removing instruction __b1_from___b4:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jmp __b2
Succesful ASM optimization Pass5NextJumpElimination

FINAL SYMBOL TABLE
__constant char *RASTER = (char *) 53266
__constant char RATE = $32
__constant char *SCREEN = (char *) 1024
char counter
char counter#0 // reg byte y 151.5
char counter#11 // reg byte y 101.0
void main()
char ypos
char ypos#0 // reg byte x 16.5
char ypos#1 // reg byte x 56.0

reg byte y [ counter#11 counter#0 ]
reg byte x [ ypos#1 ypos#0 ]


FINAL ASSEMBLER
Score: 10110

  // File Comments
// NullPointerException using current_movedown_rate in the main loop
  // Upstart
  // Commodore 64 PRG executable file
.file [name="tetris-npe.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
  // Global Constants & labels
  .const RATE = $32
  .label RASTER = $d012
  .label SCREEN = $400
.segment Code
  // main
main: {
    // [1] phi from main to main::@1 [phi:main->main::@1]
    // [1] phi ypos#1 = 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // [1] phi counter#11 = RATE [phi:main->main::@1#1] -- vbuyy=vbuc1 
    ldy #RATE
    // [1] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
    // [1] phi ypos#1 = ypos#1 [phi:main::@3->main::@1#0] -- register_copy 
    // [1] phi counter#11 = counter#0 [phi:main::@3->main::@1#1] -- register_copy 
    // main::@1
    // main::@2
  __b2:
    // while(*RASTER!=$ff)
    // [2] if(*RASTER!=$ff) goto main::@2 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$ff
    cmp RASTER
    bne __b2
    // main::@3
    // if(--counter==0)
    // [3] counter#0 = -- counter#11 -- vbuyy=_dec_vbuyy 
    dey
    // [4] if(counter#0!=0) goto main::@1 -- vbuyy_neq_0_then_la1 
    cpy #0
    bne __b2
    // main::@4
    // ypos++;
    // [5] ypos#0 = ++ ypos#1 -- vbuxx=_inc_vbuxx 
    inx
    // *SCREEN = ypos
    // [6] *SCREEN = ypos#0 -- _deref_pbuc1=vbuxx 
    stx SCREEN
    // [1] phi from main::@4 to main::@1 [phi:main::@4->main::@1]
    // [1] phi ypos#1 = ypos#0 [phi:main::@4->main::@1#0] -- register_copy 
    // [1] phi counter#11 = RATE [phi:main::@4->main::@1#1] -- vbuyy=vbuc1 
    ldy #RATE
    jmp __b2
}
  // File Data

