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

```asm
<qsi>:
  endbr64
  push   %rbp
  mov    %rdi,%r10
  xor    %r11d,%r11d
  push   %rbx
  mov    %esi,%ebx
  sub    $0x978,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x968(%rsp)
  xor    %eax,%eax
  movl   $0x0,(%rsp)
  lea    0x4b0(%rsp),%rbp
  mov    %esi,0x4b0(%rsp)
L22:
  lea    -0x1(%rbx),%edx
  cmp    %eax,%edx
  jg     L40
L19:
  sub    $0x1,%r11d
  jb     L98
  movslq %r11d,%rdx
  mov    0x4b0(%rsp,%rdx,4),%ebx
  mov    (%rsp,%rdx,4),%eax
  lea    -0x1(%rbx),%edx
  cmp    %eax,%edx
  jle    L19
L40:
  movslq %eax,%r9
  mov    (%r10,%r9,4),%edi
  nopw   0x0(%rax,%rax,1)
L163:
  movslq %edx,%rcx
  lea    (%r10,%rcx,4),%r8
  mov    (%r8),%esi
  cmp    %edx,%eax
  jge    L160
  lea    -0x4(%r10,%rcx,4),%rcx
  jmp    L55
  nopl   (%rax)
L8:
  sub    $0x1,%edx
  mov    (%rcx),%esi
  mov    %rcx,%r8
  sub    $0x4,%rcx
  cmp    %eax,%edx
  jle    L72
L55:
  cmp    %edi,%esi
  jge    L8
L160:
  cmp    %eax,%edx
  jle    L72
  add    $0x1,%eax
  mov    %esi,(%r10,%r9,4)
  movslq %eax,%rcx
  shl    $0x2,%rcx
  lea    (%r10,%rcx,1),%r9
  mov    (%r9),%esi
  cmp    %edi,%esi
  jg     L28
  cmp    %eax,%edx
  jle    L159
  lea    0x4(%r10,%rcx,1),%rcx
  jmp    L165
  nopl   0x0(%rax)
L35:
  add    $0x4,%rcx
  cmp    %edx,%eax
  je     L171
L165:
  mov    (%rcx),%esi
  add    $0x1,%eax
  mov    %rcx,%r9
  cmp    %edi,%esi
  jle    L35
L28:
  cmp    %edx,%eax
  jge    L159
  sub    $0x1,%edx
  mov    %esi,(%r8)
  cmp    %eax,%edx
  jle    L159
  movslq %eax,%r9
  jmp    L163
  nop
L72:
  lea    (%r10,%r9,4),%r9
  mov    (%r9),%esi
  cmp    %esi,%edi
  jl     L28
L159:
  mov    %eax,%edx
  nopl   (%rax)
L171:
  lea    0x1(%r11),%esi
  movd   %edx,%xmm0
  movslq %r11d,%r11
  mov    %edi,(%r9)
  movd   %ebx,%xmm2
  lea    0x1(%rdx),%eax
  lea    0x0(%rbp,%r11,4),%rdi
  movslq %esi,%rcx
  punpckldq %xmm2,%xmm0
  mov    %eax,(%rsp,%rcx,4)
  movd   %edx,%xmm3
  movd   %eax,%xmm1
  movq   %xmm0,(%rdi)
  mov    0x4b0(%rsp,%rcx,4),%ebx
  movd   (%rsp,%r11,4),%xmm4
  sub    (%rsp,%r11,4),%edx
  mov    %ebx,%r8d
  movd   %ebx,%xmm0
  punpckldq %xmm4,%xmm1
  sub    %eax,%r8d
  punpckldq %xmm3,%xmm0
  cmp    %edx,%r8d
  jle    L133
  movq   %xmm1,(%rsp,%r11,4)
  movq   %xmm0,(%rdi)
  mov    (%rsp,%rcx,4),%eax
  mov    0x4b0(%rsp,%rcx,4),%ebx
L133:
  mov    %esi,%r11d
  jmp    L22
L98:
  mov    0x968(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L54
  add    $0x978,%rsp
  pop    %rbx
  pop    %rbp
  ret
L54:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void qsi(int *a, int elements) {
  int piv, beg[300], end[300], i = 0, L, R, swap;
  beg[0] = 0;
  end[0] = elements;
  while (i >= 0) {
    L = beg[i];
    R = end[i] - 1;
    if (L < R) {
      piv = a[L];
      while (L < R) {
        while (a[R] >= piv && L < R)
          R--;
        if (L < R)
          a[L++] = a[R];
        while (a[L] <= piv && L < R)
          L++;
        if (L < R)
          a[R--] = a[L];
      }
      a[L] = piv;
      beg[i + 1] = L + 1;
      end[i + 1] = end[i];
      end[i++] = L;
      if (end[i] - beg[i] > end[i - 1] - beg[i - 1]) {
        swap = beg[i];
        beg[i] = beg[i - 1];
        beg[i - 1] = swap;
        swap = end[i];
        end[i] = end[i - 1];
        end[i - 1] = swap;
      }
    } else {
      i--;
    }
  }
}
```