Inlined call (byte~) vicSelectGfxBank::$0 ← call toDd00 (byte*) vicSelectGfxBank::gfx 

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) PROCPORT_DDR#0 ← ((byte*)) (byte/signed byte/word/signed word/dword/signed dword) 0
  (byte) PROCPORT_DDR_MEMORY_MASK#0 ← (byte/signed byte/word/signed word/dword/signed dword) 7
  (byte*) PROCPORT#0 ← ((byte*)) (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte) PROCPORT_RAM_ALL#0 ← (byte/signed byte/word/signed word/dword/signed dword) 48
  (byte) PROCPORT_RAM_IO#0 ← (byte/signed byte/word/signed word/dword/signed dword) 53
  (byte) PROCPORT_RAM_CHARROM#0 ← (byte/signed byte/word/signed word/dword/signed dword) 49
  (byte) PROCPORT_KERNEL_IO#0 ← (byte/signed byte/word/signed word/dword/signed dword) 54
  (byte) PROCPORT_BASIC_KERNEL_IO#0 ← (byte/signed byte/word/signed word/dword/signed dword) 55
  (byte*) CHARGEN#0 ← ((byte*)) (word/dword/signed dword) 53248
  (word) SPRITE_PTRS#0 ← (word/signed word/dword/signed dword) 1016
  (byte*) SPRITES_XPOS#0 ← ((byte*)) (word/dword/signed dword) 53248
  (byte*) SPRITES_YPOS#0 ← ((byte*)) (word/dword/signed dword) 53249
  (byte*) SPRITES_XMSB#0 ← ((byte*)) (word/dword/signed dword) 53264
  (byte*) RASTER#0 ← ((byte*)) (word/dword/signed dword) 53266
  (byte*) SPRITES_ENABLE#0 ← ((byte*)) (word/dword/signed dword) 53269
  (byte*) SPRITES_EXPAND_Y#0 ← ((byte*)) (word/dword/signed dword) 53271
  (byte*) SPRITES_PRIORITY#0 ← ((byte*)) (word/dword/signed dword) 53275
  (byte*) SPRITES_MC#0 ← ((byte*)) (word/dword/signed dword) 53276
  (byte*) SPRITES_EXPAND_X#0 ← ((byte*)) (word/dword/signed dword) 53277
  (byte*) BORDERCOL#0 ← ((byte*)) (word/dword/signed dword) 53280
  (byte*) BGCOL#0 ← ((byte*)) (word/dword/signed dword) 53281
  (byte*) BGCOL1#0 ← ((byte*)) (word/dword/signed dword) 53281
  (byte*) BGCOL2#0 ← ((byte*)) (word/dword/signed dword) 53282
  (byte*) BGCOL3#0 ← ((byte*)) (word/dword/signed dword) 53283
  (byte*) BGCOL4#0 ← ((byte*)) (word/dword/signed dword) 53284
  (byte*) SPRITES_MC1#0 ← ((byte*)) (word/dword/signed dword) 53285
  (byte*) SPRITES_MC2#0 ← ((byte*)) (word/dword/signed dword) 53286
  (byte*) SPRITES_COLS#0 ← ((byte*)) (word/dword/signed dword) 53287
  (byte*) VIC_CONTROL#0 ← ((byte*)) (word/dword/signed dword) 53265
  (byte*) D011#0 ← ((byte*)) (word/dword/signed dword) 53265
  (byte) VIC_RST8#0 ← (byte/word/signed word/dword/signed dword) 128
  (byte) VIC_ECM#0 ← (byte/signed byte/word/signed word/dword/signed dword) 64
  (byte) VIC_BMM#0 ← (byte/signed byte/word/signed word/dword/signed dword) 32
  (byte) VIC_DEN#0 ← (byte/signed byte/word/signed word/dword/signed dword) 16
  (byte) VIC_RSEL#0 ← (byte/signed byte/word/signed word/dword/signed dword) 8
  (byte*) VIC_CONTROL2#0 ← ((byte*)) (word/dword/signed dword) 53270
  (byte*) D016#0 ← ((byte*)) (word/dword/signed dword) 53270
  (byte) VIC_MCM#0 ← (byte/signed byte/word/signed word/dword/signed dword) 16
  (byte) VIC_CSEL#0 ← (byte/signed byte/word/signed word/dword/signed dword) 8
  (byte*) D018#0 ← ((byte*)) (word/dword/signed dword) 53272
  (byte*) VIC_MEMORY#0 ← ((byte*)) (word/dword/signed dword) 53272
  (byte*) LIGHTPEN_X#0 ← ((byte*)) (word/dword/signed dword) 53267
  (byte*) LIGHTPEN_Y#0 ← ((byte*)) (word/dword/signed dword) 53268
  (byte*) IRQ_STATUS#0 ← ((byte*)) (word/dword/signed dword) 53273
  (byte*) IRQ_ENABLE#0 ← ((byte*)) (word/dword/signed dword) 53274
  (byte) IRQ_RASTER#0 ← (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte) IRQ_COLLISION_BG#0 ← (byte/signed byte/word/signed word/dword/signed dword) 2
  (byte) IRQ_COLLISION_SPRITE#0 ← (byte/signed byte/word/signed word/dword/signed dword) 4
  (byte) IRQ_LIGHTPEN#0 ← (byte/signed byte/word/signed word/dword/signed dword) 8
  (byte*) COLS#0 ← ((byte*)) (word/dword/signed dword) 55296
  (byte*) CIA1_PORT_A#0 ← ((byte*)) (word/dword/signed dword) 56320
  (byte*) CIA1_PORT_B#0 ← ((byte*)) (word/dword/signed dword) 56321
  (byte*) CIA1_PORT_A_DDR#0 ← ((byte*)) (word/dword/signed dword) 56322
  (byte*) CIA1_PORT_B_DDR#0 ← ((byte*)) (word/dword/signed dword) 56323
  (byte*) CIA1_INTERRUPT#0 ← ((byte*)) (word/dword/signed dword) 56333
  (byte) CIA_INTERRUPT_CLEAR#0 ← (byte/signed byte/word/signed word/dword/signed dword) 127
  (byte*) CIA2_PORT_A#0 ← ((byte*)) (word/dword/signed dword) 56576
  (byte*) CIA2_PORT_B#0 ← ((byte*)) (word/dword/signed dword) 56577
  (byte*) CIA2_PORT_A_DDR#0 ← ((byte*)) (word/dword/signed dword) 56578
  (byte*) CIA2_PORT_B_DDR#0 ← ((byte*)) (word/dword/signed dword) 56579
  (byte*) CIA2_INTERRUPT#0 ← ((byte*)) (word/dword/signed dword) 56589
  (void()**) KERNEL_IRQ#0 ← ((void()**)) (word/signed word/dword/signed dword) 788
  (void()**) HARDWARE_IRQ#0 ← ((void()**)) (word/dword/signed dword) 65534
  (byte) BLACK#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  (byte) WHITE#0 ← (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte) RED#0 ← (byte/signed byte/word/signed word/dword/signed dword) 2
  (byte) CYAN#0 ← (byte/signed byte/word/signed word/dword/signed dword) 3
  (byte) PURPLE#0 ← (byte/signed byte/word/signed word/dword/signed dword) 4
  (byte) GREEN#0 ← (byte/signed byte/word/signed word/dword/signed dword) 5
  (byte) BLUE#0 ← (byte/signed byte/word/signed word/dword/signed dword) 6
  (byte) YELLOW#0 ← (byte/signed byte/word/signed word/dword/signed dword) 7
  (byte) ORANGE#0 ← (byte/signed byte/word/signed word/dword/signed dword) 8
  (byte) BROWN#0 ← (byte/signed byte/word/signed word/dword/signed dword) 9
  (byte) PINK#0 ← (byte/signed byte/word/signed word/dword/signed dword) 10
  (byte) DARK_GREY#0 ← (byte/signed byte/word/signed word/dword/signed dword) 11
  (byte) GREY#0 ← (byte/signed byte/word/signed word/dword/signed dword) 12
  (byte) LIGHT_GREEN#0 ← (byte/signed byte/word/signed word/dword/signed dword) 13
  (byte) LIGHT_BLUE#0 ← (byte/signed byte/word/signed word/dword/signed dword) 14
  (byte) LIGHT_GREY#0 ← (byte/signed byte/word/signed word/dword/signed dword) 15
  to:@4
@4: scope:[]  from @begin
  (byte) KEY_DEL#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  (byte) KEY_RETURN#0 ← (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte) KEY_CRSR_RIGHT#0 ← (byte/signed byte/word/signed word/dword/signed dword) 2
  (byte) KEY_F7#0 ← (byte/signed byte/word/signed word/dword/signed dword) 3
  (byte) KEY_F1#0 ← (byte/signed byte/word/signed word/dword/signed dword) 4
  (byte) KEY_F3#0 ← (byte/signed byte/word/signed word/dword/signed dword) 5
  (byte) KEY_F5#0 ← (byte/signed byte/word/signed word/dword/signed dword) 6
  (byte) KEY_CRSR_DOWN#0 ← (byte/signed byte/word/signed word/dword/signed dword) 7
  (byte) KEY_3#0 ← (byte/signed byte/word/signed word/dword/signed dword) 8
  (byte) KEY_W#0 ← (byte/signed byte/word/signed word/dword/signed dword) 9
  (byte) KEY_A#0 ← (byte/signed byte/word/signed word/dword/signed dword) 10
  (byte) KEY_4#0 ← (byte/signed byte/word/signed word/dword/signed dword) 11
  (byte) KEY_Z#0 ← (byte/signed byte/word/signed word/dword/signed dword) 12
  (byte) KEY_S#0 ← (byte/signed byte/word/signed word/dword/signed dword) 13
  (byte) KEY_E#0 ← (byte/signed byte/word/signed word/dword/signed dword) 14
  (byte) KEY_LSHIFT#0 ← (byte/signed byte/word/signed word/dword/signed dword) 15
  (byte) KEY_5#0 ← (byte/signed byte/word/signed word/dword/signed dword) 16
  (byte) KEY_R#0 ← (byte/signed byte/word/signed word/dword/signed dword) 17
  (byte) KEY_D#0 ← (byte/signed byte/word/signed word/dword/signed dword) 18
  (byte) KEY_6#0 ← (byte/signed byte/word/signed word/dword/signed dword) 19
  (byte) KEY_C#0 ← (byte/signed byte/word/signed word/dword/signed dword) 20
  (byte) KEY_F#0 ← (byte/signed byte/word/signed word/dword/signed dword) 21
  (byte) KEY_T#0 ← (byte/signed byte/word/signed word/dword/signed dword) 22
  (byte) KEY_X#0 ← (byte/signed byte/word/signed word/dword/signed dword) 23
  (byte) KEY_7#0 ← (byte/signed byte/word/signed word/dword/signed dword) 24
  (byte) KEY_Y#0 ← (byte/signed byte/word/signed word/dword/signed dword) 25
  (byte) KEY_G#0 ← (byte/signed byte/word/signed word/dword/signed dword) 26
  (byte) KEY_8#0 ← (byte/signed byte/word/signed word/dword/signed dword) 27
  (byte) KEY_B#0 ← (byte/signed byte/word/signed word/dword/signed dword) 28
  (byte) KEY_H#0 ← (byte/signed byte/word/signed word/dword/signed dword) 29
  (byte) KEY_U#0 ← (byte/signed byte/word/signed word/dword/signed dword) 30
  (byte) KEY_V#0 ← (byte/signed byte/word/signed word/dword/signed dword) 31
  (byte) KEY_9#0 ← (byte/signed byte/word/signed word/dword/signed dword) 32
  (byte) KEY_I#0 ← (byte/signed byte/word/signed word/dword/signed dword) 33
  (byte) KEY_J#0 ← (byte/signed byte/word/signed word/dword/signed dword) 34
  (byte) KEY_0#0 ← (byte/signed byte/word/signed word/dword/signed dword) 35
  (byte) KEY_M#0 ← (byte/signed byte/word/signed word/dword/signed dword) 36
  (byte) KEY_K#0 ← (byte/signed byte/word/signed word/dword/signed dword) 37
  (byte) KEY_O#0 ← (byte/signed byte/word/signed word/dword/signed dword) 38
  (byte) KEY_N#0 ← (byte/signed byte/word/signed word/dword/signed dword) 39
  (byte) KEY_PLUS#0 ← (byte/signed byte/word/signed word/dword/signed dword) 40
  (byte) KEY_P#0 ← (byte/signed byte/word/signed word/dword/signed dword) 41
  (byte) KEY_L#0 ← (byte/signed byte/word/signed word/dword/signed dword) 42
  (byte) KEY_MINUS#0 ← (byte/signed byte/word/signed word/dword/signed dword) 43
  (byte) KEY_DOT#0 ← (byte/signed byte/word/signed word/dword/signed dword) 44
  (byte) KEY_COLON#0 ← (byte/signed byte/word/signed word/dword/signed dword) 45
  (byte) KEY_AT#0 ← (byte/signed byte/word/signed word/dword/signed dword) 46
  (byte) KEY_COMMA#0 ← (byte/signed byte/word/signed word/dword/signed dword) 47
  (byte) KEY_POUND#0 ← (byte/signed byte/word/signed word/dword/signed dword) 48
  (byte) KEY_ASTERISK#0 ← (byte/signed byte/word/signed word/dword/signed dword) 49
  (byte) KEY_SEMICOLON#0 ← (byte/signed byte/word/signed word/dword/signed dword) 50
  (byte) KEY_HOME#0 ← (byte/signed byte/word/signed word/dword/signed dword) 51
  (byte) KEY_RSHIFT#0 ← (byte/signed byte/word/signed word/dword/signed dword) 52
  (byte) KEY_EQUALS#0 ← (byte/signed byte/word/signed word/dword/signed dword) 53
  (byte) KEY_ARROW_UP#0 ← (byte/signed byte/word/signed word/dword/signed dword) 54
  (byte) KEY_SLASH#0 ← (byte/signed byte/word/signed word/dword/signed dword) 55
  (byte) KEY_1#0 ← (byte/signed byte/word/signed word/dword/signed dword) 56
  (byte) KEY_ARROW_LEFT#0 ← (byte/signed byte/word/signed word/dword/signed dword) 57
  (byte) KEY_CTRL#0 ← (byte/signed byte/word/signed word/dword/signed dword) 58
  (byte) KEY_2#0 ← (byte/signed byte/word/signed word/dword/signed dword) 59
  (byte) KEY_SPACE#0 ← (byte/signed byte/word/signed word/dword/signed dword) 60
  (byte) KEY_COMMODORE#0 ← (byte/signed byte/word/signed word/dword/signed dword) 61
  (byte) KEY_Q#0 ← (byte/signed byte/word/signed word/dword/signed dword) 62
  (byte) KEY_RUNSTOP#0 ← (byte/signed byte/word/signed word/dword/signed dword) 63
  (byte[]) keyboard_char_keycodes#0 ← { (byte) KEY_AT#0, (byte) KEY_A#0, (byte) KEY_B#0, (byte) KEY_C#0, (byte) KEY_D#0, (byte) KEY_E#0, (byte) KEY_F#0, (byte) KEY_G#0, (byte) KEY_H#0, (byte) KEY_I#0, (byte) KEY_J#0, (byte) KEY_K#0, (byte) KEY_L#0, (byte) KEY_M#0, (byte) KEY_N#0, (byte) KEY_O#0, (byte) KEY_P#0, (byte) KEY_Q#0, (byte) KEY_R#0, (byte) KEY_S#0, (byte) KEY_T#0, (byte) KEY_U#0, (byte) KEY_V#0, (byte) KEY_W#0, (byte) KEY_X#0, (byte) KEY_Y#0, (byte) KEY_Z#0, (byte/signed byte/word/signed word/dword/signed dword) 63, (byte) KEY_POUND#0, (byte/signed byte/word/signed word/dword/signed dword) 63, (byte) KEY_ARROW_UP#0, (byte) KEY_ARROW_LEFT#0, (byte) KEY_SPACE#0, (byte/signed byte/word/signed word/dword/signed dword) 63, (byte/signed byte/word/signed word/dword/signed dword) 63, (byte/signed byte/word/signed word/dword/signed dword) 63, (byte/signed byte/word/signed word/dword/signed dword) 63, (byte/signed byte/word/signed word/dword/signed dword) 63, (byte/signed byte/word/signed word/dword/signed dword) 63, (byte/signed byte/word/signed word/dword/signed dword) 63, (byte/signed byte/word/signed word/dword/signed dword) 63, (byte/signed byte/word/signed word/dword/signed dword) 63, (byte) KEY_ASTERISK#0, (byte) KEY_PLUS#0, (byte) KEY_COMMA#0, (byte) KEY_MINUS#0, (byte) KEY_DOT#0, (byte) KEY_SLASH#0, (byte) KEY_0#0, (byte) KEY_1#0, (byte) KEY_2#0, (byte) KEY_3#0, (byte) KEY_4#0, (byte) KEY_5#0, (byte) KEY_6#0, (byte) KEY_7#0, (byte) KEY_8#0, (byte) KEY_9#0, (byte) KEY_COLON#0, (byte) KEY_SEMICOLON#0, (byte/signed byte/word/signed word/dword/signed dword) 63, (byte) KEY_EQUALS#0, (byte/signed byte/word/signed word/dword/signed dword) 63, (byte/signed byte/word/signed word/dword/signed dword) 63 }
  (byte[8]) keyboard_matrix_row_bitmask#0 ← { (byte/word/signed word/dword/signed dword) 254, (byte/word/signed word/dword/signed dword) 253, (byte/word/signed word/dword/signed dword) 251, (byte/word/signed word/dword/signed dword) 247, (byte/word/signed word/dword/signed dword) 239, (byte/word/signed word/dword/signed dword) 223, (byte/word/signed word/dword/signed dword) 191, (byte/signed byte/word/signed word/dword/signed dword) 127 }
  (byte[8]) keyboard_matrix_col_bitmask#0 ← { (byte/signed byte/word/signed word/dword/signed dword) 1, (byte/signed byte/word/signed word/dword/signed dword) 2, (byte/signed byte/word/signed word/dword/signed dword) 4, (byte/signed byte/word/signed word/dword/signed dword) 8, (byte/signed byte/word/signed word/dword/signed dword) 16, (byte/signed byte/word/signed word/dword/signed dword) 32, (byte/signed byte/word/signed word/dword/signed dword) 64, (byte/word/signed word/dword/signed dword) 128 }
  to:@8
keyboard_matrix_read: scope:[keyboard_matrix_read]  from keyboard_key_pressed
  (byte) keyboard_matrix_read::rowid#1 ← phi( keyboard_key_pressed/(byte) keyboard_matrix_read::rowid#0 )
  *((byte*) CIA1_PORT_A#0) ← *((byte[8]) keyboard_matrix_row_bitmask#0 + (byte) keyboard_matrix_read::rowid#1)
  (byte~) keyboard_matrix_read::$0 ← ~ *((byte*) CIA1_PORT_B#0)
  (byte) keyboard_matrix_read::row_pressed_bits#0 ← (byte~) keyboard_matrix_read::$0
  (byte) keyboard_matrix_read::return#0 ← (byte) keyboard_matrix_read::row_pressed_bits#0
  to:keyboard_matrix_read::@return
keyboard_matrix_read::@return: scope:[keyboard_matrix_read]  from keyboard_matrix_read
  (byte) keyboard_matrix_read::return#3 ← phi( keyboard_matrix_read/(byte) keyboard_matrix_read::return#0 )
  (byte) keyboard_matrix_read::return#1 ← (byte) keyboard_matrix_read::return#3
  return 
  to:@return
keyboard_key_pressed: scope:[keyboard_key_pressed]  from menu::@2 menu::@4 menu::@5 pressed::@2
  (byte) keyboard_key_pressed::key#4 ← phi( menu::@2/(byte) keyboard_key_pressed::key#0 menu::@4/(byte) keyboard_key_pressed::key#1 menu::@5/(byte) keyboard_key_pressed::key#2 pressed::@2/(byte) keyboard_key_pressed::key#3 )
  (byte~) keyboard_key_pressed::$0 ← (byte) keyboard_key_pressed::key#4 & (byte/signed byte/word/signed word/dword/signed dword) 7
  (byte) keyboard_key_pressed::colidx#0 ← (byte~) keyboard_key_pressed::$0
  (byte~) keyboard_key_pressed::$1 ← (byte) keyboard_key_pressed::key#4 >> (byte/signed byte/word/signed word/dword/signed dword) 3
  (byte) keyboard_key_pressed::rowidx#0 ← (byte~) keyboard_key_pressed::$1
  (byte) keyboard_matrix_read::rowid#0 ← (byte) keyboard_key_pressed::rowidx#0
  call keyboard_matrix_read 
  (byte) keyboard_matrix_read::return#2 ← (byte) keyboard_matrix_read::return#1
  to:keyboard_key_pressed::@2
keyboard_key_pressed::@2: scope:[keyboard_key_pressed]  from keyboard_key_pressed
  (byte) keyboard_key_pressed::colidx#1 ← phi( keyboard_key_pressed/(byte) keyboard_key_pressed::colidx#0 )
  (byte) keyboard_matrix_read::return#4 ← phi( keyboard_key_pressed/(byte) keyboard_matrix_read::return#2 )
  (byte~) keyboard_key_pressed::$2 ← (byte) keyboard_matrix_read::return#4
  (byte~) keyboard_key_pressed::$3 ← (byte~) keyboard_key_pressed::$2 & *((byte[8]) keyboard_matrix_col_bitmask#0 + (byte) keyboard_key_pressed::colidx#1)
  (byte) keyboard_key_pressed::return#0 ← (byte~) keyboard_key_pressed::$3
  to:keyboard_key_pressed::@return
keyboard_key_pressed::@return: scope:[keyboard_key_pressed]  from keyboard_key_pressed::@2
  (byte) keyboard_key_pressed::return#6 ← phi( keyboard_key_pressed::@2/(byte) keyboard_key_pressed::return#0 )
  (byte) keyboard_key_pressed::return#1 ← (byte) keyboard_key_pressed::return#6
  return 
  to:@return
@8: scope:[]  from @4
  (byte[8]) keyboard_events#0 ← { fill( 8, 0) }
  (byte) keyboard_events_size#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  (byte) keyboard_modifiers#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  (byte) KEY_MODIFIER_LSHIFT#0 ← (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte) KEY_MODIFIER_RSHIFT#0 ← (byte/signed byte/word/signed word/dword/signed dword) 2
  (byte) KEY_MODIFIER_CTRL#0 ← (byte/signed byte/word/signed word/dword/signed dword) 4
  (byte) KEY_MODIFIER_COMMODORE#0 ← (byte/signed byte/word/signed word/dword/signed dword) 8
  (byte~) $0 ← (byte) KEY_MODIFIER_LSHIFT#0 | (byte) KEY_MODIFIER_RSHIFT#0
  (byte) KEY_MODIFIER_SHIFT#0 ← (byte~) $0
  (byte[8]) keyboard_scan_values#0 ← { fill( 8, 0) }
  to:@12
main: scope:[main]  from @14
  (byte*) SCREEN#12 ← phi( @14/(byte*) SCREEN#14 )
  *((byte*) BORDERCOL#0) ← (byte) GREEN#0
  to:main::@1
main::@1: scope:[main]  from main main::@7
  (byte*) SCREEN#11 ← phi( main/(byte*) SCREEN#12 main::@7/(byte*) SCREEN#13 )
  if(true) goto main::@2
  to:main::@return
main::@2: scope:[main]  from main::@1
  (byte*) SCREEN#10 ← phi( main::@1/(byte*) SCREEN#11 )
  call menu 
  to:main::@7
main::@7: scope:[main]  from main::@2
  (byte*) SCREEN#13 ← phi( main::@2/(byte*) SCREEN#10 )
  to:main::@1
main::@return: scope:[main]  from main::@1
  return 
  to:@return
@12: scope:[]  from @8
  (byte*) SCREEN#0 ← ((byte*)) (word/signed word/dword/signed dword) 1024
  to:@14
menu: scope:[menu]  from main::@2
  (byte*) SCREEN#9 ← phi( main::@2/(byte*) SCREEN#10 )
  to:menu::@1
menu::@1: scope:[menu]  from menu menu::@6
  (byte*) SCREEN#8 ← phi( menu/(byte*) SCREEN#9 menu::@6/(byte*) SCREEN#1 )
  if(true) goto menu::@2
  to:menu::@return
menu::@2: scope:[menu]  from menu::@1
  (byte*) SCREEN#7 ← phi( menu::@1/(byte*) SCREEN#8 )
  (byte) keyboard_key_pressed::key#0 ← (byte) KEY_C#0
  call keyboard_key_pressed 
  (byte) keyboard_key_pressed::return#2 ← (byte) keyboard_key_pressed::return#1
  to:menu::@16
menu::@16: scope:[menu]  from menu::@2
  (byte*) SCREEN#6 ← phi( menu::@2/(byte*) SCREEN#7 )
  (byte) keyboard_key_pressed::return#7 ← phi( menu::@2/(byte) keyboard_key_pressed::return#2 )
  (byte~) menu::$0 ← (byte) keyboard_key_pressed::return#7
  (bool~) menu::$1 ← (byte~) menu::$0 != (byte/signed byte/word/signed word/dword/signed dword) 0
  (bool~) menu::$2 ← ! (bool~) menu::$1
  if((bool~) menu::$2) goto menu::@4
  to:menu::@9
menu::@4: scope:[menu]  from menu::@16
  (byte*) SCREEN#5 ← phi( menu::@16/(byte*) SCREEN#6 )
  (byte) keyboard_key_pressed::key#1 ← (byte) KEY_I#0
  call keyboard_key_pressed 
  (byte) keyboard_key_pressed::return#3 ← (byte) keyboard_key_pressed::return#1
  to:menu::@17
menu::@17: scope:[menu]  from menu::@4
  (byte*) SCREEN#4 ← phi( menu::@4/(byte*) SCREEN#5 )
  (byte) keyboard_key_pressed::return#8 ← phi( menu::@4/(byte) keyboard_key_pressed::return#3 )
  (byte~) menu::$4 ← (byte) keyboard_key_pressed::return#8
  (bool~) menu::$5 ← (byte~) menu::$4 != (byte/signed byte/word/signed word/dword/signed dword) 0
  (bool~) menu::$6 ← ! (bool~) menu::$5
  if((bool~) menu::$6) goto menu::@5
  to:menu::@11
menu::@9: scope:[menu]  from menu::@16
  call pressed 
  to:menu::@18
menu::@18: scope:[menu]  from menu::@9
  to:menu::@return
menu::@return: scope:[menu]  from menu::@1 menu::@11 menu::@13 menu::@18
  return 
  to:@return
menu::@5: scope:[menu]  from menu::@17
  (byte*) SCREEN#3 ← phi( menu::@17/(byte*) SCREEN#4 )
  (byte) keyboard_key_pressed::key#2 ← (byte) KEY_E#0
  call keyboard_key_pressed 
  (byte) keyboard_key_pressed::return#4 ← (byte) keyboard_key_pressed::return#1
  to:menu::@19
menu::@19: scope:[menu]  from menu::@5
  (byte*) SCREEN#2 ← phi( menu::@5/(byte*) SCREEN#3 )
  (byte) keyboard_key_pressed::return#9 ← phi( menu::@5/(byte) keyboard_key_pressed::return#4 )
  (byte~) menu::$7 ← (byte) keyboard_key_pressed::return#9
  (bool~) menu::$8 ← (byte~) menu::$7 != (byte/signed byte/word/signed word/dword/signed dword) 0
  (bool~) menu::$9 ← ! (bool~) menu::$8
  if((bool~) menu::$9) goto menu::@6
  to:menu::@13
menu::@11: scope:[menu]  from menu::@17
  *((byte*) BORDERCOL#0) ← (byte) RED#0
  asm { sei  }
  to:menu::@return
menu::@6: scope:[menu]  from menu::@19
  (byte*) SCREEN#1 ← phi( menu::@19/(byte*) SCREEN#2 )
  *((byte*) SCREEN#1) ← ++ *((byte*) SCREEN#1)
  to:menu::@1
menu::@13: scope:[menu]  from menu::@19
  *((byte*) BORDERCOL#0) ← (byte) GREEN#0
  asm { cli  }
  to:menu::@return
pressed: scope:[pressed]  from menu::@9
  *((byte*) BGCOL#0) ← ++ *((byte*) BGCOL#0)
  to:pressed::@1
pressed::@1: scope:[pressed]  from pressed pressed::@4
  if(true) goto pressed::@2
  to:pressed::@return
pressed::@2: scope:[pressed]  from pressed::@1
  (byte) keyboard_key_pressed::key#3 ← (byte) KEY_SPACE#0
  call keyboard_key_pressed 
  (byte) keyboard_key_pressed::return#5 ← (byte) keyboard_key_pressed::return#1
  to:pressed::@10
pressed::@10: scope:[pressed]  from pressed::@2
  (byte) keyboard_key_pressed::return#10 ← phi( pressed::@2/(byte) keyboard_key_pressed::return#5 )
  (byte~) pressed::$0 ← (byte) keyboard_key_pressed::return#10
  (bool~) pressed::$1 ← (byte~) pressed::$0 != (byte/signed byte/word/signed word/dword/signed dword) 0
  (bool~) pressed::$2 ← ! (bool~) pressed::$1
  if((bool~) pressed::$2) goto pressed::@4
  to:pressed::@return
pressed::@4: scope:[pressed]  from pressed::@10
  to:pressed::@1
pressed::@return: scope:[pressed]  from pressed::@1 pressed::@10
  return 
  to:@return
@14: scope:[]  from @12
  (byte*) SCREEN#14 ← phi( @12/(byte*) SCREEN#0 )
  call main 
  to:@15
@15: scope:[]  from @14
  to:@end
@end: scope:[]  from @15

SYMBOL TABLE SSA
(byte~) $0
(label) @12
(label) @14
(label) @15
(label) @4
(label) @8
(label) @begin
(label) @end
(byte*) BGCOL
(byte*) BGCOL#0
(byte*) BGCOL1
(byte*) BGCOL1#0
(byte*) BGCOL2
(byte*) BGCOL2#0
(byte*) BGCOL3
(byte*) BGCOL3#0
(byte*) BGCOL4
(byte*) BGCOL4#0
(byte) BLACK
(byte) BLACK#0
(byte) BLUE
(byte) BLUE#0
(byte*) BORDERCOL
(byte*) BORDERCOL#0
(byte) BROWN
(byte) BROWN#0
(byte*) CHARGEN
(byte*) CHARGEN#0
(byte*) CIA1_INTERRUPT
(byte*) CIA1_INTERRUPT#0
(byte*) CIA1_PORT_A
(byte*) CIA1_PORT_A#0
(byte*) CIA1_PORT_A_DDR
(byte*) CIA1_PORT_A_DDR#0
(byte*) CIA1_PORT_B
(byte*) CIA1_PORT_B#0
(byte*) CIA1_PORT_B_DDR
(byte*) CIA1_PORT_B_DDR#0
(byte*) CIA2_INTERRUPT
(byte*) CIA2_INTERRUPT#0
(byte*) CIA2_PORT_A
(byte*) CIA2_PORT_A#0
(byte*) CIA2_PORT_A_DDR
(byte*) CIA2_PORT_A_DDR#0
(byte*) CIA2_PORT_B
(byte*) CIA2_PORT_B#0
(byte*) CIA2_PORT_B_DDR
(byte*) CIA2_PORT_B_DDR#0
(byte) CIA_INTERRUPT_CLEAR
(byte) CIA_INTERRUPT_CLEAR#0
(byte*) COLS
(byte*) COLS#0
(byte) CYAN
(byte) CYAN#0
(byte*) D011
(byte*) D011#0
(byte*) D016
(byte*) D016#0
(byte*) D018
(byte*) D018#0
(byte) DARK_GREY
(byte) DARK_GREY#0
(byte) GREEN
(byte) GREEN#0
(byte) GREY
(byte) GREY#0
(void()**) HARDWARE_IRQ
(void()**) HARDWARE_IRQ#0
(byte) IRQ_COLLISION_BG
(byte) IRQ_COLLISION_BG#0
(byte) IRQ_COLLISION_SPRITE
(byte) IRQ_COLLISION_SPRITE#0
(byte*) IRQ_ENABLE
(byte*) IRQ_ENABLE#0
(byte) IRQ_LIGHTPEN
(byte) IRQ_LIGHTPEN#0
(byte) IRQ_RASTER
(byte) IRQ_RASTER#0
(byte*) IRQ_STATUS
(byte*) IRQ_STATUS#0
(void()**) KERNEL_IRQ
(void()**) KERNEL_IRQ#0
(byte) KEY_0
(byte) KEY_0#0
(byte) KEY_1
(byte) KEY_1#0
(byte) KEY_2
(byte) KEY_2#0
(byte) KEY_3
(byte) KEY_3#0
(byte) KEY_4
(byte) KEY_4#0
(byte) KEY_5
(byte) KEY_5#0
(byte) KEY_6
(byte) KEY_6#0
(byte) KEY_7
(byte) KEY_7#0
(byte) KEY_8
(byte) KEY_8#0
(byte) KEY_9
(byte) KEY_9#0
(byte) KEY_A
(byte) KEY_A#0
(byte) KEY_ARROW_LEFT
(byte) KEY_ARROW_LEFT#0
(byte) KEY_ARROW_UP
(byte) KEY_ARROW_UP#0
(byte) KEY_ASTERISK
(byte) KEY_ASTERISK#0
(byte) KEY_AT
(byte) KEY_AT#0
(byte) KEY_B
(byte) KEY_B#0
(byte) KEY_C
(byte) KEY_C#0
(byte) KEY_COLON
(byte) KEY_COLON#0
(byte) KEY_COMMA
(byte) KEY_COMMA#0
(byte) KEY_COMMODORE
(byte) KEY_COMMODORE#0
(byte) KEY_CRSR_DOWN
(byte) KEY_CRSR_DOWN#0
(byte) KEY_CRSR_RIGHT
(byte) KEY_CRSR_RIGHT#0
(byte) KEY_CTRL
(byte) KEY_CTRL#0
(byte) KEY_D
(byte) KEY_D#0
(byte) KEY_DEL
(byte) KEY_DEL#0
(byte) KEY_DOT
(byte) KEY_DOT#0
(byte) KEY_E
(byte) KEY_E#0
(byte) KEY_EQUALS
(byte) KEY_EQUALS#0
(byte) KEY_F
(byte) KEY_F#0
(byte) KEY_F1
(byte) KEY_F1#0
(byte) KEY_F3
(byte) KEY_F3#0
(byte) KEY_F5
(byte) KEY_F5#0
(byte) KEY_F7
(byte) KEY_F7#0
(byte) KEY_G
(byte) KEY_G#0
(byte) KEY_H
(byte) KEY_H#0
(byte) KEY_HOME
(byte) KEY_HOME#0
(byte) KEY_I
(byte) KEY_I#0
(byte) KEY_J
(byte) KEY_J#0
(byte) KEY_K
(byte) KEY_K#0
(byte) KEY_L
(byte) KEY_L#0
(byte) KEY_LSHIFT
(byte) KEY_LSHIFT#0
(byte) KEY_M
(byte) KEY_M#0
(byte) KEY_MINUS
(byte) KEY_MINUS#0
(byte) KEY_MODIFIER_COMMODORE
(byte) KEY_MODIFIER_COMMODORE#0
(byte) KEY_MODIFIER_CTRL
(byte) KEY_MODIFIER_CTRL#0
(byte) KEY_MODIFIER_LSHIFT
(byte) KEY_MODIFIER_LSHIFT#0
(byte) KEY_MODIFIER_RSHIFT
(byte) KEY_MODIFIER_RSHIFT#0
(byte) KEY_MODIFIER_SHIFT
(byte) KEY_MODIFIER_SHIFT#0
(byte) KEY_N
(byte) KEY_N#0
(byte) KEY_O
(byte) KEY_O#0
(byte) KEY_P
(byte) KEY_P#0
(byte) KEY_PLUS
(byte) KEY_PLUS#0
(byte) KEY_POUND
(byte) KEY_POUND#0
(byte) KEY_Q
(byte) KEY_Q#0
(byte) KEY_R
(byte) KEY_R#0
(byte) KEY_RETURN
(byte) KEY_RETURN#0
(byte) KEY_RSHIFT
(byte) KEY_RSHIFT#0
(byte) KEY_RUNSTOP
(byte) KEY_RUNSTOP#0
(byte) KEY_S
(byte) KEY_S#0
(byte) KEY_SEMICOLON
(byte) KEY_SEMICOLON#0
(byte) KEY_SLASH
(byte) KEY_SLASH#0
(byte) KEY_SPACE
(byte) KEY_SPACE#0
(byte) KEY_T
(byte) KEY_T#0
(byte) KEY_U
(byte) KEY_U#0
(byte) KEY_V
(byte) KEY_V#0
(byte) KEY_W
(byte) KEY_W#0
(byte) KEY_X
(byte) KEY_X#0
(byte) KEY_Y
(byte) KEY_Y#0
(byte) KEY_Z
(byte) KEY_Z#0
(byte*) LIGHTPEN_X
(byte*) LIGHTPEN_X#0
(byte*) LIGHTPEN_Y
(byte*) LIGHTPEN_Y#0
(byte) LIGHT_BLUE
(byte) LIGHT_BLUE#0
(byte) LIGHT_GREEN
(byte) LIGHT_GREEN#0
(byte) LIGHT_GREY
(byte) LIGHT_GREY#0
(byte) ORANGE
(byte) ORANGE#0
(byte) PINK
(byte) PINK#0
(byte*) PROCPORT
(byte*) PROCPORT#0
(byte) PROCPORT_BASIC_KERNEL_IO
(byte) PROCPORT_BASIC_KERNEL_IO#0
(byte*) PROCPORT_DDR
(byte*) PROCPORT_DDR#0
(byte) PROCPORT_DDR_MEMORY_MASK
(byte) PROCPORT_DDR_MEMORY_MASK#0
(byte) PROCPORT_KERNEL_IO
(byte) PROCPORT_KERNEL_IO#0
(byte) PROCPORT_RAM_ALL
(byte) PROCPORT_RAM_ALL#0
(byte) PROCPORT_RAM_CHARROM
(byte) PROCPORT_RAM_CHARROM#0
(byte) PROCPORT_RAM_IO
(byte) PROCPORT_RAM_IO#0
(byte) PURPLE
(byte) PURPLE#0
(byte*) RASTER
(byte*) RASTER#0
(byte) RED
(byte) RED#0
(byte*) SCREEN
(byte*) SCREEN#0
(byte*) SCREEN#1
(byte*) SCREEN#10
(byte*) SCREEN#11
(byte*) SCREEN#12
(byte*) SCREEN#13
(byte*) SCREEN#14
(byte*) SCREEN#2
(byte*) SCREEN#3
(byte*) SCREEN#4
(byte*) SCREEN#5
(byte*) SCREEN#6
(byte*) SCREEN#7
(byte*) SCREEN#8
(byte*) SCREEN#9
(byte*) SPRITES_COLS
(byte*) SPRITES_COLS#0
(byte*) SPRITES_ENABLE
(byte*) SPRITES_ENABLE#0
(byte*) SPRITES_EXPAND_X
(byte*) SPRITES_EXPAND_X#0
(byte*) SPRITES_EXPAND_Y
(byte*) SPRITES_EXPAND_Y#0
(byte*) SPRITES_MC
(byte*) SPRITES_MC#0
(byte*) SPRITES_MC1
(byte*) SPRITES_MC1#0
(byte*) SPRITES_MC2
(byte*) SPRITES_MC2#0
(byte*) SPRITES_PRIORITY
(byte*) SPRITES_PRIORITY#0
(byte*) SPRITES_XMSB
(byte*) SPRITES_XMSB#0
(byte*) SPRITES_XPOS
(byte*) SPRITES_XPOS#0
(byte*) SPRITES_YPOS
(byte*) SPRITES_YPOS#0
(word) SPRITE_PTRS
(word) SPRITE_PTRS#0
(byte) VIC_BMM
(byte) VIC_BMM#0
(byte*) VIC_CONTROL
(byte*) VIC_CONTROL#0
(byte*) VIC_CONTROL2
(byte*) VIC_CONTROL2#0
(byte) VIC_CSEL
(byte) VIC_CSEL#0
(byte) VIC_DEN
(byte) VIC_DEN#0
(byte) VIC_ECM
(byte) VIC_ECM#0
(byte) VIC_MCM
(byte) VIC_MCM#0
(byte*) VIC_MEMORY
(byte*) VIC_MEMORY#0
(byte) VIC_RSEL
(byte) VIC_RSEL#0
(byte) VIC_RST8
(byte) VIC_RST8#0
(byte) WHITE
(byte) WHITE#0
(byte) YELLOW
(byte) YELLOW#0
(byte[]) keyboard_char_keycodes
(byte[]) keyboard_char_keycodes#0
(byte[8]) keyboard_events
(byte[8]) keyboard_events#0
(byte) keyboard_events_size
(byte) keyboard_events_size#0
(byte()) keyboard_key_pressed((byte) keyboard_key_pressed::key)
(byte~) keyboard_key_pressed::$0
(byte~) keyboard_key_pressed::$1
(byte~) keyboard_key_pressed::$2
(byte~) keyboard_key_pressed::$3
(label) keyboard_key_pressed::@2
(label) keyboard_key_pressed::@return
(byte) keyboard_key_pressed::colidx
(byte) keyboard_key_pressed::colidx#0
(byte) keyboard_key_pressed::colidx#1
(byte) keyboard_key_pressed::key
(byte) keyboard_key_pressed::key#0
(byte) keyboard_key_pressed::key#1
(byte) keyboard_key_pressed::key#2
(byte) keyboard_key_pressed::key#3
(byte) keyboard_key_pressed::key#4
(byte) keyboard_key_pressed::return
(byte) keyboard_key_pressed::return#0
(byte) keyboard_key_pressed::return#1
(byte) keyboard_key_pressed::return#10
(byte) keyboard_key_pressed::return#2
(byte) keyboard_key_pressed::return#3
(byte) keyboard_key_pressed::return#4
(byte) keyboard_key_pressed::return#5
(byte) keyboard_key_pressed::return#6
(byte) keyboard_key_pressed::return#7
(byte) keyboard_key_pressed::return#8
(byte) keyboard_key_pressed::return#9
(byte) keyboard_key_pressed::rowidx
(byte) keyboard_key_pressed::rowidx#0
(byte[8]) keyboard_matrix_col_bitmask
(byte[8]) keyboard_matrix_col_bitmask#0
(byte()) keyboard_matrix_read((byte) keyboard_matrix_read::rowid)
(byte~) keyboard_matrix_read::$0
(label) keyboard_matrix_read::@return
(byte) keyboard_matrix_read::return
(byte) keyboard_matrix_read::return#0
(byte) keyboard_matrix_read::return#1
(byte) keyboard_matrix_read::return#2
(byte) keyboard_matrix_read::return#3
(byte) keyboard_matrix_read::return#4
(byte) keyboard_matrix_read::row_pressed_bits
(byte) keyboard_matrix_read::row_pressed_bits#0
(byte) keyboard_matrix_read::rowid
(byte) keyboard_matrix_read::rowid#0
(byte) keyboard_matrix_read::rowid#1
(byte[8]) keyboard_matrix_row_bitmask
(byte[8]) keyboard_matrix_row_bitmask#0
(byte) keyboard_modifiers
(byte) keyboard_modifiers#0
(byte[8]) keyboard_scan_values
(byte[8]) keyboard_scan_values#0
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@7
(label) main::@return
(void()) menu()
(byte~) menu::$0
(bool~) menu::$1
(bool~) menu::$2
(byte~) menu::$4
(bool~) menu::$5
(bool~) menu::$6
(byte~) menu::$7
(bool~) menu::$8
(bool~) menu::$9
(label) menu::@1
(label) menu::@11
(label) menu::@13
(label) menu::@16
(label) menu::@17
(label) menu::@18
(label) menu::@19
(label) menu::@2
(label) menu::@4
(label) menu::@5
(label) menu::@6
(label) menu::@9
(label) menu::@return
(void()) pressed()
(byte~) pressed::$0
(bool~) pressed::$1
(bool~) pressed::$2
(label) pressed::@1
(label) pressed::@10
(label) pressed::@2
(label) pressed::@4
(label) pressed::@return

Culled Empty Block (label) menu::@18
Culled Empty Block (label) pressed::@4
Culled Empty Block (label) @15
Successful SSA optimization Pass2CullEmptyBlocks
Inversing boolean not [198] (bool~) menu::$2 ← (byte~) menu::$0 == (byte/signed byte/word/signed word/dword/signed dword) 0 from [197] (bool~) menu::$1 ← (byte~) menu::$0 != (byte/signed byte/word/signed word/dword/signed dword) 0
Inversing boolean not [207] (bool~) menu::$6 ← (byte~) menu::$4 == (byte/signed byte/word/signed word/dword/signed dword) 0 from [206] (bool~) menu::$5 ← (byte~) menu::$4 != (byte/signed byte/word/signed word/dword/signed dword) 0
Inversing boolean not [218] (bool~) menu::$9 ← (byte~) menu::$7 == (byte/signed byte/word/signed word/dword/signed dword) 0 from [217] (bool~) menu::$8 ← (byte~) menu::$7 != (byte/signed byte/word/signed word/dword/signed dword) 0
Inversing boolean not [234] (bool~) pressed::$2 ← (byte~) pressed::$0 == (byte/signed byte/word/signed word/dword/signed dword) 0 from [233] (bool~) pressed::$1 ← (byte~) pressed::$0 != (byte/signed byte/word/signed word/dword/signed dword) 0
Successful SSA optimization Pass2UnaryNotSimplification
Alias (byte) keyboard_matrix_read::return#0 = (byte) keyboard_matrix_read::row_pressed_bits#0 (byte~) keyboard_matrix_read::$0 (byte) keyboard_matrix_read::return#3 (byte) keyboard_matrix_read::return#1 
Alias (byte) keyboard_key_pressed::colidx#0 = (byte~) keyboard_key_pressed::$0 (byte) keyboard_key_pressed::colidx#1 
Alias (byte) keyboard_key_pressed::rowidx#0 = (byte~) keyboard_key_pressed::$1 
Alias (byte) keyboard_matrix_read::return#2 = (byte) keyboard_matrix_read::return#4 
Alias (byte) keyboard_key_pressed::return#0 = (byte~) keyboard_key_pressed::$3 (byte) keyboard_key_pressed::return#6 (byte) keyboard_key_pressed::return#1 
Alias (byte) KEY_MODIFIER_SHIFT#0 = (byte~) $0 
Alias (byte*) SCREEN#10 = (byte*) SCREEN#11 (byte*) SCREEN#13 
Alias (byte*) SCREEN#1 = (byte*) SCREEN#7 (byte*) SCREEN#8 (byte*) SCREEN#6 (byte*) SCREEN#5 (byte*) SCREEN#4 (byte*) SCREEN#3 (byte*) SCREEN#2 
Alias (byte) keyboard_key_pressed::return#2 = (byte) keyboard_key_pressed::return#7 
Alias (byte) keyboard_key_pressed::return#3 = (byte) keyboard_key_pressed::return#8 
Alias (byte) keyboard_key_pressed::return#4 = (byte) keyboard_key_pressed::return#9 
Alias (byte) keyboard_key_pressed::return#10 = (byte) keyboard_key_pressed::return#5 
Alias (byte*) SCREEN#0 = (byte*) SCREEN#14 
Successful SSA optimization Pass2AliasElimination
Self Phi Eliminated (byte*) SCREEN#10
Self Phi Eliminated (byte*) SCREEN#1
Successful SSA optimization Pass2SelfPhiElimination
Redundant Phi (byte) keyboard_matrix_read::rowid#1 (byte) keyboard_matrix_read::rowid#0
Redundant Phi (byte*) SCREEN#12 (byte*) SCREEN#0
Redundant Phi (byte*) SCREEN#10 (byte*) SCREEN#12
Redundant Phi (byte*) SCREEN#9 (byte*) SCREEN#10
Redundant Phi (byte*) SCREEN#1 (byte*) SCREEN#9
Successful SSA optimization Pass2RedundantPhiElimination
Simple Condition (bool~) menu::$2 [199] if((byte~) menu::$0==(byte/signed byte/word/signed word/dword/signed dword) 0) goto menu::@4
Simple Condition (bool~) menu::$6 [208] if((byte~) menu::$4==(byte/signed byte/word/signed word/dword/signed dword) 0) goto menu::@5
Simple Condition (bool~) menu::$9 [219] if((byte~) menu::$7==(byte/signed byte/word/signed word/dword/signed dword) 0) goto menu::@6
Simple Condition (bool~) pressed::$2 [235] if((byte~) pressed::$0==(byte/signed byte/word/signed word/dword/signed dword) 0) goto pressed::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) PROCPORT_DDR#0 = ((byte*))0
Constant (const byte) PROCPORT_DDR_MEMORY_MASK#0 = 7
Constant (const byte*) PROCPORT#0 = ((byte*))1
Constant (const byte) PROCPORT_RAM_ALL#0 = 48
Constant (const byte) PROCPORT_RAM_IO#0 = 53
Constant (const byte) PROCPORT_RAM_CHARROM#0 = 49
Constant (const byte) PROCPORT_KERNEL_IO#0 = 54
Constant (const byte) PROCPORT_BASIC_KERNEL_IO#0 = 55
Constant (const byte*) CHARGEN#0 = ((byte*))53248
Constant (const word) SPRITE_PTRS#0 = 1016
Constant (const byte*) SPRITES_XPOS#0 = ((byte*))53248
Constant (const byte*) SPRITES_YPOS#0 = ((byte*))53249
Constant (const byte*) SPRITES_XMSB#0 = ((byte*))53264
Constant (const byte*) RASTER#0 = ((byte*))53266
Constant (const byte*) SPRITES_ENABLE#0 = ((byte*))53269
Constant (const byte*) SPRITES_EXPAND_Y#0 = ((byte*))53271
Constant (const byte*) SPRITES_PRIORITY#0 = ((byte*))53275
Constant (const byte*) SPRITES_MC#0 = ((byte*))53276
Constant (const byte*) SPRITES_EXPAND_X#0 = ((byte*))53277
Constant (const byte*) BORDERCOL#0 = ((byte*))53280
Constant (const byte*) BGCOL#0 = ((byte*))53281
Constant (const byte*) BGCOL1#0 = ((byte*))53281
Constant (const byte*) BGCOL2#0 = ((byte*))53282
Constant (const byte*) BGCOL3#0 = ((byte*))53283
Constant (const byte*) BGCOL4#0 = ((byte*))53284
Constant (const byte*) SPRITES_MC1#0 = ((byte*))53285
Constant (const byte*) SPRITES_MC2#0 = ((byte*))53286
Constant (const byte*) SPRITES_COLS#0 = ((byte*))53287
Constant (const byte*) VIC_CONTROL#0 = ((byte*))53265
Constant (const byte*) D011#0 = ((byte*))53265
Constant (const byte) VIC_RST8#0 = 128
Constant (const byte) VIC_ECM#0 = 64
Constant (const byte) VIC_BMM#0 = 32
Constant (const byte) VIC_DEN#0 = 16
Constant (const byte) VIC_RSEL#0 = 8
Constant (const byte*) VIC_CONTROL2#0 = ((byte*))53270
Constant (const byte*) D016#0 = ((byte*))53270
Constant (const byte) VIC_MCM#0 = 16
Constant (const byte) VIC_CSEL#0 = 8
Constant (const byte*) D018#0 = ((byte*))53272
Constant (const byte*) VIC_MEMORY#0 = ((byte*))53272
Constant (const byte*) LIGHTPEN_X#0 = ((byte*))53267
Constant (const byte*) LIGHTPEN_Y#0 = ((byte*))53268
Constant (const byte*) IRQ_STATUS#0 = ((byte*))53273
Constant (const byte*) IRQ_ENABLE#0 = ((byte*))53274
Constant (const byte) IRQ_RASTER#0 = 1
Constant (const byte) IRQ_COLLISION_BG#0 = 2
Constant (const byte) IRQ_COLLISION_SPRITE#0 = 4
Constant (const byte) IRQ_LIGHTPEN#0 = 8
Constant (const byte*) COLS#0 = ((byte*))55296
Constant (const byte*) CIA1_PORT_A#0 = ((byte*))56320
Constant (const byte*) CIA1_PORT_B#0 = ((byte*))56321
Constant (const byte*) CIA1_PORT_A_DDR#0 = ((byte*))56322
Constant (const byte*) CIA1_PORT_B_DDR#0 = ((byte*))56323
Constant (const byte*) CIA1_INTERRUPT#0 = ((byte*))56333
Constant (const byte) CIA_INTERRUPT_CLEAR#0 = 127
Constant (const byte*) CIA2_PORT_A#0 = ((byte*))56576
Constant (const byte*) CIA2_PORT_B#0 = ((byte*))56577
Constant (const byte*) CIA2_PORT_A_DDR#0 = ((byte*))56578
Constant (const byte*) CIA2_PORT_B_DDR#0 = ((byte*))56579
Constant (const byte*) CIA2_INTERRUPT#0 = ((byte*))56589
Constant (const void()**) KERNEL_IRQ#0 = ((void()**))788
Constant (const void()**) HARDWARE_IRQ#0 = ((void()**))65534
Constant (const byte) BLACK#0 = 0
Constant (const byte) WHITE#0 = 1
Constant (const byte) RED#0 = 2
Constant (const byte) CYAN#0 = 3
Constant (const byte) PURPLE#0 = 4
Constant (const byte) GREEN#0 = 5
Constant (const byte) BLUE#0 = 6
Constant (const byte) YELLOW#0 = 7
Constant (const byte) ORANGE#0 = 8
Constant (const byte) BROWN#0 = 9
Constant (const byte) PINK#0 = 10
Constant (const byte) DARK_GREY#0 = 11
Constant (const byte) GREY#0 = 12
Constant (const byte) LIGHT_GREEN#0 = 13
Constant (const byte) LIGHT_BLUE#0 = 14
Constant (const byte) LIGHT_GREY#0 = 15
Constant (const byte) KEY_DEL#0 = 0
Constant (const byte) KEY_RETURN#0 = 1
Constant (const byte) KEY_CRSR_RIGHT#0 = 2
Constant (const byte) KEY_F7#0 = 3
Constant (const byte) KEY_F1#0 = 4
Constant (const byte) KEY_F3#0 = 5
Constant (const byte) KEY_F5#0 = 6
Constant (const byte) KEY_CRSR_DOWN#0 = 7
Constant (const byte) KEY_3#0 = 8
Constant (const byte) KEY_W#0 = 9
Constant (const byte) KEY_A#0 = 10
Constant (const byte) KEY_4#0 = 11
Constant (const byte) KEY_Z#0 = 12
Constant (const byte) KEY_S#0 = 13
Constant (const byte) KEY_E#0 = 14
Constant (const byte) KEY_LSHIFT#0 = 15
Constant (const byte) KEY_5#0 = 16
Constant (const byte) KEY_R#0 = 17
Constant (const byte) KEY_D#0 = 18
Constant (const byte) KEY_6#0 = 19
Constant (const byte) KEY_C#0 = 20
Constant (const byte) KEY_F#0 = 21
Constant (const byte) KEY_T#0 = 22
Constant (const byte) KEY_X#0 = 23
Constant (const byte) KEY_7#0 = 24
Constant (const byte) KEY_Y#0 = 25
Constant (const byte) KEY_G#0 = 26
Constant (const byte) KEY_8#0 = 27
Constant (const byte) KEY_B#0 = 28
Constant (const byte) KEY_H#0 = 29
Constant (const byte) KEY_U#0 = 30
Constant (const byte) KEY_V#0 = 31
Constant (const byte) KEY_9#0 = 32
Constant (const byte) KEY_I#0 = 33
Constant (const byte) KEY_J#0 = 34
Constant (const byte) KEY_0#0 = 35
Constant (const byte) KEY_M#0 = 36
Constant (const byte) KEY_K#0 = 37
Constant (const byte) KEY_O#0 = 38
Constant (const byte) KEY_N#0 = 39
Constant (const byte) KEY_PLUS#0 = 40
Constant (const byte) KEY_P#0 = 41
Constant (const byte) KEY_L#0 = 42
Constant (const byte) KEY_MINUS#0 = 43
Constant (const byte) KEY_DOT#0 = 44
Constant (const byte) KEY_COLON#0 = 45
Constant (const byte) KEY_AT#0 = 46
Constant (const byte) KEY_COMMA#0 = 47
Constant (const byte) KEY_POUND#0 = 48
Constant (const byte) KEY_ASTERISK#0 = 49
Constant (const byte) KEY_SEMICOLON#0 = 50
Constant (const byte) KEY_HOME#0 = 51
Constant (const byte) KEY_RSHIFT#0 = 52
Constant (const byte) KEY_EQUALS#0 = 53
Constant (const byte) KEY_ARROW_UP#0 = 54
Constant (const byte) KEY_SLASH#0 = 55
Constant (const byte) KEY_1#0 = 56
Constant (const byte) KEY_ARROW_LEFT#0 = 57
Constant (const byte) KEY_CTRL#0 = 58
Constant (const byte) KEY_2#0 = 59
Constant (const byte) KEY_SPACE#0 = 60
Constant (const byte) KEY_COMMODORE#0 = 61
Constant (const byte) KEY_Q#0 = 62
Constant (const byte) KEY_RUNSTOP#0 = 63
Constant (const byte[8]) keyboard_matrix_row_bitmask#0 = { 254, 253, 251, 247, 239, 223, 191, 127 }
Constant (const byte[8]) keyboard_matrix_col_bitmask#0 = { 1, 2, 4, 8, 16, 32, 64, 128 }
Constant (const byte[8]) keyboard_events#0 = { fill( 8, 0) }
Constant (const byte) keyboard_events_size#0 = 0
Constant (const byte) keyboard_modifiers#0 = 0
Constant (const byte) KEY_MODIFIER_LSHIFT#0 = 1
Constant (const byte) KEY_MODIFIER_RSHIFT#0 = 2
Constant (const byte) KEY_MODIFIER_CTRL#0 = 4
Constant (const byte) KEY_MODIFIER_COMMODORE#0 = 8
Constant (const byte[8]) keyboard_scan_values#0 = { fill( 8, 0) }
Constant (const byte*) SCREEN#0 = ((byte*))1024
Successful SSA optimization Pass2ConstantIdentification
Constant (const byte[]) keyboard_char_keycodes#0 = { KEY_AT#0, KEY_A#0, KEY_B#0, KEY_C#0, KEY_D#0, KEY_E#0, KEY_F#0, KEY_G#0, KEY_H#0, KEY_I#0, KEY_J#0, KEY_K#0, KEY_L#0, KEY_M#0, KEY_N#0, KEY_O#0, KEY_P#0, KEY_Q#0, KEY_R#0, KEY_S#0, KEY_T#0, KEY_U#0, KEY_V#0, KEY_W#0, KEY_X#0, KEY_Y#0, KEY_Z#0, 63, KEY_POUND#0, 63, KEY_ARROW_UP#0, KEY_ARROW_LEFT#0, KEY_SPACE#0, 63, 63, 63, 63, 63, 63, 63, 63, 63, KEY_ASTERISK#0, KEY_PLUS#0, KEY_COMMA#0, KEY_MINUS#0, KEY_DOT#0, KEY_SLASH#0, KEY_0#0, KEY_1#0, KEY_2#0, KEY_3#0, KEY_4#0, KEY_5#0, KEY_6#0, KEY_7#0, KEY_8#0, KEY_9#0, KEY_COLON#0, KEY_SEMICOLON#0, 63, KEY_EQUALS#0, 63, 63 }
Constant (const byte) KEY_MODIFIER_SHIFT#0 = KEY_MODIFIER_LSHIFT#0|KEY_MODIFIER_RSHIFT#0
Constant (const byte) keyboard_key_pressed::key#0 = KEY_C#0
Constant (const byte) keyboard_key_pressed::key#1 = KEY_I#0
Constant (const byte) keyboard_key_pressed::key#2 = KEY_E#0
Constant (const byte) keyboard_key_pressed::key#3 = KEY_SPACE#0
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [13] if(true) goto main::@2
if() condition always true - replacing block destination [16] if(true) goto menu::@2
if() condition always true - replacing block destination [37] if(true) goto pressed::@2
Successful SSA optimization Pass2ConstantIfs
Successful SSA optimization PassNEliminateUnusedVars
Successful SSA optimization PassNEliminateUnusedVars
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Culled Empty Block (label) @4
Culled Empty Block (label) @8
Culled Empty Block (label) main::@1
Culled Empty Block (label) main::@7
Culled Empty Block (label) @12
Culled Empty Block (label) menu::@1
Culled Empty Block (label) pressed::@1
Successful SSA optimization Pass2CullEmptyBlocks
Inlining constant with var siblings (const byte) keyboard_key_pressed::key#0
Inlining constant with var siblings (const byte) keyboard_key_pressed::key#1
Inlining constant with var siblings (const byte) keyboard_key_pressed::key#2
Inlining constant with var siblings (const byte) keyboard_key_pressed::key#3
Constant inlined keyboard_key_pressed::key#0 = (const byte) KEY_C#0
Constant inlined keyboard_key_pressed::key#1 = (const byte) KEY_I#0
Constant inlined keyboard_key_pressed::key#2 = (const byte) KEY_E#0
Constant inlined keyboard_key_pressed::key#3 = (const byte) KEY_SPACE#0
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @14
Adding NOP phi() at start of @end
Adding NOP phi() at start of main::@2
Adding NOP phi() at start of menu
Adding NOP phi() at start of menu::@2
Adding NOP phi() at start of menu::@9
Adding NOP phi() at start of menu::@4
Adding NOP phi() at start of menu::@5
Adding NOP phi() at start of pressed::@2
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to menu:6 
Calls in [menu] to keyboard_key_pressed:9 pressed:14 keyboard_key_pressed:17 keyboard_key_pressed:24 
Calls in [keyboard_key_pressed] to keyboard_matrix_read:35 
Calls in [pressed] to keyboard_key_pressed:45 

Created 1 initial phi equivalence classes
Coalesced down to 1 phi equivalence classes
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @14
Adding NOP phi() at start of @end
Adding NOP phi() at start of main::@2
Adding NOP phi() at start of menu
Adding NOP phi() at start of menu::@2
Adding NOP phi() at start of menu::@9
Adding NOP phi() at start of menu::@4
Adding NOP phi() at start of menu::@5
Adding NOP phi() at start of pressed::@2

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi()
  to:@14
@14: scope:[]  from @begin
  [1] phi()
  [2] call main 
  to:@end
@end: scope:[]  from @14
  [3] phi()
main: scope:[main]  from @14
  [4] *((const byte*) BORDERCOL#0) ← (const byte) GREEN#0
  to:main::@2
main::@2: scope:[main]  from main main::@2
  [5] phi()
  [6] call menu 
  to:main::@2
menu: scope:[menu]  from main::@2
  [7] phi()
  to:menu::@2
menu::@2: scope:[menu]  from menu menu::@6
  [8] phi()
  [9] call keyboard_key_pressed 
  [10] (byte) keyboard_key_pressed::return#2 ← (byte) keyboard_key_pressed::return#0
  to:menu::@16
menu::@16: scope:[menu]  from menu::@2
  [11] (byte~) menu::$0 ← (byte) keyboard_key_pressed::return#2
  [12] if((byte~) menu::$0==(byte/signed byte/word/signed word/dword/signed dword) 0) goto menu::@4
  to:menu::@9
menu::@9: scope:[menu]  from menu::@16
  [13] phi()
  [14] call pressed 
  to:menu::@return
menu::@return: scope:[menu]  from menu::@11 menu::@13 menu::@9
  [15] return 
  to:@return
menu::@4: scope:[menu]  from menu::@16
  [16] phi()
  [17] call keyboard_key_pressed 
  [18] (byte) keyboard_key_pressed::return#3 ← (byte) keyboard_key_pressed::return#0
  to:menu::@17
menu::@17: scope:[menu]  from menu::@4
  [19] (byte~) menu::$4 ← (byte) keyboard_key_pressed::return#3
  [20] if((byte~) menu::$4==(byte/signed byte/word/signed word/dword/signed dword) 0) goto menu::@5
  to:menu::@11
menu::@11: scope:[menu]  from menu::@17
  [21] *((const byte*) BORDERCOL#0) ← (const byte) RED#0
  asm { sei  }
  to:menu::@return
menu::@5: scope:[menu]  from menu::@17
  [23] phi()
  [24] call keyboard_key_pressed 
  [25] (byte) keyboard_key_pressed::return#4 ← (byte) keyboard_key_pressed::return#0
  to:menu::@19
menu::@19: scope:[menu]  from menu::@5
  [26] (byte~) menu::$7 ← (byte) keyboard_key_pressed::return#4
  [27] if((byte~) menu::$7==(byte/signed byte/word/signed word/dword/signed dword) 0) goto menu::@6
  to:menu::@13
menu::@13: scope:[menu]  from menu::@19
  [28] *((const byte*) BORDERCOL#0) ← (const byte) GREEN#0
  asm { cli  }
  to:menu::@return
menu::@6: scope:[menu]  from menu::@19
  [30] *((const byte*) SCREEN#0) ← ++ *((const byte*) SCREEN#0)
  to:menu::@2
keyboard_key_pressed: scope:[keyboard_key_pressed]  from menu::@2 menu::@4 menu::@5 pressed::@2
  [31] (byte) keyboard_key_pressed::key#4 ← phi( menu::@2/(const byte) KEY_C#0 menu::@4/(const byte) KEY_I#0 menu::@5/(const byte) KEY_E#0 pressed::@2/(const byte) KEY_SPACE#0 )
  [32] (byte) keyboard_key_pressed::colidx#0 ← (byte) keyboard_key_pressed::key#4 & (byte/signed byte/word/signed word/dword/signed dword) 7
  [33] (byte) keyboard_key_pressed::rowidx#0 ← (byte) keyboard_key_pressed::key#4 >> (byte/signed byte/word/signed word/dword/signed dword) 3
  [34] (byte) keyboard_matrix_read::rowid#0 ← (byte) keyboard_key_pressed::rowidx#0
  [35] call keyboard_matrix_read 
  [36] (byte) keyboard_matrix_read::return#2 ← (byte) keyboard_matrix_read::return#0
  to:keyboard_key_pressed::@2
keyboard_key_pressed::@2: scope:[keyboard_key_pressed]  from keyboard_key_pressed
  [37] (byte~) keyboard_key_pressed::$2 ← (byte) keyboard_matrix_read::return#2
  [38] (byte) keyboard_key_pressed::return#0 ← (byte~) keyboard_key_pressed::$2 & *((const byte[8]) keyboard_matrix_col_bitmask#0 + (byte) keyboard_key_pressed::colidx#0)
  to:keyboard_key_pressed::@return
keyboard_key_pressed::@return: scope:[keyboard_key_pressed]  from keyboard_key_pressed::@2
  [39] return 
  to:@return
keyboard_matrix_read: scope:[keyboard_matrix_read]  from keyboard_key_pressed
  [40] *((const byte*) CIA1_PORT_A#0) ← *((const byte[8]) keyboard_matrix_row_bitmask#0 + (byte) keyboard_matrix_read::rowid#0)
  [41] (byte) keyboard_matrix_read::return#0 ← ~ *((const byte*) CIA1_PORT_B#0)
  to:keyboard_matrix_read::@return
keyboard_matrix_read::@return: scope:[keyboard_matrix_read]  from keyboard_matrix_read
  [42] return 
  to:@return
pressed: scope:[pressed]  from menu::@9
  [43] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0)
  to:pressed::@2
pressed::@2: scope:[pressed]  from pressed pressed::@10
  [44] phi()
  [45] call keyboard_key_pressed 
  [46] (byte) keyboard_key_pressed::return#10 ← (byte) keyboard_key_pressed::return#0
  to:pressed::@10
pressed::@10: scope:[pressed]  from pressed::@2
  [47] (byte~) pressed::$0 ← (byte) keyboard_key_pressed::return#10
  [48] if((byte~) pressed::$0==(byte/signed byte/word/signed word/dword/signed dword) 0) goto pressed::@2
  to:pressed::@return
pressed::@return: scope:[pressed]  from pressed::@10
  [49] return 
  to:@return

null depth in calling loop Loop head: pressed::@2 tails: pressed::@10 blocks: pressed::@10 pressed::@2  in scope keyboard_key_pressed

VARIABLE REGISTER WEIGHTS
(byte*) BGCOL
(byte*) BGCOL1
(byte*) BGCOL2
(byte*) BGCOL3
(byte*) BGCOL4
(byte) BLACK
(byte) BLUE
(byte*) BORDERCOL
(byte) BROWN
(byte*) CHARGEN
(byte*) CIA1_INTERRUPT
(byte*) CIA1_PORT_A
(byte*) CIA1_PORT_A_DDR
(byte*) CIA1_PORT_B
(byte*) CIA1_PORT_B_DDR
(byte*) CIA2_INTERRUPT
(byte*) CIA2_PORT_A
(byte*) CIA2_PORT_A_DDR
(byte*) CIA2_PORT_B
(byte*) CIA2_PORT_B_DDR
(byte) CIA_INTERRUPT_CLEAR
(byte*) COLS
(byte) CYAN
(byte*) D011
(byte*) D016
(byte*) D018
(byte) DARK_GREY
(byte) GREEN
(byte) GREY
(void()**) HARDWARE_IRQ
(byte) IRQ_COLLISION_BG
(byte) IRQ_COLLISION_SPRITE
(byte*) IRQ_ENABLE
(byte) IRQ_LIGHTPEN
(byte) IRQ_RASTER
(byte*) IRQ_STATUS
(void()**) KERNEL_IRQ
(byte) KEY_0
(byte) KEY_1
(byte) KEY_2
(byte) KEY_3
(byte) KEY_4
(byte) KEY_5
(byte) KEY_6
(byte) KEY_7
(byte) KEY_8
(byte) KEY_9
(byte) KEY_A
(byte) KEY_ARROW_LEFT
(byte) KEY_ARROW_UP
(byte) KEY_ASTERISK
(byte) KEY_AT
(byte) KEY_B
(byte) KEY_C
(byte) KEY_COLON
(byte) KEY_COMMA
(byte) KEY_COMMODORE
(byte) KEY_CRSR_DOWN
(byte) KEY_CRSR_RIGHT
(byte) KEY_CTRL
(byte) KEY_D
(byte) KEY_DEL
(byte) KEY_DOT
(byte) KEY_E
(byte) KEY_EQUALS
(byte) KEY_F
(byte) KEY_F1
(byte) KEY_F3
(byte) KEY_F5
(byte) KEY_F7
(byte) KEY_G
(byte) KEY_H
(byte) KEY_HOME
(byte) KEY_I
(byte) KEY_J
(byte) KEY_K
(byte) KEY_L
(byte) KEY_LSHIFT
(byte) KEY_M
(byte) KEY_MINUS
(byte) KEY_MODIFIER_COMMODORE
(byte) KEY_MODIFIER_CTRL
(byte) KEY_MODIFIER_LSHIFT
(byte) KEY_MODIFIER_RSHIFT
(byte) KEY_MODIFIER_SHIFT
(byte) KEY_N
(byte) KEY_O
(byte) KEY_P
(byte) KEY_PLUS
(byte) KEY_POUND
(byte) KEY_Q
(byte) KEY_R
(byte) KEY_RETURN
(byte) KEY_RSHIFT
(byte) KEY_RUNSTOP
(byte) KEY_S
(byte) KEY_SEMICOLON
(byte) KEY_SLASH
(byte) KEY_SPACE
(byte) KEY_T
(byte) KEY_U
(byte) KEY_V
(byte) KEY_W
(byte) KEY_X
(byte) KEY_Y
(byte) KEY_Z
(byte*) LIGHTPEN_X
(byte*) LIGHTPEN_Y
(byte) LIGHT_BLUE
(byte) LIGHT_GREEN
(byte) LIGHT_GREY
(byte) ORANGE
(byte) PINK
(byte*) PROCPORT
(byte) PROCPORT_BASIC_KERNEL_IO
(byte*) PROCPORT_DDR
(byte) PROCPORT_DDR_MEMORY_MASK
(byte) PROCPORT_KERNEL_IO
(byte) PROCPORT_RAM_ALL
(byte) PROCPORT_RAM_CHARROM
(byte) PROCPORT_RAM_IO
(byte) PURPLE
(byte*) RASTER
(byte) RED
(byte*) SCREEN
(byte*) SPRITES_COLS
(byte*) SPRITES_ENABLE
(byte*) SPRITES_EXPAND_X
(byte*) SPRITES_EXPAND_Y
(byte*) SPRITES_MC
(byte*) SPRITES_MC1
(byte*) SPRITES_MC2
(byte*) SPRITES_PRIORITY
(byte*) SPRITES_XMSB
(byte*) SPRITES_XPOS
(byte*) SPRITES_YPOS
(word) SPRITE_PTRS
(byte) VIC_BMM
(byte*) VIC_CONTROL
(byte*) VIC_CONTROL2
(byte) VIC_CSEL
(byte) VIC_DEN
(byte) VIC_ECM
(byte) VIC_MCM
(byte*) VIC_MEMORY
(byte) VIC_RSEL
(byte) VIC_RST8
(byte) WHITE
(byte) YELLOW
(byte[]) keyboard_char_keycodes
(byte[8]) keyboard_events
(byte) keyboard_events_size
(byte()) keyboard_key_pressed((byte) keyboard_key_pressed::key)
(byte~) keyboard_key_pressed::$2 4.0
(byte) keyboard_key_pressed::colidx
(byte) keyboard_key_pressed::colidx#0 0.6666666666666666
(byte) keyboard_key_pressed::key
(byte) keyboard_key_pressed::key#4 2.0
(byte) keyboard_key_pressed::return
(byte) keyboard_key_pressed::return#0 67.66666666666667
(byte) keyboard_key_pressed::return#10 202.0
(byte) keyboard_key_pressed::return#2 202.0
(byte) keyboard_key_pressed::return#3 202.0
(byte) keyboard_key_pressed::return#4 202.0
(byte) keyboard_key_pressed::rowidx
(byte) keyboard_key_pressed::rowidx#0 4.0
(byte[8]) keyboard_matrix_col_bitmask
(byte()) keyboard_matrix_read((byte) keyboard_matrix_read::rowid)
(byte) keyboard_matrix_read::return
(byte) keyboard_matrix_read::return#0 1.3333333333333333
(byte) keyboard_matrix_read::return#2 4.0
(byte) keyboard_matrix_read::row_pressed_bits
(byte) keyboard_matrix_read::rowid
(byte) keyboard_matrix_read::rowid#0 4.0
(byte[8]) keyboard_matrix_row_bitmask
(byte) keyboard_modifiers
(byte[8]) keyboard_scan_values
(void()) main()
(void()) menu()
(byte~) menu::$0 202.0
(byte~) menu::$4 202.0
(byte~) menu::$7 202.0
(void()) pressed()
(byte~) pressed::$0 202.0

Initial phi equivalence classes
[ keyboard_key_pressed::key#4 ]
Added variable keyboard_key_pressed::return#2 to zero page equivalence class [ keyboard_key_pressed::return#2 ]
Added variable menu::$0 to zero page equivalence class [ menu::$0 ]
Added variable keyboard_key_pressed::return#3 to zero page equivalence class [ keyboard_key_pressed::return#3 ]
Added variable menu::$4 to zero page equivalence class [ menu::$4 ]
Added variable keyboard_key_pressed::return#4 to zero page equivalence class [ keyboard_key_pressed::return#4 ]
Added variable menu::$7 to zero page equivalence class [ menu::$7 ]
Added variable keyboard_key_pressed::colidx#0 to zero page equivalence class [ keyboard_key_pressed::colidx#0 ]
Added variable keyboard_key_pressed::rowidx#0 to zero page equivalence class [ keyboard_key_pressed::rowidx#0 ]
Added variable keyboard_matrix_read::rowid#0 to zero page equivalence class [ keyboard_matrix_read::rowid#0 ]
Added variable keyboard_matrix_read::return#2 to zero page equivalence class [ keyboard_matrix_read::return#2 ]
Added variable keyboard_key_pressed::$2 to zero page equivalence class [ keyboard_key_pressed::$2 ]
Added variable keyboard_key_pressed::return#0 to zero page equivalence class [ keyboard_key_pressed::return#0 ]
Added variable keyboard_matrix_read::return#0 to zero page equivalence class [ keyboard_matrix_read::return#0 ]
Added variable keyboard_key_pressed::return#10 to zero page equivalence class [ keyboard_key_pressed::return#10 ]
Added variable pressed::$0 to zero page equivalence class [ pressed::$0 ]
Complete equivalence classes
[ keyboard_key_pressed::key#4 ]
[ keyboard_key_pressed::return#2 ]
[ menu::$0 ]
[ keyboard_key_pressed::return#3 ]
[ menu::$4 ]
[ keyboard_key_pressed::return#4 ]
[ menu::$7 ]
[ keyboard_key_pressed::colidx#0 ]
[ keyboard_key_pressed::rowidx#0 ]
[ keyboard_matrix_read::rowid#0 ]
[ keyboard_matrix_read::return#2 ]
[ keyboard_key_pressed::$2 ]
[ keyboard_key_pressed::return#0 ]
[ keyboard_matrix_read::return#0 ]
[ keyboard_key_pressed::return#10 ]
[ pressed::$0 ]
Allocated zp ZP_BYTE:2 [ keyboard_key_pressed::key#4 ]
Allocated zp ZP_BYTE:3 [ keyboard_key_pressed::return#2 ]
Allocated zp ZP_BYTE:4 [ menu::$0 ]
Allocated zp ZP_BYTE:5 [ keyboard_key_pressed::return#3 ]
Allocated zp ZP_BYTE:6 [ menu::$4 ]
Allocated zp ZP_BYTE:7 [ keyboard_key_pressed::return#4 ]
Allocated zp ZP_BYTE:8 [ menu::$7 ]
Allocated zp ZP_BYTE:9 [ keyboard_key_pressed::colidx#0 ]
Allocated zp ZP_BYTE:10 [ keyboard_key_pressed::rowidx#0 ]
Allocated zp ZP_BYTE:11 [ keyboard_matrix_read::rowid#0 ]
Allocated zp ZP_BYTE:12 [ keyboard_matrix_read::return#2 ]
Allocated zp ZP_BYTE:13 [ keyboard_key_pressed::$2 ]
Allocated zp ZP_BYTE:14 [ keyboard_key_pressed::return#0 ]
Allocated zp ZP_BYTE:15 [ keyboard_matrix_read::return#0 ]
Allocated zp ZP_BYTE:16 [ keyboard_key_pressed::return#10 ]
Allocated zp ZP_BYTE:17 [ pressed::$0 ]

INITIAL ASM
//SEG0 File Comments
// Exploring keyboard glitch that finds "C" press when pressing space
// The glitch is caused by the "normal" C64 interrupt occuring just as the keyboard is read.
// Press "I" to disable interrupts (red border)
// Press "E" to enable interrupts (green border)
// Press "C" to enter pressed state (increaded bgcol) - and "SPACE" to leave presssed state again.
// Holding SPACE will sometimes trigger the pressed state when normal interrupts are enabled (green border)
// but never when they are disabled (red border)
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label BORDERCOL = $d020
  .label BGCOL = $d021
  // CIA#1 Port A: keyboard matrix columns and joystick #2
  .label CIA1_PORT_A = $dc00
  // CIA#1 Port B: keyboard matrix rows and joystick #1.
  .label CIA1_PORT_B = $dc01
  .const RED = 2
  .const GREEN = 5
  .const KEY_E = $e
  .const KEY_C = $14
  .const KEY_I = $21
  .const KEY_SPACE = $3c
  .label SCREEN = $400
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @14 [phi:@begin->@14]
b14_from_bbegin:
  jmp b14
//SEG5 @14
b14:
//SEG6 [2] call main 
  jsr main
//SEG7 [3] phi from @14 to @end [phi:@14->@end]
bend_from_b14:
  jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
  //SEG10 [4] *((const byte*) BORDERCOL#0) ← (const byte) GREEN#0 -- _deref_pbuc1=vbuc2 
    lda #GREEN
    sta BORDERCOL
  //SEG11 [5] phi from main main::@2 to main::@2 [phi:main/main::@2->main::@2]
  b2_from_main:
  b2_from_b2:
    jmp b2
  //SEG12 main::@2
  b2:
  //SEG13 [6] call menu 
  //SEG14 [7] phi from main::@2 to menu [phi:main::@2->menu]
  menu_from_b2:
    jsr menu
    jmp b2_from_b2
}
//SEG15 menu
menu: {
    .label _0 = 4
    .label _4 = 6
    .label _7 = 8
  //SEG16 [8] phi from menu menu::@6 to menu::@2 [phi:menu/menu::@6->menu::@2]
  b2_from_menu:
  b2_from_b6:
    jmp b2
  //SEG17 menu::@2
  b2:
  //SEG18 [9] call keyboard_key_pressed 
  //SEG19 [31] phi from menu::@2 to keyboard_key_pressed [phi:menu::@2->keyboard_key_pressed]
  keyboard_key_pressed_from_b2:
  //SEG20 [31] phi (byte) keyboard_key_pressed::key#4 = (const byte) KEY_C#0 [phi:menu::@2->keyboard_key_pressed#0] -- vbuz1=vbuc1 
    lda #KEY_C
    sta keyboard_key_pressed.key
    jsr keyboard_key_pressed
  //SEG21 [10] (byte) keyboard_key_pressed::return#2 ← (byte) keyboard_key_pressed::return#0 -- vbuz1=vbuz2 
    lda keyboard_key_pressed.return
    sta keyboard_key_pressed.return_2
    jmp b16
  //SEG22 menu::@16
  b16:
  //SEG23 [11] (byte~) menu::$0 ← (byte) keyboard_key_pressed::return#2 -- vbuz1=vbuz2 
    lda keyboard_key_pressed.return_2
    sta _0
  //SEG24 [12] if((byte~) menu::$0==(byte/signed byte/word/signed word/dword/signed dword) 0) goto menu::@4 -- vbuz1_eq_0_then_la1 
    lda _0
    cmp #0
    beq b4_from_b16
  //SEG25 [13] phi from menu::@16 to menu::@9 [phi:menu::@16->menu::@9]
  b9_from_b16:
    jmp b9
  //SEG26 menu::@9
  b9:
  //SEG27 [14] call pressed 
    jsr pressed
    jmp breturn
  //SEG28 menu::@return
  breturn:
  //SEG29 [15] return 
    rts
  //SEG30 [16] phi from menu::@16 to menu::@4 [phi:menu::@16->menu::@4]
  b4_from_b16:
    jmp b4
  //SEG31 menu::@4
  b4:
  //SEG32 [17] call keyboard_key_pressed 
  //SEG33 [31] phi from menu::@4 to keyboard_key_pressed [phi:menu::@4->keyboard_key_pressed]
  keyboard_key_pressed_from_b4:
  //SEG34 [31] phi (byte) keyboard_key_pressed::key#4 = (const byte) KEY_I#0 [phi:menu::@4->keyboard_key_pressed#0] -- vbuz1=vbuc1 
    lda #KEY_I
    sta keyboard_key_pressed.key
    jsr keyboard_key_pressed
  //SEG35 [18] (byte) keyboard_key_pressed::return#3 ← (byte) keyboard_key_pressed::return#0 -- vbuz1=vbuz2 
    lda keyboard_key_pressed.return
    sta keyboard_key_pressed.return_3
    jmp b17
  //SEG36 menu::@17
  b17:
  //SEG37 [19] (byte~) menu::$4 ← (byte) keyboard_key_pressed::return#3 -- vbuz1=vbuz2 
    lda keyboard_key_pressed.return_3
    sta _4
  //SEG38 [20] if((byte~) menu::$4==(byte/signed byte/word/signed word/dword/signed dword) 0) goto menu::@5 -- vbuz1_eq_0_then_la1 
    lda _4
    cmp #0
    beq b5_from_b17
    jmp b11
  //SEG39 menu::@11
  b11:
  //SEG40 [21] *((const byte*) BORDERCOL#0) ← (const byte) RED#0 -- _deref_pbuc1=vbuc2 
    lda #RED
    sta BORDERCOL
  //SEG41 asm { sei  }
    sei
    jmp breturn
  //SEG42 [23] phi from menu::@17 to menu::@5 [phi:menu::@17->menu::@5]
  b5_from_b17:
    jmp b5
  //SEG43 menu::@5
  b5:
  //SEG44 [24] call keyboard_key_pressed 
  //SEG45 [31] phi from menu::@5 to keyboard_key_pressed [phi:menu::@5->keyboard_key_pressed]
  keyboard_key_pressed_from_b5:
  //SEG46 [31] phi (byte) keyboard_key_pressed::key#4 = (const byte) KEY_E#0 [phi:menu::@5->keyboard_key_pressed#0] -- vbuz1=vbuc1 
    lda #KEY_E
    sta keyboard_key_pressed.key
    jsr keyboard_key_pressed
  //SEG47 [25] (byte) keyboard_key_pressed::return#4 ← (byte) keyboard_key_pressed::return#0 -- vbuz1=vbuz2 
    lda keyboard_key_pressed.return
    sta keyboard_key_pressed.return_4
    jmp b19
  //SEG48 menu::@19
  b19:
  //SEG49 [26] (byte~) menu::$7 ← (byte) keyboard_key_pressed::return#4 -- vbuz1=vbuz2 
    lda keyboard_key_pressed.return_4
    sta _7
  //SEG50 [27] if((byte~) menu::$7==(byte/signed byte/word/signed word/dword/signed dword) 0) goto menu::@6 -- vbuz1_eq_0_then_la1 
    lda _7
    cmp #0
    beq b6
    jmp b13
  //SEG51 menu::@13
  b13:
  //SEG52 [28] *((const byte*) BORDERCOL#0) ← (const byte) GREEN#0 -- _deref_pbuc1=vbuc2 
    lda #GREEN
    sta BORDERCOL
  //SEG53 asm { cli  }
    cli
    jmp breturn
  //SEG54 menu::@6
  b6:
  //SEG55 [30] *((const byte*) SCREEN#0) ← ++ *((const byte*) SCREEN#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc SCREEN
    jmp b2_from_b6
}
//SEG56 keyboard_key_pressed
// Determines whether a specific key is currently pressed by accessing the matrix directly
// The key is a keyboard code defined from the keyboard matrix by %00rrrccc, where rrr is the row ID (0-7) and ccc is the column ID (0-7)
// All keys exist as as KEY_XXX constants.
// Returns zero if the key is not pressed and a non-zero value if the key is currently pressed
// keyboard_key_pressed(byte zeropage(2) key)
keyboard_key_pressed: {
    .label _2 = $d
    .label colidx = 9
    .label rowidx = $a
    .label return = $e
    .label return_2 = 3
    .label return_3 = 5
    .label return_4 = 7
    .label key = 2
    .label return_10 = $10
  //SEG57 [32] (byte) keyboard_key_pressed::colidx#0 ← (byte) keyboard_key_pressed::key#4 & (byte/signed byte/word/signed word/dword/signed dword) 7 -- vbuz1=vbuz2_band_vbuc1 
    lda #7
    and key
    sta colidx
  //SEG58 [33] (byte) keyboard_key_pressed::rowidx#0 ← (byte) keyboard_key_pressed::key#4 >> (byte/signed byte/word/signed word/dword/signed dword) 3 -- vbuz1=vbuz2_ror_3 
    lda key
    lsr
    lsr
    lsr
    sta rowidx
  //SEG59 [34] (byte) keyboard_matrix_read::rowid#0 ← (byte) keyboard_key_pressed::rowidx#0 -- vbuz1=vbuz2 
    lda rowidx
    sta keyboard_matrix_read.rowid
  //SEG60 [35] call keyboard_matrix_read 
    jsr keyboard_matrix_read
  //SEG61 [36] (byte) keyboard_matrix_read::return#2 ← (byte) keyboard_matrix_read::return#0 -- vbuz1=vbuz2 
    lda keyboard_matrix_read.return
    sta keyboard_matrix_read.return_2
    jmp b2
  //SEG62 keyboard_key_pressed::@2
  b2:
  //SEG63 [37] (byte~) keyboard_key_pressed::$2 ← (byte) keyboard_matrix_read::return#2 -- vbuz1=vbuz2 
    lda keyboard_matrix_read.return_2
    sta _2
  //SEG64 [38] (byte) keyboard_key_pressed::return#0 ← (byte~) keyboard_key_pressed::$2 & *((const byte[8]) keyboard_matrix_col_bitmask#0 + (byte) keyboard_key_pressed::colidx#0) -- vbuz1=vbuz2_band_pbuc1_derefidx_vbuz3 
    lda _2
    ldy colidx
    and keyboard_matrix_col_bitmask,y
    sta return
    jmp breturn
  //SEG65 keyboard_key_pressed::@return
  breturn:
  //SEG66 [39] return 
    rts
}
//SEG67 keyboard_matrix_read
// Read a single row of the keyboard matrix
// The row ID (0-7) of the keyboard matrix row to read. See the C64 key matrix for row IDs.
// Returns the keys pressed on the row as bits according to the C64 key matrix.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte zeropage($b) rowid)
keyboard_matrix_read: {
    .label return = $f
    .label rowid = $b
    .label return_2 = $c
  //SEG68 [40] *((const byte*) CIA1_PORT_A#0) ← *((const byte[8]) keyboard_matrix_row_bitmask#0 + (byte) keyboard_matrix_read::rowid#0) -- _deref_pbuc1=pbuc2_derefidx_vbuz1 
    ldy rowid
    lda keyboard_matrix_row_bitmask,y
    sta CIA1_PORT_A
  //SEG69 [41] (byte) keyboard_matrix_read::return#0 ← ~ *((const byte*) CIA1_PORT_B#0) -- vbuz1=_bnot__deref_pbuc1 
    lda CIA1_PORT_B
    eor #$ff
    sta return
    jmp breturn
  //SEG70 keyboard_matrix_read::@return
  breturn:
  //SEG71 [42] return 
    rts
}
//SEG72 pressed
pressed: {
    .label _0 = $11
  //SEG73 [43] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
  //SEG74 [44] phi from pressed pressed::@10 to pressed::@2 [phi:pressed/pressed::@10->pressed::@2]
  b2_from_pressed:
  b2_from_b10:
    jmp b2
  //SEG75 pressed::@2
  b2:
  //SEG76 [45] call keyboard_key_pressed 
  //SEG77 [31] phi from pressed::@2 to keyboard_key_pressed [phi:pressed::@2->keyboard_key_pressed]
  keyboard_key_pressed_from_b2:
  //SEG78 [31] phi (byte) keyboard_key_pressed::key#4 = (const byte) KEY_SPACE#0 [phi:pressed::@2->keyboard_key_pressed#0] -- vbuz1=vbuc1 
    lda #KEY_SPACE
    sta keyboard_key_pressed.key
    jsr keyboard_key_pressed
  //SEG79 [46] (byte) keyboard_key_pressed::return#10 ← (byte) keyboard_key_pressed::return#0 -- vbuz1=vbuz2 
    lda keyboard_key_pressed.return
    sta keyboard_key_pressed.return_10
    jmp b10
  //SEG80 pressed::@10
  b10:
  //SEG81 [47] (byte~) pressed::$0 ← (byte) keyboard_key_pressed::return#10 -- vbuz1=vbuz2 
    lda keyboard_key_pressed.return_10
    sta _0
  //SEG82 [48] if((byte~) pressed::$0==(byte/signed byte/word/signed word/dword/signed dword) 0) goto pressed::@2 -- vbuz1_eq_0_then_la1 
    lda _0
    cmp #0
    beq b2_from_b10
    jmp breturn
  //SEG83 pressed::@return
  breturn:
  //SEG84 [49] return 
    rts
}
  // Keyboard row bitmask as expected by CIA#1 Port A when reading a specific keyboard matrix row (rows are numbered 0-7)
  keyboard_matrix_row_bitmask: .byte $fe, $fd, $fb, $f7, $ef, $df, $bf, $7f
  // Keyboard matrix column bitmasks for a specific keybooard matrix column when reading the keyboard. (columns are numbered 0-7)
  keyboard_matrix_col_bitmask: .byte 1, 2, 4, 8, $10, $20, $40, $80

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] *((const byte*) BORDERCOL#0) ← (const byte) GREEN#0 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [21] *((const byte*) BORDERCOL#0) ← (const byte) RED#0 [ ] ( main:2::menu:6 [ ] ) always clobbers reg byte a 
Statement [28] *((const byte*) BORDERCOL#0) ← (const byte) GREEN#0 [ ] ( main:2::menu:6 [ ] ) always clobbers reg byte a 
Statement [32] (byte) keyboard_key_pressed::colidx#0 ← (byte) keyboard_key_pressed::key#4 & (byte/signed byte/word/signed word/dword/signed dword) 7 [ keyboard_key_pressed::key#4 keyboard_key_pressed::colidx#0 ] ( main:2::menu:6::keyboard_key_pressed:9 [ keyboard_key_pressed::key#4 keyboard_key_pressed::colidx#0 ] main:2::menu:6::keyboard_key_pressed:17 [ keyboard_key_pressed::key#4 keyboard_key_pressed::colidx#0 ] main:2::menu:6::keyboard_key_pressed:24 [ keyboard_key_pressed::key#4 keyboard_key_pressed::colidx#0 ] main:2::menu:6::pressed:14::keyboard_key_pressed:45 [ keyboard_key_pressed::key#4 keyboard_key_pressed::colidx#0 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ keyboard_key_pressed::key#4 ]
Statement [33] (byte) keyboard_key_pressed::rowidx#0 ← (byte) keyboard_key_pressed::key#4 >> (byte/signed byte/word/signed word/dword/signed dword) 3 [ keyboard_key_pressed::colidx#0 keyboard_key_pressed::rowidx#0 ] ( main:2::menu:6::keyboard_key_pressed:9 [ keyboard_key_pressed::colidx#0 keyboard_key_pressed::rowidx#0 ] main:2::menu:6::keyboard_key_pressed:17 [ keyboard_key_pressed::colidx#0 keyboard_key_pressed::rowidx#0 ] main:2::menu:6::keyboard_key_pressed:24 [ keyboard_key_pressed::colidx#0 keyboard_key_pressed::rowidx#0 ] main:2::menu:6::pressed:14::keyboard_key_pressed:45 [ keyboard_key_pressed::colidx#0 keyboard_key_pressed::rowidx#0 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:9 [ keyboard_key_pressed::colidx#0 ]
Statement [38] (byte) keyboard_key_pressed::return#0 ← (byte~) keyboard_key_pressed::$2 & *((const byte[8]) keyboard_matrix_col_bitmask#0 + (byte) keyboard_key_pressed::colidx#0) [ keyboard_key_pressed::return#0 ] ( main:2::menu:6::keyboard_key_pressed:9 [ keyboard_key_pressed::return#0 ] main:2::menu:6::keyboard_key_pressed:17 [ keyboard_key_pressed::return#0 ] main:2::menu:6::keyboard_key_pressed:24 [ keyboard_key_pressed::return#0 ] main:2::menu:6::pressed:14::keyboard_key_pressed:45 [ keyboard_key_pressed::return#0 ] ) always clobbers reg byte a 
Statement [40] *((const byte*) CIA1_PORT_A#0) ← *((const byte[8]) keyboard_matrix_row_bitmask#0 + (byte) keyboard_matrix_read::rowid#0) [ ] ( main:2::menu:6::keyboard_key_pressed:9::keyboard_matrix_read:35 [ keyboard_key_pressed::colidx#0 ] main:2::menu:6::keyboard_key_pressed:17::keyboard_matrix_read:35 [ keyboard_key_pressed::colidx#0 ] main:2::menu:6::keyboard_key_pressed:24::keyboard_matrix_read:35 [ keyboard_key_pressed::colidx#0 ] main:2::menu:6::pressed:14::keyboard_key_pressed:45::keyboard_matrix_read:35 [ keyboard_key_pressed::colidx#0 ] ) always clobbers reg byte a 
Statement [41] (byte) keyboard_matrix_read::return#0 ← ~ *((const byte*) CIA1_PORT_B#0) [ keyboard_matrix_read::return#0 ] ( main:2::menu:6::keyboard_key_pressed:9::keyboard_matrix_read:35 [ keyboard_key_pressed::colidx#0 keyboard_matrix_read::return#0 ] main:2::menu:6::keyboard_key_pressed:17::keyboard_matrix_read:35 [ keyboard_key_pressed::colidx#0 keyboard_matrix_read::return#0 ] main:2::menu:6::keyboard_key_pressed:24::keyboard_matrix_read:35 [ keyboard_key_pressed::colidx#0 keyboard_matrix_read::return#0 ] main:2::menu:6::pressed:14::keyboard_key_pressed:45::keyboard_matrix_read:35 [ keyboard_key_pressed::colidx#0 keyboard_matrix_read::return#0 ] ) always clobbers reg byte a 
Statement [4] *((const byte*) BORDERCOL#0) ← (const byte) GREEN#0 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [21] *((const byte*) BORDERCOL#0) ← (const byte) RED#0 [ ] ( main:2::menu:6 [ ] ) always clobbers reg byte a 
Statement [28] *((const byte*) BORDERCOL#0) ← (const byte) GREEN#0 [ ] ( main:2::menu:6 [ ] ) always clobbers reg byte a 
Statement [32] (byte) keyboard_key_pressed::colidx#0 ← (byte) keyboard_key_pressed::key#4 & (byte/signed byte/word/signed word/dword/signed dword) 7 [ keyboard_key_pressed::key#4 keyboard_key_pressed::colidx#0 ] ( main:2::menu:6::keyboard_key_pressed:9 [ keyboard_key_pressed::key#4 keyboard_key_pressed::colidx#0 ] main:2::menu:6::keyboard_key_pressed:17 [ keyboard_key_pressed::key#4 keyboard_key_pressed::colidx#0 ] main:2::menu:6::keyboard_key_pressed:24 [ keyboard_key_pressed::key#4 keyboard_key_pressed::colidx#0 ] main:2::menu:6::pressed:14::keyboard_key_pressed:45 [ keyboard_key_pressed::key#4 keyboard_key_pressed::colidx#0 ] ) always clobbers reg byte a 
Statement [33] (byte) keyboard_key_pressed::rowidx#0 ← (byte) keyboard_key_pressed::key#4 >> (byte/signed byte/word/signed word/dword/signed dword) 3 [ keyboard_key_pressed::colidx#0 keyboard_key_pressed::rowidx#0 ] ( main:2::menu:6::keyboard_key_pressed:9 [ keyboard_key_pressed::colidx#0 keyboard_key_pressed::rowidx#0 ] main:2::menu:6::keyboard_key_pressed:17 [ keyboard_key_pressed::colidx#0 keyboard_key_pressed::rowidx#0 ] main:2::menu:6::keyboard_key_pressed:24 [ keyboard_key_pressed::colidx#0 keyboard_key_pressed::rowidx#0 ] main:2::menu:6::pressed:14::keyboard_key_pressed:45 [ keyboard_key_pressed::colidx#0 keyboard_key_pressed::rowidx#0 ] ) always clobbers reg byte a 
Statement [38] (byte) keyboard_key_pressed::return#0 ← (byte~) keyboard_key_pressed::$2 & *((const byte[8]) keyboard_matrix_col_bitmask#0 + (byte) keyboard_key_pressed::colidx#0) [ keyboard_key_pressed::return#0 ] ( main:2::menu:6::keyboard_key_pressed:9 [ keyboard_key_pressed::return#0 ] main:2::menu:6::keyboard_key_pressed:17 [ keyboard_key_pressed::return#0 ] main:2::menu:6::keyboard_key_pressed:24 [ keyboard_key_pressed::return#0 ] main:2::menu:6::pressed:14::keyboard_key_pressed:45 [ keyboard_key_pressed::return#0 ] ) always clobbers reg byte a 
Statement [40] *((const byte*) CIA1_PORT_A#0) ← *((const byte[8]) keyboard_matrix_row_bitmask#0 + (byte) keyboard_matrix_read::rowid#0) [ ] ( main:2::menu:6::keyboard_key_pressed:9::keyboard_matrix_read:35 [ keyboard_key_pressed::colidx#0 ] main:2::menu:6::keyboard_key_pressed:17::keyboard_matrix_read:35 [ keyboard_key_pressed::colidx#0 ] main:2::menu:6::keyboard_key_pressed:24::keyboard_matrix_read:35 [ keyboard_key_pressed::colidx#0 ] main:2::menu:6::pressed:14::keyboard_key_pressed:45::keyboard_matrix_read:35 [ keyboard_key_pressed::colidx#0 ] ) always clobbers reg byte a 
Statement [41] (byte) keyboard_matrix_read::return#0 ← ~ *((const byte*) CIA1_PORT_B#0) [ keyboard_matrix_read::return#0 ] ( main:2::menu:6::keyboard_key_pressed:9::keyboard_matrix_read:35 [ keyboard_key_pressed::colidx#0 keyboard_matrix_read::return#0 ] main:2::menu:6::keyboard_key_pressed:17::keyboard_matrix_read:35 [ keyboard_key_pressed::colidx#0 keyboard_matrix_read::return#0 ] main:2::menu:6::keyboard_key_pressed:24::keyboard_matrix_read:35 [ keyboard_key_pressed::colidx#0 keyboard_matrix_read::return#0 ] main:2::menu:6::pressed:14::keyboard_key_pressed:45::keyboard_matrix_read:35 [ keyboard_key_pressed::colidx#0 keyboard_matrix_read::return#0 ] ) always clobbers reg byte a 
Potential registers zp ZP_BYTE:2 [ keyboard_key_pressed::key#4 ] : zp ZP_BYTE:2 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:3 [ keyboard_key_pressed::return#2 ] : zp ZP_BYTE:3 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:4 [ menu::$0 ] : zp ZP_BYTE:4 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:5 [ keyboard_key_pressed::return#3 ] : zp ZP_BYTE:5 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:6 [ menu::$4 ] : zp ZP_BYTE:6 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:7 [ keyboard_key_pressed::return#4 ] : zp ZP_BYTE:7 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:8 [ menu::$7 ] : zp ZP_BYTE:8 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:9 [ keyboard_key_pressed::colidx#0 ] : zp ZP_BYTE:9 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:10 [ keyboard_key_pressed::rowidx#0 ] : zp ZP_BYTE:10 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:11 [ keyboard_matrix_read::rowid#0 ] : zp ZP_BYTE:11 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:12 [ keyboard_matrix_read::return#2 ] : zp ZP_BYTE:12 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:13 [ keyboard_key_pressed::$2 ] : zp ZP_BYTE:13 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:14 [ keyboard_key_pressed::return#0 ] : zp ZP_BYTE:14 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:15 [ keyboard_matrix_read::return#0 ] : zp ZP_BYTE:15 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:16 [ keyboard_key_pressed::return#10 ] : zp ZP_BYTE:16 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:17 [ pressed::$0 ] : zp ZP_BYTE:17 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [keyboard_key_pressed] 202: zp ZP_BYTE:3 [ keyboard_key_pressed::return#2 ] 202: zp ZP_BYTE:5 [ keyboard_key_pressed::return#3 ] 202: zp ZP_BYTE:7 [ keyboard_key_pressed::return#4 ] 202: zp ZP_BYTE:16 [ keyboard_key_pressed::return#10 ] 67.67: zp ZP_BYTE:14 [ keyboard_key_pressed::return#0 ] 4: zp ZP_BYTE:10 [ keyboard_key_pressed::rowidx#0 ] 4: zp ZP_BYTE:13 [ keyboard_key_pressed::$2 ] 2: zp ZP_BYTE:2 [ keyboard_key_pressed::key#4 ] 0.67: zp ZP_BYTE:9 [ keyboard_key_pressed::colidx#0 ] 
Uplift Scope [menu] 202: zp ZP_BYTE:4 [ menu::$0 ] 202: zp ZP_BYTE:6 [ menu::$4 ] 202: zp ZP_BYTE:8 [ menu::$7 ] 
Uplift Scope [pressed] 202: zp ZP_BYTE:17 [ pressed::$0 ] 
Uplift Scope [keyboard_matrix_read] 4: zp ZP_BYTE:11 [ keyboard_matrix_read::rowid#0 ] 4: zp ZP_BYTE:12 [ keyboard_matrix_read::return#2 ] 1.33: zp ZP_BYTE:15 [ keyboard_matrix_read::return#0 ] 
Uplift Scope [main] 
Uplift Scope [] 

Uplifting [keyboard_key_pressed] best 9851 combination reg byte a [ keyboard_key_pressed::return#2 ] reg byte a [ keyboard_key_pressed::return#3 ] reg byte a [ keyboard_key_pressed::return#4 ] reg byte a [ keyboard_key_pressed::return#10 ] zp ZP_BYTE:14 [ keyboard_key_pressed::return#0 ] zp ZP_BYTE:10 [ keyboard_key_pressed::rowidx#0 ] zp ZP_BYTE:13 [ keyboard_key_pressed::$2 ] zp ZP_BYTE:2 [ keyboard_key_pressed::key#4 ] zp ZP_BYTE:9 [ keyboard_key_pressed::colidx#0 ] 
Limited combination testing to 100 combinations of 147456 possible.
Uplifting [menu] best 8051 combination reg byte a [ menu::$0 ] reg byte a [ menu::$4 ] reg byte a [ menu::$7 ] 
Uplifting [pressed] best 7451 combination reg byte a [ pressed::$0 ] 
Uplifting [keyboard_matrix_read] best 7433 combination reg byte x [ keyboard_matrix_read::rowid#0 ] reg byte a [ keyboard_matrix_read::return#2 ] reg byte a [ keyboard_matrix_read::return#0 ] 
Uplifting [main] best 7433 combination 
Uplifting [] best 7433 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:14 [ keyboard_key_pressed::return#0 ]
Uplifting [keyboard_key_pressed] best 6230 combination reg byte a [ keyboard_key_pressed::return#0 ] 
Attempting to uplift remaining variables inzp ZP_BYTE:10 [ keyboard_key_pressed::rowidx#0 ]
Uplifting [keyboard_key_pressed] best 6226 combination reg byte a [ keyboard_key_pressed::rowidx#0 ] 
Attempting to uplift remaining variables inzp ZP_BYTE:13 [ keyboard_key_pressed::$2 ]
Uplifting [keyboard_key_pressed] best 6220 combination reg byte a [ keyboard_key_pressed::$2 ] 
Attempting to uplift remaining variables inzp ZP_BYTE:2 [ keyboard_key_pressed::key#4 ]
Uplifting [keyboard_key_pressed] best 6206 combination reg byte x [ keyboard_key_pressed::key#4 ] 
Attempting to uplift remaining variables inzp ZP_BYTE:9 [ keyboard_key_pressed::colidx#0 ]
Uplifting [keyboard_key_pressed] best 6202 combination reg byte y [ keyboard_key_pressed::colidx#0 ] 

ASSEMBLER BEFORE OPTIMIZATION
//SEG0 File Comments
// Exploring keyboard glitch that finds "C" press when pressing space
// The glitch is caused by the "normal" C64 interrupt occuring just as the keyboard is read.
// Press "I" to disable interrupts (red border)
// Press "E" to enable interrupts (green border)
// Press "C" to enter pressed state (increaded bgcol) - and "SPACE" to leave presssed state again.
// Holding SPACE will sometimes trigger the pressed state when normal interrupts are enabled (green border)
// but never when they are disabled (red border)
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label BORDERCOL = $d020
  .label BGCOL = $d021
  // CIA#1 Port A: keyboard matrix columns and joystick #2
  .label CIA1_PORT_A = $dc00
  // CIA#1 Port B: keyboard matrix rows and joystick #1.
  .label CIA1_PORT_B = $dc01
  .const RED = 2
  .const GREEN = 5
  .const KEY_E = $e
  .const KEY_C = $14
  .const KEY_I = $21
  .const KEY_SPACE = $3c
  .label SCREEN = $400
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @14 [phi:@begin->@14]
b14_from_bbegin:
  jmp b14
//SEG5 @14
b14:
//SEG6 [2] call main 
  jsr main
//SEG7 [3] phi from @14 to @end [phi:@14->@end]
bend_from_b14:
  jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
  //SEG10 [4] *((const byte*) BORDERCOL#0) ← (const byte) GREEN#0 -- _deref_pbuc1=vbuc2 
    lda #GREEN
    sta BORDERCOL
  //SEG11 [5] phi from main main::@2 to main::@2 [phi:main/main::@2->main::@2]
  b2_from_main:
  b2_from_b2:
    jmp b2
  //SEG12 main::@2
  b2:
  //SEG13 [6] call menu 
  //SEG14 [7] phi from main::@2 to menu [phi:main::@2->menu]
  menu_from_b2:
    jsr menu
    jmp b2_from_b2
}
//SEG15 menu
menu: {
  //SEG16 [8] phi from menu menu::@6 to menu::@2 [phi:menu/menu::@6->menu::@2]
  b2_from_menu:
  b2_from_b6:
    jmp b2
  //SEG17 menu::@2
  b2:
  //SEG18 [9] call keyboard_key_pressed 
  //SEG19 [31] phi from menu::@2 to keyboard_key_pressed [phi:menu::@2->keyboard_key_pressed]
  keyboard_key_pressed_from_b2:
  //SEG20 [31] phi (byte) keyboard_key_pressed::key#4 = (const byte) KEY_C#0 [phi:menu::@2->keyboard_key_pressed#0] -- vbuxx=vbuc1 
    ldx #KEY_C
    jsr keyboard_key_pressed
  //SEG21 [10] (byte) keyboard_key_pressed::return#2 ← (byte) keyboard_key_pressed::return#0
    jmp b16
  //SEG22 menu::@16
  b16:
  //SEG23 [11] (byte~) menu::$0 ← (byte) keyboard_key_pressed::return#2
  //SEG24 [12] if((byte~) menu::$0==(byte/signed byte/word/signed word/dword/signed dword) 0) goto menu::@4 -- vbuaa_eq_0_then_la1 
    cmp #0
    beq b4_from_b16
  //SEG25 [13] phi from menu::@16 to menu::@9 [phi:menu::@16->menu::@9]
  b9_from_b16:
    jmp b9
  //SEG26 menu::@9
  b9:
  //SEG27 [14] call pressed 
    jsr pressed
    jmp breturn
  //SEG28 menu::@return
  breturn:
  //SEG29 [15] return 
    rts
  //SEG30 [16] phi from menu::@16 to menu::@4 [phi:menu::@16->menu::@4]
  b4_from_b16:
    jmp b4
  //SEG31 menu::@4
  b4:
  //SEG32 [17] call keyboard_key_pressed 
  //SEG33 [31] phi from menu::@4 to keyboard_key_pressed [phi:menu::@4->keyboard_key_pressed]
  keyboard_key_pressed_from_b4:
  //SEG34 [31] phi (byte) keyboard_key_pressed::key#4 = (const byte) KEY_I#0 [phi:menu::@4->keyboard_key_pressed#0] -- vbuxx=vbuc1 
    ldx #KEY_I
    jsr keyboard_key_pressed
  //SEG35 [18] (byte) keyboard_key_pressed::return#3 ← (byte) keyboard_key_pressed::return#0
    jmp b17
  //SEG36 menu::@17
  b17:
  //SEG37 [19] (byte~) menu::$4 ← (byte) keyboard_key_pressed::return#3
  //SEG38 [20] if((byte~) menu::$4==(byte/signed byte/word/signed word/dword/signed dword) 0) goto menu::@5 -- vbuaa_eq_0_then_la1 
    cmp #0
    beq b5_from_b17
    jmp b11
  //SEG39 menu::@11
  b11:
  //SEG40 [21] *((const byte*) BORDERCOL#0) ← (const byte) RED#0 -- _deref_pbuc1=vbuc2 
    lda #RED
    sta BORDERCOL
  //SEG41 asm { sei  }
    sei
    jmp breturn
  //SEG42 [23] phi from menu::@17 to menu::@5 [phi:menu::@17->menu::@5]
  b5_from_b17:
    jmp b5
  //SEG43 menu::@5
  b5:
  //SEG44 [24] call keyboard_key_pressed 
  //SEG45 [31] phi from menu::@5 to keyboard_key_pressed [phi:menu::@5->keyboard_key_pressed]
  keyboard_key_pressed_from_b5:
  //SEG46 [31] phi (byte) keyboard_key_pressed::key#4 = (const byte) KEY_E#0 [phi:menu::@5->keyboard_key_pressed#0] -- vbuxx=vbuc1 
    ldx #KEY_E
    jsr keyboard_key_pressed
  //SEG47 [25] (byte) keyboard_key_pressed::return#4 ← (byte) keyboard_key_pressed::return#0
    jmp b19
  //SEG48 menu::@19
  b19:
  //SEG49 [26] (byte~) menu::$7 ← (byte) keyboard_key_pressed::return#4
  //SEG50 [27] if((byte~) menu::$7==(byte/signed byte/word/signed word/dword/signed dword) 0) goto menu::@6 -- vbuaa_eq_0_then_la1 
    cmp #0
    beq b6
    jmp b13
  //SEG51 menu::@13
  b13:
  //SEG52 [28] *((const byte*) BORDERCOL#0) ← (const byte) GREEN#0 -- _deref_pbuc1=vbuc2 
    lda #GREEN
    sta BORDERCOL
  //SEG53 asm { cli  }
    cli
    jmp breturn
  //SEG54 menu::@6
  b6:
  //SEG55 [30] *((const byte*) SCREEN#0) ← ++ *((const byte*) SCREEN#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc SCREEN
    jmp b2_from_b6
}
//SEG56 keyboard_key_pressed
// Determines whether a specific key is currently pressed by accessing the matrix directly
// The key is a keyboard code defined from the keyboard matrix by %00rrrccc, where rrr is the row ID (0-7) and ccc is the column ID (0-7)
// All keys exist as as KEY_XXX constants.
// Returns zero if the key is not pressed and a non-zero value if the key is currently pressed
// keyboard_key_pressed(byte register(X) key)
keyboard_key_pressed: {
  //SEG57 [32] (byte) keyboard_key_pressed::colidx#0 ← (byte) keyboard_key_pressed::key#4 & (byte/signed byte/word/signed word/dword/signed dword) 7 -- vbuyy=vbuxx_band_vbuc1 
    txa
    and #7
    tay
  //SEG58 [33] (byte) keyboard_key_pressed::rowidx#0 ← (byte) keyboard_key_pressed::key#4 >> (byte/signed byte/word/signed word/dword/signed dword) 3 -- vbuaa=vbuxx_ror_3 
    txa
    lsr
    lsr
    lsr
  //SEG59 [34] (byte) keyboard_matrix_read::rowid#0 ← (byte) keyboard_key_pressed::rowidx#0 -- vbuxx=vbuaa 
    tax
  //SEG60 [35] call keyboard_matrix_read 
    jsr keyboard_matrix_read
  //SEG61 [36] (byte) keyboard_matrix_read::return#2 ← (byte) keyboard_matrix_read::return#0
    jmp b2
  //SEG62 keyboard_key_pressed::@2
  b2:
  //SEG63 [37] (byte~) keyboard_key_pressed::$2 ← (byte) keyboard_matrix_read::return#2
  //SEG64 [38] (byte) keyboard_key_pressed::return#0 ← (byte~) keyboard_key_pressed::$2 & *((const byte[8]) keyboard_matrix_col_bitmask#0 + (byte) keyboard_key_pressed::colidx#0) -- vbuaa=vbuaa_band_pbuc1_derefidx_vbuyy 
    and keyboard_matrix_col_bitmask,y
    jmp breturn
  //SEG65 keyboard_key_pressed::@return
  breturn:
  //SEG66 [39] return 
    rts
}
//SEG67 keyboard_matrix_read
// Read a single row of the keyboard matrix
// The row ID (0-7) of the keyboard matrix row to read. See the C64 key matrix for row IDs.
// Returns the keys pressed on the row as bits according to the C64 key matrix.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte register(X) rowid)
keyboard_matrix_read: {
  //SEG68 [40] *((const byte*) CIA1_PORT_A#0) ← *((const byte[8]) keyboard_matrix_row_bitmask#0 + (byte) keyboard_matrix_read::rowid#0) -- _deref_pbuc1=pbuc2_derefidx_vbuxx 
    lda keyboard_matrix_row_bitmask,x
    sta CIA1_PORT_A
  //SEG69 [41] (byte) keyboard_matrix_read::return#0 ← ~ *((const byte*) CIA1_PORT_B#0) -- vbuaa=_bnot__deref_pbuc1 
    lda CIA1_PORT_B
    eor #$ff
    jmp breturn
  //SEG70 keyboard_matrix_read::@return
  breturn:
  //SEG71 [42] return 
    rts
}
//SEG72 pressed
pressed: {
  //SEG73 [43] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
  //SEG74 [44] phi from pressed pressed::@10 to pressed::@2 [phi:pressed/pressed::@10->pressed::@2]
  b2_from_pressed:
  b2_from_b10:
    jmp b2
  //SEG75 pressed::@2
  b2:
  //SEG76 [45] call keyboard_key_pressed 
  //SEG77 [31] phi from pressed::@2 to keyboard_key_pressed [phi:pressed::@2->keyboard_key_pressed]
  keyboard_key_pressed_from_b2:
  //SEG78 [31] phi (byte) keyboard_key_pressed::key#4 = (const byte) KEY_SPACE#0 [phi:pressed::@2->keyboard_key_pressed#0] -- vbuxx=vbuc1 
    ldx #KEY_SPACE
    jsr keyboard_key_pressed
  //SEG79 [46] (byte) keyboard_key_pressed::return#10 ← (byte) keyboard_key_pressed::return#0
    jmp b10
  //SEG80 pressed::@10
  b10:
  //SEG81 [47] (byte~) pressed::$0 ← (byte) keyboard_key_pressed::return#10
  //SEG82 [48] if((byte~) pressed::$0==(byte/signed byte/word/signed word/dword/signed dword) 0) goto pressed::@2 -- vbuaa_eq_0_then_la1 
    cmp #0
    beq b2_from_b10
    jmp breturn
  //SEG83 pressed::@return
  breturn:
  //SEG84 [49] return 
    rts
}
  // Keyboard row bitmask as expected by CIA#1 Port A when reading a specific keyboard matrix row (rows are numbered 0-7)
  keyboard_matrix_row_bitmask: .byte $fe, $fd, $fb, $f7, $ef, $df, $bf, $7f
  // Keyboard matrix column bitmasks for a specific keybooard matrix column when reading the keyboard. (columns are numbered 0-7)
  keyboard_matrix_col_bitmask: .byte 1, 2, 4, 8, $10, $20, $40, $80

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b14
Removing instruction jmp bend
Removing instruction jmp b2
Removing instruction jmp b2
Removing instruction jmp b16
Removing instruction jmp b9
Removing instruction jmp breturn
Removing instruction jmp b4
Removing instruction jmp b17
Removing instruction jmp b11
Removing instruction jmp b5
Removing instruction jmp b19
Removing instruction jmp b13
Removing instruction jmp b2
Removing instruction jmp breturn
Removing instruction jmp breturn
Removing instruction jmp b2
Removing instruction jmp b10
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label b2_from_b2 with b2
Replacing label b4_from_b16 with b4
Replacing label b5_from_b17 with b5
Replacing label b2_from_b6 with b2
Replacing label b2_from_b10 with b2
Removing instruction b14_from_bbegin:
Removing instruction b14:
Removing instruction bend_from_b14:
Removing instruction b2_from_main:
Removing instruction b2_from_b2:
Removing instruction menu_from_b2:
Removing instruction b2_from_menu:
Removing instruction b2_from_b6:
Removing instruction keyboard_key_pressed_from_b2:
Removing instruction b9_from_b16:
Removing instruction b4_from_b16:
Removing instruction keyboard_key_pressed_from_b4:
Removing instruction b5_from_b17:
Removing instruction keyboard_key_pressed_from_b5:
Removing instruction b2_from_pressed:
Removing instruction b2_from_b10:
Removing instruction keyboard_key_pressed_from_b2:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b16:
Removing instruction b9:
Removing instruction b17:
Removing instruction b11:
Removing instruction b19:
Removing instruction b13:
Removing instruction b2:
Removing instruction breturn:
Removing instruction breturn:
Removing instruction b10:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @14
(label) @begin
(label) @end
(byte*) BGCOL
(const byte*) BGCOL#0 BGCOL = ((byte*))(word/dword/signed dword) 53281
(byte*) BGCOL1
(byte*) BGCOL2
(byte*) BGCOL3
(byte*) BGCOL4
(byte) BLACK
(byte) BLUE
(byte*) BORDERCOL
(const byte*) BORDERCOL#0 BORDERCOL = ((byte*))(word/dword/signed dword) 53280
(byte) BROWN
(byte*) CHARGEN
(byte*) CIA1_INTERRUPT
(byte*) CIA1_PORT_A
(const byte*) CIA1_PORT_A#0 CIA1_PORT_A = ((byte*))(word/dword/signed dword) 56320
(byte*) CIA1_PORT_A_DDR
(byte*) CIA1_PORT_B
(const byte*) CIA1_PORT_B#0 CIA1_PORT_B = ((byte*))(word/dword/signed dword) 56321
(byte*) CIA1_PORT_B_DDR
(byte*) CIA2_INTERRUPT
(byte*) CIA2_PORT_A
(byte*) CIA2_PORT_A_DDR
(byte*) CIA2_PORT_B
(byte*) CIA2_PORT_B_DDR
(byte) CIA_INTERRUPT_CLEAR
(byte*) COLS
(byte) CYAN
(byte*) D011
(byte*) D016
(byte*) D018
(byte) DARK_GREY
(byte) GREEN
(const byte) GREEN#0 GREEN = (byte/signed byte/word/signed word/dword/signed dword) 5
(byte) GREY
(void()**) HARDWARE_IRQ
(byte) IRQ_COLLISION_BG
(byte) IRQ_COLLISION_SPRITE
(byte*) IRQ_ENABLE
(byte) IRQ_LIGHTPEN
(byte) IRQ_RASTER
(byte*) IRQ_STATUS
(void()**) KERNEL_IRQ
(byte) KEY_0
(byte) KEY_1
(byte) KEY_2
(byte) KEY_3
(byte) KEY_4
(byte) KEY_5
(byte) KEY_6
(byte) KEY_7
(byte) KEY_8
(byte) KEY_9
(byte) KEY_A
(byte) KEY_ARROW_LEFT
(byte) KEY_ARROW_UP
(byte) KEY_ASTERISK
(byte) KEY_AT
(byte) KEY_B
(byte) KEY_C
(const byte) KEY_C#0 KEY_C = (byte/signed byte/word/signed word/dword/signed dword) 20
(byte) KEY_COLON
(byte) KEY_COMMA
(byte) KEY_COMMODORE
(byte) KEY_CRSR_DOWN
(byte) KEY_CRSR_RIGHT
(byte) KEY_CTRL
(byte) KEY_D
(byte) KEY_DEL
(byte) KEY_DOT
(byte) KEY_E
(const byte) KEY_E#0 KEY_E = (byte/signed byte/word/signed word/dword/signed dword) 14
(byte) KEY_EQUALS
(byte) KEY_F
(byte) KEY_F1
(byte) KEY_F3
(byte) KEY_F5
(byte) KEY_F7
(byte) KEY_G
(byte) KEY_H
(byte) KEY_HOME
(byte) KEY_I
(const byte) KEY_I#0 KEY_I = (byte/signed byte/word/signed word/dword/signed dword) 33
(byte) KEY_J
(byte) KEY_K
(byte) KEY_L
(byte) KEY_LSHIFT
(byte) KEY_M
(byte) KEY_MINUS
(byte) KEY_MODIFIER_COMMODORE
(byte) KEY_MODIFIER_CTRL
(byte) KEY_MODIFIER_LSHIFT
(byte) KEY_MODIFIER_RSHIFT
(byte) KEY_MODIFIER_SHIFT
(byte) KEY_N
(byte) KEY_O
(byte) KEY_P
(byte) KEY_PLUS
(byte) KEY_POUND
(byte) KEY_Q
(byte) KEY_R
(byte) KEY_RETURN
(byte) KEY_RSHIFT
(byte) KEY_RUNSTOP
(byte) KEY_S
(byte) KEY_SEMICOLON
(byte) KEY_SLASH
(byte) KEY_SPACE
(const byte) KEY_SPACE#0 KEY_SPACE = (byte/signed byte/word/signed word/dword/signed dword) 60
(byte) KEY_T
(byte) KEY_U
(byte) KEY_V
(byte) KEY_W
(byte) KEY_X
(byte) KEY_Y
(byte) KEY_Z
(byte*) LIGHTPEN_X
(byte*) LIGHTPEN_Y
(byte) LIGHT_BLUE
(byte) LIGHT_GREEN
(byte) LIGHT_GREY
(byte) ORANGE
(byte) PINK
(byte*) PROCPORT
(byte) PROCPORT_BASIC_KERNEL_IO
(byte*) PROCPORT_DDR
(byte) PROCPORT_DDR_MEMORY_MASK
(byte) PROCPORT_KERNEL_IO
(byte) PROCPORT_RAM_ALL
(byte) PROCPORT_RAM_CHARROM
(byte) PROCPORT_RAM_IO
(byte) PURPLE
(byte*) RASTER
(byte) RED
(const byte) RED#0 RED = (byte/signed byte/word/signed word/dword/signed dword) 2
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) 1024
(byte*) SPRITES_COLS
(byte*) SPRITES_ENABLE
(byte*) SPRITES_EXPAND_X
(byte*) SPRITES_EXPAND_Y
(byte*) SPRITES_MC
(byte*) SPRITES_MC1
(byte*) SPRITES_MC2
(byte*) SPRITES_PRIORITY
(byte*) SPRITES_XMSB
(byte*) SPRITES_XPOS
(byte*) SPRITES_YPOS
(word) SPRITE_PTRS
(byte) VIC_BMM
(byte*) VIC_CONTROL
(byte*) VIC_CONTROL2
(byte) VIC_CSEL
(byte) VIC_DEN
(byte) VIC_ECM
(byte) VIC_MCM
(byte*) VIC_MEMORY
(byte) VIC_RSEL
(byte) VIC_RST8
(byte) WHITE
(byte) YELLOW
(byte[]) keyboard_char_keycodes
(byte[8]) keyboard_events
(byte) keyboard_events_size
(byte()) keyboard_key_pressed((byte) keyboard_key_pressed::key)
(byte~) keyboard_key_pressed::$2 reg byte a 4.0
(label) keyboard_key_pressed::@2
(label) keyboard_key_pressed::@return
(byte) keyboard_key_pressed::colidx
(byte) keyboard_key_pressed::colidx#0 reg byte y 0.6666666666666666
(byte) keyboard_key_pressed::key
(byte) keyboard_key_pressed::key#4 reg byte x 2.0
(byte) keyboard_key_pressed::return
(byte) keyboard_key_pressed::return#0 reg byte a 67.66666666666667
(byte) keyboard_key_pressed::return#10 reg byte a 202.0
(byte) keyboard_key_pressed::return#2 reg byte a 202.0
(byte) keyboard_key_pressed::return#3 reg byte a 202.0
(byte) keyboard_key_pressed::return#4 reg byte a 202.0
(byte) keyboard_key_pressed::rowidx
(byte) keyboard_key_pressed::rowidx#0 reg byte a 4.0
(byte[8]) keyboard_matrix_col_bitmask
(const byte[8]) keyboard_matrix_col_bitmask#0 keyboard_matrix_col_bitmask = { (byte/signed byte/word/signed word/dword/signed dword) 1, (byte/signed byte/word/signed word/dword/signed dword) 2, (byte/signed byte/word/signed word/dword/signed dword) 4, (byte/signed byte/word/signed word/dword/signed dword) 8, (byte/signed byte/word/signed word/dword/signed dword) 16, (byte/signed byte/word/signed word/dword/signed dword) 32, (byte/signed byte/word/signed word/dword/signed dword) 64, (byte/word/signed word/dword/signed dword) 128 }
(byte()) keyboard_matrix_read((byte) keyboard_matrix_read::rowid)
(label) keyboard_matrix_read::@return
(byte) keyboard_matrix_read::return
(byte) keyboard_matrix_read::return#0 reg byte a 1.3333333333333333
(byte) keyboard_matrix_read::return#2 reg byte a 4.0
(byte) keyboard_matrix_read::row_pressed_bits
(byte) keyboard_matrix_read::rowid
(byte) keyboard_matrix_read::rowid#0 reg byte x 4.0
(byte[8]) keyboard_matrix_row_bitmask
(const byte[8]) keyboard_matrix_row_bitmask#0 keyboard_matrix_row_bitmask = { (byte/word/signed word/dword/signed dword) 254, (byte/word/signed word/dword/signed dword) 253, (byte/word/signed word/dword/signed dword) 251, (byte/word/signed word/dword/signed dword) 247, (byte/word/signed word/dword/signed dword) 239, (byte/word/signed word/dword/signed dword) 223, (byte/word/signed word/dword/signed dword) 191, (byte/signed byte/word/signed word/dword/signed dword) 127 }
(byte) keyboard_modifiers
(byte[8]) keyboard_scan_values
(void()) main()
(label) main::@2
(void()) menu()
(byte~) menu::$0 reg byte a 202.0
(byte~) menu::$4 reg byte a 202.0
(byte~) menu::$7 reg byte a 202.0
(label) menu::@11
(label) menu::@13
(label) menu::@16
(label) menu::@17
(label) menu::@19
(label) menu::@2
(label) menu::@4
(label) menu::@5
(label) menu::@6
(label) menu::@9
(label) menu::@return
(void()) pressed()
(byte~) pressed::$0 reg byte a 202.0
(label) pressed::@10
(label) pressed::@2
(label) pressed::@return

reg byte x [ keyboard_key_pressed::key#4 ]
reg byte a [ keyboard_key_pressed::return#2 ]
reg byte a [ menu::$0 ]
reg byte a [ keyboard_key_pressed::return#3 ]
reg byte a [ menu::$4 ]
reg byte a [ keyboard_key_pressed::return#4 ]
reg byte a [ menu::$7 ]
reg byte y [ keyboard_key_pressed::colidx#0 ]
reg byte a [ keyboard_key_pressed::rowidx#0 ]
reg byte x [ keyboard_matrix_read::rowid#0 ]
reg byte a [ keyboard_matrix_read::return#2 ]
reg byte a [ keyboard_key_pressed::$2 ]
reg byte a [ keyboard_key_pressed::return#0 ]
reg byte a [ keyboard_matrix_read::return#0 ]
reg byte a [ keyboard_key_pressed::return#10 ]
reg byte a [ pressed::$0 ]


FINAL ASSEMBLER
Score: 2845

//SEG0 File Comments
// Exploring keyboard glitch that finds "C" press when pressing space
// The glitch is caused by the "normal" C64 interrupt occuring just as the keyboard is read.
// Press "I" to disable interrupts (red border)
// Press "E" to enable interrupts (green border)
// Press "C" to enter pressed state (increaded bgcol) - and "SPACE" to leave presssed state again.
// Holding SPACE will sometimes trigger the pressed state when normal interrupts are enabled (green border)
// but never when they are disabled (red border)
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label BORDERCOL = $d020
  .label BGCOL = $d021
  // CIA#1 Port A: keyboard matrix columns and joystick #2
  .label CIA1_PORT_A = $dc00
  // CIA#1 Port B: keyboard matrix rows and joystick #1.
  .label CIA1_PORT_B = $dc01
  .const RED = 2
  .const GREEN = 5
  .const KEY_E = $e
  .const KEY_C = $14
  .const KEY_I = $21
  .const KEY_SPACE = $3c
  .label SCREEN = $400
//SEG3 @begin
//SEG4 [1] phi from @begin to @14 [phi:@begin->@14]
//SEG5 @14
//SEG6 [2] call main 
//SEG7 [3] phi from @14 to @end [phi:@14->@end]
//SEG8 @end
//SEG9 main
main: {
  //SEG10 [4] *((const byte*) BORDERCOL#0) ← (const byte) GREEN#0 -- _deref_pbuc1=vbuc2 
    lda #GREEN
    sta BORDERCOL
  //SEG11 [5] phi from main main::@2 to main::@2 [phi:main/main::@2->main::@2]
  //SEG12 main::@2
  b2:
  //SEG13 [6] call menu 
  //SEG14 [7] phi from main::@2 to menu [phi:main::@2->menu]
    jsr menu
    jmp b2
}
//SEG15 menu
menu: {
  //SEG16 [8] phi from menu menu::@6 to menu::@2 [phi:menu/menu::@6->menu::@2]
  //SEG17 menu::@2
  b2:
  //SEG18 [9] call keyboard_key_pressed 
  //SEG19 [31] phi from menu::@2 to keyboard_key_pressed [phi:menu::@2->keyboard_key_pressed]
  //SEG20 [31] phi (byte) keyboard_key_pressed::key#4 = (const byte) KEY_C#0 [phi:menu::@2->keyboard_key_pressed#0] -- vbuxx=vbuc1 
    ldx #KEY_C
    jsr keyboard_key_pressed
  //SEG21 [10] (byte) keyboard_key_pressed::return#2 ← (byte) keyboard_key_pressed::return#0
  //SEG22 menu::@16
  //SEG23 [11] (byte~) menu::$0 ← (byte) keyboard_key_pressed::return#2
  //SEG24 [12] if((byte~) menu::$0==(byte/signed byte/word/signed word/dword/signed dword) 0) goto menu::@4 -- vbuaa_eq_0_then_la1 
    cmp #0
    beq b4
  //SEG25 [13] phi from menu::@16 to menu::@9 [phi:menu::@16->menu::@9]
  //SEG26 menu::@9
  //SEG27 [14] call pressed 
    jsr pressed
  //SEG28 menu::@return
  breturn:
  //SEG29 [15] return 
    rts
  //SEG30 [16] phi from menu::@16 to menu::@4 [phi:menu::@16->menu::@4]
  //SEG31 menu::@4
  b4:
  //SEG32 [17] call keyboard_key_pressed 
  //SEG33 [31] phi from menu::@4 to keyboard_key_pressed [phi:menu::@4->keyboard_key_pressed]
  //SEG34 [31] phi (byte) keyboard_key_pressed::key#4 = (const byte) KEY_I#0 [phi:menu::@4->keyboard_key_pressed#0] -- vbuxx=vbuc1 
    ldx #KEY_I
    jsr keyboard_key_pressed
  //SEG35 [18] (byte) keyboard_key_pressed::return#3 ← (byte) keyboard_key_pressed::return#0
  //SEG36 menu::@17
  //SEG37 [19] (byte~) menu::$4 ← (byte) keyboard_key_pressed::return#3
  //SEG38 [20] if((byte~) menu::$4==(byte/signed byte/word/signed word/dword/signed dword) 0) goto menu::@5 -- vbuaa_eq_0_then_la1 
    cmp #0
    beq b5
  //SEG39 menu::@11
  //SEG40 [21] *((const byte*) BORDERCOL#0) ← (const byte) RED#0 -- _deref_pbuc1=vbuc2 
    lda #RED
    sta BORDERCOL
  //SEG41 asm { sei  }
    sei
    jmp breturn
  //SEG42 [23] phi from menu::@17 to menu::@5 [phi:menu::@17->menu::@5]
  //SEG43 menu::@5
  b5:
  //SEG44 [24] call keyboard_key_pressed 
  //SEG45 [31] phi from menu::@5 to keyboard_key_pressed [phi:menu::@5->keyboard_key_pressed]
  //SEG46 [31] phi (byte) keyboard_key_pressed::key#4 = (const byte) KEY_E#0 [phi:menu::@5->keyboard_key_pressed#0] -- vbuxx=vbuc1 
    ldx #KEY_E
    jsr keyboard_key_pressed
  //SEG47 [25] (byte) keyboard_key_pressed::return#4 ← (byte) keyboard_key_pressed::return#0
  //SEG48 menu::@19
  //SEG49 [26] (byte~) menu::$7 ← (byte) keyboard_key_pressed::return#4
  //SEG50 [27] if((byte~) menu::$7==(byte/signed byte/word/signed word/dword/signed dword) 0) goto menu::@6 -- vbuaa_eq_0_then_la1 
    cmp #0
    beq b6
  //SEG51 menu::@13
  //SEG52 [28] *((const byte*) BORDERCOL#0) ← (const byte) GREEN#0 -- _deref_pbuc1=vbuc2 
    lda #GREEN
    sta BORDERCOL
  //SEG53 asm { cli  }
    cli
    jmp breturn
  //SEG54 menu::@6
  b6:
  //SEG55 [30] *((const byte*) SCREEN#0) ← ++ *((const byte*) SCREEN#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc SCREEN
    jmp b2
}
//SEG56 keyboard_key_pressed
// Determines whether a specific key is currently pressed by accessing the matrix directly
// The key is a keyboard code defined from the keyboard matrix by %00rrrccc, where rrr is the row ID (0-7) and ccc is the column ID (0-7)
// All keys exist as as KEY_XXX constants.
// Returns zero if the key is not pressed and a non-zero value if the key is currently pressed
// keyboard_key_pressed(byte register(X) key)
keyboard_key_pressed: {
  //SEG57 [32] (byte) keyboard_key_pressed::colidx#0 ← (byte) keyboard_key_pressed::key#4 & (byte/signed byte/word/signed word/dword/signed dword) 7 -- vbuyy=vbuxx_band_vbuc1 
    txa
    and #7
    tay
  //SEG58 [33] (byte) keyboard_key_pressed::rowidx#0 ← (byte) keyboard_key_pressed::key#4 >> (byte/signed byte/word/signed word/dword/signed dword) 3 -- vbuaa=vbuxx_ror_3 
    txa
    lsr
    lsr
    lsr
  //SEG59 [34] (byte) keyboard_matrix_read::rowid#0 ← (byte) keyboard_key_pressed::rowidx#0 -- vbuxx=vbuaa 
    tax
  //SEG60 [35] call keyboard_matrix_read 
    jsr keyboard_matrix_read
  //SEG61 [36] (byte) keyboard_matrix_read::return#2 ← (byte) keyboard_matrix_read::return#0
  //SEG62 keyboard_key_pressed::@2
  //SEG63 [37] (byte~) keyboard_key_pressed::$2 ← (byte) keyboard_matrix_read::return#2
  //SEG64 [38] (byte) keyboard_key_pressed::return#0 ← (byte~) keyboard_key_pressed::$2 & *((const byte[8]) keyboard_matrix_col_bitmask#0 + (byte) keyboard_key_pressed::colidx#0) -- vbuaa=vbuaa_band_pbuc1_derefidx_vbuyy 
    and keyboard_matrix_col_bitmask,y
  //SEG65 keyboard_key_pressed::@return
  //SEG66 [39] return 
    rts
}
//SEG67 keyboard_matrix_read
// Read a single row of the keyboard matrix
// The row ID (0-7) of the keyboard matrix row to read. See the C64 key matrix for row IDs.
// Returns the keys pressed on the row as bits according to the C64 key matrix.
// Notice: If the C64 normal interrupt is still running it will occasionally interrupt right between the read & write
// leading to erroneous readings. You must disable kill the normal interrupt or sei/cli around calls to the keyboard matrix reader.
// keyboard_matrix_read(byte register(X) rowid)
keyboard_matrix_read: {
  //SEG68 [40] *((const byte*) CIA1_PORT_A#0) ← *((const byte[8]) keyboard_matrix_row_bitmask#0 + (byte) keyboard_matrix_read::rowid#0) -- _deref_pbuc1=pbuc2_derefidx_vbuxx 
    lda keyboard_matrix_row_bitmask,x
    sta CIA1_PORT_A
  //SEG69 [41] (byte) keyboard_matrix_read::return#0 ← ~ *((const byte*) CIA1_PORT_B#0) -- vbuaa=_bnot__deref_pbuc1 
    lda CIA1_PORT_B
    eor #$ff
  //SEG70 keyboard_matrix_read::@return
  //SEG71 [42] return 
    rts
}
//SEG72 pressed
pressed: {
  //SEG73 [43] *((const byte*) BGCOL#0) ← ++ *((const byte*) BGCOL#0) -- _deref_pbuc1=_inc__deref_pbuc1 
    inc BGCOL
  //SEG74 [44] phi from pressed pressed::@10 to pressed::@2 [phi:pressed/pressed::@10->pressed::@2]
  //SEG75 pressed::@2
  b2:
  //SEG76 [45] call keyboard_key_pressed 
  //SEG77 [31] phi from pressed::@2 to keyboard_key_pressed [phi:pressed::@2->keyboard_key_pressed]
  //SEG78 [31] phi (byte) keyboard_key_pressed::key#4 = (const byte) KEY_SPACE#0 [phi:pressed::@2->keyboard_key_pressed#0] -- vbuxx=vbuc1 
    ldx #KEY_SPACE
    jsr keyboard_key_pressed
  //SEG79 [46] (byte) keyboard_key_pressed::return#10 ← (byte) keyboard_key_pressed::return#0
  //SEG80 pressed::@10
  //SEG81 [47] (byte~) pressed::$0 ← (byte) keyboard_key_pressed::return#10
  //SEG82 [48] if((byte~) pressed::$0==(byte/signed byte/word/signed word/dword/signed dword) 0) goto pressed::@2 -- vbuaa_eq_0_then_la1 
    cmp #0
    beq b2
  //SEG83 pressed::@return
  //SEG84 [49] return 
    rts
}
  // Keyboard row bitmask as expected by CIA#1 Port A when reading a specific keyboard matrix row (rows are numbered 0-7)
  keyboard_matrix_row_bitmask: .byte $fe, $fd, $fb, $f7, $ef, $df, $bf, $7f
  // Keyboard matrix column bitmasks for a specific keybooard matrix column when reading the keyboard. (columns are numbered 0-7)
  keyboard_matrix_col_bitmask: .byte 1, 2, 4, 8, $10, $20, $40, $80

