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

```asm
<threeSumClosest>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %esi,%r13d
  push   %r12
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x18,%rsp
  call   <bubblesort@plt>
  mov    0x4(%rbx),%esi
  mov    (%rbx),%edx
  mov    0x8(%rbx),%r12d
  add    %esi,%edx
  add    %edx,%r12d
  cmp    %ebp,%r12d
  jge    L145
  movslq %r13d,%rax
  shl    $0x2,%rax
  mov    -0x4(%rbx,%rax,1),%edi
  mov    -0x8(%rbx,%rax,1),%r14d
  add    %edi,%r14d
  add    -0xc(%rbx,%rax,1),%r14d
  cmp    %ebp,%r14d
  jle    L104
  add    %edi,%edx
  lea    -0x2(%r13),%r15d
  cmp    %edx,%ebp
  jle    L156
  test   %r15d,%r15d
  jle    L14
  lea    -0x3(%r13),%r8d
  xor    %edx,%edx
  jmp    L70
  cs nopw 0x0(%rax,%rax,1)
L199:
  lea    0x1(%rdx),%rax
  cmp    %r8,%rdx
  je     L213
  mov    %rax,%rdx
L70:
  mov    %esi,%eax
  mov    0x8(%rbx,%rdx,4),%esi
  mov    %edx,%ecx
  add    %esi,%eax
  add    %edi,%eax
  cmp    %eax,%ebp
  jg     L199
L213:
  mov    %r12d,%edx
  mov    %r14d,%esi
  lea    D12(%rip),%rdi
  mov    %ecx,0xc(%rsp)
  call   <printf@plt>
  mov    0xc(%rsp),%ecx
  cmp    %r15d,%ecx
  jge    L117
  lea    -0x1(%r13),%r9d
  movslq %ecx,%rdi
  mov    %r12d,%esi
L78:
  lea    0x1(%rcx),%r8d
  cmp    %r9d,%r8d
  jge    L44
  mov    %r15d,%eax
  add    $0x2,%ecx
  sub    %r8d,%eax
  lea    0x3(%rdi,%rax,1),%r10
L56:
  cmp    %ecx,%r13d
  jle    L36
  mov    -0x4(%rbx,%rcx,4),%edx
  movslq %ecx,%rax
  add    (%rbx,%rdi,4),%edx
  jmp    L5
  nopl   0x0(%rax)
L47:
  mov    %r12d,%esi
L105:
  add    $0x1,%rax
  cmp    %eax,%r13d
  jle    L36
L5:
  mov    (%rbx,%rax,4),%r12d
  add    %edx,%r12d
  cmp    %r12d,%ebp
  je     L145
  jle    L10
  cmp    %esi,%r12d
  jg     L47
L10:
  cmp    %r12d,%ebp
  jge    L105
  cmp    %r12d,%r14d
  cmovg  %r12d,%r14d
L36:
  add    $0x1,%rcx
  cmp    %rcx,%r10
  jne    L56
L44:
  add    $0x1,%rdi
  cmp    %r15d,%r8d
  je     L16
  mov    %r8d,%ecx
  jmp    L78
  nopw   0x0(%rax,%rax,1)
L104:
  mov    %r14d,%r12d
L145:
  add    $0x18,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L14:
  mov    %r14d,%esi
  mov    %r12d,%edx
  lea    D12(%rip),%rdi
  call   <printf@plt>
  mov    %r12d,%esi
L16:
  lea    (%rsi,%r14,1),%eax
  add    %ebp,%ebp
  cmp    %ebp,%eax
  cmovle %r14d,%esi
  mov    %esi,%r12d
  jmp    L145
L156:
  xor    %ecx,%ecx
  jmp    L213
L117:
  mov    %r12d,%esi
  jmp    L16
```

tool_calls: name: retrieve_data
arguments: tag: D12
type: string

tool: D12: max:%d min:%d 


assistant: ```c
int threeSumClosest(int *A, int n, int target) {
  int i = 0, j = 0, k = 0;
  bubblesort(A, n);
  int min = A[0] + A[1] + A[2];
  int max = A[n - 1] + A[n - 2] + A[n - 3];
  if (min >= target)
    return min;
  if (max <= target)
    return max;
  int sum = A[0] + A[1] + A[n - 1];
  while (sum < target && i < n - 2) {
    i++;
    sum = A[i] + A[i + 1] + A[n - 1];
  }
  if (i > 0)
    i--;
  printf("max:%d min:%d \n", max, min);
  for (; i < n - 2; i++) {
    for (j = i + 1; j < n - 1; j++) {
      for (k = j + 1; k < n; k++) {
        sum = A[i] + A[j] + A[k];
        if (sum == target) {
          return target;
        }
        if (sum < target && sum > min)
          min = sum;
        if (sum > target) {
          if (sum < max)
            max = sum;
          break;
        }
      }
    }
  }
  if (max + min > target * 2)
    return min;
  return max;
}
```