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

```asm
<__getopt_long>:
  endbr64
  mov    D57(%rip),%rax
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    (%rax),%ebx
  cmp    %edi,%ebx
  jge    L249
  movslq %ebx,%rax
  mov    %rdx,%r12
  mov    %edi,%r11d
  mov    %rsi,%rbp
  mov    (%rsi,%rax,8),%rdx
  lea    0x0(,%rax,8),%rdi
  mov    %rdi,-0x10(%rsp)
  test   %rdx,%rdx
  je     L249
  cmpb   $0x2d,(%rdx)
  jne    L249
  movzbl 0x1(%rdx),%r14d
  mov    %rcx,%r10
  test   %r9d,%r9d
  je     L34
  test   %r14b,%r14b
  je     L118
  mov    (%rcx),%rax
  test   %rax,%rax
  je     L44
  movzbl 0x2(%rdx),%r15d
L192:
  lea    0x2(%rdx),%r9
  xor    %r13d,%r13d
L203:
  mov    %r15d,%esi
  mov    %r9,%rdx
  jmp    L23
  nopl   0x0(%rax,%rax,1)
L73:
  add    $0x1,%rax
  lea    0x1(%rdx),%rdi
  cmp    %cl,%sil
  jne    L241
  movzbl 0x1(%rdx),%esi
  mov    %rdi,%rdx
L23:
  movzbl (%rax),%ecx
  test   %cl,%cl
  jne    L73
L161:
  test   %sil,%sil
  je     L5
  cmp    $0x3d,%sil
  jne    L90
L5:
  mov    0x8(%r10),%rax
  cmp    $0x3d,%sil
  jne    L155
  test   %rax,%rax
  je     L90
  mov    D7(%rip),%rax
  add    $0x1,%rdx
  mov    %rdx,(%rax)
L246:
  mov    D57(%rip),%rax
  add    $0x1,%ebx
  mov    %ebx,(%rax)
  test   %r8,%r8
  je     L194
  mov    %r13d,(%r8)
L194:
  mov    0x10(%r10),%rdx
  mov    0x18(%r10),%eax
  test   %rdx,%rdx
  je     L151
  mov    %eax,(%rdx)
  xor    %eax,%eax
L151:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L34:
  cmp    $0x2d,%r14b
  jne    L118
  movzbl 0x2(%rdx),%r15d
  test   %r15b,%r15b
  je     L118
  mov    (%rcx),%rax
  test   %rax,%rax
  jne    L192
  jmp    L165
  cs nopw 0x0(%rax,%rax,1)
L118:
  pop    %rbx
  mov    %r12,%rdx
  mov    %rbp,%rsi
  mov    %r11d,%edi
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1050 <getopt@plt>
  nopl   0x0(%rax,%rax,1)
L241:
  cmpb   $0x0,(%rax)
  je     L146
L90:
  mov    0x20(%r10),%rax
  add    $0x20,%r10
  add    $0x1,%r13d
  test   %rax,%rax
  jne    L203
L44:
  cmp    $0x2d,%r14b
  jne    L118
L165:
  mov    D57(%rip),%rax
  add    $0x1,%ebx
  mov    %ebx,(%rax)
  mov    $0x3f,%eax
  jmp    L151
  cs nopw 0x0(%rax,%rax,1)
L146:
  movzbl 0x1(%rdx),%esi
  mov    %rdi,%rdx
  jmp    L161
L249:
  mov    $0xffffffff,%eax
  jmp    L151
L155:
  mov    D53(%rip),%rdx
  cmp    %rax,(%rdx)
  je     L279
  mov    D7(%rip),%rax
  movq   $0x0,(%rax)
  jmp    L246
L279:
  mov    D57(%rip),%rax
  add    $0x1,%ebx
  mov    D7(%rip),%rdx
  mov    %ebx,(%rax)
  mov    -0x10(%rsp),%rax
  mov    0x8(%rbp,%rax,1),%rax
  mov    %rax,(%rdx)
  test   %rax,%rax
  jne    L246
  mov    $0x3a,%eax
  jmp    L151
```

assistant: ```c
int __getopt_long(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *idx, int longonly) {
  if (optind >= argc || !argv[optind] || argv[optind][0] != '-')
    return -1;
  if ((longonly && argv[optind][1]) || (argv[optind][1] == '-' && argv[optind][2])) {
    int i;
    for (i = 0; longopts[i].name; i++) {
      const char *name = longopts[i].name;
      char *opt = argv[optind] + 2;
      while (*name && *name++ == *opt++)
        ;
      if (*name || (*opt && *opt != '='))
        continue;
      if (*opt == '=') {
        if (!longopts[i].has_arg)
          continue;
        optarg = opt + 1;
      } else {
        if (longopts[i].has_arg == required_argument) {
          if (!(optarg = argv[++optind]))
            return ':';
        } else
          optarg = NULL;
      }
      optind++;
      if (idx)
        *idx = i;
      if (longopts[i].flag) {
        *longopts[i].flag = longopts[i].val;
        return 0;
      }
      return longopts[i].val;
    }
    if (argv[optind][1] == '-') {
      optind++;
      return '?';
    }
  }
  return getopt(argc, argv, optstring);
}
```