user: Please show me the C implementation that matches the assembly code listed below:

```asm
<mc64ed_>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%r11
  mov    %rdx,%rbx
  sub    $0x4,%r8
  lea    -0x8(%rcx),%r10
  lea    -0x4(%rdx),%rcx
  mov    (%rdi),%eax
  movslq %eax,%rdx
  mov    (%rcx,%rdx,4),%r12d
  movslq %r12d,%rbp
  movsd  (%r10,%rbp,8),%xmm1
  sub    $0x1,%eax
  mov    %eax,(%rdi)
  mov    (%r9),%eax
  cmp    $0x1,%eax
  je     L139
  mov    (%rsi),%r9d
  test   %r9d,%r9d
  jle    L73
  mov    $0x1,%edi
  mov    $0x1,%eax
  jmp    L25
L139:
  mov    (%rsi),%r9d
  test   %r9d,%r9d
  jle    L124
  mov    %eax,%edi
  jmp    L26
L52:
  comisd %xmm0,%xmm1
  jae    L124
  movslq %edx,%rsi
  mov    (%rcx,%rsi,4),%esi
  movslq %eax,%r13
  mov    %esi,(%rcx,%r13,4)
  movslq %esi,%rsi
  mov    %eax,(%r8,%rsi,4)
  add    $0x1,%edi
  cmp    %edi,%r9d
  jl     L1
  mov    %edx,%eax
L26:
  lea    (%rax,%rax,1),%edx
  mov    (%r11),%esi
  cmp    %edx,%esi
  jl     L124
  movslq %edx,%r13
  movslq (%rcx,%r13,4),%r14
  movsd  (%r10,%r14,8),%xmm0
  jle    L52
  movslq (%rbx,%r13,4),%rsi
  movsd  (%r10,%rsi,8),%xmm2
  comisd %xmm0,%xmm2
  jbe    L52
  add    $0x1,%edx
  movapd %xmm2,%xmm0
  jmp    L52
L1:
  mov    %edx,%eax
  jmp    L124
L7:
  comisd %xmm1,%xmm0
  jae    L124
  movslq %edx,%rsi
  mov    (%rcx,%rsi,4),%esi
  movslq %eax,%r13
  mov    %esi,(%rcx,%r13,4)
  movslq %esi,%rsi
  mov    %eax,(%r8,%rsi,4)
  add    $0x1,%edi
  cmp    %edi,%r9d
  jl     L30
  mov    %edx,%eax
L25:
  lea    (%rax,%rax,1),%edx
  mov    (%r11),%esi
  cmp    %edx,%esi
  jl     L124
  movslq %edx,%r13
  movslq (%rcx,%r13,4),%r14
  movsd  (%r10,%r14,8),%xmm0
  jle    L7
  movslq (%rbx,%r13,4),%rsi
  movsd  (%r10,%rsi,8),%xmm2
  comisd %xmm2,%xmm0
  jbe    L7
  add    $0x1,%edx
  movapd %xmm2,%xmm0
  jmp    L7
L30:
  mov    %edx,%eax
L124:
  movslq %eax,%rdx
  mov    %r12d,(%rcx,%rdx,4)
  mov    %eax,(%r8,%rbp,4)
  mov    $0x0,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L73:
  mov    $0x1,%eax
  jmp    L124
```

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;
}
```