user: Please show me the C implementation that matches the assembly code listed below:

```asm
<picnic>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %esi,%r12d
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdx,0x10(%rsp)
  test   %esi,%esi
  jne    L98
L53:
  add    $0x28,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L98:
  movslq %edi,%r15
  mov    %edi,%r13d
  lea    0x0(,%r15,8),%rdi
  shl    $0x2,%r15
  call   <malloc@plt>
  mov    %rax,%rbp
  test   %r13d,%r13d
  jle    L90
  mov    %rax,%r14
  mov    %r13d,%eax
  lea    0x0(%rbp,%rax,8),%rsi
  mov    %rax,0x18(%rsp)
  lea    0x0(,%rax,4),%rbx
  mov    %rsi,0x8(%rsp)
L107:
  mov    %r15,%rdi
  call   <malloc@plt>
  mov    %rax,(%r14)
  lea    (%rax,%rbx,1),%rdx
  nop
L48:
  movl   $0x0,(%rax)
  add    $0x4,%rax
  cmp    %rax,%rdx
  jne    L48
  add    $0x8,%r14
  cmp    0x8(%rsp),%r14
  jne    L107
  add    %r12d,%r12d
  test   %r12d,%r12d
  jle    L62
L114:
  sub    $0x1,%r12d
  mov    0x10(%rsp),%rax
  shr    %r12d
  mov    %r12d,%edx
  lea    0x8(%rax,%rdx,8),%rsi
  nopw   0x0(%rax,%rax,1)
L24:
  movslq (%rax),%rdx
  movslq 0x4(%rax),%rcx
  add    $0x8,%rax
  mov    0x0(%rbp,%rdx,8),%rdx
  movl   $0x1,(%rdx,%rcx,4)
  movslq -0x4(%rax),%rdx
  movslq -0x8(%rax),%rcx
  mov    0x0(%rbp,%rdx,8),%rdx
  movl   $0x1,(%rdx,%rcx,4)
  cmp    %rax,%rsi
  jne    L24
  mov    %r15,%rdi
  call   <malloc@plt>
  mov    %rax,%rdi
  mov    %r13d,%eax
  mov    %rax,0x18(%rsp)
  test   %r13d,%r13d
  jle    L49
L10:
  mov    0x18(%rsp),%r15
  xor    %esi,%esi
  mov    %rbp,%rbx
  lea    0x0(,%r15,4),%rdx
  call   <memset@plt>
  mov    %r13d,%esi
  mov    %rbp,%rdx
  lea    0x0(%rbp,%r15,8),%r13
  mov    %rax,%rdi
  xor    %eax,%eax
  call   <take_friend@plt>
  mov    %eax,%r12d
  nopw   0x0(%rax,%rax,1)
L3:
  mov    (%rbx),%rdi
  add    $0x8,%rbx
  call   <free@plt>
  cmp    %r13,%rbx
  jne    L3
L42:
  mov    %rbp,%rdi
  call   <free@plt>
  jmp    L53
L90:
  add    %r12d,%r12d
  test   %r12d,%r12d
  jg     L114
  mov    %r15,%rdi
  call   <malloc@plt>
  mov    %rax,%rdi
L49:
  mov    %rbp,%rdx
  mov    %r13d,%esi
  xor    %eax,%eax
  call   <take_friend@plt>
  mov    %eax,%r12d
  jmp    L42
L62:
  mov    %r15,%rdi
  call   <malloc@plt>
  mov    %rax,%rdi
  jmp    L10
```

assistant: ```c
int picnic(int student_count, int friendship_count, int *friendships) {
  if (friendship_count == 0) {
    return 0;
  }
  int **grouped_friendships = (int **)malloc(sizeof(int *) * student_count);
  int i = 0;
  int j = 0;
  for (i = 0; i < student_count; i++) {
    grouped_friendships[i] = (int *)malloc(sizeof(int) * (student_count));
    for (j = 0; j < student_count; j++) {
      grouped_friendships[i][j] = 0;
    }
  }
  for (i = 0; i < 2 * friendship_count; i += 2) {
    grouped_friendships[friendships[i]][friendships[i + 1]] = 1;
    grouped_friendships[friendships[i + 1]][friendships[i]] = 1;
  }
  int *taken = (int *)malloc(sizeof(int) * student_count);
  for (i = 0; i < student_count; i++) {
    taken[i] = 0;
  }
  int result = take_friend(taken, student_count, grouped_friendships);
  for (i = 0; i < student_count; i++) {
    free(grouped_friendships[i]);
  }
  free(grouped_friendships);
  return result;
}
```