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

```asm
<quick_select>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%r11
  lea    -0x1(%rsi),%ebp
  mov    %ebp,%r13d
  shr    $0x1f,%r13d
  add    %ebp,%r13d
  sar    %r13d
  test   %ebp,%ebp
  jle    L46
  cmp    $0x1,%ebp
  je     L133
  mov    $0x0,%r12d
  mov    $0x1,%eax
  jmp    L43
L46:
  movslq %r13d,%r13
  mov    (%r11,%r13,4),%eax
L53:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L133:
  mov    $0x0,%r12d
L12:
  movslq %r12d,%r12
  lea    (%r11,%r12,4),%rcx
  mov    (%rcx),%edx
  movslq %ebp,%rbp
  lea    (%r11,%rbp,4),%rax
  mov    (%rax),%esi
  cmp    %esi,%edx
  jle    L62
  mov    %esi,(%rcx)
  mov    %edx,(%rax)
L62:
  movslq %r13d,%r13
  mov    (%r11,%r13,4),%eax
  jmp    L53
L84:
  add    $0x1,%r8
L147:
  mov    %r8d,%r14d
  mov    (%rbx),%esi
  mov    (%r11,%r8,4),%r10d
  cmp    %r10d,%esi
  jg     L84
  movslq %edx,%rax
  lea    -0x4(%r11,%rax,4),%rax
L13:
  mov    %edx,%r9d
  sub    $0x1,%edx
  mov    %rax,%rdi
  sub    $0x4,%rax
  mov    0x4(%rax),%ecx
  cmp    %ecx,%esi
  jl     L13
  cmp    %r8d,%edx
  jl     L170
  mov    %ecx,(%r11,%r8,4)
  mov    %r10d,(%rdi)
  jmp    L84
L170:
  mov    %ecx,(%rbx)
  mov    %esi,(%rdi)
  cmp    %edx,%r13d
  jl     L24
  je     L155
  mov    %r14d,%r12d
L104:
  cmp    %r12d,%ebp
  jle    L46
  lea    0x1(%r12),%eax
  cmp    %ebp,%eax
  je     L12
L43:
  lea    (%r12,%rbp,1),%ecx
  mov    %ecx,%edx
  shr    $0x1f,%edx
  add    %ecx,%edx
  sar    %edx
  movslq %edx,%rdx
  lea    (%r11,%rdx,4),%rdx
  mov    (%rdx),%ecx
  movslq %ebp,%rsi
  lea    (%r11,%rsi,4),%rsi
  mov    (%rsi),%edi
  cmp    %edi,%ecx
  jle    L97
  mov    %edi,(%rdx)
  mov    %ecx,(%rsi)
L97:
  movslq %r12d,%rcx
  shl    $0x2,%rcx
  lea    (%r11,%rcx,1),%rbx
  mov    (%rbx),%edi
  mov    (%rsi),%r8d
  cmp    %r8d,%edi
  jle    L60
  mov    %r8d,(%rbx)
  mov    %edi,(%rsi)
L60:
  mov    (%rdx),%esi
  mov    (%rbx),%edi
  cmp    %edi,%esi
  jle    L116
  mov    %edi,(%rdx)
  mov    %esi,(%rbx)
L116:
  mov    (%rdx),%esi
  lea    0x4(%r11,%rcx,1),%rcx
  mov    (%rcx),%edi
  mov    %edi,(%rdx)
  mov    %esi,(%rcx)
  add    $0x1,%eax
  movslq %eax,%r8
  mov    %ebp,%edx
  jmp    L147
L155:
  mov    %r14d,%r12d
L24:
  lea    -0x2(%r9),%ebp
  jmp    L104
```

assistant: ```c
int quick_select(int *arr, int n) {
  int low = 0, high = n - 1;
  int median = (low + high) / 2;
  int middle, ll, hh;
  while (1) {
    if (high <= low)
      return arr[median];
    if (high == low + 1) {
      if (arr[low] > arr[high]) {
        register int t = (arr[low]);
        (arr[low]) = (arr[high]);
        (arr[high]) = t;
      };
      return arr[median];
    }
    middle = (low + high) / 2;
    if (arr[middle] > arr[high]) {
      register int t = (arr[middle]);
      (arr[middle]) = (arr[high]);
      (arr[high]) = t;
    };
    if (arr[low] > arr[high]) {
      register int t = (arr[low]);
      (arr[low]) = (arr[high]);
      (arr[high]) = t;
    };
    if (arr[middle] > arr[low]) {
      register int t = (arr[middle]);
      (arr[middle]) = (arr[low]);
      (arr[low]) = t;
    };
    {
      register int t = (arr[middle]);
      (arr[middle]) = (arr[low + 1]);
      (arr[low + 1]) = t;
    };
    ll = low + 1;
    hh = high;
    while (1) {
      do
        ll++;
      while (arr[low] > arr[ll]);
      do
        hh--;
      while (arr[hh] > arr[low]);
      if (hh < ll)
        break;
      {
        register int t = (arr[ll]);
        (arr[ll]) = (arr[hh]);
        (arr[hh]) = t;
      };
    }
    {
      register int t = (arr[low]);
      (arr[low]) = (arr[hh]);
      (arr[hh]) = t;
    };
    if (hh <= median)
      low = ll;
    if (hh >= median)
      high = hh - 1;
  }
}
```