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

```asm
<MedSelect>:
  endbr64
  push   %r15
  mov    %rdx,%r11
  push   %r14
  mov    %esi,%r14d
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %edi,-0x4(%rsp)
  cmp    $0x2,%esi
  jle    L47
  mov    $0x1,%r15d
  mov    $0x2,%edx
  nopl   0x0(%rax)
L126:
  movslq %r15d,%rcx
  lea    (%r15,%r14,1),%eax
  lea    0x4(,%rcx,4),%r12
  sar    %eax
  lea    (%r11,%r12,1),%r13
  cltq
  sub    $0x4,%r12
  mov    0x0(%r13),%ecx
  lea    (%r11,%rax,4),%rax
  mov    (%rax),%edi
  mov    %ecx,(%rax)
  movslq %r14d,%rax
  lea    (%r11,%r12,1),%rcx
  lea    (%r11,%rax,4),%rsi
  mov    %edi,0x0(%r13)
  mov    (%rcx),%r8d
  mov    (%rsi),%eax
  cmp    %eax,%r8d
  jle    L29
  mov    %eax,(%rcx)
  mov    %r8d,%eax
  mov    %r8d,(%rsi)
  mov    0x0(%r13),%edi
L29:
  cmp    %eax,%edi
  jle    L55
  mov    %eax,0x0(%r13)
  mov    %edi,(%rsi)
  mov    0x0(%r13),%edi
L55:
  mov    (%rcx),%eax
  movd   %edi,%xmm0
  movd   %eax,%xmm1
  punpckldq %xmm1,%xmm0
  cmp    %edi,%eax
  jle    L36
  movq   %xmm0,(%rcx)
  mov    %eax,%edi
L36:
  add    $0x1,%edx
  movslq %edx,%rsi
  mov    %r14d,%edx
  nopl   0x0(%rax,%rax,1)
L42:
  mov    (%r11,%rsi,4),%r10d
  mov    %esi,%ebp
  lea    0x0(,%rsi,4),%rbx
  cmp    %edi,%r10d
  jl     L127
  movslq %edx,%rax
  lea    -0x4(%r11,%rax,4),%rax
  nopl   0x0(%rax,%rax,1)
L111:
  mov    %rax,%r8
  mov    (%rax),%ecx
  mov    %edx,%r9d
  sub    $0x4,%rax
  sub    $0x1,%edx
  cmp    %edi,%ecx
  jg     L111
  cmp    %esi,%edx
  jl     L82
  mov    %ecx,(%r11,%rsi,4)
  mov    %r10d,(%r8)
L127:
  add    $0x1,%rsi
  jmp    L42
  nopl   0x0(%rax)
L82:
  mov    -0x4(%rsp),%eax
  mov    %ecx,0x0(%r13)
  mov    %edi,(%r8)
  cmp    %eax,%edx
  jl     L120
  cmovne %r12,%rbx
  cmove  %ebp,%r15d
  lea    -0x2(%r9),%r14d
L75:
  lea    0x1(%r15),%edx
  cmp    %r14d,%edx
  jl     L126
L71:
  cmp    %r14d,%edx
  je     L79
L26:
  movslq -0x4(%rsp),%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  mov    (%r11,%rax,4),%eax
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L120:
  mov    %ebp,%r15d
  jmp    L75
L79:
  movslq %edx,%rdx
  add    %r11,%rbx
  lea    (%r11,%rdx,4),%rax
  mov    (%rbx),%edx
  mov    (%rax),%ecx
  cmp    %edx,%ecx
  jge    L26
  mov    %ecx,(%rbx)
  mov    %edx,(%rax)
  jmp    L26
L47:
  mov    $0x4,%ebx
  mov    $0x2,%edx
  jmp    L71
```

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;
    }
  }
}
```