Inlined call (byte~) vicSelectGfxBank::$0 ← call toDd00 (byte*) vicSelectGfxBank::gfx 
Culled Empty Block (label) @1
Culled Empty Block (label) @2
Culled Empty Block (label) @3
Culled Empty Block (label) @5
Culled Empty Block (label) keyboard_matrix_read::@1
Culled Empty Block (label) @6
Culled Empty Block (label) keyboard_key_pressed::@1
Culled Empty Block (label) @7
Culled Empty Block (label) keyboard_get_keycode::@1
Culled Empty Block (label) @8
Culled Empty Block (label) @9
Culled Empty Block (label) @10
Culled Empty Block (label) @11
Culled Empty Block (label) main::@4
Culled Empty Block (label) main::@25
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@26
Culled Empty Block (label) main::@13
Culled Empty Block (label) main::@18
Culled Empty Block (label) main::@21
Culled Empty Block (label) main::@23
Culled Empty Block (label) main::@24

CONTROL FLOW GRAPH SSA
@begin: scope:[]  from
  (byte*) RASTER#0 ← ((byte*)) (number) $d012
  (byte*) CIA1_PORT_A#0 ← ((byte*)) (number) $dc00
  (byte*) CIA1_PORT_B#0 ← ((byte*)) (number) $dc01
  (byte*) CIA1_PORT_A_DDR#0 ← ((byte*)) (number) $dc02
  (byte*) CIA1_PORT_B_DDR#0 ← ((byte*)) (number) $dc03
  to:@4
@4: scope:[]  from @begin
  (byte) KEY_3#0 ← (number) 8
  (byte) KEY_W#0 ← (number) 9
  (byte) KEY_A#0 ← (number) $a
  (byte) KEY_4#0 ← (number) $b
  (byte) KEY_Z#0 ← (number) $c
  (byte) KEY_S#0 ← (number) $d
  (byte) KEY_E#0 ← (number) $e
  (byte) KEY_5#0 ← (number) $10
  (byte) KEY_R#0 ← (number) $11
  (byte) KEY_D#0 ← (number) $12
  (byte) KEY_6#0 ← (number) $13
  (byte) KEY_C#0 ← (number) $14
  (byte) KEY_F#0 ← (number) $15
  (byte) KEY_T#0 ← (number) $16
  (byte) KEY_X#0 ← (number) $17
  (byte) KEY_7#0 ← (number) $18
  (byte) KEY_Y#0 ← (number) $19
  (byte) KEY_G#0 ← (number) $1a
  (byte) KEY_8#0 ← (number) $1b
  (byte) KEY_B#0 ← (number) $1c
  (byte) KEY_H#0 ← (number) $1d
  (byte) KEY_U#0 ← (number) $1e
  (byte) KEY_V#0 ← (number) $1f
  (byte) KEY_9#0 ← (number) $20
  (byte) KEY_I#0 ← (number) $21
  (byte) KEY_J#0 ← (number) $22
  (byte) KEY_0#0 ← (number) $23
  (byte) KEY_M#0 ← (number) $24
  (byte) KEY_K#0 ← (number) $25
  (byte) KEY_O#0 ← (number) $26
  (byte) KEY_N#0 ← (number) $27
  (byte) KEY_PLUS#0 ← (number) $28
  (byte) KEY_P#0 ← (number) $29
  (byte) KEY_L#0 ← (number) $2a
  (byte) KEY_MINUS#0 ← (number) $2b
  (byte) KEY_DOT#0 ← (number) $2c
  (byte) KEY_COLON#0 ← (number) $2d
  (byte) KEY_AT#0 ← (number) $2e
  (byte) KEY_COMMA#0 ← (number) $2f
  (byte) KEY_POUND#0 ← (number) $30
  (byte) KEY_ASTERISK#0 ← (number) $31
  (byte) KEY_SEMICOLON#0 ← (number) $32
  (byte) KEY_EQUALS#0 ← (number) $35
  (byte) KEY_ARROW_UP#0 ← (number) $36
  (byte) KEY_SLASH#0 ← (number) $37
  (byte) KEY_1#0 ← (number) $38
  (byte) KEY_ARROW_LEFT#0 ← (number) $39
  (byte) KEY_2#0 ← (number) $3b
  (byte) KEY_SPACE#0 ← (number) $3c
  (byte) KEY_Q#0 ← (number) $3e
  (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, (number) $3f, (byte) KEY_POUND#0, (number) $3f, (byte) KEY_ARROW_UP#0, (byte) KEY_ARROW_LEFT#0, (byte) KEY_SPACE#0, (number) $3f, (number) $3f, (number) $3f, (number) $3f, (number) $3f, (number) $3f, (number) $3f, (number) $3f, (number) $3f, (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, (number) $3f, (byte) KEY_EQUALS#0, (number) $3f, (number) $3f }
  (byte[8]) keyboard_matrix_row_bitmask#0 ← { (number) $fe, (number) $fd, (number) $fb, (number) $f7, (number) $ef, (number) $df, (number) $bf, (number) $7f }
  (byte[8]) keyboard_matrix_col_bitmask#0 ← { (number) 1, (number) 2, (number) 4, (number) 8, (number) $10, (number) $20, (number) $40, (number) $80 }
  to:@12
keyboard_init: scope:[keyboard_init]  from main::@2
  *((byte*) CIA1_PORT_A_DDR#0) ← (number) $ff
  *((byte*) CIA1_PORT_B_DDR#0) ← (number) 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::@8
  (byte) keyboard_matrix_read::rowid#2 ← phi( keyboard_key_pressed/(byte) keyboard_matrix_read::rowid#0 main::@8/(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::@19
  (byte) keyboard_key_pressed::key#1 ← phi( main::@19/(byte) keyboard_key_pressed::key#0 )
  (number~) keyboard_key_pressed::$0 ← (byte) keyboard_key_pressed::key#1 & (number) 7
  (byte) keyboard_key_pressed::colidx#0 ← (number~) keyboard_key_pressed::$0
  (byte~) keyboard_key_pressed::$1 ← (byte) keyboard_key_pressed::key#1 >> (number) 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::@16
  (byte) keyboard_get_keycode::ch#1 ← phi( main::@16/(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
main: scope:[main]  from @12
  (byte*) main::sc#0 ← ((byte*)) (number) $400
  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
  (bool~) main::$1 ← (byte*) main::sc#1 < (number) $400+(number) $3e8
  if((bool~) main::$1) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1
  call keyboard_init 
  to:main::@27
main::@27: scope:[main]  from main::@2
  to:main::@3
main::@3: scope:[main]  from main::@22 main::@27
  if(true) goto main::@6
  to:main::@return
main::@6: scope:[main]  from main::@3 main::@6
  (bool~) main::$2 ← *((byte*) RASTER#0) != (number) $ff
  if((bool~) main::$2) goto main::@6
  to:main::@7
main::@7: scope:[main]  from main::@6
  (byte*) main::screen#0 ← ((byte*)) (number) $400
  (byte) main::row#0 ← (byte) 0
  to:main::@8
main::@8: scope:[main]  from main::@14 main::@7
  (byte*) main::screen#16 ← phi( main::@14/(byte*) main::screen#1 main::@7/(byte*) main::screen#0 )
  (byte) main::row#2 ← phi( main::@14/(byte) main::row#1 main::@7/(byte) main::row#0 )
  (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::@8
  (byte) main::row#8 ← phi( main::@8/(byte) main::row#2 )
  (byte*) main::screen#13 ← phi( main::@8/(byte*) main::screen#16 )
  (byte) keyboard_matrix_read::return#6 ← phi( main::@8/(byte) keyboard_matrix_read::return#3 )
  (byte~) main::$3 ← (byte) keyboard_matrix_read::return#6
  (byte) main::row_pressed_bits#0 ← (byte~) main::$3
  (byte) main::col#0 ← (byte) 0
  to:main::@9
main::@9: scope:[main]  from main::@11 main::@28
  (byte) main::row#7 ← phi( main::@11/(byte) main::row#4 main::@28/(byte) main::row#8 )
  (byte) main::col#5 ← phi( main::@11/(byte) main::col#1 main::@28/(byte) main::col#0 )
  (byte*) main::screen#9 ← phi( main::@11/(byte*) main::screen#10 main::@28/(byte*) main::screen#13 )
  (byte) main::row_pressed_bits#2 ← phi( main::@11/(byte) main::row_pressed_bits#1 main::@28/(byte) main::row_pressed_bits#0 )
  (number~) main::$4 ← (byte) main::row_pressed_bits#2 & (number) $80
  (bool~) main::$5 ← (number~) main::$4 != (number) 0
  if((bool~) main::$5) goto main::@10
  to:main::@12
main::@10: scope:[main]  from main::@9
  (byte) main::row#5 ← phi( main::@9/(byte) main::row#7 )
  (byte) main::row_pressed_bits#4 ← phi( main::@9/(byte) main::row_pressed_bits#2 )
  (byte) main::col#2 ← phi( main::@9/(byte) main::col#5 )
  (byte*) main::screen#3 ← phi( main::@9/(byte*) main::screen#9 )
  *((byte*) main::screen#3 + (byte) main::col#2) ← (byte) '1'
  to:main::@11
main::@12: scope:[main]  from main::@9
  (byte) main::row#6 ← phi( main::@9/(byte) main::row#7 )
  (byte) main::row_pressed_bits#5 ← phi( main::@9/(byte) main::row_pressed_bits#2 )
  (byte) main::col#3 ← phi( main::@9/(byte) main::col#5 )
  (byte*) main::screen#4 ← phi( main::@9/(byte*) main::screen#9 )
  *((byte*) main::screen#4 + (byte) main::col#3) ← (byte) '0'
  to:main::@11
main::@11: scope:[main]  from main::@10 main::@12
  (byte) main::row#4 ← phi( main::@10/(byte) main::row#5 main::@12/(byte) main::row#6 )
  (byte*) main::screen#10 ← phi( main::@10/(byte*) main::screen#3 main::@12/(byte*) main::screen#4 )
  (byte) main::col#4 ← phi( main::@10/(byte) main::col#2 main::@12/(byte) main::col#3 )
  (byte) main::row_pressed_bits#3 ← phi( main::@10/(byte) main::row_pressed_bits#4 main::@12/(byte) main::row_pressed_bits#5 )
  (number~) main::$6 ← (byte) main::row_pressed_bits#3 * (number) 2
  (byte) main::row_pressed_bits#1 ← (number~) main::$6
  (byte) main::col#1 ← (byte) main::col#4 + rangenext(0,7)
  (bool~) main::$7 ← (byte) main::col#1 != rangelast(0,7)
  if((bool~) main::$7) goto main::@9
  to:main::@14
main::@14: scope:[main]  from main::@11
  (byte) main::row#3 ← phi( main::@11/(byte) main::row#4 )
  (byte*) main::screen#5 ← phi( main::@11/(byte*) main::screen#10 )
  (byte*~) main::$8 ← (byte*) main::screen#5 + (number) $28
  (byte*) main::screen#1 ← (byte*~) main::$8
  (byte) main::row#1 ← (byte) main::row#3 + rangenext(0,7)
  (bool~) main::$9 ← (byte) main::row#1 != rangelast(0,7)
  if((bool~) main::$9) goto main::@8
  to:main::@15
main::@15: scope:[main]  from main::@14
  (byte*) main::screen#6 ← phi( main::@14/(byte*) main::screen#1 )
  (byte*~) main::$10 ← (byte*) main::screen#6 + (number) $28
  (byte*) main::screen#2 ← (byte*~) main::$10
  (byte) main::i#0 ← (number) 0
  (byte) main::ch#0 ← (byte) 0
  to:main::@16
main::@16: scope:[main]  from main::@15 main::@17
  (byte) main::i#9 ← phi( main::@15/(byte) main::i#0 main::@17/(byte) main::i#6 )
  (byte*) main::screen#17 ← phi( main::@15/(byte*) main::screen#2 main::@17/(byte*) main::screen#12 )
  (byte) main::ch#2 ← phi( main::@15/(byte) main::ch#0 main::@17/(byte) main::ch#1 )
  (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::@16
  (byte) main::i#7 ← phi( main::@16/(byte) main::i#9 )
  (byte*) main::screen#14 ← phi( main::@16/(byte*) main::screen#17 )
  (byte) main::ch#5 ← phi( main::@16/(byte) main::ch#2 )
  (byte) keyboard_get_keycode::return#4 ← phi( main::@16/(byte) keyboard_get_keycode::return#2 )
  (byte~) main::$11 ← (byte) keyboard_get_keycode::return#4
  (byte) main::key#0 ← (byte~) main::$11
  (bool~) main::$12 ← (byte) main::key#0 != (number) $3f
  (bool~) main::$13 ← ! (bool~) main::$12
  if((bool~) main::$13) goto main::@17
  to:main::@19
main::@17: scope:[main]  from main::@20 main::@29 main::@30
  (byte) main::i#6 ← phi( main::@20/(byte) main::i#1 main::@29/(byte) main::i#7 main::@30/(byte) main::i#5 )
  (byte*) main::screen#12 ← phi( main::@20/(byte*) main::screen#7 main::@29/(byte*) main::screen#14 main::@30/(byte*) main::screen#11 )
  (byte) main::ch#3 ← phi( main::@20/(byte) main::ch#4 main::@29/(byte) main::ch#5 main::@30/(byte) main::ch#6 )
  (byte) main::ch#1 ← (byte) main::ch#3 + rangenext(0,$3f)
  (bool~) main::$17 ← (byte) main::ch#1 != rangelast(0,$3f)
  if((bool~) main::$17) goto main::@16
  to:main::@22
main::@19: scope:[main]  from main::@29
  (byte) main::i#8 ← phi( main::@29/(byte) main::i#7 )
  (byte*) main::screen#15 ← phi( main::@29/(byte*) main::screen#14 )
  (byte) main::ch#7 ← phi( main::@29/(byte) main::ch#5 )
  (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::@19
  (byte) main::i#5 ← phi( main::@19/(byte) main::i#8 )
  (byte*) main::screen#11 ← phi( main::@19/(byte*) main::screen#15 )
  (byte) main::ch#6 ← phi( main::@19/(byte) main::ch#7 )
  (byte) keyboard_key_pressed::return#4 ← phi( main::@19/(byte) keyboard_key_pressed::return#2 )
  (byte~) main::$14 ← (byte) keyboard_key_pressed::return#4
  (bool~) main::$15 ← (byte~) main::$14 != (number) 0
  (bool~) main::$16 ← ! (bool~) main::$15
  if((bool~) main::$16) goto main::@17
  to:main::@20
main::@20: 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#6 )
  *((byte*) main::screen#7 + (byte) main::i#3) ← (byte) main::ch#4
  (byte) main::i#1 ← ++ (byte) main::i#3
  to:main::@17
main::@22: scope:[main]  from main::@17 main::@22
  (byte) main::i#4 ← phi( main::@17/(byte) main::i#6 main::@22/(byte) main::i#2 )
  (byte*) main::screen#8 ← phi( main::@17/(byte*) main::screen#12 main::@22/(byte*) main::screen#8 )
  *((byte*) main::screen#8 + (byte) main::i#4) ← (byte) ' '
  (byte) main::i#2 ← ++ (byte) main::i#4
  (bool~) main::$18 ← (byte) main::i#2 < (number) 5
  if((bool~) main::$18) goto main::@22
  to:main::@3
main::@return: scope:[main]  from main::@3
  return 
  to:@return
@12: scope:[]  from @4
  call main 
  to:@13
@13: scope:[]  from @12
  to:@end
@end: scope:[]  from @13

SYMBOL TABLE SSA
(label) @12
(label) @13
(label) @4
(label) @begin
(label) @end
(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) 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_D
(byte) KEY_D#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_G
(byte) KEY_G#0
(byte) KEY_H
(byte) KEY_H#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_M
(byte) KEY_M#0
(byte) KEY_MINUS
(byte) KEY_MINUS#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_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*) RASTER
(byte*) RASTER#0
(byte[]) keyboard_char_keycodes
(byte[]) keyboard_char_keycodes#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)
(number~) 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
(void()) main()
(bool~) main::$1
(byte*~) main::$10
(byte~) main::$11
(bool~) main::$12
(bool~) main::$13
(byte~) main::$14
(bool~) main::$15
(bool~) main::$16
(bool~) main::$17
(bool~) main::$18
(bool~) main::$2
(byte~) main::$3
(number~) main::$4
(bool~) main::$5
(number~) main::$6
(bool~) main::$7
(byte*~) main::$8
(bool~) main::$9
(label) main::@1
(label) main::@10
(label) main::@11
(label) main::@12
(label) main::@14
(label) main::@15
(label) main::@16
(label) main::@17
(label) main::@19
(label) main::@2
(label) main::@20
(label) main::@22
(label) main::@27
(label) main::@28
(label) main::@29
(label) main::@3
(label) main::@30
(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::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#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#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

Adding number conversion cast (unumber) 8 in (byte) KEY_3#0 ← (number) 8
Adding number conversion cast (unumber) 9 in (byte) KEY_W#0 ← (number) 9
Adding number conversion cast (unumber) $a in (byte) KEY_A#0 ← (number) $a
Adding number conversion cast (unumber) $b in (byte) KEY_4#0 ← (number) $b
Adding number conversion cast (unumber) $c in (byte) KEY_Z#0 ← (number) $c
Adding number conversion cast (unumber) $d in (byte) KEY_S#0 ← (number) $d
Adding number conversion cast (unumber) $e in (byte) KEY_E#0 ← (number) $e
Adding number conversion cast (unumber) $10 in (byte) KEY_5#0 ← (number) $10
Adding number conversion cast (unumber) $11 in (byte) KEY_R#0 ← (number) $11
Adding number conversion cast (unumber) $12 in (byte) KEY_D#0 ← (number) $12
Adding number conversion cast (unumber) $13 in (byte) KEY_6#0 ← (number) $13
Adding number conversion cast (unumber) $14 in (byte) KEY_C#0 ← (number) $14
Adding number conversion cast (unumber) $15 in (byte) KEY_F#0 ← (number) $15
Adding number conversion cast (unumber) $16 in (byte) KEY_T#0 ← (number) $16
Adding number conversion cast (unumber) $17 in (byte) KEY_X#0 ← (number) $17
Adding number conversion cast (unumber) $18 in (byte) KEY_7#0 ← (number) $18
Adding number conversion cast (unumber) $19 in (byte) KEY_Y#0 ← (number) $19
Adding number conversion cast (unumber) $1a in (byte) KEY_G#0 ← (number) $1a
Adding number conversion cast (unumber) $1b in (byte) KEY_8#0 ← (number) $1b
Adding number conversion cast (unumber) $1c in (byte) KEY_B#0 ← (number) $1c
Adding number conversion cast (unumber) $1d in (byte) KEY_H#0 ← (number) $1d
Adding number conversion cast (unumber) $1e in (byte) KEY_U#0 ← (number) $1e
Adding number conversion cast (unumber) $1f in (byte) KEY_V#0 ← (number) $1f
Adding number conversion cast (unumber) $20 in (byte) KEY_9#0 ← (number) $20
Adding number conversion cast (unumber) $21 in (byte) KEY_I#0 ← (number) $21
Adding number conversion cast (unumber) $22 in (byte) KEY_J#0 ← (number) $22
Adding number conversion cast (unumber) $23 in (byte) KEY_0#0 ← (number) $23
Adding number conversion cast (unumber) $24 in (byte) KEY_M#0 ← (number) $24
Adding number conversion cast (unumber) $25 in (byte) KEY_K#0 ← (number) $25
Adding number conversion cast (unumber) $26 in (byte) KEY_O#0 ← (number) $26
Adding number conversion cast (unumber) $27 in (byte) KEY_N#0 ← (number) $27
Adding number conversion cast (unumber) $28 in (byte) KEY_PLUS#0 ← (number) $28
Adding number conversion cast (unumber) $29 in (byte) KEY_P#0 ← (number) $29
Adding number conversion cast (unumber) $2a in (byte) KEY_L#0 ← (number) $2a
Adding number conversion cast (unumber) $2b in (byte) KEY_MINUS#0 ← (number) $2b
Adding number conversion cast (unumber) $2c in (byte) KEY_DOT#0 ← (number) $2c
Adding number conversion cast (unumber) $2d in (byte) KEY_COLON#0 ← (number) $2d
Adding number conversion cast (unumber) $2e in (byte) KEY_AT#0 ← (number) $2e
Adding number conversion cast (unumber) $2f in (byte) KEY_COMMA#0 ← (number) $2f
Adding number conversion cast (unumber) $30 in (byte) KEY_POUND#0 ← (number) $30
Adding number conversion cast (unumber) $31 in (byte) KEY_ASTERISK#0 ← (number) $31
Adding number conversion cast (unumber) $32 in (byte) KEY_SEMICOLON#0 ← (number) $32
Adding number conversion cast (unumber) $35 in (byte) KEY_EQUALS#0 ← (number) $35
Adding number conversion cast (unumber) $36 in (byte) KEY_ARROW_UP#0 ← (number) $36
Adding number conversion cast (unumber) $37 in (byte) KEY_SLASH#0 ← (number) $37
Adding number conversion cast (unumber) $38 in (byte) KEY_1#0 ← (number) $38
Adding number conversion cast (unumber) $39 in (byte) KEY_ARROW_LEFT#0 ← (number) $39
Adding number conversion cast (unumber) $3b in (byte) KEY_2#0 ← (number) $3b
Adding number conversion cast (unumber) $3c in (byte) KEY_SPACE#0 ← (number) $3c
Adding number conversion cast (unumber) $3e in (byte) KEY_Q#0 ← (number) $3e
Adding number conversion cast (unumber) $ff in *((byte*) CIA1_PORT_A_DDR#0) ← (number) $ff
Adding number conversion cast (unumber) 0 in *((byte*) CIA1_PORT_B_DDR#0) ← (number) 0
Adding number conversion cast (unumber) 7 in (number~) keyboard_key_pressed::$0 ← (byte) keyboard_key_pressed::key#1 & (number) 7
Adding number conversion cast (unumber) keyboard_key_pressed::$0 in (number~) keyboard_key_pressed::$0 ← (byte) keyboard_key_pressed::key#1 & (unumber)(number) 7
Adding number conversion cast (unumber) 3 in (byte~) keyboard_key_pressed::$1 ← (byte) keyboard_key_pressed::key#1 >> (number) 3
Adding number conversion cast (unumber) $400+$3e8 in (bool~) main::$1 ← (byte*) main::sc#1 < (number) $400+(number) $3e8
Adding number conversion cast (unumber) $ff in (bool~) main::$2 ← *((byte*) RASTER#0) != (number) $ff
Adding number conversion cast (unumber) $80 in (number~) main::$4 ← (byte) main::row_pressed_bits#2 & (number) $80
Adding number conversion cast (unumber) main::$4 in (number~) main::$4 ← (byte) main::row_pressed_bits#2 & (unumber)(number) $80
Adding number conversion cast (unumber) 0 in (bool~) main::$5 ← (unumber~) main::$4 != (number) 0
Adding number conversion cast (unumber) 2 in (number~) main::$6 ← (byte) main::row_pressed_bits#3 * (number) 2
Adding number conversion cast (unumber) main::$6 in (number~) main::$6 ← (byte) main::row_pressed_bits#3 * (unumber)(number) 2
Adding number conversion cast (unumber) $28 in (byte*~) main::$8 ← (byte*) main::screen#5 + (number) $28
Adding number conversion cast (unumber) $28 in (byte*~) main::$10 ← (byte*) main::screen#6 + (number) $28
Adding number conversion cast (unumber) 0 in (byte) main::i#0 ← (number) 0
Adding number conversion cast (unumber) $3f in (bool~) main::$12 ← (byte) main::key#0 != (number) $3f
Adding number conversion cast (unumber) 0 in (bool~) main::$15 ← (byte~) main::$14 != (number) 0
Adding number conversion cast (unumber) 5 in (bool~) main::$18 ← (byte) main::i#2 < (number) 5
Successful SSA optimization PassNAddNumberTypeConversions
Adding number conversion cast (byte) to elements in (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)(number) $3f, (byte) KEY_POUND#0, (byte)(number) $3f, (byte) KEY_ARROW_UP#0, (byte) KEY_ARROW_LEFT#0, (byte) KEY_SPACE#0, (byte)(number) $3f, (byte)(number) $3f, (byte)(number) $3f, (byte)(number) $3f, (byte)(number) $3f, (byte)(number) $3f, (byte)(number) $3f, (byte)(number) $3f, (byte)(number) $3f, (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)(number) $3f, (byte) KEY_EQUALS#0, (byte)(number) $3f, (byte)(number) $3f }
Adding number conversion cast (byte) to elements in (byte[8]) keyboard_matrix_row_bitmask#0 ← { (byte)(number) $fe, (byte)(number) $fd, (byte)(number) $fb, (byte)(number) $f7, (byte)(number) $ef, (byte)(number) $df, (byte)(number) $bf, (byte)(number) $7f }
Adding number conversion cast (byte) to elements in (byte[8]) keyboard_matrix_col_bitmask#0 ← { (byte)(number) 1, (byte)(number) 2, (byte)(number) 4, (byte)(number) 8, (byte)(number) $10, (byte)(number) $20, (byte)(number) $40, (byte)(number) $80 }
Successful SSA optimization PassNAddArrayNumberTypeConversions
Inlining cast (byte*) RASTER#0 ← (byte*)(number) $d012
Inlining cast (byte*) CIA1_PORT_A#0 ← (byte*)(number) $dc00
Inlining cast (byte*) CIA1_PORT_B#0 ← (byte*)(number) $dc01
Inlining cast (byte*) CIA1_PORT_A_DDR#0 ← (byte*)(number) $dc02
Inlining cast (byte*) CIA1_PORT_B_DDR#0 ← (byte*)(number) $dc03
Inlining cast (byte) KEY_3#0 ← (unumber)(number) 8
Inlining cast (byte) KEY_W#0 ← (unumber)(number) 9
Inlining cast (byte) KEY_A#0 ← (unumber)(number) $a
Inlining cast (byte) KEY_4#0 ← (unumber)(number) $b
Inlining cast (byte) KEY_Z#0 ← (unumber)(number) $c
Inlining cast (byte) KEY_S#0 ← (unumber)(number) $d
Inlining cast (byte) KEY_E#0 ← (unumber)(number) $e
Inlining cast (byte) KEY_5#0 ← (unumber)(number) $10
Inlining cast (byte) KEY_R#0 ← (unumber)(number) $11
Inlining cast (byte) KEY_D#0 ← (unumber)(number) $12
Inlining cast (byte) KEY_6#0 ← (unumber)(number) $13
Inlining cast (byte) KEY_C#0 ← (unumber)(number) $14
Inlining cast (byte) KEY_F#0 ← (unumber)(number) $15
Inlining cast (byte) KEY_T#0 ← (unumber)(number) $16
Inlining cast (byte) KEY_X#0 ← (unumber)(number) $17
Inlining cast (byte) KEY_7#0 ← (unumber)(number) $18
Inlining cast (byte) KEY_Y#0 ← (unumber)(number) $19
Inlining cast (byte) KEY_G#0 ← (unumber)(number) $1a
Inlining cast (byte) KEY_8#0 ← (unumber)(number) $1b
Inlining cast (byte) KEY_B#0 ← (unumber)(number) $1c
Inlining cast (byte) KEY_H#0 ← (unumber)(number) $1d
Inlining cast (byte) KEY_U#0 ← (unumber)(number) $1e
Inlining cast (byte) KEY_V#0 ← (unumber)(number) $1f
Inlining cast (byte) KEY_9#0 ← (unumber)(number) $20
Inlining cast (byte) KEY_I#0 ← (unumber)(number) $21
Inlining cast (byte) KEY_J#0 ← (unumber)(number) $22
Inlining cast (byte) KEY_0#0 ← (unumber)(number) $23
Inlining cast (byte) KEY_M#0 ← (unumber)(number) $24
Inlining cast (byte) KEY_K#0 ← (unumber)(number) $25
Inlining cast (byte) KEY_O#0 ← (unumber)(number) $26
Inlining cast (byte) KEY_N#0 ← (unumber)(number) $27
Inlining cast (byte) KEY_PLUS#0 ← (unumber)(number) $28
Inlining cast (byte) KEY_P#0 ← (unumber)(number) $29
Inlining cast (byte) KEY_L#0 ← (unumber)(number) $2a
Inlining cast (byte) KEY_MINUS#0 ← (unumber)(number) $2b
Inlining cast (byte) KEY_DOT#0 ← (unumber)(number) $2c
Inlining cast (byte) KEY_COLON#0 ← (unumber)(number) $2d
Inlining cast (byte) KEY_AT#0 ← (unumber)(number) $2e
Inlining cast (byte) KEY_COMMA#0 ← (unumber)(number) $2f
Inlining cast (byte) KEY_POUND#0 ← (unumber)(number) $30
Inlining cast (byte) KEY_ASTERISK#0 ← (unumber)(number) $31
Inlining cast (byte) KEY_SEMICOLON#0 ← (unumber)(number) $32
Inlining cast (byte) KEY_EQUALS#0 ← (unumber)(number) $35
Inlining cast (byte) KEY_ARROW_UP#0 ← (unumber)(number) $36
Inlining cast (byte) KEY_SLASH#0 ← (unumber)(number) $37
Inlining cast (byte) KEY_1#0 ← (unumber)(number) $38
Inlining cast (byte) KEY_ARROW_LEFT#0 ← (unumber)(number) $39
Inlining cast (byte) KEY_2#0 ← (unumber)(number) $3b
Inlining cast (byte) KEY_SPACE#0 ← (unumber)(number) $3c
Inlining cast (byte) KEY_Q#0 ← (unumber)(number) $3e
Inlining cast *((byte*) CIA1_PORT_A_DDR#0) ← (unumber)(number) $ff
Inlining cast *((byte*) CIA1_PORT_B_DDR#0) ← (unumber)(number) 0
Inlining cast (byte*) main::sc#0 ← (byte*)(number) $400
Inlining cast (byte*) main::screen#0 ← (byte*)(number) $400
Inlining cast (byte) main::i#0 ← (unumber)(number) 0
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 53266
Simplifying constant pointer cast (byte*) 56320
Simplifying constant pointer cast (byte*) 56321
Simplifying constant pointer cast (byte*) 56322
Simplifying constant pointer cast (byte*) 56323
Simplifying constant integer cast 8
Simplifying constant integer cast 9
Simplifying constant integer cast $a
Simplifying constant integer cast $b
Simplifying constant integer cast $c
Simplifying constant integer cast $d
Simplifying constant integer cast $e
Simplifying constant integer cast $10
Simplifying constant integer cast $11
Simplifying constant integer cast $12
Simplifying constant integer cast $13
Simplifying constant integer cast $14
Simplifying constant integer cast $15
Simplifying constant integer cast $16
Simplifying constant integer cast $17
Simplifying constant integer cast $18
Simplifying constant integer cast $19
Simplifying constant integer cast $1a
Simplifying constant integer cast $1b
Simplifying constant integer cast $1c
Simplifying constant integer cast $1d
Simplifying constant integer cast $1e
Simplifying constant integer cast $1f
Simplifying constant integer cast $20
Simplifying constant integer cast $21
Simplifying constant integer cast $22
Simplifying constant integer cast $23
Simplifying constant integer cast $24
Simplifying constant integer cast $25
Simplifying constant integer cast $26
Simplifying constant integer cast $27
Simplifying constant integer cast $28
Simplifying constant integer cast $29
Simplifying constant integer cast $2a
Simplifying constant integer cast $2b
Simplifying constant integer cast $2c
Simplifying constant integer cast $2d
Simplifying constant integer cast $2e
Simplifying constant integer cast $2f
Simplifying constant integer cast $30
Simplifying constant integer cast $31
Simplifying constant integer cast $32
Simplifying constant integer cast $35
Simplifying constant integer cast $36
Simplifying constant integer cast $37
Simplifying constant integer cast $38
Simplifying constant integer cast $39
Simplifying constant integer cast $3b
Simplifying constant integer cast $3c
Simplifying constant integer cast $3e
Simplifying constant integer cast $3f
Simplifying constant integer cast $3f
Simplifying constant integer cast $3f
Simplifying constant integer cast $3f
Simplifying constant integer cast $3f
Simplifying constant integer cast $3f
Simplifying constant integer cast $3f
Simplifying constant integer cast $3f
Simplifying constant integer cast $3f
Simplifying constant integer cast $3f
Simplifying constant integer cast $3f
Simplifying constant integer cast $3f
Simplifying constant integer cast $3f
Simplifying constant integer cast $3f
Simplifying constant integer cast $fe
Simplifying constant integer cast $fd
Simplifying constant integer cast $fb
Simplifying constant integer cast $f7
Simplifying constant integer cast $ef
Simplifying constant integer cast $df
Simplifying constant integer cast $bf
Simplifying constant integer cast $7f
Simplifying constant integer cast 1
Simplifying constant integer cast 2
Simplifying constant integer cast 4
Simplifying constant integer cast 8
Simplifying constant integer cast $10
Simplifying constant integer cast $20
Simplifying constant integer cast $40
Simplifying constant integer cast $80
Simplifying constant integer cast $ff
Simplifying constant integer cast 0
Simplifying constant integer cast 7
Simplifying constant integer cast 3
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast $ff
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast $80
Simplifying constant integer cast 0
Simplifying constant integer cast 2
Simplifying constant integer cast $28
Simplifying constant integer cast $28
Simplifying constant integer cast 0
Simplifying constant integer cast $3f
Simplifying constant integer cast 0
Simplifying constant integer cast 5
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 8
Finalized unsigned number type (byte) 9
Finalized unsigned number type (byte) $a
Finalized unsigned number type (byte) $b
Finalized unsigned number type (byte) $c
Finalized unsigned number type (byte) $d
Finalized unsigned number type (byte) $e
Finalized unsigned number type (byte) $10
Finalized unsigned number type (byte) $11
Finalized unsigned number type (byte) $12
Finalized unsigned number type (byte) $13
Finalized unsigned number type (byte) $14
Finalized unsigned number type (byte) $15
Finalized unsigned number type (byte) $16
Finalized unsigned number type (byte) $17
Finalized unsigned number type (byte) $18
Finalized unsigned number type (byte) $19
Finalized unsigned number type (byte) $1a
Finalized unsigned number type (byte) $1b
Finalized unsigned number type (byte) $1c
Finalized unsigned number type (byte) $1d
Finalized unsigned number type (byte) $1e
Finalized unsigned number type (byte) $1f
Finalized unsigned number type (byte) $20
Finalized unsigned number type (byte) $21
Finalized unsigned number type (byte) $22
Finalized unsigned number type (byte) $23
Finalized unsigned number type (byte) $24
Finalized unsigned number type (byte) $25
Finalized unsigned number type (byte) $26
Finalized unsigned number type (byte) $27
Finalized unsigned number type (byte) $28
Finalized unsigned number type (byte) $29
Finalized unsigned number type (byte) $2a
Finalized unsigned number type (byte) $2b
Finalized unsigned number type (byte) $2c
Finalized unsigned number type (byte) $2d
Finalized unsigned number type (byte) $2e
Finalized unsigned number type (byte) $2f
Finalized unsigned number type (byte) $30
Finalized unsigned number type (byte) $31
Finalized unsigned number type (byte) $32
Finalized unsigned number type (byte) $35
Finalized unsigned number type (byte) $36
Finalized unsigned number type (byte) $37
Finalized unsigned number type (byte) $38
Finalized unsigned number type (byte) $39
Finalized unsigned number type (byte) $3b
Finalized unsigned number type (byte) $3c
Finalized unsigned number type (byte) $3e
Finalized unsigned number type (byte) $ff
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 7
Finalized unsigned number type (byte) 3
Finalized unsigned number type (byte) $ff
Finalized unsigned number type (byte) $80
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) $28
Finalized unsigned number type (byte) $28
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $3f
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 5
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) keyboard_key_pressed::$0 ← (byte) keyboard_key_pressed::key#1 & (byte) 7
Inferred type updated to byte in (unumber~) main::$4 ← (byte) main::row_pressed_bits#2 & (byte) $80
Inferred type updated to byte in (unumber~) main::$6 ← (byte) main::row_pressed_bits#3 * (byte) 2
Inversing boolean not [142] (bool~) main::$13 ← (byte) main::key#0 == (byte) $3f from [141] (bool~) main::$12 ← (byte) main::key#0 != (byte) $3f
Inversing boolean not [155] (bool~) main::$16 ← (byte~) main::$14 == (byte) 0 from [154] (bool~) main::$15 ← (byte~) main::$14 != (byte) 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) keyboard_matrix_read::return#3 = (byte) keyboard_matrix_read::return#6 
Alias (byte*) main::screen#13 = (byte*) main::screen#16 
Alias (byte) main::row#2 = (byte) main::row#8 
Alias (byte) main::row_pressed_bits#0 = (byte~) main::$3 
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#4 (byte) main::row_pressed_bits#5 
Alias (byte) main::row#5 = (byte) main::row#7 (byte) main::row#6 
Alias (byte) main::row_pressed_bits#1 = (byte~) main::$6 
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::$8 (byte*) main::screen#6 
Alias (byte*) main::screen#2 = (byte*~) main::$10 
Alias (byte) keyboard_get_keycode::return#2 = (byte) keyboard_get_keycode::return#4 
Alias (byte) main::ch#2 = (byte) main::ch#5 (byte) main::ch#7 (byte) main::ch#6 (byte) main::ch#4 
Alias (byte*) main::screen#11 = (byte*) main::screen#14 (byte*) main::screen#17 (byte*) main::screen#15 (byte*) main::screen#7 
Alias (byte) main::i#3 = (byte) main::i#7 (byte) main::i#9 (byte) main::i#8 (byte) main::i#5 
Alias (byte) main::key#0 = (byte~) main::$11 (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
Identical Phi Values (byte) keyboard_key_pressed::key#1 (byte) keyboard_key_pressed::key#0
Identical Phi Values (byte) keyboard_get_keycode::ch#1 (byte) keyboard_get_keycode::ch#0
Identical Phi Values (byte*) main::screen#10 (byte*) main::screen#13
Identical Phi Values (byte) main::row#3 (byte) main::row#2
Identical Phi Values (byte*) main::screen#11 (byte*) main::screen#2
Identical Phi Values (byte*) main::screen#8 (byte*) main::screen#11
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$1 [94] if((byte*) main::sc#1<(word)(number) $400+(number) $3e8) goto main::@1
Simple Condition (bool~) main::$2 [98] if(*((byte*) RASTER#0)!=(byte) $ff) goto main::@6
Simple Condition (bool~) main::$5 [112] if((byte~) main::$4!=(byte) 0) goto main::@10
Simple Condition (bool~) main::$7 [122] if((byte) main::col#1!=rangelast(0,7)) goto main::@9
Simple Condition (bool~) main::$9 [128] if((byte) main::row#1!=rangelast(0,7)) goto main::@8
Simple Condition (bool~) main::$13 [143] if((byte) main::key#0==(byte) $3f) goto main::@17
Simple Condition (bool~) main::$17 [147] if((byte) main::ch#1!=rangelast(0,$3f)) goto main::@16
Simple Condition (bool~) main::$16 [156] if((byte~) main::$14==(byte) 0) goto main::@17
Simple Condition (bool~) main::$18 [164] if((byte) main::i#2<(byte) 5) goto main::@22
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant right-side identified [56] (byte[8]) keyboard_matrix_row_bitmask#0 ← { (byte) $fe, (byte) $fd, (byte) $fb, (byte) $f7, (byte) $ef, (byte) $df, (byte) $bf, (byte) $7f }
Constant right-side identified [57] (byte[8]) keyboard_matrix_col_bitmask#0 ← { (byte) 1, (byte) 2, (byte) 4, (byte) 8, (byte) $10, (byte) $20, (byte) $40, (byte) $80 }
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) RASTER#0 = (byte*) 53266
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) KEY_3#0 = 8
Constant (const byte) KEY_W#0 = 9
Constant (const byte) KEY_A#0 = $a
Constant (const byte) KEY_4#0 = $b
Constant (const byte) KEY_Z#0 = $c
Constant (const byte) KEY_S#0 = $d
Constant (const byte) KEY_E#0 = $e
Constant (const byte) KEY_5#0 = $10
Constant (const byte) KEY_R#0 = $11
Constant (const byte) KEY_D#0 = $12
Constant (const byte) KEY_6#0 = $13
Constant (const byte) KEY_C#0 = $14
Constant (const byte) KEY_F#0 = $15
Constant (const byte) KEY_T#0 = $16
Constant (const byte) KEY_X#0 = $17
Constant (const byte) KEY_7#0 = $18
Constant (const byte) KEY_Y#0 = $19
Constant (const byte) KEY_G#0 = $1a
Constant (const byte) KEY_8#0 = $1b
Constant (const byte) KEY_B#0 = $1c
Constant (const byte) KEY_H#0 = $1d
Constant (const byte) KEY_U#0 = $1e
Constant (const byte) KEY_V#0 = $1f
Constant (const byte) KEY_9#0 = $20
Constant (const byte) KEY_I#0 = $21
Constant (const byte) KEY_J#0 = $22
Constant (const byte) KEY_0#0 = $23
Constant (const byte) KEY_M#0 = $24
Constant (const byte) KEY_K#0 = $25
Constant (const byte) KEY_O#0 = $26
Constant (const byte) KEY_N#0 = $27
Constant (const byte) KEY_PLUS#0 = $28
Constant (const byte) KEY_P#0 = $29
Constant (const byte) KEY_L#0 = $2a
Constant (const byte) KEY_MINUS#0 = $2b
Constant (const byte) KEY_DOT#0 = $2c
Constant (const byte) KEY_COLON#0 = $2d
Constant (const byte) KEY_AT#0 = $2e
Constant (const byte) KEY_COMMA#0 = $2f
Constant (const byte) KEY_POUND#0 = $30
Constant (const byte) KEY_ASTERISK#0 = $31
Constant (const byte) KEY_SEMICOLON#0 = $32
Constant (const byte) KEY_EQUALS#0 = $35
Constant (const byte) KEY_ARROW_UP#0 = $36
Constant (const byte) KEY_SLASH#0 = $37
Constant (const byte) KEY_1#0 = $38
Constant (const byte) KEY_ARROW_LEFT#0 = $39
Constant (const byte) KEY_2#0 = $3b
Constant (const byte) KEY_SPACE#0 = $3c
Constant (const byte) KEY_Q#0 = $3e
Constant (const byte[8]) keyboard_matrix_row_bitmask#0 = { $fe, $fd, $fb, $f7, $ef, $df, $bf, $7f }
Constant (const byte[8]) keyboard_matrix_col_bitmask#0 = { 1, 2, 4, 8, $10, $20, $40, $80 }
Constant (const byte*) main::sc#0 = (byte*) 1024
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
if() condition always true - replacing block destination [96] if(true) goto main::@6
Successful SSA optimization Pass2ConstantIfs
Resolved ranged next value [120] main::col#1 ← ++ main::col#2 to ++
Resolved ranged comparison value [122] if(main::col#1!=rangelast(0,7)) goto main::@9 to (number) 8
Resolved ranged next value [126] main::row#1 ← ++ main::row#2 to ++
Resolved ranged comparison value [128] if(main::row#1!=rangelast(0,7)) goto main::@8 to (number) 8
Resolved ranged next value [145] main::ch#1 ← ++ main::ch#2 to ++
Resolved ranged comparison value [147] if(main::ch#1!=rangelast(0,$3f)) goto main::@16 to (number) $40
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Adding number conversion cast (unumber) 8 in if((byte) main::col#1!=(number) 8) goto main::@9
Adding number conversion cast (unumber) 8 in if((byte) main::row#1!=(number) 8) goto main::@8
Adding number conversion cast (unumber) $40 in if((byte) main::ch#1!=(number) $40) goto main::@16
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 8
Simplifying constant integer cast 8
Simplifying constant integer cast $40
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 8
Finalized unsigned number type (byte) 8
Finalized unsigned number type (byte) $40
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant right-side identified [0] (byte[]) keyboard_char_keycodes#0 ← { (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) $3f, (const byte) KEY_POUND#0, (byte) $3f, (const byte) KEY_ARROW_UP#0, (const byte) KEY_ARROW_LEFT#0, (const byte) KEY_SPACE#0, (byte) $3f, (byte) $3f, (byte) $3f, (byte) $3f, (byte) $3f, (byte) $3f, (byte) $3f, (byte) $3f, (byte) $3f, (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) $3f, (const byte) KEY_EQUALS#0, (byte) $3f, (byte) $3f }
Successful SSA optimization Pass2ConstantRValueConsolidation
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, $3f, KEY_POUND#0, $3f, KEY_ARROW_UP#0, KEY_ARROW_LEFT#0, KEY_SPACE#0, $3f, $3f, $3f, $3f, $3f, $3f, $3f, $3f, $3f, 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, $3f, KEY_EQUALS#0, $3f, $3f }
Successful SSA optimization Pass2ConstantIdentification
Rewriting multiplication to use shift [33] (byte) main::row_pressed_bits#1 ← (byte) main::row_pressed_bits#2 * (byte) 2
Successful SSA optimization Pass2MultiplyToShiftRewriting
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*) 1024
Constant inlined main::col#0 = (byte) 0
Constant inlined main::i#0 = (byte) 0
Constant inlined main::sc#0 = (byte*) 1024
Constant inlined main::row#0 = (byte) 0
Constant inlined main::ch#0 = (byte) 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::@14 and main::@8)
Added new block during phi lifting main::@33(between main::@11 and main::@9)
Added new block during phi lifting main::@34(between main::@17 and main::@16)
Added new block during phi lifting main::@35(between main::@29 and main::@17)
Added new block during phi lifting main::@36(between main::@30 and main::@17)
Added new block during phi lifting main::@37(between main::@17 and main::@22)
Added new block during phi lifting main::@38(between main::@22 and main::@22)
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @4
Adding NOP phi() at start of @12
Adding NOP phi() at start of @13
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@2
Adding NOP phi() at start of main::@27
Adding NOP phi() at start of main::@3
Adding NOP phi() at start of main::@7
CALL GRAPH
Calls in [] to main:3 
Calls in [main] to keyboard_init:12 keyboard_matrix_read:20 keyboard_get_keycode:37 keyboard_key_pressed:42 
Calls in [keyboard_key_pressed] to keyboard_matrix_read:72 

Created 10 initial phi equivalence classes
Coalesced [19] keyboard_matrix_read::rowid#4 ← keyboard_matrix_read::rowid#1
Coalesced [23] main::row_pressed_bits#7 ← main::row_pressed_bits#0
Coalesced [48] main::i#11 ← main::i#1
Coalesced [52] main::i#14 ← main::i#6
Coalesced [57] main::i#15 ← main::i#2
Coalesced [58] main::ch#8 ← main::ch#1
Coalesced [59] main::i#10 ← main::i#6
Coalesced (already) [60] main::i#13 ← main::i#3
Coalesced (already) [61] main::i#12 ← main::i#3
Coalesced [62] main::row#9 ← main::row#1
Coalesced [63] main::screen#18 ← main::screen#1
Coalesced [64] main::row_pressed_bits#6 ← main::row_pressed_bits#1
Coalesced [65] main::col#6 ← main::col#1
Coalesced [67] main::sc#3 ← main::sc#1
Coalesced [71] keyboard_matrix_read::rowid#3 ← keyboard_matrix_read::rowid#0
Coalesced down to 8 phi equivalence classes
Culled Empty Block (label) @4
Culled Empty Block (label) @13
Culled Empty Block (label) main::@27
Culled Empty Block (label) main::@3
Culled Empty Block (label) main::@7
Culled Empty Block (label) main::@37
Culled Empty Block (label) main::@38
Culled Empty Block (label) main::@34
Culled Empty Block (label) main::@36
Culled Empty Block (label) main::@35
Culled Empty Block (label) main::@32
Culled Empty Block (label) main::@33
Culled Empty Block (label) main::@31
Renumbering block @12 to @1
Renumbering block keyboard_key_pressed::@2 to keyboard_key_pressed::@1
Renumbering block main::@6 to main::@3
Renumbering block main::@8 to main::@4
Renumbering block main::@9 to main::@5
Renumbering block main::@10 to main::@6
Renumbering block main::@11 to main::@7
Renumbering block main::@12 to main::@8
Renumbering block main::@14 to main::@9
Renumbering block main::@15 to main::@10
Renumbering block main::@16 to main::@11
Renumbering block main::@17 to main::@12
Renumbering block main::@19 to main::@13
Renumbering block main::@20 to main::@14
Renumbering block main::@22 to main::@15
Renumbering block main::@28 to main::@16
Renumbering block main::@29 to main::@17
Renumbering block main::@30 to main::@18
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@2

FINAL CONTROL FLOW GRAPH
@begin: scope:[]  from
  [0] phi()
  to:@1
@1: scope:[]  from @begin
  [1] phi()
  [2] call main 
  to:@end
@end: scope:[]  from @1
  [3] phi()
main: scope:[main]  from @1
  [4] phi()
  to:main::@1
main::@1: scope:[main]  from main main::@1
  [5] (byte*) main::sc#2 ← phi( main/(byte*) 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)(number) $400+(number) $3e8) goto main::@1
  to:main::@2
main::@2: scope:[main]  from main::@1
  [9] phi()
  [10] call keyboard_init 
  to:main::@3
main::@3: scope:[main]  from main::@15 main::@2 main::@3
  [11] if(*((const byte*) RASTER#0)!=(byte) $ff) goto main::@3
  to:main::@4
main::@4: scope:[main]  from main::@3 main::@9
  [12] (byte*) main::screen#13 ← phi( main::@9/(byte*) main::screen#1 main::@3/(byte*) 1024 )
  [12] (byte) main::row#2 ← phi( main::@9/(byte) main::row#1 main::@3/(byte) 0 )
  [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::@16
main::@16: scope:[main]  from main::@4
  [16] (byte) main::row_pressed_bits#0 ← (byte) keyboard_matrix_read::return#3
  to:main::@5
main::@5: scope:[main]  from main::@16 main::@7
  [17] (byte) main::col#2 ← phi( main::@7/(byte) main::col#1 main::@16/(byte) 0 )
  [17] (byte) main::row_pressed_bits#2 ← phi( main::@7/(byte) main::row_pressed_bits#1 main::@16/(byte) main::row_pressed_bits#0 )
  [18] (byte~) main::$4 ← (byte) main::row_pressed_bits#2 & (byte) $80
  [19] if((byte~) main::$4!=(byte) 0) goto main::@6
  to:main::@8
main::@8: scope:[main]  from main::@5
  [20] *((byte*) main::screen#13 + (byte) main::col#2) ← (byte) '0'
  to:main::@7
main::@7: scope:[main]  from main::@6 main::@8
  [21] (byte) main::row_pressed_bits#1 ← (byte) main::row_pressed_bits#2 << (byte) 1
  [22] (byte) main::col#1 ← ++ (byte) main::col#2
  [23] if((byte) main::col#1!=(byte) 8) goto main::@5
  to:main::@9
main::@9: scope:[main]  from main::@7
  [24] (byte*) main::screen#1 ← (byte*) main::screen#13 + (byte) $28
  [25] (byte) main::row#1 ← ++ (byte) main::row#2
  [26] if((byte) main::row#1!=(byte) 8) goto main::@4
  to:main::@10
main::@10: scope:[main]  from main::@9
  [27] (byte*) main::screen#2 ← (byte*) main::screen#1 + (byte) $28
  to:main::@11
main::@11: scope:[main]  from main::@10 main::@12
  [28] (byte) main::i#3 ← phi( main::@10/(byte) 0 main::@12/(byte) main::i#6 )
  [28] (byte) main::ch#2 ← phi( main::@10/(byte) 0 main::@12/(byte) main::ch#1 )
  [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::@17
main::@17: scope:[main]  from main::@11
  [32] (byte) main::key#0 ← (byte) keyboard_get_keycode::return#2
  [33] if((byte) main::key#0==(byte) $3f) goto main::@12
  to:main::@13
main::@13: scope:[main]  from main::@17
  [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::@18
main::@18: scope:[main]  from main::@13
  [37] (byte~) main::$14 ← (byte) keyboard_key_pressed::return#2
  [38] if((byte~) main::$14==(byte) 0) goto main::@12
  to:main::@14
main::@14: scope:[main]  from main::@18
  [39] *((byte*) main::screen#2 + (byte) main::i#3) ← (byte) main::ch#2
  [40] (byte) main::i#1 ← ++ (byte) main::i#3
  to:main::@12
main::@12: scope:[main]  from main::@14 main::@17 main::@18
  [41] (byte) main::i#6 ← phi( main::@14/(byte) main::i#1 main::@17/(byte) main::i#3 main::@18/(byte) main::i#3 )
  [42] (byte) main::ch#1 ← ++ (byte) main::ch#2
  [43] if((byte) main::ch#1!=(byte) $40) goto main::@11
  to:main::@15
main::@15: scope:[main]  from main::@12 main::@15
  [44] (byte) main::i#4 ← phi( main::@12/(byte) main::i#6 main::@15/(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) 5) goto main::@15
  to:main::@3
main::@6: scope:[main]  from main::@5
  [48] *((byte*) main::screen#13 + (byte) main::col#2) ← (byte) '1'
  to:main::@7
keyboard_key_pressed: scope:[keyboard_key_pressed]  from main::@13
  [49] (byte) keyboard_key_pressed::colidx#0 ← (byte) keyboard_key_pressed::key#0 & (byte) 7
  [50] (byte) keyboard_key_pressed::rowidx#0 ← (byte) keyboard_key_pressed::key#0 >> (byte) 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::@1
keyboard_key_pressed::@1: 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::@1
  [56] return 
  to:@return
keyboard_matrix_read: scope:[keyboard_matrix_read]  from keyboard_key_pressed main::@4
  [57] (byte) keyboard_matrix_read::rowid#2 ← phi( keyboard_key_pressed/(byte) keyboard_matrix_read::rowid#0 main::@4/(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::@11
  [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::@2
  [63] *((const byte*) CIA1_PORT_A_DDR#0) ← (byte) $ff
  [64] *((const byte*) CIA1_PORT_B_DDR#0) ← (byte) 0
  to:keyboard_init::@return
keyboard_init::@return: scope:[keyboard_init]  from keyboard_init
  [65] return 
  to:@return


VARIABLE REGISTER WEIGHTS
(byte*) CIA1_PORT_A
(byte*) CIA1_PORT_A_DDR
(byte*) CIA1_PORT_B
(byte*) CIA1_PORT_B_DDR
(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_D
(byte) KEY_DOT
(byte) KEY_E
(byte) KEY_EQUALS
(byte) KEY_F
(byte) KEY_G
(byte) KEY_H
(byte) KEY_I
(byte) KEY_J
(byte) KEY_K
(byte) KEY_L
(byte) KEY_M
(byte) KEY_MINUS
(byte) KEY_N
(byte) KEY_O
(byte) KEY_P
(byte) KEY_PLUS
(byte) KEY_POUND
(byte) KEY_Q
(byte) KEY_R
(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*) RASTER
(byte[]) keyboard_char_keycodes
(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
(void()) main()
(byte~) main::$14 202.0
(byte~) main::$4 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#2 151.5
(byte) main::i#3 42.08333333333333
(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#1 main::row_pressed_bits#0 ]
[ main::col#2 main::col#1 ]
[ main::ch#2 main::ch#1 ]
[ main::i#4 main::i#3 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::$4 to zero page equivalence class [ main::$4 ]
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::$14 to zero page equivalence class [ main::$14 ]
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#1 main::row_pressed_bits#0 ]
[ main::col#2 main::col#1 ]
[ main::ch#2 main::ch#1 ]
[ main::i#4 main::i#3 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::$4 ]
[ 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::$14 ]
[ 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#1 main::row_pressed_bits#0 ]
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#3 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::$4 ]
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::$14 ]
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
  // File Comments
// Test keyboard input - in the keyboard matrix and mapping screen codes to key codes
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // 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
  // @begin
bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
  // @1
b1:
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
main_from_b1:
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
main: {
    .label _4 = $d
    .label _14 = $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
    // [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [5] phi (byte*) main::sc#2 = (byte*) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<$400
    sta sc
    lda #>$400
    sta sc+1
    jmp b1
  // Clear screen
    // [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
    // [5] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] *((byte*) main::sc#2) ← (byte) ' ' -- _deref_pbuz1=vbuc1 
    lda #' '
    ldy #0
    sta (sc),y
    // [7] (byte*) main::sc#1 ← ++ (byte*) main::sc#2 -- pbuz1=_inc_pbuz1 
    inc sc
    bne !+
    inc sc+1
  !:
    // [8] if((byte*) main::sc#1<(word)(number) $400+(number) $3e8) 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
  !:
    // [9] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
    jmp b2
    // main::@2
  b2:
    // [10] call keyboard_init 
    jsr keyboard_init
    jmp b3
    // main::@3
  b3:
    // [11] if(*((const byte*) RASTER#0)!=(byte) $ff) goto main::@3 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$ff
    cmp RASTER
    bne b3
    // [12] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
  b4_from_b3:
    // [12] phi (byte*) main::screen#13 = (byte*) 1024 [phi:main::@3->main::@4#0] -- pbuz1=pbuc1 
    lda #<$400
    sta screen
    lda #>$400
    sta screen+1
    // [12] phi (byte) main::row#2 = (byte) 0 [phi:main::@3->main::@4#1] -- vbuz1=vbuc1 
    lda #0
    sta row
    jmp b4
  // Read & print keyboard matrix
    // [12] phi from main::@9 to main::@4 [phi:main::@9->main::@4]
  b4_from_b9:
    // [12] phi (byte*) main::screen#13 = (byte*) main::screen#1 [phi:main::@9->main::@4#0] -- register_copy 
    // [12] phi (byte) main::row#2 = (byte) main::row#1 [phi:main::@9->main::@4#1] -- register_copy 
    jmp b4
    // main::@4
  b4:
    // [13] (byte) keyboard_matrix_read::rowid#1 ← (byte) main::row#2 -- vbuz1=vbuz2 
    lda row
    sta keyboard_matrix_read.rowid
    // [14] call keyboard_matrix_read 
    // [57] phi from main::@4 to keyboard_matrix_read [phi:main::@4->keyboard_matrix_read]
  keyboard_matrix_read_from_b4:
    // [57] phi (byte) keyboard_matrix_read::rowid#2 = (byte) keyboard_matrix_read::rowid#1 [phi:main::@4->keyboard_matrix_read#0] -- register_copy 
    jsr keyboard_matrix_read
    // [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 b16
    // main::@16
  b16:
    // [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
    // [17] phi from main::@16 to main::@5 [phi:main::@16->main::@5]
  b5_from_b16:
    // [17] phi (byte) main::col#2 = (byte) 0 [phi:main::@16->main::@5#0] -- vbuz1=vbuc1 
    lda #0
    sta col
    // [17] phi (byte) main::row_pressed_bits#2 = (byte) main::row_pressed_bits#0 [phi:main::@16->main::@5#1] -- register_copy 
    jmp b5
    // [17] phi from main::@7 to main::@5 [phi:main::@7->main::@5]
  b5_from_b7:
    // [17] phi (byte) main::col#2 = (byte) main::col#1 [phi:main::@7->main::@5#0] -- register_copy 
    // [17] phi (byte) main::row_pressed_bits#2 = (byte) main::row_pressed_bits#1 [phi:main::@7->main::@5#1] -- register_copy 
    jmp b5
    // main::@5
  b5:
    // [18] (byte~) main::$4 ← (byte) main::row_pressed_bits#2 & (byte) $80 -- vbuz1=vbuz2_band_vbuc1 
    lda #$80
    and row_pressed_bits
    sta _4
    // [19] if((byte~) main::$4!=(byte) 0) goto main::@6 -- vbuz1_neq_0_then_la1 
    lda _4
    cmp #0
    bne b6
    jmp b8
    // main::@8
  b8:
    // [20] *((byte*) main::screen#13 + (byte) main::col#2) ← (byte) '0' -- pbuz1_derefidx_vbuz2=vbuc1 
    lda #'0'
    ldy col
    sta (screen),y
    jmp b7
    // main::@7
  b7:
    // [21] (byte) main::row_pressed_bits#1 ← (byte) main::row_pressed_bits#2 << (byte) 1 -- vbuz1=vbuz1_rol_1 
    asl row_pressed_bits
    // [22] (byte) main::col#1 ← ++ (byte) main::col#2 -- vbuz1=_inc_vbuz1 
    inc col
    // [23] if((byte) main::col#1!=(byte) 8) goto main::@5 -- vbuz1_neq_vbuc1_then_la1 
    lda #8
    cmp col
    bne b5_from_b7
    jmp b9
    // main::@9
  b9:
    // [24] (byte*) main::screen#1 ← (byte*) main::screen#13 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 
    lda #$28
    clc
    adc screen
    sta screen
    bcc !+
    inc screen+1
  !:
    // [25] (byte) main::row#1 ← ++ (byte) main::row#2 -- vbuz1=_inc_vbuz1 
    inc row
    // [26] if((byte) main::row#1!=(byte) 8) goto main::@4 -- vbuz1_neq_vbuc1_then_la1 
    lda #8
    cmp row
    bne b4_from_b9
    jmp b10
    // main::@10
  b10:
    // [27] (byte*) main::screen#2 ← (byte*) main::screen#1 + (byte) $28 -- pbuz1=pbuz2_plus_vbuc1 
    lda #$28
    clc
    adc screen
    sta screen_2
    lda #0
    adc screen+1
    sta screen_2+1
    // [28] phi from main::@10 to main::@11 [phi:main::@10->main::@11]
  b11_from_b10:
    // [28] phi (byte) main::i#3 = (byte) 0 [phi:main::@10->main::@11#0] -- vbuz1=vbuc1 
    lda #0
    sta i
    // [28] phi (byte) main::ch#2 = (byte) 0 [phi:main::@10->main::@11#1] -- vbuz1=vbuc1 
    lda #0
    sta ch
    jmp b11
    // [28] phi from main::@12 to main::@11 [phi:main::@12->main::@11]
  b11_from_b12:
    // [28] phi (byte) main::i#3 = (byte) main::i#6 [phi:main::@12->main::@11#0] -- register_copy 
    // [28] phi (byte) main::ch#2 = (byte) main::ch#1 [phi:main::@12->main::@11#1] -- register_copy 
    jmp b11
    // main::@11
  b11:
    // [29] (byte) keyboard_get_keycode::ch#0 ← (byte) main::ch#2 -- vbuz1=vbuz2 
    lda ch
    sta keyboard_get_keycode.ch
    // [30] call keyboard_get_keycode 
    jsr keyboard_get_keycode
    // [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 b17
    // main::@17
  b17:
    // [32] (byte) main::key#0 ← (byte) keyboard_get_keycode::return#2 -- vbuz1=vbuz2 
    lda keyboard_get_keycode.return_2
    sta key
    // [33] if((byte) main::key#0==(byte) $3f) goto main::@12 -- vbuz1_eq_vbuc1_then_la1 
    lda #$3f
    cmp key
    beq b12_from_b17
    jmp b13
    // main::@13
  b13:
    // [34] (byte) keyboard_key_pressed::key#0 ← (byte) main::key#0 -- vbuz1=vbuz2 
    lda key
    sta keyboard_key_pressed.key
    // [35] call keyboard_key_pressed 
    jsr keyboard_key_pressed
    // [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 b18
    // main::@18
  b18:
    // [37] (byte~) main::$14 ← (byte) keyboard_key_pressed::return#2 -- vbuz1=vbuz2 
    lda keyboard_key_pressed.return_2
    sta _14
    // [38] if((byte~) main::$14==(byte) 0) goto main::@12 -- vbuz1_eq_0_then_la1 
    lda _14
    cmp #0
    beq b12_from_b18
    jmp b14
    // main::@14
  b14:
    // [39] *((byte*) main::screen#2 + (byte) main::i#3) ← (byte) main::ch#2 -- pbuz1_derefidx_vbuz2=vbuz3 
    lda ch
    ldy i
    sta (screen_2),y
    // [40] (byte) main::i#1 ← ++ (byte) main::i#3 -- vbuz1=_inc_vbuz1 
    inc i
    // [41] phi from main::@14 main::@17 main::@18 to main::@12 [phi:main::@14/main::@17/main::@18->main::@12]
  b12_from_b14:
  b12_from_b17:
  b12_from_b18:
    // [41] phi (byte) main::i#6 = (byte) main::i#1 [phi:main::@14/main::@17/main::@18->main::@12#0] -- register_copy 
    jmp b12
    // main::@12
  b12:
    // [42] (byte) main::ch#1 ← ++ (byte) main::ch#2 -- vbuz1=_inc_vbuz1 
    inc ch
    // [43] if((byte) main::ch#1!=(byte) $40) goto main::@11 -- vbuz1_neq_vbuc1_then_la1 
    lda #$40
    cmp ch
    bne b11_from_b12
    // [44] phi from main::@12 main::@15 to main::@15 [phi:main::@12/main::@15->main::@15]
  b15_from_b12:
  b15_from_b15:
    // [44] phi (byte) main::i#4 = (byte) main::i#6 [phi:main::@12/main::@15->main::@15#0] -- register_copy 
    jmp b15
  // Add some spaces
    // main::@15
  b15:
    // [45] *((byte*) main::screen#2 + (byte) main::i#4) ← (byte) ' ' -- pbuz1_derefidx_vbuz2=vbuc1 
    lda #' '
    ldy i
    sta (screen_2),y
    // [46] (byte) main::i#2 ← ++ (byte) main::i#4 -- vbuz1=_inc_vbuz1 
    inc i
    // [47] if((byte) main::i#2<(byte) 5) goto main::@15 -- vbuz1_lt_vbuc1_then_la1 
    lda i
    cmp #5
    bcc b15_from_b15
    jmp b3
    // main::@6
  b6:
    // [48] *((byte*) main::screen#13 + (byte) main::col#2) ← (byte) '1' -- pbuz1_derefidx_vbuz2=vbuc1 
    lda #'1'
    ldy col
    sta (screen),y
    jmp b7
}
  // 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
    // [49] (byte) keyboard_key_pressed::colidx#0 ← (byte) keyboard_key_pressed::key#0 & (byte) 7 -- vbuz1=vbuz2_band_vbuc1 
    lda #7
    and key
    sta colidx
    // [50] (byte) keyboard_key_pressed::rowidx#0 ← (byte) keyboard_key_pressed::key#0 >> (byte) 3 -- vbuz1=vbuz2_ror_3 
    lda key
    lsr
    lsr
    lsr
    sta rowidx
    // [51] (byte) keyboard_matrix_read::rowid#0 ← (byte) keyboard_key_pressed::rowidx#0 -- vbuz1=vbuz2 
    lda rowidx
    sta keyboard_matrix_read.rowid
    // [52] call keyboard_matrix_read 
    // [57] phi from keyboard_key_pressed to keyboard_matrix_read [phi:keyboard_key_pressed->keyboard_matrix_read]
  keyboard_matrix_read_from_keyboard_key_pressed:
    // [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
    // [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 b1
    // keyboard_key_pressed::@1
  b1:
    // [54] (byte~) keyboard_key_pressed::$2 ← (byte) keyboard_matrix_read::return#2 -- vbuz1=vbuz2 
    lda keyboard_matrix_read.return_2
    sta _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) -- vbuz1=vbuz2_band_pbuc1_derefidx_vbuz3 
    lda _2
    ldy colidx
    and keyboard_matrix_col_bitmask,y
    sta return
    jmp breturn
    // keyboard_key_pressed::@return
  breturn:
    // [56] return 
    rts
}
  // 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
    // [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
    // [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
    // keyboard_matrix_read::@return
  breturn:
    // [60] return 
    rts
}
  // 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
    // [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
    // keyboard_get_keycode::@return
  breturn:
    // [62] return 
    rts
}
  // keyboard_init
// Initialize keyboard reading by setting CIA#$ Data Direction Registers
keyboard_init: {
    // [63] *((const byte*) CIA1_PORT_A_DDR#0) ← (byte) $ff -- _deref_pbuc1=vbuc2 
    // Keyboard Matrix Columns Write Mode
    lda #$ff
    sta CIA1_PORT_A_DDR
    // [64] *((const byte*) CIA1_PORT_B_DDR#0) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    // Keyboard Matrix Columns Read Mode
    lda #0
    sta CIA1_PORT_B_DDR
    jmp breturn
    // keyboard_init::@return
  breturn:
    // [65] return 
    rts
}
  // File Data
  // 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)(number) $400+(number) $3e8) goto main::@1 [ main::sc#1 ] ( main:2 [ main::sc#1 ] ) always clobbers reg byte a 
Statement [11] if(*((const byte*) RASTER#0)!=(byte) $ff) goto main::@3 [ ] ( main:2 [ ] ) 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 
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#1 main::row_pressed_bits#0 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:8 [ main::col#2 main::col#1 ]
Statement [24] (byte*) main::screen#1 ← (byte*) main::screen#13 + (byte) $28 [ 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) $28 [ 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#3 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 [50] (byte) keyboard_key_pressed::rowidx#0 ← (byte) keyboard_key_pressed::key#0 >> (byte) 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#3 keyboard_key_pressed::colidx#0 keyboard_key_pressed::rowidx#0 ] ) always clobbers reg byte a 
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:9 [ main::ch#2 main::ch#1 ]
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:22 [ keyboard_key_pressed::colidx#0 ]
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#3 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#3 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) $ff [ ] ( main:2::keyboard_init:10 [ ] ) always clobbers reg byte a 
Statement [64] *((const byte*) CIA1_PORT_B_DDR#0) ← (byte) 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)(number) $400+(number) $3e8) goto main::@1 [ main::sc#1 ] ( main:2 [ main::sc#1 ] ) always clobbers reg byte a 
Statement [11] if(*((const byte*) RASTER#0)!=(byte) $ff) goto main::@3 [ ] ( main:2 [ ] ) always clobbers reg byte a 
Statement [18] (byte~) main::$4 ← (byte) main::row_pressed_bits#2 & (byte) $80 [ main::row#2 main::screen#13 main::row_pressed_bits#2 main::col#2 main::$4 ] ( main:2 [ main::row#2 main::screen#13 main::row_pressed_bits#2 main::col#2 main::$4 ] ) 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) $28 [ 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) $28 [ main::screen#2 ] ( main:2 [ main::screen#2 ] ) always clobbers reg byte a 
Statement [39] *((byte*) main::screen#2 + (byte) main::i#3) ← (byte) main::ch#2 [ main::screen#2 main::ch#2 main::i#3 ] ( main:2 [ main::screen#2 main::ch#2 main::i#3 ] ) 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 [50] (byte) keyboard_key_pressed::rowidx#0 ← (byte) keyboard_key_pressed::key#0 >> (byte) 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#3 keyboard_key_pressed::colidx#0 keyboard_key_pressed::rowidx#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#3 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#3 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) $ff [ ] ( main:2::keyboard_init:10 [ ] ) always clobbers reg byte a 
Statement [64] *((const byte*) CIA1_PORT_B_DDR#0) ← (byte) 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#1 main::row_pressed_bits#0 ] : 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#3 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::$4 ] : 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 a , 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::$14 ] : 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::$4 ] 1,490.13: zp ZP_BYTE:7 [ main::row_pressed_bits#2 main::row_pressed_bits#1 main::row_pressed_bits#0 ] 765.92: zp ZP_BYTE:10 [ main::i#4 main::i#3 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::$14 ] 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::$4 ] reg byte x [ main::row_pressed_bits#2 main::row_pressed_bits#1 main::row_pressed_bits#0 ] reg byte x [ main::i#4 main::i#3 main::i#6 main::i#1 main::i#2 ] zp ZP_WORD:5 [ main::screen#13 main::screen#1 ] zp ZP_BYTE:21 [ main::$14 ] 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 3072 possible.
Uplifting [keyboard_init] best 76825 combination 
Uplifting [] best 76825 combination 
Attempting to uplift remaining variables inzp ZP_BYTE:21 [ main::$14 ]
Uplifting [main] best 76225 combination reg byte a [ main::$14 ] 
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
Allocated (was zp ZP_BYTE:9) zp ZP_BYTE:7 [ main::ch#2 main::ch#1 ]
Allocated (was zp ZP_BYTE:22) zp ZP_BYTE:8 [ keyboard_key_pressed::colidx#0 ]

ASSEMBLER BEFORE OPTIMIZATION
  // File Comments
// Test keyboard input - in the keyboard matrix and mapping screen codes to key codes
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
  // 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
  // @begin
bbegin:
  // [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
  jmp b1
  // @1
b1:
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
main_from_b1:
  jsr main
  // [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
  jmp bend
  // @end
bend:
  // main
main: {
    .label sc = 2
    .label screen = 5
    .label row = 4
    .label ch = 7
    // [5] phi from main to main::@1 [phi:main->main::@1]
  b1_from_main:
    // [5] phi (byte*) main::sc#2 = (byte*) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<$400
    sta sc
    lda #>$400
    sta sc+1
    jmp b1
  // Clear screen
    // [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
  b1_from_b1:
    // [5] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@1->main::@1#0] -- register_copy 
    jmp b1
    // main::@1
  b1:
    // [6] *((byte*) main::sc#2) ← (byte) ' ' -- _deref_pbuz1=vbuc1 
    lda #' '
    ldy #0
    sta (sc),y
    // [7] (byte*) main::sc#1 ← ++ (byte*) main::sc#2 -- pbuz1=_inc_pbuz1 
    inc sc
    bne !+
    inc sc+1
  !:
    // [8] if((byte*) main::sc#1<(word)(number) $400+(number) $3e8) 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
  !:
    // [9] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
  b2_from_b1:
    jmp b2
    // main::@2
  b2:
    // [10] call keyboard_init 
    jsr keyboard_init
    jmp b3
    // main::@3
  b3:
    // [11] if(*((const byte*) RASTER#0)!=(byte) $ff) goto main::@3 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$ff
    cmp RASTER
    bne b3
    // [12] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
  b4_from_b3:
    // [12] phi (byte*) main::screen#13 = (byte*) 1024 [phi:main::@3->main::@4#0] -- pbuz1=pbuc1 
    lda #<$400
    sta screen
    lda #>$400
    sta screen+1
    // [12] phi (byte) main::row#2 = (byte) 0 [phi:main::@3->main::@4#1] -- vbuz1=vbuc1 
    lda #0
    sta row
    jmp b4
  // Read & print keyboard matrix
    // [12] phi from main::@9 to main::@4 [phi:main::@9->main::@4]
  b4_from_b9:
    // [12] phi (byte*) main::screen#13 = (byte*) main::screen#1 [phi:main::@9->main::@4#0] -- register_copy 
    // [12] phi (byte) main::row#2 = (byte) main::row#1 [phi:main::@9->main::@4#1] -- register_copy 
    jmp b4
    // main::@4
  b4:
    // [13] (byte) keyboard_matrix_read::rowid#1 ← (byte) main::row#2 -- vbuyy=vbuz1 
    ldy row
    // [14] call keyboard_matrix_read 
    // [57] phi from main::@4 to keyboard_matrix_read [phi:main::@4->keyboard_matrix_read]
  keyboard_matrix_read_from_b4:
    // [57] phi (byte) keyboard_matrix_read::rowid#2 = (byte) keyboard_matrix_read::rowid#1 [phi:main::@4->keyboard_matrix_read#0] -- register_copy 
    jsr keyboard_matrix_read
    // [15] (byte) keyboard_matrix_read::return#3 ← (byte) keyboard_matrix_read::return#0
    jmp b16
    // main::@16
  b16:
    // [16] (byte) main::row_pressed_bits#0 ← (byte) keyboard_matrix_read::return#3 -- vbuxx=vbuaa 
    tax
    // [17] phi from main::@16 to main::@5 [phi:main::@16->main::@5]
  b5_from_b16:
    // [17] phi (byte) main::col#2 = (byte) 0 [phi:main::@16->main::@5#0] -- vbuyy=vbuc1 
    ldy #0
    // [17] phi (byte) main::row_pressed_bits#2 = (byte) main::row_pressed_bits#0 [phi:main::@16->main::@5#1] -- register_copy 
    jmp b5
    // [17] phi from main::@7 to main::@5 [phi:main::@7->main::@5]
  b5_from_b7:
    // [17] phi (byte) main::col#2 = (byte) main::col#1 [phi:main::@7->main::@5#0] -- register_copy 
    // [17] phi (byte) main::row_pressed_bits#2 = (byte) main::row_pressed_bits#1 [phi:main::@7->main::@5#1] -- register_copy 
    jmp b5
    // main::@5
  b5:
    // [18] (byte~) main::$4 ← (byte) main::row_pressed_bits#2 & (byte) $80 -- vbuaa=vbuxx_band_vbuc1 
    txa
    and #$80
    // [19] if((byte~) main::$4!=(byte) 0) goto main::@6 -- vbuaa_neq_0_then_la1 
    cmp #0
    bne b6
    jmp b8
    // main::@8
  b8:
    // [20] *((byte*) main::screen#13 + (byte) main::col#2) ← (byte) '0' -- pbuz1_derefidx_vbuyy=vbuc1 
    lda #'0'
    sta (screen),y
    jmp b7
    // main::@7
  b7:
    // [21] (byte) main::row_pressed_bits#1 ← (byte) main::row_pressed_bits#2 << (byte) 1 -- vbuxx=vbuxx_rol_1 
    txa
    asl
    tax
    // [22] (byte) main::col#1 ← ++ (byte) main::col#2 -- vbuyy=_inc_vbuyy 
    iny
    // [23] if((byte) main::col#1!=(byte) 8) goto main::@5 -- vbuyy_neq_vbuc1_then_la1 
    cpy #8
    bne b5_from_b7
    jmp b9
    // main::@9
  b9:
    // [24] (byte*) main::screen#1 ← (byte*) main::screen#13 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 
    lda #$28
    clc
    adc screen
    sta screen
    bcc !+
    inc screen+1
  !:
    // [25] (byte) main::row#1 ← ++ (byte) main::row#2 -- vbuz1=_inc_vbuz1 
    inc row
    // [26] if((byte) main::row#1!=(byte) 8) goto main::@4 -- vbuz1_neq_vbuc1_then_la1 
    lda #8
    cmp row
    bne b4_from_b9
    jmp b10
    // main::@10
  b10:
    // [27] (byte*) main::screen#2 ← (byte*) main::screen#1 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 
    lda #$28
    clc
    adc screen
    sta screen
    bcc !+
    inc screen+1
  !:
    // [28] phi from main::@10 to main::@11 [phi:main::@10->main::@11]
  b11_from_b10:
    // [28] phi (byte) main::i#3 = (byte) 0 [phi:main::@10->main::@11#0] -- vbuxx=vbuc1 
    ldx #0
    // [28] phi (byte) main::ch#2 = (byte) 0 [phi:main::@10->main::@11#1] -- vbuz1=vbuc1 
    lda #0
    sta ch
    jmp b11
    // [28] phi from main::@12 to main::@11 [phi:main::@12->main::@11]
  b11_from_b12:
    // [28] phi (byte) main::i#3 = (byte) main::i#6 [phi:main::@12->main::@11#0] -- register_copy 
    // [28] phi (byte) main::ch#2 = (byte) main::ch#1 [phi:main::@12->main::@11#1] -- register_copy 
    jmp b11
    // main::@11
  b11:
    // [29] (byte) keyboard_get_keycode::ch#0 ← (byte) main::ch#2 -- vbuyy=vbuz1 
    ldy ch
    // [30] call keyboard_get_keycode 
    jsr keyboard_get_keycode
    // [31] (byte) keyboard_get_keycode::return#2 ← (byte) keyboard_get_keycode::return#0
    jmp b17
    // main::@17
  b17:
    // [32] (byte) main::key#0 ← (byte) keyboard_get_keycode::return#2
    // [33] if((byte) main::key#0==(byte) $3f) goto main::@12 -- vbuaa_eq_vbuc1_then_la1 
    cmp #$3f
    beq b12_from_b17
    jmp b13
    // main::@13
  b13:
    // [34] (byte) keyboard_key_pressed::key#0 ← (byte) main::key#0 -- vbuyy=vbuaa 
    tay
    // [35] call keyboard_key_pressed 
    jsr keyboard_key_pressed
    // [36] (byte) keyboard_key_pressed::return#2 ← (byte) keyboard_key_pressed::return#0
    jmp b18
    // main::@18
  b18:
    // [37] (byte~) main::$14 ← (byte) keyboard_key_pressed::return#2
    // [38] if((byte~) main::$14==(byte) 0) goto main::@12 -- vbuaa_eq_0_then_la1 
    cmp #0
    beq b12_from_b18
    jmp b14
    // main::@14
  b14:
    // [39] *((byte*) main::screen#2 + (byte) main::i#3) ← (byte) main::ch#2 -- pbuz1_derefidx_vbuxx=vbuz2 
    txa
    tay
    lda ch
    sta (screen),y
    // [40] (byte) main::i#1 ← ++ (byte) main::i#3 -- vbuxx=_inc_vbuxx 
    inx
    // [41] phi from main::@14 main::@17 main::@18 to main::@12 [phi:main::@14/main::@17/main::@18->main::@12]
  b12_from_b14:
  b12_from_b17:
  b12_from_b18:
    // [41] phi (byte) main::i#6 = (byte) main::i#1 [phi:main::@14/main::@17/main::@18->main::@12#0] -- register_copy 
    jmp b12
    // main::@12
  b12:
    // [42] (byte) main::ch#1 ← ++ (byte) main::ch#2 -- vbuz1=_inc_vbuz1 
    inc ch
    // [43] if((byte) main::ch#1!=(byte) $40) goto main::@11 -- vbuz1_neq_vbuc1_then_la1 
    lda #$40
    cmp ch
    bne b11_from_b12
    // [44] phi from main::@12 main::@15 to main::@15 [phi:main::@12/main::@15->main::@15]
  b15_from_b12:
  b15_from_b15:
    // [44] phi (byte) main::i#4 = (byte) main::i#6 [phi:main::@12/main::@15->main::@15#0] -- register_copy 
    jmp b15
  // Add some spaces
    // main::@15
  b15:
    // [45] *((byte*) main::screen#2 + (byte) main::i#4) ← (byte) ' ' -- pbuz1_derefidx_vbuxx=vbuc1 
    txa
    tay
    lda #' '
    sta (screen),y
    // [46] (byte) main::i#2 ← ++ (byte) main::i#4 -- vbuxx=_inc_vbuxx 
    inx
    // [47] if((byte) main::i#2<(byte) 5) goto main::@15 -- vbuxx_lt_vbuc1_then_la1 
    cpx #5
    bcc b15_from_b15
    jmp b3
    // main::@6
  b6:
    // [48] *((byte*) main::screen#13 + (byte) main::col#2) ← (byte) '1' -- pbuz1_derefidx_vbuyy=vbuc1 
    lda #'1'
    sta (screen),y
    jmp b7
}
  // 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 = 8
    // [49] (byte) keyboard_key_pressed::colidx#0 ← (byte) keyboard_key_pressed::key#0 & (byte) 7 -- vbuz1=vbuyy_band_vbuc1 
    tya
    and #7
    sta colidx
    // [50] (byte) keyboard_key_pressed::rowidx#0 ← (byte) keyboard_key_pressed::key#0 >> (byte) 3 -- vbuaa=vbuyy_ror_3 
    tya
    lsr
    lsr
    lsr
    // [51] (byte) keyboard_matrix_read::rowid#0 ← (byte) keyboard_key_pressed::rowidx#0 -- vbuyy=vbuaa 
    tay
    // [52] call keyboard_matrix_read 
    // [57] phi from keyboard_key_pressed to keyboard_matrix_read [phi:keyboard_key_pressed->keyboard_matrix_read]
  keyboard_matrix_read_from_keyboard_key_pressed:
    // [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
    // [53] (byte) keyboard_matrix_read::return#2 ← (byte) keyboard_matrix_read::return#0
    jmp b1
    // keyboard_key_pressed::@1
  b1:
    // [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) -- vbuaa=vbuaa_band_pbuc1_derefidx_vbuz1 
    ldy colidx
    and keyboard_matrix_col_bitmask,y
    jmp breturn
    // keyboard_key_pressed::@return
  breturn:
    // [56] return 
    rts
}
  // 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: {
    // [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
    // [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
    // keyboard_matrix_read::@return
  breturn:
    // [60] return 
    rts
}
  // 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: {
    // [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
    // keyboard_get_keycode::@return
  breturn:
    // [62] return 
    rts
}
  // keyboard_init
// Initialize keyboard reading by setting CIA#$ Data Direction Registers
keyboard_init: {
    // [63] *((const byte*) CIA1_PORT_A_DDR#0) ← (byte) $ff -- _deref_pbuc1=vbuc2 
    // Keyboard Matrix Columns Write Mode
    lda #$ff
    sta CIA1_PORT_A_DDR
    // [64] *((const byte*) CIA1_PORT_B_DDR#0) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    // Keyboard Matrix Columns Read Mode
    lda #0
    sta CIA1_PORT_B_DDR
    jmp breturn
    // keyboard_init::@return
  breturn:
    // [65] return 
    rts
}
  // File Data
  // 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 b1
Removing instruction jmp bend
Removing instruction jmp b1
Removing instruction jmp b2
Removing instruction jmp b3
Removing instruction jmp b4
Removing instruction jmp b16
Removing instruction jmp b5
Removing instruction jmp b8
Removing instruction jmp b7
Removing instruction jmp b9
Removing instruction jmp b10
Removing instruction jmp b11
Removing instruction jmp b17
Removing instruction jmp b13
Removing instruction jmp b18
Removing instruction jmp b14
Removing instruction jmp b12
Removing instruction jmp b15
Removing instruction jmp b1
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 b5_from_b7 with b5
Replacing label b4_from_b9 with b4
Replacing label b12_from_b17 with b12
Replacing label b12_from_b18 with b12
Replacing label b11_from_b12 with b11
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction main_from_b1:
Removing instruction bend_from_b1:
Removing instruction b1_from_b1:
Removing instruction b2_from_b1:
Removing instruction b4_from_b9:
Removing instruction b5_from_b7:
Removing instruction b11_from_b12:
Removing instruction b12_from_b14:
Removing instruction b12_from_b17:
Removing instruction b12_from_b18:
Removing instruction b15_from_b12:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction b1_from_main:
Removing instruction b2:
Removing instruction b4_from_b3:
Removing instruction keyboard_matrix_read_from_b4:
Removing instruction b16:
Removing instruction b5_from_b16:
Removing instruction b8:
Removing instruction b9:
Removing instruction b10:
Removing instruction b11_from_b10:
Removing instruction b17:
Removing instruction b13:
Removing instruction b18:
Removing instruction b14:
Removing instruction b15:
Removing instruction keyboard_matrix_read_from_keyboard_key_pressed:
Removing instruction b1:
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 b15_from_b15 to b2
Succesful ASM optimization Pass5RelabelLongLabels
Removing instruction jmp b1
Removing instruction jmp b4
Removing instruction jmp b5
Removing instruction jmp b11
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination

FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte*) CIA1_PORT_A
(const byte*) CIA1_PORT_A#0 CIA1_PORT_A = (byte*) 56320
(byte*) CIA1_PORT_A_DDR
(const byte*) CIA1_PORT_A_DDR#0 CIA1_PORT_A_DDR = (byte*) 56322
(byte*) CIA1_PORT_B
(const byte*) CIA1_PORT_B#0 CIA1_PORT_B = (byte*) 56321
(byte*) CIA1_PORT_B_DDR
(const byte*) CIA1_PORT_B_DDR#0 CIA1_PORT_B_DDR = (byte*) 56323
(byte) KEY_0
(const byte) KEY_0#0 KEY_0 = (byte) $23
(byte) KEY_1
(const byte) KEY_1#0 KEY_1 = (byte) $38
(byte) KEY_2
(const byte) KEY_2#0 KEY_2 = (byte) $3b
(byte) KEY_3
(const byte) KEY_3#0 KEY_3 = (byte) 8
(byte) KEY_4
(const byte) KEY_4#0 KEY_4 = (byte) $b
(byte) KEY_5
(const byte) KEY_5#0 KEY_5 = (byte) $10
(byte) KEY_6
(const byte) KEY_6#0 KEY_6 = (byte) $13
(byte) KEY_7
(const byte) KEY_7#0 KEY_7 = (byte) $18
(byte) KEY_8
(const byte) KEY_8#0 KEY_8 = (byte) $1b
(byte) KEY_9
(const byte) KEY_9#0 KEY_9 = (byte) $20
(byte) KEY_A
(const byte) KEY_A#0 KEY_A = (byte) $a
(byte) KEY_ARROW_LEFT
(const byte) KEY_ARROW_LEFT#0 KEY_ARROW_LEFT = (byte) $39
(byte) KEY_ARROW_UP
(const byte) KEY_ARROW_UP#0 KEY_ARROW_UP = (byte) $36
(byte) KEY_ASTERISK
(const byte) KEY_ASTERISK#0 KEY_ASTERISK = (byte) $31
(byte) KEY_AT
(const byte) KEY_AT#0 KEY_AT = (byte) $2e
(byte) KEY_B
(const byte) KEY_B#0 KEY_B = (byte) $1c
(byte) KEY_C
(const byte) KEY_C#0 KEY_C = (byte) $14
(byte) KEY_COLON
(const byte) KEY_COLON#0 KEY_COLON = (byte) $2d
(byte) KEY_COMMA
(const byte) KEY_COMMA#0 KEY_COMMA = (byte) $2f
(byte) KEY_D
(const byte) KEY_D#0 KEY_D = (byte) $12
(byte) KEY_DOT
(const byte) KEY_DOT#0 KEY_DOT = (byte) $2c
(byte) KEY_E
(const byte) KEY_E#0 KEY_E = (byte) $e
(byte) KEY_EQUALS
(const byte) KEY_EQUALS#0 KEY_EQUALS = (byte) $35
(byte) KEY_F
(const byte) KEY_F#0 KEY_F = (byte) $15
(byte) KEY_G
(const byte) KEY_G#0 KEY_G = (byte) $1a
(byte) KEY_H
(const byte) KEY_H#0 KEY_H = (byte) $1d
(byte) KEY_I
(const byte) KEY_I#0 KEY_I = (byte) $21
(byte) KEY_J
(const byte) KEY_J#0 KEY_J = (byte) $22
(byte) KEY_K
(const byte) KEY_K#0 KEY_K = (byte) $25
(byte) KEY_L
(const byte) KEY_L#0 KEY_L = (byte) $2a
(byte) KEY_M
(const byte) KEY_M#0 KEY_M = (byte) $24
(byte) KEY_MINUS
(const byte) KEY_MINUS#0 KEY_MINUS = (byte) $2b
(byte) KEY_N
(const byte) KEY_N#0 KEY_N = (byte) $27
(byte) KEY_O
(const byte) KEY_O#0 KEY_O = (byte) $26
(byte) KEY_P
(const byte) KEY_P#0 KEY_P = (byte) $29
(byte) KEY_PLUS
(const byte) KEY_PLUS#0 KEY_PLUS = (byte) $28
(byte) KEY_POUND
(const byte) KEY_POUND#0 KEY_POUND = (byte) $30
(byte) KEY_Q
(const byte) KEY_Q#0 KEY_Q = (byte) $3e
(byte) KEY_R
(const byte) KEY_R#0 KEY_R = (byte) $11
(byte) KEY_S
(const byte) KEY_S#0 KEY_S = (byte) $d
(byte) KEY_SEMICOLON
(const byte) KEY_SEMICOLON#0 KEY_SEMICOLON = (byte) $32
(byte) KEY_SLASH
(const byte) KEY_SLASH#0 KEY_SLASH = (byte) $37
(byte) KEY_SPACE
(const byte) KEY_SPACE#0 KEY_SPACE = (byte) $3c
(byte) KEY_T
(const byte) KEY_T#0 KEY_T = (byte) $16
(byte) KEY_U
(const byte) KEY_U#0 KEY_U = (byte) $1e
(byte) KEY_V
(const byte) KEY_V#0 KEY_V = (byte) $1f
(byte) KEY_W
(const byte) KEY_W#0 KEY_W = (byte) 9
(byte) KEY_X
(const byte) KEY_X#0 KEY_X = (byte) $17
(byte) KEY_Y
(const byte) KEY_Y#0 KEY_Y = (byte) $19
(byte) KEY_Z
(const byte) KEY_Z#0 KEY_Z = (byte) $c
(byte*) RASTER
(const byte*) RASTER#0 RASTER = (byte*) 53266
(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) $3f, (const byte) KEY_POUND#0, (byte) $3f, (const byte) KEY_ARROW_UP#0, (const byte) KEY_ARROW_LEFT#0, (const byte) KEY_SPACE#0, (byte) $3f, (byte) $3f, (byte) $3f, (byte) $3f, (byte) $3f, (byte) $3f, (byte) $3f, (byte) $3f, (byte) $3f, (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) $3f, (const byte) KEY_EQUALS#0, (byte) $3f, (byte) $3f }
(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::@1
(label) keyboard_key_pressed::@return
(byte) keyboard_key_pressed::colidx
(byte) keyboard_key_pressed::colidx#0 colidx zp ZP_BYTE:8 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) 1, (byte) 2, (byte) 4, (byte) 8, (byte) $10, (byte) $20, (byte) $40, (byte) $80 }
(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) $fe, (byte) $fd, (byte) $fb, (byte) $f7, (byte) $ef, (byte) $df, (byte) $bf, (byte) $7f }
(void()) main()
(byte~) main::$14 reg byte a 202.0
(byte~) main::$4 reg byte a 2002.0
(label) main::@1
(label) main::@10
(label) main::@11
(label) main::@12
(label) main::@13
(label) main::@14
(label) main::@15
(label) main::@16
(label) main::@17
(label) main::@18
(label) main::@2
(label) main::@3
(label) main::@4
(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:7 151.5
(byte) main::ch#2 ch zp ZP_BYTE:7 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#2 reg byte x 151.5
(byte) main::i#3 reg byte x 42.08333333333333
(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:5 71.0
(byte*) main::screen#13 screen zp ZP_WORD:5 169.53846153846155
(byte*) main::screen#2 screen zp ZP_WORD:5 10.142857142857142

zp ZP_WORD:2 [ main::sc#2 main::sc#1 ]
zp ZP_BYTE:4 [ main::row#2 main::row#1 ]
zp ZP_WORD:5 [ main::screen#13 main::screen#1 main::screen#2 ]
reg byte x [ main::row_pressed_bits#2 main::row_pressed_bits#1 main::row_pressed_bits#0 ]
reg byte y [ main::col#2 main::col#1 ]
zp ZP_BYTE:7 [ main::ch#2 main::ch#1 ]
reg byte x [ main::i#4 main::i#3 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::$4 ]
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::$14 ]
zp ZP_BYTE:8 [ 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

  // File Comments
// Test keyboard input - in the keyboard matrix and mapping screen codes to key codes
  // Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
  // 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
  // @begin
  // [1] phi from @begin to @1 [phi:@begin->@1]
  // @1
  // [2] call main 
  // [4] phi from @1 to main [phi:@1->main]
  // [3] phi from @1 to @end [phi:@1->@end]
  // @end
  // main
main: {
    .label sc = 2
    .label screen = 5
    .label row = 4
    .label ch = 7
    // [5] phi from main to main::@1 [phi:main->main::@1]
    // [5] phi (byte*) main::sc#2 = (byte*) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1 
    lda #<$400
    sta sc
    lda #>$400
    sta sc+1
  // Clear screen
    // [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
    // [5] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@1->main::@1#0] -- register_copy 
    // main::@1
  b1:
    // *sc = ' '
    // [6] *((byte*) main::sc#2) ← (byte) ' ' -- _deref_pbuz1=vbuc1 
    lda #' '
    ldy #0
    sta (sc),y
    // for(byte* sc = $400; sc<$400+1000;sc++)
    // [7] (byte*) main::sc#1 ← ++ (byte*) main::sc#2 -- pbuz1=_inc_pbuz1 
    inc sc
    bne !+
    inc sc+1
  !:
    // [8] if((byte*) main::sc#1<(word)(number) $400+(number) $3e8) goto main::@1 -- pbuz1_lt_vwuc1_then_la1 
    lda sc+1
    cmp #>$400+$3e8
    bcc b1
    bne !+
    lda sc
    cmp #<$400+$3e8
    bcc b1
  !:
    // [9] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
    // main::@2
    // keyboard_init()
    // [10] call keyboard_init 
    jsr keyboard_init
    // main::@3
  b3:
    // while (*RASTER!=$ff)
    // [11] if(*((const byte*) RASTER#0)!=(byte) $ff) goto main::@3 -- _deref_pbuc1_neq_vbuc2_then_la1 
    lda #$ff
    cmp RASTER
    bne b3
    // [12] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
    // [12] phi (byte*) main::screen#13 = (byte*) 1024 [phi:main::@3->main::@4#0] -- pbuz1=pbuc1 
    lda #<$400
    sta screen
    lda #>$400
    sta screen+1
    // [12] phi (byte) main::row#2 = (byte) 0 [phi:main::@3->main::@4#1] -- vbuz1=vbuc1 
    lda #0
    sta row
  // Read & print keyboard matrix
    // [12] phi from main::@9 to main::@4 [phi:main::@9->main::@4]
    // [12] phi (byte*) main::screen#13 = (byte*) main::screen#1 [phi:main::@9->main::@4#0] -- register_copy 
    // [12] phi (byte) main::row#2 = (byte) main::row#1 [phi:main::@9->main::@4#1] -- register_copy 
    // main::@4
  b4:
    // keyboard_matrix_read(row)
    // [13] (byte) keyboard_matrix_read::rowid#1 ← (byte) main::row#2 -- vbuyy=vbuz1 
    ldy row
    // [14] call keyboard_matrix_read 
    // [57] phi from main::@4 to keyboard_matrix_read [phi:main::@4->keyboard_matrix_read]
    // [57] phi (byte) keyboard_matrix_read::rowid#2 = (byte) keyboard_matrix_read::rowid#1 [phi:main::@4->keyboard_matrix_read#0] -- register_copy 
    jsr keyboard_matrix_read
    // keyboard_matrix_read(row)
    // [15] (byte) keyboard_matrix_read::return#3 ← (byte) keyboard_matrix_read::return#0
    // main::@16
    // row_pressed_bits = keyboard_matrix_read(row)
    // [16] (byte) main::row_pressed_bits#0 ← (byte) keyboard_matrix_read::return#3 -- vbuxx=vbuaa 
    tax
    // [17] phi from main::@16 to main::@5 [phi:main::@16->main::@5]
    // [17] phi (byte) main::col#2 = (byte) 0 [phi:main::@16->main::@5#0] -- vbuyy=vbuc1 
    ldy #0
    // [17] phi (byte) main::row_pressed_bits#2 = (byte) main::row_pressed_bits#0 [phi:main::@16->main::@5#1] -- register_copy 
    // [17] phi from main::@7 to main::@5 [phi:main::@7->main::@5]
    // [17] phi (byte) main::col#2 = (byte) main::col#1 [phi:main::@7->main::@5#0] -- register_copy 
    // [17] phi (byte) main::row_pressed_bits#2 = (byte) main::row_pressed_bits#1 [phi:main::@7->main::@5#1] -- register_copy 
    // main::@5
  b5:
    // row_pressed_bits & $80
    // [18] (byte~) main::$4 ← (byte) main::row_pressed_bits#2 & (byte) $80 -- vbuaa=vbuxx_band_vbuc1 
    txa
    and #$80
    // if( (row_pressed_bits & $80) != 0)
    // [19] if((byte~) main::$4!=(byte) 0) goto main::@6 -- vbuaa_neq_0_then_la1 
    cmp #0
    bne b6
    // main::@8
    // screen[col] = '0'
    // [20] *((byte*) main::screen#13 + (byte) main::col#2) ← (byte) '0' -- pbuz1_derefidx_vbuyy=vbuc1 
    lda #'0'
    sta (screen),y
    // main::@7
  b7:
    // row_pressed_bits = row_pressed_bits * 2
    // [21] (byte) main::row_pressed_bits#1 ← (byte) main::row_pressed_bits#2 << (byte) 1 -- vbuxx=vbuxx_rol_1 
    txa
    asl
    tax
    // for(byte col : 0..7)
    // [22] (byte) main::col#1 ← ++ (byte) main::col#2 -- vbuyy=_inc_vbuyy 
    iny
    // [23] if((byte) main::col#1!=(byte) 8) goto main::@5 -- vbuyy_neq_vbuc1_then_la1 
    cpy #8
    bne b5
    // main::@9
    // screen = screen + 40
    // [24] (byte*) main::screen#1 ← (byte*) main::screen#13 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 
    lda #$28
    clc
    adc screen
    sta screen
    bcc !+
    inc screen+1
  !:
    // for(byte row : 0..7)
    // [25] (byte) main::row#1 ← ++ (byte) main::row#2 -- vbuz1=_inc_vbuz1 
    inc row
    // [26] if((byte) main::row#1!=(byte) 8) goto main::@4 -- vbuz1_neq_vbuc1_then_la1 
    lda #8
    cmp row
    bne b4
    // main::@10
    // screen = screen + 40
    // [27] (byte*) main::screen#2 ← (byte*) main::screen#1 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 
    lda #$28
    clc
    adc screen
    sta screen
    bcc !+
    inc screen+1
  !:
    // [28] phi from main::@10 to main::@11 [phi:main::@10->main::@11]
    // [28] phi (byte) main::i#3 = (byte) 0 [phi:main::@10->main::@11#0] -- vbuxx=vbuc1 
    ldx #0
    // [28] phi (byte) main::ch#2 = (byte) 0 [phi:main::@10->main::@11#1] -- vbuz1=vbuc1 
    txa
    sta ch
    // [28] phi from main::@12 to main::@11 [phi:main::@12->main::@11]
    // [28] phi (byte) main::i#3 = (byte) main::i#6 [phi:main::@12->main::@11#0] -- register_copy 
    // [28] phi (byte) main::ch#2 = (byte) main::ch#1 [phi:main::@12->main::@11#1] -- register_copy 
    // main::@11
  b11:
    // keyboard_get_keycode(ch)
    // [29] (byte) keyboard_get_keycode::ch#0 ← (byte) main::ch#2 -- vbuyy=vbuz1 
    ldy ch
    // [30] call keyboard_get_keycode 
    jsr keyboard_get_keycode
    // [31] (byte) keyboard_get_keycode::return#2 ← (byte) keyboard_get_keycode::return#0
    // main::@17
    // key = keyboard_get_keycode(ch)
    // [32] (byte) main::key#0 ← (byte) keyboard_get_keycode::return#2
    // if(key!=$3f)
    // [33] if((byte) main::key#0==(byte) $3f) goto main::@12 -- vbuaa_eq_vbuc1_then_la1 
    cmp #$3f
    beq b12
    // main::@13
    // keyboard_key_pressed(key)
    // [34] (byte) keyboard_key_pressed::key#0 ← (byte) main::key#0 -- vbuyy=vbuaa 
    tay
    // [35] call keyboard_key_pressed 
    jsr keyboard_key_pressed
    // [36] (byte) keyboard_key_pressed::return#2 ← (byte) keyboard_key_pressed::return#0
    // main::@18
    // [37] (byte~) main::$14 ← (byte) keyboard_key_pressed::return#2
    // if(keyboard_key_pressed(key)!=0)
    // [38] if((byte~) main::$14==(byte) 0) goto main::@12 -- vbuaa_eq_0_then_la1 
    cmp #0
    beq b12
    // main::@14
    // screen[i++] = ch
    // [39] *((byte*) main::screen#2 + (byte) main::i#3) ← (byte) main::ch#2 -- pbuz1_derefidx_vbuxx=vbuz2 
    txa
    tay
    lda ch
    sta (screen),y
    // screen[i++] = ch;
    // [40] (byte) main::i#1 ← ++ (byte) main::i#3 -- vbuxx=_inc_vbuxx 
    inx
    // [41] phi from main::@14 main::@17 main::@18 to main::@12 [phi:main::@14/main::@17/main::@18->main::@12]
    // [41] phi (byte) main::i#6 = (byte) main::i#1 [phi:main::@14/main::@17/main::@18->main::@12#0] -- register_copy 
    // main::@12
  b12:
    // for( byte ch : 0..$3f )
    // [42] (byte) main::ch#1 ← ++ (byte) main::ch#2 -- vbuz1=_inc_vbuz1 
    inc ch
    // [43] if((byte) main::ch#1!=(byte) $40) goto main::@11 -- vbuz1_neq_vbuc1_then_la1 
    lda #$40
    cmp ch
    bne b11
    // [44] phi from main::@12 main::@15 to main::@15 [phi:main::@12/main::@15->main::@15]
  b2:
    // [44] phi (byte) main::i#4 = (byte) main::i#6 [phi:main::@12/main::@15->main::@15#0] -- register_copy 
  // Add some spaces
    // main::@15
    // screen[i++] = ' '
    // [45] *((byte*) main::screen#2 + (byte) main::i#4) ← (byte) ' ' -- pbuz1_derefidx_vbuxx=vbuc1 
    txa
    tay
    lda #' '
    sta (screen),y
    // screen[i++] = ' ';
    // [46] (byte) main::i#2 ← ++ (byte) main::i#4 -- vbuxx=_inc_vbuxx 
    inx
    // while (i<5)
    // [47] if((byte) main::i#2<(byte) 5) goto main::@15 -- vbuxx_lt_vbuc1_then_la1 
    cpx #5
    bcc b2
    jmp b3
    // main::@6
  b6:
    // screen[col] = '1'
    // [48] *((byte*) main::screen#13 + (byte) main::col#2) ← (byte) '1' -- pbuz1_derefidx_vbuyy=vbuc1 
    lda #'1'
    sta (screen),y
    jmp b7
}
  // 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 = 8
    // colidx = key&7
    // [49] (byte) keyboard_key_pressed::colidx#0 ← (byte) keyboard_key_pressed::key#0 & (byte) 7 -- vbuz1=vbuyy_band_vbuc1 
    tya
    and #7
    sta colidx
    // rowidx = key>>3
    // [50] (byte) keyboard_key_pressed::rowidx#0 ← (byte) keyboard_key_pressed::key#0 >> (byte) 3 -- vbuaa=vbuyy_ror_3 
    tya
    lsr
    lsr
    lsr
    // keyboard_matrix_read(rowidx)
    // [51] (byte) keyboard_matrix_read::rowid#0 ← (byte) keyboard_key_pressed::rowidx#0 -- vbuyy=vbuaa 
    tay
    // [52] call keyboard_matrix_read 
    // [57] phi from keyboard_key_pressed to keyboard_matrix_read [phi:keyboard_key_pressed->keyboard_matrix_read]
    // [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
    // keyboard_matrix_read(rowidx)
    // [53] (byte) keyboard_matrix_read::return#2 ← (byte) keyboard_matrix_read::return#0
    // keyboard_key_pressed::@1
    // [54] (byte~) keyboard_key_pressed::$2 ← (byte) keyboard_matrix_read::return#2
    // keyboard_matrix_read(rowidx) & keyboard_matrix_col_bitmask[colidx]
    // [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
    // keyboard_key_pressed::@return
    // }
    // [56] return 
    rts
}
  // 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: {
    // *CIA1_PORT_A = keyboard_matrix_row_bitmask[rowid]
    // [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
    // ~*CIA1_PORT_B
    // [59] (byte) keyboard_matrix_read::return#0 ← ~ *((const byte*) CIA1_PORT_B#0) -- vbuaa=_bnot__deref_pbuc1 
    lda CIA1_PORT_B
    eor #$ff
    // keyboard_matrix_read::@return
    // }
    // [60] return 
    rts
}
  // 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: {
    // return keyboard_char_keycodes[ch];
    // [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
    // keyboard_get_keycode::@return
    // }
    // [62] return 
    rts
}
  // keyboard_init
// Initialize keyboard reading by setting CIA#$ Data Direction Registers
keyboard_init: {
    // *CIA1_PORT_A_DDR = $ff
    // [63] *((const byte*) CIA1_PORT_A_DDR#0) ← (byte) $ff -- _deref_pbuc1=vbuc2 
    // Keyboard Matrix Columns Write Mode
    lda #$ff
    sta CIA1_PORT_A_DDR
    // *CIA1_PORT_B_DDR = $00
    // [64] *((const byte*) CIA1_PORT_B_DDR#0) ← (byte) 0 -- _deref_pbuc1=vbuc2 
    // Keyboard Matrix Columns Read Mode
    lda #0
    sta CIA1_PORT_B_DDR
    // keyboard_init::@return
    // }
    // [65] return 
    rts
}
  // File Data
  // 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

