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

```asm
<sort>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  mov    %edx,-0x30(%rbp)
  mov    $0x0,%eax
  call   <stackInit@plt>
  mov    -0x30(%rbp),%edx
  mov    -0x2c(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <push@plt>
  jmp    L60
L133:
  mov    $0x0,%eax
  call   <pop@plt>
  mov    %eax,-0x10(%rbp)
  mov    -0x10(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    $0x0,%eax
  call   <pop@plt>
  mov    %eax,-0x14(%rbp)
  mov    -0x14(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  mov    -0x14(%rbp),%edx
  mov    -0x10(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x4(%rbp)
  jmp    L36
L114:
  addl   $0x1,-0x14(%rbp)
L50:
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    %eax,-0x4(%rbp)
  jg     L114
  jmp    L45
L116:
  subl   $0x1,-0x10(%rbp)
L45:
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    %eax,-0x4(%rbp)
  jl     L116
  mov    -0x14(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jg     L36
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <swap@plt>
  addl   $0x1,-0x14(%rbp)
  subl   $0x1,-0x10(%rbp)
L36:
  mov    -0x14(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jle    L50
  mov    -0x10(%rbp),%eax
  sub    -0x8(%rbp),%eax
  mov    %eax,%edx
  mov    -0xc(%rbp),%eax
  sub    -0x14(%rbp),%eax
  cmp    %eax,%edx
  jle    L59
  mov    -0x10(%rbp),%eax
  cmp    -0x8(%rbp),%eax
  jle    L77
  mov    -0x10(%rbp),%edx
  mov    -0x8(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <push@plt>
L77:
  mov    -0x14(%rbp),%eax
  cmp    -0xc(%rbp),%eax
  jge    L60
  mov    -0xc(%rbp),%edx
  mov    -0x14(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <push@plt>
  jmp    L60
L59:
  mov    -0x14(%rbp),%eax
  cmp    -0xc(%rbp),%eax
  jge    L14
  mov    -0xc(%rbp),%edx
  mov    -0x14(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <push@plt>
L14:
  mov    -0x10(%rbp),%eax
  cmp    -0x8(%rbp),%eax
  jle    L60
  mov    -0x10(%rbp),%edx
  mov    -0x8(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <push@plt>
L60:
  mov    $0x0,%eax
  call   <isEmpty@plt>
  test   %eax,%eax
  je     L133
  nop
  nop
  leave
  ret
```

assistant: ```c
void sort(int *a, int l, int r) {
  stackInit();
  int i, j, v;
  int l0, r0;
  push(l, r);
  while (!isEmpty()) {
    r0 = j = pop();
    l0 = i = pop();
    v = a[(i + j) / 2];
    while (i <= j) {
      while (a[i] < v)
        i++;
      while (a[j] > v)
        j--;
      if (i <= j) {
        swap(a + i, a + j);
        i++;
        j--;
      }
    }
    if (j - l0 > r0 - i) {
      if (j > l0)
        push(l0, j);
      if (i < r0)
        push(i, r0);
    } else {
      if (i < r0)
        push(i, r0);
      if (j > l0)
        push(l0, j);
    }
  }
}
```