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_init: scope:[keyboard_init]  from main::@14
  *((byte*) CIA1_PORT_A_DDR#0) ← (byte/word/signed word/dword/signed dword) 255
  *((byte*) CIA1_PORT_B_DDR#0) ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:keyboard_init::@return
keyboard_init::@return: scope:[keyboard_init]  from keyboard_init
  return 
  to:@return
keyboard_matrix_read: scope:[keyboard_matrix_read]  from keyboard_key_pressed main::@6
  (byte) keyboard_matrix_read::rowid#2 ← phi( keyboard_key_pressed/(byte) keyboard_matrix_read::rowid#0 main::@6/(byte) keyboard_matrix_read::rowid#1 )
  *((byte*) CIA1_PORT_A#0) ← *((byte[8]) keyboard_matrix_row_bitmask#0 + (byte) keyboard_matrix_read::rowid#2)
  (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#4 ← phi( keyboard_matrix_read/(byte) keyboard_matrix_read::return#0 )
  (byte) keyboard_matrix_read::return#1 ← (byte) keyboard_matrix_read::return#4
  return 
  to:@return
keyboard_key_pressed: scope:[keyboard_key_pressed]  from main::@22
  (byte) keyboard_key_pressed::key#1 ← phi( main::@22/(byte) keyboard_key_pressed::key#0 )
  (byte~) keyboard_key_pressed::$0 ← (byte) keyboard_key_pressed::key#1 & (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#1 >> (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#5 ← phi( keyboard_key_pressed/(byte) keyboard_matrix_read::return#2 )
  (byte~) keyboard_key_pressed::$2 ← (byte) keyboard_matrix_read::return#5
  (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#3 ← phi( keyboard_key_pressed::@2/(byte) keyboard_key_pressed::return#0 )
  (byte) keyboard_key_pressed::return#1 ← (byte) keyboard_key_pressed::return#3
  return 
  to:@return
keyboard_get_keycode: scope:[keyboard_get_keycode]  from main::@10
  (byte) keyboard_get_keycode::ch#1 ← phi( main::@10/(byte) keyboard_get_keycode::ch#0 )
  (byte) keyboard_get_keycode::return#0 ← *((byte[]) keyboard_char_keycodes#0 + (byte) keyboard_get_keycode::ch#1)
  to:keyboard_get_keycode::@return
keyboard_get_keycode::@return: scope:[keyboard_get_keycode]  from keyboard_get_keycode
  (byte) keyboard_get_keycode::return#3 ← phi( keyboard_get_keycode/(byte) keyboard_get_keycode::return#0 )
  (byte) keyboard_get_keycode::return#1 ← (byte) keyboard_get_keycode::return#3
  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 @12
  (byte*) main::sc#0 ← ((byte*)) (word/signed word/dword/signed dword) 1024
  to:main::@1
main::@1: scope:[main]  from main main::@1
  (byte*) main::sc#2 ← phi( main/(byte*) main::sc#0 main::@1/(byte*) main::sc#1 )
  *((byte*) main::sc#2) ← (byte) ' '
  (byte*) main::sc#1 ← ++ (byte*) main::sc#2
  (word/signed word/dword/signed dword~) main::$0 ← (word/signed word/dword/signed dword) 1024 + (word/signed word/dword/signed dword) 1000
  (bool~) main::$1 ← (byte*) main::sc#1 < (word/signed word/dword/signed dword~) main::$0
  if((bool~) main::$1) goto main::@1
  to:main::@14
main::@14: scope:[main]  from main::@1
  call keyboard_init 
  to:main::@27
main::@27: scope:[main]  from main::@14
  to:main::@2
main::@2: scope:[main]  from main::@13 main::@27
  if(true) goto main::@3
  to:main::@return
main::@3: scope:[main]  from main::@2
  to:main::@5
main::@5: scope:[main]  from main::@3 main::@5
  (bool~) main::$3 ← *((byte*) RASTER#0) != (byte/word/signed word/dword/signed dword) 255
  if((bool~) main::$3) goto main::@5
  to:main::@17
main::@17: scope:[main]  from main::@5
  (byte*) main::screen#0 ← ((byte*)) (word/signed word/dword/signed dword) 1024
  (byte) main::row#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:main::@6
main::@6: scope:[main]  from main::@17 main::@20
  (byte*) main::screen#17 ← phi( main::@17/(byte*) main::screen#0 main::@20/(byte*) main::screen#1 )
  (byte) main::row#2 ← phi( main::@17/(byte) main::row#0 main::@20/(byte) main::row#1 )
  (byte) keyboard_matrix_read::rowid#1 ← (byte) main::row#2
  call keyboard_matrix_read 
  (byte) keyboard_matrix_read::return#3 ← (byte) keyboard_matrix_read::return#1
  to:main::@28
main::@28: scope:[main]  from main::@6
  (byte) main::row#8 ← phi( main::@6/(byte) main::row#2 )
  (byte*) main::screen#13 ← phi( main::@6/(byte*) main::screen#17 )
  (byte) keyboard_matrix_read::return#6 ← phi( main::@6/(byte) keyboard_matrix_read::return#3 )
  (byte~) main::$4 ← (byte) keyboard_matrix_read::return#6
  (byte) main::row_pressed_bits#0 ← (byte~) main::$4
  (byte) main::col#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:main::@7
main::@7: scope:[main]  from main::@28 main::@9
  (byte) main::row#7 ← phi( main::@28/(byte) main::row#8 main::@9/(byte) main::row#4 )
  (byte) main::col#5 ← phi( main::@28/(byte) main::col#0 main::@9/(byte) main::col#1 )
  (byte*) main::screen#9 ← phi( main::@28/(byte*) main::screen#13 main::@9/(byte*) main::screen#10 )
  (byte) main::row_pressed_bits#2 ← phi( main::@28/(byte) main::row_pressed_bits#0 main::@9/(byte) main::row_pressed_bits#1 )
  (byte~) main::$5 ← (byte) main::row_pressed_bits#2 & (byte/word/signed word/dword/signed dword) 128
  (bool~) main::$6 ← (byte~) main::$5 != (byte/signed byte/word/signed word/dword/signed dword) 0
  if((bool~) main::$6) goto main::@8
  to:main::@18
main::@8: scope:[main]  from main::@7
  (byte) main::row#6 ← phi( main::@7/(byte) main::row#7 )
  (byte) main::row_pressed_bits#5 ← phi( main::@7/(byte) main::row_pressed_bits#2 )
  (byte) main::col#2 ← phi( main::@7/(byte) main::col#5 )
  (byte*) main::screen#3 ← phi( main::@7/(byte*) main::screen#9 )
  *((byte*) main::screen#3 + (byte) main::col#2) ← (byte) '1'
  to:main::@9
main::@18: scope:[main]  from main::@7
  (byte) main::row#5 ← phi( main::@7/(byte) main::row#7 )
  (byte) main::row_pressed_bits#4 ← phi( main::@7/(byte) main::row_pressed_bits#2 )
  (byte) main::col#3 ← phi( main::@7/(byte) main::col#5 )
  (byte*) main::screen#4 ← phi( main::@7/(byte*) main::screen#9 )
  *((byte*) main::screen#4 + (byte) main::col#3) ← (byte) '0'
  to:main::@9
main::@9: scope:[main]  from main::@18 main::@8
  (byte) main::row#4 ← phi( main::@18/(byte) main::row#5 main::@8/(byte) main::row#6 )
  (byte*) main::screen#10 ← phi( main::@18/(byte*) main::screen#4 main::@8/(byte*) main::screen#3 )
  (byte) main::col#4 ← phi( main::@18/(byte) main::col#3 main::@8/(byte) main::col#2 )
  (byte) main::row_pressed_bits#3 ← phi( main::@18/(byte) main::row_pressed_bits#4 main::@8/(byte) main::row_pressed_bits#5 )
  (byte~) main::$7 ← (byte) main::row_pressed_bits#3 << (byte/signed byte/word/signed word/dword/signed dword) 1
  (byte) main::row_pressed_bits#1 ← (byte~) main::$7
  (byte) main::col#1 ← (byte) main::col#4 + rangenext(0,7)
  (bool~) main::$8 ← (byte) main::col#1 != rangelast(0,7)
  if((bool~) main::$8) goto main::@7
  to:main::@20
main::@20: scope:[main]  from main::@9
  (byte) main::row#3 ← phi( main::@9/(byte) main::row#4 )
  (byte*) main::screen#5 ← phi( main::@9/(byte*) main::screen#10 )
  (byte*~) main::$9 ← (byte*) main::screen#5 + (byte/signed byte/word/signed word/dword/signed dword) 40
  (byte*) main::screen#1 ← (byte*~) main::$9
  (byte) main::row#1 ← (byte) main::row#3 + rangenext(0,7)
  (bool~) main::$10 ← (byte) main::row#1 != rangelast(0,7)
  if((bool~) main::$10) goto main::@6
  to:main::@21
main::@21: scope:[main]  from main::@20
  (byte*) main::screen#6 ← phi( main::@20/(byte*) main::screen#1 )
  (byte*~) main::$11 ← (byte*) main::screen#6 + (byte/signed byte/word/signed word/dword/signed dword) 40
  (byte*) main::screen#2 ← (byte*~) main::$11
  (byte) main::i#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  (byte) main::ch#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:main::@10
main::@10: scope:[main]  from main::@11 main::@21
  (byte) main::i#10 ← phi( main::@11/(byte) main::i#6 main::@21/(byte) main::i#0 )
  (byte*) main::screen#18 ← phi( main::@11/(byte*) main::screen#12 main::@21/(byte*) main::screen#2 )
  (byte) main::ch#2 ← phi( main::@11/(byte) main::ch#1 main::@21/(byte) main::ch#0 )
  (byte) keyboard_get_keycode::ch#0 ← (byte) main::ch#2
  call keyboard_get_keycode 
  (byte) keyboard_get_keycode::return#2 ← (byte) keyboard_get_keycode::return#1
  to:main::@29
main::@29: scope:[main]  from main::@10
  (byte) main::i#8 ← phi( main::@10/(byte) main::i#10 )
  (byte*) main::screen#15 ← phi( main::@10/(byte*) main::screen#18 )
  (byte) main::ch#6 ← phi( main::@10/(byte) main::ch#2 )
  (byte) keyboard_get_keycode::return#4 ← phi( main::@10/(byte) keyboard_get_keycode::return#2 )
  (byte~) main::$12 ← (byte) keyboard_get_keycode::return#4
  (byte) main::key#0 ← (byte~) main::$12
  (bool~) main::$13 ← (byte) main::key#0 != (byte/signed byte/word/signed word/dword/signed dword) 63
  (bool~) main::$14 ← ! (bool~) main::$13
  if((bool~) main::$14) goto main::@11
  to:main::@22
main::@11: scope:[main]  from main::@12 main::@23 main::@29
  (byte) main::i#6 ← phi( main::@12/(byte) main::i#7 main::@23/(byte) main::i#1 main::@29/(byte) main::i#8 )
  (byte*) main::screen#12 ← phi( main::@12/(byte*) main::screen#14 main::@23/(byte*) main::screen#7 main::@29/(byte*) main::screen#15 )
  (byte) main::ch#3 ← phi( main::@12/(byte) main::ch#5 main::@23/(byte) main::ch#4 main::@29/(byte) main::ch#6 )
  (byte) main::ch#1 ← (byte) main::ch#3 + rangenext(0,63)
  (bool~) main::$18 ← (byte) main::ch#1 != rangelast(0,63)
  if((bool~) main::$18) goto main::@10
  to:main::@13
main::@22: scope:[main]  from main::@29
  (byte) main::i#9 ← phi( main::@29/(byte) main::i#8 )
  (byte*) main::screen#16 ← phi( main::@29/(byte*) main::screen#15 )
  (byte) main::ch#8 ← phi( main::@29/(byte) main::ch#6 )
  (byte) main::key#1 ← phi( main::@29/(byte) main::key#0 )
  (byte) keyboard_key_pressed::key#0 ← (byte) main::key#1
  call keyboard_key_pressed 
  (byte) keyboard_key_pressed::return#2 ← (byte) keyboard_key_pressed::return#1
  to:main::@30
main::@30: scope:[main]  from main::@22
  (byte) main::i#5 ← phi( main::@22/(byte) main::i#9 )
  (byte*) main::screen#11 ← phi( main::@22/(byte*) main::screen#16 )
  (byte) main::ch#7 ← phi( main::@22/(byte) main::ch#8 )
  (byte) keyboard_key_pressed::return#4 ← phi( main::@22/(byte) keyboard_key_pressed::return#2 )
  (byte~) main::$15 ← (byte) keyboard_key_pressed::return#4
  (bool~) main::$16 ← (byte~) main::$15 != (byte/signed byte/word/signed word/dword/signed dword) 0
  (bool~) main::$17 ← ! (bool~) main::$16
  if((bool~) main::$17) goto main::@12
  to:main::@23
main::@12: scope:[main]  from main::@30
  (byte) main::i#7 ← phi( main::@30/(byte) main::i#5 )
  (byte*) main::screen#14 ← phi( main::@30/(byte*) main::screen#11 )
  (byte) main::ch#5 ← phi( main::@30/(byte) main::ch#7 )
  to:main::@11
main::@23: scope:[main]  from main::@30
  (byte) main::i#3 ← phi( main::@30/(byte) main::i#5 )
  (byte*) main::screen#7 ← phi( main::@30/(byte*) main::screen#11 )
  (byte) main::ch#4 ← phi( main::@30/(byte) main::ch#7 )
  *((byte*) main::screen#7 + (byte) main::i#3) ← (byte) main::ch#4
  (byte) main::i#1 ← ++ (byte) main::i#3
  to:main::@11
main::@13: scope:[main]  from main::@11 main::@13
  (byte) main::i#4 ← phi( main::@11/(byte) main::i#6 main::@13/(byte) main::i#2 )
  (byte*) main::screen#8 ← phi( main::@11/(byte*) main::screen#12 main::@13/(byte*) main::screen#8 )
  *((byte*) main::screen#8 + (byte) main::i#4) ← (byte) ' '
  (byte) main::i#2 ← ++ (byte) main::i#4
  (bool~) main::$19 ← (byte) main::i#2 < (byte/signed byte/word/signed word/dword/signed dword) 5
  if((bool~) main::$19) goto main::@13
  to:main::@2
main::@return: scope:[main]  from main::@2
  return 
  to:@return
@12: scope:[]  from @8
  call main 
  to:@13
@13: scope:[]  from @12
  to:@end
@end: scope:[]  from @13

SYMBOL TABLE SSA
(byte~) $0
(label) @12
(label) @13
(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*) 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_get_keycode((byte) keyboard_get_keycode::ch)
(label) keyboard_get_keycode::@return
(byte) keyboard_get_keycode::ch
(byte) keyboard_get_keycode::ch#0
(byte) keyboard_get_keycode::ch#1
(byte) keyboard_get_keycode::return
(byte) keyboard_get_keycode::return#0
(byte) keyboard_get_keycode::return#1
(byte) keyboard_get_keycode::return#2
(byte) keyboard_get_keycode::return#3
(byte) keyboard_get_keycode::return#4
(void()) keyboard_init()
(label) keyboard_init::@return
(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::return
(byte) keyboard_key_pressed::return#0
(byte) keyboard_key_pressed::return#1
(byte) keyboard_key_pressed::return#2
(byte) keyboard_key_pressed::return#3
(byte) keyboard_key_pressed::return#4
(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::return#5
(byte) keyboard_matrix_read::return#6
(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) keyboard_matrix_read::rowid#2
(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()
(word/signed word/dword/signed dword~) main::$0
(bool~) main::$1
(bool~) main::$10
(byte*~) main::$11
(byte~) main::$12
(bool~) main::$13
(bool~) main::$14
(byte~) main::$15
(bool~) main::$16
(bool~) main::$17
(bool~) main::$18
(bool~) main::$19
(bool~) main::$3
(byte~) main::$4
(byte~) main::$5
(bool~) main::$6
(byte~) main::$7
(bool~) main::$8
(byte*~) main::$9
(label) main::@1
(label) main::@10
(label) main::@11
(label) main::@12
(label) main::@13
(label) main::@14
(label) main::@17
(label) main::@18
(label) main::@2
(label) main::@20
(label) main::@21
(label) main::@22
(label) main::@23
(label) main::@27
(label) main::@28
(label) main::@29
(label) main::@3
(label) main::@30
(label) main::@5
(label) main::@6
(label) main::@7
(label) main::@8
(label) main::@9
(label) main::@return
(byte) main::ch
(byte) main::ch#0
(byte) main::ch#1
(byte) main::ch#2
(byte) main::ch#3
(byte) main::ch#4
(byte) main::ch#5
(byte) main::ch#6
(byte) main::ch#7
(byte) main::ch#8
(byte) main::col
(byte) main::col#0
(byte) main::col#1
(byte) main::col#2
(byte) main::col#3
(byte) main::col#4
(byte) main::col#5
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#10
(byte) main::i#2
(byte) main::i#3
(byte) main::i#4
(byte) main::i#5
(byte) main::i#6
(byte) main::i#7
(byte) main::i#8
(byte) main::i#9
(byte) main::key
(byte) main::key#0
(byte) main::key#1
(byte) main::row
(byte) main::row#0
(byte) main::row#1
(byte) main::row#2
(byte) main::row#3
(byte) main::row#4
(byte) main::row#5
(byte) main::row#6
(byte) main::row#7
(byte) main::row#8
(byte) main::row_pressed_bits
(byte) main::row_pressed_bits#0
(byte) main::row_pressed_bits#1
(byte) main::row_pressed_bits#2
(byte) main::row_pressed_bits#3
(byte) main::row_pressed_bits#4
(byte) main::row_pressed_bits#5
(byte*) main::sc
(byte*) main::sc#0
(byte*) main::sc#1
(byte*) main::sc#2
(byte*) main::screen
(byte*) main::screen#0
(byte*) main::screen#1
(byte*) main::screen#10
(byte*) main::screen#11
(byte*) main::screen#12
(byte*) main::screen#13
(byte*) main::screen#14
(byte*) main::screen#15
(byte*) main::screen#16
(byte*) main::screen#17
(byte*) main::screen#18
(byte*) main::screen#2
(byte*) main::screen#3
(byte*) main::screen#4
(byte*) main::screen#5
(byte*) main::screen#6
(byte*) main::screen#7
(byte*) main::screen#8
(byte*) main::screen#9

Culled Empty Block (label) main::@27
Culled Empty Block (label) main::@3
Culled Empty Block (label) @13
Successful SSA optimization Pass2CullEmptyBlocks
Inversing boolean not [241] (bool~) main::$14 ← (byte) main::key#0 == (byte/signed byte/word/signed word/dword/signed dword) 63 from [240] (bool~) main::$13 ← (byte) main::key#0 != (byte/signed byte/word/signed word/dword/signed dword) 63
Inversing boolean not [254] (bool~) main::$17 ← (byte~) main::$15 == (byte/signed byte/word/signed word/dword/signed dword) 0 from [253] (bool~) main::$16 ← (byte~) main::$15 != (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#4 (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#5 
Alias (byte) keyboard_key_pressed::return#0 = (byte~) keyboard_key_pressed::$3 (byte) keyboard_key_pressed::return#3 (byte) keyboard_key_pressed::return#1 
Alias (byte) keyboard_get_keycode::return#0 = (byte) keyboard_get_keycode::return#3 (byte) keyboard_get_keycode::return#1 
Alias (byte) KEY_MODIFIER_SHIFT#0 = (byte~) $0 
Alias (byte) keyboard_matrix_read::return#3 = (byte) keyboard_matrix_read::return#6 
Alias (byte*) main::screen#13 = (byte*) main::screen#17 
Alias (byte) main::row#2 = (byte) main::row#8 
Alias (byte) main::row_pressed_bits#0 = (byte~) main::$4 
Alias (byte*) main::screen#3 = (byte*) main::screen#9 (byte*) main::screen#4 
Alias (byte) main::col#2 = (byte) main::col#5 (byte) main::col#3 
Alias (byte) main::row_pressed_bits#2 = (byte) main::row_pressed_bits#5 (byte) main::row_pressed_bits#4 
Alias (byte) main::row#5 = (byte) main::row#6 (byte) main::row#7 
Alias (byte) main::row_pressed_bits#1 = (byte~) main::$7 
Alias (byte*) main::screen#10 = (byte*) main::screen#5 
Alias (byte) main::row#3 = (byte) main::row#4 
Alias (byte*) main::screen#1 = (byte*~) main::$9 (byte*) main::screen#6 
Alias (byte*) main::screen#2 = (byte*~) main::$11 
Alias (byte) keyboard_get_keycode::return#2 = (byte) keyboard_get_keycode::return#4 
Alias (byte) main::ch#2 = (byte) main::ch#6 (byte) main::ch#8 (byte) main::ch#7 (byte) main::ch#5 (byte) main::ch#4 
Alias (byte*) main::screen#11 = (byte*) main::screen#15 (byte*) main::screen#18 (byte*) main::screen#16 (byte*) main::screen#14 (byte*) main::screen#7 
Alias (byte) main::i#10 = (byte) main::i#8 (byte) main::i#9 (byte) main::i#5 (byte) main::i#7 (byte) main::i#3 
Alias (byte) main::key#0 = (byte~) main::$12 (byte) main::key#1 
Alias (byte) keyboard_key_pressed::return#2 = (byte) keyboard_key_pressed::return#4 
Successful SSA optimization Pass2AliasElimination
Alias (byte) main::row_pressed_bits#2 = (byte) main::row_pressed_bits#3 
Alias (byte) main::col#2 = (byte) main::col#4 
Alias (byte*) main::screen#10 = (byte*) main::screen#3 
Alias (byte) main::row#3 = (byte) main::row#5 
Alias (byte) main::ch#2 = (byte) main::ch#3 
Alias (byte*) main::screen#11 = (byte*) main::screen#12 
Successful SSA optimization Pass2AliasElimination
Self Phi Eliminated (byte*) main::screen#10
Self Phi Eliminated (byte) main::row#3
Self Phi Eliminated (byte*) main::screen#11
Self Phi Eliminated (byte*) main::screen#8
Successful SSA optimization Pass2SelfPhiElimination
Redundant Phi (byte) keyboard_key_pressed::key#1 (byte) keyboard_key_pressed::key#0
Redundant Phi (byte) keyboard_get_keycode::ch#1 (byte) keyboard_get_keycode::ch#0
Redundant Phi (byte*) main::screen#10 (byte*) main::screen#13
Redundant Phi (byte) main::row#3 (byte) main::row#2
Redundant Phi (byte*) main::screen#11 (byte*) main::screen#2
Redundant Phi (byte*) main::screen#8 (byte*) main::screen#11
Successful SSA optimization Pass2RedundantPhiElimination
Simple Condition (bool~) main::$1 [193] if((byte*) main::sc#1<(word/signed word/dword/signed dword~) main::$0) goto main::@1
Simple Condition (bool~) main::$3 [197] if(*((byte*) RASTER#0)!=(byte/word/signed word/dword/signed dword) 255) goto main::@5
Simple Condition (bool~) main::$6 [211] if((byte~) main::$5!=(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@8
Simple Condition (bool~) main::$8 [221] if((byte) main::col#1!=rangelast(0,7)) goto main::@7
Simple Condition (bool~) main::$10 [227] if((byte) main::row#1!=rangelast(0,7)) goto main::@6
Simple Condition (bool~) main::$14 [242] if((byte) main::key#0==(byte/signed byte/word/signed word/dword/signed dword) 63) goto main::@11
Simple Condition (bool~) main::$18 [246] if((byte) main::ch#1!=rangelast(0,63)) goto main::@10
Simple Condition (bool~) main::$17 [255] if((byte~) main::$15==(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@12
Simple Condition (bool~) main::$19 [264] if((byte) main::i#2<(byte/signed byte/word/signed word/dword/signed dword) 5) goto main::@13
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*) main::sc#0 = ((byte*))1024
Constant (const word/signed word/dword/signed dword) main::$0 = 1024+1000
Constant (const byte*) main::screen#0 = ((byte*))1024
Constant (const byte) main::row#0 = 0
Constant (const byte) main::col#0 = 0
Constant (const byte) main::i#0 = 0
Constant (const byte) main::ch#0 = 0
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
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [22] if(true) goto main::@5
Successful SSA optimization Pass2ConstantIfs
Successful SSA optimization PassNEliminateUnusedVars
Successful SSA optimization PassNEliminateUnusedVars
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Resolved ranged next value main::col#1 ← ++ main::col#2 to ++
Resolved ranged comparison value if(main::col#1!=rangelast(0,7)) goto main::@7 to (byte/signed byte/word/signed word/dword/signed dword) 8
Resolved ranged next value main::row#1 ← ++ main::row#2 to ++
Resolved ranged comparison value if(main::row#1!=rangelast(0,7)) goto main::@6 to (byte/signed byte/word/signed word/dword/signed dword) 8
Resolved ranged next value main::ch#1 ← ++ main::ch#2 to ++
Resolved ranged comparison value if(main::ch#1!=rangelast(0,63)) goto main::@10 to (byte/signed byte/word/signed word/dword/signed dword) 64
Culled Empty Block (label) @4
Culled Empty Block (label) @8
Culled Empty Block (label) main::@2
Culled Empty Block (label) main::@17
Culled Empty Block (label) main::@12
Successful SSA optimization Pass2CullEmptyBlocks
Inlining constant with var siblings (const byte*) main::sc#0
Inlining constant with var siblings (const byte*) main::screen#0
Inlining constant with var siblings (const byte) main::row#0
Inlining constant with var siblings (const byte) main::col#0
Inlining constant with var siblings (const byte) main::i#0
Inlining constant with var siblings (const byte) main::ch#0
Constant inlined main::screen#0 = ((byte*))(word/signed word/dword/signed dword) 1024
Constant inlined main::col#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Constant inlined main::$0 = (word/signed word/dword/signed dword) 1024+(word/signed word/dword/signed dword) 1000
Constant inlined main::i#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Constant inlined main::sc#0 = ((byte*))(word/signed word/dword/signed dword) 1024
Constant inlined main::row#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Constant inlined main::ch#0 = (byte/signed byte/word/signed word/dword/signed dword) 0
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@31(between main::@1 and main::@1)
Added new block during phi lifting main::@32(between main::@20 and main::@6)
Added new block during phi lifting main::@33(between main::@9 and main::@7)
Added new block during phi lifting main::@34(between main::@11 and main::@10)
Added new block during phi lifting main::@35(between main::@30 and main::@11)
Added new block during phi lifting main::@36(between main::@29 and main::@11)
Added new block during phi lifting main::@37(between main::@11 and main::@13)
Added new block during phi lifting main::@38(between main::@13 and main::@13)
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @12
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@14
CALL GRAPH
Calls in [] to main:2 
Calls in [main] to keyboard_init:10 keyboard_matrix_read:15 keyboard_get_keycode:32 keyboard_key_pressed:37 
Calls in [keyboard_key_pressed] to keyboard_matrix_read:67 

Created 10 initial phi equivalence classes
Coalesced [14] keyboard_matrix_read::rowid#4 ← keyboard_matrix_read::rowid#1
Coalesced [18] main::row_pressed_bits#6 ← main::row_pressed_bits#0
Coalesced [43] main::i#13 ← main::i#1
Coalesced [47] main::i#15 ← main::i#6
Coalesced [52] main::i#16 ← main::i#2
Coalesced [53] main::ch#9 ← main::ch#1
Coalesced [54] main::i#11 ← main::i#6
Coalesced (already) [55] main::i#12 ← main::i#10
Coalesced (already) [56] main::i#14 ← main::i#10
Coalesced [57] main::row#9 ← main::row#1
Coalesced [58] main::screen#19 ← main::screen#1
Coalesced [59] main::row_pressed_bits#7 ← main::row_pressed_bits#1
Coalesced [60] main::col#6 ← main::col#1
Coalesced [62] main::sc#3 ← main::sc#1
Coalesced [66] keyboard_matrix_read::rowid#3 ← keyboard_matrix_read::rowid#0
Coalesced down to 8 phi equivalence classes
Culled Empty Block (label) main::@37
Culled Empty Block (label) main::@38
Culled Empty Block (label) main::@34
Culled Empty Block (label) main::@35
Culled Empty Block (label) main::@36
Culled Empty Block (label) main::@32
Culled Empty Block (label) main::@33
Culled Empty Block (label) main::@31
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @12
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@14

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi()
  to:@12
@12: scope:[]  from @begin
  [1] phi()
  [2] call main 
  to:@end
@end: scope:[]  from @12
  [3] phi()
main: scope:[main]  from @12
  [4] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@1
  [5] (byte*) main::sc#2 ← phi( main/((byte*))(word/signed word/dword/signed dword) 1024 main::@1/(byte*) main::sc#1 )
  [6] *((byte*) main::sc#2) ← (byte) ' '
  [7] (byte*) main::sc#1 ← ++ (byte*) main::sc#2
  [8] if((byte*) main::sc#1<(word/signed word/dword/signed dword) 1024+(word/signed word/dword/signed dword) 1000) goto main::@1
  to:main::@14
main::@14: scope:[main]  from main::@1
  [9] phi()
  [10] call keyboard_init 
  to:main::@5
main::@5: scope:[main]  from main::@13 main::@14 main::@5
  [11] if(*((const byte*) RASTER#0)!=(byte/word/signed word/dword/signed dword) 255) goto main::@5
  to:main::@6
main::@6: scope:[main]  from main::@20 main::@5
  [12] (byte*) main::screen#13 ← phi( main::@5/((byte*))(word/signed word/dword/signed dword) 1024 main::@20/(byte*) main::screen#1 )
  [12] (byte) main::row#2 ← phi( main::@5/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@20/(byte) main::row#1 )
  [13] (byte) keyboard_matrix_read::rowid#1 ← (byte) main::row#2
  [14] call keyboard_matrix_read 
  [15] (byte) keyboard_matrix_read::return#3 ← (byte) keyboard_matrix_read::return#0
  to:main::@28
main::@28: scope:[main]  from main::@6
  [16] (byte) main::row_pressed_bits#0 ← (byte) keyboard_matrix_read::return#3
  to:main::@7
main::@7: scope:[main]  from main::@28 main::@9
  [17] (byte) main::col#2 ← phi( main::@28/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@9/(byte) main::col#1 )
  [17] (byte) main::row_pressed_bits#2 ← phi( main::@28/(byte) main::row_pressed_bits#0 main::@9/(byte) main::row_pressed_bits#1 )
  [18] (byte~) main::$5 ← (byte) main::row_pressed_bits#2 & (byte/word/signed word/dword/signed dword) 128
  [19] if((byte~) main::$5!=(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@8
  to:main::@18
main::@18: scope:[main]  from main::@7
  [20] *((byte*) main::screen#13 + (byte) main::col#2) ← (byte) '0'
  to:main::@9
main::@9: scope:[main]  from main::@18 main::@8
  [21] (byte) main::row_pressed_bits#1 ← (byte) main::row_pressed_bits#2 << (byte/signed byte/word/signed word/dword/signed dword) 1
  [22] (byte) main::col#1 ← ++ (byte) main::col#2
  [23] if((byte) main::col#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@7
  to:main::@20
main::@20: scope:[main]  from main::@9
  [24] (byte*) main::screen#1 ← (byte*) main::screen#13 + (byte/signed byte/word/signed word/dword/signed dword) 40
  [25] (byte) main::row#1 ← ++ (byte) main::row#2
  [26] if((byte) main::row#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@6
  to:main::@21
main::@21: scope:[main]  from main::@20
  [27] (byte*) main::screen#2 ← (byte*) main::screen#1 + (byte/signed byte/word/signed word/dword/signed dword) 40
  to:main::@10
main::@10: scope:[main]  from main::@11 main::@21
  [28] (byte) main::i#10 ← phi( main::@11/(byte) main::i#6 main::@21/(byte/signed byte/word/signed word/dword/signed dword) 0 )
  [28] (byte) main::ch#2 ← phi( main::@11/(byte) main::ch#1 main::@21/(byte/signed byte/word/signed word/dword/signed dword) 0 )
  [29] (byte) keyboard_get_keycode::ch#0 ← (byte) main::ch#2
  [30] call keyboard_get_keycode 
  [31] (byte) keyboard_get_keycode::return#2 ← (byte) keyboard_get_keycode::return#0
  to:main::@29
main::@29: scope:[main]  from main::@10
  [32] (byte) main::key#0 ← (byte) keyboard_get_keycode::return#2
  [33] if((byte) main::key#0==(byte/signed byte/word/signed word/dword/signed dword) 63) goto main::@11
  to:main::@22
main::@22: scope:[main]  from main::@29
  [34] (byte) keyboard_key_pressed::key#0 ← (byte) main::key#0
  [35] call keyboard_key_pressed 
  [36] (byte) keyboard_key_pressed::return#2 ← (byte) keyboard_key_pressed::return#0
  to:main::@30
main::@30: scope:[main]  from main::@22
  [37] (byte~) main::$15 ← (byte) keyboard_key_pressed::return#2
  [38] if((byte~) main::$15==(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@11
  to:main::@23
main::@23: scope:[main]  from main::@30
  [39] *((byte*) main::screen#2 + (byte) main::i#10) ← (byte) main::ch#2
  [40] (byte) main::i#1 ← ++ (byte) main::i#10
  to:main::@11
main::@11: scope:[main]  from main::@23 main::@29 main::@30
  [41] (byte) main::i#6 ← phi( main::@30/(byte) main::i#10 main::@23/(byte) main::i#1 main::@29/(byte) main::i#10 )
  [42] (byte) main::ch#1 ← ++ (byte) main::ch#2
  [43] if((byte) main::ch#1!=(byte/signed byte/word/signed word/dword/signed dword) 64) goto main::@10
  to:main::@13
main::@13: scope:[main]  from main::@11 main::@13
  [44] (byte) main::i#4 ← phi( main::@11/(byte) main::i#6 main::@13/(byte) main::i#2 )
  [45] *((byte*) main::screen#2 + (byte) main::i#4) ← (byte) ' '
  [46] (byte) main::i#2 ← ++ (byte) main::i#4
  [47] if((byte) main::i#2<(byte/signed byte/word/signed word/dword/signed dword) 5) goto main::@13
  to:main::@5
main::@8: scope:[main]  from main::@7
  [48] *((byte*) main::screen#13 + (byte) main::col#2) ← (byte) '1'
  to:main::@9
keyboard_key_pressed: scope:[keyboard_key_pressed]  from main::@22
  [49] (byte) keyboard_key_pressed::colidx#0 ← (byte) keyboard_key_pressed::key#0 & (byte/signed byte/word/signed word/dword/signed dword) 7
  [50] (byte) keyboard_key_pressed::rowidx#0 ← (byte) keyboard_key_pressed::key#0 >> (byte/signed byte/word/signed word/dword/signed dword) 3
  [51] (byte) keyboard_matrix_read::rowid#0 ← (byte) keyboard_key_pressed::rowidx#0
  [52] call keyboard_matrix_read 
  [53] (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
  [54] (byte~) keyboard_key_pressed::$2 ← (byte) keyboard_matrix_read::return#2
  [55] (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
  [56] return 
  to:@return
keyboard_matrix_read: scope:[keyboard_matrix_read]  from keyboard_key_pressed main::@6
  [57] (byte) keyboard_matrix_read::rowid#2 ← phi( keyboard_key_pressed/(byte) keyboard_matrix_read::rowid#0 main::@6/(byte) keyboard_matrix_read::rowid#1 )
  [58] *((const byte*) CIA1_PORT_A#0) ← *((const byte[8]) keyboard_matrix_row_bitmask#0 + (byte) keyboard_matrix_read::rowid#2)
  [59] (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
  [60] return 
  to:@return
keyboard_get_keycode: scope:[keyboard_get_keycode]  from main::@10
  [61] (byte) keyboard_get_keycode::return#0 ← *((const byte[]) keyboard_char_keycodes#0 + (byte) keyboard_get_keycode::ch#0)
  to:keyboard_get_keycode::@return
keyboard_get_keycode::@return: scope:[keyboard_get_keycode]  from keyboard_get_keycode
  [62] return 
  to:@return
keyboard_init: scope:[keyboard_init]  from main::@14
  [63] *((const byte*) CIA1_PORT_A_DDR#0) ← (byte/word/signed word/dword/signed dword) 255
  [64] *((const byte*) CIA1_PORT_B_DDR#0) ← (byte/signed byte/word/signed word/dword/signed dword) 0
  to:keyboard_init::@return
keyboard_init::@return: scope:[keyboard_init]  from keyboard_init
  [65] return 
  to:@return


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*) 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_get_keycode((byte) keyboard_get_keycode::ch)
(byte) keyboard_get_keycode::ch
(byte) keyboard_get_keycode::ch#0 103.0
(byte) keyboard_get_keycode::return
(byte) keyboard_get_keycode::return#0 34.33333333333333
(byte) keyboard_get_keycode::return#2 202.0
(void()) keyboard_init()
(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#0 52.5
(byte) keyboard_key_pressed::return
(byte) keyboard_key_pressed::return#0 34.33333333333333
(byte) keyboard_key_pressed::return#2 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 26.25
(byte) keyboard_matrix_read::return#2 4.0
(byte) keyboard_matrix_read::return#3 202.0
(byte) keyboard_matrix_read::row_pressed_bits
(byte) keyboard_matrix_read::rowid
(byte) keyboard_matrix_read::rowid#0 4.0
(byte) keyboard_matrix_read::rowid#1 202.0
(byte) keyboard_matrix_read::rowid#2 105.0
(byte[8]) keyboard_matrix_row_bitmask
(byte) keyboard_modifiers
(byte[8]) keyboard_scan_values
(void()) main()
(byte~) main::$15 202.0
(byte~) main::$5 2002.0
(byte) main::ch
(byte) main::ch#1 151.5
(byte) main::ch#2 28.857142857142858
(byte) main::col
(byte) main::col#1 1501.5
(byte) main::col#2 667.3333333333334
(byte) main::i
(byte) main::i#1 202.0
(byte) main::i#10 42.08333333333333
(byte) main::i#2 151.5
(byte) main::i#4 202.0
(byte) main::i#6 168.33333333333331
(byte) main::key
(byte) main::key#0 151.5
(byte) main::row
(byte) main::row#1 151.5
(byte) main::row#2 21.642857142857142
(byte) main::row_pressed_bits
(byte) main::row_pressed_bits#0 202.0
(byte) main::row_pressed_bits#1 667.3333333333334
(byte) main::row_pressed_bits#2 620.8
(byte*) main::sc
(byte*) main::sc#1 16.5
(byte*) main::sc#2 16.5
(byte*) main::screen
(byte*) main::screen#1 71.0
(byte*) main::screen#13 169.53846153846155
(byte*) main::screen#2 10.142857142857142

Initial phi equivalence classes
[ main::sc#2 main::sc#1 ]
[ main::row#2 main::row#1 ]
[ main::screen#13 main::screen#1 ]
[ main::row_pressed_bits#2 main::row_pressed_bits#0 main::row_pressed_bits#1 ]
[ main::col#2 main::col#1 ]
[ main::ch#2 main::ch#1 ]
[ main::i#4 main::i#10 main::i#6 main::i#1 main::i#2 ]
[ keyboard_matrix_read::rowid#2 keyboard_matrix_read::rowid#0 keyboard_matrix_read::rowid#1 ]
Added variable keyboard_matrix_read::return#3 to zero page equivalence class [ keyboard_matrix_read::return#3 ]
Added variable main::$5 to zero page equivalence class [ main::$5 ]
Added variable main::screen#2 to zero page equivalence class [ main::screen#2 ]
Added variable keyboard_get_keycode::ch#0 to zero page equivalence class [ keyboard_get_keycode::ch#0 ]
Added variable keyboard_get_keycode::return#2 to zero page equivalence class [ keyboard_get_keycode::return#2 ]
Added variable main::key#0 to zero page equivalence class [ main::key#0 ]
Added variable keyboard_key_pressed::key#0 to zero page equivalence class [ keyboard_key_pressed::key#0 ]
Added variable keyboard_key_pressed::return#2 to zero page equivalence class [ keyboard_key_pressed::return#2 ]
Added variable main::$15 to zero page equivalence class [ main::$15 ]
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::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_get_keycode::return#0 to zero page equivalence class [ keyboard_get_keycode::return#0 ]
Complete equivalence classes
[ main::sc#2 main::sc#1 ]
[ main::row#2 main::row#1 ]
[ main::screen#13 main::screen#1 ]
[ main::row_pressed_bits#2 main::row_pressed_bits#0 main::row_pressed_bits#1 ]
[ main::col#2 main::col#1 ]
[ main::ch#2 main::ch#1 ]
[ main::i#4 main::i#10 main::i#6 main::i#1 main::i#2 ]
[ keyboard_matrix_read::rowid#2 keyboard_matrix_read::rowid#0 keyboard_matrix_read::rowid#1 ]
[ keyboard_matrix_read::return#3 ]
[ main::$5 ]
[ main::screen#2 ]
[ keyboard_get_keycode::ch#0 ]
[ keyboard_get_keycode::return#2 ]
[ main::key#0 ]
[ keyboard_key_pressed::key#0 ]
[ keyboard_key_pressed::return#2 ]
[ main::$15 ]
[ keyboard_key_pressed::colidx#0 ]
[ keyboard_key_pressed::rowidx#0 ]
[ keyboard_matrix_read::return#2 ]
[ keyboard_key_pressed::$2 ]
[ keyboard_key_pressed::return#0 ]
[ keyboard_matrix_read::return#0 ]
[ keyboard_get_keycode::return#0 ]
Allocated zp ZP_WORD:2 [ main::sc#2 main::sc#1 ]
Allocated zp ZP_BYTE:4 [ main::row#2 main::row#1 ]
Allocated zp ZP_WORD:5 [ main::screen#13 main::screen#1 ]
Allocated zp ZP_BYTE:7 [ main::row_pressed_bits#2 main::row_pressed_bits#0 main::row_pressed_bits#1 ]
Allocated zp ZP_BYTE:8 [ main::col#2 main::col#1 ]
Allocated zp ZP_BYTE:9 [ main::ch#2 main::ch#1 ]
Allocated zp ZP_BYTE:10 [ main::i#4 main::i#10 main::i#6 main::i#1 main::i#2 ]
Allocated zp ZP_BYTE:11 [ keyboard_matrix_read::rowid#2 keyboard_matrix_read::rowid#0 keyboard_matrix_read::rowid#1 ]
Allocated zp ZP_BYTE:12 [ keyboard_matrix_read::return#3 ]
Allocated zp ZP_BYTE:13 [ main::$5 ]
Allocated zp ZP_WORD:14 [ main::screen#2 ]
Allocated zp ZP_BYTE:16 [ keyboard_get_keycode::ch#0 ]
Allocated zp ZP_BYTE:17 [ keyboard_get_keycode::return#2 ]
Allocated zp ZP_BYTE:18 [ main::key#0 ]
Allocated zp ZP_BYTE:19 [ keyboard_key_pressed::key#0 ]
Allocated zp ZP_BYTE:20 [ keyboard_key_pressed::return#2 ]
Allocated zp ZP_BYTE:21 [ main::$15 ]
Allocated zp ZP_BYTE:22 [ keyboard_key_pressed::colidx#0 ]
Allocated zp ZP_BYTE:23 [ keyboard_key_pressed::rowidx#0 ]
Allocated zp ZP_BYTE:24 [ keyboard_matrix_read::return#2 ]
Allocated zp ZP_BYTE:25 [ keyboard_key_pressed::$2 ]
Allocated zp ZP_BYTE:26 [ keyboard_key_pressed::return#0 ]
Allocated zp ZP_BYTE:27 [ keyboard_matrix_read::return#0 ]
Allocated zp ZP_BYTE:28 [ keyboard_get_keycode::return#0 ]

INITIAL ASM
//SEG0 File Comments
// Test keyboard input - in the keyboard matrix and mapping screen codes to key codes
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label RASTER = $d012
  // 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
  // CIA #1 Port A data direction register.
  .label CIA1_PORT_A_DDR = $dc02
  // CIA #1 Port B data direction register.
  .label CIA1_PORT_B_DDR = $dc03
  .const KEY_3 = 8
  .const KEY_W = 9
  .const KEY_A = $a
  .const KEY_4 = $b
  .const KEY_Z = $c
  .const KEY_S = $d
  .const KEY_E = $e
  .const KEY_5 = $10
  .const KEY_R = $11
  .const KEY_D = $12
  .const KEY_6 = $13
  .const KEY_C = $14
  .const KEY_F = $15
  .const KEY_T = $16
  .const KEY_X = $17
  .const KEY_7 = $18
  .const KEY_Y = $19
  .const KEY_G = $1a
  .const KEY_8 = $1b
  .const KEY_B = $1c
  .const KEY_H = $1d
  .const KEY_U = $1e
  .const KEY_V = $1f
  .const KEY_9 = $20
  .const KEY_I = $21
  .const KEY_J = $22
  .const KEY_0 = $23
  .const KEY_M = $24
  .const KEY_K = $25
  .const KEY_O = $26
  .const KEY_N = $27
  .const KEY_PLUS = $28
  .const KEY_P = $29
  .const KEY_L = $2a
  .const KEY_MINUS = $2b
  .const KEY_DOT = $2c
  .const KEY_COLON = $2d
  .const KEY_AT = $2e
  .const KEY_COMMA = $2f
  .const KEY_POUND = $30
  .const KEY_ASTERISK = $31
  .const KEY_SEMICOLON = $32
  .const KEY_EQUALS = $35
  .const KEY_ARROW_UP = $36
  .const KEY_SLASH = $37
  .const KEY_1 = $38
  .const KEY_ARROW_LEFT = $39
  .const KEY_2 = $3b
  .const KEY_SPACE = $3c
  .const KEY_Q = $3e
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @12 [phi:@begin->@12]
b12_from_bbegin:
  jmp b12
//SEG5 @12
b12:
//SEG6 [2] call main 
//SEG7 [4] phi from @12 to main [phi:@12->main]
main_from_b12:
  jsr main
//SEG8 [3] phi from @12 to @end [phi:@12->@end]
bend_from_b12:
  jmp bend
//SEG9 @end
bend:
//SEG10 main
main: {
    .label _5 = $d
    .label _15 = $15
    .label sc = 2
    .label row_pressed_bits = 7
    .label col = 8
    .label screen = 5
    .label row = 4
    .label screen_2 = $e
    .label key = $12
    .label ch = 9
    .label i = $a
  //SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
  //SEG12 [5] phi (byte*) main::sc#2 = ((byte*))(word/signed word/dword/signed dword) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<$400
    sta sc
    lda #>$400
    sta sc+1
    jmp b1
  // Clear screen
  //SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
  //SEG14 [5] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
  //SEG15 main::@1
  b1:
  //SEG16 [6] *((byte*) main::sc#2) ← (byte) ' ' -- _deref_pbuz1=vbuc1 
    lda #' '
    ldy #0
    sta (sc),y
  //SEG17 [7] (byte*) main::sc#1 ← ++ (byte*) main::sc#2 -- pbuz1=_inc_pbuz1 
    inc sc
    bne !+
    inc sc+1
  !:
  //SEG18 [8] if((byte*) main::sc#1<(word/signed word/dword/signed dword) 1024+(word/signed word/dword/signed dword) 1000) goto main::@1 -- pbuz1_lt_vwuc1_then_la1 
    lda sc+1
    cmp #>$400+$3e8
    bcc b1_from_b1
    bne !+
    lda sc
    cmp #<$400+$3e8
    bcc b1_from_b1
  !:
  //SEG19 [9] phi from main::@1 to main::@14 [phi:main::@1->main::@14]
  b14_from_b1:
    jmp b14
  //SEG20 main::@14
  b14:
  //SEG21 [10] call keyboard_init 
    jsr keyboard_init
    jmp b5
  //SEG22 main::@5
  b5:
  //SEG23 [11] if(*((const byte*) RASTER#0)!=(byte/word/signed word/dword/signed dword) 255) goto main::@5 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda RASTER
    cmp #$ff
    bne b5
  //SEG24 [12] phi from main::@5 to main::@6 [phi:main::@5->main::@6]
  b6_from_b5:
  //SEG25 [12] phi (byte*) main::screen#13 = ((byte*))(word/signed word/dword/signed dword) 1024 [phi:main::@5->main::@6#0] -- pbuz1=pbuc1 
    lda #<$400
    sta screen
    lda #>$400
    sta screen+1
  //SEG26 [12] phi (byte) main::row#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@5->main::@6#1] -- vbuz1=vbuc1 
    lda #0
    sta row
    jmp b6
  // Read & print keyboard matrix
  //SEG27 [12] phi from main::@20 to main::@6 [phi:main::@20->main::@6]
  b6_from_b20:
  //SEG28 [12] phi (byte*) main::screen#13 = (byte*) main::screen#1 [phi:main::@20->main::@6#0] -- register_copy 
  //SEG29 [12] phi (byte) main::row#2 = (byte) main::row#1 [phi:main::@20->main::@6#1] -- register_copy 
    jmp b6
  //SEG30 main::@6
  b6:
  //SEG31 [13] (byte) keyboard_matrix_read::rowid#1 ← (byte) main::row#2 -- vbuz1=vbuz2 
    lda row
    sta keyboard_matrix_read.rowid
  //SEG32 [14] call keyboard_matrix_read 
  //SEG33 [57] phi from main::@6 to keyboard_matrix_read [phi:main::@6->keyboard_matrix_read]
  keyboard_matrix_read_from_b6:
  //SEG34 [57] phi (byte) keyboard_matrix_read::rowid#2 = (byte) keyboard_matrix_read::rowid#1 [phi:main::@6->keyboard_matrix_read#0] -- register_copy 
    jsr keyboard_matrix_read
  //SEG35 [15] (byte) keyboard_matrix_read::return#3 ← (byte) keyboard_matrix_read::return#0 -- vbuz1=vbuz2 
    lda keyboard_matrix_read.return
    sta keyboard_matrix_read.return_3
    jmp b28
  //SEG36 main::@28
  b28:
  //SEG37 [16] (byte) main::row_pressed_bits#0 ← (byte) keyboard_matrix_read::return#3 -- vbuz1=vbuz2 
    lda keyboard_matrix_read.return_3
    sta row_pressed_bits
  //SEG38 [17] phi from main::@28 to main::@7 [phi:main::@28->main::@7]
  b7_from_b28:
  //SEG39 [17] phi (byte) main::col#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@28->main::@7#0] -- vbuz1=vbuc1 
    lda #0
    sta col
  //SEG40 [17] phi (byte) main::row_pressed_bits#2 = (byte) main::row_pressed_bits#0 [phi:main::@28->main::@7#1] -- register_copy 
    jmp b7
  //SEG41 [17] phi from main::@9 to main::@7 [phi:main::@9->main::@7]
  b7_from_b9:
  //SEG42 [17] phi (byte) main::col#2 = (byte) main::col#1 [phi:main::@9->main::@7#0] -- register_copy 
  //SEG43 [17] phi (byte) main::row_pressed_bits#2 = (byte) main::row_pressed_bits#1 [phi:main::@9->main::@7#1] -- register_copy 
    jmp b7
  //SEG44 main::@7
  b7:
  //SEG45 [18] (byte~) main::$5 ← (byte) main::row_pressed_bits#2 & (byte/word/signed word/dword/signed dword) 128 -- vbuz1=vbuz2_band_vbuc1 
    lda #$80
    and row_pressed_bits
    sta _5
  //SEG46 [19] if((byte~) main::$5!=(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@8 -- vbuz1_neq_0_then_la1 
    lda _5
    cmp #0
    bne b8
    jmp b18
  //SEG47 main::@18
  b18:
  //SEG48 [20] *((byte*) main::screen#13 + (byte) main::col#2) ← (byte) '0' -- pbuz1_derefidx_vbuz2=vbuc1 
    lda #'0'
    ldy col
    sta (screen),y
    jmp b9
  //SEG49 main::@9
  b9:
  //SEG50 [21] (byte) main::row_pressed_bits#1 ← (byte) main::row_pressed_bits#2 << (byte/signed byte/word/signed word/dword/signed dword) 1 -- vbuz1=vbuz1_rol_1 
    asl row_pressed_bits
  //SEG51 [22] (byte) main::col#1 ← ++ (byte) main::col#2 -- vbuz1=_inc_vbuz1 
    inc col
  //SEG52 [23] if((byte) main::col#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@7 -- vbuz1_neq_vbuc1_then_la1 
    lda col
    cmp #8
    bne b7_from_b9
    jmp b20
  //SEG53 main::@20
  b20:
  //SEG54 [24] (byte*) main::screen#1 ← (byte*) main::screen#13 + (byte/signed byte/word/signed word/dword/signed dword) 40 -- pbuz1=pbuz1_plus_vbuc1 
    lda screen
    clc
    adc #$28
    sta screen
    bcc !+
    inc screen+1
  !:
  //SEG55 [25] (byte) main::row#1 ← ++ (byte) main::row#2 -- vbuz1=_inc_vbuz1 
    inc row
  //SEG56 [26] if((byte) main::row#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@6 -- vbuz1_neq_vbuc1_then_la1 
    lda row
    cmp #8
    bne b6_from_b20
    jmp b21
  //SEG57 main::@21
  b21:
  //SEG58 [27] (byte*) main::screen#2 ← (byte*) main::screen#1 + (byte/signed byte/word/signed word/dword/signed dword) 40 -- pbuz1=pbuz2_plus_vbuc1 
    lda #$28
    clc
    adc screen
    sta screen_2
    lda #0
    adc screen+1
    sta screen_2+1
  //SEG59 [28] phi from main::@21 to main::@10 [phi:main::@21->main::@10]
  b10_from_b21:
  //SEG60 [28] phi (byte) main::i#10 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@21->main::@10#0] -- vbuz1=vbuc1 
    lda #0
    sta i
  //SEG61 [28] phi (byte) main::ch#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@21->main::@10#1] -- vbuz1=vbuc1 
    lda #0
    sta ch
    jmp b10
  //SEG62 [28] phi from main::@11 to main::@10 [phi:main::@11->main::@10]
  b10_from_b11:
  //SEG63 [28] phi (byte) main::i#10 = (byte) main::i#6 [phi:main::@11->main::@10#0] -- register_copy 
  //SEG64 [28] phi (byte) main::ch#2 = (byte) main::ch#1 [phi:main::@11->main::@10#1] -- register_copy 
    jmp b10
  //SEG65 main::@10
  b10:
  //SEG66 [29] (byte) keyboard_get_keycode::ch#0 ← (byte) main::ch#2 -- vbuz1=vbuz2 
    lda ch
    sta keyboard_get_keycode.ch
  //SEG67 [30] call keyboard_get_keycode 
    jsr keyboard_get_keycode
  //SEG68 [31] (byte) keyboard_get_keycode::return#2 ← (byte) keyboard_get_keycode::return#0 -- vbuz1=vbuz2 
    lda keyboard_get_keycode.return
    sta keyboard_get_keycode.return_2
    jmp b29
  //SEG69 main::@29
  b29:
  //SEG70 [32] (byte) main::key#0 ← (byte) keyboard_get_keycode::return#2 -- vbuz1=vbuz2 
    lda keyboard_get_keycode.return_2
    sta key
  //SEG71 [33] if((byte) main::key#0==(byte/signed byte/word/signed word/dword/signed dword) 63) goto main::@11 -- vbuz1_eq_vbuc1_then_la1 
    lda key
    cmp #$3f
    beq b11_from_b29
    jmp b22
  //SEG72 main::@22
  b22:
  //SEG73 [34] (byte) keyboard_key_pressed::key#0 ← (byte) main::key#0 -- vbuz1=vbuz2 
    lda key
    sta keyboard_key_pressed.key
  //SEG74 [35] call keyboard_key_pressed 
    jsr keyboard_key_pressed
  //SEG75 [36] (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 b30
  //SEG76 main::@30
  b30:
  //SEG77 [37] (byte~) main::$15 ← (byte) keyboard_key_pressed::return#2 -- vbuz1=vbuz2 
    lda keyboard_key_pressed.return_2
    sta _15
  //SEG78 [38] if((byte~) main::$15==(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@11 -- vbuz1_eq_0_then_la1 
    lda _15
    cmp #0
    beq b11_from_b30
    jmp b23
  //SEG79 main::@23
  b23:
  //SEG80 [39] *((byte*) main::screen#2 + (byte) main::i#10) ← (byte) main::ch#2 -- pbuz1_derefidx_vbuz2=vbuz3 
    lda ch
    ldy i
    sta (screen_2),y
  //SEG81 [40] (byte) main::i#1 ← ++ (byte) main::i#10 -- vbuz1=_inc_vbuz1 
    inc i
  //SEG82 [41] phi from main::@23 main::@29 main::@30 to main::@11 [phi:main::@23/main::@29/main::@30->main::@11]
  b11_from_b23:
  b11_from_b29:
  b11_from_b30:
  //SEG83 [41] phi (byte) main::i#6 = (byte) main::i#1 [phi:main::@23/main::@29/main::@30->main::@11#0] -- register_copy 
    jmp b11
  //SEG84 main::@11
  b11:
  //SEG85 [42] (byte) main::ch#1 ← ++ (byte) main::ch#2 -- vbuz1=_inc_vbuz1 
    inc ch
  //SEG86 [43] if((byte) main::ch#1!=(byte/signed byte/word/signed word/dword/signed dword) 64) goto main::@10 -- vbuz1_neq_vbuc1_then_la1 
    lda ch
    cmp #$40
    bne b10_from_b11
  //SEG87 [44] phi from main::@11 main::@13 to main::@13 [phi:main::@11/main::@13->main::@13]
  b13_from_b11:
  b13_from_b13:
  //SEG88 [44] phi (byte) main::i#4 = (byte) main::i#6 [phi:main::@11/main::@13->main::@13#0] -- register_copy 
    jmp b13
  // Add some spaces
  //SEG89 main::@13
  b13:
  //SEG90 [45] *((byte*) main::screen#2 + (byte) main::i#4) ← (byte) ' ' -- pbuz1_derefidx_vbuz2=vbuc1 
    lda #' '
    ldy i
    sta (screen_2),y
  //SEG91 [46] (byte) main::i#2 ← ++ (byte) main::i#4 -- vbuz1=_inc_vbuz1 
    inc i
  //SEG92 [47] if((byte) main::i#2<(byte/signed byte/word/signed word/dword/signed dword) 5) goto main::@13 -- vbuz1_lt_vbuc1_then_la1 
    lda i
    cmp #5
    bcc b13_from_b13
    jmp b5
  //SEG93 main::@8
  b8:
  //SEG94 [48] *((byte*) main::screen#13 + (byte) main::col#2) ← (byte) '1' -- pbuz1_derefidx_vbuz2=vbuc1 
    lda #'1'
    ldy col
    sta (screen),y
    jmp b9
}
//SEG95 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($13) key)
keyboard_key_pressed: {
    .label _2 = $19
    .label colidx = $16
    .label rowidx = $17
    .label return = $1a
    .label key = $13
    .label return_2 = $14
  //SEG96 [49] (byte) keyboard_key_pressed::colidx#0 ← (byte) keyboard_key_pressed::key#0 & (byte/signed byte/word/signed word/dword/signed dword) 7 -- vbuz1=vbuz2_band_vbuc1 
    lda #7
    and key
    sta colidx
  //SEG97 [50] (byte) keyboard_key_pressed::rowidx#0 ← (byte) keyboard_key_pressed::key#0 >> (byte/signed byte/word/signed word/dword/signed dword) 3 -- vbuz1=vbuz2_ror_3 
    lda key
    lsr
    lsr
    lsr
    sta rowidx
  //SEG98 [51] (byte) keyboard_matrix_read::rowid#0 ← (byte) keyboard_key_pressed::rowidx#0 -- vbuz1=vbuz2 
    lda rowidx
    sta keyboard_matrix_read.rowid
  //SEG99 [52] call keyboard_matrix_read 
  //SEG100 [57] phi from keyboard_key_pressed to keyboard_matrix_read [phi:keyboard_key_pressed->keyboard_matrix_read]
  keyboard_matrix_read_from_keyboard_key_pressed:
  //SEG101 [57] phi (byte) keyboard_matrix_read::rowid#2 = (byte) keyboard_matrix_read::rowid#0 [phi:keyboard_key_pressed->keyboard_matrix_read#0] -- register_copy 
    jsr keyboard_matrix_read
  //SEG102 [53] (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
  //SEG103 keyboard_key_pressed::@2
  b2:
  //SEG104 [54] (byte~) keyboard_key_pressed::$2 ← (byte) keyboard_matrix_read::return#2 -- vbuz1=vbuz2 
    lda keyboard_matrix_read.return_2
    sta _2
  //SEG105 [55] (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
  //SEG106 keyboard_key_pressed::@return
  breturn:
  //SEG107 [56] return 
    rts
}
//SEG108 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 = $1b
    .label rowid = $b
    .label return_2 = $18
    .label return_3 = $c
  //SEG109 [58] *((const byte*) CIA1_PORT_A#0) ← *((const byte[8]) keyboard_matrix_row_bitmask#0 + (byte) keyboard_matrix_read::rowid#2) -- _deref_pbuc1=pbuc2_derefidx_vbuz1 
    ldy rowid
    lda keyboard_matrix_row_bitmask,y
    sta CIA1_PORT_A
  //SEG110 [59] (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
  //SEG111 keyboard_matrix_read::@return
  breturn:
  //SEG112 [60] return 
    rts
}
//SEG113 keyboard_get_keycode
// Get the keycode corresponding to a specific screen code character
// ch is the character to get the key code for ($00-$3f)
// Returns the key code corresponding to the passed character. Only characters with a non-shifted key are handled.
// If there is no non-shifted key representing the char $3f is returned (representing RUN/STOP) .
// keyboard_get_keycode(byte zeropage($10) ch)
keyboard_get_keycode: {
    .label return = $1c
    .label ch = $10
    .label return_2 = $11
  //SEG114 [61] (byte) keyboard_get_keycode::return#0 ← *((const byte[]) keyboard_char_keycodes#0 + (byte) keyboard_get_keycode::ch#0) -- vbuz1=pbuc1_derefidx_vbuz2 
    ldy ch
    lda keyboard_char_keycodes,y
    sta return
    jmp breturn
  //SEG115 keyboard_get_keycode::@return
  breturn:
  //SEG116 [62] return 
    rts
}
//SEG117 keyboard_init
// Initialize keyboard reading by setting CIA#$ Data Direction Registers
keyboard_init: {
  //SEG118 [63] *((const byte*) CIA1_PORT_A_DDR#0) ← (byte/word/signed word/dword/signed dword) 255 -- _deref_pbuc1=vbuc2 
    // Keyboard Matrix Columns Write Mode
    lda #$ff
    sta CIA1_PORT_A_DDR
  //SEG119 [64] *((const byte*) CIA1_PORT_B_DDR#0) ← (byte/signed byte/word/signed word/dword/signed dword) 0 -- _deref_pbuc1=vbuc2 
    // Keyboard Matrix Columns Read Mode
    lda #0
    sta CIA1_PORT_B_DDR
    jmp breturn
  //SEG120 keyboard_init::@return
  breturn:
  //SEG121 [65] 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
  // Keycodes for each screen code character from $00-$3f.
  // Chars that do not have an unmodified keycode return $3f (representing RUN/STOP).
  keyboard_char_keycodes: .byte KEY_AT, KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, $3f, KEY_POUND, $3f, KEY_ARROW_UP, KEY_ARROW_LEFT, KEY_SPACE, $3f, $3f, $3f, $3f, $3f, $3f, $3f, $3f, $3f, KEY_ASTERISK, KEY_PLUS, KEY_COMMA, KEY_MINUS, KEY_DOT, KEY_SLASH, KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_COLON, KEY_SEMICOLON, $3f, KEY_EQUALS, $3f, $3f

REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] *((byte*) main::sc#2) ← (byte) ' ' [ main::sc#2 ] ( main:2 [ main::sc#2 ] ) always clobbers reg byte a reg byte y 
Statement [8] if((byte*) main::sc#1<(word/signed word/dword/signed dword) 1024+(word/signed word/dword/signed dword) 1000) goto main::@1 [ main::sc#1 ] ( main:2 [ main::sc#1 ] ) always clobbers reg byte a 
Statement [11] if(*((const byte*) RASTER#0)!=(byte/word/signed word/dword/signed dword) 255) goto main::@5 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [18] (byte~) main::$5 ← (byte) main::row_pressed_bits#2 & (byte/word/signed word/dword/signed dword) 128 [ main::row#2 main::screen#13 main::row_pressed_bits#2 main::col#2 main::$5 ] ( main:2 [ main::row#2 main::screen#13 main::row_pressed_bits#2 main::col#2 main::$5 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:4 [ main::row#2 main::row#1 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:7 [ main::row_pressed_bits#2 main::row_pressed_bits#0 main::row_pressed_bits#1 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:8 [ main::col#2 main::col#1 ]
Statement [20] *((byte*) main::screen#13 + (byte) main::col#2) ← (byte) '0' [ main::row#2 main::screen#13 main::row_pressed_bits#2 main::col#2 ] ( main:2 [ main::row#2 main::screen#13 main::row_pressed_bits#2 main::col#2 ] ) always clobbers reg byte a 
Statement [24] (byte*) main::screen#1 ← (byte*) main::screen#13 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::row#2 main::screen#1 ] ( main:2 [ main::row#2 main::screen#1 ] ) always clobbers reg byte a 
Statement [27] (byte*) main::screen#2 ← (byte*) main::screen#1 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::screen#2 ] ( main:2 [ main::screen#2 ] ) always clobbers reg byte a 
Statement [45] *((byte*) main::screen#2 + (byte) main::i#4) ← (byte) ' ' [ main::screen#2 main::i#4 ] ( main:2 [ main::screen#2 main::i#4 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:10 [ main::i#4 main::i#10 main::i#6 main::i#1 main::i#2 ]
Statement [48] *((byte*) main::screen#13 + (byte) main::col#2) ← (byte) '1' [ main::row#2 main::screen#13 main::row_pressed_bits#2 main::col#2 ] ( main:2 [ main::row#2 main::screen#13 main::row_pressed_bits#2 main::col#2 ] ) always clobbers reg byte a 
Statement [49] (byte) keyboard_key_pressed::colidx#0 ← (byte) keyboard_key_pressed::key#0 & (byte/signed byte/word/signed word/dword/signed dword) 7 [ keyboard_key_pressed::key#0 keyboard_key_pressed::colidx#0 ] ( main:2::keyboard_key_pressed:35 [ main::screen#2 main::ch#2 main::i#10 keyboard_key_pressed::key#0 keyboard_key_pressed::colidx#0 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:9 [ main::ch#2 main::ch#1 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:19 [ keyboard_key_pressed::key#0 ]
Statement [50] (byte) keyboard_key_pressed::rowidx#0 ← (byte) keyboard_key_pressed::key#0 >> (byte/signed byte/word/signed word/dword/signed dword) 3 [ keyboard_key_pressed::colidx#0 keyboard_key_pressed::rowidx#0 ] ( main:2::keyboard_key_pressed:35 [ main::screen#2 main::ch#2 main::i#10 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:22 [ keyboard_key_pressed::colidx#0 ]
Statement [55] (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::keyboard_key_pressed:35 [ main::screen#2 main::ch#2 main::i#10 keyboard_key_pressed::return#0 ] ) always clobbers reg byte a 
Statement [58] *((const byte*) CIA1_PORT_A#0) ← *((const byte[8]) keyboard_matrix_row_bitmask#0 + (byte) keyboard_matrix_read::rowid#2) [ ] ( main:2::keyboard_matrix_read:14 [ main::row#2 main::screen#13 ] main:2::keyboard_key_pressed:35::keyboard_matrix_read:52 [ main::screen#2 main::ch#2 main::i#10 keyboard_key_pressed::colidx#0 ] ) always clobbers reg byte a 
Statement [59] (byte) keyboard_matrix_read::return#0 ← ~ *((const byte*) CIA1_PORT_B#0) [ keyboard_matrix_read::return#0 ] ( main:2::keyboard_matrix_read:14 [ main::row#2 main::screen#13 keyboard_matrix_read::return#0 ] main:2::keyboard_key_pressed:35::keyboard_matrix_read:52 [ main::screen#2 main::ch#2 main::i#10 keyboard_key_pressed::colidx#0 keyboard_matrix_read::return#0 ] ) always clobbers reg byte a 
Statement [63] *((const byte*) CIA1_PORT_A_DDR#0) ← (byte/word/signed word/dword/signed dword) 255 [ ] ( main:2::keyboard_init:10 [ ] ) always clobbers reg byte a 
Statement [64] *((const byte*) CIA1_PORT_B_DDR#0) ← (byte/signed byte/word/signed word/dword/signed dword) 0 [ ] ( main:2::keyboard_init:10 [ ] ) always clobbers reg byte a 
Statement [6] *((byte*) main::sc#2) ← (byte) ' ' [ main::sc#2 ] ( main:2 [ main::sc#2 ] ) always clobbers reg byte a reg byte y 
Statement [8] if((byte*) main::sc#1<(word/signed word/dword/signed dword) 1024+(word/signed word/dword/signed dword) 1000) goto main::@1 [ main::sc#1 ] ( main:2 [ main::sc#1 ] ) always clobbers reg byte a 
Statement [11] if(*((const byte*) RASTER#0)!=(byte/word/signed word/dword/signed dword) 255) goto main::@5 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [18] (byte~) main::$5 ← (byte) main::row_pressed_bits#2 & (byte/word/signed word/dword/signed dword) 128 [ main::row#2 main::screen#13 main::row_pressed_bits#2 main::col#2 main::$5 ] ( main:2 [ main::row#2 main::screen#13 main::row_pressed_bits#2 main::col#2 main::$5 ] ) always clobbers reg byte a 
Statement [20] *((byte*) main::screen#13 + (byte) main::col#2) ← (byte) '0' [ main::row#2 main::screen#13 main::row_pressed_bits#2 main::col#2 ] ( main:2 [ main::row#2 main::screen#13 main::row_pressed_bits#2 main::col#2 ] ) always clobbers reg byte a 
Statement [24] (byte*) main::screen#1 ← (byte*) main::screen#13 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::row#2 main::screen#1 ] ( main:2 [ main::row#2 main::screen#1 ] ) always clobbers reg byte a 
Statement [27] (byte*) main::screen#2 ← (byte*) main::screen#1 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::screen#2 ] ( main:2 [ main::screen#2 ] ) always clobbers reg byte a 
Statement [39] *((byte*) main::screen#2 + (byte) main::i#10) ← (byte) main::ch#2 [ main::screen#2 main::ch#2 main::i#10 ] ( main:2 [ main::screen#2 main::ch#2 main::i#10 ] ) always clobbers reg byte a 
Statement [45] *((byte*) main::screen#2 + (byte) main::i#4) ← (byte) ' ' [ main::screen#2 main::i#4 ] ( main:2 [ main::screen#2 main::i#4 ] ) always clobbers reg byte a 
Statement [48] *((byte*) main::screen#13 + (byte) main::col#2) ← (byte) '1' [ main::row#2 main::screen#13 main::row_pressed_bits#2 main::col#2 ] ( main:2 [ main::row#2 main::screen#13 main::row_pressed_bits#2 main::col#2 ] ) always clobbers reg byte a 
Statement [49] (byte) keyboard_key_pressed::colidx#0 ← (byte) keyboard_key_pressed::key#0 & (byte/signed byte/word/signed word/dword/signed dword) 7 [ keyboard_key_pressed::key#0 keyboard_key_pressed::colidx#0 ] ( main:2::keyboard_key_pressed:35 [ main::screen#2 main::ch#2 main::i#10 keyboard_key_pressed::key#0 keyboard_key_pressed::colidx#0 ] ) always clobbers reg byte a 
Statement [50] (byte) keyboard_key_pressed::rowidx#0 ← (byte) keyboard_key_pressed::key#0 >> (byte/signed byte/word/signed word/dword/signed dword) 3 [ keyboard_key_pressed::colidx#0 keyboard_key_pressed::rowidx#0 ] ( main:2::keyboard_key_pressed:35 [ main::screen#2 main::ch#2 main::i#10 keyboard_key_pressed::colidx#0 keyboard_key_pressed::rowidx#0 ] ) always clobbers reg byte a 
Statement [55] (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::keyboard_key_pressed:35 [ main::screen#2 main::ch#2 main::i#10 keyboard_key_pressed::return#0 ] ) always clobbers reg byte a 
Statement [58] *((const byte*) CIA1_PORT_A#0) ← *((const byte[8]) keyboard_matrix_row_bitmask#0 + (byte) keyboard_matrix_read::rowid#2) [ ] ( main:2::keyboard_matrix_read:14 [ main::row#2 main::screen#13 ] main:2::keyboard_key_pressed:35::keyboard_matrix_read:52 [ main::screen#2 main::ch#2 main::i#10 keyboard_key_pressed::colidx#0 ] ) always clobbers reg byte a 
Statement [59] (byte) keyboard_matrix_read::return#0 ← ~ *((const byte*) CIA1_PORT_B#0) [ keyboard_matrix_read::return#0 ] ( main:2::keyboard_matrix_read:14 [ main::row#2 main::screen#13 keyboard_matrix_read::return#0 ] main:2::keyboard_key_pressed:35::keyboard_matrix_read:52 [ main::screen#2 main::ch#2 main::i#10 keyboard_key_pressed::colidx#0 keyboard_matrix_read::return#0 ] ) always clobbers reg byte a 
Statement [63] *((const byte*) CIA1_PORT_A_DDR#0) ← (byte/word/signed word/dword/signed dword) 255 [ ] ( main:2::keyboard_init:10 [ ] ) always clobbers reg byte a 
Statement [64] *((const byte*) CIA1_PORT_B_DDR#0) ← (byte/signed byte/word/signed word/dword/signed dword) 0 [ ] ( main:2::keyboard_init:10 [ ] ) always clobbers reg byte a 
Potential registers zp ZP_WORD:2 [ main::sc#2 main::sc#1 ] : zp ZP_WORD:2 , 
Potential registers zp ZP_BYTE:4 [ main::row#2 main::row#1 ] : zp ZP_BYTE:4 , reg byte x , reg byte y , 
Potential registers zp ZP_WORD:5 [ main::screen#13 main::screen#1 ] : zp ZP_WORD:5 , 
Potential registers zp ZP_BYTE:7 [ main::row_pressed_bits#2 main::row_pressed_bits#0 main::row_pressed_bits#1 ] : zp ZP_BYTE:7 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:8 [ main::col#2 main::col#1 ] : zp ZP_BYTE:8 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:9 [ main::ch#2 main::ch#1 ] : zp ZP_BYTE:9 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:10 [ main::i#4 main::i#10 main::i#6 main::i#1 main::i#2 ] : zp ZP_BYTE:10 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:11 [ keyboard_matrix_read::rowid#2 keyboard_matrix_read::rowid#0 keyboard_matrix_read::rowid#1 ] : zp ZP_BYTE:11 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:12 [ keyboard_matrix_read::return#3 ] : zp ZP_BYTE:12 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:13 [ main::$5 ] : zp ZP_BYTE:13 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_WORD:14 [ main::screen#2 ] : zp ZP_WORD:14 , 
Potential registers zp ZP_BYTE:16 [ keyboard_get_keycode::ch#0 ] : zp ZP_BYTE:16 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:17 [ keyboard_get_keycode::return#2 ] : zp ZP_BYTE:17 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:18 [ main::key#0 ] : zp ZP_BYTE:18 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:19 [ keyboard_key_pressed::key#0 ] : zp ZP_BYTE:19 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:20 [ keyboard_key_pressed::return#2 ] : zp ZP_BYTE:20 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:21 [ main::$15 ] : zp ZP_BYTE:21 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:22 [ keyboard_key_pressed::colidx#0 ] : zp ZP_BYTE:22 , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:23 [ keyboard_key_pressed::rowidx#0 ] : zp ZP_BYTE:23 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:24 [ keyboard_matrix_read::return#2 ] : zp ZP_BYTE:24 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:25 [ keyboard_key_pressed::$2 ] : zp ZP_BYTE:25 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:26 [ keyboard_key_pressed::return#0 ] : zp ZP_BYTE:26 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:27 [ keyboard_matrix_read::return#0 ] : zp ZP_BYTE:27 , reg byte a , reg byte x , reg byte y , 
Potential registers zp ZP_BYTE:28 [ keyboard_get_keycode::return#0 ] : zp ZP_BYTE:28 , reg byte a , reg byte x , reg byte y , 

REGISTER UPLIFT SCOPES
Uplift Scope [main] 2,168.83: zp ZP_BYTE:8 [ main::col#2 main::col#1 ] 2,002: zp ZP_BYTE:13 [ main::$5 ] 1,490.13: zp ZP_BYTE:7 [ main::row_pressed_bits#2 main::row_pressed_bits#0 main::row_pressed_bits#1 ] 765.92: zp ZP_BYTE:10 [ main::i#4 main::i#10 main::i#6 main::i#1 main::i#2 ] 240.54: zp ZP_WORD:5 [ main::screen#13 main::screen#1 ] 202: zp ZP_BYTE:21 [ main::$15 ] 180.36: zp ZP_BYTE:9 [ main::ch#2 main::ch#1 ] 173.14: zp ZP_BYTE:4 [ main::row#2 main::row#1 ] 151.5: zp ZP_BYTE:18 [ main::key#0 ] 33: zp ZP_WORD:2 [ main::sc#2 main::sc#1 ] 10.14: zp ZP_WORD:14 [ main::screen#2 ] 
Uplift Scope [keyboard_matrix_read] 311: zp ZP_BYTE:11 [ keyboard_matrix_read::rowid#2 keyboard_matrix_read::rowid#0 keyboard_matrix_read::rowid#1 ] 202: zp ZP_BYTE:12 [ keyboard_matrix_read::return#3 ] 26.25: zp ZP_BYTE:27 [ keyboard_matrix_read::return#0 ] 4: zp ZP_BYTE:24 [ keyboard_matrix_read::return#2 ] 
Uplift Scope [keyboard_get_keycode] 202: zp ZP_BYTE:17 [ keyboard_get_keycode::return#2 ] 103: zp ZP_BYTE:16 [ keyboard_get_keycode::ch#0 ] 34.33: zp ZP_BYTE:28 [ keyboard_get_keycode::return#0 ] 
Uplift Scope [keyboard_key_pressed] 202: zp ZP_BYTE:20 [ keyboard_key_pressed::return#2 ] 52.5: zp ZP_BYTE:19 [ keyboard_key_pressed::key#0 ] 34.33: zp ZP_BYTE:26 [ keyboard_key_pressed::return#0 ] 4: zp ZP_BYTE:23 [ keyboard_key_pressed::rowidx#0 ] 4: zp ZP_BYTE:25 [ keyboard_key_pressed::$2 ] 0.67: zp ZP_BYTE:22 [ keyboard_key_pressed::colidx#0 ] 
Uplift Scope [keyboard_init] 
Uplift Scope [] 

Uplifting [main] best 80258 combination reg byte y [ main::col#2 main::col#1 ] reg byte a [ main::$5 ] reg byte x [ main::row_pressed_bits#2 main::row_pressed_bits#0 main::row_pressed_bits#1 ] reg byte x [ main::i#4 main::i#10 main::i#6 main::i#1 main::i#2 ] zp ZP_WORD:5 [ main::screen#13 main::screen#1 ] zp ZP_BYTE:21 [ main::$15 ] zp ZP_BYTE:9 [ main::ch#2 main::ch#1 ] zp ZP_BYTE:4 [ main::row#2 main::row#1 ] zp ZP_BYTE:18 [ main::key#0 ] zp ZP_WORD:2 [ main::sc#2 main::sc#1 ] zp ZP_WORD:14 [ main::screen#2 ] 
Limited combination testing to 100 combinations of 15552 possible.
Uplifting [keyboard_matrix_read] best 79240 combination reg byte y [ keyboard_matrix_read::rowid#2 keyboard_matrix_read::rowid#0 keyboard_matrix_read::rowid#1 ] reg byte a [ keyboard_matrix_read::return#3 ] reg byte a [ keyboard_matrix_read::return#0 ] reg byte a [ keyboard_matrix_read::return#2 ] 
Limited combination testing to 100 combinations of 256 possible.
Uplifting [keyboard_get_keycode] best 78034 combination reg byte a [ keyboard_get_keycode::return#2 ] reg byte y [ keyboard_get_keycode::ch#0 ] reg byte a [ keyboard_get_keycode::return#0 ] 
Uplifting [keyboard_key_pressed] best 76825 combination reg byte a [ keyboard_key_pressed::return#2 ] reg byte y [ keyboard_key_pressed::key#0 ] reg byte a [ keyboard_key_pressed::return#0 ] reg byte a [ keyboard_key_pressed::rowidx#0 ] zp ZP_BYTE:25 [ keyboard_key_pressed::$2 ] zp ZP_BYTE:22 [ keyboard_key_pressed::colidx#0 ] 
Limited combination testing to 100 combinations of 2304 possible.
Uplifting [keyboard_init] best 76825 combination 
Uplifting [] best 76825 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:21 [ main::$15 ]
Uplifting [main] best 76225 combination reg byte a [ main::$15 ] 
Attempting to uplift remaining variables inzp ZP_BYTE:9 [ main::ch#2 main::ch#1 ]
Uplifting [main] best 76225 combination zp ZP_BYTE:9 [ main::ch#2 main::ch#1 ] 
Attempting to uplift remaining variables inzp ZP_BYTE:4 [ main::row#2 main::row#1 ]
Uplifting [main] best 76225 combination zp ZP_BYTE:4 [ main::row#2 main::row#1 ] 
Attempting to uplift remaining variables inzp ZP_BYTE:18 [ main::key#0 ]
Uplifting [main] best 75525 combination reg byte a [ main::key#0 ] 
Attempting to uplift remaining variables inzp ZP_BYTE:25 [ keyboard_key_pressed::$2 ]
Uplifting [keyboard_key_pressed] best 75519 combination reg byte a [ keyboard_key_pressed::$2 ] 
Attempting to uplift remaining variables inzp ZP_BYTE:22 [ keyboard_key_pressed::colidx#0 ]
Uplifting [keyboard_key_pressed] best 75519 combination zp ZP_BYTE:22 [ keyboard_key_pressed::colidx#0 ] 
Coalescing zero page register with common assignment [ zp ZP_WORD:5 [ main::screen#13 main::screen#1 ] ] with [ zp ZP_WORD:14 [ main::screen#2 ] ] - score: 1
Coalescing zero page register [ zp ZP_WORD:2 [ main::sc#2 main::sc#1 ] ] with [ zp ZP_WORD:5 [ main::screen#13 main::screen#1 main::screen#2 ] ]
Coalescing zero page register [ zp ZP_BYTE:4 [ main::row#2 main::row#1 ] ] with [ zp ZP_BYTE:9 [ main::ch#2 main::ch#1 ] ]
Allocated (was zp ZP_BYTE:22) zp ZP_BYTE:5 [ keyboard_key_pressed::colidx#0 ]

ASSEMBLER BEFORE OPTIMIZATION
//SEG0 File Comments
// Test keyboard input - in the keyboard matrix and mapping screen codes to key codes
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label RASTER = $d012
  // 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
  // CIA #1 Port A data direction register.
  .label CIA1_PORT_A_DDR = $dc02
  // CIA #1 Port B data direction register.
  .label CIA1_PORT_B_DDR = $dc03
  .const KEY_3 = 8
  .const KEY_W = 9
  .const KEY_A = $a
  .const KEY_4 = $b
  .const KEY_Z = $c
  .const KEY_S = $d
  .const KEY_E = $e
  .const KEY_5 = $10
  .const KEY_R = $11
  .const KEY_D = $12
  .const KEY_6 = $13
  .const KEY_C = $14
  .const KEY_F = $15
  .const KEY_T = $16
  .const KEY_X = $17
  .const KEY_7 = $18
  .const KEY_Y = $19
  .const KEY_G = $1a
  .const KEY_8 = $1b
  .const KEY_B = $1c
  .const KEY_H = $1d
  .const KEY_U = $1e
  .const KEY_V = $1f
  .const KEY_9 = $20
  .const KEY_I = $21
  .const KEY_J = $22
  .const KEY_0 = $23
  .const KEY_M = $24
  .const KEY_K = $25
  .const KEY_O = $26
  .const KEY_N = $27
  .const KEY_PLUS = $28
  .const KEY_P = $29
  .const KEY_L = $2a
  .const KEY_MINUS = $2b
  .const KEY_DOT = $2c
  .const KEY_COLON = $2d
  .const KEY_AT = $2e
  .const KEY_COMMA = $2f
  .const KEY_POUND = $30
  .const KEY_ASTERISK = $31
  .const KEY_SEMICOLON = $32
  .const KEY_EQUALS = $35
  .const KEY_ARROW_UP = $36
  .const KEY_SLASH = $37
  .const KEY_1 = $38
  .const KEY_ARROW_LEFT = $39
  .const KEY_2 = $3b
  .const KEY_SPACE = $3c
  .const KEY_Q = $3e
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @12 [phi:@begin->@12]
b12_from_bbegin:
  jmp b12
//SEG5 @12
b12:
//SEG6 [2] call main 
//SEG7 [4] phi from @12 to main [phi:@12->main]
main_from_b12:
  jsr main
//SEG8 [3] phi from @12 to @end [phi:@12->@end]
bend_from_b12:
  jmp bend
//SEG9 @end
bend:
//SEG10 main
main: {
    .label sc = 2
    .label screen = 2
    .label row = 4
    .label ch = 4
  //SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
  //SEG12 [5] phi (byte*) main::sc#2 = ((byte*))(word/signed word/dword/signed dword) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<$400
    sta sc
    lda #>$400
    sta sc+1
    jmp b1
  // Clear screen
  //SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
  //SEG14 [5] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
  //SEG15 main::@1
  b1:
  //SEG16 [6] *((byte*) main::sc#2) ← (byte) ' ' -- _deref_pbuz1=vbuc1 
    lda #' '
    ldy #0
    sta (sc),y
  //SEG17 [7] (byte*) main::sc#1 ← ++ (byte*) main::sc#2 -- pbuz1=_inc_pbuz1 
    inc sc
    bne !+
    inc sc+1
  !:
  //SEG18 [8] if((byte*) main::sc#1<(word/signed word/dword/signed dword) 1024+(word/signed word/dword/signed dword) 1000) goto main::@1 -- pbuz1_lt_vwuc1_then_la1 
    lda sc+1
    cmp #>$400+$3e8
    bcc b1_from_b1
    bne !+
    lda sc
    cmp #<$400+$3e8
    bcc b1_from_b1
  !:
  //SEG19 [9] phi from main::@1 to main::@14 [phi:main::@1->main::@14]
  b14_from_b1:
    jmp b14
  //SEG20 main::@14
  b14:
  //SEG21 [10] call keyboard_init 
    jsr keyboard_init
    jmp b5
  //SEG22 main::@5
  b5:
  //SEG23 [11] if(*((const byte*) RASTER#0)!=(byte/word/signed word/dword/signed dword) 255) goto main::@5 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda RASTER
    cmp #$ff
    bne b5
  //SEG24 [12] phi from main::@5 to main::@6 [phi:main::@5->main::@6]
  b6_from_b5:
  //SEG25 [12] phi (byte*) main::screen#13 = ((byte*))(word/signed word/dword/signed dword) 1024 [phi:main::@5->main::@6#0] -- pbuz1=pbuc1 
    lda #<$400
    sta screen
    lda #>$400
    sta screen+1
  //SEG26 [12] phi (byte) main::row#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@5->main::@6#1] -- vbuz1=vbuc1 
    lda #0
    sta row
    jmp b6
  // Read & print keyboard matrix
  //SEG27 [12] phi from main::@20 to main::@6 [phi:main::@20->main::@6]
  b6_from_b20:
  //SEG28 [12] phi (byte*) main::screen#13 = (byte*) main::screen#1 [phi:main::@20->main::@6#0] -- register_copy 
  //SEG29 [12] phi (byte) main::row#2 = (byte) main::row#1 [phi:main::@20->main::@6#1] -- register_copy 
    jmp b6
  //SEG30 main::@6
  b6:
  //SEG31 [13] (byte) keyboard_matrix_read::rowid#1 ← (byte) main::row#2 -- vbuyy=vbuz1 
    ldy row
  //SEG32 [14] call keyboard_matrix_read 
  //SEG33 [57] phi from main::@6 to keyboard_matrix_read [phi:main::@6->keyboard_matrix_read]
  keyboard_matrix_read_from_b6:
  //SEG34 [57] phi (byte) keyboard_matrix_read::rowid#2 = (byte) keyboard_matrix_read::rowid#1 [phi:main::@6->keyboard_matrix_read#0] -- register_copy 
    jsr keyboard_matrix_read
  //SEG35 [15] (byte) keyboard_matrix_read::return#3 ← (byte) keyboard_matrix_read::return#0
    jmp b28
  //SEG36 main::@28
  b28:
  //SEG37 [16] (byte) main::row_pressed_bits#0 ← (byte) keyboard_matrix_read::return#3 -- vbuxx=vbuaa 
    tax
  //SEG38 [17] phi from main::@28 to main::@7 [phi:main::@28->main::@7]
  b7_from_b28:
  //SEG39 [17] phi (byte) main::col#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@28->main::@7#0] -- vbuyy=vbuc1 
    ldy #0
  //SEG40 [17] phi (byte) main::row_pressed_bits#2 = (byte) main::row_pressed_bits#0 [phi:main::@28->main::@7#1] -- register_copy 
    jmp b7
  //SEG41 [17] phi from main::@9 to main::@7 [phi:main::@9->main::@7]
  b7_from_b9:
  //SEG42 [17] phi (byte) main::col#2 = (byte) main::col#1 [phi:main::@9->main::@7#0] -- register_copy 
  //SEG43 [17] phi (byte) main::row_pressed_bits#2 = (byte) main::row_pressed_bits#1 [phi:main::@9->main::@7#1] -- register_copy 
    jmp b7
  //SEG44 main::@7
  b7:
  //SEG45 [18] (byte~) main::$5 ← (byte) main::row_pressed_bits#2 & (byte/word/signed word/dword/signed dword) 128 -- vbuaa=vbuxx_band_vbuc1 
    txa
    and #$80
  //SEG46 [19] if((byte~) main::$5!=(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@8 -- vbuaa_neq_0_then_la1 
    cmp #0
    bne b8
    jmp b18
  //SEG47 main::@18
  b18:
  //SEG48 [20] *((byte*) main::screen#13 + (byte) main::col#2) ← (byte) '0' -- pbuz1_derefidx_vbuyy=vbuc1 
    lda #'0'
    sta (screen),y
    jmp b9
  //SEG49 main::@9
  b9:
  //SEG50 [21] (byte) main::row_pressed_bits#1 ← (byte) main::row_pressed_bits#2 << (byte/signed byte/word/signed word/dword/signed dword) 1 -- vbuxx=vbuxx_rol_1 
    txa
    asl
    tax
  //SEG51 [22] (byte) main::col#1 ← ++ (byte) main::col#2 -- vbuyy=_inc_vbuyy 
    iny
  //SEG52 [23] if((byte) main::col#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@7 -- vbuyy_neq_vbuc1_then_la1 
    cpy #8
    bne b7_from_b9
    jmp b20
  //SEG53 main::@20
  b20:
  //SEG54 [24] (byte*) main::screen#1 ← (byte*) main::screen#13 + (byte/signed byte/word/signed word/dword/signed dword) 40 -- pbuz1=pbuz1_plus_vbuc1 
    lda screen
    clc
    adc #$28
    sta screen
    bcc !+
    inc screen+1
  !:
  //SEG55 [25] (byte) main::row#1 ← ++ (byte) main::row#2 -- vbuz1=_inc_vbuz1 
    inc row
  //SEG56 [26] if((byte) main::row#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@6 -- vbuz1_neq_vbuc1_then_la1 
    lda row
    cmp #8
    bne b6_from_b20
    jmp b21
  //SEG57 main::@21
  b21:
  //SEG58 [27] (byte*) main::screen#2 ← (byte*) main::screen#1 + (byte/signed byte/word/signed word/dword/signed dword) 40 -- pbuz1=pbuz1_plus_vbuc1 
    lda screen
    clc
    adc #$28
    sta screen
    bcc !+
    inc screen+1
  !:
  //SEG59 [28] phi from main::@21 to main::@10 [phi:main::@21->main::@10]
  b10_from_b21:
  //SEG60 [28] phi (byte) main::i#10 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@21->main::@10#0] -- vbuxx=vbuc1 
    ldx #0
  //SEG61 [28] phi (byte) main::ch#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@21->main::@10#1] -- vbuz1=vbuc1 
    lda #0
    sta ch
    jmp b10
  //SEG62 [28] phi from main::@11 to main::@10 [phi:main::@11->main::@10]
  b10_from_b11:
  //SEG63 [28] phi (byte) main::i#10 = (byte) main::i#6 [phi:main::@11->main::@10#0] -- register_copy 
  //SEG64 [28] phi (byte) main::ch#2 = (byte) main::ch#1 [phi:main::@11->main::@10#1] -- register_copy 
    jmp b10
  //SEG65 main::@10
  b10:
  //SEG66 [29] (byte) keyboard_get_keycode::ch#0 ← (byte) main::ch#2 -- vbuyy=vbuz1 
    ldy ch
  //SEG67 [30] call keyboard_get_keycode 
    jsr keyboard_get_keycode
  //SEG68 [31] (byte) keyboard_get_keycode::return#2 ← (byte) keyboard_get_keycode::return#0
    jmp b29
  //SEG69 main::@29
  b29:
  //SEG70 [32] (byte) main::key#0 ← (byte) keyboard_get_keycode::return#2
  //SEG71 [33] if((byte) main::key#0==(byte/signed byte/word/signed word/dword/signed dword) 63) goto main::@11 -- vbuaa_eq_vbuc1_then_la1 
    cmp #$3f
    beq b11_from_b29
    jmp b22
  //SEG72 main::@22
  b22:
  //SEG73 [34] (byte) keyboard_key_pressed::key#0 ← (byte) main::key#0 -- vbuyy=vbuaa 
    tay
  //SEG74 [35] call keyboard_key_pressed 
    jsr keyboard_key_pressed
  //SEG75 [36] (byte) keyboard_key_pressed::return#2 ← (byte) keyboard_key_pressed::return#0
    jmp b30
  //SEG76 main::@30
  b30:
  //SEG77 [37] (byte~) main::$15 ← (byte) keyboard_key_pressed::return#2
  //SEG78 [38] if((byte~) main::$15==(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@11 -- vbuaa_eq_0_then_la1 
    cmp #0
    beq b11_from_b30
    jmp b23
  //SEG79 main::@23
  b23:
  //SEG80 [39] *((byte*) main::screen#2 + (byte) main::i#10) ← (byte) main::ch#2 -- pbuz1_derefidx_vbuxx=vbuz2 
    txa
    tay
    lda ch
    sta (screen),y
  //SEG81 [40] (byte) main::i#1 ← ++ (byte) main::i#10 -- vbuxx=_inc_vbuxx 
    inx
  //SEG82 [41] phi from main::@23 main::@29 main::@30 to main::@11 [phi:main::@23/main::@29/main::@30->main::@11]
  b11_from_b23:
  b11_from_b29:
  b11_from_b30:
  //SEG83 [41] phi (byte) main::i#6 = (byte) main::i#1 [phi:main::@23/main::@29/main::@30->main::@11#0] -- register_copy 
    jmp b11
  //SEG84 main::@11
  b11:
  //SEG85 [42] (byte) main::ch#1 ← ++ (byte) main::ch#2 -- vbuz1=_inc_vbuz1 
    inc ch
  //SEG86 [43] if((byte) main::ch#1!=(byte/signed byte/word/signed word/dword/signed dword) 64) goto main::@10 -- vbuz1_neq_vbuc1_then_la1 
    lda ch
    cmp #$40
    bne b10_from_b11
  //SEG87 [44] phi from main::@11 main::@13 to main::@13 [phi:main::@11/main::@13->main::@13]
  b13_from_b11:
  b13_from_b13:
  //SEG88 [44] phi (byte) main::i#4 = (byte) main::i#6 [phi:main::@11/main::@13->main::@13#0] -- register_copy 
    jmp b13
  // Add some spaces
  //SEG89 main::@13
  b13:
  //SEG90 [45] *((byte*) main::screen#2 + (byte) main::i#4) ← (byte) ' ' -- pbuz1_derefidx_vbuxx=vbuc1 
    txa
    tay
    lda #' '
    sta (screen),y
  //SEG91 [46] (byte) main::i#2 ← ++ (byte) main::i#4 -- vbuxx=_inc_vbuxx 
    inx
  //SEG92 [47] if((byte) main::i#2<(byte/signed byte/word/signed word/dword/signed dword) 5) goto main::@13 -- vbuxx_lt_vbuc1_then_la1 
    cpx #5
    bcc b13_from_b13
    jmp b5
  //SEG93 main::@8
  b8:
  //SEG94 [48] *((byte*) main::screen#13 + (byte) main::col#2) ← (byte) '1' -- pbuz1_derefidx_vbuyy=vbuc1 
    lda #'1'
    sta (screen),y
    jmp b9
}
//SEG95 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(Y) key)
keyboard_key_pressed: {
    .label colidx = 5
  //SEG96 [49] (byte) keyboard_key_pressed::colidx#0 ← (byte) keyboard_key_pressed::key#0 & (byte/signed byte/word/signed word/dword/signed dword) 7 -- vbuz1=vbuyy_band_vbuc1 
    tya
    and #7
    sta colidx
  //SEG97 [50] (byte) keyboard_key_pressed::rowidx#0 ← (byte) keyboard_key_pressed::key#0 >> (byte/signed byte/word/signed word/dword/signed dword) 3 -- vbuaa=vbuyy_ror_3 
    tya
    lsr
    lsr
    lsr
  //SEG98 [51] (byte) keyboard_matrix_read::rowid#0 ← (byte) keyboard_key_pressed::rowidx#0 -- vbuyy=vbuaa 
    tay
  //SEG99 [52] call keyboard_matrix_read 
  //SEG100 [57] phi from keyboard_key_pressed to keyboard_matrix_read [phi:keyboard_key_pressed->keyboard_matrix_read]
  keyboard_matrix_read_from_keyboard_key_pressed:
  //SEG101 [57] phi (byte) keyboard_matrix_read::rowid#2 = (byte) keyboard_matrix_read::rowid#0 [phi:keyboard_key_pressed->keyboard_matrix_read#0] -- register_copy 
    jsr keyboard_matrix_read
  //SEG102 [53] (byte) keyboard_matrix_read::return#2 ← (byte) keyboard_matrix_read::return#0
    jmp b2
  //SEG103 keyboard_key_pressed::@2
  b2:
  //SEG104 [54] (byte~) keyboard_key_pressed::$2 ← (byte) keyboard_matrix_read::return#2
  //SEG105 [55] (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_vbuz1 
    ldy colidx
    and keyboard_matrix_col_bitmask,y
    jmp breturn
  //SEG106 keyboard_key_pressed::@return
  breturn:
  //SEG107 [56] return 
    rts
}
//SEG108 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(Y) rowid)
keyboard_matrix_read: {
  //SEG109 [58] *((const byte*) CIA1_PORT_A#0) ← *((const byte[8]) keyboard_matrix_row_bitmask#0 + (byte) keyboard_matrix_read::rowid#2) -- _deref_pbuc1=pbuc2_derefidx_vbuyy 
    lda keyboard_matrix_row_bitmask,y
    sta CIA1_PORT_A
  //SEG110 [59] (byte) keyboard_matrix_read::return#0 ← ~ *((const byte*) CIA1_PORT_B#0) -- vbuaa=_bnot__deref_pbuc1 
    lda CIA1_PORT_B
    eor #$ff
    jmp breturn
  //SEG111 keyboard_matrix_read::@return
  breturn:
  //SEG112 [60] return 
    rts
}
//SEG113 keyboard_get_keycode
// Get the keycode corresponding to a specific screen code character
// ch is the character to get the key code for ($00-$3f)
// Returns the key code corresponding to the passed character. Only characters with a non-shifted key are handled.
// If there is no non-shifted key representing the char $3f is returned (representing RUN/STOP) .
// keyboard_get_keycode(byte register(Y) ch)
keyboard_get_keycode: {
  //SEG114 [61] (byte) keyboard_get_keycode::return#0 ← *((const byte[]) keyboard_char_keycodes#0 + (byte) keyboard_get_keycode::ch#0) -- vbuaa=pbuc1_derefidx_vbuyy 
    lda keyboard_char_keycodes,y
    jmp breturn
  //SEG115 keyboard_get_keycode::@return
  breturn:
  //SEG116 [62] return 
    rts
}
//SEG117 keyboard_init
// Initialize keyboard reading by setting CIA#$ Data Direction Registers
keyboard_init: {
  //SEG118 [63] *((const byte*) CIA1_PORT_A_DDR#0) ← (byte/word/signed word/dword/signed dword) 255 -- _deref_pbuc1=vbuc2 
    // Keyboard Matrix Columns Write Mode
    lda #$ff
    sta CIA1_PORT_A_DDR
  //SEG119 [64] *((const byte*) CIA1_PORT_B_DDR#0) ← (byte/signed byte/word/signed word/dword/signed dword) 0 -- _deref_pbuc1=vbuc2 
    // Keyboard Matrix Columns Read Mode
    lda #0
    sta CIA1_PORT_B_DDR
    jmp breturn
  //SEG120 keyboard_init::@return
  breturn:
  //SEG121 [65] 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
  // Keycodes for each screen code character from $00-$3f.
  // Chars that do not have an unmodified keycode return $3f (representing RUN/STOP).
  keyboard_char_keycodes: .byte KEY_AT, KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, $3f, KEY_POUND, $3f, KEY_ARROW_UP, KEY_ARROW_LEFT, KEY_SPACE, $3f, $3f, $3f, $3f, $3f, $3f, $3f, $3f, $3f, KEY_ASTERISK, KEY_PLUS, KEY_COMMA, KEY_MINUS, KEY_DOT, KEY_SLASH, KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_COLON, KEY_SEMICOLON, $3f, KEY_EQUALS, $3f, $3f

ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b12
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b14
Removing instruction jmp b5
Removing instruction jmp b6
Removing instruction jmp b28
Removing instruction jmp b7
Removing instruction jmp b18
Removing instruction jmp b9
Removing instruction jmp b20
Removing instruction jmp b21
Removing instruction jmp b10
Removing instruction jmp b29
Removing instruction jmp b22
Removing instruction jmp b30
Removing instruction jmp b23
Removing instruction jmp b11
Removing instruction jmp b13
Removing instruction jmp b2
Removing instruction jmp breturn
Removing instruction jmp breturn
Removing instruction jmp breturn
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing instruction lda #0 with TXA
Replacing label b1_from_b1 with b1
Replacing label b1_from_b1 with b1
Replacing label b7_from_b9 with b7
Replacing label b6_from_b20 with b6
Replacing label b11_from_b29 with b11
Replacing label b11_from_b30 with b11
Replacing label b10_from_b11 with b10
Removing instruction b12_from_bbegin:
Removing instruction b12:
Removing instruction main_from_b12:
Removing instruction bend_from_b12:
Removing instruction b1_from_b1:
Removing instruction b14_from_b1:
Removing instruction b6_from_b20:
Removing instruction b7_from_b9:
Removing instruction b10_from_b11:
Removing instruction b11_from_b23:
Removing instruction b11_from_b29:
Removing instruction b11_from_b30:
Removing instruction b13_from_b11:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction b14:
Removing instruction b6_from_b5:
Removing instruction keyboard_matrix_read_from_b6:
Removing instruction b28:
Removing instruction b7_from_b28:
Removing instruction b18:
Removing instruction b20:
Removing instruction b21:
Removing instruction b10_from_b21:
Removing instruction b29:
Removing instruction b22:
Removing instruction b30:
Removing instruction b23:
Removing instruction b13:
Removing instruction keyboard_matrix_read_from_keyboard_key_pressed:
Removing instruction b2:
Removing instruction breturn:
Removing instruction breturn:
Removing instruction breturn:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Relabelling long label b13_from_b13 to b2
Succesful ASM optimization Pass5RelabelLongLabels
Removing instruction jmp b1
Removing instruction jmp b6
Removing instruction jmp b7
Removing instruction jmp b10
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @12
(label) @begin
(label) @end
(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
(const byte*) CIA1_PORT_A#0 CIA1_PORT_A = ((byte*))(word/dword/signed dword) 56320
(byte*) CIA1_PORT_A_DDR
(const byte*) CIA1_PORT_A_DDR#0 CIA1_PORT_A_DDR = ((byte*))(word/dword/signed dword) 56322
(byte*) CIA1_PORT_B
(const byte*) CIA1_PORT_B#0 CIA1_PORT_B = ((byte*))(word/dword/signed dword) 56321
(byte*) CIA1_PORT_B_DDR
(const byte*) CIA1_PORT_B_DDR#0 CIA1_PORT_B_DDR = ((byte*))(word/dword/signed dword) 56323
(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
(const byte) KEY_0#0 KEY_0 = (byte/signed byte/word/signed word/dword/signed dword) 35
(byte) KEY_1
(const byte) KEY_1#0 KEY_1 = (byte/signed byte/word/signed word/dword/signed dword) 56
(byte) KEY_2
(const byte) KEY_2#0 KEY_2 = (byte/signed byte/word/signed word/dword/signed dword) 59
(byte) KEY_3
(const byte) KEY_3#0 KEY_3 = (byte/signed byte/word/signed word/dword/signed dword) 8
(byte) KEY_4
(const byte) KEY_4#0 KEY_4 = (byte/signed byte/word/signed word/dword/signed dword) 11
(byte) KEY_5
(const byte) KEY_5#0 KEY_5 = (byte/signed byte/word/signed word/dword/signed dword) 16
(byte) KEY_6
(const byte) KEY_6#0 KEY_6 = (byte/signed byte/word/signed word/dword/signed dword) 19
(byte) KEY_7
(const byte) KEY_7#0 KEY_7 = (byte/signed byte/word/signed word/dword/signed dword) 24
(byte) KEY_8
(const byte) KEY_8#0 KEY_8 = (byte/signed byte/word/signed word/dword/signed dword) 27
(byte) KEY_9
(const byte) KEY_9#0 KEY_9 = (byte/signed byte/word/signed word/dword/signed dword) 32
(byte) KEY_A
(const byte) KEY_A#0 KEY_A = (byte/signed byte/word/signed word/dword/signed dword) 10
(byte) KEY_ARROW_LEFT
(const byte) KEY_ARROW_LEFT#0 KEY_ARROW_LEFT = (byte/signed byte/word/signed word/dword/signed dword) 57
(byte) KEY_ARROW_UP
(const byte) KEY_ARROW_UP#0 KEY_ARROW_UP = (byte/signed byte/word/signed word/dword/signed dword) 54
(byte) KEY_ASTERISK
(const byte) KEY_ASTERISK#0 KEY_ASTERISK = (byte/signed byte/word/signed word/dword/signed dword) 49
(byte) KEY_AT
(const byte) KEY_AT#0 KEY_AT = (byte/signed byte/word/signed word/dword/signed dword) 46
(byte) KEY_B
(const byte) KEY_B#0 KEY_B = (byte/signed byte/word/signed word/dword/signed dword) 28
(byte) KEY_C
(const byte) KEY_C#0 KEY_C = (byte/signed byte/word/signed word/dword/signed dword) 20
(byte) KEY_COLON
(const byte) KEY_COLON#0 KEY_COLON = (byte/signed byte/word/signed word/dword/signed dword) 45
(byte) KEY_COMMA
(const byte) KEY_COMMA#0 KEY_COMMA = (byte/signed byte/word/signed word/dword/signed dword) 47
(byte) KEY_COMMODORE
(byte) KEY_CRSR_DOWN
(byte) KEY_CRSR_RIGHT
(byte) KEY_CTRL
(byte) KEY_D
(const byte) KEY_D#0 KEY_D = (byte/signed byte/word/signed word/dword/signed dword) 18
(byte) KEY_DEL
(byte) KEY_DOT
(const byte) KEY_DOT#0 KEY_DOT = (byte/signed byte/word/signed word/dword/signed dword) 44
(byte) KEY_E
(const byte) KEY_E#0 KEY_E = (byte/signed byte/word/signed word/dword/signed dword) 14
(byte) KEY_EQUALS
(const byte) KEY_EQUALS#0 KEY_EQUALS = (byte/signed byte/word/signed word/dword/signed dword) 53
(byte) KEY_F
(const byte) KEY_F#0 KEY_F = (byte/signed byte/word/signed word/dword/signed dword) 21
(byte) KEY_F1
(byte) KEY_F3
(byte) KEY_F5
(byte) KEY_F7
(byte) KEY_G
(const byte) KEY_G#0 KEY_G = (byte/signed byte/word/signed word/dword/signed dword) 26
(byte) KEY_H
(const byte) KEY_H#0 KEY_H = (byte/signed byte/word/signed word/dword/signed dword) 29
(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
(const byte) KEY_J#0 KEY_J = (byte/signed byte/word/signed word/dword/signed dword) 34
(byte) KEY_K
(const byte) KEY_K#0 KEY_K = (byte/signed byte/word/signed word/dword/signed dword) 37
(byte) KEY_L
(const byte) KEY_L#0 KEY_L = (byte/signed byte/word/signed word/dword/signed dword) 42
(byte) KEY_LSHIFT
(byte) KEY_M
(const byte) KEY_M#0 KEY_M = (byte/signed byte/word/signed word/dword/signed dword) 36
(byte) KEY_MINUS
(const byte) KEY_MINUS#0 KEY_MINUS = (byte/signed byte/word/signed word/dword/signed dword) 43
(byte) KEY_MODIFIER_COMMODORE
(byte) KEY_MODIFIER_CTRL
(byte) KEY_MODIFIER_LSHIFT
(byte) KEY_MODIFIER_RSHIFT
(byte) KEY_MODIFIER_SHIFT
(byte) KEY_N
(const byte) KEY_N#0 KEY_N = (byte/signed byte/word/signed word/dword/signed dword) 39
(byte) KEY_O
(const byte) KEY_O#0 KEY_O = (byte/signed byte/word/signed word/dword/signed dword) 38
(byte) KEY_P
(const byte) KEY_P#0 KEY_P = (byte/signed byte/word/signed word/dword/signed dword) 41
(byte) KEY_PLUS
(const byte) KEY_PLUS#0 KEY_PLUS = (byte/signed byte/word/signed word/dword/signed dword) 40
(byte) KEY_POUND
(const byte) KEY_POUND#0 KEY_POUND = (byte/signed byte/word/signed word/dword/signed dword) 48
(byte) KEY_Q
(const byte) KEY_Q#0 KEY_Q = (byte/signed byte/word/signed word/dword/signed dword) 62
(byte) KEY_R
(const byte) KEY_R#0 KEY_R = (byte/signed byte/word/signed word/dword/signed dword) 17
(byte) KEY_RETURN
(byte) KEY_RSHIFT
(byte) KEY_RUNSTOP
(byte) KEY_S
(const byte) KEY_S#0 KEY_S = (byte/signed byte/word/signed word/dword/signed dword) 13
(byte) KEY_SEMICOLON
(const byte) KEY_SEMICOLON#0 KEY_SEMICOLON = (byte/signed byte/word/signed word/dword/signed dword) 50
(byte) KEY_SLASH
(const byte) KEY_SLASH#0 KEY_SLASH = (byte/signed byte/word/signed word/dword/signed dword) 55
(byte) KEY_SPACE
(const byte) KEY_SPACE#0 KEY_SPACE = (byte/signed byte/word/signed word/dword/signed dword) 60
(byte) KEY_T
(const byte) KEY_T#0 KEY_T = (byte/signed byte/word/signed word/dword/signed dword) 22
(byte) KEY_U
(const byte) KEY_U#0 KEY_U = (byte/signed byte/word/signed word/dword/signed dword) 30
(byte) KEY_V
(const byte) KEY_V#0 KEY_V = (byte/signed byte/word/signed word/dword/signed dword) 31
(byte) KEY_W
(const byte) KEY_W#0 KEY_W = (byte/signed byte/word/signed word/dword/signed dword) 9
(byte) KEY_X
(const byte) KEY_X#0 KEY_X = (byte/signed byte/word/signed word/dword/signed dword) 23
(byte) KEY_Y
(const byte) KEY_Y#0 KEY_Y = (byte/signed byte/word/signed word/dword/signed dword) 25
(byte) KEY_Z
(const byte) KEY_Z#0 KEY_Z = (byte/signed byte/word/signed word/dword/signed dword) 12
(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
(const byte*) RASTER#0 RASTER = ((byte*))(word/dword/signed dword) 53266
(byte) RED
(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
(const byte[]) keyboard_char_keycodes#0 keyboard_char_keycodes = { (const byte) KEY_AT#0, (const byte) KEY_A#0, (const byte) KEY_B#0, (const byte) KEY_C#0, (const byte) KEY_D#0, (const byte) KEY_E#0, (const byte) KEY_F#0, (const byte) KEY_G#0, (const byte) KEY_H#0, (const byte) KEY_I#0, (const byte) KEY_J#0, (const byte) KEY_K#0, (const byte) KEY_L#0, (const byte) KEY_M#0, (const byte) KEY_N#0, (const byte) KEY_O#0, (const byte) KEY_P#0, (const byte) KEY_Q#0, (const byte) KEY_R#0, (const byte) KEY_S#0, (const byte) KEY_T#0, (const byte) KEY_U#0, (const byte) KEY_V#0, (const byte) KEY_W#0, (const byte) KEY_X#0, (const byte) KEY_Y#0, (const byte) KEY_Z#0, (byte/signed byte/word/signed word/dword/signed dword) 63, (const byte) KEY_POUND#0, (byte/signed byte/word/signed word/dword/signed dword) 63, (const byte) KEY_ARROW_UP#0, (const byte) KEY_ARROW_LEFT#0, (const 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, (const byte) KEY_ASTERISK#0, (const byte) KEY_PLUS#0, (const byte) KEY_COMMA#0, (const byte) KEY_MINUS#0, (const byte) KEY_DOT#0, (const byte) KEY_SLASH#0, (const byte) KEY_0#0, (const byte) KEY_1#0, (const byte) KEY_2#0, (const byte) KEY_3#0, (const byte) KEY_4#0, (const byte) KEY_5#0, (const byte) KEY_6#0, (const byte) KEY_7#0, (const byte) KEY_8#0, (const byte) KEY_9#0, (const byte) KEY_COLON#0, (const byte) KEY_SEMICOLON#0, (byte/signed byte/word/signed word/dword/signed dword) 63, (const 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_events
(byte) keyboard_events_size
(byte()) keyboard_get_keycode((byte) keyboard_get_keycode::ch)
(label) keyboard_get_keycode::@return
(byte) keyboard_get_keycode::ch
(byte) keyboard_get_keycode::ch#0 reg byte y 103.0
(byte) keyboard_get_keycode::return
(byte) keyboard_get_keycode::return#0 reg byte a 34.33333333333333
(byte) keyboard_get_keycode::return#2 reg byte a 202.0
(void()) keyboard_init()
(label) keyboard_init::@return
(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 colidx zp ZP_BYTE:5 0.6666666666666666
(byte) keyboard_key_pressed::key
(byte) keyboard_key_pressed::key#0 reg byte y 52.5
(byte) keyboard_key_pressed::return
(byte) keyboard_key_pressed::return#0 reg byte a 34.33333333333333
(byte) keyboard_key_pressed::return#2 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 26.25
(byte) keyboard_matrix_read::return#2 reg byte a 4.0
(byte) keyboard_matrix_read::return#3 reg byte a 202.0
(byte) keyboard_matrix_read::row_pressed_bits
(byte) keyboard_matrix_read::rowid
(byte) keyboard_matrix_read::rowid#0 reg byte y 4.0
(byte) keyboard_matrix_read::rowid#1 reg byte y 202.0
(byte) keyboard_matrix_read::rowid#2 reg byte y 105.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()
(byte~) main::$15 reg byte a 202.0
(byte~) main::$5 reg byte a 2002.0
(label) main::@1
(label) main::@10
(label) main::@11
(label) main::@13
(label) main::@14
(label) main::@18
(label) main::@20
(label) main::@21
(label) main::@22
(label) main::@23
(label) main::@28
(label) main::@29
(label) main::@30
(label) main::@5
(label) main::@6
(label) main::@7
(label) main::@8
(label) main::@9
(byte) main::ch
(byte) main::ch#1 ch zp ZP_BYTE:4 151.5
(byte) main::ch#2 ch zp ZP_BYTE:4 28.857142857142858
(byte) main::col
(byte) main::col#1 reg byte y 1501.5
(byte) main::col#2 reg byte y 667.3333333333334
(byte) main::i
(byte) main::i#1 reg byte x 202.0
(byte) main::i#10 reg byte x 42.08333333333333
(byte) main::i#2 reg byte x 151.5
(byte) main::i#4 reg byte x 202.0
(byte) main::i#6 reg byte x 168.33333333333331
(byte) main::key
(byte) main::key#0 reg byte a 151.5
(byte) main::row
(byte) main::row#1 row zp ZP_BYTE:4 151.5
(byte) main::row#2 row zp ZP_BYTE:4 21.642857142857142
(byte) main::row_pressed_bits
(byte) main::row_pressed_bits#0 reg byte x 202.0
(byte) main::row_pressed_bits#1 reg byte x 667.3333333333334
(byte) main::row_pressed_bits#2 reg byte x 620.8
(byte*) main::sc
(byte*) main::sc#1 sc zp ZP_WORD:2 16.5
(byte*) main::sc#2 sc zp ZP_WORD:2 16.5
(byte*) main::screen
(byte*) main::screen#1 screen zp ZP_WORD:2 71.0
(byte*) main::screen#13 screen zp ZP_WORD:2 169.53846153846155
(byte*) main::screen#2 screen zp ZP_WORD:2 10.142857142857142

zp ZP_WORD:2 [ main::sc#2 main::sc#1 main::screen#13 main::screen#1 main::screen#2 ]
zp ZP_BYTE:4 [ main::row#2 main::row#1 main::ch#2 main::ch#1 ]
reg byte x [ main::row_pressed_bits#2 main::row_pressed_bits#0 main::row_pressed_bits#1 ]
reg byte y [ main::col#2 main::col#1 ]
reg byte x [ main::i#4 main::i#10 main::i#6 main::i#1 main::i#2 ]
reg byte y [ keyboard_matrix_read::rowid#2 keyboard_matrix_read::rowid#0 keyboard_matrix_read::rowid#1 ]
reg byte a [ keyboard_matrix_read::return#3 ]
reg byte a [ main::$5 ]
reg byte y [ keyboard_get_keycode::ch#0 ]
reg byte a [ keyboard_get_keycode::return#2 ]
reg byte a [ main::key#0 ]
reg byte y [ keyboard_key_pressed::key#0 ]
reg byte a [ keyboard_key_pressed::return#2 ]
reg byte a [ main::$15 ]
zp ZP_BYTE:5 [ keyboard_key_pressed::colidx#0 ]
reg byte a [ keyboard_key_pressed::rowidx#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_get_keycode::return#0 ]


FINAL ASSEMBLER
Score: 56821

//SEG0 File Comments
// Test keyboard input - in the keyboard matrix and mapping screen codes to key codes
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG2 Global Constants & labels
  .label RASTER = $d012
  // 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
  // CIA #1 Port A data direction register.
  .label CIA1_PORT_A_DDR = $dc02
  // CIA #1 Port B data direction register.
  .label CIA1_PORT_B_DDR = $dc03
  .const KEY_3 = 8
  .const KEY_W = 9
  .const KEY_A = $a
  .const KEY_4 = $b
  .const KEY_Z = $c
  .const KEY_S = $d
  .const KEY_E = $e
  .const KEY_5 = $10
  .const KEY_R = $11
  .const KEY_D = $12
  .const KEY_6 = $13
  .const KEY_C = $14
  .const KEY_F = $15
  .const KEY_T = $16
  .const KEY_X = $17
  .const KEY_7 = $18
  .const KEY_Y = $19
  .const KEY_G = $1a
  .const KEY_8 = $1b
  .const KEY_B = $1c
  .const KEY_H = $1d
  .const KEY_U = $1e
  .const KEY_V = $1f
  .const KEY_9 = $20
  .const KEY_I = $21
  .const KEY_J = $22
  .const KEY_0 = $23
  .const KEY_M = $24
  .const KEY_K = $25
  .const KEY_O = $26
  .const KEY_N = $27
  .const KEY_PLUS = $28
  .const KEY_P = $29
  .const KEY_L = $2a
  .const KEY_MINUS = $2b
  .const KEY_DOT = $2c
  .const KEY_COLON = $2d
  .const KEY_AT = $2e
  .const KEY_COMMA = $2f
  .const KEY_POUND = $30
  .const KEY_ASTERISK = $31
  .const KEY_SEMICOLON = $32
  .const KEY_EQUALS = $35
  .const KEY_ARROW_UP = $36
  .const KEY_SLASH = $37
  .const KEY_1 = $38
  .const KEY_ARROW_LEFT = $39
  .const KEY_2 = $3b
  .const KEY_SPACE = $3c
  .const KEY_Q = $3e
//SEG3 @begin
//SEG4 [1] phi from @begin to @12 [phi:@begin->@12]
//SEG5 @12
//SEG6 [2] call main 
//SEG7 [4] phi from @12 to main [phi:@12->main]
//SEG8 [3] phi from @12 to @end [phi:@12->@end]
//SEG9 @end
//SEG10 main
main: {
    .label sc = 2
    .label screen = 2
    .label row = 4
    .label ch = 4
  //SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
  //SEG12 [5] phi (byte*) main::sc#2 = ((byte*))(word/signed word/dword/signed dword) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<$400
    sta sc
    lda #>$400
    sta sc+1
  // Clear screen
  //SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  //SEG14 [5] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@1->main::@1#0] -- register_copy 
  //SEG15 main::@1
  b1:
  //SEG16 [6] *((byte*) main::sc#2) ← (byte) ' ' -- _deref_pbuz1=vbuc1 
    lda #' '
    ldy #0
    sta (sc),y
  //SEG17 [7] (byte*) main::sc#1 ← ++ (byte*) main::sc#2 -- pbuz1=_inc_pbuz1 
    inc sc
    bne !+
    inc sc+1
  !:
  //SEG18 [8] if((byte*) main::sc#1<(word/signed word/dword/signed dword) 1024+(word/signed word/dword/signed dword) 1000) goto main::@1 -- pbuz1_lt_vwuc1_then_la1 
    lda sc+1
    cmp #>$400+$3e8
    bcc b1
    bne !+
    lda sc
    cmp #<$400+$3e8
    bcc b1
  !:
  //SEG19 [9] phi from main::@1 to main::@14 [phi:main::@1->main::@14]
  //SEG20 main::@14
  //SEG21 [10] call keyboard_init 
    jsr keyboard_init
  //SEG22 main::@5
  b5:
  //SEG23 [11] if(*((const byte*) RASTER#0)!=(byte/word/signed word/dword/signed dword) 255) goto main::@5 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda RASTER
    cmp #$ff
    bne b5
  //SEG24 [12] phi from main::@5 to main::@6 [phi:main::@5->main::@6]
  //SEG25 [12] phi (byte*) main::screen#13 = ((byte*))(word/signed word/dword/signed dword) 1024 [phi:main::@5->main::@6#0] -- pbuz1=pbuc1 
    lda #<$400
    sta screen
    lda #>$400
    sta screen+1
  //SEG26 [12] phi (byte) main::row#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@5->main::@6#1] -- vbuz1=vbuc1 
    lda #0
    sta row
  // Read & print keyboard matrix
  //SEG27 [12] phi from main::@20 to main::@6 [phi:main::@20->main::@6]
  //SEG28 [12] phi (byte*) main::screen#13 = (byte*) main::screen#1 [phi:main::@20->main::@6#0] -- register_copy 
  //SEG29 [12] phi (byte) main::row#2 = (byte) main::row#1 [phi:main::@20->main::@6#1] -- register_copy 
  //SEG30 main::@6
  b6:
  //SEG31 [13] (byte) keyboard_matrix_read::rowid#1 ← (byte) main::row#2 -- vbuyy=vbuz1 
    ldy row
  //SEG32 [14] call keyboard_matrix_read 
  //SEG33 [57] phi from main::@6 to keyboard_matrix_read [phi:main::@6->keyboard_matrix_read]
  //SEG34 [57] phi (byte) keyboard_matrix_read::rowid#2 = (byte) keyboard_matrix_read::rowid#1 [phi:main::@6->keyboard_matrix_read#0] -- register_copy 
    jsr keyboard_matrix_read
  //SEG35 [15] (byte) keyboard_matrix_read::return#3 ← (byte) keyboard_matrix_read::return#0
  //SEG36 main::@28
  //SEG37 [16] (byte) main::row_pressed_bits#0 ← (byte) keyboard_matrix_read::return#3 -- vbuxx=vbuaa 
    tax
  //SEG38 [17] phi from main::@28 to main::@7 [phi:main::@28->main::@7]
  //SEG39 [17] phi (byte) main::col#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@28->main::@7#0] -- vbuyy=vbuc1 
    ldy #0
  //SEG40 [17] phi (byte) main::row_pressed_bits#2 = (byte) main::row_pressed_bits#0 [phi:main::@28->main::@7#1] -- register_copy 
  //SEG41 [17] phi from main::@9 to main::@7 [phi:main::@9->main::@7]
  //SEG42 [17] phi (byte) main::col#2 = (byte) main::col#1 [phi:main::@9->main::@7#0] -- register_copy 
  //SEG43 [17] phi (byte) main::row_pressed_bits#2 = (byte) main::row_pressed_bits#1 [phi:main::@9->main::@7#1] -- register_copy 
  //SEG44 main::@7
  b7:
  //SEG45 [18] (byte~) main::$5 ← (byte) main::row_pressed_bits#2 & (byte/word/signed word/dword/signed dword) 128 -- vbuaa=vbuxx_band_vbuc1 
    txa
    and #$80
  //SEG46 [19] if((byte~) main::$5!=(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@8 -- vbuaa_neq_0_then_la1 
    cmp #0
    bne b8
  //SEG47 main::@18
  //SEG48 [20] *((byte*) main::screen#13 + (byte) main::col#2) ← (byte) '0' -- pbuz1_derefidx_vbuyy=vbuc1 
    lda #'0'
    sta (screen),y
  //SEG49 main::@9
  b9:
  //SEG50 [21] (byte) main::row_pressed_bits#1 ← (byte) main::row_pressed_bits#2 << (byte/signed byte/word/signed word/dword/signed dword) 1 -- vbuxx=vbuxx_rol_1 
    txa
    asl
    tax
  //SEG51 [22] (byte) main::col#1 ← ++ (byte) main::col#2 -- vbuyy=_inc_vbuyy 
    iny
  //SEG52 [23] if((byte) main::col#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@7 -- vbuyy_neq_vbuc1_then_la1 
    cpy #8
    bne b7
  //SEG53 main::@20
  //SEG54 [24] (byte*) main::screen#1 ← (byte*) main::screen#13 + (byte/signed byte/word/signed word/dword/signed dword) 40 -- pbuz1=pbuz1_plus_vbuc1 
    lda screen
    clc
    adc #$28
    sta screen
    bcc !+
    inc screen+1
  !:
  //SEG55 [25] (byte) main::row#1 ← ++ (byte) main::row#2 -- vbuz1=_inc_vbuz1 
    inc row
  //SEG56 [26] if((byte) main::row#1!=(byte/signed byte/word/signed word/dword/signed dword) 8) goto main::@6 -- vbuz1_neq_vbuc1_then_la1 
    lda row
    cmp #8
    bne b6
  //SEG57 main::@21
  //SEG58 [27] (byte*) main::screen#2 ← (byte*) main::screen#1 + (byte/signed byte/word/signed word/dword/signed dword) 40 -- pbuz1=pbuz1_plus_vbuc1 
    lda screen
    clc
    adc #$28
    sta screen
    bcc !+
    inc screen+1
  !:
  //SEG59 [28] phi from main::@21 to main::@10 [phi:main::@21->main::@10]
  //SEG60 [28] phi (byte) main::i#10 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@21->main::@10#0] -- vbuxx=vbuc1 
    ldx #0
  //SEG61 [28] phi (byte) main::ch#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@21->main::@10#1] -- vbuz1=vbuc1 
    txa
    sta ch
  //SEG62 [28] phi from main::@11 to main::@10 [phi:main::@11->main::@10]
  //SEG63 [28] phi (byte) main::i#10 = (byte) main::i#6 [phi:main::@11->main::@10#0] -- register_copy 
  //SEG64 [28] phi (byte) main::ch#2 = (byte) main::ch#1 [phi:main::@11->main::@10#1] -- register_copy 
  //SEG65 main::@10
  b10:
  //SEG66 [29] (byte) keyboard_get_keycode::ch#0 ← (byte) main::ch#2 -- vbuyy=vbuz1 
    ldy ch
  //SEG67 [30] call keyboard_get_keycode 
    jsr keyboard_get_keycode
  //SEG68 [31] (byte) keyboard_get_keycode::return#2 ← (byte) keyboard_get_keycode::return#0
  //SEG69 main::@29
  //SEG70 [32] (byte) main::key#0 ← (byte) keyboard_get_keycode::return#2
  //SEG71 [33] if((byte) main::key#0==(byte/signed byte/word/signed word/dword/signed dword) 63) goto main::@11 -- vbuaa_eq_vbuc1_then_la1 
    cmp #$3f
    beq b11
  //SEG72 main::@22
  //SEG73 [34] (byte) keyboard_key_pressed::key#0 ← (byte) main::key#0 -- vbuyy=vbuaa 
    tay
  //SEG74 [35] call keyboard_key_pressed 
    jsr keyboard_key_pressed
  //SEG75 [36] (byte) keyboard_key_pressed::return#2 ← (byte) keyboard_key_pressed::return#0
  //SEG76 main::@30
  //SEG77 [37] (byte~) main::$15 ← (byte) keyboard_key_pressed::return#2
  //SEG78 [38] if((byte~) main::$15==(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@11 -- vbuaa_eq_0_then_la1 
    cmp #0
    beq b11
  //SEG79 main::@23
  //SEG80 [39] *((byte*) main::screen#2 + (byte) main::i#10) ← (byte) main::ch#2 -- pbuz1_derefidx_vbuxx=vbuz2 
    txa
    tay
    lda ch
    sta (screen),y
  //SEG81 [40] (byte) main::i#1 ← ++ (byte) main::i#10 -- vbuxx=_inc_vbuxx 
    inx
  //SEG82 [41] phi from main::@23 main::@29 main::@30 to main::@11 [phi:main::@23/main::@29/main::@30->main::@11]
  //SEG83 [41] phi (byte) main::i#6 = (byte) main::i#1 [phi:main::@23/main::@29/main::@30->main::@11#0] -- register_copy 
  //SEG84 main::@11
  b11:
  //SEG85 [42] (byte) main::ch#1 ← ++ (byte) main::ch#2 -- vbuz1=_inc_vbuz1 
    inc ch
  //SEG86 [43] if((byte) main::ch#1!=(byte/signed byte/word/signed word/dword/signed dword) 64) goto main::@10 -- vbuz1_neq_vbuc1_then_la1 
    lda ch
    cmp #$40
    bne b10
  //SEG87 [44] phi from main::@11 main::@13 to main::@13 [phi:main::@11/main::@13->main::@13]
  b2:
  //SEG88 [44] phi (byte) main::i#4 = (byte) main::i#6 [phi:main::@11/main::@13->main::@13#0] -- register_copy 
  // Add some spaces
  //SEG89 main::@13
  //SEG90 [45] *((byte*) main::screen#2 + (byte) main::i#4) ← (byte) ' ' -- pbuz1_derefidx_vbuxx=vbuc1 
    txa
    tay
    lda #' '
    sta (screen),y
  //SEG91 [46] (byte) main::i#2 ← ++ (byte) main::i#4 -- vbuxx=_inc_vbuxx 
    inx
  //SEG92 [47] if((byte) main::i#2<(byte/signed byte/word/signed word/dword/signed dword) 5) goto main::@13 -- vbuxx_lt_vbuc1_then_la1 
    cpx #5
    bcc b2
    jmp b5
  //SEG93 main::@8
  b8:
  //SEG94 [48] *((byte*) main::screen#13 + (byte) main::col#2) ← (byte) '1' -- pbuz1_derefidx_vbuyy=vbuc1 
    lda #'1'
    sta (screen),y
    jmp b9
}
//SEG95 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(Y) key)
keyboard_key_pressed: {
    .label colidx = 5
  //SEG96 [49] (byte) keyboard_key_pressed::colidx#0 ← (byte) keyboard_key_pressed::key#0 & (byte/signed byte/word/signed word/dword/signed dword) 7 -- vbuz1=vbuyy_band_vbuc1 
    tya
    and #7
    sta colidx
  //SEG97 [50] (byte) keyboard_key_pressed::rowidx#0 ← (byte) keyboard_key_pressed::key#0 >> (byte/signed byte/word/signed word/dword/signed dword) 3 -- vbuaa=vbuyy_ror_3 
    tya
    lsr
    lsr
    lsr
  //SEG98 [51] (byte) keyboard_matrix_read::rowid#0 ← (byte) keyboard_key_pressed::rowidx#0 -- vbuyy=vbuaa 
    tay
  //SEG99 [52] call keyboard_matrix_read 
  //SEG100 [57] phi from keyboard_key_pressed to keyboard_matrix_read [phi:keyboard_key_pressed->keyboard_matrix_read]
  //SEG101 [57] phi (byte) keyboard_matrix_read::rowid#2 = (byte) keyboard_matrix_read::rowid#0 [phi:keyboard_key_pressed->keyboard_matrix_read#0] -- register_copy 
    jsr keyboard_matrix_read
  //SEG102 [53] (byte) keyboard_matrix_read::return#2 ← (byte) keyboard_matrix_read::return#0
  //SEG103 keyboard_key_pressed::@2
  //SEG104 [54] (byte~) keyboard_key_pressed::$2 ← (byte) keyboard_matrix_read::return#2
  //SEG105 [55] (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_vbuz1 
    ldy colidx
    and keyboard_matrix_col_bitmask,y
  //SEG106 keyboard_key_pressed::@return
  //SEG107 [56] return 
    rts
}
//SEG108 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(Y) rowid)
keyboard_matrix_read: {
  //SEG109 [58] *((const byte*) CIA1_PORT_A#0) ← *((const byte[8]) keyboard_matrix_row_bitmask#0 + (byte) keyboard_matrix_read::rowid#2) -- _deref_pbuc1=pbuc2_derefidx_vbuyy 
    lda keyboard_matrix_row_bitmask,y
    sta CIA1_PORT_A
  //SEG110 [59] (byte) keyboard_matrix_read::return#0 ← ~ *((const byte*) CIA1_PORT_B#0) -- vbuaa=_bnot__deref_pbuc1 
    lda CIA1_PORT_B
    eor #$ff
  //SEG111 keyboard_matrix_read::@return
  //SEG112 [60] return 
    rts
}
//SEG113 keyboard_get_keycode
// Get the keycode corresponding to a specific screen code character
// ch is the character to get the key code for ($00-$3f)
// Returns the key code corresponding to the passed character. Only characters with a non-shifted key are handled.
// If there is no non-shifted key representing the char $3f is returned (representing RUN/STOP) .
// keyboard_get_keycode(byte register(Y) ch)
keyboard_get_keycode: {
  //SEG114 [61] (byte) keyboard_get_keycode::return#0 ← *((const byte[]) keyboard_char_keycodes#0 + (byte) keyboard_get_keycode::ch#0) -- vbuaa=pbuc1_derefidx_vbuyy 
    lda keyboard_char_keycodes,y
  //SEG115 keyboard_get_keycode::@return
  //SEG116 [62] return 
    rts
}
//SEG117 keyboard_init
// Initialize keyboard reading by setting CIA#$ Data Direction Registers
keyboard_init: {
  //SEG118 [63] *((const byte*) CIA1_PORT_A_DDR#0) ← (byte/word/signed word/dword/signed dword) 255 -- _deref_pbuc1=vbuc2 
    // Keyboard Matrix Columns Write Mode
    lda #$ff
    sta CIA1_PORT_A_DDR
  //SEG119 [64] *((const byte*) CIA1_PORT_B_DDR#0) ← (byte/signed byte/word/signed word/dword/signed dword) 0 -- _deref_pbuc1=vbuc2 
    // Keyboard Matrix Columns Read Mode
    lda #0
    sta CIA1_PORT_B_DDR
  //SEG120 keyboard_init::@return
  //SEG121 [65] 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
  // Keycodes for each screen code character from $00-$3f.
  // Chars that do not have an unmodified keycode return $3f (representing RUN/STOP).
  keyboard_char_keycodes: .byte KEY_AT, KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, $3f, KEY_POUND, $3f, KEY_ARROW_UP, KEY_ARROW_LEFT, KEY_SPACE, $3f, $3f, $3f, $3f, $3f, $3f, $3f, $3f, $3f, KEY_ASTERISK, KEY_PLUS, KEY_COMMA, KEY_MINUS, KEY_DOT, KEY_SLASH, KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_COLON, KEY_SEMICOLON, $3f, KEY_EQUALS, $3f, $3f

