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

```asm
<c_dsortins>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %edi,0x1c(%rsp)
  test   %edi,%edi
  jle    L149
  mov    %rsi,%r13
  mov    %edx,%esi
  ucomisd D4(%rip),%xmm0
  setnp  %al
  mov    $0x0,%edx
  cmovne %edx,%eax
  test   %al,%al
  jne    L149
  mov    %esi,%eax
  neg    %eax
  pxor   %xmm1,%xmm1
  comisd %xmm0,%xmm1
  cmovbe %esi,%eax
  mov    %eax,0x10(%rsp)
  test   %eax,%eax
  js     L114
  mov    0x1c(%rsp),%esi
  lea    -0x1(%rsi),%eax
  mov    0x10(%rsp),%edx
  imul   %edx,%eax
  mov    %eax,%r14d
  cmp    $0x1,%esi
  jle    L149
  cltq
  lea    0x0(%r13,%rax,8),%rax
  mov    %rax,0x20(%rsp)
  mov    %edx,%eax
  neg    %eax
  cltq
  shl    $0x3,%rax
  mov    %rax,0x8(%rsp)
  movslq %edx,%rbp
  lea    0x0(%r13,%rbp,8),%r15
  mov    %edx,0x18(%rsp)
  movl   $0x1,0x14(%rsp)
  mov    %rbp,%rax
  mov    %r14d,%ebp
  mov    %rax,%r14
  jmp    L1
L114:
  mov    $0x1,%eax
  mov    %edi,%ecx
  sub    %edi,%eax
  mov    0x10(%rsp),%edi
  imul   %edi,%eax
  mov    %eax,%esi
  mov    %eax,0x38(%rsp)
  mov    %edi,%eax
  add    %esi,%eax
  mov    %eax,0x20(%rsp)
  cmp    $0x1,%ecx
  jle    L149
  mov    %edi,%eax
  neg    %eax
  cltq
  shl    $0x3,%rax
  mov    %rax,0x8(%rsp)
  movslq %edi,%rbp
  lea    0x0(%r13,%rbp,8),%r15
  movl   $0x1,0x14(%rsp)
  jmp    L18
L145:
  movsd  (%rsp),%xmm1
  movsd  %xmm1,0x0(%r13)
L283:
  addl   $0x1,0x14(%rsp)
  mov    0x14(%rsp),%eax
  cmp    %eax,0x1c(%rsp)
  je     L149
L18:
  mov    0x20(%rsp),%r14d
  movslq %r14d,%rbx
  movsd  0x0(%r13,%rbx,8),%xmm6
  movsd  %xmm6,(%rsp)
  movapd %xmm6,%xmm0
  call   <stdlib_base_is_nan@plt>
  test   %rax,%rax
  je     L310
  test   %r14d,%r14d
  jle    L145
L267:
  movsd  (%r15,%rbx,8),%xmm0
  movsd  %xmm0,0x0(%r13,%rbx,8)
  add    %rbp,%rbx
  test   %ebx,%ebx
  jg     L267
  jmp    L145
L310:
  movsd  (%rsp),%xmm0
  call   <stdlib_base_is_negative_zero@plt>
  mov    %eax,0x18(%rsp)
  mov    0x20(%rsp),%r12d
  sub    0x10(%rsp),%r12d
  mov    0x38(%rsp),%ecx
  cmp    %r12d,%ecx
  jl     L171
  movslq %r12d,%rax
  lea    0x0(%r13,%rax,8),%rbx
  mov    %r15,0x28(%rsp)
  mov    %ecx,%r15d
  mov    %r13,0x30(%rsp)
  jmp    L236
L176:
  mov    %r13,(%r14,%rbp,8)
  sub    0x10(%rsp),%r12d
  add    0x8(%rsp),%rbx
  cmp    %r12d,%r15d
  jl     L97
L236:
  mov    %rbx,%r14
  mov    (%rbx),%r13
  movsd  (%rsp),%xmm5
  movq   %r13,%xmm6
  comisd %xmm6,%xmm5
  jb     L176
  cmpl   $0x0,0x18(%rsp)
  je     L180
  ucomisd %xmm6,%xmm5
  setp   %al
  mov    $0x1,%edi
  cmovne %edi,%eax
  test   %al,%al
  jne    L232
  movq   %r13,%xmm0
  call   <stdlib_base_is_negative_zero@plt>
  test   %eax,%eax
  je     L176
  mov    0x28(%rsp),%r15
  mov    0x30(%rsp),%r13
  jmp    L171
L97:
  mov    0x28(%rsp),%r15
  mov    0x30(%rsp),%r13
L171:
  mov    0x10(%rsp),%edi
  add    %edi,%r12d
  movslq %r12d,%r12
  movsd  (%rsp),%xmm1
  movsd  %xmm1,0x0(%r13,%r12,8)
  add    %edi,0x20(%rsp)
  jmp    L283
L180:
  mov    0x28(%rsp),%r15
  mov    0x30(%rsp),%r13
  jmp    L171
L232:
  mov    0x28(%rsp),%r15
  mov    0x30(%rsp),%r13
  jmp    L171
L378:
  mov    0x20(%rsp),%rax
  movsd  (%rsp),%xmm1
  movsd  %xmm1,(%rax)
L246:
  addl   $0x1,0x14(%rsp)
  mov    0x14(%rsp),%eax
  cmp    %eax,0x1c(%rsp)
  je     L149
L1:
  mov    0x18(%rsp),%r12d
  movslq %r12d,%rbx
  movsd  0x0(%r13,%rbx,8),%xmm7
  movsd  %xmm7,(%rsp)
  movapd %xmm7,%xmm0
  call   <stdlib_base_is_nan@plt>
  test   %rax,%rax
  je     L17
  cmp    %r12d,%ebp
  jle    L378
L387:
  movsd  (%r15,%rbx,8),%xmm0
  movsd  %xmm0,0x0(%r13,%rbx,8)
  add    %r14,%rbx
  cmp    %ebx,%ebp
  jg     L387
  jmp    L378
L17:
  movsd  (%rsp),%xmm0
  call   <stdlib_base_is_negative_zero@plt>
  mov    %eax,%edi
  mov    0x18(%rsp),%r12d
  sub    0x10(%rsp),%r12d
  js     L208
  movslq %r12d,%rax
  lea    0x0(%r13,%rax,8),%rbx
  mov    %ebp,0x28(%rsp)
  mov    %r15,0x30(%rsp)
  mov    %edi,%r15d
  mov    %r13,0x38(%rsp)
  jmp    L317
L64:
  mov    %rbp,0x0(%r13,%r14,8)
  add    0x8(%rsp),%rbx
  sub    0x10(%rsp),%r12d
  js     L38
L317:
  mov    %rbx,%r13
  mov    (%rbx),%rbp
  movsd  (%rsp),%xmm2
  movq   %rbp,%xmm3
  comisd %xmm3,%xmm2
  jb     L64
  test   %r15d,%r15d
  je     L139
  ucomisd %xmm3,%xmm2
  setp   %al
  mov    $0x1,%ecx
  cmovne %ecx,%eax
  test   %al,%al
  jne    L105
  movq   %rbp,%xmm0
  call   <stdlib_base_is_negative_zero@plt>
  test   %eax,%eax
  je     L64
  mov    0x28(%rsp),%ebp
  mov    0x30(%rsp),%r15
  mov    0x38(%rsp),%r13
  jmp    L208
L38:
  mov    0x28(%rsp),%ebp
  mov    0x30(%rsp),%r15
  mov    0x38(%rsp),%r13
L208:
  mov    0x10(%rsp),%edx
  add    %edx,%r12d
  movslq %r12d,%r12
  movsd  (%rsp),%xmm1
  movsd  %xmm1,0x0(%r13,%r12,8)
  add    %edx,0x18(%rsp)
  jmp    L246
L139:
  mov    0x28(%rsp),%ebp
  mov    0x30(%rsp),%r15
  mov    0x38(%rsp),%r13
  jmp    L208
L105:
  mov    0x28(%rsp),%ebp
  mov    0x30(%rsp),%r15
  mov    0x38(%rsp),%r13
  jmp    L208
L149:
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: disassemble_data
arguments: data_label: D4
datatype: f64

tool: D4: 0

assistant: ```c
void c_dsortins(const int64_t N, const double order, double *X, const int64_t stride) {
  int64_t ix;
  int64_t jx;
  int64_t fx;
  int64_t lx;
  int64_t sx;
  int64_t i;
  double v;
  double u;
  bool flg;
  if (N <= 0 || order == 0.0) {
    return;
  }
  if (order < 0.0) {
    sx = -stride;
  } else {
    sx = stride;
  }
  if (sx < 0) {
    fx = (1 - N) * sx;
    lx = 0;
    ix = fx + sx;
    for (i = 1; i < N; i++) {
      v = X[ix];
      if (stdlib_base_is_nan(v)) {
        jx = ix;
        while (jx > lx) {
          X[jx] = X[jx + sx];
          jx += sx;
        }
        X[lx] = v;
      } else {
        flg = stdlib_base_is_negative_zero(v);
        jx = ix - sx;
        while (jx <= fx) {
          u = X[jx];
          if (u <= v && !(flg && u == v && !stdlib_base_is_negative_zero(u))) {
            break;
          }
          X[jx + sx] = u;
          jx -= sx;
        }
        X[jx + sx] = v;
        ix += sx;
      }
    }
    return;
  }
  fx = 0;
  lx = (N - 1) * sx;
  ix = fx + sx;
  for (i = 1; i < N; i++) {
    v = X[ix];
    if (stdlib_base_is_nan(v)) {
      jx = ix;
      while (jx < lx) {
        X[jx] = X[jx + sx];
        jx += sx;
      }
      X[lx] = v;
    } else {
      flg = stdlib_base_is_negative_zero(v);
      jx = ix - sx;
      while (jx >= fx) {
        u = X[jx];
        if (u <= v && !(flg && u == v && !stdlib_base_is_negative_zero(u))) {
          break;
        }
        X[jx + sx] = u;
        jx -= sx;
      }
      X[jx + sx] = v;
      ix += sx;
    }
  }
  return;
}
```