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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  lea    D91(%rip),%r14
  push   %r13
  lea    D146(%rip),%r13
  push   %r12
  lea    D50(%rip),%r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  call   <initscr@plt>
  pxor   %xmm0,%xmm0
  mov    $0x78,%edi
  movq   $0x0,0x10(%rsp)
  movaps %xmm0,(%rsp)
  movb   $0x0,0x18(%rsp)
  call   <malloc@plt>
  mov    $0x1,%esi
  lea    0x1c(%rax),%rdi
  mov    %si,0x12(%rax)
  mov    %rax,%rbx
  and    $0xfffffffffffffff8,%rdi
  movq   $0x10064,0xa(%rax)
  movq   $0x0,0x14(%rax)
  movq   $0x0,0x70(%rax)
  sub    %edi,%eax
  lea    0x78(%rax),%ecx
  xor    %eax,%eax
  shr    $0x3,%ecx
  rep stos %rax,%es:(%rdi)
  mov    $0xf,%edi
  call   <malloc@plt>
  lea    D136(%rip),%rdi
  mov    %rax,(%rbx)
  xor    %eax,%eax
  call   <printw@plt>
  mov    (%rbx),%rdi
  call   <getstr@plt>
  xor    %eax,%eax
  call   <refresh@plt>
  mov    (%rbx),%rsi
  lea    D52(%rip),%rdi
  xor    %eax,%eax
  call   <printw@plt>
  xor    %eax,%eax
  call   <refresh@plt>
  movzwl 0x12(%rbx),%eax
L133:
  lea    D111(%rip),%rbp
  jmp    L17
  nopl   0x0(%rax)
L84:
  cmp    $0x1,%ax
  je     L85
L135:
  movzwl 0x12(%rbx),%eax
L17:
  cmp    $0x1,%ax
  jne    L8
  movzwl 0x10(%rbx),%eax
  test   %ax,%ax
  jne    L84
  mov    %r14,%rdi
  mov    %rsp,%r15
  call   <printw@plt>
  xor    %eax,%eax
  call   <refresh@plt>
  mov    %r15,%rsi
  mov    %r12,%rdi
  call   <scanw@plt>
  mov    $0x5,%edx
  mov    %r13,%rsi
  mov    %r15,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  je     L74
  mov    $0x1,%edx
  lea    D67(%rip),%rsi
  mov    %r15,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L131
L74:
  lea    D144(%rip),%rdi
  xor    %eax,%eax
  call   <printw@plt>
  xor    %eax,%eax
  call   <refresh@plt>
  mov    $0x1,%ecx
  mov    %cx,0x10(%rbx)
L131:
  mov    $0x4,%edx
  mov    %rbp,%rsi
  mov    %r15,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  je     L20
  mov    $0x4,%edx
  lea    D41(%rip),%rsi
  mov    %r15,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L12
L20:
  lea    D22(%rip),%rdi
  xor    %eax,%eax
  call   <printw@plt>
  xor    %eax,%eax
  call   <refresh@plt>
  xor    %edx,%edx
  mov    %dx,0x12(%rbx)
L12:
  movzwl 0x10(%rbx),%eax
  cmp    $0x1,%ax
  jne    L135
L85:
  lea    D56(%rip),%rdi
  xor    %eax,%eax
  mov    %rsp,%rbp
  call   <printw@plt>
  xor    %eax,%eax
  call   <refresh@plt>
  mov    %rbp,%rsi
  mov    %r12,%rdi
  call   <scanw@plt>
  mov    $0x4,%edx
  lea    D124(%rip),%rsi
  mov    %rbp,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  je     L36
  mov    $0x1,%edx
  lea    D98(%rip),%rsi
  mov    %rbp,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  je     L36
  movzwl 0x12(%rbx),%eax
  jmp    L133
  nopw   0x0(%rax,%rax,1)
L8:
  lea    D59(%rip),%rdi
  xor    %eax,%eax
  call   <printw@plt>
  xor    %eax,%eax
  call   <refresh@plt>
  xor    %eax,%eax
  call   <getch@plt>
  xor    %eax,%eax
  call   <endwin@plt>
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L120
  add    $0x38,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L36:
  lea    D102(%rip),%rdi
  xor    %eax,%eax
  call   <printw@plt>
  xor    %eax,%eax
  call   <refresh@plt>
  xor    %eax,%eax
  mov    %ax,0x12(%rbx)
  xor    %eax,%eax
  jmp    L133
L120:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_label: D91
data_type: string
name: read_data
arguments: data_label: D146
data_type: string
name: read_data
arguments: data_label: D50
data_type: string
name: read_data
arguments: data_label: D136
data_type: string
name: read_data
arguments: data_label: D52
data_type: string
name: read_data
arguments: data_label: D111
data_type: string
name: read_data
arguments: data_label: D67
data_type: string
name: read_data
arguments: data_label: D144
data_type: string
name: read_data
arguments: data_label: D41
data_type: string
name: read_data
arguments: data_label: D22
data_type: string
name: read_data
arguments: data_label: D56
data_type: string
name: read_data
arguments: data_label: D124
data_type: string
name: read_data
arguments: data_label: D98
data_type: string
name: read_data
arguments: data_label: D59
data_type: string
name: read_data
arguments: data_label: D102
data_type: string

tool: D91: You are in a dark room. There is a door to the north.


tool: D146: north

tool: D50: %s

tool: D136: What is your name? (Maximum of 15 characters)


tool: D52: Welcome, %s


tool: D111: exit

tool: D67: n

tool: D144: You walk through the doorway.


tool: D41: quit

tool: D22: Exiting game...

tool: D56: You are now in a hallway. There is a light to the west.


tool: D124: west

tool: D98: w

tool: D59: Game over. Press any key to quit.


tool: D102: You are free.


assistant: ```c
int main() {
  initscr();
  struct player {
    char *name;
    unsigned short age;
    unsigned short health;
    unsigned int level;
    unsigned short location;
    unsigned short active;
    unsigned short inventory[50];
  };
  char input[25] = "";
  struct player *main_character = NULL;
  main_character = malloc(sizeof(struct player));
  main_character->level = 1;
  main_character->location = 0;
  main_character->health = 100;
  main_character->active = 1;
  for (unsigned short i = 0; i < 50; i++) {
    main_character->inventory[i] = 0;
  }
  main_character->name = malloc(sizeof(char) * 15);
  printw("What is your name? (Maximum of 15 characters)\n");
  getstr(main_character->name);
  refresh();
  printw("Welcome, %s\n", main_character->name);
  refresh();
  while (main_character->active == 1) {
    if (main_character->location == 0) {
      printw("You are in a dark room. There is a door to the north.\n");
      refresh();
      scanw("%s", &input);
      if (strncmp(input, "north", 5) == 0 || strncmp(input, "n", 1) == 0) {
        printw("You walk through the doorway.\n");
        refresh();
        main_character->location = 1;
      }
      if (strncmp(input, "exit", 4) == 0 || strncmp(input, "quit", 4) == 0) {
        printw("Exiting game...");
        refresh();
        main_character->active = 0;
      }
    }
    if (main_character->location == 1) {
      printw("You are now in a hallway. There is a light to the west.\n");
      refresh();
      scanw("%s", &input);
      if (strncmp(input, "west", 4) == 0 || strncmp(input, "w", 1) == 0) {
        printw("You are free.\n");
        refresh();
        main_character->active = 0;
      }
    }
  }
  printw("Game over. Press any key to quit.\n");
  refresh();
  getch();
  endwin();
  return 0;
}
```