user: Converte this assembly snippet into its equivalent C code:

```asm
<QuickSort>:
  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)
L132:
  lea    -0x1(%rbx),%edx
  cmp    %eax,%edx
  jg     L194
L116:
  sub    $0x1,%r11d
  jb     L28
  movslq %r11d,%rdx
  mov    0x4b0(%rsp,%rdx,4),%ebx
  mov    (%rsp,%rdx,4),%eax
  lea    -0x1(%rbx),%edx
  cmp    %eax,%edx
  jle    L116
L194:
  movslq %eax,%r9
  mov    (%r10,%r9,4),%edi
  nopw   0x0(%rax,%rax,1)
L38:
  movslq %edx,%rcx
  lea    (%r10,%rcx,4),%r8
  mov    (%r8),%esi
  cmp    %edx,%eax
  jge    L104
  lea    -0x4(%r10,%rcx,4),%rcx
  jmp    L46
  nopl   (%rax)
L18:
  sub    $0x1,%edx
  mov    (%rcx),%esi
  mov    %rcx,%r8
  sub    $0x4,%rcx
  cmp    %eax,%edx
  jle    L112
L46:
  cmp    %edi,%esi
  jge    L18
L104:
  cmp    %eax,%edx
  jle    L112
  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     L187
  cmp    %eax,%edx
  jle    L37
  lea    0x4(%r10,%rcx,1),%rcx
  jmp    L91
  nopl   0x0(%rax)
L73:
  add    $0x4,%rcx
  cmp    %edx,%eax
  je     L173
L91:
  mov    (%rcx),%esi
  add    $0x1,%eax
  mov    %rcx,%r9
  cmp    %edi,%esi
  jle    L73
L187:
  cmp    %edx,%eax
  jge    L37
  sub    $0x1,%edx
  mov    %esi,(%r8)
  cmp    %eax,%edx
  jle    L37
  movslq %eax,%r9
  jmp    L38
  nop
L112:
  lea    (%r10,%r9,4),%r9
  mov    (%r9),%esi
  cmp    %esi,%edi
  jl     L187
L37:
  mov    %eax,%edx
  nopl   (%rax)
L173:
  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    L132
L28:
  mov    0x968(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L62
  add    $0x978,%rsp
  pop    %rbx
  pop    %rbp
  ret
L62:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void QuickSort(int *arr, 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 = arr[L];
      while (L < R) {
        while (arr[R] >= piv && L < R)
          R--;
        if (L < R)
          arr[L++] = arr[R];
        while (arr[L] <= piv && L < R)
          L++;
        if (L < R)
          arr[R--] = arr[L];
      }
      arr[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;
    }
  }
}
```