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

```asm
<stable_grail_rec_merge>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  mov    %esi,%ebx
  sub    $0x28,%rsp
  cmp    $0x2,%esi
  jle    L93
  cmp    $0x2,%edx
  jle    L93
L0:
  mov    %ebp,%edx
  mov    %ebx,%eax
  mov    %ebx,%esi
  mov    %r12,%rdi
  sar    %edx
  sar    %eax
  add    %ebx,%edx
  cmp    %ebx,%ebp
  cmovg  %edx,%eax
  cltq
  lea    (%r12,%rax,8),%r15
  mov    %r15,%rdx
  call   <stable_grail_bin_search_left@plt>
  mov    %ebx,%r9d
  mov    %eax,%r13d
  cltq
  sub    %r13d,%r9d
  lea    (%r12,%rax,8),%r10
  mov    %r9d,%r14d
  cmp    %ebx,%r13d
  jge    L11
  mov    (%r15),%rax
  mov    (%r10),%rdx
  mov    (%rax),%eax
  cmp    %eax,(%rdx)
  je     L127
L11:
  movslq %ebx,%rcx
  mov    %r15,%rdx
  mov    %ebp,%esi
  mov    %r10,0x10(%rsp)
  lea    (%r12,%rcx,8),%rdi
  mov    %r9d,0x8(%rsp)
  mov    %rcx,(%rsp)
  call   <stable_grail_bin_search_left@plt>
  mov    (%rsp),%rcx
  mov    0x8(%rsp),%r9d
  cmp    %eax,%ebp
  mov    0x10(%rsp),%r10
  mov    %eax,%ebx
  jg     L15
  mov    %r13d,(%rsp)
  mov    %eax,%r15d
L120:
  mov    %ebx,%edx
  mov    %r9d,%esi
  mov    %r10,%rdi
  call   <stable_grail_rotate@plt>
L29:
  mov    %ebp,%edx
  mov    %r14d,%esi
  sub    %ebx,%edx
  add    (%rsp),%ebx
  movslq %ebx,%rbx
  lea    (%r12,%rbx,8),%rdi
  call   <stable_grail_rec_merge>
  cmp    $0x2,%r13d
  jle    L68
  cmp    $0x2,%r15d
  jle    L68
  mov    %r15d,%ebp
  mov    %r13d,%ebx
  jmp    L0
  nopl   0x0(%rax,%rax,1)
L15:
  mov    %r13d,(%rsp)
L80:
  movslq %ebx,%rax
  add    %rcx,%rax
  lea    (%r12,%rax,8),%rdi
  mov    (%r15),%rax
  mov    (%rdi),%rdx
  mov    (%rax),%eax
  cmp    %eax,(%rdx)
  je     L16
L79:
  cmp    %r13d,(%rsp)
  je     L178
  mov    %ebx,%edx
  mov    %r9d,%esi
  mov    %r10,%rdi
  mov    %ebx,%r15d
  call   <stable_grail_rotate@plt>
  jmp    L29
  nopw   0x0(%rax,%rax,1)
L93:
  mov    %ebp,%r15d
  mov    %ebx,%r13d
L68:
  add    $0x28,%rsp
  mov    %r15d,%edx
  mov    %r13d,%esi
  mov    %r12,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10b0 <stable_grail_merge_without_buffer@plt>
  nopw   0x0(%rax,%rax,1)
L178:
  mov    %ebx,%r15d
  jmp    L120
  nopl   0x0(%rax,%rax,1)
L16:
  mov    %ebp,%esi
  mov    %r15,%rdx
  mov    %r10,0x18(%rsp)
  sub    %ebx,%esi
  mov    %r9d,0x10(%rsp)
  call   <stable_grail_bin_search_right@plt>
  cmp    (%rsp),%r13d
  mov    0x10(%rsp),%r9d
  mov    %eax,%r15d
  lea    (%rax,%rbx,1),%eax
  mov    0x18(%rsp),%r10
  mov    %eax,0x8(%rsp)
  je     L129
  mov    %ebx,%edx
  mov    %r9d,%esi
  mov    %r10,%rdi
  call   <stable_grail_rotate@plt>
  cmp    %ebx,0x8(%rsp)
  je     L122
  mov    (%rsp),%ecx
  mov    %r15d,%edx
  mov    %r14d,%esi
  mov    %ebx,%r15d
  lea    (%rcx,%rbx,1),%eax
  cltq
  lea    (%r12,%rax,8),%rdi
  call   <stable_grail_rotate@plt>
  mov    0x8(%rsp),%ebx
  jmp    L29
  xchg   %ax,%ax
L127:
  mov    %r9d,%esi
  mov    %r10,%rdi
  mov    %r15,%rdx
  mov    %r9d,0x18(%rsp)
  mov    %r10,0x10(%rsp)
  mov    %ebx,%r14d
  call   <stable_grail_bin_search_right@plt>
  movslq %ebx,%rcx
  mov    %r15,%rdx
  mov    %ebp,%esi
  add    %r13d,%eax
  lea    (%r12,%rcx,8),%rdi
  mov    %rcx,0x8(%rsp)
  sub    %eax,%r14d
  mov    %eax,(%rsp)
  call   <stable_grail_bin_search_left@plt>
  mov    0x8(%rsp),%rcx
  mov    0x10(%rsp),%r10
  cmp    %ebp,%eax
  mov    0x18(%rsp),%r9d
  mov    %eax,%ebx
  jl     L80
  jmp    L79
L129:
  mov    %ebx,%r15d
  mov    %eax,%ebx
  jmp    L120
L122:
  mov    %ebx,%r15d
  jmp    L29
```

assistant: ```c
void stable_grail_rec_merge(int **A, int L1, int L2) {
  int K, k1, k2, m1, m2;
  if (L1 < 3 || L2 < 3) {
    stable_grail_merge_without_buffer(A, L1, L2);
    return;
  }
  if (L1 < L2) {
    K = L1 + L2 / 2;
  } else {
    K = L1 / 2;
  }
  k1 = k2 = stable_grail_bin_search_left(A, L1, A + K);
  if (k2 < L1 && (*(*(A + k2)) - *(*(A + K))) == 0) {
    k2 = stable_grail_bin_search_right(A + k1, L1 - k1, A + K) + k1;
  }
  m1 = stable_grail_bin_search_left(A + L1, L2, A + K);
  m2 = m1;
  if (m2 < L2 && (*(*(A + L1 + m2)) - *(*(A + K))) == 0) {
    m2 = stable_grail_bin_search_right(A + L1 + m1, L2 - m1, A + K) + m1;
  }
  if (k1 == k2) {
    stable_grail_rotate(A + k2, L1 - k2, m2);
  } else {
    stable_grail_rotate(A + k1, L1 - k1, m1);
    if (m2 != m1) {
      stable_grail_rotate(A + (k2 + m1), L1 - k2, m2 - m1);
    }
  }
  stable_grail_rec_merge(A + (k2 + m2), L1 - k2, L2 - m2);
  stable_grail_rec_merge(A, k1, m1);
}
```