user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<threeSumClosest>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  mov    %edx,-0x30(%rbp)
  movl   $0x0,-0x18(%rbp)
  movl   $0x0,-0x14(%rbp)
  movl   $0x0,-0x10(%rbp)
  mov    -0x2c(%rbp),%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <bubblesort@plt>
  mov    -0x28(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x28(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%eax
  add    %eax,%edx
  mov    -0x28(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%eax
  add    %edx,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x2c(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x2c(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x8(%rax),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  add    %eax,%edx
  mov    -0x2c(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0xc(%rax),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  add    %edx,%eax
  mov    %eax,-0x8(%rbp)
  mov    -0xc(%rbp),%eax
  cmp    -0x30(%rbp),%eax
  jl     L54
  mov    -0xc(%rbp),%eax
  jmp    L178
L54:
  mov    -0x8(%rbp),%eax
  cmp    -0x30(%rbp),%eax
  jg     L65
  mov    -0x8(%rbp),%eax
  jmp    L178
L65:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x28(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%eax
  add    %eax,%edx
  mov    -0x2c(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  add    %edx,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L108
L21:
  addl   $0x1,-0x18(%rbp)
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x18(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  add    %eax,%edx
  mov    -0x2c(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  add    %edx,%eax
  mov    %eax,-0x4(%rbp)
L108:
  mov    -0x4(%rbp),%eax
  cmp    -0x30(%rbp),%eax
  jge    L83
  mov    -0x2c(%rbp),%eax
  sub    $0x2,%eax
  cmp    %eax,-0x18(%rbp)
  jl     L21
L83:
  cmpl   $0x0,-0x18(%rbp)
  jle    L221
  subl   $0x1,-0x18(%rbp)
L221:
  mov    -0xc(%rbp),%edx
  mov    -0x8(%rbp),%eax
  mov    %eax,%esi
  lea    D4(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  jmp    L230
L237:
  mov    -0x18(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x14(%rbp)
  jmp    L61
L157:
  mov    -0x14(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x10(%rbp)
  jmp    L215
L116:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  add    %eax,%edx
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  add    %edx,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  cmp    -0x30(%rbp),%eax
  jne    L51
  mov    -0x30(%rbp),%eax
  jmp    L178
L51:
  mov    -0x4(%rbp),%eax
  cmp    -0x30(%rbp),%eax
  jge    L41
  mov    -0x4(%rbp),%eax
  cmp    -0xc(%rbp),%eax
  jle    L41
  mov    -0x4(%rbp),%eax
  mov    %eax,-0xc(%rbp)
L41:
  mov    -0x4(%rbp),%eax
  cmp    -0x30(%rbp),%eax
  jle    L40
  mov    -0x4(%rbp),%eax
  cmp    -0x8(%rbp),%eax
  jge    L208
  mov    -0x4(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  jmp    L208
L40:
  addl   $0x1,-0x10(%rbp)
L215:
  mov    -0x10(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jl     L116
  jmp    L72
L208:
  nop
L72:
  addl   $0x1,-0x14(%rbp)
L61:
  mov    -0x2c(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x14(%rbp)
  jl     L157
  addl   $0x1,-0x18(%rbp)
L230:
  mov    -0x2c(%rbp),%eax
  sub    $0x2,%eax
  cmp    %eax,-0x18(%rbp)
  jl     L237
  mov    -0x8(%rbp),%edx
  mov    -0xc(%rbp),%eax
  add    %eax,%edx
  mov    -0x30(%rbp),%eax
  add    %eax,%eax
  cmp    %eax,%edx
  jle    L186
  mov    -0xc(%rbp),%eax
  jmp    L178
L186:
  mov    -0x8(%rbp),%eax
L178:
  leave
  ret
```

tool_calls: name: read_data
arguments: tag: D4
type_infered: string

tool: D4: 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;
}
```