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

```asm
<fairCandySwap>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  lea    -0x61000(%rsp),%r11
L7:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L7
  sub    $0xaa8,%rsp
  mov    %rdi,%rbx
  mov    %rdi,0x8(%rsp)
  mov    %esi,%r15d
  mov    %rdx,%r13
  mov    %ecx,%ebp
  mov    %fs:0x28,%rax
  mov    %rax,0x61a98(%rsp)
  xor    %eax,%eax
  movl   $0x2,(%r8)
  mov    $0x4,%esi
  mov    $0x2,%edi
  call   <calloc@plt>
  mov    %rax,%r14
  test   %r15d,%r15d
  jle    L34
  mov    %rbx,%rax
  lea    -0x1(%r15),%edx
  lea    0x4(%rbx,%rdx,4),%rdx
  mov    $0x0,%ebx
L173:
  add    (%rax),%ebx
  add    $0x4,%rax
  cmp    %rdx,%rax
  jne    L173
  test   %ebp,%ebp
  jle    L96
L177:
  mov    $0x0,%eax
  mov    $0x0,%edx
L195:
  add    0x0(%r13,%rax,4),%edx
  add    $0x1,%rax
  cmp    %eax,%ebp
  jg     L195
  cmp    %edx,%ebx
  je     L176
  add    %ebx,%edx
  mov    %edx,%r12d
  shr    $0x1f,%r12d
  add    %edx,%r12d
  sar    %r12d
  mov    %r12d,0x4(%rsp)
  sub    %ebx,%r12d
  lea    0x10(%rsp),%rdi
  mov    $0x61a84,%edx
  mov    $0x0,%esi
  call   <memset@plt>
  test   %r15d,%r15d
  jle    L199
L155:
  mov    0x8(%rsp),%rdi
  mov    %rdi,%rax
  lea    -0x1(%r15),%edx
  lea    0x4(%rdi,%rdx,4),%rcx
  jmp    L143
L99:
  add    $0x4,%rax
  cmp    %rcx,%rax
  je     L199
L143:
  mov    %r12d,%edx
  add    (%rax),%edx
  cmp    $0x186a0,%edx
  ja     L99
  movslq %edx,%rdx
  movl   $0x1,0x10(%rsp,%rdx,4)
  jmp    L99
L199:
  test   %ebp,%ebp
  jle    L176
  mov    %r13,%rax
  lea    -0x1(%rbp),%edx
  lea    0x4(%r13,%rdx,4),%rsi
  jmp    L103
L47:
  add    $0x4,%rax
  cmp    %rsi,%rax
  je     L176
L103:
  mov    (%rax),%edx
  movslq %edx,%rcx
  cmpl   $0x0,0x10(%rsp,%rcx,4)
  je     L47
  sub    0x4(%rsp),%edx
  add    %ebx,%edx
  mov    %edx,(%r14)
  mov    (%rax),%edx
  mov    %edx,0x4(%r14)
  jmp    L47
L34:
  mov    $0x0,%ebx
  test   %ebp,%ebp
  jg     L177
L176:
  mov    0x61a98(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L50
  mov    %r14,%rax
  add    $0x61aa8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L96:
  test   %ebx,%ebx
  je     L176
  mov    %ebx,%r12d
  shr    $0x1f,%r12d
  add    %ebx,%r12d
  sar    %r12d
  mov    %r12d,0x4(%rsp)
  sub    %ebx,%r12d
  lea    0x10(%rsp),%rdi
  mov    $0x61a84,%edx
  mov    $0x0,%esi
  call   <memset@plt>
  jmp    L155
L50:
  call   <__stack_chk_fail@plt>
```

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;
}
```