user: Please show me the C implementation that matches the assembly code listed below:

```asm
<__getopt_long>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    D6(%rip),%rax
  mov    (%rax),%ebp
  cmp    %edi,%ebp
  jge    L232
  mov    %edi,%r10d
  mov    %rsi,%r11
  mov    %rdx,%rbx
  mov    %rcx,%rsi
  movslq %ebp,%rax
  lea    0x0(,%rax,8),%r12
  mov    (%r11,%rax,8),%rdi
  test   %rdi,%rdi
  je     L148
  cmpb   $0x2d,(%rdi)
  jne    L128
  test   %r9d,%r9d
  je     L183
  cmpb   $0x0,0x1(%rdi)
  je     L157
  mov    (%rcx),%rax
  test   %rax,%rax
  je     L123
L193:
  mov    $0x0,%r9d
  jmp    L40
L183:
  cmpb   $0x2d,0x1(%rdi)
  jne    L157
  cmpb   $0x0,0x2(%rdi)
  jne    L14
L157:
  mov    %rbx,%rdx
  mov    %r11,%rsi
  mov    %r10d,%edi
  call   <getopt@plt>
L102:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L137:
  mov    D25(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,0x8(%rsi)
  je     L54
  mov    D72(%rip),%rax
  movq   $0x0,(%rax)
  jmp    L299
L54:
  add    $0x1,%ebp
  mov    D6(%rip),%rax
  mov    %ebp,(%rax)
  mov    0x8(%r11,%r12,1),%rax
  mov    D72(%rip),%rdx
  mov    %rax,(%rdx)
  test   %rax,%rax
  jne    L299
  mov    $0x3a,%eax
  jmp    L102
L292:
  mov    0x18(%rsi),%eax
  jmp    L102
L247:
  add    $0x1,%r9d
  add    $0x20,%rsi
  mov    (%rsi),%rax
  test   %rax,%rax
  je     L123
L40:
  lea    0x2(%rdi),%rdx
L215:
  movzbl (%rax),%ecx
  test   %cl,%cl
  je     L57
  add    $0x1,%rax
  add    $0x1,%rdx
  cmp    -0x1(%rdx),%cl
  je     L215
  cmpb   $0x0,(%rax)
  jne    L247
L57:
  movzbl (%rdx),%eax
  test   %al,%al
  je     L151
  cmp    $0x3d,%al
  jne    L247
L151:
  cmp    $0x3d,%al
  jne    L137
  cmpq   $0x0,0x8(%rsi)
  je     L247
  add    $0x1,%rdx
  mov    D72(%rip),%rax
  mov    %rdx,(%rax)
L299:
  mov    D6(%rip),%rax
  addl   $0x1,(%rax)
  test   %r8,%r8
  je     L37
  mov    %r9d,(%r8)
L37:
  mov    0x10(%rsi),%rax
  test   %rax,%rax
  je     L292
  mov    0x18(%rsi),%edx
  mov    %edx,(%rax)
  mov    $0x0,%eax
  jmp    L102
L123:
  cmpb   $0x2d,0x1(%rdi)
  jne    L157
  jmp    L283
L232:
  mov    $0xffffffff,%eax
  jmp    L102
L148:
  mov    $0xffffffff,%eax
  jmp    L102
L128:
  mov    $0xffffffff,%eax
  jmp    L102
L14:
  mov    (%rcx),%rax
  test   %rax,%rax
  jne    L193
L283:
  add    $0x1,%ebp
  mov    D6(%rip),%rax
  mov    %ebp,(%rax)
  mov    $0x3f,%eax
  jmp    L102
```

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