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

```asm
<fairCandySwap>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  lea    -0x61000(%rsp),%r11
L119:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L119
  sub    $0xae0,%rsp
  mov    %rdi,-0x61ac8(%rbp)
  mov    %esi,-0x61acc(%rbp)
  mov    %rdx,-0x61ad8(%rbp)
  mov    %ecx,-0x61ad0(%rbp)
  mov    %r8,-0x61ae0(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x61ae0(%rbp),%rax
  movl   $0x2,(%rax)
  mov    $0x4,%esi
  mov    $0x2,%edi
  call   <calloc@plt>
  mov    %rax,-0x61a98(%rbp)
  movl   $0x0,-0x61ab4(%rbp)
  movl   $0x0,-0x61ab0(%rbp)
  movl   $0x0,-0x61aac(%rbp)
  movl   $0x0,-0x61aa8(%rbp)
  movl   $0x0,-0x61aac(%rbp)
  jmp    L87
L43:
  mov    -0x61aac(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x61ac8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  add    %eax,-0x61ab4(%rbp)
  addl   $0x1,-0x61aac(%rbp)
L87:
  mov    -0x61aac(%rbp),%eax
  cmp    -0x61acc(%rbp),%eax
  jl     L43
  movl   $0x0,-0x61aa8(%rbp)
  jmp    L50
L102:
  mov    -0x61aa8(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x61ad8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  add    %eax,-0x61ab0(%rbp)
  addl   $0x1,-0x61aa8(%rbp)
L50:
  mov    -0x61aa8(%rbp),%eax
  cmp    -0x61ad0(%rbp),%eax
  jl     L102
  mov    -0x61ab4(%rbp),%eax
  cmp    -0x61ab0(%rbp),%eax
  jne    L21
  mov    -0x61a98(%rbp),%rax
  jmp    L131
L21:
  mov    -0x61ab4(%rbp),%edx
  mov    -0x61ab0(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0x61aa4(%rbp)
  mov    -0x61aa4(%rbp),%eax
  sub    -0x61ab4(%rbp),%eax
  mov    %eax,-0x61aa0(%rbp)
  lea    -0x61a90(%rbp),%rax
  mov    $0x61a84,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  movl   $0x0,-0x61aac(%rbp)
  jmp    L71
L54:
  mov    -0x61aac(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x61ac8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x61aa0(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0x61a9c(%rbp)
  cmpl   $0x0,-0x61a9c(%rbp)
  js     L27
  cmpl   $0x186a0,-0x61a9c(%rbp)
  jg     L27
  mov    -0x61a9c(%rbp),%eax
  cltq
  movl   $0x1,-0x61a90(%rbp,%rax,4)
L27:
  addl   $0x1,-0x61aac(%rbp)
L71:
  mov    -0x61aac(%rbp),%eax
  cmp    -0x61acc(%rbp),%eax
  jl     L54
  movl   $0x0,-0x61aa8(%rbp)
  jmp    L69
L126:
  mov    -0x61aa8(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x61ad8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  mov    -0x61a90(%rbp,%rax,4),%eax
  test   %eax,%eax
  je     L7
  mov    -0x61aa8(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x61ad8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  sub    -0x61aa4(%rbp),%eax
  mov    %eax,%edx
  mov    -0x61ab4(%rbp),%eax
  add    %eax,%edx
  mov    -0x61a98(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x61aa8(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x61ad8(%rbp),%rax
  add    %rdx,%rax
  mov    -0x61a98(%rbp),%rdx
  add    $0x4,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
L7:
  addl   $0x1,-0x61aa8(%rbp)
L69:
  mov    -0x61aa8(%rbp),%eax
  cmp    -0x61ad0(%rbp),%eax
  jl     L126
  mov    -0x61a98(%rbp),%rax
L131:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L77
  call   <__stack_chk_fail@plt>
L77:
  leave
  ret
```

assistant: ```c
int *fairCandySwap(int *A, int ASize, int *B, int BSize, int *returnSize) {
  *returnSize = 2;
  int *res = (int *)calloc(2, sizeof(int));
  int countA = 0, countB = 0;
  int i = 0, j = 0;
  for (i = 0; i < ASize; i++) {
    countA += A[i];
  }
  for (j = 0; j < BSize; j++) {
    countB += B[j];
  }
  if (countA == countB) {
    return res;
  }
  int average = (countA + countB) / 2;
  int padA = average - countA;
  int record[100001] = {0};
  for (i = 0; i < ASize; i++) {
    int k = A[i] + padA;
    if (k >= 0 && k <= 100000) {
      record[k] = 1;
    }
  }
  for (j = 0; j < BSize; j++) {
    if (record[B[j]]) {
      res[0] = B[j] - average + countA;
      res[1] = B[j];
    }
  }
  return res;
}
```