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

```asm
<charmap_parse>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x428,%rsp
  mov    %rdi,%r13
  mov    %rsi,%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0x418(%rsp)
  xor    %eax,%eax
  lea    D30(%rip),%rsi
  call   <fopen@plt>
  test   %rax,%rax
  je     L51
  mov    %rax,%r12
  mov    $0x0,%ebx
  lea    D14(%rip),%r14
  lea    D53(%rip),%r15
  jmp    L24
L128:
  mov    %r15,%rdx
  mov    %ebx,%esi
  mov    %r13,%rdi
  call   <maperr@plt>
  jmp    L24
L36:
  add    $0x1,%eax
  mov    %eax,0xc(%rsp)
  lea    0xb(%rsp),%rdx
  lea    0xc(%rsp),%rsi
  lea    0x10(%rsp),%rdi
  call   <get_key@plt>
  test   %rax,%rax
  je     L186
  movzbl 0xa(%rsp),%eax
  cmp    %al,0xb(%rsp)
  jae    L155
  lea    D4(%rip),%rdx
  mov    %ebx,%esi
  mov    %r13,%rdi
  call   <maperr@plt>
  jmp    L24
L186:
  lea    D50(%rip),%rdx
  mov    %ebx,%esi
  mov    %r13,%rdi
  call   <maperr@plt>
  jmp    L24
L185:
  mov    %r14,%rdx
  mov    %ebx,%esi
  mov    %r13,%rdi
  call   <maperr@plt>
L24:
  lea    0x10(%rsp),%rdi
  mov    %r12,%rdx
  mov    $0x3ff,%esi
  call   <fgets@plt>
  test   %rax,%rax
  je     L74
  add    $0x1,%ebx
  movl   $0x0,0xc(%rsp)
  lea    0xa(%rsp),%rdx
  lea    0xc(%rsp),%rsi
  lea    0x10(%rsp),%rdi
  call   <get_key@plt>
  test   %rax,%rax
  je     L128
  mov    0xc(%rsp),%eax
  movslq %eax,%rdx
  cmpb   $0x2d,0x10(%rsp,%rdx,1)
  je     L36
  movzbl 0xa(%rsp),%eax
  mov    %al,0xb(%rsp)
L155:
  lea    0xc(%rsp),%rsi
  lea    0x10(%rsp),%rdi
  call   <eat_ws@plt>
  mov    0xc(%rsp),%eax
  movslq %eax,%rdx
  cmpb   $0x3d,0x10(%rsp,%rdx,1)
  jne    L185
  add    $0x1,%eax
  mov    %eax,0xc(%rsp)
  lea    0xc(%rsp),%rsi
  lea    0x10(%rsp),%rdi
  call   <eat_ws@plt>
  mov    0xc(%rsp),%eax
  movslq %eax,%rdx
  movzbl 0x10(%rsp,%rdx,1),%edx
  test   %dl,%dl
  je     L146
  cmp    $0xa,%dl
  je     L146
  cltq
  lea    0x10(%rsp,%rax,1),%rdi
  call   <get_value@plt>
  movzbl 0xa(%rsp),%ecx
  movzbl 0xb(%rsp),%edi
  cmp    %dil,%cl
  ja     L24
  mov    %ecx,%edx
  sub    %ecx,%eax
L48:
  movzbl %dl,%ecx
  lea    (%rax,%rdx,1),%esi
  mov    %sil,0x0(%rbp,%rcx,1)
  add    $0x1,%edx
  cmp    %dil,%dl
  jbe    L48
  mov    %dl,0xa(%rsp)
  jmp    L24
L146:
  lea    D52(%rip),%rdx
  mov    %ebx,%esi
  mov    %r13,%rdi
  call   <maperr@plt>
  mov    $0x0,%eax
  jmp    L73
L74:
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    $0x1,%eax
L73:
  mov    0x418(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L184
  add    $0x428,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L51:
  mov    $0x0,%eax
  jmp    L73
L184:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_tag: D30
data_type: string
name: retrieve_data
arguments: data_tag: D14
data_type: string
name: retrieve_data
arguments: data_tag: D53
data_type: string
name: retrieve_data
arguments: data_tag: D4
data_type: string
name: retrieve_data
arguments: data_tag: D50
data_type: string
name: retrieve_data
arguments: data_tag: D52
data_type: string

tool: D30: rt

tool: D14: `=' expected

tool: D53: key expected

tool: D4: invalid range

tool: D50: high limit key expected

tool: D52: value expected

assistant: ```c
int charmap_parse(const char *filename, unsigned char *map) {
  int lineno;
  FILE *fp;
  unsigned char key;
  unsigned char hkey;
  unsigned char value;
  int i;
  char line[1024];
  fp = fopen(filename, "rt");
  if (fp == NULL) {
    return 0;
  }
  lineno = 0;
  while (fgets(line, 1023, fp) != NULL) {
    lineno++;
    i = 0;
    if (get_key(line, &i, &key) == 0) {
      maperr(filename, lineno, "key expected");
      continue;
    }
    if (line[i] == '-') {
      i++;
      if (get_key(line, &i, &hkey) == 0) {
        maperr(filename, lineno, "high limit key expected");
        continue;
      }
      if (hkey < key) {
        maperr(filename, lineno, "invalid range");
        continue;
      }
    } else {
      hkey = key;
    }
    eat_ws(line, &i);
    if (line[i] != '=') {
      maperr(filename, lineno, "`=' expected");
      continue;
    }
    i++;
    eat_ws(line, &i);
    if ((line[i] == '\0') || (line[i] == '\n')) {
      maperr(filename, lineno, "value expected");
      return 0;
    }
    value = get_value(&line[i]);
    for (; key <= hkey; key++) {
      map[key] = value++;
    }
  }
  fclose(fp);
  return 1;
}
```