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

```asm
<mc64ed_>:
  endbr64
  mov    %rdi,%r10
  mov    %rsi,%rdi
  lea    -0x4(%rdx),%rsi
  push   %r14
  movslq (%r10),%rax
  push   %r13
  lea    -0x8(%rcx),%r11
  sub    $0x4,%r8
  push   %r12
  mov    %rax,%rcx
  push   %rbp
  push   %rbx
  movslq (%rsi,%rax,4),%rbp
  sub    $0x1,%ecx
  mov    %rdx,%rbx
  movsd  (%r11,%rbp,8),%xmm1
  mov    %ecx,(%r10)
  mov    %rbp,%r12
  mov    (%r9),%eax
  mov    (%rdi),%r13d
  cmp    $0x1,%eax
  je     L75
  test   %r13d,%r13d
  jle    L137
  mov    $0x1,%r9d
  mov    $0x1,%eax
  jmp    L85
  nop
L141:
  movslq %edx,%rdi
  movslq (%rsi,%rdi,4),%r14
  movsd  (%r11,%r14,8),%xmm0
  jle    L20
  movslq (%rbx,%rdi,4),%rcx
  movsd  (%r11,%rcx,8),%xmm2
  comisd %xmm2,%xmm0
  jbe    L20
  add    $0x1,%edx
  movapd %xmm2,%xmm0
L20:
  comisd %xmm1,%xmm0
  movslq %eax,%rcx
  lea    (%rsi,%rcx,4),%rdi
  jae    L84
  movslq %edx,%rcx
  add    $0x1,%r9d
  lea    (%rsi,%rcx,4),%r14
  movslq (%r14),%rcx
  mov    %ecx,(%rdi)
  mov    %eax,(%r8,%rcx,4)
  cmp    %r9d,%r13d
  jl     L64
  mov    (%r10),%ecx
  mov    %edx,%eax
L85:
  lea    (%rax,%rax,1),%edx
  cmp    %edx,%ecx
  jge    L141
  movslq %eax,%rdx
  lea    (%rsi,%rdx,4),%rdi
L84:
  mov    %r12d,(%rdi)
  mov    %eax,(%r8,%rbp,4)
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   (%rax)
L75:
  test   %r13d,%r13d
  jle    L17
  mov    $0x1,%r9d
  jmp    L146
  nopl   0x0(%rax)
L189:
  movslq %edx,%rdi
  movslq (%rsi,%rdi,4),%r14
  movsd  (%r11,%r14,8),%xmm0
  jle    L116
  movslq (%rbx,%rdi,4),%rcx
  movsd  (%r11,%rcx,8),%xmm2
  comisd %xmm0,%xmm2
  jbe    L116
  add    $0x1,%edx
  movapd %xmm2,%xmm0
L116:
  comisd %xmm0,%xmm1
  movslq %eax,%rcx
  lea    (%rsi,%rcx,4),%rdi
  jae    L84
  movslq %edx,%rcx
  add    $0x1,%r9d
  lea    (%rsi,%rcx,4),%r14
  movslq (%r14),%rcx
  mov    %ecx,(%rdi)
  mov    %eax,(%r8,%rcx,4)
  cmp    %r9d,%r13d
  jl     L64
  mov    (%r10),%ecx
  mov    %edx,%eax
L146:
  lea    (%rax,%rax,1),%edx
  cmp    %edx,%ecx
  jge    L189
  movslq %eax,%rdx
  lea    (%rsi,%rdx,4),%rdi
  jmp    L84
  nopl   0x0(%rax)
L64:
  mov    %r14,%rdi
  mov    %edx,%eax
  jmp    L84
L137:
  mov    %rdx,%rdi
  mov    $0x1,%eax
  jmp    L84
L17:
  mov    %rdx,%rdi
  jmp    L84
```

assistant: ```c
int mc64ed_(int *qlen, int *n, int *q, double *d__, int *l, int *iway) {
  int i__1;
  int i__;
  double di, dk, dr;
  int pos, idum, posk;
  --l;
  --d__;
  --q;
  i__ = q[*qlen];
  di = d__[i__];
  --(*qlen);
  pos = 1;
  if (*iway == 1) {
    i__1 = *n;
    for (idum = 1; idum <= i__1; ++idum) {
      posk = pos << 1;
      if (posk > *qlen) {
        goto L20;
      }
      dk = d__[q[posk]];
      if (posk < *qlen) {
        dr = d__[q[posk + 1]];
        if (dk < dr) {
          ++posk;
          dk = dr;
        }
      }
      if (di >= dk) {
        goto L20;
      }
      q[pos] = q[posk];
      l[q[pos]] = pos;
      pos = posk;
    }
  } else {
    i__1 = *n;
    for (idum = 1; idum <= i__1; ++idum) {
      posk = pos << 1;
      if (posk > *qlen) {
        goto L20;
      }
      dk = d__[q[posk]];
      if (posk < *qlen) {
        dr = d__[q[posk + 1]];
        if (dk > dr) {
          ++posk;
          dk = dr;
        }
      }
      if (di <= dk) {
        goto L20;
      }
      q[pos] = q[posk];
      l[q[pos]] = pos;
      pos = posk;
    }
  }
L20:
  q[pos] = i__;
  l[i__] = pos;
  return 0;
}
```