user: Please show me the C implementation that matches the assembly code listed below:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  lea    -0x80000(%rsp),%r11
L179:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L179
  sub    $0x28,%rsp
  mov    %rsi,-0x80048(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  cmp    $0x2,%edi
  je     L43
  mov    (%rsi),%rsi
  lea    D67(%rip),%rdi
  call   <printf@plt>
L199:
  mov    -0x38(%rbp),%rdx
  sub    %fs:0x28,%rdx
  jne    L69
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L43:
  lea    D53(%rip),%rsi
  lea    D1(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L188
  lea    -0x80040(%rbp),%r13
  lea    -0x40(%rbp),%r14
  mov    %r13,%r12
  jmp    L221
L188:
  lea    D1(%rip),%rsi
  lea    D6(%rip),%rdi
  call   <printf@plt>
  mov    $0x1,%eax
  jmp    L199
L233:
  movb   $0x0,(%rcx)
  sub    $0x1,%rdx
  mov    %eax,%edi
  add    %edx,%edi
  js     L186
L89:
  mov    %rdx,%rcx
  add    (%rbx),%rcx
  movzbl (%rcx),%esi
  cmp    $0xa,%sil
  je     L233
  cmp    $0xd,%sil
  je     L233
L186:
  add    $0x8,%r12
  cmp    %r14,%r12
  je     L184
L221:
  mov    $0xc,%edi
  call   <malloc@plt>
  mov    %rax,%rdi
  mov    %r12,%rbx
  mov    %rax,(%r12)
  mov    %r15,%rdx
  mov    $0xc,%esi
  call   <fgets@plt>
  mov    (%r12),%rdi
  call   <strlen@plt>
  sub    $0x1,%eax
  js     L186
  movslq %eax,%rcx
  mov    %rcx,%rdx
  sub    %ecx,%eax
  jmp    L89
L184:
  mov    -0x80048(%rbp),%r15
  mov    0x8(%r15),%rdi
  call   <is_hex@plt>
  test   %rax,%rax
  je     L32
  mov    %rsp,%rbx
  mov    0x8(%r15),%rdi
  call   <normalized_hex_string_length@plt>
  cltq
  add    $0xf,%rax
  mov    %rax,%rdx
  and    $0xfffffffffffffff0,%rdx
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%rcx
  sub    %rax,%rcx
L293:
  cmp    %rcx,%rsp
  je     L57
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L293
L57:
  mov    %rdx,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  je     L132
  orq    $0x0,-0x8(%rsp,%rax,1)
L132:
  mov    %rsp,%r12
  mov    -0x80048(%rbp),%rax
  mov    0x8(%rax),%rsi
  mov    %rsp,%rdi
  call   <normalize_hex_string@plt>
  mov    %rsp,%rdi
  call   <max_phrase_length@plt>
  cltq
  add    $0xf,%rax
  mov    %rax,%rdx
  and    $0xfffffffffffffff0,%rdx
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%rcx
  sub    %rax,%rcx
L44:
  cmp    %rcx,%rsp
  je     L41
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L44
L41:
  mov    %rdx,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  je     L192
  orq    $0x0,-0x8(%rsp,%rax,1)
L192:
  lea    -0x80040(%rbp),%rdx
  mov    %r12,%rsi
  mov    %rsp,%rdi
  call   <get_phrase@plt>
  mov    %rsp,%rsi
  lea    D79(%rip),%rdi
  call   <printf@plt>
  mov    %rbx,%rsp
  jmp    L153
L32:
  mov    %rsp,%rbx
  mov    -0x80048(%rbp),%rax
  mov    0x8(%rax),%rdi
  call   <key_length@plt>
  cltq
  add    $0xf,%rax
  mov    %rax,%rdx
  and    $0xfffffffffffffff0,%rdx
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%rcx
  sub    %rax,%rcx
L299:
  cmp    %rcx,%rsp
  je     L56
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L299
L56:
  mov    %rdx,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  je     L156
  orq    $0x0,-0x8(%rsp,%rax,1)
L156:
  mov    %rsp,%r12
  mov    -0x80048(%rbp),%rax
  mov    0x8(%rax),%r15
  mov    %r15,%rdi
  call   <strlen@plt>
  add    $0x4f,%rax
  mov    %rax,%rdx
  and    $0xfffffffffffffff0,%rdx
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%rcx
  sub    %rax,%rcx
L154:
  cmp    %rcx,%rsp
  je     L169
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L154
L169:
  mov    %rdx,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  je     L49
  orq    $0x0,-0x8(%rsp,%rax,1)
L49:
  mov    %rsp,-0x80048(%rbp)
  lea    -0x80040(%rbp),%rdx
  mov    %rsp,%r8
  mov    $0x10000,%ecx
  mov    %r15,%rsi
  mov    %r12,%rdi
  call   <get_key@plt>
  mov    %rsp,%rdi
  call   <strlen@plt>
  test   %rax,%rax
  jg     L216
  mov    %r12,%rsi
  lea    D13(%rip),%rdi
  call   <printf@plt>
  mov    %rbx,%rsp
L153:
  mov    0x0(%r13),%rdi
  call   <free@plt>
  add    $0x8,%r13
  cmp    %r14,%r13
  jne    L153
  mov    $0x0,%eax
  jmp    L199
L216:
  mov    -0x80048(%rbp),%rsi
  lea    D30(%rip),%rdi
  call   <printf@plt>
  mov    %rbx,%rsp
  mov    $0x1,%eax
  jmp    L199
L69:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_label: D67
data_type: string
name: unpack_data
arguments: data_label: D53
data_type: string
name: unpack_data
arguments: data_label: D1
data_type: string
name: unpack_data
arguments: data_label: D6
data_type: string
name: unpack_data
arguments: data_label: D79
data_type: string
name: unpack_data
arguments: data_label: D13
data_type: string
name: unpack_data
arguments: data_label: D30
data_type: string

tool: D67: usage: %s [hex key] [key phrase]


tool: D53: r

tool: D1: words.txt

tool: D6: Could not find wordlist: '%s' is missing!


tool: D79: %s


tool: D13: 0x%s


tool: D30: ERROR: %s


assistant: ```c
int main(int argc, char **argv) {
  if (argc != 2) {
    return printf("usage: %s [hex key] [key phrase]\n", argv[0]);
  }
  char *wordlist[65536];
  FILE *fp = fopen("words.txt", "r");
  if (!fp) {
    printf("Could not find wordlist: '%s' is missing!\n", "words.txt");
    return 1;
  }
  for (int i = 0; i < 65536; i++) {
    wordlist[i] = malloc(11 + 1);
    fgets(wordlist[i], 11 + 1, fp);
    for (int j = strlen(wordlist[i]) - 1; j >= 0 && (wordlist[i][j] == '\n' || wordlist[i][j] == '\r'); j--) {
      wordlist[i][j] = '\0';
    }
  }
  if (is_hex(argv[1])) {
    char hex[normalized_hex_string_length(argv[1])];
    normalize_hex_string(hex, argv[1]);
    char phrase[max_phrase_length(hex)];
    get_phrase(phrase, hex, wordlist);
    printf("%s\n", phrase);
  } else {
    char key[key_length(argv[1])];
    char err_msg[64 + strlen(argv[1])];
    get_key(key, argv[1], wordlist, 65536, err_msg);
    if (strlen(err_msg) > 0) {
      printf("ERROR: %s\n", err_msg);
      return 1;
    } else {
      printf("0x%s\n", key);
    }
  }
  for (int i = 0; i < 65536; i++) {
    free(wordlist[i]);
  }
  return 0;
}
```