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

```asm
<load_hex_table>:
  endbr64
  push   %r15
  push   %r14
  mov    %rdi,%r14
  push   %r13
  movslq %edx,%r13
  push   %r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %rcx,%rbx
  sub    $0x18,%rsp
  test   %rdi,%rdi
  setne  %dil
  mov    %rcx,0x8(%rsp)
  movzbl %dil,%edi
  call   <assert@plt>
  xor    %edi,%edi
  test   %rbp,%rbp
  setne  %dil
  call   <assert@plt>
  test   %rbx,%rbx
  je     L201
  movl   $0x0,(%rbx)
L201:
  test   %r13d,%r13d
  jle    L232
  movslq %r13d,%rdx
  xor    %esi,%esi
  mov    %rbp,%rdi
  call   <memset@plt>
  jmp    L232
L19:
  add    $0x1,%r14
L232:
  movzbl (%r14),%eax
  cmp    $0x20,%al
  je     L19
  cmp    $0x9,%al
  je     L19
  mov    $0x2,%edx
  lea    D23(%rip),%rsi
  mov    %r14,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L131
  add    $0x2,%r14
L114:
  xor    %r12d,%r12d
  test   %r13d,%r13d
  jle    L8
  nopl   (%rax)
L105:
  mov    %r14,%rbx
  nopl   0x0(%rax,%rax,1)
L187:
  mov    %rbx,%r14
  movzbl (%rbx),%esi
  add    $0x1,%rbx
  cmp    $0x20,%sil
  je     L187
  cmp    $0x9,%sil
  je     L187
  test   %sil,%sil
  je     L229
  movsbl %sil,%r15d
  mov    %r15d,%edi
  call   <get_hex_digit@plt>
  cmp    $0xffffffff,%eax
  je     L124
  movzbl (%rbx),%esi
  shl    $0x4,%eax
  add    $0x2,%r14
  mov    %eax,%r15d
  test   %sil,%sil
  je     L103
  movsbl %sil,%ebx
  mov    %ebx,%edi
  call   <get_hex_digit@plt>
  cmp    $0xffffffff,%eax
  je     L267
  add    %eax,%r15d
  add    $0x1,%r12d
  add    $0x1,%rbp
  mov    %r15b,-0x1(%rbp)
  cmp    %r12d,%r13d
  jne    L105
  cs nopw 0x0(%rax,%rax,1)
L205:
  movzbl (%r14),%eax
  add    $0x1,%r14
  cmp    $0x20,%al
  je     L205
  cmp    $0x9,%al
  je     L205
  mov    %r13d,%r12d
  test   %al,%al
  jne    L169
L229:
  mov    0x8(%rsp),%rax
  mov    $0x1,%r15d
  test   %rax,%rax
  je     L272
  mov    %r12d,(%rax)
L272:
  add    $0x18,%rsp
  mov    %r15d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L131:
  cmpb   $0x22,(%r14)
  jne    L114
  mov    %r13d,%edx
  mov    %rbp,%rsi
  mov    %r14,%rdi
  call   <load_char_table@plt>
  mov    0x8(%rsp),%rbx
  mov    %eax,%r15d
  test   %rbx,%rbx
  je     L272
  cmp    $0x1,%eax
  jne    L272
  movb   $0x0,-0x1(%rbp,%r13,1)
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %eax,(%rbx)
  jmp    L272
L124:
  mov    %r15d,%esi
  lea    D22(%rip),%rdi
  xor    %eax,%eax
  xor    %r15d,%r15d
  call   <printf@plt>
  jmp    L272
L103:
  lea    D35(%rip),%rdi
  xor    %r15d,%r15d
  call   <puts@plt>
  jmp    L272
L267:
  mov    %ebx,%esi
  lea    D22(%rip),%rdi
  xor    %eax,%eax
  xor    %r15d,%r15d
  call   <printf@plt>
  jmp    L272
L8:
  jne    L229
  jmp    L205
  cs nopw 0x0(%rax,%rax,1)
L169:
  lea    D41(%rip),%rdi
  xor    %r15d,%r15d
  call   <puts@plt>
  jmp    L272
```

tool_calls: name: unpack_data
arguments: tag: D23
data_type: string
name: unpack_data
arguments: tag: D22
data_type: string
name: unpack_data
arguments: tag: D35
data_type: string
name: unpack_data
arguments: tag: D41
data_type: string

tool: D23: 0x

tool: D22: load_hex_table: invalid character '%c'


tool: D35: load_hex_table: incomplete hex byte

tool: D41: load_hex_table: too long hex value

assistant: ```c
int load_hex_table(const char *data, unsigned char *table, int maxlen, int *length) {
  int i, tmp, res;
  char c;
  assert(data != NULL);
  assert(table != NULL);
  if (length != NULL) {
    *length = 0;
  }
  for (i = 0; i < maxlen; i++) {
    table[i] = '\0';
  }
  while (*data == ' ' || *data == '\t')
    data++;
  if (strncmp(data, "0x", 2) == 0) {
    data += 2;
  } else if (*data == '"') {
    res = load_char_table(data, (char *)table, maxlen);
    if (length != NULL && res == 1) {
      table[maxlen - 1] = '\0';
      *length = strlen((char *)table);
    }
    return res;
  }
  for (i = 0; i < maxlen; i++) {
    do {
      c = *data++;
    } while (c == ' ' || c == '\t');
    if (c == '\0')
      break;
    tmp = get_hex_digit(c);
    if (tmp == -1) {
      printf("load_hex_table: invalid character '%c'\n", c);
      return 0;
    }
    res = tmp * 16;
    c = *data++;
    if (c == '\0') {
      printf("load_hex_table: incomplete hex byte\n");
      return 0;
    }
    tmp = get_hex_digit(c);
    if (tmp == -1) {
      printf("load_hex_table: invalid character '%c'\n", c);
      return 0;
    }
    res += tmp;
    table[i] = res;
  }
  if (i == maxlen) {
    do {
      c = *data++;
    } while (c == ' ' || c == '\t');
    if (c != '\0') {
      printf("load_hex_table: too long hex value\n");
      return 0;
    }
  }
  if (length != NULL) {
    *length = i;
  }
  return 1;
}
```