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

```asm
<parsegroup>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1d8,%rsp
  mov    %rdi,%rbx
  mov    %rsi,(%rsp)
  mov    %rdx,%r14
  mov    %rcx,%r12
  mov    %fs:0x28,%rax
  mov    %rax,0x1c8(%rsp)
  xor    %eax,%eax
  movq   $0x0,0x10(%rsp)
  movq   $0x0,0x18(%rsp)
  lea    0x30(%rsp),%rdi
  mov    $0x32,%ecx
  rep stos %rax,%es:(%rdi)
  mov    %rbx,%rdi
  call   <strlen@plt>
  add    $0x1,%eax
  mov    %eax,0x20(%rsp)
  cmp    %r12d,%eax
  jg     L59
  mov    %r12d,%edi
  mov    $0x0,%edx
  mov    $0x1,%ecx
  test   %eax,%eax
  jg     L81
L96:
  mov    D22(%rip),%rax
  mov    (%rax),%eax
  jmp    L62
L59:
  mov    D10(%rip),%rax
  mov    (%rax),%eax
L62:
  mov    0x1c8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L164
  add    $0x1d8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L101:
  mov    0x20(%rsp),%ebp
  add    $0x1,%rdx
  cmp    %edx,%ebp
  jle    L95
L81:
  cmpb   $0x3a,(%rbx,%rdx,1)
  jne    L101
  movslq %ecx,%rax
  lea    0x1(%rdx),%esi
  mov    %esi,0x10(%rsp,%rax,4)
  lea    0x1(%rcx),%ecx
  jmp    L101
L95:
  cmp    $0x4,%ecx
  jne    L96
  mov    0x1c(%rsp),%r15d
  mov    %r15d,0x30(%rsp)
  cmp    %r15d,%ebp
  jle    L155
  lea    0x1(%r15),%eax
  cltq
  lea    -0x1(%rbp),%edx
  sub    %r15d,%edx
  movslq %r15d,%rcx
  lea    0x2(%rdx,%rcx,1),%rdx
  mov    $0x1,%r13d
  jmp    L134
L107:
  add    $0x1,%rax
  cmp    %rdx,%rax
  je     L187
L134:
  cmpb   $0x2c,-0x1(%rbx,%rax,1)
  jne    L107
  movslq %r13d,%rcx
  mov    %eax,0x30(%rsp,%rcx,4)
  lea    0x1(%r13),%r13d
  jmp    L107
L155:
  mov    $0x1,%r13d
L187:
  movslq %r13d,%rax
  mov    %ebp,0x30(%rsp,%rax,4)
  lea    0x1(%r13),%eax
  cltq
  shl    $0x3,%rax
  mov    %rax,%rcx
  mov    %rax,0x8(%rsp)
  movslq %ebp,%rax
  add    %rcx,%rax
  cmp    %r12,%rax
  jbe    L140
  mov    D10(%rip),%rax
  mov    (%rax),%eax
  jmp    L62
L140:
  mov    %edi,%edx
  mov    $0x0,%esi
  mov    %r14,%rdi
  call   <memset@plt>
  mov    0x18(%rsp),%r12d
  sub    %r12d,%r15d
  lea    -0x1(%r15),%edx
  movslq %r12d,%rsi
  add    %rbx,%rsi
  mov    %r14,%rdi
  call   <memcpy@plt>
  movslq %r15d,%r15
  movb   $0x0,(%r14,%r15,1)
  mov    %r14,%rdi
  call   <atoi@plt>
  mov    (%rsp),%r15
  mov    %eax,0x18(%r15)
  mov    %ebp,%edx
  mov    $0x0,%esi
  mov    %r14,%rdi
  call   <memset@plt>
  mov    %r15,(%rsp)
  mov    %r14,(%r15)
  mov    0x14(%rsp),%ebp
  mov    0x10(%rsp),%eax
  mov    %ebp,%edi
  sub    %eax,%edi
  mov    %edi,%r15d
  lea    -0x1(%rdi),%edx
  cltq
  lea    (%rbx,%rax,1),%rsi
  mov    %r14,%rdi
  call   <memcpy@plt>
  movslq %r15d,%r15
  add    %r15,%r14
  movb   $0x0,(%r14)
  mov    (%rsp),%r15
  mov    %r14,0x8(%r15)
  sub    %ebp,%r12d
  lea    -0x1(%r12),%edx
  movslq %ebp,%rsi
  add    %rbx,%rsi
  mov    %r14,%rdi
  call   <memcpy@plt>
  movslq %r12d,%r12
  add    %r14,%r12
  movb   $0x0,(%r12)
  mov    %r12,0x10(%r15)
  mov    0x8(%rsp),%r14
  add    %r12,%r14
  test   %r13d,%r13d
  jle    L103
  lea    0x34(%rsp),%r15
  mov    %r13d,%r13d
  lea    (%r12,%r13,8),%r13
L117:
  mov    -0x4(%r15),%esi
  mov    (%r15),%ebp
  sub    %esi,%ebp
  lea    -0x1(%rbp),%edx
  movslq %esi,%rsi
  add    %rbx,%rsi
  mov    %r14,%rdi
  call   <memcpy@plt>
  mov    %r14,%rax
  movslq %ebp,%rbp
  add    %rbp,%r14
  movb   $0x0,(%r14)
  add    $0x8,%r12
  mov    %rax,-0x8(%r12)
  add    $0x4,%r15
  cmp    %r12,%r13
  jne    L117
L80:
  movq   $0x0,0x0(%r13)
  mov    $0x0,%eax
  jmp    L62
L103:
  mov    %r12,%r13
  jmp    L80
L164:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int parsegroup(char *str, struct group *result, char *buffer, size_t buflen) {
  int fields[4 + 1] = {0};
  int members[100] = {0};
  int i, field, len;
  char **bufp;
  fields[4] = strlen(str) + 1;
  if (fields[4] > (int)buflen) {
    return ERANGE;
  }
  for (field = 1, i = 0; i < fields[4]; i++) {
    if (str[i] == ':') {
      fields[field++] = i + 1;
    }
  }
  if (field != 4) {
    return ENOENT;
  }
  members[0] = fields[3];
  for (field = 1, i = fields[3]; i < fields[4]; i++) {
    if (str[i] == ',') {
      members[field++] = i + 1;
    }
  }
  members[field] = fields[4];
  if ((fields[4] + ((field + 1) * sizeof(char *))) > buflen) {
    return ERANGE;
  }
  do {
    memset(buffer, 0, buflen);
    memcpy(buffer, &str[fields[2]], ((fields[2 + 1] - fields[2]) - 1));
    buffer[((fields[2 + 1] - fields[2]) - 1) + 1] = '\0';
    result->gr_gid = atoi(buffer);
  } while (0);
  memset(buffer, 0, fields[4]);
  do {
    result->gr_name = buffer;
    memcpy(buffer, &str[fields[0]], ((fields[0 + 1] - fields[0]) - 1));
    buffer[((fields[0 + 1] - fields[0]) - 1) + 1] = '\0';
    buffer += ((fields[0 + 1] - fields[0]) - 1) + 1;
  } while (0);
  do {
    result->gr_passwd = buffer;
    memcpy(buffer, &str[fields[1]], ((fields[1 + 1] - fields[1]) - 1));
    buffer[((fields[1 + 1] - fields[1]) - 1) + 1] = '\0';
    buffer += ((fields[1 + 1] - fields[1]) - 1) + 1;
  } while (0);
  result->gr_mem = bufp = (char **)buffer;
  buffer += (sizeof(char *) * (field + 1));
  for (i = 0; i < field; i++) {
    len = ((members[i + 1] - members[i]) - 1);
    memcpy(buffer, &str[members[i]], len);
    buffer[len + 1] = '\0';
    *(bufp++) = buffer;
    buffer += len + 1;
  }
  *bufp = NULL;
  return 0;
}
```