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

```asm
<threeSum>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %rdi,%rbx
  mov    %rdi,0x38(%rsp)
  mov    %esi,%ebp
  mov    %esi,0x40(%rsp)
  mov    %rdx,0x48(%rsp)
  call   <bubblesort@plt>
  mov    (%rbx),%eax
  test   %eax,%eax
  jg     L30
  movl   $0x1,0x34(%rsp)
  mov    $0x0,%r15d
  movq   $0x0,(%rsp)
  lea    -0x2(%rbp),%esi
  mov    %esi,0x44(%rsp)
  lea    0x8(%rbx),%rsi
  mov    %rsi,0x28(%rsp)
  mov    %r15d,%r14d
  mov    %rbx,%r15
  jmp    L53
L78:
  mov    $0x3,%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  mov    (%r15),%eax
  mov    %eax,0x0(%rbp)
  mov    -0x4(%r12),%eax
  mov    %eax,0x4(%rbp)
  mov    0x0(%r13),%eax
  mov    %eax,0x8(%rbp)
  add    $0x1,%r14d
  movslq %r14d,%rax
  mov    %rax,0x10(%rsp)
  lea    0x0(,%r14,8),%esi
  mov    (%rsp),%rdi
  call   <realloc@plt>
  mov    %rax,(%rsp)
  mov    0x10(%rsp),%rdi
  mov    %rbp,-0x8(%rax,%rdi,8)
L160:
  mov    -0x4(%r12),%eax
  add    (%r15),%eax
  add    0x0(%r13),%eax
  test   %eax,%eax
  jg     L139
L3:
  add    $0x4,%rbx
  cmp    0x8(%rsp),%rbx
  je     L139
L136:
  mov    (%r15),%edx
  mov    -0x4(%r12),%ecx
  mov    %rbx,%r13
  lea    (%rdx,%rcx,1),%eax
  add    (%rbx),%eax
  jne    L160
  test   %r14d,%r14d
  jle    L78
  movslq %r14d,%rax
  mov    (%rsp),%rsi
  mov    -0x8(%rsi,%rax,8),%rax
  cmp    (%rax),%edx
  jne    L78
  cmp    0x4(%rax),%ecx
  jne    L78
  jmp    L3
L17:
  add    $0x4,%r15
  mov    (%r15),%eax
  addl   $0x1,0x34(%rsp)
  test   %eax,%eax
  jg     L65
L53:
  mov    0x34(%rsp),%ecx
  lea    -0x1(%rcx),%edx
  test   %edx,%edx
  jle    L85
  cmp    %eax,-0x4(%r15)
  je     L17
L85:
  mov    0x34(%rsp),%eax
  cmp    %eax,0x40(%rsp)
  jle    L17
  movslq %eax,%rcx
  mov    %rcx,0x20(%rsp)
  mov    0x38(%rsp),%rsi
  lea    0x4(%rsi,%rcx,4),%rdi
  mov    %rdi,0x18(%rsp)
  mov    0x44(%rsp),%edi
  sub    %eax,%edi
  mov    %edi,0x30(%rsp)
  jmp    L35
L65:
  mov    %r14d,%r15d
L67:
  mov    0x48(%rsp),%rax
  mov    %r15d,(%rax)
  mov    (%rsp),%rax
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L30:
  mov    $0x0,%r15d
  movq   $0x0,(%rsp)
  jmp    L67
L139:
  addq   $0x1,0x20(%rsp)
  addq   $0x4,0x18(%rsp)
  subl   $0x1,0x30(%rsp)
L35:
  mov    0x18(%rsp),%rbx
  mov    %rbx,%r12
  mov    -0x4(%rbx),%eax
  add    (%r15),%eax
  test   %eax,%eax
  jg     L17
  mov    0x30(%rsp),%eax
  cmp    $0xffffffff,%eax
  je     L17
  mov    %eax,%eax
  add    0x20(%rsp),%rax
  mov    0x28(%rsp),%rdi
  lea    (%rdi,%rax,4),%rax
  mov    %rax,0x8(%rsp)
  jmp    L136
```

assistant: ```c
int **threeSum(int *A, int n, int *returnSize) {
  int i = 0, j = 0, k = 0;
  bubblesort(A, n);
  int **result = NULL;
  int num = 0;
  for (i = 0; A[i] <= 0; i++) {
    if (i > 0 && A[i] == A[i - 1])
      continue;
    for (j = i + 1; j < n; j++) {
      if (A[i] + A[j] > 0)
        break;
      for (k = j + 1; k < n; k++) {
        if (A[i] + A[j] + A[k] == 0) {
          if (num > 0 && A[i] == result[num - 1][0] && A[j] == result[num - 1][1])
            continue;
          int *tmp = malloc(3);
          tmp[0] = A[i];
          tmp[1] = A[j];
          tmp[2] = A[k];
          num++;
          result = realloc(result, num * sizeof(int *));
          result[num - 1] = tmp;
        }
        if (A[i] + A[j] + A[k] > 0)
          break;
      }
    }
  }
  *returnSize = num;
  return result;
}
```