user: 请将以下的汇编代码转换成C语言代码:

```asm
<user_is_member_of_group>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movq   $0x0,-0x18(%rbp)
  movq   $0x0,-0x20(%rbp)
  movq   $0x0,-0x10(%rbp)
  movl   $0x3e8,-0x2c(%rbp)
  mov    -0x2c(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L119
  lea    D15(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
  mov    $0xffffffff,%eax
  jmp    L41
L119:
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <getpwnam@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L51
  lea    D27(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0xffffffff,%eax
  jmp    L41
L51:
  mov    -0x18(%rbp),%rax
  mov    (%rax),%esi
  lea    -0x2c(%rbp),%rcx
  mov    -0x10(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <getgrouplist@plt>
  mov    %eax,-0x24(%rbp)
  cmpl   $0xffffffff,-0x24(%rbp)
  jne    L20
  lea    D18(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
  mov    $0xffffffff,%eax
  jmp    L41
L20:
  movl   $0x0,-0x28(%rbp)
  jmp    L11
L115:
  cmpq   $0x0,-0x20(%rbp)
  je     L64
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  mov    -0x40(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L64
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0x1,%eax
  jmp    L41
L64:
  mov    -0x28(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x28(%rbp)
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,%edi
  call   <getgrgid@plt>
  mov    %rax,-0x20(%rbp)
L11:
  mov    -0x28(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jle    L115
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0x0,%eax
L41:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L31
  call   <__stack_chk_fail@plt>
L31:
  leave
  ret
```

tool_calls: name: read_data
arguments: data_label: D15
type_infered: string
name: read_data
arguments: data_label: D27
type_infered: string
name: read_data
arguments: data_label: D18
type_infered: string

tool: D15: malloc error

tool: D27: Could not get passwd from given name

tool: D18: Error occured while getting groups.

assistant: ```c
int user_is_member_of_group(char *user, char *group) {
  struct passwd *pw = NULL;
  struct group *grp = NULL;
  gid_t *groups = NULL;
  int i, ngroups = 1000;
  groups = (gid_t *)malloc(sizeof(gid_t) * ngroups);
  if (groups == NULL) {
    perror("malloc error");
    return -1;
  }
  pw = getpwnam(user);
  if (pw == NULL) {
    perror("Could not get passwd from given name");
    free(groups);
    return -1;
  }
  int count = getgrouplist(user, pw->pw_gid, groups, &ngroups);
  if (count == -1) {
    perror("Error occured while getting groups.");
    return -1;
  }
  for (i = 0; i <= count; grp = getgrgid(groups[i++]))
    if (grp != NULL && strcmp(grp->gr_name, group) == 0) {
      free(groups);
      return 1;
    }
  free(groups);
  return 0;
}
```