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

```asm
<readMx>:
  endbr64
  push   %r15
  push   %r14
  mov    %rsi,%r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %ecx,%ebp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,0x8(%rsp)
  mov    %rdx,0x10(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  movzbl (%rsi),%eax
  cmp    $0x5b,%al
  jne    L176
  movzbl 0x1(%rsi),%eax
  add    $0x1,%r14
L176:
  test   %al,%al
  je     L47
  mov    0x10(%rsp),%r13
  xor    %r12d,%r12d
  xor    %edx,%edx
  nopw   0x0(%rax,%rax,1)
L258:
  mov    0x8(%rsp),%rsi
  mov    %r12d,%ebx
  mov    %r12d,%r15d
  cmp    %r12d,(%rsi)
  jle    L168
  cmp    $0x7,%ebp
  je     L81
  jg     L145
  cmp    $0x3,%ebp
  je     L246
  cmp    $0x6,%ebp
  jne    L226
  mov    0x10(%rsp),%rax
  lea    D5(%rip),%rsi
  mov    %r14,%rdi
  lea    (%rax,%r12,8),%rdx
  xor    %eax,%eax
  call   <sscanf@plt>
  mov    %eax,%edx
L233:
  movzbl (%r14),%eax
  test   %edx,%edx
  je     L168
L50:
  cmp    $0x5d,%al
  je     L262
  lea    -0x2d(%rax),%ecx
  cmp    $0x1,%cl
  jbe    L247
  lea    -0x30(%rax),%ecx
  cmp    $0x9,%cl
  ja     L40
  nopl   (%rax)
L247:
  movzbl 0x1(%r14),%eax
  add    $0x1,%r14
  lea    -0x30(%rax),%ecx
  cmp    $0x9,%cl
  jbe    L247
  lea    -0x2d(%rax),%ecx
  cmp    $0x1,%cl
  jbe    L247
L40:
  cmp    $0x2c,%al
  je     L137
  cmp    $0x20,%al
  je     L137
  lea    0x1(%rbx),%r15d
  add    $0x1,%r12
  add    $0x4,%r13
  test   %al,%al
  jne    L258
L143:
  mov    %r14,%r11
L265:
  mov    0x8(%rsp),%rax
  mov    %r15d,(%rax)
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L185
  add    $0x38,%rsp
  mov    %r11,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  xchg   %ax,%ax
L145:
  cmp    $0xc,%ebp
  jne    L226
  mov    %r13,%rdx
  lea    D46(%rip),%rsi
  mov    %r14,%rdi
  xor    %eax,%eax
  call   <sscanf@plt>
  mov    %eax,%edx
  movzbl (%r14),%eax
  test   %edx,%edx
  jne    L50
L168:
  cmp    $0x5d,%al
  jne    L143
L262:
  lea    0x1(%r14),%r11
  jmp    L265
  nopl   (%rax)
L137:
  lea    0x1(%r14),%r11
  lea    0x1(%rbx),%r15d
  add    $0x1,%r12
  add    $0x4,%r13
  movzbl 0x1(%r14),%eax
  test   %al,%al
  je     L265
  mov    %r11,%r14
  jmp    L258
  nopl   (%rax)
L246:
  lea    0x24(%rsp),%rdx
  mov    %r14,%rdi
  lea    D46(%rip),%rsi
  xor    %eax,%eax
  call   <sscanf@plt>
  mov    0x10(%rsp),%rdi
  mov    %eax,%edx
  mov    0x24(%rsp),%eax
  mov    %al,(%rdi,%r12,1)
  jmp    L233
  nopw   0x0(%rax,%rax,1)
L226:
  lea    D27(%rip),%rdi
  mov    %edx,0x1c(%rsp)
  call   <ERROR@plt>
  mov    0x1c(%rsp),%edx
  jmp    L233
  nopl   0x0(%rax)
L81:
  mov    %r13,%rdx
  lea    D25(%rip),%rsi
  mov    %r14,%rdi
  xor    %eax,%eax
  call   <sscanf@plt>
  mov    %eax,%edx
  jmp    L233
L47:
  mov    %r14,%r11
  xor    %r15d,%r15d
  jmp    L265
L185:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_tag: D5
type_guessed: string
name: unpack_data
arguments: data_tag: D46
type_guessed: string
name: unpack_data
arguments: data_tag: D27
type_guessed: string
name: unpack_data
arguments: data_tag: D25
type_guessed: string

tool: D5: %lf

tool: D46: %d

tool: D27: Unsupported data type

tool: D25: %f

assistant: ```c
char *readMx(int *numel, char *datstr, void *data, int dtype) {
  char *cp = datstr;
  int i, nch = 0, tmp;
  if (*cp == '[')
    cp++;
  for (i = 0; *cp != 0 && i < *numel; i++) {
    switch (dtype) {
    case 12:
      nch = sscanf(cp, "%d", ((int *)data) + i);
      break;
    case 6:
      nch = sscanf(cp, "%lf", ((double *)data) + i);
      break;
    case 7:
      nch = sscanf(cp, "%f", ((float *)data) + i);
      break;
    case 3:
      nch = sscanf(cp, "%d", &tmp);
      ((char *)data)[i] = (char)tmp;
      break;
    default:
      ERROR("Unsupported data type");
    }
    if (nch == 0 || *cp == ']')
      break;
    for (; (*cp >= '0' && *cp <= '9') || *cp == '.' || *cp == '-'; cp++)
      ;
    if (*cp == ',' || *cp == ' ')
      cp++;
  }
  if (*cp == ']')
    cp++;
  *numel = i;
  return cp;
}
```