user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<__getopt_long>:
  endbr64
  mov    D7(%rip),%rax
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    (%rax),%ebx
  cmp    %edi,%ebx
  jge    L99
  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     L99
  cmpb   $0x2d,(%rdx)
  jne    L99
  movzbl 0x1(%rdx),%r14d
  mov    %rcx,%r10
  test   %r9d,%r9d
  je     L88
  test   %r14b,%r14b
  je     L279
  mov    (%rcx),%rax
  test   %rax,%rax
  je     L48
  movzbl 0x2(%rdx),%r15d
L194:
  lea    0x2(%rdx),%r9
  xor    %r13d,%r13d
L128:
  mov    %r15d,%esi
  mov    %r9,%rdx
  jmp    L219
  nopl   0x0(%rax,%rax,1)
L269:
  add    $0x1,%rax
  lea    0x1(%rdx),%rdi
  cmp    %sil,%cl
  jne    L188
  movzbl 0x1(%rdx),%esi
  mov    %rdi,%rdx
L219:
  movzbl (%rax),%ecx
  test   %cl,%cl
  jne    L269
L289:
  test   %sil,%sil
  je     L240
  cmp    $0x3d,%sil
  jne    L123
L240:
  mov    0x8(%r10),%rax
  cmp    $0x3d,%sil
  jne    L25
  test   %rax,%rax
  je     L123
  mov    D79(%rip),%rax
  add    $0x1,%rdx
  mov    %rdx,(%rax)
L202:
  mov    D7(%rip),%rax
  add    $0x1,%ebx
  mov    %ebx,(%rax)
  test   %r8,%r8
  je     L266
  mov    %r13d,(%r8)
L266:
  mov    0x10(%r10),%rdx
  mov    0x18(%r10),%eax
  test   %rdx,%rdx
  je     L8
  mov    %eax,(%rdx)
  xor    %eax,%eax
L8:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L88:
  cmp    $0x2d,%r14b
  jne    L279
  movzbl 0x2(%rdx),%r15d
  test   %r15b,%r15b
  je     L279
  mov    (%rcx),%rax
  test   %rax,%rax
  jne    L194
  jmp    L27
  cs nopw 0x0(%rax,%rax,1)
L279:
  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)
L188:
  cmpb   $0x0,(%rax)
  je     L169
L123:
  mov    0x20(%r10),%rax
  add    $0x20,%r10
  add    $0x1,%r13d
  test   %rax,%rax
  jne    L128
L48:
  cmp    $0x2d,%r14b
  jne    L279
L27:
  mov    D7(%rip),%rax
  add    $0x1,%ebx
  mov    %ebx,(%rax)
  mov    $0x3f,%eax
  jmp    L8
  cs nopw 0x0(%rax,%rax,1)
L169:
  movzbl 0x1(%rdx),%esi
  mov    %rdi,%rdx
  jmp    L289
L99:
  mov    $0xffffffff,%eax
  jmp    L8
L25:
  mov    D43(%rip),%rdx
  cmp    %rax,(%rdx)
  je     L126
  mov    D79(%rip),%rax
  movq   $0x0,(%rax)
  jmp    L202
L126:
  mov    D7(%rip),%rax
  add    $0x1,%ebx
  mov    D79(%rip),%rdx
  mov    %ebx,(%rax)
  mov    -0x10(%rsp),%rax
  mov    0x8(%rbp,%rax,1),%rax
  mov    %rax,(%rdx)
  test   %rax,%rax
  jne    L202
  mov    $0x3a,%eax
  jmp    L8
```

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);
}
```