user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<rank>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x20,%rsp
  mov    %rdi,%rbp
  mov    %rsi,%r14
  mov    %rdx,%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  mov    %rdi,%r12
  shr    $0x3f,%r12
  add    %rdi,%r12
  sar    %r12
  lea    0x0(,%r12,8),%rdi
  call   <malloc@plt>
  mov    %rax,%r13
  cmp    $0x1,%rbp
  jle    L160
  mov    %rax,%rdx
  mov    $0x0,%eax
L223:
  movq   $0xffffffffffffffff,(%rdx)
  add    $0x1,%rax
  add    $0x8,%rdx
  cmp    %rax,%r12
  jg     L223
  lea    0x10(%rsp),%rcx
  lea    0x8(%rsp),%rdx
  mov    %r14,%rsi
  mov    %rbp,%rdi
  call   <minmax@plt>
  movsd  0x10(%rsp),%xmm0
  movsd  0x8(%rsp),%xmm1
  ucomisd %xmm1,%xmm0
  jp     L117
  je     L91
L117:
  lea    -0x1(%r12),%rax
  pxor   %xmm2,%xmm2
  cvtsi2sd %rax,%xmm2
  subsd  %xmm1,%xmm0
  divsd  %xmm0,%xmm2
  test   %rbp,%rbp
  jle    L205
  mov    $0x0,%ecx
  jmp    L14
L160:
  lea    0x10(%rsp),%rcx
  lea    0x8(%rsp),%rdx
  mov    %r14,%rsi
  mov    %rbp,%rdi
  call   <minmax@plt>
  movsd  0x10(%rsp),%xmm0
  movsd  0x8(%rsp),%xmm1
  ucomisd %xmm1,%xmm0
  jp     L117
  jne    L117
  test   %rbp,%rbp
  jle    L226
L91:
  mov    $0x0,%eax
L82:
  mov    %rax,(%rbx,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%rbp
  jne    L82
  jmp    L226
L56:
  mov    %rcx,(%rdx)
L233:
  mov    %rax,(%rbx,%rsi,8)
  add    $0x1,%rcx
  cmp    %rcx,%rbp
  je     L49
L14:
  mov    %rcx,%rsi
  movsd  (%r14,%rcx,8),%xmm0
  movapd %xmm0,%xmm1
  subsd  0x8(%rsp),%xmm1
  mulsd  %xmm2,%xmm1
  cvttsd2si %xmm1,%rax
  lea    0x0(%r13,%rax,8),%rdx
  mov    (%rdx),%rax
  cmp    $0xffffffffffffffff,%rax
  je     L56
  movsd  (%r14,%rax,8),%xmm1
  comisd %xmm0,%xmm1
  jae    L56
L172:
  lea    (%rbx,%rax,8),%rdx
  mov    (%rdx),%rax
  cmp    $0xffffffffffffffff,%rax
  je     L48
  comisd (%r14,%rax,8),%xmm0
  ja     L172
L48:
  mov    %rcx,(%rdx)
  jmp    L233
L49:
  mov    %r13,%rdi
  mov    $0x0,%esi
  mov    $0x0,%edx
  cmp    $0x1,%rcx
  jle    L89
L86:
  mov    (%rdi),%rax
  cmp    $0xffffffffffffffff,%rax
  je     L83
L44:
  lea    (%rbx,%rax,8),%rcx
  mov    (%rcx),%rax
  add    $0x1,%rdx
  mov    %rdx,(%rcx)
  cmp    $0xffffffffffffffff,%rax
  jne    L44
L83:
  add    $0x1,%rsi
  add    $0x8,%rdi
  cmp    %rsi,%r12
  jg     L86
  test   %rbp,%rbp
  jle    L205
  mov    $0x0,%eax
L29:
  subq   $0x1,(%rbx,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%rbp
  jg     L29
L205:
  mov    %r13,%rdi
  call   <free@plt>
L226:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L15
  add    $0x20,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L89:
  subq   $0x1,(%rbx)
  jmp    L205
L15:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void rank(long nmax, double *x, long *list) {
  long *jptr, nl, n, i, ip, ipp;
  double xmin, xmax, sc, xn;
  nl = nmax / 2;
  jptr = (long *)malloc(nl * sizeof(long));
  for (n = 0; n < nl; n++)
    jptr[n] = (-1);
  minmax(nmax, x, &xmin, &xmax);
  if (xmax == xmin) {
    for (n = 0; n < nmax; n++)
      list[n] = n;
    return;
  }
  sc = (nl - 1) / (xmax - xmin);
  for (n = 0; n < nmax; n++) {
    xn = x[n];
    i = (long)((xn - xmin) * sc);
    ip = jptr[i];
    if ((ip == (-1)) || (xn <= x[ip])) {
      jptr[i] = n;
    } else {
      do {
        ipp = ip;
        ip = list[ip];
      } while ((ip != (-1)) && (xn > x[ip]));
      list[ipp] = n;
    }
    list[n] = ip;
  }
  for (n = 0, i = 0; i < nl; i++) {
    ip = jptr[i];
    while (ip != (-1)) {
      ipp = ip;
      ip = list[ip];
      list[ipp] = ++n;
    }
  }
  for (n = 0; n < nmax; n++)
    list[n] -= 1;
  free(jptr);
}
```