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

```asm
<QuickSort>:
  endbr64
  push   %rbx
  mov    %rdi,%r10
  mov    %esi,%ebx
  xor    %r11d,%r11d
  sub    $0x970,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x968(%rsp)
  xor    %eax,%eax
  movl   $0x0,(%rsp)
  mov    %esi,0x4b0(%rsp)
L113:
  lea    -0x1(%rbx),%edx
  cmp    %eax,%edx
  jg     L192
L157:
  sub    $0x1,%r11d
  jb     L151
  movslq %r11d,%rdx
  mov    0x4b0(%rsp,%rdx,4),%ebx
  mov    (%rsp,%rdx,4),%eax
  lea    -0x1(%rbx),%edx
  cmp    %eax,%edx
  jle    L157
L192:
  movslq %eax,%r9
  mov    (%r10,%r9,4),%edi
  nopl   0x0(%rax)
L144:
  movslq %edx,%rcx
  lea    (%r10,%rcx,4),%r8
  mov    (%r8),%esi
  cmp    %edx,%eax
  jge    L101
  lea    -0x4(%r10,%rcx,4),%rcx
  jmp    L102
  nopl   (%rax)
L14:
  sub    $0x1,%edx
  mov    (%rcx),%esi
  mov    %rcx,%r8
  sub    $0x4,%rcx
  cmp    %eax,%edx
  jle    L87
L102:
  cmp    %edi,%esi
  jge    L14
L101:
  cmp    %eax,%edx
  jle    L87
  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     L112
  cmp    %eax,%edx
  jle    L55
  lea    0x4(%r10,%rcx,1),%rcx
  jmp    L97
  nopl   0x0(%rax)
L175:
  add    $0x4,%rcx
  cmp    %edx,%eax
  je     L59
L97:
  mov    (%rcx),%esi
  add    $0x1,%eax
  mov    %rcx,%r9
  cmp    %edi,%esi
  jle    L175
L112:
  cmp    %edx,%eax
  jge    L55
  sub    $0x1,%edx
  mov    %esi,(%r8)
  cmp    %eax,%edx
  jle    L55
  movslq %eax,%r9
  jmp    L144
  nopw   0x0(%rax,%rax,1)
L87:
  lea    (%r10,%r9,4),%r9
  mov    (%r9),%esi
  cmp    %esi,%edi
  jl     L112
L55:
  mov    %eax,%edx
  nopl   (%rax)
L59:
  lea    0x1(%r11),%esi
  movslq %r11d,%r11
  lea    0x1(%rdx),%eax
  mov    %edi,(%r9)
  movslq %esi,%rcx
  mov    %edx,%r8d
  mov    %ebx,0x4b0(%rsp,%rcx,4)
  mov    %edx,0x4b0(%rsp,%r11,4)
  mov    0x4b0(%rsp,%rcx,4),%ebx
  mov    %eax,(%rsp,%rcx,4)
  mov    (%rsp,%r11,4),%edi
  mov    %ebx,%r9d
  sub    %eax,%r9d
  sub    %edi,%r8d
  cmp    %r8d,%r9d
  jle    L4
  mov    %edi,(%rsp,%rcx,4)
  mov    %edx,0x4b0(%rsp,%rcx,4)
  mov    %eax,(%rsp,%r11,4)
  mov    (%rsp,%rcx,4),%eax
  mov    %ebx,0x4b0(%rsp,%r11,4)
  mov    0x4b0(%rsp,%rcx,4),%ebx
L4:
  mov    %esi,%r11d
  jmp    L113
L151:
  mov    0x968(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L191
  add    $0x970,%rsp
  pop    %rbx
  ret
L191:
  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;
    }
  }
}
```