// File: rfotino[P]consolite-emulator/src/window.cpp
// Function: EmuWindow::_loadKeyMap(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void EmuWindow::_loadKeyMap(const std::string& keymap_filename) {
  std::ifstream keyMapFile(keymap_filename);
  if (!keyMapFile.good()) {
    std::cerr << "Error: Failed to open keymap '"
              << keymap_filename << "'." << std::endl;
    return;
  }
  // Key map should be in the form
  // KEY INPUT_ID
  std::string line;
  int line_num = 0;
  while (std::getline(keyMapFile, line)) {
    line_num++;
    std::istringstream iss(line);
    std::string keyStr;
    int inputId;
    if (!(iss >> keyStr >> inputId)) {
      continue;
    }
    KeySym keysym = XStringToKeysym(keyStr.c_str());
    if (!keysym) {
      std::cerr << "Warning: Key '" << keyStr << "' not recognized in "
                << keymap_filename << " on line " << line << "."
                << std::endl;
      continue;
    }
    _keyMap[inputId] = keysym;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4b0, %rsp            # imm = 0x4B0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x410(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x218(%rbp), %rdi
movl $0x8, %edx
callq 0x3480
movq -0x218(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x218(%rbp,%rax), %rdi
callq 0x34c0
movb %al, -0x403(%rbp)
jmp 0x50d3
movb -0x403(%rbp), %al
testb $0x1, %al
jne 0x516f
jmp 0x50e3
movq 0x9f06(%rip), %rdi      # 0xeff0
leaq 0x50ed(%rip), %rsi      # 0xa1de
callq 0x32c0
movq %rax, -0x418(%rbp)
jmp 0x50ff
movq -0x418(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x3260
movq %rax, -0x420(%rbp)
jmp 0x5118
movq -0x420(%rbp), %rdi
leaq 0x50d7(%rip), %rsi      # 0xa1fd
callq 0x32c0
movq %rax, -0x428(%rbp)
jmp 0x5134
movq -0x428(%rbp), %rdi
movq 0x9e7e(%rip), %rsi      # 0xefc0
callq 0x3300
jmp 0x5149
movl $0x1, -0x228(%rbp)
jmp 0x5476
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x5497
leaq -0x248(%rbp), %rdi
callq 0x3410
movl $0x0, -0x24c(%rbp)
leaq -0x218(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x3060
movq %rax, -0x430(%rbp)
jmp 0x51a1
movq -0x430(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3390
movb %al, -0x431(%rbp)
jmp 0x51bf
movb -0x431(%rbp), %al
testb $0x1, %al
jne 0x51ce
jmp 0x5460
movl -0x24c(%rbp), %eax
incl %eax
movl %eax, -0x24c(%rbp)
leaq -0x3d0(%rbp), %rdi
leaq -0x248(%rbp), %rsi
movl $0x8, %edx
callq 0x34b0
jmp 0x51f6
leaq -0x3f0(%rbp), %rdi
movq %rdi, -0x448(%rbp)
callq 0x3410
movq -0x448(%rbp), %rsi
leaq -0x3d0(%rbp), %rdi
callq 0x33b0
movq %rax, -0x440(%rbp)
jmp 0x5225
movq -0x440(%rbp), %rdi
leaq -0x3f4(%rbp), %rsi
callq 0x3180
movq %rax, -0x450(%rbp)
jmp 0x5241
movq -0x450(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3110
movb %al, -0x451(%rbp)
jmp 0x525f
movb -0x451(%rbp), %al
testb $0x1, %al
jne 0x526b
jmp 0x52c0
movl $0x2, -0x228(%rbp)
jmp 0x5432
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x548b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
leaq -0x3f0(%rbp), %rdi
callq 0x3190
leaq -0x3d0(%rbp), %rdi
callq 0x3130
jmp 0x548b
leaq -0x3f0(%rbp), %rdi
callq 0x30f0
movq %rax, %rdi
callq 0x3510
movq %rax, -0x460(%rbp)
jmp 0x52dd
movq -0x460(%rbp), %rax
movq %rax, -0x400(%rbp)
cmpq $0x0, -0x400(%rbp)
jne 0x53db
movq 0x9cf0(%rip), %rdi      # 0xeff0
leaq 0x4ef9(%rip), %rsi      # 0xa200
callq 0x32c0
movq %rax, -0x468(%rbp)
jmp 0x5315
movq -0x468(%rbp), %rdi
leaq -0x3f0(%rbp), %rsi
callq 0x3260
movq %rax, -0x470(%rbp)
jmp 0x5331
movq -0x470(%rbp), %rdi
leaq 0x4ed0(%rip), %rsi      # 0xa20f
callq 0x32c0
movq %rax, -0x478(%rbp)
jmp 0x534d
movq -0x478(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x3260
movq %rax, -0x480(%rbp)
jmp 0x5366
movq -0x480(%rbp), %rdi
leaq 0x4eb0(%rip), %rsi      # 0xa224
callq 0x32c0
movq %rax, -0x488(%rbp)
jmp 0x5382
movq -0x488(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x3260
movq %rax, -0x490(%rbp)
jmp 0x539e
movq -0x490(%rbp), %rdi
leaq 0x4e52(%rip), %rsi      # 0xa1fe
callq 0x32c0
movq %rax, -0x498(%rbp)
jmp 0x53ba
movq -0x498(%rbp), %rdi
movq 0x9bf8(%rip), %rsi      # 0xefc0
callq 0x3300
jmp 0x53cf
movl $0x2, -0x228(%rbp)
jmp 0x5432
movq -0x410(%rbp), %rdi
movq -0x400(%rbp), %rax
movq %rax, -0x4a8(%rbp)
addq $0x38, %rdi
movw -0x3f4(%rbp), %ax
movw %ax, -0x402(%rbp)
leaq -0x402(%rbp), %rsi
callq 0x5af0
movq %rax, -0x4a0(%rbp)
jmp 0x5417
movq -0x4a0(%rbp), %rax
movq -0x4a8(%rbp), %rcx
movq %rcx, (%rax)
movl $0x0, -0x228(%rbp)
leaq -0x3f0(%rbp), %rdi
callq 0x3190
leaq -0x3d0(%rbp), %rdi
callq 0x3130
movl -0x228(%rbp), %eax
testl %eax, %eax
je 0x545b
jmp 0x5456
jmp 0x5185
jmp 0x5185
leaq -0x248(%rbp), %rdi
callq 0x3190
movl $0x0, -0x228(%rbp)
leaq -0x218(%rbp), %rdi
callq 0x3070
addq $0x4b0, %rsp            # imm = 0x4B0
popq %rbp
retq
leaq -0x248(%rbp), %rdi
callq 0x3190
leaq -0x218(%rbp), %rdi
callq 0x3070
movq -0x220(%rbp), %rdi
callq 0x3520
nop