user: What would the C source look like for the assembly code provided here:

```asm
<getgrouplist>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %rcx,-0x40(%rbp)
  mov    -0x40(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0xc(%rbp)
  movl   $0x0,-0x10(%rbp)
  movl   $0x0,-0x14(%rbp)
  mov    -0x14(%rbp),%eax
  cmp    -0xc(%rbp),%eax
  jge    L122
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rax,%rdx
  mov    -0x30(%rbp),%rax
  mov    %rax,(%rdx)
  jmp    L100
L122:
  movl   $0xffffffff,-0x10(%rbp)
L100:
  addl   $0x1,-0x14(%rbp)
  mov    $0x0,%eax
  call   <setgrent@plt>
L67:
  jmp    L72
L56:
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  cmp    %rax,-0x30(%rbp)
  jne    L44
  jmp    L72
L44:
  movl   $0x0,-0x18(%rbp)
  jmp    L139
L149:
  mov    -0x8(%rbp),%rax
  mov    0x8(%rax),%rdx
  mov    -0x18(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    -0x28(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L74
  movl   $0x0,-0x18(%rbp)
  jmp    L117
L92:
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x38(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  jne    L40
  jmp    L67
L40:
  addl   $0x1,-0x18(%rbp)
L117:
  mov    -0xc(%rbp),%edx
  mov    -0x14(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <MIN@plt>
  cmp    %eax,-0x18(%rbp)
  jl     L92
  mov    -0x14(%rbp),%eax
  cmp    -0xc(%rbp),%eax
  jge    L95
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,(%rdx)
  jmp    L10
L95:
  movl   $0xffffffff,-0x10(%rbp)
L10:
  addl   $0x1,-0x14(%rbp)
  jmp    L72
L74:
  nop
  addl   $0x1,-0x18(%rbp)
L139:
  mov    -0x8(%rbp),%rax
  mov    0x8(%rax),%rdx
  mov    -0x18(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L149
L72:
  mov    $0x0,%eax
  call   <getgrent@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L56
  mov    $0x0,%eax
  call   <endgrent@plt>
  mov    -0x40(%rbp),%rax
  mov    -0x14(%rbp),%edx
  mov    %edx,(%rax)
  mov    -0x10(%rbp),%eax
  leave
  ret
```

assistant: ```c
int getgrouplist(const char *uname, gid_t agroup, gid_t *groups, int *grpcnt) {
  struct group *grp;
  int maxgroups, i, ngroups, ret;
  maxgroups = *grpcnt;
  ret = 0;
  ngroups = 0;
  if (ngroups < maxgroups)
    groups[ngroups] = agroup;
  else
    ret = -1;
  ngroups++;
  setgrent();
nextgroup:
  while ((grp = getgrent()) != NULL) {
    if (grp->gr_gid == agroup)
      continue;
    for (i = 0; grp->gr_mem[i]; i++) {
      if (strcmp(grp->gr_mem[i], uname) != 0)
        continue;
      for (i = 0; i < MIN(ngroups, maxgroups); i++) {
        if (grp->gr_gid == groups[i])
          goto nextgroup;
      }
      if (ngroups < maxgroups)
        groups[ngroups] = grp->gr_gid;
      else
        ret = -1;
      ngroups++;
      break;
    }
  }
  endgrent();
  *grpcnt = ngroups;
  return ret;
}
```