Resolved forward reference plex_irq to interrupt(KERNEL_MIN)(void()) plex_irq()
Fixing pointer array-indexing *((const word*) PLEX_XPOS + (byte) plexShowSprite::xpos_idx)
Fixing pointer array-indexing *((const word*) PLEX_XPOS + (byte) plexShowSprite::xpos_idx)
Fixing pointer array-indexing *((const word*) PLEX_XPOS + (byte) init::sx)
Identified constant variable (byte*) SCREEN
Inlined call (byte~) vicSelectGfxBank::$0 ← call toDd00 (byte*) vicSelectGfxBank::gfx 
Inlined call call plexSetScreen (byte*) plexInit::screen 
Inlined call call plexFreePrepare 
Inlined call call plexFreeAdd (byte) plexShowSprite::ypos 
Inlined call (byte~) plex_irq::$2 ← call plexFreeNextYpos 
Culled Empty Block (label) @1
Culled Empty Block (label) @2
Culled Empty Block (label) @3
Culled Empty Block (label) plexInit::plexSetScreen1_@return
Culled Empty Block (label) plexInit::@2
Culled Empty Block (label) @5
Culled Empty Block (label) @6
Culled Empty Block (label) plexSort::plexFreePrepare1_@return
Culled Empty Block (label) plexSort::@7
Culled Empty Block (label) @7
Culled Empty Block (label) plexShowSprite::plexFreeAdd1_@return
Culled Empty Block (label) plexShowSprite::@5
Culled Empty Block (label) plexShowSprite::@3
Culled Empty Block (label) @8
Culled Empty Block (label) @10
Culled Empty Block (label) @11
Culled Empty Block (label) @12
Culled Empty Block (label) @13
Culled Empty Block (label) plex_irq::plexFreeNextYpos1_@1
Culled Empty Block (label) plex_irq::@6
Culled Empty Block (label) @15
Culled Empty Block (label) loop::@2
Culled Empty Block (label) loop::@13
Culled Empty Block (label) loop::@3
Culled Empty Block (label) loop::@14
Culled Empty Block (label) loop::@5
Culled Empty Block (label) loop::@7
Culled Empty Block (label) loop::@8
Culled Empty Block (label) loop::@9
Culled Empty Block (label) loop::@12

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  to:@4
@4: scope:[]  from @begin
  (byte*) PLEX_SCREEN_PTR#0 ← (byte*)(number) $400+(number) $3f8
  (byte) plex_show_idx ← (byte) 0
  (byte) plex_sprite_idx ← (byte) 0
  (byte) plex_sprite_msb ← (byte) 1
  to:@9

(void()) plexInit((byte*) plexInit::screen)
plexInit: scope:[plexInit]  from init
  (byte*) plexInit::screen#1 ← phi( init/(byte*) plexInit::screen#0 )
  (byte*) plexInit::plexSetScreen1_screen#0 ← (byte*) plexInit::screen#1
  to:plexInit::plexSetScreen1
plexInit::plexSetScreen1: scope:[plexInit]  from plexInit
  (byte*) plexInit::plexSetScreen1_screen#1 ← phi( plexInit/(byte*) plexInit::plexSetScreen1_screen#0 )
  (byte*~) plexInit::plexSetScreen1_$0 ← (byte*) plexInit::plexSetScreen1_screen#1 + (number) $3f8
  (byte*) PLEX_SCREEN_PTR#1 ← (byte*~) plexInit::plexSetScreen1_$0
  to:plexInit::@3
plexInit::@3: scope:[plexInit]  from plexInit::plexSetScreen1
  (byte*) PLEX_SCREEN_PTR#22 ← phi( plexInit::plexSetScreen1/(byte*) PLEX_SCREEN_PTR#1 )
  (byte) plexInit::i#0 ← (byte) 0
  to:plexInit::@1
plexInit::@1: scope:[plexInit]  from plexInit::@1 plexInit::@3
  (byte*) PLEX_SCREEN_PTR#15 ← phi( plexInit::@1/(byte*) PLEX_SCREEN_PTR#15 plexInit::@3/(byte*) PLEX_SCREEN_PTR#22 )
  (byte) plexInit::i#2 ← phi( plexInit::@1/(byte) plexInit::i#1 plexInit::@3/(byte) plexInit::i#0 )
  *((const byte*) PLEX_SORTED_IDX + (byte) plexInit::i#2) ← (byte) plexInit::i#2
  (byte) plexInit::i#1 ← (byte) plexInit::i#2 + rangenext(0,PLEX_COUNT-1)
  (bool~) plexInit::$1 ← (byte) plexInit::i#1 != rangelast(0,PLEX_COUNT-1)
  if((bool~) plexInit::$1) goto plexInit::@1
  to:plexInit::@return
plexInit::@return: scope:[plexInit]  from plexInit::@1
  (byte*) PLEX_SCREEN_PTR#8 ← phi( plexInit::@1/(byte*) PLEX_SCREEN_PTR#15 )
  (byte*) PLEX_SCREEN_PTR#2 ← (byte*) PLEX_SCREEN_PTR#8
  return 
  to:@return

(void()) plexSort()
plexSort: scope:[plexSort]  from loop::@11
  (byte) plexSort::m#0 ← (byte) 0
  to:plexSort::@1
plexSort::@1: scope:[plexSort]  from plexSort plexSort::@2
  (byte) plexSort::m#2 ← phi( plexSort/(byte) plexSort::m#0 plexSort::@2/(byte) plexSort::m#1 )
  (number~) plexSort::$1 ← (byte) plexSort::m#2 + (number) 1
  (byte) plexSort::nxt_idx#0 ← *((const byte*) PLEX_SORTED_IDX + (number~) plexSort::$1)
  (byte) plexSort::nxt_y#0 ← *((const byte*) PLEX_YPOS + (byte) plexSort::nxt_idx#0)
  (bool~) plexSort::$2 ← (byte) plexSort::nxt_y#0 < *((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::m#2))
  (bool~) plexSort::$3 ← ! (bool~) plexSort::$2
  if((bool~) plexSort::$3) goto plexSort::@2
  to:plexSort::@5
plexSort::@2: scope:[plexSort]  from plexSort::@1 plexSort::@4
  (byte) plexSort::m#3 ← phi( plexSort::@1/(byte) plexSort::m#2 plexSort::@4/(byte) plexSort::m#5 )
  (byte) plexSort::m#1 ← (byte) plexSort::m#3 + rangenext(0,PLEX_COUNT-2)
  (bool~) plexSort::$8 ← (byte) plexSort::m#1 != rangelast(0,PLEX_COUNT-2)
  if((bool~) plexSort::$8) goto plexSort::@1
  to:plexSort::@6
plexSort::@5: scope:[plexSort]  from plexSort::@1
  (byte) plexSort::nxt_idx#3 ← phi( plexSort::@1/(byte) plexSort::nxt_idx#0 )
  (byte) plexSort::nxt_y#2 ← phi( plexSort::@1/(byte) plexSort::nxt_y#0 )
  (byte) plexSort::m#4 ← phi( plexSort::@1/(byte) plexSort::m#2 )
  (byte) plexSort::s#0 ← (byte) plexSort::m#4
  to:plexSort::@3
plexSort::@3: scope:[plexSort]  from plexSort::@3 plexSort::@5
  (byte) plexSort::m#6 ← phi( plexSort::@3/(byte) plexSort::m#6 plexSort::@5/(byte) plexSort::m#4 )
  (byte) plexSort::nxt_idx#2 ← phi( plexSort::@3/(byte) plexSort::nxt_idx#2 plexSort::@5/(byte) plexSort::nxt_idx#3 )
  (byte) plexSort::nxt_y#1 ← phi( plexSort::@3/(byte) plexSort::nxt_y#1 plexSort::@5/(byte) plexSort::nxt_y#2 )
  (byte) plexSort::s#3 ← phi( plexSort::@3/(byte) plexSort::s#1 plexSort::@5/(byte) plexSort::s#0 )
  (number~) plexSort::$4 ← (byte) plexSort::s#3 + (number) 1
  *((const byte*) PLEX_SORTED_IDX + (number~) plexSort::$4) ← *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#3)
  (byte) plexSort::s#1 ← -- (byte) plexSort::s#3
  (bool~) plexSort::$5 ← (byte) plexSort::s#1 != (number) $ff
  (bool~) plexSort::$6 ← (byte) plexSort::nxt_y#1 < *((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#1))
  (bool~) plexSort::$7 ← (bool~) plexSort::$5 && (bool~) plexSort::$6
  if((bool~) plexSort::$7) goto plexSort::@3
  to:plexSort::@4
plexSort::@4: scope:[plexSort]  from plexSort::@3
  (byte) plexSort::m#5 ← phi( plexSort::@3/(byte) plexSort::m#6 )
  (byte) plexSort::nxt_idx#1 ← phi( plexSort::@3/(byte) plexSort::nxt_idx#2 )
  (byte) plexSort::s#4 ← phi( plexSort::@3/(byte) plexSort::s#1 )
  (byte) plexSort::s#2 ← ++ (byte) plexSort::s#4
  *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#2) ← (byte) plexSort::nxt_idx#1
  to:plexSort::@2
plexSort::@6: scope:[plexSort]  from plexSort::@2
  (byte) plex_show_idx ← (number) 0
  (byte) plex_sprite_idx ← (number) 0
  (byte) plex_sprite_msb ← (number) 1
  to:plexSort::plexFreePrepare1
plexSort::plexFreePrepare1: scope:[plexSort]  from plexSort::@6
  (byte) plexSort::plexFreePrepare1_s#0 ← (byte) 0
  to:plexSort::plexFreePrepare1_@1
plexSort::plexFreePrepare1_@1: scope:[plexSort]  from plexSort::plexFreePrepare1 plexSort::plexFreePrepare1_@1
  (byte) plexSort::plexFreePrepare1_s#2 ← phi( plexSort::plexFreePrepare1/(byte) plexSort::plexFreePrepare1_s#0 plexSort::plexFreePrepare1_@1/(byte) plexSort::plexFreePrepare1_s#1 )
  *((const byte*) PLEX_FREE_YPOS + (byte) plexSort::plexFreePrepare1_s#2) ← (number) 0
  (byte) plexSort::plexFreePrepare1_s#1 ← (byte) plexSort::plexFreePrepare1_s#2 + rangenext(0,7)
  (bool~) plexSort::plexFreePrepare1_$0 ← (byte) plexSort::plexFreePrepare1_s#1 != rangelast(0,7)
  if((bool~) plexSort::plexFreePrepare1_$0) goto plexSort::plexFreePrepare1_@1
  to:plexSort::plexFreePrepare1_@2
plexSort::plexFreePrepare1_@2: scope:[plexSort]  from plexSort::plexFreePrepare1_@1
  (byte) plex_free_next ← (number) 0
  to:plexSort::@return
plexSort::@return: scope:[plexSort]  from plexSort::plexFreePrepare1_@2
  return 
  to:@return

(void()) plexShowSprite()
plexShowSprite: scope:[plexShowSprite]  from plex_irq::@3
  (byte*) PLEX_SCREEN_PTR#23 ← phi( plex_irq::@3/(byte*) PLEX_SCREEN_PTR#26 )
  (number~) plexShowSprite::$0 ← (byte) plex_sprite_idx * (number) 2
  (byte) plexShowSprite::plex_sprite_idx2#0 ← (number~) plexShowSprite::$0
  (byte) plexShowSprite::ypos#0 ← *((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx))
  *((const byte*) SPRITES_YPOS + (byte) plexShowSprite::plex_sprite_idx2#0) ← (byte) plexShowSprite::ypos#0
  (byte) plexShowSprite::plexFreeAdd1_ypos#0 ← (byte) plexShowSprite::ypos#0
  to:plexShowSprite::plexFreeAdd1
plexShowSprite::plexFreeAdd1: scope:[plexShowSprite]  from plexShowSprite
  (byte) plexShowSprite::plex_sprite_idx2#2 ← phi( plexShowSprite/(byte) plexShowSprite::plex_sprite_idx2#0 )
  (byte*) PLEX_SCREEN_PTR#16 ← phi( plexShowSprite/(byte*) PLEX_SCREEN_PTR#23 )
  (byte) plexShowSprite::plexFreeAdd1_ypos#1 ← phi( plexShowSprite/(byte) plexShowSprite::plexFreeAdd1_ypos#0 )
  (number~) plexShowSprite::plexFreeAdd1_$0 ← (byte) plexShowSprite::plexFreeAdd1_ypos#1 + (number) $15
  *((const byte*) PLEX_FREE_YPOS + (byte) plex_free_next) ← (number~) plexShowSprite::plexFreeAdd1_$0
  (number~) plexShowSprite::plexFreeAdd1_$1 ← (byte) plex_free_next + (number) 1
  (number~) plexShowSprite::plexFreeAdd1_$2 ← (number~) plexShowSprite::plexFreeAdd1_$1 & (number) 7
  (byte) plex_free_next ← (number~) plexShowSprite::plexFreeAdd1_$2
  to:plexShowSprite::@7
plexShowSprite::@7: scope:[plexShowSprite]  from plexShowSprite::plexFreeAdd1
  (byte) plexShowSprite::plex_sprite_idx2#1 ← phi( plexShowSprite::plexFreeAdd1/(byte) plexShowSprite::plex_sprite_idx2#2 )
  (byte*) PLEX_SCREEN_PTR#9 ← phi( plexShowSprite::plexFreeAdd1/(byte*) PLEX_SCREEN_PTR#16 )
  *((byte*) PLEX_SCREEN_PTR#9 + (byte) plex_sprite_idx) ← *((const byte*) PLEX_PTR + *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx))
  (byte) plexShowSprite::xpos_idx#0 ← *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx)
  (byte~) plexShowSprite::$10 ← (byte) plexShowSprite::xpos_idx#0 * (const byte) SIZEOF_WORD
  (byte~) plexShowSprite::$2 ← < *((const word*) PLEX_XPOS + (byte~) plexShowSprite::$10)
  *((const byte*) SPRITES_XPOS + (byte) plexShowSprite::plex_sprite_idx2#1) ← (byte~) plexShowSprite::$2
  (byte~) plexShowSprite::$11 ← (byte) plexShowSprite::xpos_idx#0 * (const byte) SIZEOF_WORD
  (byte~) plexShowSprite::$3 ← > *((const word*) PLEX_XPOS + (byte~) plexShowSprite::$11)
  (bool~) plexShowSprite::$4 ← (byte~) plexShowSprite::$3 != (number) 0
  if((bool~) plexShowSprite::$4) goto plexShowSprite::@1
  to:plexShowSprite::@4
plexShowSprite::@1: scope:[plexShowSprite]  from plexShowSprite::@7
  *((const byte*) SPRITES_XMSB) ← *((const byte*) SPRITES_XMSB) | (byte) plex_sprite_msb
  to:plexShowSprite::@2
plexShowSprite::@4: scope:[plexShowSprite]  from plexShowSprite::@7
  (number~) plexShowSprite::$9 ← (number) $ff ^ (byte) plex_sprite_msb
  *((const byte*) SPRITES_XMSB) ← *((const byte*) SPRITES_XMSB) & (number~) plexShowSprite::$9
  to:plexShowSprite::@2
plexShowSprite::@2: scope:[plexShowSprite]  from plexShowSprite::@1 plexShowSprite::@4
  (number~) plexShowSprite::$5 ← (byte) plex_sprite_idx + (number) 1
  (number~) plexShowSprite::$6 ← (number~) plexShowSprite::$5 & (number) 7
  (byte) plex_sprite_idx ← (number~) plexShowSprite::$6
  (byte) plex_show_idx ← ++ (byte) plex_show_idx
  (byte) plex_sprite_msb ← (byte) plex_sprite_msb << (number) 1
  (bool~) plexShowSprite::$7 ← (byte) plex_sprite_msb == (number) 0
  (bool~) plexShowSprite::$8 ← ! (bool~) plexShowSprite::$7
  if((bool~) plexShowSprite::$8) goto plexShowSprite::@return
  to:plexShowSprite::@6
plexShowSprite::@6: scope:[plexShowSprite]  from plexShowSprite::@2
  (byte) plex_sprite_msb ← (number) 1
  to:plexShowSprite::@return
plexShowSprite::@return: scope:[plexShowSprite]  from plexShowSprite::@2 plexShowSprite::@6
  return 
  to:@return
@9: scope:[]  from @4
  (byte*) PLEX_SCREEN_PTR#28 ← phi( @4/(byte*) PLEX_SCREEN_PTR#0 )
  (byte) plex_free_next ← (byte) 0
  to:@14

(void()) main()
main: scope:[main]  from @16
  (byte*) PLEX_SCREEN_PTR#17 ← phi( @16/(byte*) PLEX_SCREEN_PTR#21 )
  asm { sei  }
  call init 
  to:main::@1
main::@1: scope:[main]  from main
  (byte*) PLEX_SCREEN_PTR#10 ← phi( main/(byte*) PLEX_SCREEN_PTR#6 )
  (byte*) PLEX_SCREEN_PTR#3 ← (byte*) PLEX_SCREEN_PTR#10
  call loop 
  to:main::@2
main::@2: scope:[main]  from main::@1
  (byte*) PLEX_SCREEN_PTR#18 ← phi( main::@1/(byte*) PLEX_SCREEN_PTR#3 )
  to:main::@return
main::@return: scope:[main]  from main::@2
  (byte*) PLEX_SCREEN_PTR#11 ← phi( main::@2/(byte*) PLEX_SCREEN_PTR#18 )
  (byte*) PLEX_SCREEN_PTR#4 ← (byte*) PLEX_SCREEN_PTR#11
  return 
  to:@return

(void()) init()
init: scope:[init]  from main
  (byte*) PLEX_SCREEN_PTR#19 ← phi( main/(byte*) PLEX_SCREEN_PTR#17 )
  *((const byte*) D011) ← (const byte) VIC_DEN|(const byte) VIC_RSEL|(number) 3
  (byte*) plexInit::screen#0 ← (const byte*) SCREEN
  call plexInit 
  to:init::@5
init::@5: scope:[init]  from init
  (byte*) PLEX_SCREEN_PTR#12 ← phi( init/(byte*) PLEX_SCREEN_PTR#2 )
  (byte*) PLEX_SCREEN_PTR#5 ← (byte*) PLEX_SCREEN_PTR#12
  (word) init::xp#0 ← (word) $20
  (byte) init::sx#0 ← (byte) 0
  to:init::@1
init::@1: scope:[init]  from init::@1 init::@5
  (byte*) PLEX_SCREEN_PTR#29 ← phi( init::@1/(byte*) PLEX_SCREEN_PTR#29 init::@5/(byte*) PLEX_SCREEN_PTR#5 )
  (word) init::xp#2 ← phi( init::@1/(word) init::xp#1 init::@5/(word) init::xp#0 )
  (byte) init::sx#2 ← phi( init::@1/(byte) init::sx#1 init::@5/(byte) init::sx#0 )
  *((const byte*) PLEX_PTR + (byte) init::sx#2) ← (byte)(const byte*) SPRITE/(number) $40
  (byte~) init::$3 ← (byte) init::sx#2 * (const byte) SIZEOF_WORD
  *((const word*) PLEX_XPOS + (byte~) init::$3) ← (word) init::xp#2
  (word) init::xp#1 ← (word) init::xp#2 + (number) 9
  (byte) init::sx#1 ← (byte) init::sx#2 + rangenext(0,PLEX_COUNT-1)
  (bool~) init::$1 ← (byte) init::sx#1 != rangelast(0,PLEX_COUNT-1)
  if((bool~) init::$1) goto init::@1
  to:init::@2
init::@2: scope:[init]  from init::@1
  (byte*) PLEX_SCREEN_PTR#27 ← phi( init::@1/(byte*) PLEX_SCREEN_PTR#29 )
  *((const byte*) SPRITES_ENABLE) ← (number) $ff
  (byte) init::ss#0 ← (byte) 0
  to:init::@3
init::@3: scope:[init]  from init::@2 init::@3
  (byte*) PLEX_SCREEN_PTR#24 ← phi( init::@2/(byte*) PLEX_SCREEN_PTR#27 init::@3/(byte*) PLEX_SCREEN_PTR#24 )
  (byte) init::ss#2 ← phi( init::@2/(byte) init::ss#0 init::@3/(byte) init::ss#1 )
  *((const byte*) SPRITES_COLS + (byte) init::ss#2) ← (const byte) GREEN
  (byte) init::ss#1 ← (byte) init::ss#2 + rangenext(0,7)
  (bool~) init::$2 ← (byte) init::ss#1 != rangelast(0,7)
  if((bool~) init::$2) goto init::@3
  to:init::@4
init::@4: scope:[init]  from init::@3
  (byte*) PLEX_SCREEN_PTR#20 ← phi( init::@3/(byte*) PLEX_SCREEN_PTR#24 )
  asm { sei  }
  *((const byte*) CIA1_INTERRUPT) ← (const byte) CIA_INTERRUPT_CLEAR
  *((const byte*) IRQ_ENABLE) ← (const byte) IRQ_RASTER
  *((const byte*) IRQ_STATUS) ← (const byte) IRQ_RASTER
  *((const void()**) KERNEL_IRQ) ← &interrupt(KERNEL_MIN)(void()) plex_irq()
  asm { cli  }
  to:init::@return
init::@return: scope:[init]  from init::@4
  (byte*) PLEX_SCREEN_PTR#13 ← phi( init::@4/(byte*) PLEX_SCREEN_PTR#20 )
  (byte*) PLEX_SCREEN_PTR#6 ← (byte*) PLEX_SCREEN_PTR#13
  return 
  to:@return
@14: scope:[]  from @9
  (byte*) PLEX_SCREEN_PTR#25 ← phi( @9/(byte*) PLEX_SCREEN_PTR#28 )
  (bool) framedone ← true
  to:@16

interrupt(KERNEL_MIN)(void()) plex_irq()
plex_irq: scope:[plex_irq]  from
  (byte*) PLEX_SCREEN_PTR#30 ← phi( @16/(byte*) PLEX_SCREEN_PTR#21 )
  (byte) plex_irq::rasterY#0 ← (byte) 0
  *((const byte*) BORDERCOL) ← (const byte) WHITE
  to:plex_irq::@3
plex_irq::@3: scope:[plex_irq]  from plex_irq plex_irq::@7
  (byte*) PLEX_SCREEN_PTR#26 ← phi( plex_irq/(byte*) PLEX_SCREEN_PTR#30 plex_irq::@7/(byte*) PLEX_SCREEN_PTR#31 )
  call plexShowSprite 
  to:plex_irq::@8
plex_irq::@8: scope:[plex_irq]  from plex_irq::@3
  (byte*) PLEX_SCREEN_PTR#34 ← phi( plex_irq::@3/(byte*) PLEX_SCREEN_PTR#26 )
  to:plex_irq::plexFreeNextYpos1
plex_irq::plexFreeNextYpos1: scope:[plex_irq]  from plex_irq::@8
  (byte*) PLEX_SCREEN_PTR#33 ← phi( plex_irq::@8/(byte*) PLEX_SCREEN_PTR#34 )
  (byte) plex_irq::plexFreeNextYpos1_return#0 ← *((const byte*) PLEX_FREE_YPOS + (byte) plex_free_next)
  to:plex_irq::plexFreeNextYpos1_@return
plex_irq::plexFreeNextYpos1_@return: scope:[plex_irq]  from plex_irq::plexFreeNextYpos1
  (byte*) PLEX_SCREEN_PTR#32 ← phi( plex_irq::plexFreeNextYpos1/(byte*) PLEX_SCREEN_PTR#33 )
  (byte) plex_irq::plexFreeNextYpos1_return#2 ← phi( plex_irq::plexFreeNextYpos1/(byte) plex_irq::plexFreeNextYpos1_return#0 )
  (byte) plex_irq::plexFreeNextYpos1_return#1 ← (byte) plex_irq::plexFreeNextYpos1_return#2
  to:plex_irq::@7
plex_irq::@7: scope:[plex_irq]  from plex_irq::plexFreeNextYpos1_@return
  (byte*) PLEX_SCREEN_PTR#31 ← phi( plex_irq::plexFreeNextYpos1_@return/(byte*) PLEX_SCREEN_PTR#32 )
  (byte) plex_irq::plexFreeNextYpos1_return#3 ← phi( plex_irq::plexFreeNextYpos1_@return/(byte) plex_irq::plexFreeNextYpos1_return#1 )
  (byte~) plex_irq::$2 ← (byte) plex_irq::plexFreeNextYpos1_return#3
  (byte) plex_irq::rasterY#1 ← (byte~) plex_irq::$2
  (bool~) plex_irq::$3 ← (byte) plex_show_idx < (const byte) PLEX_COUNT
  (number~) plex_irq::$4 ← *((const byte*) RASTER) + (number) 2
  (bool~) plex_irq::$5 ← (byte) plex_irq::rasterY#1 < (number~) plex_irq::$4
  (bool~) plex_irq::$6 ← (bool~) plex_irq::$3 && (bool~) plex_irq::$5
  if((bool~) plex_irq::$6) goto plex_irq::@3
  to:plex_irq::@4
plex_irq::@4: scope:[plex_irq]  from plex_irq::@7
  (byte) plex_irq::rasterY#3 ← phi( plex_irq::@7/(byte) plex_irq::rasterY#1 )
  *((const byte*) IRQ_STATUS) ← (const byte) IRQ_RASTER
  (bool~) plex_irq::$0 ← (byte) plex_show_idx < (const byte) PLEX_COUNT
  if((bool~) plex_irq::$0) goto plex_irq::@1
  to:plex_irq::@5
plex_irq::@1: scope:[plex_irq]  from plex_irq::@4
  (byte) plex_irq::rasterY#2 ← phi( plex_irq::@4/(byte) plex_irq::rasterY#3 )
  *((const byte*) RASTER) ← (byte) plex_irq::rasterY#2
  to:plex_irq::@2
plex_irq::@5: scope:[plex_irq]  from plex_irq::@4
  (bool) framedone ← true
  to:plex_irq::@2
plex_irq::@2: scope:[plex_irq]  from plex_irq::@1 plex_irq::@5
  *((const byte*) BORDERCOL) ← (number) 0
  to:plex_irq::@return
plex_irq::@return: scope:[plex_irq]  from plex_irq::@2
  return 
  to:@return

(void()) loop()
loop: scope:[loop]  from main::@1
  (byte) loop::sin_idx#0 ← (byte) 0
  to:loop::@1
loop::@1: scope:[loop]  from loop loop::@15
  (byte) loop::sin_idx#6 ← phi( loop/(byte) loop::sin_idx#0 loop::@15/(byte) loop::sin_idx#7 )
  if(true) goto loop::@4
  to:loop::@return
loop::@4: scope:[loop]  from loop::@1 loop::@4
  (byte) loop::sin_idx#4 ← phi( loop::@1/(byte) loop::sin_idx#6 loop::@4/(byte) loop::sin_idx#4 )
  (bool~) loop::$0 ← ! (bool) framedone
  if((bool~) loop::$0) goto loop::@4
  to:loop::@6
loop::@6: scope:[loop]  from loop::@4
  (byte) loop::sin_idx#2 ← phi( loop::@4/(byte) loop::sin_idx#4 )
  *((const byte*) BORDERCOL) ← (const byte) RED
  (byte) loop::y_idx#0 ← (byte) loop::sin_idx#2
  (byte) loop::sy#0 ← (byte) 0
  to:loop::@10
loop::@10: scope:[loop]  from loop::@10 loop::@6
  (byte) loop::sin_idx#5 ← phi( loop::@10/(byte) loop::sin_idx#5 loop::@6/(byte) loop::sin_idx#2 )
  (byte) loop::sy#2 ← phi( loop::@10/(byte) loop::sy#1 loop::@6/(byte) loop::sy#0 )
  (byte) loop::y_idx#2 ← phi( loop::@10/(byte) loop::y_idx#1 loop::@6/(byte) loop::y_idx#0 )
  *((const byte*) PLEX_YPOS + (byte) loop::sy#2) ← *((const byte*) YSIN + (byte) loop::y_idx#2)
  (byte) loop::y_idx#1 ← (byte) loop::y_idx#2 + (number) 8
  (byte) loop::sy#1 ← (byte) loop::sy#2 + rangenext(0,PLEX_COUNT-1)
  (bool~) loop::$1 ← (byte) loop::sy#1 != rangelast(0,PLEX_COUNT-1)
  if((bool~) loop::$1) goto loop::@10
  to:loop::@11
loop::@11: scope:[loop]  from loop::@10
  (byte) loop::sin_idx#3 ← phi( loop::@10/(byte) loop::sin_idx#5 )
  (byte) loop::sin_idx#1 ← (byte) loop::sin_idx#3 + (number) 1
  *((const byte*) BORDERCOL) ← ++ *((const byte*) BORDERCOL)
  call plexSort 
  to:loop::@15
loop::@15: scope:[loop]  from loop::@11
  (byte) loop::sin_idx#7 ← phi( loop::@11/(byte) loop::sin_idx#1 )
  *((const byte*) BORDERCOL) ← (const byte) GREEN
  (bool) framedone ← false
  *((const byte*) VIC_CONTROL) ← *((const byte*) VIC_CONTROL) & (number) $7f
  *((const byte*) RASTER) ← (number) 0
  to:loop::@1
loop::@return: scope:[loop]  from loop::@1
  return 
  to:@return
@16: scope:[]  from @14
  (byte*) PLEX_SCREEN_PTR#21 ← phi( @14/(byte*) PLEX_SCREEN_PTR#25 )
  call main 
  to:@17
@17: scope:[]  from @16
  (byte*) PLEX_SCREEN_PTR#14 ← phi( @16/(byte*) PLEX_SCREEN_PTR#4 )
  (byte*) PLEX_SCREEN_PTR#7 ← (byte*) PLEX_SCREEN_PTR#14
  to:@end
@end: scope:[]  from @17

SYMBOL TABLE SSA
(label) @14
(label) @16
(label) @17
(label) @4
(label) @9
(label) @begin
(label) @end
(const byte*) BORDERCOL = (byte*)(number) $d020
(const byte*) CIA1_INTERRUPT = (byte*)(number) $dc0d
(const byte) CIA_INTERRUPT_CLEAR = (byte) $7f
(const byte*) D011 = (byte*)(number) $d011
(const byte) GREEN = (byte) 5
(const byte*) IRQ_ENABLE = (byte*)(number) $d01a
(const byte) IRQ_RASTER = (byte) 1
(const byte*) IRQ_STATUS = (byte*)(number) $d019
(const void()**) KERNEL_IRQ = (void()**)(number) $314
(const byte) PLEX_COUNT = (byte) $20
(const byte*) PLEX_FREE_YPOS[(number) 8]  = { fill( 8, 0) }
(const byte*) PLEX_PTR[(const byte) PLEX_COUNT]  = { fill( PLEX_COUNT, 0) }
(byte*) PLEX_SCREEN_PTR
(byte*) PLEX_SCREEN_PTR#0
(byte*) PLEX_SCREEN_PTR#1
(byte*) PLEX_SCREEN_PTR#10
(byte*) PLEX_SCREEN_PTR#11
(byte*) PLEX_SCREEN_PTR#12
(byte*) PLEX_SCREEN_PTR#13
(byte*) PLEX_SCREEN_PTR#14
(byte*) PLEX_SCREEN_PTR#15
(byte*) PLEX_SCREEN_PTR#16
(byte*) PLEX_SCREEN_PTR#17
(byte*) PLEX_SCREEN_PTR#18
(byte*) PLEX_SCREEN_PTR#19
(byte*) PLEX_SCREEN_PTR#2
(byte*) PLEX_SCREEN_PTR#20
(byte*) PLEX_SCREEN_PTR#21
(byte*) PLEX_SCREEN_PTR#22
(byte*) PLEX_SCREEN_PTR#23
(byte*) PLEX_SCREEN_PTR#24
(byte*) PLEX_SCREEN_PTR#25
(byte*) PLEX_SCREEN_PTR#26
(byte*) PLEX_SCREEN_PTR#27
(byte*) PLEX_SCREEN_PTR#28
(byte*) PLEX_SCREEN_PTR#29
(byte*) PLEX_SCREEN_PTR#3
(byte*) PLEX_SCREEN_PTR#30
(byte*) PLEX_SCREEN_PTR#31
(byte*) PLEX_SCREEN_PTR#32
(byte*) PLEX_SCREEN_PTR#33
(byte*) PLEX_SCREEN_PTR#34
(byte*) PLEX_SCREEN_PTR#4
(byte*) PLEX_SCREEN_PTR#5
(byte*) PLEX_SCREEN_PTR#6
(byte*) PLEX_SCREEN_PTR#7
(byte*) PLEX_SCREEN_PTR#8
(byte*) PLEX_SCREEN_PTR#9
(const byte*) PLEX_SORTED_IDX[(const byte) PLEX_COUNT]  = { fill( PLEX_COUNT, 0) }
(const word*) PLEX_XPOS[(const byte) PLEX_COUNT]  = { fill( PLEX_COUNT, 0) }
(const byte*) PLEX_YPOS[(const byte) PLEX_COUNT]  = { fill( PLEX_COUNT, 0) }
(const byte*) RASTER = (byte*)(number) $d012
(const byte) RED = (byte) 2
(const byte*) SCREEN = (byte*)(number) $400
(const byte) SIZEOF_WORD = (byte) 2
(const byte*) SPRITE[(number) $40]  = kickasm {{ .var pic = LoadPicture("balloon.png", List().add($000000, $ffffff))
    .for (var y=0; y<21; y++)
        .for (var x=0;x<3; x++)
            .byte pic.getSinglecolorByte(x,y)
 }}
(const byte*) SPRITES_COLS = (byte*)(number) $d027
(const byte*) SPRITES_ENABLE = (byte*)(number) $d015
(const byte*) SPRITES_XMSB = (byte*)(number) $d010
(const byte*) SPRITES_XPOS = (byte*)(number) $d000
(const byte*) SPRITES_YPOS = (byte*)(number) $d001
(const byte*) VIC_CONTROL = (byte*)(number) $d011
(const byte) VIC_DEN = (byte) $10
(const byte) VIC_RSEL = (byte) 8
(const byte) WHITE = (byte) 1
(const byte*) YSIN[(number) $100]  = kickasm {{ .fill $100, round(139.5+89.5*sin(toRadians(360*i/256)))
 }}
(bool) framedone loadstore
(void()) init()
(bool~) init::$1
(bool~) init::$2
(byte~) init::$3
(label) init::@1
(label) init::@2
(label) init::@3
(label) init::@4
(label) init::@5
(label) init::@return
(byte) init::ss
(byte) init::ss#0
(byte) init::ss#1
(byte) init::ss#2
(byte) init::sx
(byte) init::sx#0
(byte) init::sx#1
(byte) init::sx#2
(word) init::xp
(word) init::xp#0
(word) init::xp#1
(word) init::xp#2
(void()) loop()
(bool~) loop::$0
(bool~) loop::$1
(label) loop::@1
(label) loop::@10
(label) loop::@11
(label) loop::@15
(label) loop::@4
(label) loop::@6
(label) loop::@return
(byte) loop::sin_idx
(byte) loop::sin_idx#0
(byte) loop::sin_idx#1
(byte) loop::sin_idx#2
(byte) loop::sin_idx#3
(byte) loop::sin_idx#4
(byte) loop::sin_idx#5
(byte) loop::sin_idx#6
(byte) loop::sin_idx#7
(byte) loop::sy
(byte) loop::sy#0
(byte) loop::sy#1
(byte) loop::sy#2
(byte) loop::y_idx
(byte) loop::y_idx#0
(byte) loop::y_idx#1
(byte) loop::y_idx#2
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(void()) plexInit((byte*) plexInit::screen)
(bool~) plexInit::$1
(label) plexInit::@1
(label) plexInit::@3
(label) plexInit::@return
(byte) plexInit::i
(byte) plexInit::i#0
(byte) plexInit::i#1
(byte) plexInit::i#2
(label) plexInit::plexSetScreen1
(byte*~) plexInit::plexSetScreen1_$0
(byte*) plexInit::plexSetScreen1_screen
(byte*) plexInit::plexSetScreen1_screen#0
(byte*) plexInit::plexSetScreen1_screen#1
(byte*) plexInit::screen
(byte*) plexInit::screen#0
(byte*) plexInit::screen#1
(void()) plexShowSprite()
(number~) plexShowSprite::$0
(byte~) plexShowSprite::$10
(byte~) plexShowSprite::$11
(byte~) plexShowSprite::$2
(byte~) plexShowSprite::$3
(bool~) plexShowSprite::$4
(number~) plexShowSprite::$5
(number~) plexShowSprite::$6
(bool~) plexShowSprite::$7
(bool~) plexShowSprite::$8
(number~) plexShowSprite::$9
(label) plexShowSprite::@1
(label) plexShowSprite::@2
(label) plexShowSprite::@4
(label) plexShowSprite::@6
(label) plexShowSprite::@7
(label) plexShowSprite::@return
(label) plexShowSprite::plexFreeAdd1
(number~) plexShowSprite::plexFreeAdd1_$0
(number~) plexShowSprite::plexFreeAdd1_$1
(number~) plexShowSprite::plexFreeAdd1_$2
(byte) plexShowSprite::plexFreeAdd1_ypos
(byte) plexShowSprite::plexFreeAdd1_ypos#0
(byte) plexShowSprite::plexFreeAdd1_ypos#1
(byte) plexShowSprite::plex_sprite_idx2
(byte) plexShowSprite::plex_sprite_idx2#0
(byte) plexShowSprite::plex_sprite_idx2#1
(byte) plexShowSprite::plex_sprite_idx2#2
(byte) plexShowSprite::xpos_idx
(byte) plexShowSprite::xpos_idx#0
(byte) plexShowSprite::ypos
(byte) plexShowSprite::ypos#0
(void()) plexSort()
(number~) plexSort::$1
(bool~) plexSort::$2
(bool~) plexSort::$3
(number~) plexSort::$4
(bool~) plexSort::$5
(bool~) plexSort::$6
(bool~) plexSort::$7
(bool~) plexSort::$8
(label) plexSort::@1
(label) plexSort::@2
(label) plexSort::@3
(label) plexSort::@4
(label) plexSort::@5
(label) plexSort::@6
(label) plexSort::@return
(byte) plexSort::m
(byte) plexSort::m#0
(byte) plexSort::m#1
(byte) plexSort::m#2
(byte) plexSort::m#3
(byte) plexSort::m#4
(byte) plexSort::m#5
(byte) plexSort::m#6
(byte) plexSort::nxt_idx
(byte) plexSort::nxt_idx#0
(byte) plexSort::nxt_idx#1
(byte) plexSort::nxt_idx#2
(byte) plexSort::nxt_idx#3
(byte) plexSort::nxt_y
(byte) plexSort::nxt_y#0
(byte) plexSort::nxt_y#1
(byte) plexSort::nxt_y#2
(label) plexSort::plexFreePrepare1
(bool~) plexSort::plexFreePrepare1_$0
(label) plexSort::plexFreePrepare1_@1
(label) plexSort::plexFreePrepare1_@2
(byte) plexSort::plexFreePrepare1_s
(byte) plexSort::plexFreePrepare1_s#0
(byte) plexSort::plexFreePrepare1_s#1
(byte) plexSort::plexFreePrepare1_s#2
(byte) plexSort::s
(byte) plexSort::s#0
(byte) plexSort::s#1
(byte) plexSort::s#2
(byte) plexSort::s#3
(byte) plexSort::s#4
(byte) plex_free_next loadstore
interrupt(KERNEL_MIN)(void()) plex_irq()
(bool~) plex_irq::$0
(byte~) plex_irq::$2
(bool~) plex_irq::$3
(number~) plex_irq::$4
(bool~) plex_irq::$5
(bool~) plex_irq::$6
(label) plex_irq::@1
(label) plex_irq::@2
(label) plex_irq::@3
(label) plex_irq::@4
(label) plex_irq::@5
(label) plex_irq::@7
(label) plex_irq::@8
(label) plex_irq::@return
(label) plex_irq::plexFreeNextYpos1
(label) plex_irq::plexFreeNextYpos1_@return
(byte) plex_irq::plexFreeNextYpos1_return
(byte) plex_irq::plexFreeNextYpos1_return#0
(byte) plex_irq::plexFreeNextYpos1_return#1
(byte) plex_irq::plexFreeNextYpos1_return#2
(byte) plex_irq::plexFreeNextYpos1_return#3
(byte) plex_irq::rasterY
(byte) plex_irq::rasterY#0
(byte) plex_irq::rasterY#1
(byte) plex_irq::rasterY#2
(byte) plex_irq::rasterY#3
(byte) plex_show_idx loadstore
(byte) plex_sprite_idx loadstore
(byte) plex_sprite_msb loadstore

Adding number conversion cast (unumber) $3f8 in (byte*~) plexInit::plexSetScreen1_$0 ← (byte*) plexInit::plexSetScreen1_screen#1 + (number) $3f8
Adding number conversion cast (unumber) 1 in (byte) plexInit::i#1 ← (byte) plexInit::i#2 + rangenext(0,PLEX_COUNT-1)
Adding number conversion cast (unumber) 1 in (number~) plexSort::$1 ← (byte) plexSort::m#2 + (number) 1
Adding number conversion cast (unumber) plexSort::$1 in (number~) plexSort::$1 ← (byte) plexSort::m#2 + (unumber)(number) 1
Adding number conversion cast (unumber) 2 in (byte) plexSort::m#1 ← (byte) plexSort::m#3 + rangenext(0,PLEX_COUNT-2)
Adding number conversion cast (unumber) 1 in (number~) plexSort::$4 ← (byte) plexSort::s#3 + (number) 1
Adding number conversion cast (unumber) plexSort::$4 in (number~) plexSort::$4 ← (byte) plexSort::s#3 + (unumber)(number) 1
Adding number conversion cast (unumber) $ff in (bool~) plexSort::$5 ← (byte) plexSort::s#1 != (number) $ff
Adding number conversion cast (unumber) 0 in (byte) plex_show_idx ← (number) 0
Adding number conversion cast (unumber) 0 in (byte) plex_sprite_idx ← (number) 0
Adding number conversion cast (unumber) 1 in (byte) plex_sprite_msb ← (number) 1
Adding number conversion cast (unumber) 0 in *((const byte*) PLEX_FREE_YPOS + (byte) plexSort::plexFreePrepare1_s#2) ← (number) 0
Adding number conversion cast (unumber) 0 in (byte) plex_free_next ← (number) 0
Adding number conversion cast (unumber) 2 in (number~) plexShowSprite::$0 ← (byte) plex_sprite_idx * (number) 2
Adding number conversion cast (unumber) plexShowSprite::$0 in (number~) plexShowSprite::$0 ← (byte) plex_sprite_idx * (unumber)(number) 2
Adding number conversion cast (unumber) $15 in (number~) plexShowSprite::plexFreeAdd1_$0 ← (byte) plexShowSprite::plexFreeAdd1_ypos#1 + (number) $15
Adding number conversion cast (unumber) plexShowSprite::plexFreeAdd1_$0 in (number~) plexShowSprite::plexFreeAdd1_$0 ← (byte) plexShowSprite::plexFreeAdd1_ypos#1 + (unumber)(number) $15
Adding number conversion cast (unumber) 1 in (number~) plexShowSprite::plexFreeAdd1_$1 ← (byte) plex_free_next + (number) 1
Adding number conversion cast (unumber) plexShowSprite::plexFreeAdd1_$1 in (number~) plexShowSprite::plexFreeAdd1_$1 ← (byte) plex_free_next + (unumber)(number) 1
Adding number conversion cast (unumber) 7 in (number~) plexShowSprite::plexFreeAdd1_$2 ← (unumber~) plexShowSprite::plexFreeAdd1_$1 & (number) 7
Adding number conversion cast (unumber) plexShowSprite::plexFreeAdd1_$2 in (number~) plexShowSprite::plexFreeAdd1_$2 ← (unumber~) plexShowSprite::plexFreeAdd1_$1 & (unumber)(number) 7
Adding number conversion cast (unumber) 0 in (bool~) plexShowSprite::$4 ← (byte~) plexShowSprite::$3 != (number) 0
Adding number conversion cast (unumber) $ff in (number~) plexShowSprite::$9 ← (number) $ff ^ (byte) plex_sprite_msb
Adding number conversion cast (unumber) plexShowSprite::$9 in (number~) plexShowSprite::$9 ← (unumber)(number) $ff ^ (byte) plex_sprite_msb
Adding number conversion cast (unumber) 1 in (number~) plexShowSprite::$5 ← (byte) plex_sprite_idx + (number) 1
Adding number conversion cast (unumber) plexShowSprite::$5 in (number~) plexShowSprite::$5 ← (byte) plex_sprite_idx + (unumber)(number) 1
Adding number conversion cast (unumber) 7 in (number~) plexShowSprite::$6 ← (unumber~) plexShowSprite::$5 & (number) 7
Adding number conversion cast (unumber) plexShowSprite::$6 in (number~) plexShowSprite::$6 ← (unumber~) plexShowSprite::$5 & (unumber)(number) 7
Adding number conversion cast (unumber) 1 in (byte) plex_sprite_msb ← (byte) plex_sprite_msb << (number) 1
Adding number conversion cast (unumber) 0 in (bool~) plexShowSprite::$7 ← (byte) plex_sprite_msb == (number) 0
Adding number conversion cast (unumber) 1 in (byte) plex_sprite_msb ← (number) 1
Adding number conversion cast (unumber) VIC_DEN|VIC_RSEL|3 in *((const byte*) D011) ← (const byte) VIC_DEN|(const byte) VIC_RSEL|(number) 3
Adding number conversion cast (unumber) 3 in *((const byte*) D011) ← ((unumber)) (const byte) VIC_DEN|(const byte) VIC_RSEL|(number) 3
Adding number conversion cast (unumber) $40 in *((const byte*) PLEX_PTR + (byte) init::sx#2) ← (byte)(const byte*) SPRITE/(number) $40
Adding number conversion cast (unumber) 9 in (word) init::xp#1 ← (word) init::xp#2 + (number) 9
Adding number conversion cast (unumber) 1 in (byte) init::sx#1 ← (byte) init::sx#2 + rangenext(0,PLEX_COUNT-1)
Adding number conversion cast (unumber) $ff in *((const byte*) SPRITES_ENABLE) ← (number) $ff
Adding number conversion cast (unumber) 2 in (number~) plex_irq::$4 ← *((const byte*) RASTER) + (number) 2
Adding number conversion cast (unumber) plex_irq::$4 in (number~) plex_irq::$4 ← *((const byte*) RASTER) + (unumber)(number) 2
Adding number conversion cast (unumber) 0 in *((const byte*) BORDERCOL) ← (number) 0
Adding number conversion cast (unumber) 8 in (byte) loop::y_idx#1 ← (byte) loop::y_idx#2 + (number) 8
Adding number conversion cast (unumber) 1 in (byte) loop::sy#1 ← (byte) loop::sy#2 + rangenext(0,PLEX_COUNT-1)
Adding number conversion cast (unumber) 1 in (byte) loop::sin_idx#1 ← (byte) loop::sin_idx#3 + (number) 1
Adding number conversion cast (unumber) $7f in *((const byte*) VIC_CONTROL) ← *((const byte*) VIC_CONTROL) & (number) $7f
Adding number conversion cast (unumber) 0 in *((const byte*) RASTER) ← (number) 0
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte) plex_show_idx ← (unumber)(number) 0
Inlining cast (byte) plex_sprite_idx ← (unumber)(number) 0
Inlining cast (byte) plex_sprite_msb ← (unumber)(number) 1
Inlining cast *((const byte*) PLEX_FREE_YPOS + (byte) plexSort::plexFreePrepare1_s#2) ← (unumber)(number) 0
Inlining cast (byte) plex_free_next ← (unumber)(number) 0
Inlining cast (byte) plex_sprite_msb ← (unumber)(number) 1
Inlining cast *((const byte*) D011) ← (unumber)(const byte) VIC_DEN|(const byte) VIC_RSEL|(unumber)(number) 3
Inlining cast *((const byte*) SPRITES_ENABLE) ← (unumber)(number) $ff
Inlining cast *((const byte*) BORDERCOL) ← (unumber)(number) 0
Inlining cast *((const byte*) RASTER) ← (unumber)(number) 0
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 53248
Simplifying constant pointer cast (byte*) 53249
Simplifying constant pointer cast (byte*) 53264
Simplifying constant pointer cast (byte*) 53266
Simplifying constant pointer cast (byte*) 53269
Simplifying constant pointer cast (byte*) 53280
Simplifying constant pointer cast (byte*) 53287
Simplifying constant pointer cast (byte*) 53265
Simplifying constant pointer cast (byte*) 53265
Simplifying constant pointer cast (byte*) 53273
Simplifying constant pointer cast (byte*) 53274
Simplifying constant pointer cast (byte*) 56333
Simplifying constant pointer cast (void()**) 788
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast $3f8
Simplifying constant integer cast 1
Simplifying constant integer cast 1
Simplifying constant integer cast 2
Simplifying constant integer cast 1
Simplifying constant integer cast $ff
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 2
Simplifying constant integer cast $15
Simplifying constant integer cast 1
Simplifying constant integer cast 7
Simplifying constant integer cast 0
Simplifying constant integer cast $ff
Simplifying constant integer cast 1
Simplifying constant integer cast 7
Simplifying constant integer cast 1
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast (const byte) VIC_DEN|(const byte) VIC_RSEL|(unumber)(number) 3
Simplifying constant integer cast 3
Simplifying constant integer cast $40
Simplifying constant integer cast 9
Simplifying constant integer cast 1
Simplifying constant integer cast $ff
Simplifying constant integer cast 2
Simplifying constant integer cast 0
Simplifying constant integer cast 8
Simplifying constant integer cast 1
Simplifying constant integer cast 1
Simplifying constant integer cast $7f
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (word) $3f8
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) $ff
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) $15
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 7
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $ff
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 7
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 3
Finalized unsigned number type (byte) $40
Finalized unsigned number type (byte) 9
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) $ff
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 8
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) $7f
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) plexSort::$1 ← (byte) plexSort::m#2 + (byte) 1
Inferred type updated to byte in (unumber~) plexSort::$4 ← (byte) plexSort::s#3 + (byte) 1
Inferred type updated to byte in (unumber~) plexShowSprite::$0 ← (byte) plex_sprite_idx * (byte) 2
Inferred type updated to byte in (unumber~) plexShowSprite::plexFreeAdd1_$0 ← (byte) plexShowSprite::plexFreeAdd1_ypos#1 + (byte) $15
Inferred type updated to byte in (unumber~) plexShowSprite::plexFreeAdd1_$1 ← (byte) plex_free_next + (byte) 1
Inferred type updated to byte in (unumber~) plexShowSprite::plexFreeAdd1_$2 ← (byte~) plexShowSprite::plexFreeAdd1_$1 & (byte) 7
Inferred type updated to byte in (unumber~) plexShowSprite::$9 ← (byte) $ff ^ (byte) plex_sprite_msb
Inferred type updated to byte in (unumber~) plexShowSprite::$5 ← (byte) plex_sprite_idx + (byte) 1
Inferred type updated to byte in (unumber~) plexShowSprite::$6 ← (byte~) plexShowSprite::$5 & (byte) 7
Inferred type updated to byte in (unumber~) plex_irq::$4 ← *((const byte*) RASTER) + (byte) 2
Inversing boolean not [25] (bool~) plexSort::$3 ← (byte) plexSort::nxt_y#0 >= *((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::m#2)) from [24] (bool~) plexSort::$2 ← (byte) plexSort::nxt_y#0 < *((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::m#2))
Inversing boolean not [86] (bool~) plexShowSprite::$8 ← (byte) plex_sprite_msb != (byte) 0 from [85] (bool~) plexShowSprite::$7 ← (byte) plex_sprite_msb == (byte) 0
Successful SSA optimization Pass2UnaryNotSimplification
Alias candidate removed (volatile)(byte) plex_free_next = (byte~) plexShowSprite::plexFreeAdd1_$2 
Alias candidate removed (volatile)(byte) plex_sprite_idx = (byte~) plexShowSprite::$6 
Alias (byte*) plexInit::plexSetScreen1_screen#0 = (byte*) plexInit::screen#1 (byte*) plexInit::plexSetScreen1_screen#1 
Alias (byte*) PLEX_SCREEN_PTR#1 = (byte*~) plexInit::plexSetScreen1_$0 (byte*) PLEX_SCREEN_PTR#22 
Alias (byte*) PLEX_SCREEN_PTR#15 = (byte*) PLEX_SCREEN_PTR#8 (byte*) PLEX_SCREEN_PTR#2 
Alias (byte) plexSort::m#2 = (byte) plexSort::m#4 (byte) plexSort::s#0 
Alias (byte) plexSort::nxt_y#0 = (byte) plexSort::nxt_y#2 
Alias (byte) plexSort::nxt_idx#0 = (byte) plexSort::nxt_idx#3 
Alias (byte) plexSort::s#1 = (byte) plexSort::s#4 
Alias (byte) plexSort::nxt_idx#1 = (byte) plexSort::nxt_idx#2 
Alias (byte) plexSort::m#5 = (byte) plexSort::m#6 
Alias (byte) plexShowSprite::plex_sprite_idx2#0 = (byte~) plexShowSprite::$0 (byte) plexShowSprite::plex_sprite_idx2#2 (byte) plexShowSprite::plex_sprite_idx2#1 
Alias (byte) plexShowSprite::plexFreeAdd1_ypos#0 = (byte) plexShowSprite::ypos#0 (byte) plexShowSprite::plexFreeAdd1_ypos#1 
Alias (byte*) PLEX_SCREEN_PTR#16 = (byte*) PLEX_SCREEN_PTR#23 (byte*) PLEX_SCREEN_PTR#9 
Alias (byte*) PLEX_SCREEN_PTR#0 = (byte*) PLEX_SCREEN_PTR#28 (byte*) PLEX_SCREEN_PTR#25 (byte*) PLEX_SCREEN_PTR#21 
Alias (byte*) PLEX_SCREEN_PTR#10 = (byte*) PLEX_SCREEN_PTR#3 (byte*) PLEX_SCREEN_PTR#18 (byte*) PLEX_SCREEN_PTR#11 (byte*) PLEX_SCREEN_PTR#4 
Alias (byte*) PLEX_SCREEN_PTR#12 = (byte*) PLEX_SCREEN_PTR#5 
Alias (byte*) PLEX_SCREEN_PTR#27 = (byte*) PLEX_SCREEN_PTR#29 
Alias (byte*) PLEX_SCREEN_PTR#13 = (byte*) PLEX_SCREEN_PTR#20 (byte*) PLEX_SCREEN_PTR#24 (byte*) PLEX_SCREEN_PTR#6 
Alias (byte*) PLEX_SCREEN_PTR#26 = (byte*) PLEX_SCREEN_PTR#34 (byte*) PLEX_SCREEN_PTR#33 (byte*) PLEX_SCREEN_PTR#32 (byte*) PLEX_SCREEN_PTR#31 
Alias (byte) plex_irq::plexFreeNextYpos1_return#0 = (byte) plex_irq::plexFreeNextYpos1_return#2 (byte) plex_irq::plexFreeNextYpos1_return#1 (byte) plex_irq::plexFreeNextYpos1_return#3 (byte~) plex_irq::$2 (byte) plex_irq::rasterY#1 (byte) plex_irq::rasterY#3 (byte) plex_irq::rasterY#2 
Alias (byte) loop::sin_idx#2 = (byte) loop::sin_idx#4 (byte) loop::y_idx#0 
Alias (byte) loop::sin_idx#3 = (byte) loop::sin_idx#5 
Alias (byte) loop::sin_idx#1 = (byte) loop::sin_idx#7 
Alias (byte*) PLEX_SCREEN_PTR#14 = (byte*) PLEX_SCREEN_PTR#7 
Successful SSA optimization Pass2AliasElimination
Alias candidate removed (volatile)(byte) plex_free_next = (byte~) plexShowSprite::plexFreeAdd1_$2 
Alias candidate removed (volatile)(byte) plex_sprite_idx = (byte~) plexShowSprite::$6 
Identical Phi Values (byte*) plexInit::plexSetScreen1_screen#0 (byte*) plexInit::screen#0
Identical Phi Values (byte*) PLEX_SCREEN_PTR#15 (byte*) PLEX_SCREEN_PTR#1
Identical Phi Values (byte) plexSort::nxt_y#1 (byte) plexSort::nxt_y#0
Identical Phi Values (byte) plexSort::nxt_idx#1 (byte) plexSort::nxt_idx#0
Identical Phi Values (byte) plexSort::m#5 (byte) plexSort::m#2
Identical Phi Values (byte*) PLEX_SCREEN_PTR#16 (byte*) PLEX_SCREEN_PTR#26
Identical Phi Values (byte*) PLEX_SCREEN_PTR#17 (byte*) PLEX_SCREEN_PTR#0
Identical Phi Values (byte*) PLEX_SCREEN_PTR#10 (byte*) PLEX_SCREEN_PTR#13
Identical Phi Values (byte*) PLEX_SCREEN_PTR#19 (byte*) PLEX_SCREEN_PTR#17
Identical Phi Values (byte*) PLEX_SCREEN_PTR#12 (byte*) PLEX_SCREEN_PTR#15
Identical Phi Values (byte*) PLEX_SCREEN_PTR#27 (byte*) PLEX_SCREEN_PTR#12
Identical Phi Values (byte*) PLEX_SCREEN_PTR#13 (byte*) PLEX_SCREEN_PTR#27
Identical Phi Values (byte*) PLEX_SCREEN_PTR#30 (byte*) PLEX_SCREEN_PTR#0
Identical Phi Values (byte*) PLEX_SCREEN_PTR#26 (byte*) PLEX_SCREEN_PTR#30
Identical Phi Values (byte) loop::sin_idx#2 (byte) loop::sin_idx#6
Identical Phi Values (byte) loop::sin_idx#3 (byte) loop::sin_idx#2
Identical Phi Values (byte*) PLEX_SCREEN_PTR#14 (byte*) PLEX_SCREEN_PTR#10
Successful SSA optimization Pass2IdenticalPhiElimination
Identical Phi Values (byte) plexSort::m#3 (byte) plexSort::m#2
Successful SSA optimization Pass2IdenticalPhiElimination
Identified duplicate assignment right side [73] (byte~) plexShowSprite::$11 ← (byte) plexShowSprite::xpos_idx#0 * (const byte) SIZEOF_WORD
Successful SSA optimization Pass2DuplicateRValueIdentification
Simple Condition (bool~) plexInit::$1 [11] if((byte) plexInit::i#1!=rangelast(0,PLEX_COUNT-1)) goto plexInit::@1
Simple Condition (bool~) plexSort::$3 [19] if((byte) plexSort::nxt_y#0>=*((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::m#2))) goto plexSort::@2
Simple Condition (bool~) plexSort::$8 [23] if((byte) plexSort::m#1!=rangelast(0,PLEX_COUNT-2)) goto plexSort::@1
Simple Condition (bool~) plexSort::plexFreePrepare1_$0 [42] if((byte) plexSort::plexFreePrepare1_s#1!=rangelast(0,7)) goto plexSort::plexFreePrepare1_@1
Simple Condition (bool~) plexShowSprite::$4 [62] if((byte~) plexShowSprite::$3!=(byte) 0) goto plexShowSprite::@1
Simple Condition (bool~) plexShowSprite::$8 [72] if((byte) plex_sprite_msb!=(byte) 0) goto plexShowSprite::@return
Simple Condition (bool~) init::$1 [96] if((byte) init::sx#1!=rangelast(0,PLEX_COUNT-1)) goto init::@1
Simple Condition (bool~) init::$2 [103] if((byte) init::ss#1!=rangelast(0,7)) goto init::@3
Simple Condition (bool~) plex_irq::$0 [125] if((byte) plex_show_idx<(const byte) PLEX_COUNT) goto plex_irq::@1
Simple Condition (bool~) loop::$1 [143] if((byte) loop::sy#1!=rangelast(0,PLEX_COUNT-1)) goto loop::@10
Successful SSA optimization Pass2ConditionalJumpSimplification
Rewriting && if()-condition to two if()s [30] (bool~) plexSort::$7 ← (bool~) plexSort::$5 && (bool~) plexSort::$6
Rewriting && if()-condition to two if()s [121] (bool~) plex_irq::$6 ← (bool~) plex_irq::$3 && (bool~) plex_irq::$5
Rewriting ! if()-condition to reversed if() [134] (bool~) loop::$0 ← ! (bool) framedone
Successful SSA optimization Pass2ConditionalAndOrRewriting
Constant (const byte*) PLEX_SCREEN_PTR#0 = (byte*)$400+$3f8
Constant (const byte) plexInit::i#0 = 0
Constant (const byte) plexSort::m#0 = 0
Constant (const byte) plexSort::plexFreePrepare1_s#0 = 0
Constant (const byte*) plexInit::screen#0 = SCREEN
Constant (const word) init::xp#0 = $20
Constant (const byte) init::sx#0 = 0
Constant (const byte) init::ss#0 = 0
Constant (const byte) plex_irq::rasterY#0 = 0
Constant (const byte) loop::sin_idx#0 = 0
Constant (const byte) loop::sy#0 = 0
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [132] if(true) goto loop::@4
Successful SSA optimization Pass2ConstantIfs
Resolved ranged next value [9] plexInit::i#1 ← ++ plexInit::i#2 to ++
Resolved ranged comparison value [11] if(plexInit::i#1!=rangelast(0,PLEX_COUNT-1)) goto plexInit::@1 to (const byte) PLEX_COUNT-(byte) 1+(number) 1
Resolved ranged next value [21] plexSort::m#1 ← ++ plexSort::m#2 to ++
Resolved ranged comparison value [23] if(plexSort::m#1!=rangelast(0,PLEX_COUNT-2)) goto plexSort::@1 to (const byte) PLEX_COUNT-(byte) 2+(number) 1
Resolved ranged next value [40] plexSort::plexFreePrepare1_s#1 ← ++ plexSort::plexFreePrepare1_s#2 to ++
Resolved ranged comparison value [42] if(plexSort::plexFreePrepare1_s#1!=rangelast(0,7)) goto plexSort::plexFreePrepare1_@1 to (number) 8
Resolved ranged next value [94] init::sx#1 ← ++ init::sx#2 to ++
Resolved ranged comparison value [96] if(init::sx#1!=rangelast(0,PLEX_COUNT-1)) goto init::@1 to (const byte) PLEX_COUNT-(byte) 1+(number) 1
Resolved ranged next value [101] init::ss#1 ← ++ init::ss#2 to ++
Resolved ranged comparison value [103] if(init::ss#1!=rangelast(0,7)) goto init::@3 to (number) 8
Resolved ranged next value [141] loop::sy#1 ← ++ loop::sy#2 to ++
Resolved ranged comparison value [143] if(loop::sy#1!=rangelast(0,PLEX_COUNT-1)) goto loop::@10 to (const byte) PLEX_COUNT-(byte) 1+(number) 1
Eliminating unused variable (byte*) PLEX_SCREEN_PTR#1 and assignment [3] (byte*) PLEX_SCREEN_PTR#1 ← (const byte*) plexInit::screen#0 + (word) $3f8
Eliminating unused constant (const byte) plex_irq::rasterY#0
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused constant (const byte*) plexInit::screen#0
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused constant (const byte*) SCREEN
Successful SSA optimization PassNEliminateUnusedVars
Removing unused block loop::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Adding number conversion cast (unumber) PLEX_COUNT-1+1 in if((byte) plexInit::i#1!=(const byte) PLEX_COUNT-(byte) 1+(number) 1) goto plexInit::@1
Adding number conversion cast (unumber) 1 in if((byte) plexInit::i#1!=(unumber)(const byte) PLEX_COUNT-(byte) 1+(number) 1) goto plexInit::@1
Adding number conversion cast (unumber) PLEX_COUNT-2+1 in if((byte) plexSort::m#1!=(const byte) PLEX_COUNT-(byte) 2+(number) 1) goto plexSort::@1
Adding number conversion cast (unumber) 1 in if((byte) plexSort::m#1!=(unumber)(const byte) PLEX_COUNT-(byte) 2+(number) 1) goto plexSort::@1
Adding number conversion cast (unumber) 8 in if((byte) plexSort::plexFreePrepare1_s#1!=(number) 8) goto plexSort::plexFreePrepare1_@1
Adding number conversion cast (unumber) PLEX_COUNT-1+1 in if((byte) init::sx#1!=(const byte) PLEX_COUNT-(byte) 1+(number) 1) goto init::@1
Adding number conversion cast (unumber) 1 in if((byte) init::sx#1!=(unumber)(const byte) PLEX_COUNT-(byte) 1+(number) 1) goto init::@1
Adding number conversion cast (unumber) 8 in if((byte) init::ss#1!=(number) 8) goto init::@3
Adding number conversion cast (unumber) PLEX_COUNT-1+1 in if((byte) loop::sy#1!=(const byte) PLEX_COUNT-(byte) 1+(number) 1) goto loop::@10
Adding number conversion cast (unumber) 1 in if((byte) loop::sy#1!=(unumber)(const byte) PLEX_COUNT-(byte) 1+(number) 1) goto loop::@10
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast (const byte) PLEX_COUNT-(byte) 1+(unumber)(number) 1
Simplifying constant integer cast 1
Simplifying constant integer cast (const byte) PLEX_COUNT-(byte) 2+(unumber)(number) 1
Simplifying constant integer cast 1
Simplifying constant integer cast 8
Simplifying constant integer cast (const byte) PLEX_COUNT-(byte) 1+(unumber)(number) 1
Simplifying constant integer cast 1
Simplifying constant integer cast 8
Simplifying constant integer cast (const byte) PLEX_COUNT-(byte) 1+(unumber)(number) 1
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 8
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 8
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias candidate removed (volatile)(byte) plex_free_next = (byte~) plexShowSprite::plexFreeAdd1_$2 
Alias candidate removed (volatile)(byte) plex_sprite_idx = (byte~) plexShowSprite::$6 
Alias (byte~) plexShowSprite::$11 = (byte~) plexShowSprite::$10 
Successful SSA optimization Pass2AliasElimination
Alias candidate removed (volatile)(byte) plex_free_next = (byte~) plexShowSprite::plexFreeAdd1_$2 
Alias candidate removed (volatile)(byte) plex_sprite_idx = (byte~) plexShowSprite::$6 
Simple Condition (bool~) plexSort::$5 [21] if((byte) plexSort::s#1!=(byte) $ff) goto plexSort::@8
Simple Condition (bool~) plex_irq::$3 [92] if((byte) plex_show_idx<(const byte) PLEX_COUNT) goto plex_irq::@9
Simple Condition (bool~) plexSort::$6 [115] if((byte) plexSort::nxt_y#0<*((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#1))) goto plexSort::@3
Simple Condition (bool~) plex_irq::$5 [116] if((byte) plex_irq::plexFreeNextYpos1_return#0<(byte~) plex_irq::$4) goto plex_irq::@3
Successful SSA optimization Pass2ConditionalJumpSimplification
Negating conditional jump and destination [21] if((byte) plexSort::s#1==(byte) $ff) goto plexSort::@4
Negating conditional jump and destination [92] if((byte) plex_show_idx>=(const byte) PLEX_COUNT) goto plex_irq::@4
Successful SSA optimization Pass2ConditionalJumpSequenceImprovement
Alias candidate removed (volatile)(byte) plex_free_next = (byte~) plexShowSprite::plexFreeAdd1_$2 
Alias candidate removed (volatile)(byte) plex_sprite_idx = (byte~) plexShowSprite::$6 
Rewriting multiplication to use shift [31] (byte) plexShowSprite::plex_sprite_idx2#0 ← (byte) plex_sprite_idx * (byte) 2
Rewriting multiplication to use shift [41] (byte~) plexShowSprite::$11 ← (byte) plexShowSprite::xpos_idx#0 * (const byte) SIZEOF_WORD
Rewriting multiplication to use shift [66] (byte~) init::$3 ← (byte) init::sx#2 * (const byte) SIZEOF_WORD
Successful SSA optimization Pass2MultiplyToShiftRewriting
Inlining constant with var siblings (const byte) plexInit::i#0
Inlining constant with var siblings (const byte) plexSort::m#0
Inlining constant with var siblings (const byte) plexSort::plexFreePrepare1_s#0
Inlining constant with var siblings (const word) init::xp#0
Inlining constant with var siblings (const byte) init::sx#0
Inlining constant with var siblings (const byte) init::ss#0
Inlining constant with var siblings (const byte) loop::sin_idx#0
Inlining constant with var siblings (const byte) loop::sy#0
Constant inlined init::xp#0 = (word) $20
Constant inlined loop::sy#0 = (byte) 0
Constant inlined init::sx#0 = (byte) 0
Constant inlined plexSort::plexFreePrepare1_s#0 = (byte) 0
Constant inlined init::ss#0 = (byte) 0
Constant inlined plexInit::i#0 = (byte) 0
Constant inlined plexSort::m#0 = (byte) 0
Constant inlined loop::sin_idx#0 = (byte) 0
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in assignment *(PLEX_SORTED_IDX+1 + plexSort::$1)
Consolidated array index constant in assignment *(PLEX_SORTED_IDX+1 + plexSort::$4)
Successful SSA optimization Pass2ConstantAdditionElimination
Alias candidate removed (volatile)(byte) plex_free_next = (byte~) plexShowSprite::plexFreeAdd1_$2 
Alias candidate removed (volatile)(byte) plex_sprite_idx = (byte~) plexShowSprite::$6 
Alias (byte) plexSort::m#2 = (byte~) plexSort::$1 
Alias (byte) plexSort::s#3 = (byte~) plexSort::$4 
Successful SSA optimization Pass2AliasElimination
Alias candidate removed (volatile)(byte) plex_free_next = (byte~) plexShowSprite::plexFreeAdd1_$2 
Alias candidate removed (volatile)(byte) plex_sprite_idx = (byte~) plexShowSprite::$6 
Eliminating unused constant (const byte) SIZEOF_WORD
Successful SSA optimization PassNEliminateUnusedVars
Alias candidate removed (volatile)(byte) plex_free_next = (byte~) plexShowSprite::plexFreeAdd1_$2 
Alias candidate removed (volatile)(byte) plex_sprite_idx = (byte~) plexShowSprite::$6 
Added new block during phi lifting plexInit::@4(between plexInit::@1 and plexInit::@1)
Added new block during phi lifting plexSort::@9(between plexSort::@2 and plexSort::@1)
Added new block during phi lifting plexSort::@10(between plexSort::@8 and plexSort::@3)
Added new block during phi lifting plexSort::@11(between plexSort::plexFreePrepare1_@1 and plexSort::plexFreePrepare1_@1)
Added new block during phi lifting init::@6(between init::@1 and init::@1)
Added new block during phi lifting init::@7(between init::@3 and init::@3)
Added new block during phi lifting loop::@16(between loop::@10 and loop::@10)
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @16
Adding NOP phi() at start of @17
Adding NOP phi() at start of @end
Adding NOP phi() at start of main::@1
Adding NOP phi() at start of main::@2
Adding NOP phi() at start of loop
Adding NOP phi() at start of plexSort
Adding NOP phi() at start of plexSort::plexFreePrepare1
Adding NOP phi() at start of init::@5
Adding NOP phi() at start of plexInit
Adding NOP phi() at start of plexInit::plexSetScreen1
Adding NOP phi() at start of plexInit::@3
Adding NOP phi() at start of plex_irq::@3
Adding NOP phi() at start of plex_irq::@8
Adding NOP phi() at start of plex_irq::plexFreeNextYpos1_@return
CALL GRAPH
Calls in [] to main:7 
Calls in [main] to init:11 loop:13 
Calls in [loop] to plexSort:28 
Calls in [init] to plexInit:65 
Calls in [plex_irq] to plexShowSprite:100 

Created 10 initial phi equivalence classes
Not coalescing [20] loop::y_idx#4 ← loop::sin_idx#6
Coalesced [33] loop::sin_idx#8 ← loop::sin_idx#1
Coalesced [34] loop::y_idx#3 ← loop::y_idx#1
Coalesced [35] loop::sy#3 ← loop::sy#1
Not coalescing [41] plexSort::s#6 ← plexSort::m#2
Coalesced [61] plexSort::plexFreePrepare1_s#3 ← plexSort::plexFreePrepare1_s#1
Coalesced [62] plexSort::m#7 ← plexSort::m#1
Coalesced [63] plexSort::s#5 ← plexSort::s#1
Coalesced [86] init::ss#3 ← init::ss#1
Coalesced [87] init::sx#3 ← init::sx#1
Coalesced [88] init::xp#3 ← init::xp#1
Coalesced [97] plexInit::i#3 ← plexInit::i#1
Coalesced down to 10 phi equivalence classes
Culled Empty Block (label) @17
Culled Empty Block (label) main::@2
Culled Empty Block (label) loop::@16
Culled Empty Block (label) plexSort::@11
Culled Empty Block (label) plexSort::@9
Culled Empty Block (label) plexSort::@10
Culled Empty Block (label) init::@5
Culled Empty Block (label) init::@7
Culled Empty Block (label) init::@6
Culled Empty Block (label) plexInit::@3
Culled Empty Block (label) plexInit::@4
Culled Empty Block (label) plex_irq::@8
Culled Empty Block (label) plex_irq::plexFreeNextYpos1_@return
Renumbering block @4 to @1
Renumbering block @9 to @2
Renumbering block @14 to @3
Renumbering block @16 to @4
Renumbering block plexSort::@8 to plexSort::@7
Renumbering block plexShowSprite::@4 to plexShowSprite::@3
Renumbering block plexShowSprite::@6 to plexShowSprite::@4
Renumbering block plexShowSprite::@7 to plexShowSprite::@5
Renumbering block plex_irq::@7 to plex_irq::@6
Renumbering block plex_irq::@9 to plex_irq::@7
Renumbering block loop::@4 to loop::@2
Renumbering block loop::@6 to loop::@3
Renumbering block loop::@10 to loop::@4
Renumbering block loop::@11 to loop::@5
Renumbering block loop::@15 to loop::@6
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @4
Adding NOP phi() at start of @end
Adding NOP phi() at start of main::@1
Adding NOP phi() at start of loop
Adding NOP phi() at start of plexSort
Adding NOP phi() at start of plexSort::plexFreePrepare1
Adding NOP phi() at start of plexInit
Adding NOP phi() at start of plexInit::plexSetScreen1
Adding NOP phi() at start of plex_irq::@3

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi()
  to:@1
@1: scope:[]  from @begin
  [1] (byte) plex_show_idx ← (byte) 0
  [2] (byte) plex_sprite_idx ← (byte) 0
  [3] (byte) plex_sprite_msb ← (byte) 1
  to:@2
@2: scope:[]  from @1
  [4] (byte) plex_free_next ← (byte) 0
  to:@3
@3: scope:[]  from @2
  [5] (bool) framedone ← true
  to:@4
@4: scope:[]  from @3
  [6] phi()
  [7] call main 
  to:@end
@end: scope:[]  from @4
  [8] phi()

(void()) main()
main: scope:[main]  from @4
  asm { sei  }
  [10] call init 
  to:main::@1
main::@1: scope:[main]  from main
  [11] phi()
  [12] call loop 
  to:main::@return
main::@return: scope:[main]  from main::@1
  [13] return 
  to:@return

(void()) loop()
loop: scope:[loop]  from main::@1
  [14] phi()
  to:loop::@1
loop::@1: scope:[loop]  from loop loop::@6
  [15] (byte) loop::sin_idx#6 ← phi( loop/(byte) 0 loop::@6/(byte) loop::sin_idx#1 )
  to:loop::@2
loop::@2: scope:[loop]  from loop::@1 loop::@2
  [16] if((bool) framedone) goto loop::@3
  to:loop::@2
loop::@3: scope:[loop]  from loop::@2
  [17] *((const byte*) BORDERCOL) ← (const byte) RED
  [18] (byte) loop::y_idx#4 ← (byte) loop::sin_idx#6
  to:loop::@4
loop::@4: scope:[loop]  from loop::@3 loop::@4
  [19] (byte) loop::sy#2 ← phi( loop::@4/(byte) loop::sy#1 loop::@3/(byte) 0 )
  [19] (byte) loop::y_idx#2 ← phi( loop::@4/(byte) loop::y_idx#1 loop::@3/(byte) loop::y_idx#4 )
  [20] *((const byte*) PLEX_YPOS + (byte) loop::sy#2) ← *((const byte*) YSIN + (byte) loop::y_idx#2)
  [21] (byte) loop::y_idx#1 ← (byte) loop::y_idx#2 + (byte) 8
  [22] (byte) loop::sy#1 ← ++ (byte) loop::sy#2
  [23] if((byte) loop::sy#1!=(const byte) PLEX_COUNT-(byte) 1+(byte) 1) goto loop::@4
  to:loop::@5
loop::@5: scope:[loop]  from loop::@4
  [24] (byte) loop::sin_idx#1 ← (byte) loop::sin_idx#6 + (byte) 1
  [25] *((const byte*) BORDERCOL) ← ++ *((const byte*) BORDERCOL)
  [26] call plexSort 
  to:loop::@6
loop::@6: scope:[loop]  from loop::@5
  [27] *((const byte*) BORDERCOL) ← (const byte) GREEN
  [28] (bool) framedone ← false
  [29] *((const byte*) VIC_CONTROL) ← *((const byte*) VIC_CONTROL) & (byte) $7f
  [30] *((const byte*) RASTER) ← (byte) 0
  to:loop::@1

(void()) plexSort()
plexSort: scope:[plexSort]  from loop::@5
  [31] phi()
  to:plexSort::@1
plexSort::@1: scope:[plexSort]  from plexSort plexSort::@2
  [32] (byte) plexSort::m#2 ← phi( plexSort/(byte) 0 plexSort::@2/(byte) plexSort::m#1 )
  [33] (byte) plexSort::nxt_idx#0 ← *((const byte*) PLEX_SORTED_IDX+(byte) 1 + (byte) plexSort::m#2)
  [34] (byte) plexSort::nxt_y#0 ← *((const byte*) PLEX_YPOS + (byte) plexSort::nxt_idx#0)
  [35] if((byte) plexSort::nxt_y#0>=*((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::m#2))) goto plexSort::@2
  to:plexSort::@5
plexSort::@5: scope:[plexSort]  from plexSort::@1
  [36] (byte) plexSort::s#6 ← (byte) plexSort::m#2
  to:plexSort::@3
plexSort::@3: scope:[plexSort]  from plexSort::@5 plexSort::@7
  [37] (byte) plexSort::s#3 ← phi( plexSort::@7/(byte) plexSort::s#1 plexSort::@5/(byte) plexSort::s#6 )
  [38] *((const byte*) PLEX_SORTED_IDX+(byte) 1 + (byte) plexSort::s#3) ← *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#3)
  [39] (byte) plexSort::s#1 ← -- (byte) plexSort::s#3
  [40] if((byte) plexSort::s#1==(byte) $ff) goto plexSort::@4
  to:plexSort::@7
plexSort::@7: scope:[plexSort]  from plexSort::@3
  [41] if((byte) plexSort::nxt_y#0<*((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#1))) goto plexSort::@3
  to:plexSort::@4
plexSort::@4: scope:[plexSort]  from plexSort::@3 plexSort::@7
  [42] (byte) plexSort::s#2 ← ++ (byte) plexSort::s#1
  [43] *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#2) ← (byte) plexSort::nxt_idx#0
  to:plexSort::@2
plexSort::@2: scope:[plexSort]  from plexSort::@1 plexSort::@4
  [44] (byte) plexSort::m#1 ← ++ (byte) plexSort::m#2
  [45] if((byte) plexSort::m#1!=(const byte) PLEX_COUNT-(byte) 2+(byte) 1) goto plexSort::@1
  to:plexSort::@6
plexSort::@6: scope:[plexSort]  from plexSort::@2
  [46] (byte) plex_show_idx ← (byte) 0
  [47] (byte) plex_sprite_idx ← (byte) 0
  [48] (byte) plex_sprite_msb ← (byte) 1
  to:plexSort::plexFreePrepare1
plexSort::plexFreePrepare1: scope:[plexSort]  from plexSort::@6
  [49] phi()
  to:plexSort::plexFreePrepare1_@1
plexSort::plexFreePrepare1_@1: scope:[plexSort]  from plexSort::plexFreePrepare1 plexSort::plexFreePrepare1_@1
  [50] (byte) plexSort::plexFreePrepare1_s#2 ← phi( plexSort::plexFreePrepare1/(byte) 0 plexSort::plexFreePrepare1_@1/(byte) plexSort::plexFreePrepare1_s#1 )
  [51] *((const byte*) PLEX_FREE_YPOS + (byte) plexSort::plexFreePrepare1_s#2) ← (byte) 0
  [52] (byte) plexSort::plexFreePrepare1_s#1 ← ++ (byte) plexSort::plexFreePrepare1_s#2
  [53] if((byte) plexSort::plexFreePrepare1_s#1!=(byte) 8) goto plexSort::plexFreePrepare1_@1
  to:plexSort::plexFreePrepare1_@2
plexSort::plexFreePrepare1_@2: scope:[plexSort]  from plexSort::plexFreePrepare1_@1
  [54] (byte) plex_free_next ← (byte) 0
  to:plexSort::@return
plexSort::@return: scope:[plexSort]  from plexSort::plexFreePrepare1_@2
  [55] return 
  to:@return

(void()) init()
init: scope:[init]  from main
  [56] *((const byte*) D011) ← (const byte) VIC_DEN|(const byte) VIC_RSEL|(byte) 3
  [57] call plexInit 
  to:init::@1
init::@1: scope:[init]  from init init::@1
  [58] (word) init::xp#2 ← phi( init::@1/(word) init::xp#1 init/(word) $20 )
  [58] (byte) init::sx#2 ← phi( init::@1/(byte) init::sx#1 init/(byte) 0 )
  [59] *((const byte*) PLEX_PTR + (byte) init::sx#2) ← (byte)(const byte*) SPRITE/(byte) $40
  [60] (byte~) init::$3 ← (byte) init::sx#2 << (byte) 1
  [61] *((const word*) PLEX_XPOS + (byte~) init::$3) ← (word) init::xp#2
  [62] (word) init::xp#1 ← (word) init::xp#2 + (byte) 9
  [63] (byte) init::sx#1 ← ++ (byte) init::sx#2
  [64] if((byte) init::sx#1!=(const byte) PLEX_COUNT-(byte) 1+(byte) 1) goto init::@1
  to:init::@2
init::@2: scope:[init]  from init::@1
  [65] *((const byte*) SPRITES_ENABLE) ← (byte) $ff
  to:init::@3
init::@3: scope:[init]  from init::@2 init::@3
  [66] (byte) init::ss#2 ← phi( init::@2/(byte) 0 init::@3/(byte) init::ss#1 )
  [67] *((const byte*) SPRITES_COLS + (byte) init::ss#2) ← (const byte) GREEN
  [68] (byte) init::ss#1 ← ++ (byte) init::ss#2
  [69] if((byte) init::ss#1!=(byte) 8) goto init::@3
  to:init::@4
init::@4: scope:[init]  from init::@3
  asm { sei  }
  [71] *((const byte*) CIA1_INTERRUPT) ← (const byte) CIA_INTERRUPT_CLEAR
  [72] *((const byte*) IRQ_ENABLE) ← (const byte) IRQ_RASTER
  [73] *((const byte*) IRQ_STATUS) ← (const byte) IRQ_RASTER
  [74] *((const void()**) KERNEL_IRQ) ← &interrupt(KERNEL_MIN)(void()) plex_irq()
  asm { cli  }
  to:init::@return
init::@return: scope:[init]  from init::@4
  [76] return 
  to:@return

(void()) plexInit((byte*) plexInit::screen)
plexInit: scope:[plexInit]  from init
  [77] phi()
  to:plexInit::plexSetScreen1
plexInit::plexSetScreen1: scope:[plexInit]  from plexInit
  [78] phi()
  to:plexInit::@1
plexInit::@1: scope:[plexInit]  from plexInit::@1 plexInit::plexSetScreen1
  [79] (byte) plexInit::i#2 ← phi( plexInit::@1/(byte) plexInit::i#1 plexInit::plexSetScreen1/(byte) 0 )
  [80] *((const byte*) PLEX_SORTED_IDX + (byte) plexInit::i#2) ← (byte) plexInit::i#2
  [81] (byte) plexInit::i#1 ← ++ (byte) plexInit::i#2
  [82] if((byte) plexInit::i#1!=(const byte) PLEX_COUNT-(byte) 1+(byte) 1) goto plexInit::@1
  to:plexInit::@return
plexInit::@return: scope:[plexInit]  from plexInit::@1
  [83] return 
  to:@return

interrupt(KERNEL_MIN)(void()) plex_irq()
plex_irq: scope:[plex_irq]  from
  [84] *((const byte*) BORDERCOL) ← (const byte) WHITE
  to:plex_irq::@3
plex_irq::@3: scope:[plex_irq]  from plex_irq plex_irq::@7
  [85] phi()
  [86] call plexShowSprite 
  to:plex_irq::plexFreeNextYpos1
plex_irq::plexFreeNextYpos1: scope:[plex_irq]  from plex_irq::@3
  [87] (byte) plex_irq::plexFreeNextYpos1_return#0 ← *((const byte*) PLEX_FREE_YPOS + (byte) plex_free_next)
  to:plex_irq::@6
plex_irq::@6: scope:[plex_irq]  from plex_irq::plexFreeNextYpos1
  [88] (byte~) plex_irq::$4 ← *((const byte*) RASTER) + (byte) 2
  [89] if((byte) plex_show_idx>=(const byte) PLEX_COUNT) goto plex_irq::@4
  to:plex_irq::@7
plex_irq::@7: scope:[plex_irq]  from plex_irq::@6
  [90] if((byte) plex_irq::plexFreeNextYpos1_return#0<(byte~) plex_irq::$4) goto plex_irq::@3
  to:plex_irq::@4
plex_irq::@4: scope:[plex_irq]  from plex_irq::@6 plex_irq::@7
  [91] *((const byte*) IRQ_STATUS) ← (const byte) IRQ_RASTER
  [92] if((byte) plex_show_idx<(const byte) PLEX_COUNT) goto plex_irq::@1
  to:plex_irq::@5
plex_irq::@5: scope:[plex_irq]  from plex_irq::@4
  [93] (bool) framedone ← true
  to:plex_irq::@2
plex_irq::@2: scope:[plex_irq]  from plex_irq::@1 plex_irq::@5
  [94] *((const byte*) BORDERCOL) ← (byte) 0
  to:plex_irq::@return
plex_irq::@return: scope:[plex_irq]  from plex_irq::@2
  [95] return 
  to:@return
plex_irq::@1: scope:[plex_irq]  from plex_irq::@4
  [96] *((const byte*) RASTER) ← (byte) plex_irq::plexFreeNextYpos1_return#0
  to:plex_irq::@2

(void()) plexShowSprite()
plexShowSprite: scope:[plexShowSprite]  from plex_irq::@3
  [97] (byte) plexShowSprite::plex_sprite_idx2#0 ← (byte) plex_sprite_idx << (byte) 1
  [98] (byte) plexShowSprite::plexFreeAdd1_ypos#0 ← *((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx))
  [99] *((const byte*) SPRITES_YPOS + (byte) plexShowSprite::plex_sprite_idx2#0) ← (byte) plexShowSprite::plexFreeAdd1_ypos#0
  to:plexShowSprite::plexFreeAdd1
plexShowSprite::plexFreeAdd1: scope:[plexShowSprite]  from plexShowSprite
  [100] (byte~) plexShowSprite::plexFreeAdd1_$0 ← (byte) plexShowSprite::plexFreeAdd1_ypos#0 + (byte) $15
  [101] *((const byte*) PLEX_FREE_YPOS + (byte) plex_free_next) ← (byte~) plexShowSprite::plexFreeAdd1_$0
  [102] (byte~) plexShowSprite::plexFreeAdd1_$1 ← (byte) plex_free_next + (byte) 1
  [103] (byte~) plexShowSprite::plexFreeAdd1_$2 ← (byte~) plexShowSprite::plexFreeAdd1_$1 & (byte) 7
  [104] (byte) plex_free_next ← (byte~) plexShowSprite::plexFreeAdd1_$2
  to:plexShowSprite::@5
plexShowSprite::@5: scope:[plexShowSprite]  from plexShowSprite::plexFreeAdd1
  [105] *((const byte*) PLEX_SCREEN_PTR#0 + (byte) plex_sprite_idx) ← *((const byte*) PLEX_PTR + *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx))
  [106] (byte) plexShowSprite::xpos_idx#0 ← *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx)
  [107] (byte~) plexShowSprite::$11 ← (byte) plexShowSprite::xpos_idx#0 << (byte) 1
  [108] (byte~) plexShowSprite::$2 ← < *((const word*) PLEX_XPOS + (byte~) plexShowSprite::$11)
  [109] *((const byte*) SPRITES_XPOS + (byte) plexShowSprite::plex_sprite_idx2#0) ← (byte~) plexShowSprite::$2
  [110] (byte~) plexShowSprite::$3 ← > *((const word*) PLEX_XPOS + (byte~) plexShowSprite::$11)
  [111] if((byte~) plexShowSprite::$3!=(byte) 0) goto plexShowSprite::@1
  to:plexShowSprite::@3
plexShowSprite::@3: scope:[plexShowSprite]  from plexShowSprite::@5
  [112] (byte~) plexShowSprite::$9 ← (byte) $ff ^ (byte) plex_sprite_msb
  [113] *((const byte*) SPRITES_XMSB) ← *((const byte*) SPRITES_XMSB) & (byte~) plexShowSprite::$9
  to:plexShowSprite::@2
plexShowSprite::@2: scope:[plexShowSprite]  from plexShowSprite::@1 plexShowSprite::@3
  [114] (byte~) plexShowSprite::$5 ← (byte) plex_sprite_idx + (byte) 1
  [115] (byte~) plexShowSprite::$6 ← (byte~) plexShowSprite::$5 & (byte) 7
  [116] (byte) plex_sprite_idx ← (byte~) plexShowSprite::$6
  [117] (byte) plex_show_idx ← ++ (byte) plex_show_idx
  [118] (byte) plex_sprite_msb ← (byte) plex_sprite_msb << (byte) 1
  [119] if((byte) plex_sprite_msb!=(byte) 0) goto plexShowSprite::@return
  to:plexShowSprite::@4
plexShowSprite::@4: scope:[plexShowSprite]  from plexShowSprite::@2
  [120] (byte) plex_sprite_msb ← (byte) 1
  to:plexShowSprite::@return
plexShowSprite::@return: scope:[plexShowSprite]  from plexShowSprite::@2 plexShowSprite::@4
  [121] return 
  to:@return
plexShowSprite::@1: scope:[plexShowSprite]  from plexShowSprite::@5
  [122] *((const byte*) SPRITES_XMSB) ← *((const byte*) SPRITES_XMSB) | (byte) plex_sprite_msb
  to:plexShowSprite::@2


VARIABLE REGISTER WEIGHTS
(byte*) PLEX_SCREEN_PTR
(bool) framedone loadstore 10.545454545454545
(void()) init()
(byte~) init::$3 22.0
(byte) init::ss
(byte) init::ss#1 16.5
(byte) init::ss#2 16.5
(byte) init::sx
(byte) init::sx#1 16.5
(byte) init::sx#2 8.8
(word) init::xp
(word) init::xp#1 7.333333333333333
(word) init::xp#2 8.25
(void()) loop()
(byte) loop::sin_idx
(byte) loop::sin_idx#1 3.142857142857143
(byte) loop::sin_idx#6 3.666666666666667
(byte) loop::sy
(byte) loop::sy#1 151.5
(byte) loop::sy#2 101.0
(byte) loop::y_idx
(byte) loop::y_idx#1 67.33333333333333
(byte) loop::y_idx#2 157.0
(byte) loop::y_idx#4 22.0
(void()) main()
(void()) plexInit((byte*) plexInit::screen)
(byte) plexInit::i
(byte) plexInit::i#1 16.5
(byte) plexInit::i#2 22.0
(byte*) plexInit::plexSetScreen1_screen
(byte*) plexInit::screen
(void()) plexShowSprite()
(byte~) plexShowSprite::$11 2.0
(byte~) plexShowSprite::$2 4.0
(byte~) plexShowSprite::$3 4.0
(byte~) plexShowSprite::$5 4.0
(byte~) plexShowSprite::$6 4.0
(byte~) plexShowSprite::$9 4.0
(byte~) plexShowSprite::plexFreeAdd1_$0 4.0
(byte~) plexShowSprite::plexFreeAdd1_$1 4.0
(byte~) plexShowSprite::plexFreeAdd1_$2 4.0
(byte) plexShowSprite::plexFreeAdd1_ypos
(byte) plexShowSprite::plexFreeAdd1_ypos#0 3.0
(byte) plexShowSprite::plex_sprite_idx2
(byte) plexShowSprite::plex_sprite_idx2#0 0.5
(byte) plexShowSprite::xpos_idx
(byte) plexShowSprite::xpos_idx#0 4.0
(byte) plexShowSprite::ypos
(void()) plexSort()
(byte) plexSort::m
(byte) plexSort::m#1 151.5
(byte) plexSort::m#2 42.08333333333333
(byte) plexSort::nxt_idx
(byte) plexSort::nxt_idx#0 30.299999999999997
(byte) plexSort::nxt_y
(byte) plexSort::nxt_y#0 150.375
(byte) plexSort::plexFreePrepare1_s
(byte) plexSort::plexFreePrepare1_s#1 151.5
(byte) plexSort::plexFreePrepare1_s#2 151.5
(byte) plexSort::s
(byte) plexSort::s#1 1368.3333333333335
(byte) plexSort::s#2 202.0
(byte) plexSort::s#3 2052.5
(byte) plexSort::s#6 202.0
(byte) plex_free_next loadstore 0.6774193548387095
interrupt(KERNEL_MIN)(void()) plex_irq()
(byte~) plex_irq::$4 11.0
(byte) plex_irq::plexFreeNextYpos1_return
(byte) plex_irq::plexFreeNextYpos1_return#0 4.0
(byte) plex_irq::rasterY
(byte) plex_show_idx loadstore 0.7941176470588236
(byte) plex_sprite_idx loadstore 0.3870967741935484
(byte) plex_sprite_msb loadstore 0.48484848484848486

Initial phi equivalence classes
[ loop::sin_idx#6 loop::sin_idx#1 ]
[ loop::y_idx#2 loop::y_idx#1 loop::y_idx#4 ]
[ loop::sy#2 loop::sy#1 ]
[ plexSort::m#2 plexSort::m#1 ]
[ plexSort::s#3 plexSort::s#1 plexSort::s#6 ]
[ plexSort::plexFreePrepare1_s#2 plexSort::plexFreePrepare1_s#1 ]
[ init::sx#2 init::sx#1 ]
[ init::xp#2 init::xp#1 ]
[ init::ss#2 init::ss#1 ]
[ plexInit::i#2 plexInit::i#1 ]
Added variable plex_show_idx to live range equivalence class [ plex_show_idx ]
Added variable plex_sprite_idx to live range equivalence class [ plex_sprite_idx ]
Added variable plex_sprite_msb to live range equivalence class [ plex_sprite_msb ]
Added variable plex_free_next to live range equivalence class [ plex_free_next ]
Added variable framedone to live range equivalence class [ framedone ]
Added variable plexSort::nxt_idx#0 to live range equivalence class [ plexSort::nxt_idx#0 ]
Added variable plexSort::nxt_y#0 to live range equivalence class [ plexSort::nxt_y#0 ]
Added variable plexSort::s#2 to live range equivalence class [ plexSort::s#2 ]
Added variable init::$3 to live range equivalence class [ init::$3 ]
Added variable plex_irq::plexFreeNextYpos1_return#0 to live range equivalence class [ plex_irq::plexFreeNextYpos1_return#0 ]
Added variable plex_irq::$4 to live range equivalence class [ plex_irq::$4 ]
Added variable plexShowSprite::plex_sprite_idx2#0 to live range equivalence class [ plexShowSprite::plex_sprite_idx2#0 ]
Added variable plexShowSprite::plexFreeAdd1_ypos#0 to live range equivalence class [ plexShowSprite::plexFreeAdd1_ypos#0 ]
Added variable plexShowSprite::plexFreeAdd1_$0 to live range equivalence class [ plexShowSprite::plexFreeAdd1_$0 ]
Added variable plexShowSprite::plexFreeAdd1_$1 to live range equivalence class [ plexShowSprite::plexFreeAdd1_$1 ]
Added variable plexShowSprite::plexFreeAdd1_$2 to live range equivalence class [ plexShowSprite::plexFreeAdd1_$2 ]
Added variable plexShowSprite::xpos_idx#0 to live range equivalence class [ plexShowSprite::xpos_idx#0 ]
Added variable plexShowSprite::$11 to live range equivalence class [ plexShowSprite::$11 ]
Added variable plexShowSprite::$2 to live range equivalence class [ plexShowSprite::$2 ]
Added variable plexShowSprite::$3 to live range equivalence class [ plexShowSprite::$3 ]
Added variable plexShowSprite::$9 to live range equivalence class [ plexShowSprite::$9 ]
Added variable plexShowSprite::$5 to live range equivalence class [ plexShowSprite::$5 ]
Added variable plexShowSprite::$6 to live range equivalence class [ plexShowSprite::$6 ]
Complete equivalence classes
[ loop::sin_idx#6 loop::sin_idx#1 ]
[ loop::y_idx#2 loop::y_idx#1 loop::y_idx#4 ]
[ loop::sy#2 loop::sy#1 ]
[ plexSort::m#2 plexSort::m#1 ]
[ plexSort::s#3 plexSort::s#1 plexSort::s#6 ]
[ plexSort::plexFreePrepare1_s#2 plexSort::plexFreePrepare1_s#1 ]
[ init::sx#2 init::sx#1 ]
[ init::xp#2 init::xp#1 ]
[ init::ss#2 init::ss#1 ]
[ plexInit::i#2 plexInit::i#1 ]
[ plex_show_idx ]
[ plex_sprite_idx ]
[ plex_sprite_msb ]
[ plex_free_next ]
[ framedone ]
[ plexSort::nxt_idx#0 ]
[ plexSort::nxt_y#0 ]
[ plexSort::s#2 ]
[ init::$3 ]
[ plex_irq::plexFreeNextYpos1_return#0 ]
[ plex_irq::$4 ]
[ plexShowSprite::plex_sprite_idx2#0 ]
[ plexShowSprite::plexFreeAdd1_ypos#0 ]
[ plexShowSprite::plexFreeAdd1_$0 ]
[ plexShowSprite::plexFreeAdd1_$1 ]
[ plexShowSprite::plexFreeAdd1_$2 ]
[ plexShowSprite::xpos_idx#0 ]
[ plexShowSprite::$11 ]
[ plexShowSprite::$2 ]
[ plexShowSprite::$3 ]
[ plexShowSprite::$9 ]
[ plexShowSprite::$5 ]
[ plexShowSprite::$6 ]
Allocated zp[1]:2 [ loop::sin_idx#6 loop::sin_idx#1 ]
Allocated zp[1]:3 [ loop::y_idx#2 loop::y_idx#1 loop::y_idx#4 ]
Allocated zp[1]:4 [ loop::sy#2 loop::sy#1 ]
Allocated zp[1]:5 [ plexSort::m#2 plexSort::m#1 ]
Allocated zp[1]:6 [ plexSort::s#3 plexSort::s#1 plexSort::s#6 ]
Allocated zp[1]:7 [ plexSort::plexFreePrepare1_s#2 plexSort::plexFreePrepare1_s#1 ]
Allocated zp[1]:8 [ init::sx#2 init::sx#1 ]
Allocated zp[2]:9 [ init::xp#2 init::xp#1 ]
Allocated zp[1]:11 [ init::ss#2 init::ss#1 ]
Allocated zp[1]:12 [ plexInit::i#2 plexInit::i#1 ]
Allocated zp[1]:13 [ plex_show_idx ]
Allocated zp[1]:14 [ plex_sprite_idx ]
Allocated zp[1]:15 [ plex_sprite_msb ]
Allocated zp[1]:16 [ plex_free_next ]
Allocated zp[1]:17 [ framedone ]
Allocated zp[1]:18 [ plexSort::nxt_idx#0 ]
Allocated zp[1]:19 [ plexSort::nxt_y#0 ]
Allocated zp[1]:20 [ plexSort::s#2 ]
Allocated zp[1]:21 [ init::$3 ]
Allocated zp[1]:22 [ plex_irq::plexFreeNextYpos1_return#0 ]
Allocated zp[1]:23 [ plex_irq::$4 ]
Allocated zp[1]:24 [ plexShowSprite::plex_sprite_idx2#0 ]
Allocated zp[1]:25 [ plexShowSprite::plexFreeAdd1_ypos#0 ]
Allocated zp[1]:26 [ plexShowSprite::plexFreeAdd1_$0 ]
Allocated zp[1]:27 [ plexShowSprite::plexFreeAdd1_$1 ]
Allocated zp[1]:28 [ plexShowSprite::plexFreeAdd1_$2 ]
Allocated zp[1]:29 [ plexShowSprite::xpos_idx#0 ]
Allocated zp[1]:30 [ plexShowSprite::$11 ]
Allocated zp[1]:31 [ plexShowSprite::$2 ]
Allocated zp[1]:32 [ plexShowSprite::$3 ]
Allocated zp[1]:33 [ plexShowSprite::$9 ]
Allocated zp[1]:34 [ plexShowSprite::$5 ]
Allocated zp[1]:35 [ plexShowSprite::$6 ]

INITIAL ASM
Target platform is c64basic / MOS6502X
  // File Comments
// A simple usage of the flexible sprite multiplexer routine
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label SPRITES_XPOS = $d000
  .label SPRITES_YPOS = $d001
  .label SPRITES_XMSB = $d010
  .label RASTER = $d012
  .label SPRITES_ENABLE = $d015
  .label BORDERCOL = $d020
  .label SPRITES_COLS = $d027
  .label VIC_CONTROL = $d011
  .label D011 = $d011
  .const VIC_DEN = $10
  .const VIC_RSEL = 8
  // VIC II IRQ Status Register
  .label IRQ_STATUS = $d019
  // VIC II IRQ Enable Register
  .label IRQ_ENABLE = $d01a
  // Bits for the IRQ Status/Enable Registers
  .const IRQ_RASTER = 1
  // CIA#1 Interrupt Status & Control Register
  .label CIA1_INTERRUPT = $dc0d
  // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
  .const CIA_INTERRUPT_CLEAR = $7f
  // The vector used when the KERNAL serves IRQ interrupts
  .label KERNEL_IRQ = $314
  .const WHITE = 1
  .const RED = 2
  .const GREEN = 5
  // The number of sprites in the multiplexer
  .const PLEX_COUNT = $20
  // The address of the sprite pointers on the current screen (screen+0x3f8).
  .label PLEX_SCREEN_PTR = $400+$3f8
  .label plex_show_idx = $d
  .label plex_sprite_idx = $e
  .label plex_sprite_msb = $f
  .label plex_free_next = $10
  .label framedone = $11
  // @begin
__bbegin:
  jmp __b1
  // @1
__b1:
  // [1] (byte) plex_show_idx ← (byte) 0 -- vbuz1=vbuc1 
  // The index in the PLEX tables of the next sprite to show
  lda #0
  sta.z plex_show_idx
  // [2] (byte) plex_sprite_idx ← (byte) 0 -- vbuz1=vbuc1 
  // The index the next sprite to use for showing (sprites are used round-robin)
  lda #0
  sta.z plex_sprite_idx
  // [3] (byte) plex_sprite_msb ← (byte) 1 -- vbuz1=vbuc1 
  // The MSB bit of the next sprite to use for showing
  lda #1
  sta.z plex_sprite_msb
  jmp __b2
  // @2
__b2:
  // [4] (byte) plex_free_next ← (byte) 0 -- vbuz1=vbuc1 
  // The index of the sprite that is free next. Since sprites are used round-robin this moves forward each time a sprite is shown.
  lda #0
  sta.z plex_free_next
  jmp __b3
  // @3
__b3:
  // [5] (bool) framedone ← true -- vboz1=vboc1 
  lda #1
  sta.z framedone
  // [6] phi from @3 to @4 [phi:@3->@4]
__b4_from___b3:
  jmp __b4
  // @4
__b4:
  // [7] call main 
  jsr main
  // [8] phi from @4 to @end [phi:@4->@end]
__bend_from___b4:
  jmp __bend
  // @end
__bend:
  // main
main: {
    // asm { sei  }
    sei
    // [10] call init 
    jsr init
    // [11] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    jmp __b1
    // main::@1
  __b1:
    // [12] call loop 
    // [14] phi from main::@1 to loop [phi:main::@1->loop]
  loop_from___b1:
    jsr loop
    jmp __breturn
    // main::@return
  __breturn:
    // [13] return 
    rts
}
  // loop
// The raster loop
loop: {
    .label y_idx = 3
    .label sy = 4
    // The current index into the y-sinus
    .label sin_idx = 2
    // [15] phi from loop to loop::@1 [phi:loop->loop::@1]
  __b1_from_loop:
    // [15] phi (byte) loop::sin_idx#6 = (byte) 0 [phi:loop->loop::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z sin_idx
    jmp __b1
    // loop::@1
  __b1:
    jmp __b2
    // loop::@2
  __b2:
    // [16] if((bool) framedone) goto loop::@3 -- vboz1_then_la1 
    lda.z framedone
    cmp #0
    bne __b3
    jmp __b2
    // loop::@3
  __b3:
    // [17] *((const byte*) BORDERCOL) ← (const byte) RED -- _deref_pbuc1=vbuc2 
    lda #RED
    sta BORDERCOL
    // [18] (byte) loop::y_idx#4 ← (byte) loop::sin_idx#6 -- vbuz1=vbuz2 
    lda.z sin_idx
    sta.z y_idx
    // [19] phi from loop::@3 to loop::@4 [phi:loop::@3->loop::@4]
  __b4_from___b3:
    // [19] phi (byte) loop::sy#2 = (byte) 0 [phi:loop::@3->loop::@4#0] -- vbuz1=vbuc1 
    lda #0
    sta.z sy
    // [19] phi (byte) loop::y_idx#2 = (byte) loop::y_idx#4 [phi:loop::@3->loop::@4#1] -- register_copy 
    jmp __b4
    // [19] phi from loop::@4 to loop::@4 [phi:loop::@4->loop::@4]
  __b4_from___b4:
    // [19] phi (byte) loop::sy#2 = (byte) loop::sy#1 [phi:loop::@4->loop::@4#0] -- register_copy 
    // [19] phi (byte) loop::y_idx#2 = (byte) loop::y_idx#1 [phi:loop::@4->loop::@4#1] -- register_copy 
    jmp __b4
    // loop::@4
  __b4:
    // [20] *((const byte*) PLEX_YPOS + (byte) loop::sy#2) ← *((const byte*) YSIN + (byte) loop::y_idx#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz2 
    ldy.z y_idx
    lda YSIN,y
    ldy.z sy
    sta PLEX_YPOS,y
    // [21] (byte) loop::y_idx#1 ← (byte) loop::y_idx#2 + (byte) 8 -- vbuz1=vbuz1_plus_vbuc1 
    lax.z y_idx
    axs #-[8]
    stx.z y_idx
    // [22] (byte) loop::sy#1 ← ++ (byte) loop::sy#2 -- vbuz1=_inc_vbuz1 
    inc.z sy
    // [23] if((byte) loop::sy#1!=(const byte) PLEX_COUNT-(byte) 1+(byte) 1) goto loop::@4 -- vbuz1_neq_vbuc1_then_la1 
    lda #PLEX_COUNT-1+1
    cmp.z sy
    bne __b4_from___b4
    jmp __b5
    // loop::@5
  __b5:
    // [24] (byte) loop::sin_idx#1 ← (byte) loop::sin_idx#6 + (byte) 1 -- vbuz1=vbuz1_plus_1 
    inc.z sin_idx
    // [25] *((const byte*) BORDERCOL) ← ++ *((const byte*) BORDERCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    // [26] call plexSort 
    // [31] phi from loop::@5 to plexSort [phi:loop::@5->plexSort]
  plexSort_from___b5:
    jsr plexSort
    jmp __b6
    // loop::@6
  __b6:
    // [27] *((const byte*) BORDERCOL) ← (const byte) GREEN -- _deref_pbuc1=vbuc2 
    lda #GREEN
    sta BORDERCOL
    // [28] (bool) framedone ← false -- vboz1=vboc1 
    lda #0
    sta.z framedone
    // [29] *((const byte*) VIC_CONTROL) ← *((const byte*) VIC_CONTROL) & (byte) $7f -- _deref_pbuc1=_deref_pbuc1_band_vbuc2 
    lda #$7f
    and VIC_CONTROL
    sta VIC_CONTROL
    // [30] *((const byte*) RASTER) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta RASTER
    // [15] phi from loop::@6 to loop::@1 [phi:loop::@6->loop::@1]
  __b1_from___b6:
    // [15] phi (byte) loop::sin_idx#6 = (byte) loop::sin_idx#1 [phi:loop::@6->loop::@1#0] -- register_copy 
    jmp __b1
}
  // plexSort
// Ensure that the indices in PLEX_SORTED_IDX is sorted based on the y-positions in PLEX_YPOS
// Assumes that the positions are nearly sorted already (as each sprite just moves a bit)
// Uses an insertion sort:
// 1. Moves a marker (m) from the start to end of the array. Every time the marker moves forward all elements before the marker are sorted correctly.
// 2a. If the next element after the marker is larger that the current element
//     the marker can be moved forwards (as the sorting is correct).
// 2b. If the next element after the marker is smaller than the current element:
//     elements before the marker are shifted right one at a time until encountering one smaller than the current one.
//      It is then inserted at the spot. Now the marker can move forward.
plexSort: {
    .label nxt_idx = $12
    .label nxt_y = $13
    .label m = 5
    .label s = 6
    .label s_1 = $14
    .label plexFreePrepare1_s = 7
    // [32] phi from plexSort to plexSort::@1 [phi:plexSort->plexSort::@1]
  __b1_from_plexSort:
    // [32] phi (byte) plexSort::m#2 = (byte) 0 [phi:plexSort->plexSort::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z m
    jmp __b1
    // [32] phi from plexSort::@2 to plexSort::@1 [phi:plexSort::@2->plexSort::@1]
  __b1_from___b2:
    // [32] phi (byte) plexSort::m#2 = (byte) plexSort::m#1 [phi:plexSort::@2->plexSort::@1#0] -- register_copy 
    jmp __b1
    // plexSort::@1
  __b1:
    // [33] (byte) plexSort::nxt_idx#0 ← *((const byte*) PLEX_SORTED_IDX+(byte) 1 + (byte) plexSort::m#2) -- vbuz1=pbuc1_derefidx_vbuz2 
    ldy.z m
    lda PLEX_SORTED_IDX+1,y
    sta.z nxt_idx
    // [34] (byte) plexSort::nxt_y#0 ← *((const byte*) PLEX_YPOS + (byte) plexSort::nxt_idx#0) -- vbuz1=pbuc1_derefidx_vbuz2 
    ldy.z nxt_idx
    lda PLEX_YPOS,y
    sta.z nxt_y
    // [35] if((byte) plexSort::nxt_y#0>=*((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::m#2))) goto plexSort::@2 -- vbuz1_ge_pbuc1_derefidx_(pbuc2_derefidx_vbuz2)_then_la1 
    lda.z nxt_y
    ldx.z m
    ldy PLEX_SORTED_IDX,x
    cmp PLEX_YPOS,y
    bcs __b2
    jmp __b5
    // plexSort::@5
  __b5:
    // [36] (byte) plexSort::s#6 ← (byte) plexSort::m#2 -- vbuz1=vbuz2 
    lda.z m
    sta.z s
    // [37] phi from plexSort::@5 plexSort::@7 to plexSort::@3 [phi:plexSort::@5/plexSort::@7->plexSort::@3]
  __b3_from___b5:
  __b3_from___b7:
    // [37] phi (byte) plexSort::s#3 = (byte) plexSort::s#6 [phi:plexSort::@5/plexSort::@7->plexSort::@3#0] -- register_copy 
    jmp __b3
    // plexSort::@3
  __b3:
    // [38] *((const byte*) PLEX_SORTED_IDX+(byte) 1 + (byte) plexSort::s#3) ← *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#3) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1 
    ldy.z s
    lda PLEX_SORTED_IDX,y
    sta PLEX_SORTED_IDX+1,y
    // [39] (byte) plexSort::s#1 ← -- (byte) plexSort::s#3 -- vbuz1=_dec_vbuz1 
    dec.z s
    // [40] if((byte) plexSort::s#1==(byte) $ff) goto plexSort::@4 -- vbuz1_eq_vbuc1_then_la1 
    lda #$ff
    cmp.z s
    beq __b4
    jmp __b7
    // plexSort::@7
  __b7:
    // [41] if((byte) plexSort::nxt_y#0<*((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#1))) goto plexSort::@3 -- vbuz1_lt_pbuc1_derefidx_(pbuc2_derefidx_vbuz2)_then_la1 
    lda.z nxt_y
    ldx.z s
    ldy PLEX_SORTED_IDX,x
    cmp PLEX_YPOS,y
    bcc __b3_from___b7
    jmp __b4
    // plexSort::@4
  __b4:
    // [42] (byte) plexSort::s#2 ← ++ (byte) plexSort::s#1 -- vbuz1=_inc_vbuz2 
    ldy.z s
    iny
    sty.z s_1
    // [43] *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#2) ← (byte) plexSort::nxt_idx#0 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda.z nxt_idx
    ldy.z s_1
    sta PLEX_SORTED_IDX,y
    jmp __b2
    // plexSort::@2
  __b2:
    // [44] (byte) plexSort::m#1 ← ++ (byte) plexSort::m#2 -- vbuz1=_inc_vbuz1 
    inc.z m
    // [45] if((byte) plexSort::m#1!=(const byte) PLEX_COUNT-(byte) 2+(byte) 1) goto plexSort::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #PLEX_COUNT-2+1
    cmp.z m
    bne __b1_from___b2
    jmp __b6
    // plexSort::@6
  __b6:
    // [46] (byte) plex_show_idx ← (byte) 0 -- vbuz1=vbuc1 
    // Prepare for showing the sprites
    lda #0
    sta.z plex_show_idx
    // [47] (byte) plex_sprite_idx ← (byte) 0 -- vbuz1=vbuc1 
    lda #0
    sta.z plex_sprite_idx
    // [48] (byte) plex_sprite_msb ← (byte) 1 -- vbuz1=vbuc1 
    lda #1
    sta.z plex_sprite_msb
    // [49] phi from plexSort::@6 to plexSort::plexFreePrepare1 [phi:plexSort::@6->plexSort::plexFreePrepare1]
  plexFreePrepare1_from___b6:
    jmp plexFreePrepare1
    // plexSort::plexFreePrepare1
  plexFreePrepare1:
    // [50] phi from plexSort::plexFreePrepare1 to plexSort::plexFreePrepare1_@1 [phi:plexSort::plexFreePrepare1->plexSort::plexFreePrepare1_@1]
  plexFreePrepare1___b1_from_plexFreePrepare1:
    // [50] phi (byte) plexSort::plexFreePrepare1_s#2 = (byte) 0 [phi:plexSort::plexFreePrepare1->plexSort::plexFreePrepare1_@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z plexFreePrepare1_s
    jmp plexFreePrepare1___b1
    // [50] phi from plexSort::plexFreePrepare1_@1 to plexSort::plexFreePrepare1_@1 [phi:plexSort::plexFreePrepare1_@1->plexSort::plexFreePrepare1_@1]
  plexFreePrepare1___b1_from_plexFreePrepare1___b1:
    // [50] phi (byte) plexSort::plexFreePrepare1_s#2 = (byte) plexSort::plexFreePrepare1_s#1 [phi:plexSort::plexFreePrepare1_@1->plexSort::plexFreePrepare1_@1#0] -- register_copy 
    jmp plexFreePrepare1___b1
    // plexSort::plexFreePrepare1_@1
  plexFreePrepare1___b1:
    // [51] *((const byte*) PLEX_FREE_YPOS + (byte) plexSort::plexFreePrepare1_s#2) ← (byte) 0 -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #0
    ldy.z plexFreePrepare1_s
    sta PLEX_FREE_YPOS,y
    // [52] (byte) plexSort::plexFreePrepare1_s#1 ← ++ (byte) plexSort::plexFreePrepare1_s#2 -- vbuz1=_inc_vbuz1 
    inc.z plexFreePrepare1_s
    // [53] if((byte) plexSort::plexFreePrepare1_s#1!=(byte) 8) goto plexSort::plexFreePrepare1_@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #8
    cmp.z plexFreePrepare1_s
    bne plexFreePrepare1___b1_from_plexFreePrepare1___b1
    jmp plexFreePrepare1___b2
    // plexSort::plexFreePrepare1_@2
  plexFreePrepare1___b2:
    // [54] (byte) plex_free_next ← (byte) 0 -- vbuz1=vbuc1 
    lda #0
    sta.z plex_free_next
    jmp __breturn
    // plexSort::@return
  __breturn:
    // [55] return 
    rts
}
  // init
// Initialize the program
init: {
    .label __3 = $15
    // Set the x-positions & pointers
    .label xp = 9
    .label sx = 8
    .label ss = $b
    // [56] *((const byte*) D011) ← (const byte) VIC_DEN|(const byte) VIC_RSEL|(byte) 3 -- _deref_pbuc1=vbuc2 
    lda #VIC_DEN|VIC_RSEL|3
    sta D011
    // [57] call plexInit 
    // [77] phi from init to plexInit [phi:init->plexInit]
  plexInit_from_init:
    jsr plexInit
    // [58] phi from init to init::@1 [phi:init->init::@1]
  __b1_from_init:
    // [58] phi (word) init::xp#2 = (word) $20 [phi:init->init::@1#0] -- vwuz1=vwuc1 
    lda #<$20
    sta.z xp
    lda #>$20
    sta.z xp+1
    // [58] phi (byte) init::sx#2 = (byte) 0 [phi:init->init::@1#1] -- vbuz1=vbuc1 
    lda #0
    sta.z sx
    jmp __b1
    // [58] phi from init::@1 to init::@1 [phi:init::@1->init::@1]
  __b1_from___b1:
    // [58] phi (word) init::xp#2 = (word) init::xp#1 [phi:init::@1->init::@1#0] -- register_copy 
    // [58] phi (byte) init::sx#2 = (byte) init::sx#1 [phi:init::@1->init::@1#1] -- register_copy 
    jmp __b1
    // init::@1
  __b1:
    // [59] *((const byte*) PLEX_PTR + (byte) init::sx#2) ← (byte)(const byte*) SPRITE/(byte) $40 -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #$ff&SPRITE/$40
    ldy.z sx
    sta PLEX_PTR,y
    // [60] (byte~) init::$3 ← (byte) init::sx#2 << (byte) 1 -- vbuz1=vbuz2_rol_1 
    lda.z sx
    asl
    sta.z __3
    // [61] *((const word*) PLEX_XPOS + (byte~) init::$3) ← (word) init::xp#2 -- pwuc1_derefidx_vbuz1=vwuz2 
    ldy.z __3
    lda.z xp
    sta PLEX_XPOS,y
    lda.z xp+1
    sta PLEX_XPOS+1,y
    // [62] (word) init::xp#1 ← (word) init::xp#2 + (byte) 9 -- vwuz1=vwuz1_plus_vbuc1 
    lda #9
    clc
    adc.z xp
    sta.z xp
    bcc !+
    inc.z xp+1
  !:
    // [63] (byte) init::sx#1 ← ++ (byte) init::sx#2 -- vbuz1=_inc_vbuz1 
    inc.z sx
    // [64] if((byte) init::sx#1!=(const byte) PLEX_COUNT-(byte) 1+(byte) 1) goto init::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #PLEX_COUNT-1+1
    cmp.z sx
    bne __b1_from___b1
    jmp __b2
    // init::@2
  __b2:
    // [65] *((const byte*) SPRITES_ENABLE) ← (byte) $ff -- _deref_pbuc1=vbuc2 
    // Enable & initialize sprites
    lda #$ff
    sta SPRITES_ENABLE
    // [66] phi from init::@2 to init::@3 [phi:init::@2->init::@3]
  __b3_from___b2:
    // [66] phi (byte) init::ss#2 = (byte) 0 [phi:init::@2->init::@3#0] -- vbuz1=vbuc1 
    lda #0
    sta.z ss
    jmp __b3
    // [66] phi from init::@3 to init::@3 [phi:init::@3->init::@3]
  __b3_from___b3:
    // [66] phi (byte) init::ss#2 = (byte) init::ss#1 [phi:init::@3->init::@3#0] -- register_copy 
    jmp __b3
    // init::@3
  __b3:
    // [67] *((const byte*) SPRITES_COLS + (byte) init::ss#2) ← (const byte) GREEN -- pbuc1_derefidx_vbuz1=vbuc2 
    lda #GREEN
    ldy.z ss
    sta SPRITES_COLS,y
    // [68] (byte) init::ss#1 ← ++ (byte) init::ss#2 -- vbuz1=_inc_vbuz1 
    inc.z ss
    // [69] if((byte) init::ss#1!=(byte) 8) goto init::@3 -- vbuz1_neq_vbuc1_then_la1 
    lda #8
    cmp.z ss
    bne __b3_from___b3
    jmp __b4
    // init::@4
  __b4:
    // asm { sei  }
    // enable the interrupt
    sei
    // [71] *((const byte*) CIA1_INTERRUPT) ← (const byte) CIA_INTERRUPT_CLEAR -- _deref_pbuc1=vbuc2 
    lda #CIA_INTERRUPT_CLEAR
    sta CIA1_INTERRUPT
    // [72] *((const byte*) IRQ_ENABLE) ← (const byte) IRQ_RASTER -- _deref_pbuc1=vbuc2 
    lda #IRQ_RASTER
    sta IRQ_ENABLE
    // [73] *((const byte*) IRQ_STATUS) ← (const byte) IRQ_RASTER -- _deref_pbuc1=vbuc2 
    lda #IRQ_RASTER
    sta IRQ_STATUS
    // [74] *((const void()**) KERNEL_IRQ) ← &interrupt(KERNEL_MIN)(void()) plex_irq() -- _deref_pptc1=pprc2 
    lda #<plex_irq
    sta KERNEL_IRQ
    lda #>plex_irq
    sta KERNEL_IRQ+1
    // asm { cli  }
    cli
    jmp __breturn
    // init::@return
  __breturn:
    // [76] return 
    rts
}
  // plexInit
// Initialize the multiplexer data structures
plexInit: {
    .label i = $c
    // [78] phi from plexInit to plexInit::plexSetScreen1 [phi:plexInit->plexInit::plexSetScreen1]
  plexSetScreen1_from_plexInit:
    jmp plexSetScreen1
    // plexInit::plexSetScreen1
  plexSetScreen1:
    // [79] phi from plexInit::plexSetScreen1 to plexInit::@1 [phi:plexInit::plexSetScreen1->plexInit::@1]
  __b1_from_plexSetScreen1:
    // [79] phi (byte) plexInit::i#2 = (byte) 0 [phi:plexInit::plexSetScreen1->plexInit::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z i
    jmp __b1
    // [79] phi from plexInit::@1 to plexInit::@1 [phi:plexInit::@1->plexInit::@1]
  __b1_from___b1:
    // [79] phi (byte) plexInit::i#2 = (byte) plexInit::i#1 [phi:plexInit::@1->plexInit::@1#0] -- register_copy 
    jmp __b1
    // plexInit::@1
  __b1:
    // [80] *((const byte*) PLEX_SORTED_IDX + (byte) plexInit::i#2) ← (byte) plexInit::i#2 -- pbuc1_derefidx_vbuz1=vbuz1 
    ldy.z i
    tya
    sta PLEX_SORTED_IDX,y
    // [81] (byte) plexInit::i#1 ← ++ (byte) plexInit::i#2 -- vbuz1=_inc_vbuz1 
    inc.z i
    // [82] if((byte) plexInit::i#1!=(const byte) PLEX_COUNT-(byte) 1+(byte) 1) goto plexInit::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #PLEX_COUNT-1+1
    cmp.z i
    bne __b1_from___b1
    jmp __breturn
    // plexInit::@return
  __breturn:
    // [83] return 
    rts
}
  // plex_irq
plex_irq: {
    .label __4 = $17
    .label plexFreeNextYpos1_return = $16
    // entry interrupt(KERNEL_MIN)
    // [84] *((const byte*) BORDERCOL) ← (const byte) WHITE -- _deref_pbuc1=vbuc2 
    lda #WHITE
    sta BORDERCOL
    // [85] phi from plex_irq plex_irq::@7 to plex_irq::@3 [phi:plex_irq/plex_irq::@7->plex_irq::@3]
  __b3_from_plex_irq:
  __b3_from___b7:
    jmp __b3
    // plex_irq::@3
  __b3:
    // [86] call plexShowSprite 
    jsr plexShowSprite
    jmp plexFreeNextYpos1
    // plex_irq::plexFreeNextYpos1
  plexFreeNextYpos1:
    // [87] (byte) plex_irq::plexFreeNextYpos1_return#0 ← *((const byte*) PLEX_FREE_YPOS + (byte) plex_free_next) -- vbuz1=pbuc1_derefidx_vbuz2 
    ldy.z plex_free_next
    lda PLEX_FREE_YPOS,y
    sta.z plexFreeNextYpos1_return
    jmp __b6
    // plex_irq::@6
  __b6:
    // [88] (byte~) plex_irq::$4 ← *((const byte*) RASTER) + (byte) 2 -- vbuz1=_deref_pbuc1_plus_2 
    lda RASTER
    clc
    adc #2
    sta.z __4
    // [89] if((byte) plex_show_idx>=(const byte) PLEX_COUNT) goto plex_irq::@4 -- vbuz1_ge_vbuc1_then_la1 
    lda.z plex_show_idx
    cmp #PLEX_COUNT
    bcs __b4
    jmp __b7
    // plex_irq::@7
  __b7:
    // [90] if((byte) plex_irq::plexFreeNextYpos1_return#0<(byte~) plex_irq::$4) goto plex_irq::@3 -- vbuz1_lt_vbuz2_then_la1 
    lda.z plexFreeNextYpos1_return
    cmp.z __4
    bcc __b3_from___b7
    jmp __b4
    // plex_irq::@4
  __b4:
    // [91] *((const byte*) IRQ_STATUS) ← (const byte) IRQ_RASTER -- _deref_pbuc1=vbuc2 
    lda #IRQ_RASTER
    sta IRQ_STATUS
    // [92] if((byte) plex_show_idx<(const byte) PLEX_COUNT) goto plex_irq::@1 -- vbuz1_lt_vbuc1_then_la1 
    lda.z plex_show_idx
    cmp #PLEX_COUNT
    bcc __b1
    jmp __b5
    // plex_irq::@5
  __b5:
    // [93] (bool) framedone ← true -- vboz1=vboc1 
    lda #1
    sta.z framedone
    jmp __b2
    // plex_irq::@2
  __b2:
    // [94] *((const byte*) BORDERCOL) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta BORDERCOL
    jmp __breturn
    // plex_irq::@return
  __breturn:
    // [95] return  - exit interrupt(KERNEL_MIN)
    jmp $ea81
    // plex_irq::@1
  __b1:
    // [96] *((const byte*) RASTER) ← (byte) plex_irq::plexFreeNextYpos1_return#0 -- _deref_pbuc1=vbuz1 
    lda.z plexFreeNextYpos1_return
    sta RASTER
    jmp __b2
}
  // plexShowSprite
// Show the next sprite.
// plexSort() prepares showing the sprites
plexShowSprite: {
    .label __2 = $1f
    .label __3 = $20
    .label __5 = $22
    .label __6 = $23
    .label __9 = $21
    .label __11 = $1e
    .label plexFreeAdd1___0 = $1a
    .label plexFreeAdd1___1 = $1b
    .label plexFreeAdd1___2 = $1c
    .label plex_sprite_idx2 = $18
    .label plexFreeAdd1_ypos = $19
    .label xpos_idx = $1d
    // [97] (byte) plexShowSprite::plex_sprite_idx2#0 ← (byte) plex_sprite_idx << (byte) 1 -- vbuz1=vbuz2_rol_1 
    lda.z plex_sprite_idx
    asl
    sta.z plex_sprite_idx2
    // [98] (byte) plexShowSprite::plexFreeAdd1_ypos#0 ← *((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx)) -- vbuz1=pbuc1_derefidx_(pbuc2_derefidx_vbuz2) 
    ldx.z plex_show_idx
    ldy PLEX_SORTED_IDX,x
    ldx PLEX_YPOS,y
    stx.z plexFreeAdd1_ypos
    // [99] *((const byte*) SPRITES_YPOS + (byte) plexShowSprite::plex_sprite_idx2#0) ← (byte) plexShowSprite::plexFreeAdd1_ypos#0 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda.z plexFreeAdd1_ypos
    ldy.z plex_sprite_idx2
    sta SPRITES_YPOS,y
    jmp plexFreeAdd1
    // plexShowSprite::plexFreeAdd1
  plexFreeAdd1:
    // [100] (byte~) plexShowSprite::plexFreeAdd1_$0 ← (byte) plexShowSprite::plexFreeAdd1_ypos#0 + (byte) $15 -- vbuz1=vbuz2_plus_vbuc1 
    lax.z plexFreeAdd1_ypos
    axs #-[$15]
    stx.z plexFreeAdd1___0
    // [101] *((const byte*) PLEX_FREE_YPOS + (byte) plex_free_next) ← (byte~) plexShowSprite::plexFreeAdd1_$0 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda.z plexFreeAdd1___0
    ldy.z plex_free_next
    sta PLEX_FREE_YPOS,y
    // [102] (byte~) plexShowSprite::plexFreeAdd1_$1 ← (byte) plex_free_next + (byte) 1 -- vbuz1=vbuz2_plus_1 
    ldy.z plex_free_next
    iny
    sty.z plexFreeAdd1___1
    // [103] (byte~) plexShowSprite::plexFreeAdd1_$2 ← (byte~) plexShowSprite::plexFreeAdd1_$1 & (byte) 7 -- vbuz1=vbuz2_band_vbuc1 
    lda #7
    and.z plexFreeAdd1___1
    sta.z plexFreeAdd1___2
    // [104] (byte) plex_free_next ← (byte~) plexShowSprite::plexFreeAdd1_$2 -- vbuz1=vbuz2 
    lda.z plexFreeAdd1___2
    sta.z plex_free_next
    jmp __b5
    // plexShowSprite::@5
  __b5:
    // [105] *((const byte*) PLEX_SCREEN_PTR#0 + (byte) plex_sprite_idx) ← *((const byte*) PLEX_PTR + *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx)) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_(pbuc3_derefidx_vbuz2) 
    ldx.z plex_show_idx
    ldy PLEX_SORTED_IDX,x
    lda PLEX_PTR,y
    ldx.z plex_sprite_idx
    sta PLEX_SCREEN_PTR,x
    // [106] (byte) plexShowSprite::xpos_idx#0 ← *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx) -- vbuz1=pbuc1_derefidx_vbuz2 
    ldy.z plex_show_idx
    lda PLEX_SORTED_IDX,y
    sta.z xpos_idx
    // [107] (byte~) plexShowSprite::$11 ← (byte) plexShowSprite::xpos_idx#0 << (byte) 1 -- vbuz1=vbuz2_rol_1 
    lda.z xpos_idx
    asl
    sta.z __11
    // [108] (byte~) plexShowSprite::$2 ← < *((const word*) PLEX_XPOS + (byte~) plexShowSprite::$11) -- vbuz1=_lo_pwuc1_derefidx_vbuz2 
    ldy.z __11
    lda PLEX_XPOS,y
    sta.z __2
    // [109] *((const byte*) SPRITES_XPOS + (byte) plexShowSprite::plex_sprite_idx2#0) ← (byte~) plexShowSprite::$2 -- pbuc1_derefidx_vbuz1=vbuz2 
    lda.z __2
    ldy.z plex_sprite_idx2
    sta SPRITES_XPOS,y
    // [110] (byte~) plexShowSprite::$3 ← > *((const word*) PLEX_XPOS + (byte~) plexShowSprite::$11) -- vbuz1=_hi_pwuc1_derefidx_vbuz2 
    ldy.z __11
    lda PLEX_XPOS+1,y
    sta.z __3
    // [111] if((byte~) plexShowSprite::$3!=(byte) 0) goto plexShowSprite::@1 -- vbuz1_neq_0_then_la1 
    lda.z __3
    cmp #0
    bne __b1
    jmp __b3
    // plexShowSprite::@3
  __b3:
    // [112] (byte~) plexShowSprite::$9 ← (byte) $ff ^ (byte) plex_sprite_msb -- vbuz1=vbuc1_bxor_vbuz2 
    lda #$ff
    eor.z plex_sprite_msb
    sta.z __9
    // [113] *((const byte*) SPRITES_XMSB) ← *((const byte*) SPRITES_XMSB) & (byte~) plexShowSprite::$9 -- _deref_pbuc1=_deref_pbuc1_band_vbuz1 
    lda SPRITES_XMSB
    and.z __9
    sta SPRITES_XMSB
    jmp __b2
    // plexShowSprite::@2
  __b2:
    // [114] (byte~) plexShowSprite::$5 ← (byte) plex_sprite_idx + (byte) 1 -- vbuz1=vbuz2_plus_1 
    ldy.z plex_sprite_idx
    iny
    sty.z __5
    // [115] (byte~) plexShowSprite::$6 ← (byte~) plexShowSprite::$5 & (byte) 7 -- vbuz1=vbuz2_band_vbuc1 
    lda #7
    and.z __5
    sta.z __6
    // [116] (byte) plex_sprite_idx ← (byte~) plexShowSprite::$6 -- vbuz1=vbuz2 
    lda.z __6
    sta.z plex_sprite_idx
    // [117] (byte) plex_show_idx ← ++ (byte) plex_show_idx -- vbuz1=_inc_vbuz1 
    inc.z plex_show_idx
    // [118] (byte) plex_sprite_msb ← (byte) plex_sprite_msb << (byte) 1 -- vbuz1=vbuz1_rol_1 
    asl.z plex_sprite_msb
    // [119] if((byte) plex_sprite_msb!=(byte) 0) goto plexShowSprite::@return -- vbuz1_neq_0_then_la1 
    lda.z plex_sprite_msb
    cmp #0
    bne __breturn
    jmp __b4
    // plexShowSprite::@4
  __b4:
    // [120] (byte) plex_sprite_msb ← (byte) 1 -- vbuz1=vbuc1 
    lda #1
    sta.z plex_sprite_msb
    jmp __breturn
    // plexShowSprite::@return
  __breturn:
    // [121] return 
    rts
    // plexShowSprite::@1
  __b1:
    // [122] *((const byte*) SPRITES_XMSB) ← *((const byte*) SPRITES_XMSB) | (byte) plex_sprite_msb -- _deref_pbuc1=_deref_pbuc1_bor_vbuz1 
    lda SPRITES_XMSB
    ora.z plex_sprite_msb
    sta SPRITES_XMSB
    jmp __b2
}
  // File Data
  // The x-positions of the multiplexer sprites (0x000-0x1ff)
  PLEX_XPOS: .fill 2*PLEX_COUNT, 0
  // The y-positions of the multiplexer sprites.
  PLEX_YPOS: .fill PLEX_COUNT, 0
  // The sprite pointers for the multiplexed sprites
  PLEX_PTR: .fill PLEX_COUNT, 0
  // Indexes of the plex-sprites sorted by sprite y-position. Each call to plexSort() will fix the sorting if changes to the Y-positions have ruined it.
  PLEX_SORTED_IDX: .fill PLEX_COUNT, 0
  // Contains the Y-position where each sprite is free again. PLEX_FREE_YPOS[s] holds the Y-position where sprite s is free to use again.
  PLEX_FREE_YPOS: .fill 8, 0
  .align $40
SPRITE:
.var pic = LoadPicture("balloon.png", List().add($000000, $ffffff))
    .for (var y=0; y<21; y++)
        .for (var x=0;x<3; x++)
            .byte pic.getSinglecolorByte(x,y)

  .align $100
YSIN:
.fill $100, round(139.5+89.5*sin(toRadians(360*i/256)))


REGISTER UPLIFT POTENTIAL REGISTERS
Statement [1] (byte) plex_show_idx ← (byte) 0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [2] (byte) plex_sprite_idx ← (byte) 0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [3] (byte) plex_sprite_msb ← (byte) 1 [ ] (  [ ] ) always clobbers reg byte a 
Statement [4] (byte) plex_free_next ← (byte) 0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [5] (bool) framedone ← true [ framedone ] (  [ framedone ] ) always clobbers reg byte a 
Statement [16] if((bool) framedone) goto loop::@3 [ framedone loop::sin_idx#6 ] ( main:7::loop:12 [ framedone loop::sin_idx#6 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:2 [ loop::sin_idx#6 loop::sin_idx#1 ]
Statement [17] *((const byte*) BORDERCOL) ← (const byte) RED [ loop::sin_idx#6 ] ( main:7::loop:12 [ loop::sin_idx#6 ] ) always clobbers reg byte a 
Statement [20] *((const byte*) PLEX_YPOS + (byte) loop::sy#2) ← *((const byte*) YSIN + (byte) loop::y_idx#2) [ loop::sin_idx#6 loop::y_idx#2 loop::sy#2 ] ( main:7::loop:12 [ loop::sin_idx#6 loop::y_idx#2 loop::sy#2 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:3 [ loop::y_idx#2 loop::y_idx#1 loop::y_idx#4 ]
Removing always clobbered register reg byte a as potential for zp[1]:4 [ loop::sy#2 loop::sy#1 ]
Statement [21] (byte) loop::y_idx#1 ← (byte) loop::y_idx#2 + (byte) 8 [ loop::sin_idx#6 loop::sy#2 loop::y_idx#1 ] ( main:7::loop:12 [ loop::sin_idx#6 loop::sy#2 loop::y_idx#1 ] ) always clobbers reg byte a 
Statement [27] *((const byte*) BORDERCOL) ← (const byte) GREEN [ loop::sin_idx#1 ] ( main:7::loop:12 [ loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [28] (bool) framedone ← false [ framedone loop::sin_idx#1 ] ( main:7::loop:12 [ framedone loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [29] *((const byte*) VIC_CONTROL) ← *((const byte*) VIC_CONTROL) & (byte) $7f [ framedone loop::sin_idx#1 ] ( main:7::loop:12 [ framedone loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [30] *((const byte*) RASTER) ← (byte) 0 [ framedone loop::sin_idx#1 ] ( main:7::loop:12 [ framedone loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [38] *((const byte*) PLEX_SORTED_IDX+(byte) 1 + (byte) plexSort::s#3) ← *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#3) [ plexSort::m#2 plexSort::nxt_idx#0 plexSort::nxt_y#0 plexSort::s#3 ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 plexSort::m#2 plexSort::nxt_idx#0 plexSort::nxt_y#0 plexSort::s#3 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:5 [ plexSort::m#2 plexSort::m#1 ]
Removing always clobbered register reg byte a as potential for zp[1]:18 [ plexSort::nxt_idx#0 ]
Removing always clobbered register reg byte a as potential for zp[1]:19 [ plexSort::nxt_y#0 ]
Removing always clobbered register reg byte a as potential for zp[1]:6 [ plexSort::s#3 plexSort::s#1 plexSort::s#6 ]
Statement [41] if((byte) plexSort::nxt_y#0<*((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#1))) goto plexSort::@3 [ plexSort::m#2 plexSort::nxt_idx#0 plexSort::nxt_y#0 plexSort::s#1 ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 plexSort::m#2 plexSort::nxt_idx#0 plexSort::nxt_y#0 plexSort::s#1 ] ) always clobbers reg byte a 
Statement [43] *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#2) ← (byte) plexSort::nxt_idx#0 [ plexSort::m#2 ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 plexSort::m#2 ] ) always clobbers reg byte a 
Statement [46] (byte) plex_show_idx ← (byte) 0 [ ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [47] (byte) plex_sprite_idx ← (byte) 0 [ ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [48] (byte) plex_sprite_msb ← (byte) 1 [ ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [51] *((const byte*) PLEX_FREE_YPOS + (byte) plexSort::plexFreePrepare1_s#2) ← (byte) 0 [ plexSort::plexFreePrepare1_s#2 ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 plexSort::plexFreePrepare1_s#2 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:7 [ plexSort::plexFreePrepare1_s#2 plexSort::plexFreePrepare1_s#1 ]
Statement [54] (byte) plex_free_next ← (byte) 0 [ ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [56] *((const byte*) D011) ← (const byte) VIC_DEN|(const byte) VIC_RSEL|(byte) 3 [ ] ( main:7::init:10 [ framedone ] ) always clobbers reg byte a 
Statement [59] *((const byte*) PLEX_PTR + (byte) init::sx#2) ← (byte)(const byte*) SPRITE/(byte) $40 [ init::sx#2 init::xp#2 ] ( main:7::init:10 [ framedone init::sx#2 init::xp#2 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:8 [ init::sx#2 init::sx#1 ]
Statement [60] (byte~) init::$3 ← (byte) init::sx#2 << (byte) 1 [ init::sx#2 init::xp#2 init::$3 ] ( main:7::init:10 [ framedone init::sx#2 init::xp#2 init::$3 ] ) always clobbers reg byte a 
Statement [61] *((const word*) PLEX_XPOS + (byte~) init::$3) ← (word) init::xp#2 [ init::sx#2 init::xp#2 ] ( main:7::init:10 [ framedone init::sx#2 init::xp#2 ] ) always clobbers reg byte a 
Statement [62] (word) init::xp#1 ← (word) init::xp#2 + (byte) 9 [ init::sx#2 init::xp#1 ] ( main:7::init:10 [ framedone init::sx#2 init::xp#1 ] ) always clobbers reg byte a 
Statement [65] *((const byte*) SPRITES_ENABLE) ← (byte) $ff [ ] ( main:7::init:10 [ framedone ] ) always clobbers reg byte a 
Statement [67] *((const byte*) SPRITES_COLS + (byte) init::ss#2) ← (const byte) GREEN [ init::ss#2 ] ( main:7::init:10 [ framedone init::ss#2 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:11 [ init::ss#2 init::ss#1 ]
Statement [71] *((const byte*) CIA1_INTERRUPT) ← (const byte) CIA_INTERRUPT_CLEAR [ ] ( main:7::init:10 [ framedone ] ) always clobbers reg byte a 
Statement [72] *((const byte*) IRQ_ENABLE) ← (const byte) IRQ_RASTER [ ] ( main:7::init:10 [ framedone ] ) always clobbers reg byte a 
Statement [73] *((const byte*) IRQ_STATUS) ← (const byte) IRQ_RASTER [ ] ( main:7::init:10 [ framedone ] ) always clobbers reg byte a 
Statement [74] *((const void()**) KERNEL_IRQ) ← &interrupt(KERNEL_MIN)(void()) plex_irq() [ ] ( main:7::init:10 [ framedone ] ) always clobbers reg byte a 
Statement [84] *((const byte*) BORDERCOL) ← (const byte) WHITE [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] (  [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ) always clobbers reg byte a 
Statement [87] (byte) plex_irq::plexFreeNextYpos1_return#0 ← *((const byte*) PLEX_FREE_YPOS + (byte) plex_free_next) [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plex_irq::plexFreeNextYpos1_return#0 ] (  [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plex_irq::plexFreeNextYpos1_return#0 ] ) always clobbers reg byte y 
Statement [89] if((byte) plex_show_idx>=(const byte) PLEX_COUNT) goto plex_irq::@4 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plex_irq::plexFreeNextYpos1_return#0 plex_irq::$4 ] (  [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plex_irq::plexFreeNextYpos1_return#0 plex_irq::$4 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:22 [ plex_irq::plexFreeNextYpos1_return#0 ]
Removing always clobbered register reg byte a as potential for zp[1]:23 [ plex_irq::$4 ]
Statement [91] *((const byte*) IRQ_STATUS) ← (const byte) IRQ_RASTER [ plex_show_idx plex_irq::plexFreeNextYpos1_return#0 ] (  [ plex_show_idx plex_irq::plexFreeNextYpos1_return#0 ] ) always clobbers reg byte a 
Statement [92] if((byte) plex_show_idx<(const byte) PLEX_COUNT) goto plex_irq::@1 [ plex_irq::plexFreeNextYpos1_return#0 ] (  [ plex_irq::plexFreeNextYpos1_return#0 ] ) always clobbers reg byte a 
Statement [93] (bool) framedone ← true [ ] (  [ ] ) always clobbers reg byte a 
Statement [94] *((const byte*) BORDERCOL) ← (byte) 0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [97] (byte) plexShowSprite::plex_sprite_idx2#0 ← (byte) plex_sprite_idx << (byte) 1 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 ] ) always clobbers reg byte a 
Statement [98] (byte) plexShowSprite::plexFreeAdd1_ypos#0 ← *((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx)) [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::plexFreeAdd1_ypos#0 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::plexFreeAdd1_ypos#0 ] ) always clobbers reg byte x reg byte y 
Removing always clobbered register reg byte x as potential for zp[1]:24 [ plexShowSprite::plex_sprite_idx2#0 ]
Removing always clobbered register reg byte y as potential for zp[1]:24 [ plexShowSprite::plex_sprite_idx2#0 ]
Statement [101] *((const byte*) PLEX_FREE_YPOS + (byte) plex_free_next) ← (byte~) plexShowSprite::plexFreeAdd1_$0 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 ] ) always clobbers reg byte y 
Statement [105] *((const byte*) PLEX_SCREEN_PTR#0 + (byte) plex_sprite_idx) ← *((const byte*) PLEX_PTR + *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx)) [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 ] ) always clobbers reg byte a reg byte x reg byte y 
Removing always clobbered register reg byte a as potential for zp[1]:24 [ plexShowSprite::plex_sprite_idx2#0 ]
Statement [106] (byte) plexShowSprite::xpos_idx#0 ← *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx) [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::xpos_idx#0 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::xpos_idx#0 ] ) always clobbers reg byte y 
Statement [107] (byte~) plexShowSprite::$11 ← (byte) plexShowSprite::xpos_idx#0 << (byte) 1 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::$11 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::$11 ] ) always clobbers reg byte a 
Statement [108] (byte~) plexShowSprite::$2 ← < *((const word*) PLEX_XPOS + (byte~) plexShowSprite::$11) [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::$11 plexShowSprite::$2 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::$11 plexShowSprite::$2 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp[1]:30 [ plexShowSprite::$11 ]
Statement [109] *((const byte*) SPRITES_XPOS + (byte) plexShowSprite::plex_sprite_idx2#0) ← (byte~) plexShowSprite::$2 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::$11 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::$11 ] ) always clobbers reg byte y 
Removing always clobbered register reg byte y as potential for zp[1]:30 [ plexShowSprite::$11 ]
Statement [110] (byte~) plexShowSprite::$3 ← > *((const word*) PLEX_XPOS + (byte~) plexShowSprite::$11) [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::$3 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::$3 ] ) always clobbers reg byte a 
Statement [112] (byte~) plexShowSprite::$9 ← (byte) $ff ^ (byte) plex_sprite_msb [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::$9 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::$9 ] ) always clobbers reg byte a 
Statement [113] *((const byte*) SPRITES_XMSB) ← *((const byte*) SPRITES_XMSB) & (byte~) plexShowSprite::$9 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ) always clobbers reg byte a 
Statement [119] if((byte) plex_sprite_msb!=(byte) 0) goto plexShowSprite::@return [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ) always clobbers reg byte a 
Statement [120] (byte) plex_sprite_msb ← (byte) 1 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ) always clobbers reg byte a 
Statement [122] *((const byte*) SPRITES_XMSB) ← *((const byte*) SPRITES_XMSB) | (byte) plex_sprite_msb [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ) always clobbers reg byte a 
Statement [1] (byte) plex_show_idx ← (byte) 0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [2] (byte) plex_sprite_idx ← (byte) 0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [3] (byte) plex_sprite_msb ← (byte) 1 [ ] (  [ ] ) always clobbers reg byte a 
Statement [4] (byte) plex_free_next ← (byte) 0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [5] (bool) framedone ← true [ framedone ] (  [ framedone ] ) always clobbers reg byte a 
Statement [16] if((bool) framedone) goto loop::@3 [ framedone loop::sin_idx#6 ] ( main:7::loop:12 [ framedone loop::sin_idx#6 ] ) always clobbers reg byte a 
Statement [17] *((const byte*) BORDERCOL) ← (const byte) RED [ loop::sin_idx#6 ] ( main:7::loop:12 [ loop::sin_idx#6 ] ) always clobbers reg byte a 
Statement [20] *((const byte*) PLEX_YPOS + (byte) loop::sy#2) ← *((const byte*) YSIN + (byte) loop::y_idx#2) [ loop::sin_idx#6 loop::y_idx#2 loop::sy#2 ] ( main:7::loop:12 [ loop::sin_idx#6 loop::y_idx#2 loop::sy#2 ] ) always clobbers reg byte a 
Statement [21] (byte) loop::y_idx#1 ← (byte) loop::y_idx#2 + (byte) 8 [ loop::sin_idx#6 loop::sy#2 loop::y_idx#1 ] ( main:7::loop:12 [ loop::sin_idx#6 loop::sy#2 loop::y_idx#1 ] ) always clobbers reg byte a 
Statement [27] *((const byte*) BORDERCOL) ← (const byte) GREEN [ loop::sin_idx#1 ] ( main:7::loop:12 [ loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [28] (bool) framedone ← false [ framedone loop::sin_idx#1 ] ( main:7::loop:12 [ framedone loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [29] *((const byte*) VIC_CONTROL) ← *((const byte*) VIC_CONTROL) & (byte) $7f [ framedone loop::sin_idx#1 ] ( main:7::loop:12 [ framedone loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [30] *((const byte*) RASTER) ← (byte) 0 [ framedone loop::sin_idx#1 ] ( main:7::loop:12 [ framedone loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [35] if((byte) plexSort::nxt_y#0>=*((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::m#2))) goto plexSort::@2 [ plexSort::m#2 plexSort::nxt_idx#0 plexSort::nxt_y#0 ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 plexSort::m#2 plexSort::nxt_idx#0 plexSort::nxt_y#0 ] ) always clobbers reg byte a 
Statement [38] *((const byte*) PLEX_SORTED_IDX+(byte) 1 + (byte) plexSort::s#3) ← *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#3) [ plexSort::m#2 plexSort::nxt_idx#0 plexSort::nxt_y#0 plexSort::s#3 ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 plexSort::m#2 plexSort::nxt_idx#0 plexSort::nxt_y#0 plexSort::s#3 ] ) always clobbers reg byte a 
Statement [41] if((byte) plexSort::nxt_y#0<*((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#1))) goto plexSort::@3 [ plexSort::m#2 plexSort::nxt_idx#0 plexSort::nxt_y#0 plexSort::s#1 ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 plexSort::m#2 plexSort::nxt_idx#0 plexSort::nxt_y#0 plexSort::s#1 ] ) always clobbers reg byte a 
Statement [43] *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#2) ← (byte) plexSort::nxt_idx#0 [ plexSort::m#2 ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 plexSort::m#2 ] ) always clobbers reg byte a 
Statement [46] (byte) plex_show_idx ← (byte) 0 [ ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [47] (byte) plex_sprite_idx ← (byte) 0 [ ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [48] (byte) plex_sprite_msb ← (byte) 1 [ ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [51] *((const byte*) PLEX_FREE_YPOS + (byte) plexSort::plexFreePrepare1_s#2) ← (byte) 0 [ plexSort::plexFreePrepare1_s#2 ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 plexSort::plexFreePrepare1_s#2 ] ) always clobbers reg byte a 
Statement [54] (byte) plex_free_next ← (byte) 0 [ ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [56] *((const byte*) D011) ← (const byte) VIC_DEN|(const byte) VIC_RSEL|(byte) 3 [ ] ( main:7::init:10 [ framedone ] ) always clobbers reg byte a 
Statement [59] *((const byte*) PLEX_PTR + (byte) init::sx#2) ← (byte)(const byte*) SPRITE/(byte) $40 [ init::sx#2 init::xp#2 ] ( main:7::init:10 [ framedone init::sx#2 init::xp#2 ] ) always clobbers reg byte a 
Statement [60] (byte~) init::$3 ← (byte) init::sx#2 << (byte) 1 [ init::sx#2 init::xp#2 init::$3 ] ( main:7::init:10 [ framedone init::sx#2 init::xp#2 init::$3 ] ) always clobbers reg byte a 
Statement [61] *((const word*) PLEX_XPOS + (byte~) init::$3) ← (word) init::xp#2 [ init::sx#2 init::xp#2 ] ( main:7::init:10 [ framedone init::sx#2 init::xp#2 ] ) always clobbers reg byte a 
Statement [62] (word) init::xp#1 ← (word) init::xp#2 + (byte) 9 [ init::sx#2 init::xp#1 ] ( main:7::init:10 [ framedone init::sx#2 init::xp#1 ] ) always clobbers reg byte a 
Statement [65] *((const byte*) SPRITES_ENABLE) ← (byte) $ff [ ] ( main:7::init:10 [ framedone ] ) always clobbers reg byte a 
Statement [67] *((const byte*) SPRITES_COLS + (byte) init::ss#2) ← (const byte) GREEN [ init::ss#2 ] ( main:7::init:10 [ framedone init::ss#2 ] ) always clobbers reg byte a 
Statement [71] *((const byte*) CIA1_INTERRUPT) ← (const byte) CIA_INTERRUPT_CLEAR [ ] ( main:7::init:10 [ framedone ] ) always clobbers reg byte a 
Statement [72] *((const byte*) IRQ_ENABLE) ← (const byte) IRQ_RASTER [ ] ( main:7::init:10 [ framedone ] ) always clobbers reg byte a 
Statement [73] *((const byte*) IRQ_STATUS) ← (const byte) IRQ_RASTER [ ] ( main:7::init:10 [ framedone ] ) always clobbers reg byte a 
Statement [74] *((const void()**) KERNEL_IRQ) ← &interrupt(KERNEL_MIN)(void()) plex_irq() [ ] ( main:7::init:10 [ framedone ] ) always clobbers reg byte a 
Statement [84] *((const byte*) BORDERCOL) ← (const byte) WHITE [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] (  [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ) always clobbers reg byte a 
Statement [87] (byte) plex_irq::plexFreeNextYpos1_return#0 ← *((const byte*) PLEX_FREE_YPOS + (byte) plex_free_next) [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plex_irq::plexFreeNextYpos1_return#0 ] (  [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plex_irq::plexFreeNextYpos1_return#0 ] ) always clobbers reg byte y 
Statement [89] if((byte) plex_show_idx>=(const byte) PLEX_COUNT) goto plex_irq::@4 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plex_irq::plexFreeNextYpos1_return#0 plex_irq::$4 ] (  [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plex_irq::plexFreeNextYpos1_return#0 plex_irq::$4 ] ) always clobbers reg byte a 
Statement [91] *((const byte*) IRQ_STATUS) ← (const byte) IRQ_RASTER [ plex_show_idx plex_irq::plexFreeNextYpos1_return#0 ] (  [ plex_show_idx plex_irq::plexFreeNextYpos1_return#0 ] ) always clobbers reg byte a 
Statement [92] if((byte) plex_show_idx<(const byte) PLEX_COUNT) goto plex_irq::@1 [ plex_irq::plexFreeNextYpos1_return#0 ] (  [ plex_irq::plexFreeNextYpos1_return#0 ] ) always clobbers reg byte a 
Statement [93] (bool) framedone ← true [ ] (  [ ] ) always clobbers reg byte a 
Statement [94] *((const byte*) BORDERCOL) ← (byte) 0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [97] (byte) plexShowSprite::plex_sprite_idx2#0 ← (byte) plex_sprite_idx << (byte) 1 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 ] ) always clobbers reg byte a 
Statement [98] (byte) plexShowSprite::plexFreeAdd1_ypos#0 ← *((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx)) [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::plexFreeAdd1_ypos#0 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::plexFreeAdd1_ypos#0 ] ) always clobbers reg byte x reg byte y 
Statement [99] *((const byte*) SPRITES_YPOS + (byte) plexShowSprite::plex_sprite_idx2#0) ← (byte) plexShowSprite::plexFreeAdd1_ypos#0 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::plexFreeAdd1_ypos#0 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::plexFreeAdd1_ypos#0 ] ) always clobbers reg byte y 
Removing always clobbered register reg byte y as potential for zp[1]:25 [ plexShowSprite::plexFreeAdd1_ypos#0 ]
Statement [101] *((const byte*) PLEX_FREE_YPOS + (byte) plex_free_next) ← (byte~) plexShowSprite::plexFreeAdd1_$0 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 ] ) always clobbers reg byte y 
Statement [105] *((const byte*) PLEX_SCREEN_PTR#0 + (byte) plex_sprite_idx) ← *((const byte*) PLEX_PTR + *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx)) [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 ] ) always clobbers reg byte a reg byte x reg byte y 
Statement [106] (byte) plexShowSprite::xpos_idx#0 ← *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx) [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::xpos_idx#0 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::xpos_idx#0 ] ) always clobbers reg byte y 
Statement [107] (byte~) plexShowSprite::$11 ← (byte) plexShowSprite::xpos_idx#0 << (byte) 1 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::$11 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::$11 ] ) always clobbers reg byte a 
Statement [108] (byte~) plexShowSprite::$2 ← < *((const word*) PLEX_XPOS + (byte~) plexShowSprite::$11) [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::$11 plexShowSprite::$2 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::$11 plexShowSprite::$2 ] ) always clobbers reg byte a 
Statement [109] *((const byte*) SPRITES_XPOS + (byte) plexShowSprite::plex_sprite_idx2#0) ← (byte~) plexShowSprite::$2 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::$11 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::$11 ] ) always clobbers reg byte y 
Statement [110] (byte~) plexShowSprite::$3 ← > *((const word*) PLEX_XPOS + (byte~) plexShowSprite::$11) [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::$3 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::$3 ] ) always clobbers reg byte a 
Statement [112] (byte~) plexShowSprite::$9 ← (byte) $ff ^ (byte) plex_sprite_msb [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::$9 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::$9 ] ) always clobbers reg byte a 
Statement [113] *((const byte*) SPRITES_XMSB) ← *((const byte*) SPRITES_XMSB) & (byte~) plexShowSprite::$9 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ) always clobbers reg byte a 
Statement [119] if((byte) plex_sprite_msb!=(byte) 0) goto plexShowSprite::@return [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ) always clobbers reg byte a 
Statement [120] (byte) plex_sprite_msb ← (byte) 1 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ) always clobbers reg byte a 
Statement [122] *((const byte*) SPRITES_XMSB) ← *((const byte*) SPRITES_XMSB) | (byte) plex_sprite_msb [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ) always clobbers reg byte a 
Statement [1] (byte) plex_show_idx ← (byte) 0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [2] (byte) plex_sprite_idx ← (byte) 0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [3] (byte) plex_sprite_msb ← (byte) 1 [ ] (  [ ] ) always clobbers reg byte a 
Statement [4] (byte) plex_free_next ← (byte) 0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [5] (bool) framedone ← true [ framedone ] (  [ framedone ] ) always clobbers reg byte a 
Statement [16] if((bool) framedone) goto loop::@3 [ framedone loop::sin_idx#6 ] ( main:7::loop:12 [ framedone loop::sin_idx#6 ] ) always clobbers reg byte a 
Statement [17] *((const byte*) BORDERCOL) ← (const byte) RED [ loop::sin_idx#6 ] ( main:7::loop:12 [ loop::sin_idx#6 ] ) always clobbers reg byte a 
Statement [20] *((const byte*) PLEX_YPOS + (byte) loop::sy#2) ← *((const byte*) YSIN + (byte) loop::y_idx#2) [ loop::sin_idx#6 loop::y_idx#2 loop::sy#2 ] ( main:7::loop:12 [ loop::sin_idx#6 loop::y_idx#2 loop::sy#2 ] ) always clobbers reg byte a 
Statement [21] (byte) loop::y_idx#1 ← (byte) loop::y_idx#2 + (byte) 8 [ loop::sin_idx#6 loop::sy#2 loop::y_idx#1 ] ( main:7::loop:12 [ loop::sin_idx#6 loop::sy#2 loop::y_idx#1 ] ) always clobbers reg byte a 
Statement [27] *((const byte*) BORDERCOL) ← (const byte) GREEN [ loop::sin_idx#1 ] ( main:7::loop:12 [ loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [28] (bool) framedone ← false [ framedone loop::sin_idx#1 ] ( main:7::loop:12 [ framedone loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [29] *((const byte*) VIC_CONTROL) ← *((const byte*) VIC_CONTROL) & (byte) $7f [ framedone loop::sin_idx#1 ] ( main:7::loop:12 [ framedone loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [30] *((const byte*) RASTER) ← (byte) 0 [ framedone loop::sin_idx#1 ] ( main:7::loop:12 [ framedone loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [35] if((byte) plexSort::nxt_y#0>=*((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::m#2))) goto plexSort::@2 [ plexSort::m#2 plexSort::nxt_idx#0 plexSort::nxt_y#0 ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 plexSort::m#2 plexSort::nxt_idx#0 plexSort::nxt_y#0 ] ) always clobbers reg byte a 
Statement [38] *((const byte*) PLEX_SORTED_IDX+(byte) 1 + (byte) plexSort::s#3) ← *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#3) [ plexSort::m#2 plexSort::nxt_idx#0 plexSort::nxt_y#0 plexSort::s#3 ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 plexSort::m#2 plexSort::nxt_idx#0 plexSort::nxt_y#0 plexSort::s#3 ] ) always clobbers reg byte a 
Statement [41] if((byte) plexSort::nxt_y#0<*((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#1))) goto plexSort::@3 [ plexSort::m#2 plexSort::nxt_idx#0 plexSort::nxt_y#0 plexSort::s#1 ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 plexSort::m#2 plexSort::nxt_idx#0 plexSort::nxt_y#0 plexSort::s#1 ] ) always clobbers reg byte a 
Statement [43] *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#2) ← (byte) plexSort::nxt_idx#0 [ plexSort::m#2 ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 plexSort::m#2 ] ) always clobbers reg byte a 
Statement [46] (byte) plex_show_idx ← (byte) 0 [ ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [47] (byte) plex_sprite_idx ← (byte) 0 [ ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [48] (byte) plex_sprite_msb ← (byte) 1 [ ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [51] *((const byte*) PLEX_FREE_YPOS + (byte) plexSort::plexFreePrepare1_s#2) ← (byte) 0 [ plexSort::plexFreePrepare1_s#2 ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 plexSort::plexFreePrepare1_s#2 ] ) always clobbers reg byte a 
Statement [54] (byte) plex_free_next ← (byte) 0 [ ] ( main:7::loop:12::plexSort:26 [ loop::sin_idx#1 ] ) always clobbers reg byte a 
Statement [56] *((const byte*) D011) ← (const byte) VIC_DEN|(const byte) VIC_RSEL|(byte) 3 [ ] ( main:7::init:10 [ framedone ] ) always clobbers reg byte a 
Statement [59] *((const byte*) PLEX_PTR + (byte) init::sx#2) ← (byte)(const byte*) SPRITE/(byte) $40 [ init::sx#2 init::xp#2 ] ( main:7::init:10 [ framedone init::sx#2 init::xp#2 ] ) always clobbers reg byte a 
Statement [60] (byte~) init::$3 ← (byte) init::sx#2 << (byte) 1 [ init::sx#2 init::xp#2 init::$3 ] ( main:7::init:10 [ framedone init::sx#2 init::xp#2 init::$3 ] ) always clobbers reg byte a 
Statement [61] *((const word*) PLEX_XPOS + (byte~) init::$3) ← (word) init::xp#2 [ init::sx#2 init::xp#2 ] ( main:7::init:10 [ framedone init::sx#2 init::xp#2 ] ) always clobbers reg byte a 
Statement [62] (word) init::xp#1 ← (word) init::xp#2 + (byte) 9 [ init::sx#2 init::xp#1 ] ( main:7::init:10 [ framedone init::sx#2 init::xp#1 ] ) always clobbers reg byte a 
Statement [65] *((const byte*) SPRITES_ENABLE) ← (byte) $ff [ ] ( main:7::init:10 [ framedone ] ) always clobbers reg byte a 
Statement [67] *((const byte*) SPRITES_COLS + (byte) init::ss#2) ← (const byte) GREEN [ init::ss#2 ] ( main:7::init:10 [ framedone init::ss#2 ] ) always clobbers reg byte a 
Statement [71] *((const byte*) CIA1_INTERRUPT) ← (const byte) CIA_INTERRUPT_CLEAR [ ] ( main:7::init:10 [ framedone ] ) always clobbers reg byte a 
Statement [72] *((const byte*) IRQ_ENABLE) ← (const byte) IRQ_RASTER [ ] ( main:7::init:10 [ framedone ] ) always clobbers reg byte a 
Statement [73] *((const byte*) IRQ_STATUS) ← (const byte) IRQ_RASTER [ ] ( main:7::init:10 [ framedone ] ) always clobbers reg byte a 
Statement [74] *((const void()**) KERNEL_IRQ) ← &interrupt(KERNEL_MIN)(void()) plex_irq() [ ] ( main:7::init:10 [ framedone ] ) always clobbers reg byte a 
Statement [84] *((const byte*) BORDERCOL) ← (const byte) WHITE [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] (  [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ) always clobbers reg byte a 
Statement [87] (byte) plex_irq::plexFreeNextYpos1_return#0 ← *((const byte*) PLEX_FREE_YPOS + (byte) plex_free_next) [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plex_irq::plexFreeNextYpos1_return#0 ] (  [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plex_irq::plexFreeNextYpos1_return#0 ] ) always clobbers reg byte y 
Statement [89] if((byte) plex_show_idx>=(const byte) PLEX_COUNT) goto plex_irq::@4 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plex_irq::plexFreeNextYpos1_return#0 plex_irq::$4 ] (  [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plex_irq::plexFreeNextYpos1_return#0 plex_irq::$4 ] ) always clobbers reg byte a 
Statement [91] *((const byte*) IRQ_STATUS) ← (const byte) IRQ_RASTER [ plex_show_idx plex_irq::plexFreeNextYpos1_return#0 ] (  [ plex_show_idx plex_irq::plexFreeNextYpos1_return#0 ] ) always clobbers reg byte a 
Statement [92] if((byte) plex_show_idx<(const byte) PLEX_COUNT) goto plex_irq::@1 [ plex_irq::plexFreeNextYpos1_return#0 ] (  [ plex_irq::plexFreeNextYpos1_return#0 ] ) always clobbers reg byte a 
Statement [93] (bool) framedone ← true [ ] (  [ ] ) always clobbers reg byte a 
Statement [94] *((const byte*) BORDERCOL) ← (byte) 0 [ ] (  [ ] ) always clobbers reg byte a 
Statement [97] (byte) plexShowSprite::plex_sprite_idx2#0 ← (byte) plex_sprite_idx << (byte) 1 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 ] ) always clobbers reg byte a 
Statement [98] (byte) plexShowSprite::plexFreeAdd1_ypos#0 ← *((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx)) [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::plexFreeAdd1_ypos#0 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::plexFreeAdd1_ypos#0 ] ) always clobbers reg byte x reg byte y 
Statement [99] *((const byte*) SPRITES_YPOS + (byte) plexShowSprite::plex_sprite_idx2#0) ← (byte) plexShowSprite::plexFreeAdd1_ypos#0 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::plexFreeAdd1_ypos#0 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::plexFreeAdd1_ypos#0 ] ) always clobbers reg byte y 
Statement [101] *((const byte*) PLEX_FREE_YPOS + (byte) plex_free_next) ← (byte~) plexShowSprite::plexFreeAdd1_$0 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 ] ) always clobbers reg byte y 
Statement [105] *((const byte*) PLEX_SCREEN_PTR#0 + (byte) plex_sprite_idx) ← *((const byte*) PLEX_PTR + *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx)) [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 ] ) always clobbers reg byte a reg byte x reg byte y 
Statement [106] (byte) plexShowSprite::xpos_idx#0 ← *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx) [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::xpos_idx#0 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::xpos_idx#0 ] ) always clobbers reg byte y 
Statement [107] (byte~) plexShowSprite::$11 ← (byte) plexShowSprite::xpos_idx#0 << (byte) 1 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::$11 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::$11 ] ) always clobbers reg byte a 
Statement [108] (byte~) plexShowSprite::$2 ← < *((const word*) PLEX_XPOS + (byte~) plexShowSprite::$11) [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::$11 plexShowSprite::$2 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::plex_sprite_idx2#0 plexShowSprite::$11 plexShowSprite::$2 ] ) always clobbers reg byte a 
Statement [109] *((const byte*) SPRITES_XPOS + (byte) plexShowSprite::plex_sprite_idx2#0) ← (byte~) plexShowSprite::$2 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::$11 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::$11 ] ) always clobbers reg byte y 
Statement [110] (byte~) plexShowSprite::$3 ← > *((const word*) PLEX_XPOS + (byte~) plexShowSprite::$11) [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::$3 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::$3 ] ) always clobbers reg byte a 
Statement [112] (byte~) plexShowSprite::$9 ← (byte) $ff ^ (byte) plex_sprite_msb [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::$9 ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next plexShowSprite::$9 ] ) always clobbers reg byte a 
Statement [113] *((const byte*) SPRITES_XMSB) ← *((const byte*) SPRITES_XMSB) & (byte~) plexShowSprite::$9 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ) always clobbers reg byte a 
Statement [119] if((byte) plex_sprite_msb!=(byte) 0) goto plexShowSprite::@return [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ) always clobbers reg byte a 
Statement [120] (byte) plex_sprite_msb ← (byte) 1 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ) always clobbers reg byte a 
Statement [122] *((const byte*) SPRITES_XMSB) ← *((const byte*) SPRITES_XMSB) | (byte) plex_sprite_msb [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ( plexShowSprite:86 [ plex_show_idx plex_sprite_idx plex_sprite_msb plex_free_next ] ) always clobbers reg byte a 
Potential registers zp[1]:2 [ loop::sin_idx#6 loop::sin_idx#1 ] : zp[1]:2 , reg byte x , reg byte y , 
Potential registers zp[1]:3 [ loop::y_idx#2 loop::y_idx#1 loop::y_idx#4 ] : zp[1]:3 , reg byte x , reg byte y , 
Potential registers zp[1]:4 [ loop::sy#2 loop::sy#1 ] : zp[1]:4 , reg byte x , reg byte y , 
Potential registers zp[1]:5 [ plexSort::m#2 plexSort::m#1 ] : zp[1]:5 , reg byte x , reg byte y , 
Potential registers zp[1]:6 [ plexSort::s#3 plexSort::s#1 plexSort::s#6 ] : zp[1]:6 , reg byte x , reg byte y , 
Potential registers zp[1]:7 [ plexSort::plexFreePrepare1_s#2 plexSort::plexFreePrepare1_s#1 ] : zp[1]:7 , reg byte x , reg byte y , 
Potential registers zp[1]:8 [ init::sx#2 init::sx#1 ] : zp[1]:8 , reg byte x , reg byte y , 
Potential registers zp[2]:9 [ init::xp#2 init::xp#1 ] : zp[2]:9 , 
Potential registers zp[1]:11 [ init::ss#2 init::ss#1 ] : zp[1]:11 , reg byte x , reg byte y , 
Potential registers zp[1]:12 [ plexInit::i#2 plexInit::i#1 ] : zp[1]:12 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:13 [ plex_show_idx ] : zp[1]:13 , 
Potential registers zp[1]:14 [ plex_sprite_idx ] : zp[1]:14 , 
Potential registers zp[1]:15 [ plex_sprite_msb ] : zp[1]:15 , 
Potential registers zp[1]:16 [ plex_free_next ] : zp[1]:16 , 
Potential registers zp[1]:17 [ framedone ] : zp[1]:17 , 
Potential registers zp[1]:18 [ plexSort::nxt_idx#0 ] : zp[1]:18 , reg byte x , reg byte y , 
Potential registers zp[1]:19 [ plexSort::nxt_y#0 ] : zp[1]:19 , reg byte x , reg byte y , 
Potential registers zp[1]:20 [ plexSort::s#2 ] : zp[1]:20 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:21 [ init::$3 ] : zp[1]:21 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:22 [ plex_irq::plexFreeNextYpos1_return#0 ] : zp[1]:22 , reg byte x , reg byte y , 
Potential registers zp[1]:23 [ plex_irq::$4 ] : zp[1]:23 , reg byte x , reg byte y , 
Potential registers zp[1]:24 [ plexShowSprite::plex_sprite_idx2#0 ] : zp[1]:24 , 
Potential registers zp[1]:25 [ plexShowSprite::plexFreeAdd1_ypos#0 ] : zp[1]:25 , reg byte a , reg byte x , 
Potential registers zp[1]:26 [ plexShowSprite::plexFreeAdd1_$0 ] : zp[1]:26 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:27 [ plexShowSprite::plexFreeAdd1_$1 ] : zp[1]:27 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:28 [ plexShowSprite::plexFreeAdd1_$2 ] : zp[1]:28 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:29 [ plexShowSprite::xpos_idx#0 ] : zp[1]:29 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:30 [ plexShowSprite::$11 ] : zp[1]:30 , reg byte x , 
Potential registers zp[1]:31 [ plexShowSprite::$2 ] : zp[1]:31 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:32 [ plexShowSprite::$3 ] : zp[1]:32 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:33 [ plexShowSprite::$9 ] : zp[1]:33 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:34 [ plexShowSprite::$5 ] : zp[1]:34 , reg byte a , reg byte x , reg byte y , 
Potential registers zp[1]:35 [ plexShowSprite::$6 ] : zp[1]:35 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [plexSort] 3,622.83: zp[1]:6 [ plexSort::s#3 plexSort::s#1 plexSort::s#6 ] 303: zp[1]:7 [ plexSort::plexFreePrepare1_s#2 plexSort::plexFreePrepare1_s#1 ] 202: zp[1]:20 [ plexSort::s#2 ] 193.58: zp[1]:5 [ plexSort::m#2 plexSort::m#1 ] 150.38: zp[1]:19 [ plexSort::nxt_y#0 ] 30.3: zp[1]:18 [ plexSort::nxt_idx#0 ] 
Uplift Scope [loop] 252.5: zp[1]:4 [ loop::sy#2 loop::sy#1 ] 246.33: zp[1]:3 [ loop::y_idx#2 loop::y_idx#1 loop::y_idx#4 ] 6.81: zp[1]:2 [ loop::sin_idx#6 loop::sin_idx#1 ] 
Uplift Scope [init] 33: zp[1]:11 [ init::ss#2 init::ss#1 ] 25.3: zp[1]:8 [ init::sx#2 init::sx#1 ] 22: zp[1]:21 [ init::$3 ] 15.58: zp[2]:9 [ init::xp#2 init::xp#1 ] 
Uplift Scope [plexShowSprite] 4: zp[1]:26 [ plexShowSprite::plexFreeAdd1_$0 ] 4: zp[1]:27 [ plexShowSprite::plexFreeAdd1_$1 ] 4: zp[1]:28 [ plexShowSprite::plexFreeAdd1_$2 ] 4: zp[1]:29 [ plexShowSprite::xpos_idx#0 ] 4: zp[1]:31 [ plexShowSprite::$2 ] 4: zp[1]:32 [ plexShowSprite::$3 ] 4: zp[1]:33 [ plexShowSprite::$9 ] 4: zp[1]:34 [ plexShowSprite::$5 ] 4: zp[1]:35 [ plexShowSprite::$6 ] 3: zp[1]:25 [ plexShowSprite::plexFreeAdd1_ypos#0 ] 2: zp[1]:30 [ plexShowSprite::$11 ] 0.5: zp[1]:24 [ plexShowSprite::plex_sprite_idx2#0 ] 
Uplift Scope [plexInit] 38.5: zp[1]:12 [ plexInit::i#2 plexInit::i#1 ] 
Uplift Scope [plex_irq] 11: zp[1]:23 [ plex_irq::$4 ] 4: zp[1]:22 [ plex_irq::plexFreeNextYpos1_return#0 ] 
Uplift Scope [] 10.55: zp[1]:17 [ framedone ] 0.79: zp[1]:13 [ plex_show_idx ] 0.68: zp[1]:16 [ plex_free_next ] 0.48: zp[1]:15 [ plex_sprite_msb ] 0.39: zp[1]:14 [ plex_sprite_idx ] 
Uplift Scope [main] 

Uplifting [plexSort] best 60379 combination reg byte x [ plexSort::s#3 plexSort::s#1 plexSort::s#6 ] reg byte x [ plexSort::plexFreePrepare1_s#2 plexSort::plexFreePrepare1_s#1 ] zp[1]:20 [ plexSort::s#2 ] zp[1]:5 [ plexSort::m#2 plexSort::m#1 ] zp[1]:19 [ plexSort::nxt_y#0 ] zp[1]:18 [ plexSort::nxt_idx#0 ] 
Limited combination testing to 10 combinations of 972 possible.
Uplifting [loop] best 58449 combination reg byte y [ loop::sy#2 loop::sy#1 ] reg byte x [ loop::y_idx#2 loop::y_idx#1 loop::y_idx#4 ] zp[1]:2 [ loop::sin_idx#6 loop::sin_idx#1 ] 
Limited combination testing to 10 combinations of 27 possible.
Uplifting [init] best 58199 combination reg byte x [ init::ss#2 init::ss#1 ] reg byte x [ init::sx#2 init::sx#1 ] zp[1]:21 [ init::$3 ] zp[2]:9 [ init::xp#2 init::xp#1 ] 
Limited combination testing to 10 combinations of 36 possible.
Uplifting [plexShowSprite] best 58189 combination reg byte a [ plexShowSprite::plexFreeAdd1_$0 ] reg byte x [ plexShowSprite::plexFreeAdd1_$1 ] zp[1]:28 [ plexShowSprite::plexFreeAdd1_$2 ] zp[1]:29 [ plexShowSprite::xpos_idx#0 ] zp[1]:31 [ plexShowSprite::$2 ] zp[1]:32 [ plexShowSprite::$3 ] zp[1]:33 [ plexShowSprite::$9 ] zp[1]:34 [ plexShowSprite::$5 ] zp[1]:35 [ plexShowSprite::$6 ] zp[1]:25 [ plexShowSprite::plexFreeAdd1_ypos#0 ] zp[1]:30 [ plexShowSprite::$11 ] zp[1]:24 [ plexShowSprite::plex_sprite_idx2#0 ] 
Limited combination testing to 10 combinations of 1572864 possible.
Uplifting [plexInit] best 58069 combination reg byte x [ plexInit::i#2 plexInit::i#1 ] 
Uplifting [plex_irq] best 58006 combination zp[1]:23 [ plex_irq::$4 ] reg byte x [ plex_irq::plexFreeNextYpos1_return#0 ] 
Uplifting [] best 58006 combination zp[1]:17 [ framedone ] zp[1]:13 [ plex_show_idx ] zp[1]:16 [ plex_free_next ] zp[1]:15 [ plex_sprite_msb ] zp[1]:14 [ plex_sprite_idx ] 
Uplifting [main] best 58006 combination 
Attempting to uplift remaining variables inzp[1]:20 [ plexSort::s#2 ]
Uplifting [plexSort] best 57406 combination reg byte x [ plexSort::s#2 ] 
Attempting to uplift remaining variables inzp[1]:5 [ plexSort::m#2 plexSort::m#1 ]
Uplifting [plexSort] best 57406 combination zp[1]:5 [ plexSort::m#2 plexSort::m#1 ] 
Attempting to uplift remaining variables inzp[1]:19 [ plexSort::nxt_y#0 ]
Uplifting [plexSort] best 57406 combination zp[1]:19 [ plexSort::nxt_y#0 ] 
Attempting to uplift remaining variables inzp[1]:18 [ plexSort::nxt_idx#0 ]
Uplifting [plexSort] best 57406 combination zp[1]:18 [ plexSort::nxt_idx#0 ] 
Attempting to uplift remaining variables inzp[1]:21 [ init::$3 ]
Uplifting [init] best 57366 combination reg byte a [ init::$3 ] 
Attempting to uplift remaining variables inzp[1]:23 [ plex_irq::$4 ]
Uplifting [plex_irq] best 57366 combination zp[1]:23 [ plex_irq::$4 ] 
Attempting to uplift remaining variables inzp[1]:17 [ framedone ]
Uplifting [] best 57366 combination zp[1]:17 [ framedone ] 
Attempting to uplift remaining variables inzp[1]:2 [ loop::sin_idx#6 loop::sin_idx#1 ]
Uplifting [loop] best 57366 combination zp[1]:2 [ loop::sin_idx#6 loop::sin_idx#1 ] 
Attempting to uplift remaining variables inzp[1]:28 [ plexShowSprite::plexFreeAdd1_$2 ]
Uplifting [plexShowSprite] best 57362 combination reg byte a [ plexShowSprite::plexFreeAdd1_$2 ] 
Attempting to uplift remaining variables inzp[1]:29 [ plexShowSprite::xpos_idx#0 ]
Uplifting [plexShowSprite] best 57356 combination reg byte a [ plexShowSprite::xpos_idx#0 ] 
Attempting to uplift remaining variables inzp[1]:31 [ plexShowSprite::$2 ]
Uplifting [plexShowSprite] best 57350 combination reg byte a [ plexShowSprite::$2 ] 
Attempting to uplift remaining variables inzp[1]:32 [ plexShowSprite::$3 ]
Uplifting [plexShowSprite] best 57344 combination reg byte a [ plexShowSprite::$3 ] 
Attempting to uplift remaining variables inzp[1]:33 [ plexShowSprite::$9 ]
Uplifting [plexShowSprite] best 57338 combination reg byte a [ plexShowSprite::$9 ] 
Attempting to uplift remaining variables inzp[1]:34 [ plexShowSprite::$5 ]
Uplifting [plexShowSprite] best 57332 combination reg byte x [ plexShowSprite::$5 ] 
Attempting to uplift remaining variables inzp[1]:35 [ plexShowSprite::$6 ]
Uplifting [plexShowSprite] best 57328 combination reg byte a [ plexShowSprite::$6 ] 
Attempting to uplift remaining variables inzp[1]:25 [ plexShowSprite::plexFreeAdd1_ypos#0 ]
Uplifting [plexShowSprite] best 57319 combination reg byte a [ plexShowSprite::plexFreeAdd1_ypos#0 ] 
Attempting to uplift remaining variables inzp[1]:30 [ plexShowSprite::$11 ]
Uplifting [plexShowSprite] best 57312 combination reg byte x [ plexShowSprite::$11 ] 
Attempting to uplift remaining variables inzp[1]:13 [ plex_show_idx ]
Uplifting [] best 57312 combination zp[1]:13 [ plex_show_idx ] 
Attempting to uplift remaining variables inzp[1]:16 [ plex_free_next ]
Uplifting [] best 57312 combination zp[1]:16 [ plex_free_next ] 
Attempting to uplift remaining variables inzp[1]:24 [ plexShowSprite::plex_sprite_idx2#0 ]
Uplifting [plexShowSprite] best 57312 combination zp[1]:24 [ plexShowSprite::plex_sprite_idx2#0 ] 
Attempting to uplift remaining variables inzp[1]:15 [ plex_sprite_msb ]
Uplifting [] best 57312 combination zp[1]:15 [ plex_sprite_msb ] 
Attempting to uplift remaining variables inzp[1]:14 [ plex_sprite_idx ]
Uplifting [] best 57312 combination zp[1]:14 [ plex_sprite_idx ] 
Coalescing zero page register [ zp[1]:24 [ plexShowSprite::plex_sprite_idx2#0 ] ] with [ zp[1]:23 [ plex_irq::$4 ] ]
Allocated (was zp[1]:5) zp[1]:3 [ plexSort::m#2 plexSort::m#1 ]
Allocated (was zp[2]:9) zp[2]:4 [ init::xp#2 init::xp#1 ]
Allocated (was zp[1]:13) zp[1]:6 [ plex_show_idx ]
Allocated (was zp[1]:14) zp[1]:7 [ plex_sprite_idx ]
Allocated (was zp[1]:15) zp[1]:8 [ plex_sprite_msb ]
Allocated (was zp[1]:16) zp[1]:9 [ plex_free_next ]
Allocated (was zp[1]:17) zp[1]:10 [ framedone ]
Allocated (was zp[1]:18) zp[1]:11 [ plexSort::nxt_idx#0 ]
Allocated (was zp[1]:19) zp[1]:12 [ plexSort::nxt_y#0 ]
Allocated (was zp[1]:24) zp[1]:13 [ plexShowSprite::plex_sprite_idx2#0 plex_irq::$4 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// A simple usage of the flexible sprite multiplexer routine
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
  // Global Constants & labels
  .label SPRITES_XPOS = $d000
  .label SPRITES_YPOS = $d001
  .label SPRITES_XMSB = $d010
  .label RASTER = $d012
  .label SPRITES_ENABLE = $d015
  .label BORDERCOL = $d020
  .label SPRITES_COLS = $d027
  .label VIC_CONTROL = $d011
  .label D011 = $d011
  .const VIC_DEN = $10
  .const VIC_RSEL = 8
  // VIC II IRQ Status Register
  .label IRQ_STATUS = $d019
  // VIC II IRQ Enable Register
  .label IRQ_ENABLE = $d01a
  // Bits for the IRQ Status/Enable Registers
  .const IRQ_RASTER = 1
  // CIA#1 Interrupt Status & Control Register
  .label CIA1_INTERRUPT = $dc0d
  // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
  .const CIA_INTERRUPT_CLEAR = $7f
  // The vector used when the KERNAL serves IRQ interrupts
  .label KERNEL_IRQ = $314
  .const WHITE = 1
  .const RED = 2
  .const GREEN = 5
  // The number of sprites in the multiplexer
  .const PLEX_COUNT = $20
  // The address of the sprite pointers on the current screen (screen+0x3f8).
  .label PLEX_SCREEN_PTR = $400+$3f8
  .label plex_show_idx = 6
  .label plex_sprite_idx = 7
  .label plex_sprite_msb = 8
  .label plex_free_next = 9
  .label framedone = $a
  // @begin
__bbegin:
  jmp __b1
  // @1
__b1:
  // [1] (byte) plex_show_idx ← (byte) 0 -- vbuz1=vbuc1 
  // The index in the PLEX tables of the next sprite to show
  lda #0
  sta.z plex_show_idx
  // [2] (byte) plex_sprite_idx ← (byte) 0 -- vbuz1=vbuc1 
  // The index the next sprite to use for showing (sprites are used round-robin)
  lda #0
  sta.z plex_sprite_idx
  // [3] (byte) plex_sprite_msb ← (byte) 1 -- vbuz1=vbuc1 
  // The MSB bit of the next sprite to use for showing
  lda #1
  sta.z plex_sprite_msb
  jmp __b2
  // @2
__b2:
  // [4] (byte) plex_free_next ← (byte) 0 -- vbuz1=vbuc1 
  // The index of the sprite that is free next. Since sprites are used round-robin this moves forward each time a sprite is shown.
  lda #0
  sta.z plex_free_next
  jmp __b3
  // @3
__b3:
  // [5] (bool) framedone ← true -- vboz1=vboc1 
  lda #1
  sta.z framedone
  // [6] phi from @3 to @4 [phi:@3->@4]
__b4_from___b3:
  jmp __b4
  // @4
__b4:
  // [7] call main 
  jsr main
  // [8] phi from @4 to @end [phi:@4->@end]
__bend_from___b4:
  jmp __bend
  // @end
__bend:
  // main
main: {
    // asm { sei  }
    sei
    // [10] call init 
    jsr init
    // [11] phi from main to main::@1 [phi:main->main::@1]
  __b1_from_main:
    jmp __b1
    // main::@1
  __b1:
    // [12] call loop 
    // [14] phi from main::@1 to loop [phi:main::@1->loop]
  loop_from___b1:
    jsr loop
    jmp __breturn
    // main::@return
  __breturn:
    // [13] return 
    rts
}
  // loop
// The raster loop
loop: {
    // The current index into the y-sinus
    .label sin_idx = 2
    // [15] phi from loop to loop::@1 [phi:loop->loop::@1]
  __b1_from_loop:
    // [15] phi (byte) loop::sin_idx#6 = (byte) 0 [phi:loop->loop::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z sin_idx
    jmp __b1
    // loop::@1
  __b1:
    jmp __b2
    // loop::@2
  __b2:
    // [16] if((bool) framedone) goto loop::@3 -- vboz1_then_la1 
    lda.z framedone
    cmp #0
    bne __b3
    jmp __b2
    // loop::@3
  __b3:
    // [17] *((const byte*) BORDERCOL) ← (const byte) RED -- _deref_pbuc1=vbuc2 
    lda #RED
    sta BORDERCOL
    // [18] (byte) loop::y_idx#4 ← (byte) loop::sin_idx#6 -- vbuxx=vbuz1 
    ldx.z sin_idx
    // [19] phi from loop::@3 to loop::@4 [phi:loop::@3->loop::@4]
  __b4_from___b3:
    // [19] phi (byte) loop::sy#2 = (byte) 0 [phi:loop::@3->loop::@4#0] -- vbuyy=vbuc1 
    ldy #0
    // [19] phi (byte) loop::y_idx#2 = (byte) loop::y_idx#4 [phi:loop::@3->loop::@4#1] -- register_copy 
    jmp __b4
    // [19] phi from loop::@4 to loop::@4 [phi:loop::@4->loop::@4]
  __b4_from___b4:
    // [19] phi (byte) loop::sy#2 = (byte) loop::sy#1 [phi:loop::@4->loop::@4#0] -- register_copy 
    // [19] phi (byte) loop::y_idx#2 = (byte) loop::y_idx#1 [phi:loop::@4->loop::@4#1] -- register_copy 
    jmp __b4
    // loop::@4
  __b4:
    // [20] *((const byte*) PLEX_YPOS + (byte) loop::sy#2) ← *((const byte*) YSIN + (byte) loop::y_idx#2) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuxx 
    lda YSIN,x
    sta PLEX_YPOS,y
    // [21] (byte) loop::y_idx#1 ← (byte) loop::y_idx#2 + (byte) 8 -- vbuxx=vbuxx_plus_vbuc1 
    txa
    axs #-[8]
    // [22] (byte) loop::sy#1 ← ++ (byte) loop::sy#2 -- vbuyy=_inc_vbuyy 
    iny
    // [23] if((byte) loop::sy#1!=(const byte) PLEX_COUNT-(byte) 1+(byte) 1) goto loop::@4 -- vbuyy_neq_vbuc1_then_la1 
    cpy #PLEX_COUNT-1+1
    bne __b4_from___b4
    jmp __b5
    // loop::@5
  __b5:
    // [24] (byte) loop::sin_idx#1 ← (byte) loop::sin_idx#6 + (byte) 1 -- vbuz1=vbuz1_plus_1 
    inc.z sin_idx
    // [25] *((const byte*) BORDERCOL) ← ++ *((const byte*) BORDERCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    // [26] call plexSort 
    // [31] phi from loop::@5 to plexSort [phi:loop::@5->plexSort]
  plexSort_from___b5:
    jsr plexSort
    jmp __b6
    // loop::@6
  __b6:
    // [27] *((const byte*) BORDERCOL) ← (const byte) GREEN -- _deref_pbuc1=vbuc2 
    lda #GREEN
    sta BORDERCOL
    // [28] (bool) framedone ← false -- vboz1=vboc1 
    lda #0
    sta.z framedone
    // [29] *((const byte*) VIC_CONTROL) ← *((const byte*) VIC_CONTROL) & (byte) $7f -- _deref_pbuc1=_deref_pbuc1_band_vbuc2 
    lda #$7f
    and VIC_CONTROL
    sta VIC_CONTROL
    // [30] *((const byte*) RASTER) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta RASTER
    // [15] phi from loop::@6 to loop::@1 [phi:loop::@6->loop::@1]
  __b1_from___b6:
    // [15] phi (byte) loop::sin_idx#6 = (byte) loop::sin_idx#1 [phi:loop::@6->loop::@1#0] -- register_copy 
    jmp __b1
}
  // plexSort
// Ensure that the indices in PLEX_SORTED_IDX is sorted based on the y-positions in PLEX_YPOS
// Assumes that the positions are nearly sorted already (as each sprite just moves a bit)
// Uses an insertion sort:
// 1. Moves a marker (m) from the start to end of the array. Every time the marker moves forward all elements before the marker are sorted correctly.
// 2a. If the next element after the marker is larger that the current element
//     the marker can be moved forwards (as the sorting is correct).
// 2b. If the next element after the marker is smaller than the current element:
//     elements before the marker are shifted right one at a time until encountering one smaller than the current one.
//      It is then inserted at the spot. Now the marker can move forward.
plexSort: {
    .label nxt_idx = $b
    .label nxt_y = $c
    .label m = 3
    // [32] phi from plexSort to plexSort::@1 [phi:plexSort->plexSort::@1]
  __b1_from_plexSort:
    // [32] phi (byte) plexSort::m#2 = (byte) 0 [phi:plexSort->plexSort::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z m
    jmp __b1
    // [32] phi from plexSort::@2 to plexSort::@1 [phi:plexSort::@2->plexSort::@1]
  __b1_from___b2:
    // [32] phi (byte) plexSort::m#2 = (byte) plexSort::m#1 [phi:plexSort::@2->plexSort::@1#0] -- register_copy 
    jmp __b1
    // plexSort::@1
  __b1:
    // [33] (byte) plexSort::nxt_idx#0 ← *((const byte*) PLEX_SORTED_IDX+(byte) 1 + (byte) plexSort::m#2) -- vbuz1=pbuc1_derefidx_vbuz2 
    ldy.z m
    lda PLEX_SORTED_IDX+1,y
    sta.z nxt_idx
    // [34] (byte) plexSort::nxt_y#0 ← *((const byte*) PLEX_YPOS + (byte) plexSort::nxt_idx#0) -- vbuz1=pbuc1_derefidx_vbuz2 
    ldy.z nxt_idx
    lda PLEX_YPOS,y
    sta.z nxt_y
    // [35] if((byte) plexSort::nxt_y#0>=*((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::m#2))) goto plexSort::@2 -- vbuz1_ge_pbuc1_derefidx_(pbuc2_derefidx_vbuz2)_then_la1 
    lda.z nxt_y
    ldx.z m
    ldy PLEX_SORTED_IDX,x
    cmp PLEX_YPOS,y
    bcs __b2
    jmp __b5
    // plexSort::@5
  __b5:
    // [36] (byte) plexSort::s#6 ← (byte) plexSort::m#2 -- vbuxx=vbuz1 
    ldx.z m
    // [37] phi from plexSort::@5 plexSort::@7 to plexSort::@3 [phi:plexSort::@5/plexSort::@7->plexSort::@3]
  __b3_from___b5:
  __b3_from___b7:
    // [37] phi (byte) plexSort::s#3 = (byte) plexSort::s#6 [phi:plexSort::@5/plexSort::@7->plexSort::@3#0] -- register_copy 
    jmp __b3
    // plexSort::@3
  __b3:
    // [38] *((const byte*) PLEX_SORTED_IDX+(byte) 1 + (byte) plexSort::s#3) ← *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#3) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx 
    lda PLEX_SORTED_IDX,x
    sta PLEX_SORTED_IDX+1,x
    // [39] (byte) plexSort::s#1 ← -- (byte) plexSort::s#3 -- vbuxx=_dec_vbuxx 
    dex
    // [40] if((byte) plexSort::s#1==(byte) $ff) goto plexSort::@4 -- vbuxx_eq_vbuc1_then_la1 
    cpx #$ff
    beq __b4
    jmp __b7
    // plexSort::@7
  __b7:
    // [41] if((byte) plexSort::nxt_y#0<*((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#1))) goto plexSort::@3 -- vbuz1_lt_pbuc1_derefidx_(pbuc2_derefidx_vbuxx)_then_la1 
    lda.z nxt_y
    ldy PLEX_SORTED_IDX,x
    cmp PLEX_YPOS,y
    bcc __b3_from___b7
    jmp __b4
    // plexSort::@4
  __b4:
    // [42] (byte) plexSort::s#2 ← ++ (byte) plexSort::s#1 -- vbuxx=_inc_vbuxx 
    inx
    // [43] *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#2) ← (byte) plexSort::nxt_idx#0 -- pbuc1_derefidx_vbuxx=vbuz1 
    lda.z nxt_idx
    sta PLEX_SORTED_IDX,x
    jmp __b2
    // plexSort::@2
  __b2:
    // [44] (byte) plexSort::m#1 ← ++ (byte) plexSort::m#2 -- vbuz1=_inc_vbuz1 
    inc.z m
    // [45] if((byte) plexSort::m#1!=(const byte) PLEX_COUNT-(byte) 2+(byte) 1) goto plexSort::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #PLEX_COUNT-2+1
    cmp.z m
    bne __b1_from___b2
    jmp __b6
    // plexSort::@6
  __b6:
    // [46] (byte) plex_show_idx ← (byte) 0 -- vbuz1=vbuc1 
    // Prepare for showing the sprites
    lda #0
    sta.z plex_show_idx
    // [47] (byte) plex_sprite_idx ← (byte) 0 -- vbuz1=vbuc1 
    lda #0
    sta.z plex_sprite_idx
    // [48] (byte) plex_sprite_msb ← (byte) 1 -- vbuz1=vbuc1 
    lda #1
    sta.z plex_sprite_msb
    // [49] phi from plexSort::@6 to plexSort::plexFreePrepare1 [phi:plexSort::@6->plexSort::plexFreePrepare1]
  plexFreePrepare1_from___b6:
    jmp plexFreePrepare1
    // plexSort::plexFreePrepare1
  plexFreePrepare1:
    // [50] phi from plexSort::plexFreePrepare1 to plexSort::plexFreePrepare1_@1 [phi:plexSort::plexFreePrepare1->plexSort::plexFreePrepare1_@1]
  plexFreePrepare1___b1_from_plexFreePrepare1:
    // [50] phi (byte) plexSort::plexFreePrepare1_s#2 = (byte) 0 [phi:plexSort::plexFreePrepare1->plexSort::plexFreePrepare1_@1#0] -- vbuxx=vbuc1 
    ldx #0
    jmp plexFreePrepare1___b1
    // [50] phi from plexSort::plexFreePrepare1_@1 to plexSort::plexFreePrepare1_@1 [phi:plexSort::plexFreePrepare1_@1->plexSort::plexFreePrepare1_@1]
  plexFreePrepare1___b1_from_plexFreePrepare1___b1:
    // [50] phi (byte) plexSort::plexFreePrepare1_s#2 = (byte) plexSort::plexFreePrepare1_s#1 [phi:plexSort::plexFreePrepare1_@1->plexSort::plexFreePrepare1_@1#0] -- register_copy 
    jmp plexFreePrepare1___b1
    // plexSort::plexFreePrepare1_@1
  plexFreePrepare1___b1:
    // [51] *((const byte*) PLEX_FREE_YPOS + (byte) plexSort::plexFreePrepare1_s#2) ← (byte) 0 -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #0
    sta PLEX_FREE_YPOS,x
    // [52] (byte) plexSort::plexFreePrepare1_s#1 ← ++ (byte) plexSort::plexFreePrepare1_s#2 -- vbuxx=_inc_vbuxx 
    inx
    // [53] if((byte) plexSort::plexFreePrepare1_s#1!=(byte) 8) goto plexSort::plexFreePrepare1_@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #8
    bne plexFreePrepare1___b1_from_plexFreePrepare1___b1
    jmp plexFreePrepare1___b2
    // plexSort::plexFreePrepare1_@2
  plexFreePrepare1___b2:
    // [54] (byte) plex_free_next ← (byte) 0 -- vbuz1=vbuc1 
    lda #0
    sta.z plex_free_next
    jmp __breturn
    // plexSort::@return
  __breturn:
    // [55] return 
    rts
}
  // init
// Initialize the program
init: {
    // Set the x-positions & pointers
    .label xp = 4
    // [56] *((const byte*) D011) ← (const byte) VIC_DEN|(const byte) VIC_RSEL|(byte) 3 -- _deref_pbuc1=vbuc2 
    lda #VIC_DEN|VIC_RSEL|3
    sta D011
    // [57] call plexInit 
    // [77] phi from init to plexInit [phi:init->plexInit]
  plexInit_from_init:
    jsr plexInit
    // [58] phi from init to init::@1 [phi:init->init::@1]
  __b1_from_init:
    // [58] phi (word) init::xp#2 = (word) $20 [phi:init->init::@1#0] -- vwuz1=vwuc1 
    lda #<$20
    sta.z xp
    lda #>$20
    sta.z xp+1
    // [58] phi (byte) init::sx#2 = (byte) 0 [phi:init->init::@1#1] -- vbuxx=vbuc1 
    ldx #0
    jmp __b1
    // [58] phi from init::@1 to init::@1 [phi:init::@1->init::@1]
  __b1_from___b1:
    // [58] phi (word) init::xp#2 = (word) init::xp#1 [phi:init::@1->init::@1#0] -- register_copy 
    // [58] phi (byte) init::sx#2 = (byte) init::sx#1 [phi:init::@1->init::@1#1] -- register_copy 
    jmp __b1
    // init::@1
  __b1:
    // [59] *((const byte*) PLEX_PTR + (byte) init::sx#2) ← (byte)(const byte*) SPRITE/(byte) $40 -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #$ff&SPRITE/$40
    sta PLEX_PTR,x
    // [60] (byte~) init::$3 ← (byte) init::sx#2 << (byte) 1 -- vbuaa=vbuxx_rol_1 
    txa
    asl
    // [61] *((const word*) PLEX_XPOS + (byte~) init::$3) ← (word) init::xp#2 -- pwuc1_derefidx_vbuaa=vwuz1 
    tay
    lda.z xp
    sta PLEX_XPOS,y
    lda.z xp+1
    sta PLEX_XPOS+1,y
    // [62] (word) init::xp#1 ← (word) init::xp#2 + (byte) 9 -- vwuz1=vwuz1_plus_vbuc1 
    lda #9
    clc
    adc.z xp
    sta.z xp
    bcc !+
    inc.z xp+1
  !:
    // [63] (byte) init::sx#1 ← ++ (byte) init::sx#2 -- vbuxx=_inc_vbuxx 
    inx
    // [64] if((byte) init::sx#1!=(const byte) PLEX_COUNT-(byte) 1+(byte) 1) goto init::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #PLEX_COUNT-1+1
    bne __b1_from___b1
    jmp __b2
    // init::@2
  __b2:
    // [65] *((const byte*) SPRITES_ENABLE) ← (byte) $ff -- _deref_pbuc1=vbuc2 
    // Enable & initialize sprites
    lda #$ff
    sta SPRITES_ENABLE
    // [66] phi from init::@2 to init::@3 [phi:init::@2->init::@3]
  __b3_from___b2:
    // [66] phi (byte) init::ss#2 = (byte) 0 [phi:init::@2->init::@3#0] -- vbuxx=vbuc1 
    ldx #0
    jmp __b3
    // [66] phi from init::@3 to init::@3 [phi:init::@3->init::@3]
  __b3_from___b3:
    // [66] phi (byte) init::ss#2 = (byte) init::ss#1 [phi:init::@3->init::@3#0] -- register_copy 
    jmp __b3
    // init::@3
  __b3:
    // [67] *((const byte*) SPRITES_COLS + (byte) init::ss#2) ← (const byte) GREEN -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #GREEN
    sta SPRITES_COLS,x
    // [68] (byte) init::ss#1 ← ++ (byte) init::ss#2 -- vbuxx=_inc_vbuxx 
    inx
    // [69] if((byte) init::ss#1!=(byte) 8) goto init::@3 -- vbuxx_neq_vbuc1_then_la1 
    cpx #8
    bne __b3_from___b3
    jmp __b4
    // init::@4
  __b4:
    // asm { sei  }
    // enable the interrupt
    sei
    // [71] *((const byte*) CIA1_INTERRUPT) ← (const byte) CIA_INTERRUPT_CLEAR -- _deref_pbuc1=vbuc2 
    lda #CIA_INTERRUPT_CLEAR
    sta CIA1_INTERRUPT
    // [72] *((const byte*) IRQ_ENABLE) ← (const byte) IRQ_RASTER -- _deref_pbuc1=vbuc2 
    lda #IRQ_RASTER
    sta IRQ_ENABLE
    // [73] *((const byte*) IRQ_STATUS) ← (const byte) IRQ_RASTER -- _deref_pbuc1=vbuc2 
    lda #IRQ_RASTER
    sta IRQ_STATUS
    // [74] *((const void()**) KERNEL_IRQ) ← &interrupt(KERNEL_MIN)(void()) plex_irq() -- _deref_pptc1=pprc2 
    lda #<plex_irq
    sta KERNEL_IRQ
    lda #>plex_irq
    sta KERNEL_IRQ+1
    // asm { cli  }
    cli
    jmp __breturn
    // init::@return
  __breturn:
    // [76] return 
    rts
}
  // plexInit
// Initialize the multiplexer data structures
plexInit: {
    // [78] phi from plexInit to plexInit::plexSetScreen1 [phi:plexInit->plexInit::plexSetScreen1]
  plexSetScreen1_from_plexInit:
    jmp plexSetScreen1
    // plexInit::plexSetScreen1
  plexSetScreen1:
    // [79] phi from plexInit::plexSetScreen1 to plexInit::@1 [phi:plexInit::plexSetScreen1->plexInit::@1]
  __b1_from_plexSetScreen1:
    // [79] phi (byte) plexInit::i#2 = (byte) 0 [phi:plexInit::plexSetScreen1->plexInit::@1#0] -- vbuxx=vbuc1 
    ldx #0
    jmp __b1
    // [79] phi from plexInit::@1 to plexInit::@1 [phi:plexInit::@1->plexInit::@1]
  __b1_from___b1:
    // [79] phi (byte) plexInit::i#2 = (byte) plexInit::i#1 [phi:plexInit::@1->plexInit::@1#0] -- register_copy 
    jmp __b1
    // plexInit::@1
  __b1:
    // [80] *((const byte*) PLEX_SORTED_IDX + (byte) plexInit::i#2) ← (byte) plexInit::i#2 -- pbuc1_derefidx_vbuxx=vbuxx 
    txa
    sta PLEX_SORTED_IDX,x
    // [81] (byte) plexInit::i#1 ← ++ (byte) plexInit::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [82] if((byte) plexInit::i#1!=(const byte) PLEX_COUNT-(byte) 1+(byte) 1) goto plexInit::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #PLEX_COUNT-1+1
    bne __b1_from___b1
    jmp __breturn
    // plexInit::@return
  __breturn:
    // [83] return 
    rts
}
  // plex_irq
plex_irq: {
    .label __4 = $d
    // entry interrupt(KERNEL_MIN)
    // [84] *((const byte*) BORDERCOL) ← (const byte) WHITE -- _deref_pbuc1=vbuc2 
    lda #WHITE
    sta BORDERCOL
    // [85] phi from plex_irq plex_irq::@7 to plex_irq::@3 [phi:plex_irq/plex_irq::@7->plex_irq::@3]
  __b3_from_plex_irq:
  __b3_from___b7:
    jmp __b3
    // plex_irq::@3
  __b3:
    // [86] call plexShowSprite 
    jsr plexShowSprite
    jmp plexFreeNextYpos1
    // plex_irq::plexFreeNextYpos1
  plexFreeNextYpos1:
    // [87] (byte) plex_irq::plexFreeNextYpos1_return#0 ← *((const byte*) PLEX_FREE_YPOS + (byte) plex_free_next) -- vbuxx=pbuc1_derefidx_vbuz1 
    ldy.z plex_free_next
    ldx PLEX_FREE_YPOS,y
    jmp __b6
    // plex_irq::@6
  __b6:
    // [88] (byte~) plex_irq::$4 ← *((const byte*) RASTER) + (byte) 2 -- vbuz1=_deref_pbuc1_plus_2 
    lda RASTER
    clc
    adc #2
    sta.z __4
    // [89] if((byte) plex_show_idx>=(const byte) PLEX_COUNT) goto plex_irq::@4 -- vbuz1_ge_vbuc1_then_la1 
    lda.z plex_show_idx
    cmp #PLEX_COUNT
    bcs __b4
    jmp __b7
    // plex_irq::@7
  __b7:
    // [90] if((byte) plex_irq::plexFreeNextYpos1_return#0<(byte~) plex_irq::$4) goto plex_irq::@3 -- vbuxx_lt_vbuz1_then_la1 
    cpx.z __4
    bcc __b3_from___b7
    jmp __b4
    // plex_irq::@4
  __b4:
    // [91] *((const byte*) IRQ_STATUS) ← (const byte) IRQ_RASTER -- _deref_pbuc1=vbuc2 
    lda #IRQ_RASTER
    sta IRQ_STATUS
    // [92] if((byte) plex_show_idx<(const byte) PLEX_COUNT) goto plex_irq::@1 -- vbuz1_lt_vbuc1_then_la1 
    lda.z plex_show_idx
    cmp #PLEX_COUNT
    bcc __b1
    jmp __b5
    // plex_irq::@5
  __b5:
    // [93] (bool) framedone ← true -- vboz1=vboc1 
    lda #1
    sta.z framedone
    jmp __b2
    // plex_irq::@2
  __b2:
    // [94] *((const byte*) BORDERCOL) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta BORDERCOL
    jmp __breturn
    // plex_irq::@return
  __breturn:
    // [95] return  - exit interrupt(KERNEL_MIN)
    jmp $ea81
    // plex_irq::@1
  __b1:
    // [96] *((const byte*) RASTER) ← (byte) plex_irq::plexFreeNextYpos1_return#0 -- _deref_pbuc1=vbuxx 
    stx RASTER
    jmp __b2
}
  // plexShowSprite
// Show the next sprite.
// plexSort() prepares showing the sprites
plexShowSprite: {
    .label plex_sprite_idx2 = $d
    // [97] (byte) plexShowSprite::plex_sprite_idx2#0 ← (byte) plex_sprite_idx << (byte) 1 -- vbuz1=vbuz2_rol_1 
    lda.z plex_sprite_idx
    asl
    sta.z plex_sprite_idx2
    // [98] (byte) plexShowSprite::plexFreeAdd1_ypos#0 ← *((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx)) -- vbuaa=pbuc1_derefidx_(pbuc2_derefidx_vbuz1) 
    ldx.z plex_show_idx
    ldy PLEX_SORTED_IDX,x
    lda PLEX_YPOS,y
    // [99] *((const byte*) SPRITES_YPOS + (byte) plexShowSprite::plex_sprite_idx2#0) ← (byte) plexShowSprite::plexFreeAdd1_ypos#0 -- pbuc1_derefidx_vbuz1=vbuaa 
    ldy.z plex_sprite_idx2
    sta SPRITES_YPOS,y
    jmp plexFreeAdd1
    // plexShowSprite::plexFreeAdd1
  plexFreeAdd1:
    // [100] (byte~) plexShowSprite::plexFreeAdd1_$0 ← (byte) plexShowSprite::plexFreeAdd1_ypos#0 + (byte) $15 -- vbuaa=vbuaa_plus_vbuc1 
    clc
    adc #$15
    // [101] *((const byte*) PLEX_FREE_YPOS + (byte) plex_free_next) ← (byte~) plexShowSprite::plexFreeAdd1_$0 -- pbuc1_derefidx_vbuz1=vbuaa 
    ldy.z plex_free_next
    sta PLEX_FREE_YPOS,y
    // [102] (byte~) plexShowSprite::plexFreeAdd1_$1 ← (byte) plex_free_next + (byte) 1 -- vbuxx=vbuz1_plus_1 
    ldx.z plex_free_next
    inx
    // [103] (byte~) plexShowSprite::plexFreeAdd1_$2 ← (byte~) plexShowSprite::plexFreeAdd1_$1 & (byte) 7 -- vbuaa=vbuxx_band_vbuc1 
    txa
    and #7
    // [104] (byte) plex_free_next ← (byte~) plexShowSprite::plexFreeAdd1_$2 -- vbuz1=vbuaa 
    sta.z plex_free_next
    jmp __b5
    // plexShowSprite::@5
  __b5:
    // [105] *((const byte*) PLEX_SCREEN_PTR#0 + (byte) plex_sprite_idx) ← *((const byte*) PLEX_PTR + *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx)) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_(pbuc3_derefidx_vbuz2) 
    ldx.z plex_show_idx
    ldy PLEX_SORTED_IDX,x
    lda PLEX_PTR,y
    ldx.z plex_sprite_idx
    sta PLEX_SCREEN_PTR,x
    // [106] (byte) plexShowSprite::xpos_idx#0 ← *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx) -- vbuaa=pbuc1_derefidx_vbuz1 
    ldy.z plex_show_idx
    lda PLEX_SORTED_IDX,y
    // [107] (byte~) plexShowSprite::$11 ← (byte) plexShowSprite::xpos_idx#0 << (byte) 1 -- vbuxx=vbuaa_rol_1 
    asl
    tax
    // [108] (byte~) plexShowSprite::$2 ← < *((const word*) PLEX_XPOS + (byte~) plexShowSprite::$11) -- vbuaa=_lo_pwuc1_derefidx_vbuxx 
    lda PLEX_XPOS,x
    // [109] *((const byte*) SPRITES_XPOS + (byte) plexShowSprite::plex_sprite_idx2#0) ← (byte~) plexShowSprite::$2 -- pbuc1_derefidx_vbuz1=vbuaa 
    ldy.z plex_sprite_idx2
    sta SPRITES_XPOS,y
    // [110] (byte~) plexShowSprite::$3 ← > *((const word*) PLEX_XPOS + (byte~) plexShowSprite::$11) -- vbuaa=_hi_pwuc1_derefidx_vbuxx 
    lda PLEX_XPOS+1,x
    // [111] if((byte~) plexShowSprite::$3!=(byte) 0) goto plexShowSprite::@1 -- vbuaa_neq_0_then_la1 
    cmp #0
    bne __b1
    jmp __b3
    // plexShowSprite::@3
  __b3:
    // [112] (byte~) plexShowSprite::$9 ← (byte) $ff ^ (byte) plex_sprite_msb -- vbuaa=vbuc1_bxor_vbuz1 
    lda #$ff
    eor.z plex_sprite_msb
    // [113] *((const byte*) SPRITES_XMSB) ← *((const byte*) SPRITES_XMSB) & (byte~) plexShowSprite::$9 -- _deref_pbuc1=_deref_pbuc1_band_vbuaa 
    and SPRITES_XMSB
    sta SPRITES_XMSB
    jmp __b2
    // plexShowSprite::@2
  __b2:
    // [114] (byte~) plexShowSprite::$5 ← (byte) plex_sprite_idx + (byte) 1 -- vbuxx=vbuz1_plus_1 
    ldx.z plex_sprite_idx
    inx
    // [115] (byte~) plexShowSprite::$6 ← (byte~) plexShowSprite::$5 & (byte) 7 -- vbuaa=vbuxx_band_vbuc1 
    txa
    and #7
    // [116] (byte) plex_sprite_idx ← (byte~) plexShowSprite::$6 -- vbuz1=vbuaa 
    sta.z plex_sprite_idx
    // [117] (byte) plex_show_idx ← ++ (byte) plex_show_idx -- vbuz1=_inc_vbuz1 
    inc.z plex_show_idx
    // [118] (byte) plex_sprite_msb ← (byte) plex_sprite_msb << (byte) 1 -- vbuz1=vbuz1_rol_1 
    asl.z plex_sprite_msb
    // [119] if((byte) plex_sprite_msb!=(byte) 0) goto plexShowSprite::@return -- vbuz1_neq_0_then_la1 
    lda.z plex_sprite_msb
    cmp #0
    bne __breturn
    jmp __b4
    // plexShowSprite::@4
  __b4:
    // [120] (byte) plex_sprite_msb ← (byte) 1 -- vbuz1=vbuc1 
    lda #1
    sta.z plex_sprite_msb
    jmp __breturn
    // plexShowSprite::@return
  __breturn:
    // [121] return 
    rts
    // plexShowSprite::@1
  __b1:
    // [122] *((const byte*) SPRITES_XMSB) ← *((const byte*) SPRITES_XMSB) | (byte) plex_sprite_msb -- _deref_pbuc1=_deref_pbuc1_bor_vbuz1 
    lda SPRITES_XMSB
    ora.z plex_sprite_msb
    sta SPRITES_XMSB
    jmp __b2
}
  // File Data
  // The x-positions of the multiplexer sprites (0x000-0x1ff)
  PLEX_XPOS: .fill 2*PLEX_COUNT, 0
  // The y-positions of the multiplexer sprites.
  PLEX_YPOS: .fill PLEX_COUNT, 0
  // The sprite pointers for the multiplexed sprites
  PLEX_PTR: .fill PLEX_COUNT, 0
  // Indexes of the plex-sprites sorted by sprite y-position. Each call to plexSort() will fix the sorting if changes to the Y-positions have ruined it.
  PLEX_SORTED_IDX: .fill PLEX_COUNT, 0
  // Contains the Y-position where each sprite is free again. PLEX_FREE_YPOS[s] holds the Y-position where sprite s is free to use again.
  PLEX_FREE_YPOS: .fill 8, 0
  .align $40
SPRITE:
.var pic = LoadPicture("balloon.png", List().add($000000, $ffffff))
    .for (var y=0; y<21; y++)
        .for (var x=0;x<3; x++)
            .byte pic.getSinglecolorByte(x,y)

  .align $100
YSIN:
.fill $100, round(139.5+89.5*sin(toRadians(360*i/256)))


ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __b3
Removing instruction jmp __b4
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __b4
Removing instruction jmp __b5
Removing instruction jmp __b6
Removing instruction jmp __b1
Removing instruction jmp __b5
Removing instruction jmp __b3
Removing instruction jmp __b7
Removing instruction jmp __b4
Removing instruction jmp __b2
Removing instruction jmp __b6
Removing instruction jmp plexFreePrepare1
Removing instruction jmp plexFreePrepare1___b1
Removing instruction jmp plexFreePrepare1___b2
Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __b3
Removing instruction jmp __b4
Removing instruction jmp __breturn
Removing instruction jmp plexSetScreen1
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __b3
Removing instruction jmp plexFreeNextYpos1
Removing instruction jmp __b6
Removing instruction jmp __b7
Removing instruction jmp __b4
Removing instruction jmp __b5
Removing instruction jmp __b2
Removing instruction jmp __breturn
Removing instruction jmp plexFreeAdd1
Removing instruction jmp __b5
Removing instruction jmp __b3
Removing instruction jmp __b2
Removing instruction jmp __b4
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda #0
Replacing instruction ldy.z nxt_idx with TAY
Removing instruction lda.z nxt_y
Removing instruction lda #0
Removing instruction lda #IRQ_RASTER
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Replacing label __bbegin with __b1
Replacing label __b4_from___b4 with __b4
Replacing label __b1 with __b2
Replacing label __b3_from___b7 with __b3
Replacing label __b1_from___b2 with __b1
Replacing label plexFreePrepare1___b1_from_plexFreePrepare1___b1 with plexFreePrepare1___b1
Replacing label __b1_from___b1 with __b1
Replacing label __b3_from___b3 with __b3
Replacing label __b1_from___b1 with __b1
Replacing label __b3_from___b7 with __b3
Removing instruction __bbegin:
Removing instruction __b4_from___b3:
Removing instruction __bend_from___b4:
Removing instruction __b1_from_main:
Removing instruction loop_from___b1:
Removing instruction __b1:
Removing instruction __b4_from___b4:
Removing instruction __b1_from___b2:
Removing instruction __b3_from___b5:
Removing instruction __b3_from___b7:
Removing instruction plexFreePrepare1_from___b6:
Removing instruction plexFreePrepare1___b1_from_plexFreePrepare1:
Removing instruction plexFreePrepare1___b1_from_plexFreePrepare1___b1:
Removing instruction __b1_from___b1:
Removing instruction __b3_from___b3:
Removing instruction plexSetScreen1_from_plexInit:
Removing instruction __b1_from_plexSetScreen1:
Removing instruction __b1_from___b1:
Removing instruction __b3_from_plex_irq:
Removing instruction __b3_from___b7:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b2:
Removing instruction __b3:
Removing instruction __b4:
Removing instruction __bend:
Removing instruction __b1:
Removing instruction __breturn:
Removing instruction __b1_from_loop:
Removing instruction __b4_from___b3:
Removing instruction __b5:
Removing instruction plexSort_from___b5:
Removing instruction __b6:
Removing instruction __b1_from___b6:
Removing instruction __b1_from_plexSort:
Removing instruction __b5:
Removing instruction __b7:
Removing instruction __b6:
Removing instruction plexFreePrepare1:
Removing instruction plexFreePrepare1___b2:
Removing instruction __breturn:
Removing instruction plexInit_from_init:
Removing instruction __b1_from_init:
Removing instruction __b2:
Removing instruction __b3_from___b2:
Removing instruction __b4:
Removing instruction __breturn:
Removing instruction plexSetScreen1:
Removing instruction __breturn:
Removing instruction plexFreeNextYpos1:
Removing instruction __b6:
Removing instruction __b7:
Removing instruction __b5:
Removing instruction __breturn:
Removing instruction plexFreeAdd1:
Removing instruction __b5:
Removing instruction __b3:
Removing instruction __b4:
Succesful ASM optimization Pass5UnusedLabelElimination
Adding RTS to root block 
Succesful ASM optimization Pass5AddMainRts
Removing instruction jmp __b4
Removing instruction jmp __b1
Removing instruction jmp plexFreePrepare1___b1
Removing instruction jmp __b1
Removing instruction jmp __b3
Removing instruction jmp __b1
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction ldx.z m
Removing instruction lda #0
Succesful ASM optimization Pass5UnnecesaryLoadElimination

FINAL SYMBOL TABLE
(label) @1
(label) @2
(label) @3
(label) @4
(label) @begin
(label) @end
(const byte*) BORDERCOL = (byte*) 53280
(const byte*) CIA1_INTERRUPT = (byte*) 56333
(const byte) CIA_INTERRUPT_CLEAR = (byte) $7f
(const byte*) D011 = (byte*) 53265
(const byte) GREEN = (byte) 5
(const byte*) IRQ_ENABLE = (byte*) 53274
(const byte) IRQ_RASTER = (byte) 1
(const byte*) IRQ_STATUS = (byte*) 53273
(const void()**) KERNEL_IRQ = (void()**) 788
(const byte) PLEX_COUNT = (byte) $20
(const byte*) PLEX_FREE_YPOS[(number) 8]  = { fill( 8, 0) }
(const byte*) PLEX_PTR[(const byte) PLEX_COUNT]  = { fill( PLEX_COUNT, 0) }
(byte*) PLEX_SCREEN_PTR
(const byte*) PLEX_SCREEN_PTR#0 PLEX_SCREEN_PTR = (byte*)(number) $400+(number) $3f8
(const byte*) PLEX_SORTED_IDX[(const byte) PLEX_COUNT]  = { fill( PLEX_COUNT, 0) }
(const word*) PLEX_XPOS[(const byte) PLEX_COUNT]  = { fill( PLEX_COUNT, 0) }
(const byte*) PLEX_YPOS[(const byte) PLEX_COUNT]  = { fill( PLEX_COUNT, 0) }
(const byte*) RASTER = (byte*) 53266
(const byte) RED = (byte) 2
(const byte*) SPRITE[(number) $40]  = kickasm {{ .var pic = LoadPicture("balloon.png", List().add($000000, $ffffff))
    .for (var y=0; y<21; y++)
        .for (var x=0;x<3; x++)
            .byte pic.getSinglecolorByte(x,y)
 }}
(const byte*) SPRITES_COLS = (byte*) 53287
(const byte*) SPRITES_ENABLE = (byte*) 53269
(const byte*) SPRITES_XMSB = (byte*) 53264
(const byte*) SPRITES_XPOS = (byte*) 53248
(const byte*) SPRITES_YPOS = (byte*) 53249
(const byte*) VIC_CONTROL = (byte*) 53265
(const byte) VIC_DEN = (byte) $10
(const byte) VIC_RSEL = (byte) 8
(const byte) WHITE = (byte) 1
(const byte*) YSIN[(number) $100]  = kickasm {{ .fill $100, round(139.5+89.5*sin(toRadians(360*i/256)))
 }}
(bool) framedone loadstore zp[1]:10 10.545454545454545
(void()) init()
(byte~) init::$3 reg byte a 22.0
(label) init::@1
(label) init::@2
(label) init::@3
(label) init::@4
(label) init::@return
(byte) init::ss
(byte) init::ss#1 reg byte x 16.5
(byte) init::ss#2 reg byte x 16.5
(byte) init::sx
(byte) init::sx#1 reg byte x 16.5
(byte) init::sx#2 reg byte x 8.8
(word) init::xp
(word) init::xp#1 xp zp[2]:4 7.333333333333333
(word) init::xp#2 xp zp[2]:4 8.25
(void()) loop()
(label) loop::@1
(label) loop::@2
(label) loop::@3
(label) loop::@4
(label) loop::@5
(label) loop::@6
(byte) loop::sin_idx
(byte) loop::sin_idx#1 sin_idx zp[1]:2 3.142857142857143
(byte) loop::sin_idx#6 sin_idx zp[1]:2 3.666666666666667
(byte) loop::sy
(byte) loop::sy#1 reg byte y 151.5
(byte) loop::sy#2 reg byte y 101.0
(byte) loop::y_idx
(byte) loop::y_idx#1 reg byte x 67.33333333333333
(byte) loop::y_idx#2 reg byte x 157.0
(byte) loop::y_idx#4 reg byte x 22.0
(void()) main()
(label) main::@1
(label) main::@return
(void()) plexInit((byte*) plexInit::screen)
(label) plexInit::@1
(label) plexInit::@return
(byte) plexInit::i
(byte) plexInit::i#1 reg byte x 16.5
(byte) plexInit::i#2 reg byte x 22.0
(label) plexInit::plexSetScreen1
(byte*) plexInit::plexSetScreen1_screen
(byte*) plexInit::screen
(void()) plexShowSprite()
(byte~) plexShowSprite::$11 reg byte x 2.0
(byte~) plexShowSprite::$2 reg byte a 4.0
(byte~) plexShowSprite::$3 reg byte a 4.0
(byte~) plexShowSprite::$5 reg byte x 4.0
(byte~) plexShowSprite::$6 reg byte a 4.0
(byte~) plexShowSprite::$9 reg byte a 4.0
(label) plexShowSprite::@1
(label) plexShowSprite::@2
(label) plexShowSprite::@3
(label) plexShowSprite::@4
(label) plexShowSprite::@5
(label) plexShowSprite::@return
(label) plexShowSprite::plexFreeAdd1
(byte~) plexShowSprite::plexFreeAdd1_$0 reg byte a 4.0
(byte~) plexShowSprite::plexFreeAdd1_$1 reg byte x 4.0
(byte~) plexShowSprite::plexFreeAdd1_$2 reg byte a 4.0
(byte) plexShowSprite::plexFreeAdd1_ypos
(byte) plexShowSprite::plexFreeAdd1_ypos#0 reg byte a 3.0
(byte) plexShowSprite::plex_sprite_idx2
(byte) plexShowSprite::plex_sprite_idx2#0 plex_sprite_idx2 zp[1]:13 0.5
(byte) plexShowSprite::xpos_idx
(byte) plexShowSprite::xpos_idx#0 reg byte a 4.0
(byte) plexShowSprite::ypos
(void()) plexSort()
(label) plexSort::@1
(label) plexSort::@2
(label) plexSort::@3
(label) plexSort::@4
(label) plexSort::@5
(label) plexSort::@6
(label) plexSort::@7
(label) plexSort::@return
(byte) plexSort::m
(byte) plexSort::m#1 m zp[1]:3 151.5
(byte) plexSort::m#2 m zp[1]:3 42.08333333333333
(byte) plexSort::nxt_idx
(byte) plexSort::nxt_idx#0 nxt_idx zp[1]:11 30.299999999999997
(byte) plexSort::nxt_y
(byte) plexSort::nxt_y#0 nxt_y zp[1]:12 150.375
(label) plexSort::plexFreePrepare1
(label) plexSort::plexFreePrepare1_@1
(label) plexSort::plexFreePrepare1_@2
(byte) plexSort::plexFreePrepare1_s
(byte) plexSort::plexFreePrepare1_s#1 reg byte x 151.5
(byte) plexSort::plexFreePrepare1_s#2 reg byte x 151.5
(byte) plexSort::s
(byte) plexSort::s#1 reg byte x 1368.3333333333335
(byte) plexSort::s#2 reg byte x 202.0
(byte) plexSort::s#3 reg byte x 2052.5
(byte) plexSort::s#6 reg byte x 202.0
(byte) plex_free_next loadstore zp[1]:9 0.6774193548387095
interrupt(KERNEL_MIN)(void()) plex_irq()
(byte~) plex_irq::$4 zp[1]:13 11.0
(label) plex_irq::@1
(label) plex_irq::@2
(label) plex_irq::@3
(label) plex_irq::@4
(label) plex_irq::@5
(label) plex_irq::@6
(label) plex_irq::@7
(label) plex_irq::@return
(label) plex_irq::plexFreeNextYpos1
(byte) plex_irq::plexFreeNextYpos1_return
(byte) plex_irq::plexFreeNextYpos1_return#0 reg byte x 4.0
(byte) plex_irq::rasterY
(byte) plex_show_idx loadstore zp[1]:6 0.7941176470588236
(byte) plex_sprite_idx loadstore zp[1]:7 0.3870967741935484
(byte) plex_sprite_msb loadstore zp[1]:8 0.48484848484848486

zp[1]:2 [ loop::sin_idx#6 loop::sin_idx#1 ]
reg byte x [ loop::y_idx#2 loop::y_idx#1 loop::y_idx#4 ]
reg byte y [ loop::sy#2 loop::sy#1 ]
zp[1]:3 [ plexSort::m#2 plexSort::m#1 ]
reg byte x [ plexSort::s#3 plexSort::s#1 plexSort::s#6 ]
reg byte x [ plexSort::plexFreePrepare1_s#2 plexSort::plexFreePrepare1_s#1 ]
reg byte x [ init::sx#2 init::sx#1 ]
zp[2]:4 [ init::xp#2 init::xp#1 ]
reg byte x [ init::ss#2 init::ss#1 ]
reg byte x [ plexInit::i#2 plexInit::i#1 ]
zp[1]:6 [ plex_show_idx ]
zp[1]:7 [ plex_sprite_idx ]
zp[1]:8 [ plex_sprite_msb ]
zp[1]:9 [ plex_free_next ]
zp[1]:10 [ framedone ]
zp[1]:11 [ plexSort::nxt_idx#0 ]
zp[1]:12 [ plexSort::nxt_y#0 ]
reg byte x [ plexSort::s#2 ]
reg byte a [ init::$3 ]
reg byte x [ plex_irq::plexFreeNextYpos1_return#0 ]
zp[1]:13 [ plexShowSprite::plex_sprite_idx2#0 plex_irq::$4 ]
reg byte a [ plexShowSprite::plexFreeAdd1_ypos#0 ]
reg byte a [ plexShowSprite::plexFreeAdd1_$0 ]
reg byte x [ plexShowSprite::plexFreeAdd1_$1 ]
reg byte a [ plexShowSprite::plexFreeAdd1_$2 ]
reg byte a [ plexShowSprite::xpos_idx#0 ]
reg byte x [ plexShowSprite::$11 ]
reg byte a [ plexShowSprite::$2 ]
reg byte a [ plexShowSprite::$3 ]
reg byte a [ plexShowSprite::$9 ]
reg byte x [ plexShowSprite::$5 ]
reg byte a [ plexShowSprite::$6 ]


FINAL ASSEMBLER
Score: 43740

  // File Comments
// A simple usage of the flexible sprite multiplexer routine
  // Upstart
.pc = $801 "Basic"
:BasicUpstart(__b1)
.pc = $80d "Program"
  // Global Constants & labels
  .label SPRITES_XPOS = $d000
  .label SPRITES_YPOS = $d001
  .label SPRITES_XMSB = $d010
  .label RASTER = $d012
  .label SPRITES_ENABLE = $d015
  .label BORDERCOL = $d020
  .label SPRITES_COLS = $d027
  .label VIC_CONTROL = $d011
  .label D011 = $d011
  .const VIC_DEN = $10
  .const VIC_RSEL = 8
  // VIC II IRQ Status Register
  .label IRQ_STATUS = $d019
  // VIC II IRQ Enable Register
  .label IRQ_ENABLE = $d01a
  // Bits for the IRQ Status/Enable Registers
  .const IRQ_RASTER = 1
  // CIA#1 Interrupt Status & Control Register
  .label CIA1_INTERRUPT = $dc0d
  // Value that disables all CIA interrupts when stored to the CIA Interrupt registers
  .const CIA_INTERRUPT_CLEAR = $7f
  // The vector used when the KERNAL serves IRQ interrupts
  .label KERNEL_IRQ = $314
  .const WHITE = 1
  .const RED = 2
  .const GREEN = 5
  // The number of sprites in the multiplexer
  .const PLEX_COUNT = $20
  // The address of the sprite pointers on the current screen (screen+0x3f8).
  .label PLEX_SCREEN_PTR = $400+$3f8
  .label plex_show_idx = 6
  .label plex_sprite_idx = 7
  .label plex_sprite_msb = 8
  .label plex_free_next = 9
  .label framedone = $a
  // @begin
  // @1
__b1:
  // plex_show_idx=0
  // [1] (byte) plex_show_idx ← (byte) 0 -- vbuz1=vbuc1 
  // The index in the PLEX tables of the next sprite to show
  lda #0
  sta.z plex_show_idx
  // plex_sprite_idx=0
  // [2] (byte) plex_sprite_idx ← (byte) 0 -- vbuz1=vbuc1 
  // The index the next sprite to use for showing (sprites are used round-robin)
  sta.z plex_sprite_idx
  // plex_sprite_msb=1
  // [3] (byte) plex_sprite_msb ← (byte) 1 -- vbuz1=vbuc1 
  // The MSB bit of the next sprite to use for showing
  lda #1
  sta.z plex_sprite_msb
  // @2
  // plex_free_next = 0
  // [4] (byte) plex_free_next ← (byte) 0 -- vbuz1=vbuc1 
  // The index of the sprite that is free next. Since sprites are used round-robin this moves forward each time a sprite is shown.
  lda #0
  sta.z plex_free_next
  // @3
  // framedone = true
  // [5] (bool) framedone ← true -- vboz1=vboc1 
  lda #1
  sta.z framedone
  // [6] phi from @3 to @4 [phi:@3->@4]
  // @4
  // [7] call main 
  jsr main
  rts
  // [8] phi from @4 to @end [phi:@4->@end]
  // @end
  // main
main: {
    // asm
    // asm { sei  }
    sei
    // init()
    // [10] call init 
    jsr init
    // [11] phi from main to main::@1 [phi:main->main::@1]
    // main::@1
    // loop()
    // [12] call loop 
    // [14] phi from main::@1 to loop [phi:main::@1->loop]
    jsr loop
    // main::@return
    // }
    // [13] return 
    rts
}
  // loop
// The raster loop
loop: {
    // The current index into the y-sinus
    .label sin_idx = 2
    // [15] phi from loop to loop::@1 [phi:loop->loop::@1]
    // [15] phi (byte) loop::sin_idx#6 = (byte) 0 [phi:loop->loop::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z sin_idx
    // loop::@1
    // loop::@2
  __b2:
    // while(!framedone)
    // [16] if((bool) framedone) goto loop::@3 -- vboz1_then_la1 
    lda.z framedone
    cmp #0
    bne __b3
    jmp __b2
    // loop::@3
  __b3:
    // *BORDERCOL = RED
    // [17] *((const byte*) BORDERCOL) ← (const byte) RED -- _deref_pbuc1=vbuc2 
    lda #RED
    sta BORDERCOL
    // [18] (byte) loop::y_idx#4 ← (byte) loop::sin_idx#6 -- vbuxx=vbuz1 
    ldx.z sin_idx
    // [19] phi from loop::@3 to loop::@4 [phi:loop::@3->loop::@4]
    // [19] phi (byte) loop::sy#2 = (byte) 0 [phi:loop::@3->loop::@4#0] -- vbuyy=vbuc1 
    ldy #0
    // [19] phi (byte) loop::y_idx#2 = (byte) loop::y_idx#4 [phi:loop::@3->loop::@4#1] -- register_copy 
    // [19] phi from loop::@4 to loop::@4 [phi:loop::@4->loop::@4]
    // [19] phi (byte) loop::sy#2 = (byte) loop::sy#1 [phi:loop::@4->loop::@4#0] -- register_copy 
    // [19] phi (byte) loop::y_idx#2 = (byte) loop::y_idx#1 [phi:loop::@4->loop::@4#1] -- register_copy 
    // loop::@4
  __b4:
    // PLEX_YPOS[sy] = YSIN[y_idx]
    // [20] *((const byte*) PLEX_YPOS + (byte) loop::sy#2) ← *((const byte*) YSIN + (byte) loop::y_idx#2) -- pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuxx 
    lda YSIN,x
    sta PLEX_YPOS,y
    // y_idx += 8
    // [21] (byte) loop::y_idx#1 ← (byte) loop::y_idx#2 + (byte) 8 -- vbuxx=vbuxx_plus_vbuc1 
    txa
    axs #-[8]
    // for(char sy: 0..PLEX_COUNT-1)
    // [22] (byte) loop::sy#1 ← ++ (byte) loop::sy#2 -- vbuyy=_inc_vbuyy 
    iny
    // [23] if((byte) loop::sy#1!=(const byte) PLEX_COUNT-(byte) 1+(byte) 1) goto loop::@4 -- vbuyy_neq_vbuc1_then_la1 
    cpy #PLEX_COUNT-1+1
    bne __b4
    // loop::@5
    // sin_idx +=1
    // [24] (byte) loop::sin_idx#1 ← (byte) loop::sin_idx#6 + (byte) 1 -- vbuz1=vbuz1_plus_1 
    inc.z sin_idx
    // (*BORDERCOL)++;
    // [25] *((const byte*) BORDERCOL) ← ++ *((const byte*) BORDERCOL) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BORDERCOL
    // plexSort()
    // [26] call plexSort 
    // [31] phi from loop::@5 to plexSort [phi:loop::@5->plexSort]
    jsr plexSort
    // loop::@6
    // *BORDERCOL = GREEN
    // [27] *((const byte*) BORDERCOL) ← (const byte) GREEN -- _deref_pbuc1=vbuc2 
    lda #GREEN
    sta BORDERCOL
    // framedone = false
    // [28] (bool) framedone ← false -- vboz1=vboc1 
    lda #0
    sta.z framedone
    // *VIC_CONTROL &=0x7f
    // [29] *((const byte*) VIC_CONTROL) ← *((const byte*) VIC_CONTROL) & (byte) $7f -- _deref_pbuc1=_deref_pbuc1_band_vbuc2 
    lda #$7f
    and VIC_CONTROL
    sta VIC_CONTROL
    // *RASTER = 0x0
    // [30] *((const byte*) RASTER) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta RASTER
    // [15] phi from loop::@6 to loop::@1 [phi:loop::@6->loop::@1]
    // [15] phi (byte) loop::sin_idx#6 = (byte) loop::sin_idx#1 [phi:loop::@6->loop::@1#0] -- register_copy 
    jmp __b2
}
  // plexSort
// Ensure that the indices in PLEX_SORTED_IDX is sorted based on the y-positions in PLEX_YPOS
// Assumes that the positions are nearly sorted already (as each sprite just moves a bit)
// Uses an insertion sort:
// 1. Moves a marker (m) from the start to end of the array. Every time the marker moves forward all elements before the marker are sorted correctly.
// 2a. If the next element after the marker is larger that the current element
//     the marker can be moved forwards (as the sorting is correct).
// 2b. If the next element after the marker is smaller than the current element:
//     elements before the marker are shifted right one at a time until encountering one smaller than the current one.
//      It is then inserted at the spot. Now the marker can move forward.
plexSort: {
    .label nxt_idx = $b
    .label nxt_y = $c
    .label m = 3
    // [32] phi from plexSort to plexSort::@1 [phi:plexSort->plexSort::@1]
    // [32] phi (byte) plexSort::m#2 = (byte) 0 [phi:plexSort->plexSort::@1#0] -- vbuz1=vbuc1 
    lda #0
    sta.z m
    // [32] phi from plexSort::@2 to plexSort::@1 [phi:plexSort::@2->plexSort::@1]
    // [32] phi (byte) plexSort::m#2 = (byte) plexSort::m#1 [phi:plexSort::@2->plexSort::@1#0] -- register_copy 
    // plexSort::@1
  __b1:
    // nxt_idx = PLEX_SORTED_IDX[m+1]
    // [33] (byte) plexSort::nxt_idx#0 ← *((const byte*) PLEX_SORTED_IDX+(byte) 1 + (byte) plexSort::m#2) -- vbuz1=pbuc1_derefidx_vbuz2 
    ldy.z m
    lda PLEX_SORTED_IDX+1,y
    sta.z nxt_idx
    // nxt_y = PLEX_YPOS[nxt_idx]
    // [34] (byte) plexSort::nxt_y#0 ← *((const byte*) PLEX_YPOS + (byte) plexSort::nxt_idx#0) -- vbuz1=pbuc1_derefidx_vbuz2 
    tay
    lda PLEX_YPOS,y
    sta.z nxt_y
    // if(nxt_y<PLEX_YPOS[PLEX_SORTED_IDX[m]])
    // [35] if((byte) plexSort::nxt_y#0>=*((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::m#2))) goto plexSort::@2 -- vbuz1_ge_pbuc1_derefidx_(pbuc2_derefidx_vbuz2)_then_la1 
    ldx.z m
    ldy PLEX_SORTED_IDX,x
    cmp PLEX_YPOS,y
    bcs __b2
    // plexSort::@5
    // [36] (byte) plexSort::s#6 ← (byte) plexSort::m#2 -- vbuxx=vbuz1 
    // [37] phi from plexSort::@5 plexSort::@7 to plexSort::@3 [phi:plexSort::@5/plexSort::@7->plexSort::@3]
    // [37] phi (byte) plexSort::s#3 = (byte) plexSort::s#6 [phi:plexSort::@5/plexSort::@7->plexSort::@3#0] -- register_copy 
    // plexSort::@3
  __b3:
    // PLEX_SORTED_IDX[s+1] = PLEX_SORTED_IDX[s]
    // [38] *((const byte*) PLEX_SORTED_IDX+(byte) 1 + (byte) plexSort::s#3) ← *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#3) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx 
    lda PLEX_SORTED_IDX,x
    sta PLEX_SORTED_IDX+1,x
    // s--;
    // [39] (byte) plexSort::s#1 ← -- (byte) plexSort::s#3 -- vbuxx=_dec_vbuxx 
    dex
    // while((s!=0xff) && (nxt_y<PLEX_YPOS[PLEX_SORTED_IDX[s]]))
    // [40] if((byte) plexSort::s#1==(byte) $ff) goto plexSort::@4 -- vbuxx_eq_vbuc1_then_la1 
    cpx #$ff
    beq __b4
    // plexSort::@7
    // [41] if((byte) plexSort::nxt_y#0<*((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#1))) goto plexSort::@3 -- vbuz1_lt_pbuc1_derefidx_(pbuc2_derefidx_vbuxx)_then_la1 
    lda.z nxt_y
    ldy PLEX_SORTED_IDX,x
    cmp PLEX_YPOS,y
    bcc __b3
    // plexSort::@4
  __b4:
    // s++;
    // [42] (byte) plexSort::s#2 ← ++ (byte) plexSort::s#1 -- vbuxx=_inc_vbuxx 
    inx
    // PLEX_SORTED_IDX[s] = nxt_idx
    // [43] *((const byte*) PLEX_SORTED_IDX + (byte) plexSort::s#2) ← (byte) plexSort::nxt_idx#0 -- pbuc1_derefidx_vbuxx=vbuz1 
    lda.z nxt_idx
    sta PLEX_SORTED_IDX,x
    // plexSort::@2
  __b2:
    // for(char m: 0..PLEX_COUNT-2)
    // [44] (byte) plexSort::m#1 ← ++ (byte) plexSort::m#2 -- vbuz1=_inc_vbuz1 
    inc.z m
    // [45] if((byte) plexSort::m#1!=(const byte) PLEX_COUNT-(byte) 2+(byte) 1) goto plexSort::@1 -- vbuz1_neq_vbuc1_then_la1 
    lda #PLEX_COUNT-2+1
    cmp.z m
    bne __b1
    // plexSort::@6
    // plex_show_idx = 0
    // [46] (byte) plex_show_idx ← (byte) 0 -- vbuz1=vbuc1 
    // Prepare for showing the sprites
    lda #0
    sta.z plex_show_idx
    // plex_sprite_idx = 0
    // [47] (byte) plex_sprite_idx ← (byte) 0 -- vbuz1=vbuc1 
    sta.z plex_sprite_idx
    // plex_sprite_msb = 1
    // [48] (byte) plex_sprite_msb ← (byte) 1 -- vbuz1=vbuc1 
    lda #1
    sta.z plex_sprite_msb
    // [49] phi from plexSort::@6 to plexSort::plexFreePrepare1 [phi:plexSort::@6->plexSort::plexFreePrepare1]
    // plexSort::plexFreePrepare1
    // [50] phi from plexSort::plexFreePrepare1 to plexSort::plexFreePrepare1_@1 [phi:plexSort::plexFreePrepare1->plexSort::plexFreePrepare1_@1]
    // [50] phi (byte) plexSort::plexFreePrepare1_s#2 = (byte) 0 [phi:plexSort::plexFreePrepare1->plexSort::plexFreePrepare1_@1#0] -- vbuxx=vbuc1 
    ldx #0
    // [50] phi from plexSort::plexFreePrepare1_@1 to plexSort::plexFreePrepare1_@1 [phi:plexSort::plexFreePrepare1_@1->plexSort::plexFreePrepare1_@1]
    // [50] phi (byte) plexSort::plexFreePrepare1_s#2 = (byte) plexSort::plexFreePrepare1_s#1 [phi:plexSort::plexFreePrepare1_@1->plexSort::plexFreePrepare1_@1#0] -- register_copy 
    // plexSort::plexFreePrepare1_@1
  plexFreePrepare1___b1:
    // PLEX_FREE_YPOS[s] = 0
    // [51] *((const byte*) PLEX_FREE_YPOS + (byte) plexSort::plexFreePrepare1_s#2) ← (byte) 0 -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #0
    sta PLEX_FREE_YPOS,x
    // for( char s: 0..7)
    // [52] (byte) plexSort::plexFreePrepare1_s#1 ← ++ (byte) plexSort::plexFreePrepare1_s#2 -- vbuxx=_inc_vbuxx 
    inx
    // [53] if((byte) plexSort::plexFreePrepare1_s#1!=(byte) 8) goto plexSort::plexFreePrepare1_@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #8
    bne plexFreePrepare1___b1
    // plexSort::plexFreePrepare1_@2
    // plex_free_next = 0
    // [54] (byte) plex_free_next ← (byte) 0 -- vbuz1=vbuc1 
    sta.z plex_free_next
    // plexSort::@return
    // }
    // [55] return 
    rts
}
  // init
// Initialize the program
init: {
    // Set the x-positions & pointers
    .label xp = 4
    // *D011 = VIC_DEN | VIC_RSEL | 3
    // [56] *((const byte*) D011) ← (const byte) VIC_DEN|(const byte) VIC_RSEL|(byte) 3 -- _deref_pbuc1=vbuc2 
    lda #VIC_DEN|VIC_RSEL|3
    sta D011
    // plexInit(SCREEN)
    // [57] call plexInit 
    // [77] phi from init to plexInit [phi:init->plexInit]
    jsr plexInit
    // [58] phi from init to init::@1 [phi:init->init::@1]
    // [58] phi (word) init::xp#2 = (word) $20 [phi:init->init::@1#0] -- vwuz1=vwuc1 
    lda #<$20
    sta.z xp
    lda #>$20
    sta.z xp+1
    // [58] phi (byte) init::sx#2 = (byte) 0 [phi:init->init::@1#1] -- vbuxx=vbuc1 
    ldx #0
    // [58] phi from init::@1 to init::@1 [phi:init::@1->init::@1]
    // [58] phi (word) init::xp#2 = (word) init::xp#1 [phi:init::@1->init::@1#0] -- register_copy 
    // [58] phi (byte) init::sx#2 = (byte) init::sx#1 [phi:init::@1->init::@1#1] -- register_copy 
    // init::@1
  __b1:
    // PLEX_PTR[sx] = (char)(SPRITE/0x40)
    // [59] *((const byte*) PLEX_PTR + (byte) init::sx#2) ← (byte)(const byte*) SPRITE/(byte) $40 -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #$ff&SPRITE/$40
    sta PLEX_PTR,x
    // PLEX_XPOS[sx] = xp
    // [60] (byte~) init::$3 ← (byte) init::sx#2 << (byte) 1 -- vbuaa=vbuxx_rol_1 
    txa
    asl
    // [61] *((const word*) PLEX_XPOS + (byte~) init::$3) ← (word) init::xp#2 -- pwuc1_derefidx_vbuaa=vwuz1 
    tay
    lda.z xp
    sta PLEX_XPOS,y
    lda.z xp+1
    sta PLEX_XPOS+1,y
    // xp += 9
    // [62] (word) init::xp#1 ← (word) init::xp#2 + (byte) 9 -- vwuz1=vwuz1_plus_vbuc1 
    lda #9
    clc
    adc.z xp
    sta.z xp
    bcc !+
    inc.z xp+1
  !:
    // for(char sx: 0..PLEX_COUNT-1)
    // [63] (byte) init::sx#1 ← ++ (byte) init::sx#2 -- vbuxx=_inc_vbuxx 
    inx
    // [64] if((byte) init::sx#1!=(const byte) PLEX_COUNT-(byte) 1+(byte) 1) goto init::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #PLEX_COUNT-1+1
    bne __b1
    // init::@2
    // *SPRITES_ENABLE = 0xff
    // [65] *((const byte*) SPRITES_ENABLE) ← (byte) $ff -- _deref_pbuc1=vbuc2 
    // Enable & initialize sprites
    lda #$ff
    sta SPRITES_ENABLE
    // [66] phi from init::@2 to init::@3 [phi:init::@2->init::@3]
    // [66] phi (byte) init::ss#2 = (byte) 0 [phi:init::@2->init::@3#0] -- vbuxx=vbuc1 
    ldx #0
    // [66] phi from init::@3 to init::@3 [phi:init::@3->init::@3]
    // [66] phi (byte) init::ss#2 = (byte) init::ss#1 [phi:init::@3->init::@3#0] -- register_copy 
    // init::@3
  __b3:
    // SPRITES_COLS[ss] = GREEN
    // [67] *((const byte*) SPRITES_COLS + (byte) init::ss#2) ← (const byte) GREEN -- pbuc1_derefidx_vbuxx=vbuc2 
    lda #GREEN
    sta SPRITES_COLS,x
    // for(char ss: 0..7)
    // [68] (byte) init::ss#1 ← ++ (byte) init::ss#2 -- vbuxx=_inc_vbuxx 
    inx
    // [69] if((byte) init::ss#1!=(byte) 8) goto init::@3 -- vbuxx_neq_vbuc1_then_la1 
    cpx #8
    bne __b3
    // init::@4
    // asm
    // asm { sei  }
    // enable the interrupt
    sei
    // *CIA1_INTERRUPT = CIA_INTERRUPT_CLEAR
    // [71] *((const byte*) CIA1_INTERRUPT) ← (const byte) CIA_INTERRUPT_CLEAR -- _deref_pbuc1=vbuc2 
    lda #CIA_INTERRUPT_CLEAR
    sta CIA1_INTERRUPT
    // *IRQ_ENABLE = IRQ_RASTER
    // [72] *((const byte*) IRQ_ENABLE) ← (const byte) IRQ_RASTER -- _deref_pbuc1=vbuc2 
    lda #IRQ_RASTER
    sta IRQ_ENABLE
    // *IRQ_STATUS = IRQ_RASTER
    // [73] *((const byte*) IRQ_STATUS) ← (const byte) IRQ_RASTER -- _deref_pbuc1=vbuc2 
    sta IRQ_STATUS
    // *KERNEL_IRQ = &plex_irq
    // [74] *((const void()**) KERNEL_IRQ) ← &interrupt(KERNEL_MIN)(void()) plex_irq() -- _deref_pptc1=pprc2 
    lda #<plex_irq
    sta KERNEL_IRQ
    lda #>plex_irq
    sta KERNEL_IRQ+1
    // asm
    // asm { cli  }
    cli
    // init::@return
    // }
    // [76] return 
    rts
}
  // plexInit
// Initialize the multiplexer data structures
plexInit: {
    // [78] phi from plexInit to plexInit::plexSetScreen1 [phi:plexInit->plexInit::plexSetScreen1]
    // plexInit::plexSetScreen1
    // [79] phi from plexInit::plexSetScreen1 to plexInit::@1 [phi:plexInit::plexSetScreen1->plexInit::@1]
    // [79] phi (byte) plexInit::i#2 = (byte) 0 [phi:plexInit::plexSetScreen1->plexInit::@1#0] -- vbuxx=vbuc1 
    ldx #0
    // [79] phi from plexInit::@1 to plexInit::@1 [phi:plexInit::@1->plexInit::@1]
    // [79] phi (byte) plexInit::i#2 = (byte) plexInit::i#1 [phi:plexInit::@1->plexInit::@1#0] -- register_copy 
    // plexInit::@1
  __b1:
    // PLEX_SORTED_IDX[i] = i
    // [80] *((const byte*) PLEX_SORTED_IDX + (byte) plexInit::i#2) ← (byte) plexInit::i#2 -- pbuc1_derefidx_vbuxx=vbuxx 
    txa
    sta PLEX_SORTED_IDX,x
    // for(char i: 0..PLEX_COUNT-1)
    // [81] (byte) plexInit::i#1 ← ++ (byte) plexInit::i#2 -- vbuxx=_inc_vbuxx 
    inx
    // [82] if((byte) plexInit::i#1!=(const byte) PLEX_COUNT-(byte) 1+(byte) 1) goto plexInit::@1 -- vbuxx_neq_vbuc1_then_la1 
    cpx #PLEX_COUNT-1+1
    bne __b1
    // plexInit::@return
    // }
    // [83] return 
    rts
}
  // plex_irq
plex_irq: {
    .label __4 = $d
    // entry interrupt(KERNEL_MIN)
    // *BORDERCOL = WHITE
    // [84] *((const byte*) BORDERCOL) ← (const byte) WHITE -- _deref_pbuc1=vbuc2 
    lda #WHITE
    sta BORDERCOL
    // [85] phi from plex_irq plex_irq::@7 to plex_irq::@3 [phi:plex_irq/plex_irq::@7->plex_irq::@3]
    // plex_irq::@3
  __b3:
    // plexShowSprite()
    // [86] call plexShowSprite 
    jsr plexShowSprite
    // plex_irq::plexFreeNextYpos1
    // return PLEX_FREE_YPOS[plex_free_next];
    // [87] (byte) plex_irq::plexFreeNextYpos1_return#0 ← *((const byte*) PLEX_FREE_YPOS + (byte) plex_free_next) -- vbuxx=pbuc1_derefidx_vbuz1 
    ldy.z plex_free_next
    ldx PLEX_FREE_YPOS,y
    // plex_irq::@6
    // *RASTER+2
    // [88] (byte~) plex_irq::$4 ← *((const byte*) RASTER) + (byte) 2 -- vbuz1=_deref_pbuc1_plus_2 
    lda RASTER
    clc
    adc #2
    sta.z __4
    // while (plex_show_idx < PLEX_COUNT && rasterY < *RASTER+2)
    // [89] if((byte) plex_show_idx>=(const byte) PLEX_COUNT) goto plex_irq::@4 -- vbuz1_ge_vbuc1_then_la1 
    lda.z plex_show_idx
    cmp #PLEX_COUNT
    bcs __b4
    // plex_irq::@7
    // [90] if((byte) plex_irq::plexFreeNextYpos1_return#0<(byte~) plex_irq::$4) goto plex_irq::@3 -- vbuxx_lt_vbuz1_then_la1 
    cpx.z __4
    bcc __b3
    // plex_irq::@4
  __b4:
    // *IRQ_STATUS = IRQ_RASTER
    // [91] *((const byte*) IRQ_STATUS) ← (const byte) IRQ_RASTER -- _deref_pbuc1=vbuc2 
    lda #IRQ_RASTER
    sta IRQ_STATUS
    // if (plex_show_idx<PLEX_COUNT)
    // [92] if((byte) plex_show_idx<(const byte) PLEX_COUNT) goto plex_irq::@1 -- vbuz1_lt_vbuc1_then_la1 
    lda.z plex_show_idx
    cmp #PLEX_COUNT
    bcc __b1
    // plex_irq::@5
    // framedone = true
    // [93] (bool) framedone ← true -- vboz1=vboc1 
    lda #1
    sta.z framedone
    // plex_irq::@2
  __b2:
    // *BORDERCOL = 0
    // [94] *((const byte*) BORDERCOL) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    lda #0
    sta BORDERCOL
    // plex_irq::@return
    // }
    // [95] return  - exit interrupt(KERNEL_MIN)
    jmp $ea81
    // plex_irq::@1
  __b1:
    // *RASTER = rasterY
    // [96] *((const byte*) RASTER) ← (byte) plex_irq::plexFreeNextYpos1_return#0 -- _deref_pbuc1=vbuxx 
    stx RASTER
    jmp __b2
}
  // plexShowSprite
// Show the next sprite.
// plexSort() prepares showing the sprites
plexShowSprite: {
    .label plex_sprite_idx2 = $d
    // plex_sprite_idx2 = plex_sprite_idx*2
    // [97] (byte) plexShowSprite::plex_sprite_idx2#0 ← (byte) plex_sprite_idx << (byte) 1 -- vbuz1=vbuz2_rol_1 
    lda.z plex_sprite_idx
    asl
    sta.z plex_sprite_idx2
    // ypos = PLEX_YPOS[PLEX_SORTED_IDX[plex_show_idx]]
    // [98] (byte) plexShowSprite::plexFreeAdd1_ypos#0 ← *((const byte*) PLEX_YPOS + *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx)) -- vbuaa=pbuc1_derefidx_(pbuc2_derefidx_vbuz1) 
    ldx.z plex_show_idx
    ldy PLEX_SORTED_IDX,x
    lda PLEX_YPOS,y
    // SPRITES_YPOS[plex_sprite_idx2] = ypos
    // [99] *((const byte*) SPRITES_YPOS + (byte) plexShowSprite::plex_sprite_idx2#0) ← (byte) plexShowSprite::plexFreeAdd1_ypos#0 -- pbuc1_derefidx_vbuz1=vbuaa 
    ldy.z plex_sprite_idx2
    sta SPRITES_YPOS,y
    // plexShowSprite::plexFreeAdd1
    // ypos+21
    // [100] (byte~) plexShowSprite::plexFreeAdd1_$0 ← (byte) plexShowSprite::plexFreeAdd1_ypos#0 + (byte) $15 -- vbuaa=vbuaa_plus_vbuc1 
    clc
    adc #$15
    // PLEX_FREE_YPOS[plex_free_next] =  ypos+21
    // [101] *((const byte*) PLEX_FREE_YPOS + (byte) plex_free_next) ← (byte~) plexShowSprite::plexFreeAdd1_$0 -- pbuc1_derefidx_vbuz1=vbuaa 
    ldy.z plex_free_next
    sta PLEX_FREE_YPOS,y
    // plex_free_next+1
    // [102] (byte~) plexShowSprite::plexFreeAdd1_$1 ← (byte) plex_free_next + (byte) 1 -- vbuxx=vbuz1_plus_1 
    ldx.z plex_free_next
    inx
    // (plex_free_next+1)&7
    // [103] (byte~) plexShowSprite::plexFreeAdd1_$2 ← (byte~) plexShowSprite::plexFreeAdd1_$1 & (byte) 7 -- vbuaa=vbuxx_band_vbuc1 
    txa
    and #7
    // plex_free_next = (plex_free_next+1)&7
    // [104] (byte) plex_free_next ← (byte~) plexShowSprite::plexFreeAdd1_$2 -- vbuz1=vbuaa 
    sta.z plex_free_next
    // plexShowSprite::@5
    // PLEX_SCREEN_PTR[plex_sprite_idx] = PLEX_PTR[PLEX_SORTED_IDX[plex_show_idx]]
    // [105] *((const byte*) PLEX_SCREEN_PTR#0 + (byte) plex_sprite_idx) ← *((const byte*) PLEX_PTR + *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx)) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_(pbuc3_derefidx_vbuz2) 
    ldx.z plex_show_idx
    ldy PLEX_SORTED_IDX,x
    lda PLEX_PTR,y
    ldx.z plex_sprite_idx
    sta PLEX_SCREEN_PTR,x
    // xpos_idx = PLEX_SORTED_IDX[plex_show_idx]
    // [106] (byte) plexShowSprite::xpos_idx#0 ← *((const byte*) PLEX_SORTED_IDX + (byte) plex_show_idx) -- vbuaa=pbuc1_derefidx_vbuz1 
    ldy.z plex_show_idx
    lda PLEX_SORTED_IDX,y
    // <PLEX_XPOS[xpos_idx]
    // [107] (byte~) plexShowSprite::$11 ← (byte) plexShowSprite::xpos_idx#0 << (byte) 1 -- vbuxx=vbuaa_rol_1 
    asl
    tax
    // [108] (byte~) plexShowSprite::$2 ← < *((const word*) PLEX_XPOS + (byte~) plexShowSprite::$11) -- vbuaa=_lo_pwuc1_derefidx_vbuxx 
    lda PLEX_XPOS,x
    // SPRITES_XPOS[plex_sprite_idx2] = <PLEX_XPOS[xpos_idx]
    // [109] *((const byte*) SPRITES_XPOS + (byte) plexShowSprite::plex_sprite_idx2#0) ← (byte~) plexShowSprite::$2 -- pbuc1_derefidx_vbuz1=vbuaa 
    ldy.z plex_sprite_idx2
    sta SPRITES_XPOS,y
    // >PLEX_XPOS[xpos_idx]
    // [110] (byte~) plexShowSprite::$3 ← > *((const word*) PLEX_XPOS + (byte~) plexShowSprite::$11) -- vbuaa=_hi_pwuc1_derefidx_vbuxx 
    lda PLEX_XPOS+1,x
    // if(>PLEX_XPOS[xpos_idx]!=0)
    // [111] if((byte~) plexShowSprite::$3!=(byte) 0) goto plexShowSprite::@1 -- vbuaa_neq_0_then_la1 
    cmp #0
    bne __b1
    // plexShowSprite::@3
    // 0xff^plex_sprite_msb
    // [112] (byte~) plexShowSprite::$9 ← (byte) $ff ^ (byte) plex_sprite_msb -- vbuaa=vbuc1_bxor_vbuz1 
    lda #$ff
    eor.z plex_sprite_msb
    // *SPRITES_XMSB &= (0xff^plex_sprite_msb)
    // [113] *((const byte*) SPRITES_XMSB) ← *((const byte*) SPRITES_XMSB) & (byte~) plexShowSprite::$9 -- _deref_pbuc1=_deref_pbuc1_band_vbuaa 
    and SPRITES_XMSB
    sta SPRITES_XMSB
    // plexShowSprite::@2
  __b2:
    // plex_sprite_idx+1
    // [114] (byte~) plexShowSprite::$5 ← (byte) plex_sprite_idx + (byte) 1 -- vbuxx=vbuz1_plus_1 
    ldx.z plex_sprite_idx
    inx
    // (plex_sprite_idx+1)&7
    // [115] (byte~) plexShowSprite::$6 ← (byte~) plexShowSprite::$5 & (byte) 7 -- vbuaa=vbuxx_band_vbuc1 
    txa
    and #7
    // plex_sprite_idx = (plex_sprite_idx+1)&7
    // [116] (byte) plex_sprite_idx ← (byte~) plexShowSprite::$6 -- vbuz1=vbuaa 
    sta.z plex_sprite_idx
    // plex_show_idx++;
    // [117] (byte) plex_show_idx ← ++ (byte) plex_show_idx -- vbuz1=_inc_vbuz1 
    inc.z plex_show_idx
    // plex_sprite_msb <<=1
    // [118] (byte) plex_sprite_msb ← (byte) plex_sprite_msb << (byte) 1 -- vbuz1=vbuz1_rol_1 
    asl.z plex_sprite_msb
    // if(plex_sprite_msb==0)
    // [119] if((byte) plex_sprite_msb!=(byte) 0) goto plexShowSprite::@return -- vbuz1_neq_0_then_la1 
    lda.z plex_sprite_msb
    cmp #0
    bne __breturn
    // plexShowSprite::@4
    // plex_sprite_msb = 1
    // [120] (byte) plex_sprite_msb ← (byte) 1 -- vbuz1=vbuc1 
    lda #1
    sta.z plex_sprite_msb
    // plexShowSprite::@return
  __breturn:
    // }
    // [121] return 
    rts
    // plexShowSprite::@1
  __b1:
    // *SPRITES_XMSB |= plex_sprite_msb
    // [122] *((const byte*) SPRITES_XMSB) ← *((const byte*) SPRITES_XMSB) | (byte) plex_sprite_msb -- _deref_pbuc1=_deref_pbuc1_bor_vbuz1 
    lda SPRITES_XMSB
    ora.z plex_sprite_msb
    sta SPRITES_XMSB
    jmp __b2
}
  // File Data
  // The x-positions of the multiplexer sprites (0x000-0x1ff)
  PLEX_XPOS: .fill 2*PLEX_COUNT, 0
  // The y-positions of the multiplexer sprites.
  PLEX_YPOS: .fill PLEX_COUNT, 0
  // The sprite pointers for the multiplexed sprites
  PLEX_PTR: .fill PLEX_COUNT, 0
  // Indexes of the plex-sprites sorted by sprite y-position. Each call to plexSort() will fix the sorting if changes to the Y-positions have ruined it.
  PLEX_SORTED_IDX: .fill PLEX_COUNT, 0
  // Contains the Y-position where each sprite is free again. PLEX_FREE_YPOS[s] holds the Y-position where sprite s is free to use again.
  PLEX_FREE_YPOS: .fill 8, 0
  .align $40
SPRITE:
.var pic = LoadPicture("balloon.png", List().add($000000, $ffffff))
    .for (var y=0; y<21; y++)
        .for (var x=0;x<3; x++)
            .byte pic.getSinglecolorByte(x,y)

  .align $100
YSIN:
.fill $100, round(139.5+89.5*sin(toRadians(360*i/256)))


