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

```asm
<test_get_set_gid>:
  endbr64
  push   %r13
  mov    $0x1,%edi
  mov    $0x1,%edx
  mov    $0x1,%esi
  push   %r12
  push   %rbp
  sub    $0x20,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  call   <getresgid@plt>
  xor    %edi,%edi
  test   %eax,%eax
  jns    L56
  mov    D20(%rip),%rdx
  mov    D34(%rip),%rax
  xor    %edi,%edi
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  sete   %dil
L56:
  call   <assert@plt>
  lea    0x14(%rsp),%r13
  lea    0x10(%rsp),%r12
  lea    0xc(%rsp),%rbp
  mov    %r13,%rdx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <getresgid@plt>
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
  call   <assert@plt>
  mov    0xc(%rsp),%eax
  xor    %edi,%edi
  or     0x10(%rsp),%eax
  or     0x14(%rsp),%eax
  sete   %dil
  call   <assert@plt>
  mov    $0x3,%edx
  mov    $0x2,%esi
  mov    $0x1,%edi
  movl   $0x1,0xc(%rsp)
  movl   $0x2,0x10(%rsp)
  movl   $0x3,0x14(%rsp)
  call   <setresgid@plt>
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
  call   <assert@plt>
  mov    %rbp,%rdi
  mov    %r13,%rdx
  mov    %r12,%rsi
  call   <getresgid@plt>
  xor    %edi,%edi
  cmpl   $0x1,0xc(%rsp)
  je     L71
L78:
  call   <assert@plt>
  mov    $0x1,%edx
  mov    $0x1,%esi
  mov    $0x1,%edi
  call   <setresuid@plt>
  mov    $0xffffffff,%edx
  mov    $0x3,%esi
  mov    $0xffffffff,%edi
  movl   $0xffffffff,0xc(%rsp)
  movl   $0x3,0x10(%rsp)
  movl   $0xffffffff,0x14(%rsp)
  call   <setresgid@plt>
  xor    %edi,%edi
  test   %eax,%eax
  sete   %dil
  call   <assert@plt>
  mov    %rbp,%rdi
  mov    %r13,%rdx
  mov    %r12,%rsi
  call   <getresgid@plt>
  xor    %edi,%edi
  cmpl   $0x1,0xc(%rsp)
  je     L72
L33:
  call   <assert@plt>
  mov    $0xffffffff,%edi
  mov    $0xffffffff,%edx
  mov    $0x2,%esi
  movl   $0xffffffff,0xc(%rsp)
  movl   $0x2,0x10(%rsp)
  movl   $0xffffffff,0x14(%rsp)
  call   <setresgid@plt>
  xor    %edi,%edi
  test   %eax,%eax
  jns    L32
  mov    D20(%rip),%rdx
  mov    D18(%rip),%rax
  xor    %edi,%edi
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  sete   %dil
L32:
  call   <assert@plt>
  mov    %rbp,%rdi
  mov    %r13,%rdx
  mov    %r12,%rsi
  call   <getresgid@plt>
  xor    %edi,%edi
  cmpl   $0x1,0xc(%rsp)
  je     L27
L79:
  call   <assert@plt>
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L103
  add    $0x20,%rsp
  xor    %eax,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  cs nopw 0x0(%rax,%rax,1)
L72:
  cmpl   $0x3,0x10(%rsp)
  jne    L33
  xor    %edi,%edi
  cmpl   $0x3,0x14(%rsp)
  sete   %dil
  jmp    L33
  nopl   0x0(%rax,%rax,1)
L71:
  cmpl   $0x2,0x10(%rsp)
  jne    L78
  xor    %edi,%edi
  cmpl   $0x3,0x14(%rsp)
  sete   %dil
  jmp    L78
  nopl   0x0(%rax,%rax,1)
L27:
  cmpl   $0x3,0x10(%rsp)
  jne    L79
  xor    %edi,%edi
  cmpl   $0x3,0x14(%rsp)
  sete   %dil
  jmp    L79
L103:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int test_get_set_gid(void) {
  gid_t rgid, egid, sgid;
  int error;
  error = getresgid((void *)1, (void *)1, (void *)1);
  assert(error < 0 && errno == EFAULT);
  error = getresgid(&rgid, &egid, &sgid);
  assert(error == 0);
  assert(rgid == 0 && egid == 0 && sgid == 0);
  rgid = 1, egid = 2, sgid = 3;
  error = setresgid(rgid, egid, sgid);
  assert(error == 0);
  getresgid(&rgid, &egid, &sgid);
  assert(rgid == 1 && egid == 2 && sgid == 3);
  setresuid(1, 1, 1);
  rgid = -1, egid = 3, sgid = -1;
  error = setresgid(rgid, egid, sgid);
  assert(error == 0);
  getresgid(&rgid, &egid, &sgid);
  assert(rgid == 1 && egid == 3 && sgid == 3);
  rgid = -1, egid = 2, sgid = -1;
  error = setresgid(rgid, egid, sgid);
  assert(error < 0 && errno == EPERM);
  getresgid(&rgid, &egid, &sgid);
  assert(rgid == 1 && egid == 3 && sgid == 3);
  return 0;
}
```