user: 请从给定的汇编指令推导出C源代码:

```asm
<main>:
  endbr64
  push   %r13
  lea    D21(%rip),%r13
  push   %r12
  mov    %r13,%rdi
  push   %rbp
  push   %rbx
  xor    %ebx,%ebx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    0xc(%rsp),%rsi
  call   <scanf@plt>
  mov    0xc(%rsp),%eax
  lea    0x0(,%rax,4),%edi
  call   <malloc@plt>
  mov    0xc(%rsp),%edx
  mov    %rax,%r12
  mov    %rax,%rbp
  test   %edx,%edx
  je     L225
  nopw   0x0(%rax,%rax,1)
L252:
  mov    %rbp,%rsi
  mov    %r13,%rdi
  xor    %eax,%eax
  add    $0x1,%rbx
  call   <scanf@plt>
  movslq 0xc(%rsp),%rax
  add    $0x4,%rbp
  cmp    %rbx,%rax
  ja     L252
L225:
  lea    0x14(%rsp),%rdx
  lea    0x10(%rsp),%rsi
  xor    %eax,%eax
  lea    D17(%rip),%rdi
  call   <scanf@plt>
  mov    0xc(%rsp),%eax
  mov    %r12,%rdi
  xor    %esi,%esi
  lea    -0x1(%rax),%edx
  call   <quick_sort@plt>
  mov    (%r12),%eax
  mov    0x10(%rsp),%edi
  cmp    %edi,%eax
  jge    L175
  xor    %r11d,%r11d
  or     $0xffffffff,%r9d
L65:
  movslq 0xc(%rsp),%rbx
  mov    0x14(%rsp),%esi
  cmp    $0x1,%rbx
  jbe    L223
  lea    0x4(%r12),%rdx
  lea    (%r12,%rbx,4),%r10
  nop
L127:
  mov    %eax,%ecx
  mov    (%rdx),%eax
  cmp    %ecx,%edi
  jle    L27
  cmp    %eax,%esi
  jge    L57
  lea    (%rax,%rcx,1),%ebp
  mov    %ebp,%r8d
  shr    $0x1f,%r8d
  add    %ebp,%r8d
  sar    %r8d
  cmp    %r8d,%esi
  jl     L9
  cmp    %r8d,%edi
  jle    L167
  cmp    %r8d,%esi
  jl     L9
L16:
  mov    %eax,%ecx
  sub    %edi,%ecx
  cmp    %r9d,%ecx
  jle    L20
  mov    %edi,%r11d
  mov    %ecx,%r9d
  xchg   %ax,%ax
L20:
  add    $0x4,%rdx
  cmp    %rdx,%r10
  jne    L127
L223:
  mov    -0x4(%r12,%rbx,4),%eax
  cmp    %esi,%eax
  jg     L195
  mov    %esi,%edx
  sub    %eax,%edx
  cmp    %r9d,%edx
  cmovg  %esi,%r11d
L195:
  lea    D15(%rip),%rdi
  mov    %r11d,%esi
  call   <printf@plt>
  mov    %r12,%rdi
  call   <free@plt>
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L128
  add    $0x28,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   (%rax)
L44:
  cmp    %ecx,%esi
  jl     L20
  lea    (%rax,%rcx,1),%ebp
  mov    %ebp,%r8d
  shr    $0x1f,%r8d
  add    %ebp,%r8d
  sar    %r8d
  cmp    %r8d,%esi
  jge    L167
L9:
  mov    %esi,%r8d
  sub    %ecx,%r8d
  cmp    %r9d,%r8d
  jle    L20
  mov    %esi,%r11d
  mov    %r8d,%r9d
  jmp    L20
  nopl   0x0(%rax,%rax,1)
L27:
  cmp    %eax,%esi
  jl     L44
  lea    (%rax,%rcx,1),%ebp
  mov    %ebp,%r8d
  shr    $0x1f,%r8d
  add    %ebp,%r8d
  sar    %r8d
  mov    %r8d,%ebp
  sub    %ecx,%ebp
  cmp    %r9d,%ebp
  jle    L20
L235:
  add    $0x4,%rdx
  mov    %r8d,%r11d
  mov    %ebp,%r9d
  cmp    %rdx,%r10
  jne    L127
  jmp    L223
  nopw   0x0(%rax,%rax,1)
L57:
  cmp    %eax,%edi
  jg     L20
  lea    (%rax,%rcx,1),%ebp
  mov    %ebp,%r8d
  shr    $0x1f,%r8d
  add    %ebp,%r8d
  sar    %r8d
  cmp    %r8d,%edi
  jg     L16
L167:
  mov    %r8d,%ebp
  sub    %ecx,%ebp
  cmp    %r9d,%ebp
  jg     L235
  add    $0x4,%rdx
  cmp    %rdx,%r10
  jne    L127
  jmp    L223
L175:
  mov    %eax,%r9d
  mov    %edi,%r11d
  sub    %edi,%r9d
  jmp    L65
L128:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_label: D21
type_guessed: string
name: disassemble_data
arguments: data_label: D17
type_guessed: string
name: disassemble_data
arguments: data_label: D15
type_guessed: string

tool: D21: %d

tool: D17: %d %d

tool: D15: %d


assistant: ```c
int main() {
  int n;
  scanf("%d", &n);
  int *a = malloc(sizeof(int) * n);
  for (size_t i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  int p, q;
  scanf("%d %d", &p, &q);
  quick_sort(a, 0, n - 1);
  int max = -1;
  int ans = 0;
  if (a[0] >= p) {
    max = a[0] - p;
    ans = p;
  }
  int left = a[0];
  int right = 0;
  for (size_t i = 1; i < n; i++) {
    right = a[i];
    if (p <= left && q >= right) {
      int mid = (left + right) / 2;
      if ((mid - left) > max) {
        max = mid - left;
        ans = mid;
      }
    } else if (left < p && right > q) {
      int mid = (left + right) / 2;
      if (mid >= p && mid <= q) {
        if ((mid - left) > max) {
          max = mid - left;
          ans = mid;
        }
      } else if (mid > q) {
        if ((q - left) > max) {
          max = q - left;
          ans = q;
        }
      } else {
        if ((right - p) > max) {
          max = right - p;
          ans = p;
        }
      }
    } else if (right > q && left <= q) {
      int mid = (left + right) / 2;
      if (mid <= q) {
        if ((mid - left) > max) {
          max = mid - left;
          ans = mid;
        }
      } else {
        if ((q - left) > max) {
          max = q - left;
          ans = q;
        }
      }
    } else if (left < p && p <= right) {
      int mid = (left + right) / 2;
      if (mid >= p) {
        if ((mid - left) > max) {
          max = mid - left;
          ans = mid;
        }
      } else {
        if ((right - p) > max) {
          max = right - p;
          ans = p;
        }
      }
    }
    left = a[i];
  }
  if (q >= a[n - 1]) {
    if ((q - a[n - 1]) > max) {
      max = q - a[n - 1];
      ans = q;
    }
  }
  printf("%d\n", ans);
  free(a);
  return 0;
}
```