user: Translate the below assembly code into C programming language:

```asm
<rank>:
  endbr64
  push   %r15
  push   %r14
  mov    %rdi,%r14
  shr    $0x3f,%r14
  push   %r13
  add    %rdi,%r14
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  sar    %r14
  mov    %rsi,%rbp
  push   %rbx
  lea    0x0(,%r14,8),%r15
  mov    %rdx,%rbx
  mov    %r15,%rdi
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  call   <malloc@plt>
  mov    %rax,%r13
  cmp    $0x1,%r12
  jle    L244
  mov    %r15,%rdx
  mov    $0xff,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  lea    0x10(%rsp),%rcx
  mov    %rbp,%rsi
  mov    %r12,%rdi
  lea    0x8(%rsp),%rdx
  call   <minmax@plt>
  movsd  0x10(%rsp),%xmm0
  movsd  0x8(%rsp),%xmm2
  ucomisd %xmm2,%xmm0
  jp     L181
  je     L124
L181:
  lea    -0x1(%r14),%rax
  pxor   %xmm3,%xmm3
  subsd  %xmm2,%xmm0
  cvtsi2sd %rax,%xmm3
  divsd  %xmm0,%xmm3
L167:
  xor    %edx,%edx
  jmp    L2
  nopl   0x0(%rax,%rax,1)
L70:
  mov    %rdx,(%rcx)
  mov    %rax,(%rbx,%rdx,8)
  add    $0x1,%rdx
  cmp    %rdx,%r12
  je     L127
L2:
  movsd  0x0(%rbp,%rdx,8),%xmm0
  movapd %xmm0,%xmm1
  subsd  %xmm2,%xmm1
  mulsd  %xmm3,%xmm1
  cvttsd2si %xmm1,%rax
  lea    0x0(%r13,%rax,8),%rcx
  mov    (%rcx),%rax
  cmp    $0xffffffffffffffff,%rax
  je     L70
  movsd  0x0(%rbp,%rax,8),%xmm1
  comisd %xmm0,%xmm1
  jb     L207
  mov    %rdx,(%rcx)
  mov    %rax,(%rbx,%rdx,8)
  add    $0x1,%rdx
  cmp    %rdx,%r12
  jne    L2
L127:
  mov    %r13,%rdi
  xor    %esi,%esi
  xor    %edx,%edx
  cmp    $0x1,%r12
  je     L130
  cs nopw 0x0(%rax,%rax,1)
L176:
  mov    (%rdi),%rax
  cmp    $0xffffffffffffffff,%rax
  je     L144
  nopl   0x0(%rax)
L206:
  lea    (%rbx,%rax,8),%rcx
  add    $0x1,%rdx
  mov    (%rcx),%rax
  mov    %rdx,(%rcx)
  cmp    $0xffffffffffffffff,%rax
  jne    L206
L144:
  add    $0x1,%rsi
  add    $0x8,%rdi
  cmp    %rsi,%r14
  jg     L176
  xor    %eax,%eax
  nopl   0x0(%rax,%rax,1)
L193:
  subq   $0x1,(%rbx,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%r12
  jg     L193
L101:
  mov    %r13,%rdi
  call   <free@plt>
L182:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L152
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L100:
  comisd 0x0(%rbp,%rax,8),%xmm0
  jbe    L70
L207:
  lea    (%rbx,%rax,8),%rcx
  mov    (%rcx),%rax
  cmp    $0xffffffffffffffff,%rax
  jne    L100
  jmp    L70
L244:
  lea    0x10(%rsp),%rcx
  lea    0x8(%rsp),%rdx
  mov    %rbp,%rsi
  mov    %r12,%rdi
  call   <minmax@plt>
  movsd  0x10(%rsp),%xmm0
  movsd  0x8(%rsp),%xmm2
  ucomisd %xmm2,%xmm0
  jp     L67
  je     L163
L67:
  lea    -0x1(%r14),%rax
  pxor   %xmm3,%xmm3
  subsd  %xmm2,%xmm0
  cvtsi2sd %rax,%xmm3
  divsd  %xmm0,%xmm3
  test   %r12,%r12
  jle    L101
  jmp    L167
  nopw   0x0(%rax,%rax,1)
L163:
  cmp    $0x1,%r12
  jne    L182
L124:
  xor    %eax,%eax
  nopl   0x0(%rax)
L236:
  mov    %rax,(%rbx,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%r12
  jne    L236
  jmp    L182
L130:
  subq   $0x1,(%rbx)
  jmp    L101
L152:
  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);
}
```