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

```asm
<MERGE>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%r9
  mov    %esi,%r11d
  mov    %edx,%r13d
  mov    %fs:0x28,%rax
  mov    %rax,-0x28(%rbp)
  xor    %eax,%eax
  sub    %esi,%edx
  lea    0x1(%rdx),%r8d
  mov    %ecx,%r10d
  sub    %r13d,%r10d
  movslq %r8d,%rax
  lea    0xf(,%rax,4),%rax
  mov    %rax,%rdi
  and    $0xfffffffffffffff0,%rdi
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%rsi
  sub    %rax,%rsi
L50:
  cmp    %rsi,%rsp
  je     L64
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L50
L64:
  mov    %rdi,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  je     L131
  orq    $0x0,-0x8(%rsp,%rax,1)
L131:
  mov    %rsp,%rdi
  movslq %r10d,%rax
  lea    0xf(,%rax,4),%rax
  mov    %rax,%rbx
  and    $0xfffffffffffffff0,%rbx
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%rsi
  sub    %rax,%rsi
L75:
  cmp    %rsi,%rsp
  je     L149
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L75
L149:
  mov    %rbx,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  je     L115
  orq    $0x0,-0x8(%rsp,%rax,1)
L115:
  mov    %rsp,%rsi
  test   %r8d,%r8d
  jle    L16
  mov    %edx,%edx
  lea    0x4(,%rdx,4),%r12
  movslq %r11d,%rax
  lea    (%r9,%rax,4),%rbx
  mov    $0x0,%eax
L177:
  mov    (%rbx,%rax,1),%edx
  mov    %edx,(%rdi,%rax,1)
  add    $0x4,%rax
  cmp    %r12,%rax
  jne    L177
L16:
  test   %r10d,%r10d
  jle    L14
  lea    0x1(%r10),%r12d
  movslq %r13d,%r13
  lea    (%r9,%r13,4),%rbx
  mov    $0x1,%eax
L91:
  mov    (%rbx,%rax,4),%edx
  mov    %edx,-0x4(%rsi,%rax,4)
  add    $0x1,%rax
  cmp    %r12,%rax
  jne    L91
L14:
  cmp    %ecx,%r11d
  jg     L12
  movslq %r11d,%rdx
  lea    (%r9,%rdx,4),%rax
  sub    %r11d,%ecx
  add    %rdx,%rcx
  lea    0x4(%r9,%rcx,4),%r9
  mov    $0x0,%r12d
  mov    $0x0,%ecx
  mov    $0x0,%edx
  jmp    L57
L70:
  movslq %ecx,%r11
  mov    (%rsi,%r11,4),%r11d
  mov    %r11d,(%rax)
  lea    0x1(%rcx),%ecx
L170:
  add    $0x4,%rax
  cmp    %r9,%rax
  je     L116
L57:
  cmp    %edx,%r8d
  je     L70
  cmp    %ecx,%r10d
  je     L30
  movslq %edx,%r11
  mov    (%rdi,%r11,4),%ebx
  movslq %ecx,%r11
  mov    (%rsi,%r11,4),%r11d
  cmp    %r11d,%ebx
  jg     L181
  add    $0x1,%edx
  mov    %ebx,(%rax)
  jmp    L170
L30:
  movslq %edx,%r11
  mov    (%rdi,%r11,4),%r11d
  mov    %r11d,(%rax)
  lea    0x1(%rdx),%edx
  jmp    L170
L181:
  add    $0x1,%ecx
  mov    %r11d,(%rax)
  mov    %r8d,%r11d
  sub    %edx,%r11d
  add    %r11d,%r12d
  jmp    L170
L12:
  mov    $0x0,%r12d
L116:
  mov    -0x28(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L29
  mov    %r12d,%eax
  lea    -0x18(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %rbp
  ret
L29:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int MERGE(int A[], int p, int q, int r) {
  int i, j, k, inversions = 0;
  int n1 = q - p + 1;
  int n2 = r - q;
  int L[n1];
  int R[n2];
  for (i = 0; i < n1; i++)
    L[i] = A[p + i];
  for (j = 0; j < n2; j++)
    R[j] = A[q + j + 1];
  for (i = 0, j = 0, k = p; k <= r; k++) {
    if (i == n1) {
      A[k] = R[j++];
    } else if (j == n2) {
      A[k] = L[i++];
    } else if (L[i] <= R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
      inversions += n1 - i;
    }
  }
  return inversions;
}
```