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

```asm
<MedSelect>:
  endbr64
  push   %r14
  mov    %rdx,%r11
  mov    $0x2,%eax
  push   %r13
  mov    $0x1,%r13d
  push   %r12
  mov    %esi,%r12d
  push   %rbp
  movslq %edi,%rbp
  push   %rbx
  cmp    $0x2,%esi
  jle    L33
  nopl   0x0(%rax)
L121:
  lea    0x0(%r13,%r12,1),%edx
  sar    %edx
  movslq %edx,%rdx
  lea    (%r11,%rdx,4),%rcx
  movslq %r13d,%rdx
  lea    0x4(,%rdx,4),%rdx
  mov    (%rcx),%esi
  lea    (%r11,%rdx,1),%rbx
  mov    (%rbx),%edi
  mov    %edi,(%rcx)
  lea    -0x4(%r11,%rdx,1),%rcx
  movslq %r12d,%rdx
  lea    (%r11,%rdx,4),%rdi
  mov    %esi,(%rbx)
  mov    (%rcx),%r8d
  mov    (%rdi),%edx
  cmp    %edx,%r8d
  jle    L80
  mov    %edx,(%rcx)
  mov    %r8d,%edx
  mov    %r8d,(%rdi)
  mov    (%rbx),%esi
L80:
  cmp    %edx,%esi
  jle    L90
  mov    %edx,(%rbx)
  mov    %esi,(%rdi)
  mov    (%rbx),%esi
L90:
  mov    (%rcx),%edx
  cmp    %esi,%edx
  jle    L3
  mov    %esi,(%rcx)
  mov    %edx,%esi
  mov    %edx,(%rbx)
L3:
  add    $0x1,%eax
  mov    %r12d,%edx
  movslq %eax,%r8
  nopl   0x0(%rax)
L100:
  mov    (%r11,%r8,4),%r10d
  movslq %r8d,%r14
  cmp    %esi,%r10d
  jl     L47
  movslq %edx,%rax
  lea    -0x4(%r11,%rax,4),%rax
  nopl   0x0(%rax)
L117:
  mov    %rax,%rdi
  mov    (%rax),%ecx
  mov    %edx,%r9d
  sub    $0x4,%rax
  sub    $0x1,%edx
  cmp    %esi,%ecx
  jg     L117
  cmp    %r8d,%edx
  jl     L26
  mov    %ecx,(%r11,%r8,4)
  mov    %r10d,(%rdi)
L47:
  add    $0x1,%r8
  jmp    L100
  nopl   (%rax)
L26:
  mov    %ecx,(%rbx)
  mov    %esi,(%rdi)
  cmp    %ebp,%edx
  jl     L18
  cmove  %r14,%r13
  lea    -0x2(%r9),%r12d
L43:
  lea    0x1(%r13),%eax
  cmp    %r12d,%eax
  jl     L121
L33:
  cmp    %r12d,%eax
  je     L73
L27:
  pop    %rbx
  mov    (%r11,%rbp,4),%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L18:
  movslq %r14d,%r13
  jmp    L43
L73:
  cltq
  lea    (%r11,%r13,4),%rcx
  lea    (%r11,%rax,4),%rax
  mov    (%rcx),%edx
  mov    (%rax),%esi
  cmp    %edx,%esi
  jge    L27
  mov    %esi,(%rcx)
  mov    %edx,(%rax)
  pop    %rbx
  mov    (%r11,%rbp,4),%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

assistant: ```c
int MedSelect(int k, int n, int arr[]) {
  int a, temp;
  int i, ir, j, mid, l;
  l = 1;
  ir = n;
  for (;;) {
    if (ir <= l + 1) {
      if (ir == l + 1 && arr[ir] < arr[l]) {
        temp = (arr[l]);
        (arr[l]) = (arr[ir]);
        (arr[ir]) = temp;
      }
      return arr[k];
    } else {
      mid = (l + ir) >> 1;
      temp = (arr[mid]);
      (arr[mid]) = (arr[l + 1]);
      (arr[l + 1]) = temp;
      if (arr[l] > arr[ir]) {
        temp = (arr[l]);
        (arr[l]) = (arr[ir]);
        (arr[ir]) = temp;
      }
      if (arr[l + 1] > arr[ir]) {
        temp = (arr[l + 1]);
        (arr[l + 1]) = (arr[ir]);
        (arr[ir]) = temp;
      }
      if (arr[l] > arr[l + 1]) {
        temp = (arr[l]);
        (arr[l]) = (arr[l + 1]);
        (arr[l + 1]) = temp;
      }
      i = l + 1;
      j = ir;
      a = arr[l + 1];
      for (;;) {
        do
          i++;
        while (arr[i] < a);
        do
          j--;
        while (arr[j] > a);
        if (j < i)
          break;
        temp = (arr[i]);
        (arr[i]) = (arr[j]);
        (arr[j]) = temp;
      }
      arr[l + 1] = arr[j];
      arr[j] = a;
      if (j >= k)
        ir = j - 1;
      if (j <= k)
        l = i;
    }
  }
}
```