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

```asm
<sorter_sqrt_sort_build_blocks>:
  endbr64
  push   %r15
  mov    %rdi,%rcx
  mov    $0x1,%eax
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %esi,0x18(%rsp)
  mov    %edx,0x1c(%rsp)
  cmp    $0x1,%esi
  jle    L149
  nopw   0x0(%rax,%rax,1)
L11:
  mov    (%rcx,%rax,8),%rdi
  xor    %esi,%esi
  cmp    %rdi,-0x8(%rcx,%rax,8)
  setg   %sil
  lea    -0x1(%rsi,%rax,1),%edx
  movslq %edx,%rdx
  mov    (%rcx,%rdx,8),%rdx
  mov    %rdx,-0x18(%rcx,%rax,8)
  mov    %eax,%edx
  sub    %esi,%edx
  movslq %edx,%rdx
  mov    (%rcx,%rdx,8),%rdx
  mov    %rdx,-0x10(%rcx,%rax,8)
  add    $0x2,%rax
  cmp    %eax,0x18(%rsp)
  jg     L11
L149:
  testb  $0x1,0x18(%rsp)
  je     L76
  movslq 0x18(%rsp),%rax
  shl    $0x3,%rax
  mov    -0x8(%rcx,%rax,1),%rdx
  mov    %rdx,-0x18(%rcx,%rax,1)
L76:
  lea    -0x10(%rcx),%rax
  cmpl   $0x2,0x1c(%rsp)
  mov    %rax,0x10(%rsp)
  jle    L97
  mov    $0x2,%ebx
  nopl   0x0(%rax)
L29:
  mov    0x18(%rsp),%eax
  mov    %ebx,%r12d
  add    %ebx,%ebx
  sub    %ebx,%eax
  mov    %eax,0xc(%rsp)
  js     L62
  mov    %r12d,%r14d
  movslq %ebx,%rbp
  mov    0x10(%rsp),%r13
  xor    %r15d,%r15d
  neg    %r14d
  shl    $0x3,%rbp
  nopw   0x0(%rax,%rax,1)
L27:
  mov    %r13,%rdi
  mov    %r14d,%ecx
  mov    %r12d,%edx
  mov    %r12d,%esi
  call   <sorter_sqrt_sort_merge_left_with_x_buf@plt>
  add    %ebx,%r15d
  add    %rbp,%r13
  cmp    %r15d,0xc(%rsp)
  jge    L27
  mov    0x18(%rsp),%edx
  sub    %r15d,%edx
L28:
  cmp    %edx,%r12d
  jge    L99
  mov    0x10(%rsp),%rax
  mov    %r12d,%ecx
  movslq %r15d,%r8
  sub    %r12d,%edx
  neg    %ecx
  mov    %r12d,%esi
  lea    (%rax,%r8,8),%rdi
  call   <sorter_sqrt_sort_merge_left_with_x_buf@plt>
L82:
  movslq %r12d,%rsi
L65:
  shl    $0x3,%rsi
  sub    %rsi,0x10(%rsp)
  cmp    0x1c(%rsp),%ebx
  jl     L29
L97:
  mov    0x18(%rsp),%eax
  mov    0x1c(%rsp),%esi
  mov    0x18(%rsp),%r12d
  mov    0x10(%rsp),%rcx
  lea    (%rsi,%rsi,1),%ebp
  cltd
  idiv   %ebp
  sub    %edx,%r12d
  movslq %r12d,%rbx
  lea    (%rcx,%rbx,8),%rdi
  cmp    %edx,%esi
  jl     L47
  movslq %esi,%rax
  shl    $0x3,%edx
  mov    %rdi,%rsi
  add    %rbx,%rax
  lea    (%rcx,%rax,8),%r8
  mov    %r8,%rdi
  call   <memcpy@plt>
L121:
  test   %r12d,%r12d
  jle    L9
  movslq %ebp,%rax
  mov    %ebp,%r13d
  sub    %rax,%rbx
  neg    %r13d
  mov    0x10(%rsp),%rax
  movslq %r13d,%r13
  shl    $0x3,%r13
  lea    (%rax,%rbx,8),%rbx
  nopl   0x0(%rax,%rax,1)
L1:
  mov    0x1c(%rsp),%esi
  mov    %rbx,%rdi
  sub    %ebp,%r12d
  add    %r13,%rbx
  mov    %esi,%ecx
  mov    %esi,%edx
  call   <sorter_sqrt_sort_merge_right@plt>
  test   %r12d,%r12d
  jg     L1
L9:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L99:
  cmp    %r15d,0x18(%rsp)
  jle    L82
  mov    0x18(%rsp),%esi
  mov    0x10(%rsp),%rdi
  movslq %r15d,%rcx
  lea    -0x1(%rsi),%edx
  movslq %r12d,%rsi
  lea    (%rdi,%rcx,8),%rax
  sub    %r15d,%edx
  add    %rcx,%rdx
  mov    %rsi,%rcx
  neg    %rcx
  lea    0x8(%rdi,%rdx,8),%rdi
  shl    $0x3,%rcx
  xchg   %ax,%ax
L105:
  mov    (%rax),%rdx
  add    $0x8,%rax
  mov    %rdx,-0x8(%rax,%rcx,1)
  cmp    %rax,%rdi
  jne    L105
  jmp    L65
  cs nopw 0x0(%rax,%rax,1)
L62:
  mov    0x18(%rsp),%edx
  xor    %r15d,%r15d
  jmp    L28
L47:
  mov    0x1c(%rsp),%esi
  sub    %esi,%edx
  mov    %esi,%ecx
  call   <sorter_sqrt_sort_merge_right@plt>
  jmp    L121
```

assistant: ```c
void sorter_sqrt_sort_build_blocks(int64_t *arr, int L, int K) {
  int m, u, h, p0, p1, rest, restk, p;
  for (m = 1; m < L; m += 2) {
    u = 0;
    if (((*(arr + (m - 1))) - (*(arr + m))) > 0) {
      u = 1;
    }
    arr[m - 3] = arr[m - 1 + u];
    arr[m - 2] = arr[m - u];
  }
  if (L % 2) {
    arr[L - 3] = arr[L - 1];
  }
  arr -= 2;
  for (h = 2; h < K; h *= 2) {
    p0 = 0;
    p1 = L - 2 * h;
    while (p0 <= p1) {
      sorter_sqrt_sort_merge_left_with_x_buf(arr + p0, h, h, -h);
      p0 += 2 * h;
    }
    rest = L - p0;
    if (rest > h) {
      sorter_sqrt_sort_merge_left_with_x_buf(arr + p0, h, rest - h, -h);
    } else {
      for (; p0 < L; p0++) {
        arr[p0 - h] = arr[p0];
      }
    }
    arr -= h;
  }
  restk = L % (2 * K);
  p = L - restk;
  if (restk <= K) {
    memcpy(arr + p + K, arr + p, restk * sizeof(int64_t));
  } else {
    sorter_sqrt_sort_merge_right(arr + p, K, restk - K, K);
  }
  while (p > 0) {
    p -= 2 * K;
    sorter_sqrt_sort_merge_right(arr + p, K, K, K);
  }
}
```