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

```asm
<isAuthenticatedAsAdministratorForTask>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x58,%rsp
  mov    %edi,-0x74(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x6c(%rbp)
  mov    $0x0,%eax
  call   <isAuthenticatedAsRoot@plt>
  test   %rax,%rax
  je     L110
  mov    $0x1,%eax
  jmp    L105
L110:
  mov    $0x0,%eax
  call   <getuid@plt>
  mov    %rax,-0x60(%rbp)
  cmpq   $0x0,-0x60(%rbp)
  je     L36
  mov    %rsp,%rax
  mov    %rax,%rbx
  mov    D9(%rip),%rax
  mov    (%rax),%eax
  movslq %eax,%rdx
  sub    $0x1,%rdx
  mov    %rdx,-0x58(%rbp)
  movslq %eax,%rdx
  mov    %rdx,%r14
  mov    $0x0,%r15d
  movslq %eax,%rdx
  mov    %rdx,%r12
  mov    $0x0,%r13d
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    $0x10,%eax
  sub    $0x1,%rax
  add    %rdx,%rax
  mov    $0x10,%esi
  mov    $0x0,%edx
  div    %rsi
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L115:
  cmp    %rdx,%rsp
  je     L44
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L115
L44:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L25
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L25:
  mov    %rsp,%rax
  add    $0x7,%rax
  shr    $0x3,%rax
  shl    $0x3,%rax
  mov    %rax,-0x50(%rbp)
  mov    D9(%rip),%rax
  mov    (%rax),%eax
  mov    -0x50(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <getgroups@plt>
  mov    %eax,-0x64(%rbp)
  cmpl   $0x0,-0x64(%rbp)
  jle    L10
  movq   $0x0,-0x48(%rbp)
  mov    -0x74(%rbp),%eax
  mov    %eax,%edi
  call   <groupNameForTask@plt>
  mov    %eax,%edi
  call   <getgrnam@plt>
  mov    %rax,-0x40(%rbp)
  cmpq   $0x0,-0x40(%rbp)
  je     L10
  mov    -0x40(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x48(%rbp)
  movl   $0x0,-0x68(%rbp)
  jmp    L99
L128:
  mov    -0x50(%rbp),%rax
  mov    -0x68(%rbp),%edx
  movslq %edx,%rdx
  mov    (%rax,%rdx,8),%rax
  cmp    %rax,-0x48(%rbp)
  jne    L54
  movl   $0x1,-0x6c(%rbp)
  jmp    L10
L54:
  addl   $0x1,-0x68(%rbp)
L99:
  mov    -0x68(%rbp),%eax
  cmp    -0x64(%rbp),%eax
  jl     L128
L10:
  mov    %rbx,%rsp
L36:
  mov    -0x6c(%rbp),%eax
L105:
  mov    -0x38(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L66
  call   <__stack_chk_fail@plt>
L66:
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
```

assistant: ```c
int isAuthenticatedAsAdministratorForTask(int taskNum) {
  int admin = 0;
  uid_t ruid;
  if (isAuthenticatedAsRoot()) {
    return 1;
  }
  ruid = getuid();
  if (ruid) {
    gid_t groups[NGROUPS_MAX];
    int numgroups;
    if ((numgroups = getgroups(NGROUPS_MAX, groups)) > 0) {
      int i;
      gid_t admingid = 0;
      struct group *admingroup;
      if ((admingroup = getgrnam(groupNameForTask(taskNum))) != NULL) {
        admingid = admingroup->gr_gid;
        for (i = 0; i < numgroups; i++) {
          if (groups[i] == admingid) {
            admin = 1;
            break;
          }
        }
      }
    }
  }
  return admin;
}
```