user: Converte this assembly snippet into its equivalent C code:

```asm
<level_select>:
  endbr64
  push   %r13
  mov    $0x2b,%ecx
  mov    $0x5,%edx
  mov    $0x25,%esi
  push   %r12
  mov    $0xf,%edi
  lea    D15(%rip),%r12
  push   %rbp
  push   %rbx
  mov    $0x1,%ebx
  sub    $0x8,%rsp
  call   <newwin@plt>
  lea    D10(%rip),%rcx
  xor    %edx,%edx
  xor    %esi,%esi
  mov    %rax,%rdi
  mov    %rax,%rbp
  call   <mvwaddstr@plt>
  nopl   0x0(%rax)
L16:
  mov    %ebx,%r8d
  mov    %ebx,%esi
  mov    %r12,%rcx
  mov    $0x2,%edx
  mov    %rbp,%rdi
  add    $0x1,%ebx
  call   <mvwprintw@plt>
  cmp    $0xe,%ebx
  jne    L16
  mov    $0x1,%r12d
  mov    $0xd,%r13d
  nopl   0x0(%rax)
L21:
  xor    %edx,%edx
  mov    %r12d,%esi
  mov    %rbp,%rdi
  call   <draw_arrow@plt>
  mov    %rbp,%rdi
  call   <wrefresh@plt>
  xor    %eax,%eax
  call   <getch@plt>
  mov    %eax,%edi
  call   <tolower@plt>
  mov    %eax,%ebx
  xor    %eax,%eax
  call   <flushinp@plt>
  cmp    $0x80,%ebx
  je     L4
  cmp    $0x81,%ebx
  je     L71
  cmp    $0xa,%ebx
  je     L80
  cmp    $0x20,%ebx
  je     L80
  mov    %ebx,%esi
  mov    $0xa,%edi
  call   <pressed@plt>
  test   %eax,%eax
  jne    L13
  cmp    $0x1b,%ebx
  jne    L21
L13:
  mov    %rbp,%rdi
  mov    $0x25,%edx
  mov    $0xf,%esi
  mov    $0xffffffff,%r12d
  call   <erase_window@plt>
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   (%rax)
L71:
  xor    %edx,%edx
  mov    %r12d,%esi
  mov    %rbp,%rdi
  call   <erase_arrow@plt>
  lea    0x1(%r12),%eax
  cmp    $0xd,%r12d
  mov    $0x1,%r12d
  cmovne %eax,%r12d
  jmp    L21
  nopl   (%rax)
L4:
  xor    %edx,%edx
  mov    %r12d,%esi
  mov    %rbp,%rdi
  call   <erase_arrow@plt>
  lea    -0x1(%r12),%eax
  cmp    $0x1,%r12d
  cmove  %r13d,%eax
  mov    %eax,%r12d
  jmp    L21
  nopw   0x0(%rax,%rax,1)
L80:
  mov    %rbp,%rdi
  mov    $0x25,%edx
  mov    $0xf,%esi
  call   <erase_window@plt>
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

tool_calls: name: parse_data
arguments: tag: D15
datatype: string
name: parse_data
arguments: tag: D10
datatype: string

tool: D15: %d

tool: D10: Choose a level; press space or enter.

assistant: ```c
int level_select() {
  WINDOW *win = newwin(15, 37, 5, 43);
  int input;
  int active = 1;
  mvwaddstr(win, 0, 0, "Choose a level; press space or enter.");
  for (input = 1; input <= 13; input++) {
    mvwprintw(win, input, 2, "%d", input);
  }
  while (true) {
    draw_arrow(win, active, 0);
    wrefresh(win);
    input = tolower(getch());
    flushinp();
    switch (input) {
    case KEY_UP:
      erase_arrow(win, active, 0);
      if (active > 1) {
        active--;
        break;
      }
      active = 13;
      break;
    case KEY_DOWN:
      erase_arrow(win, active, 0);
      if (active < 13) {
        active++;
        break;
      }
      active = 1;
      break;
    default:
      if (input == '\n' || input == ' ') {
        erase_window(win, 15, 37);
        return active;
      } else if (pressed(10, input) || input == 27) {
        erase_window(win, 15, 37);
        return -1;
      }
      break;
    }
  }
}
```