// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: qsort_double_sample
void
qsort_double_sample(const double * const array0, const u64 nr, const u64 res, FILE * const out)
{
  const u64 datasize = nr * sizeof(double);
  double * const array = (typeof(array))malloc(datasize);
  debug_assert(array);
  memcpy(array, array0, datasize);
  qsort_double(array, nr);

  const u64 srate = res ? res : 64;
  const double srate_d = (double)srate;
  const u64 sized = (double)nr;
  const u64 xstep = ({u64 step = nr / srate; step ? step : 1; });
  const double ystep = ({ double step = fabs((array[nr - 1] - array[0]) / srate_d); step ? step : 1.0; });
  u64 i = 0;
  fprintf(out, "%lu %06.2lf %020.9lf\n", i, ((double)(i + 1lu)) * 100.0 / sized, array[i]);
  for (u64 j = 1; j < nr; j++) {
    if (((j - i) >= xstep) || (array[j] - array[i]) >= ystep) {
      i = j;
      fprintf(out, "%lu %06.2lf %020.9lf\n", i, ((double)(i + 1lu)) * 100.0 / sized, array[i]);
    }
  }
  if (i != (nr - 1)) {
    i = nr - 1;
    fprintf(out, "%lu %06.2lf %020.9lf\n", i, ((double)(i + 1lu)) * 100.0 / sized, array[i]);
  }
  free(array);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, -0x30(%rbp)
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %r15
leaq (,%rsi,8), %r13
movq %r13, %rdi
callq 0x63a0
movq %rax, %rbx
testq %rax, %rax
je 0x8ee3
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x6340
leaq -0x208(%rip), %rcx      # 0x8b4d
movl $0x8, %edx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x60d0
testq %r14, %r14
movl $0x40, %ecx
cmovneq %r14, %rcx
vcvtusi2sd %r12, %xmm0, %xmm0
movq %r12, %rax
xorl %edx, %edx
divq %rcx
movq %rax, %r13
vmovsd %xmm0, -0x68(%rbp)
vcvttsd2usi %xmm0, %rax
xorl %r15d, %r15d
movq %rcx, -0x50(%rbp)
cmpq %r12, %rcx
movl $0x1, %r14d
cmovaq %r14, %r13
vmovsd -0x8(%rbx,%r12,8), %xmm0
vmovsd %xmm0, -0x60(%rbp)
vmovsd (%rbx), %xmm1
leaq -0x1(%r12), %rcx
movq %rcx, -0x70(%rbp)
vcvtusi2sd %rax, %xmm2, %xmm0
vmovsd 0xb2a0(%rip), %xmm2     # 0x14068
vmovsd %xmm0, -0x38(%rbp)
vdivsd %xmm0, %xmm2, %xmm0
leaq 0xb497(%rip), %rsi      # 0x1426f
movq -0x30(%rbp), %rdi
xorl %edx, %edx
vmovsd %xmm1, -0x58(%rbp)
movb $0x2, %al
callq 0x6300
cmpq $0x2, %r12
movq %r12, %rcx
jb 0x8e9a
vcvtusi2sdq -0x50(%rbp), %xmm3, %xmm0
vmovsd -0x60(%rbp), %xmm1
vsubsd -0x58(%rbp), %xmm1, %xmm1
vdivsd %xmm0, %xmm1, %xmm0
vandpd 0xb25a(%rip){1to2}, %xmm0, %xmm1 # 0x14070
vxorpd %xmm2, %xmm2, %xmm2
vcmpneqsd %xmm2, %xmm0, %k1
vmovsd 0xb24f(%rip), %xmm0     # 0x14078
vmovsd %xmm1, %xmm0, %xmm0 {%k1}
vmovapd %xmm0, -0x50(%rbp)
xorl %r15d, %r15d
movq %r14, %rax
subq %r15, %rax
vmovsd (%rbx,%r14,8), %xmm1
cmpq %r13, %rax
jae 0x8e5d
vsubsd (%rbx,%r15,8), %xmm1, %xmm0
vucomisd -0x50(%rbp), %xmm0
jae 0x8e5d
incq %r14
movq %r14, %r12
jmp 0x8e95
leaq 0x1(%r14), %r12
vcvtusi2sd %r12, %xmm3, %xmm0
vmulsd 0xb1f9(%rip), %xmm0, %xmm0 # 0x14068
vdivsd -0x38(%rbp), %xmm0, %xmm0
movq -0x30(%rbp), %rdi
movq %rcx, %r15
leaq 0xb3ed(%rip), %rsi      # 0x1426f
movq %r14, %rdx
movb $0x2, %al
callq 0x6300
movq %r15, %rcx
movq %r14, %r15
movq %r12, %r14
cmpq %rcx, %r12
jne 0x8e37
movq -0x70(%rbp), %rdx
cmpq %rdx, %r15
je 0x8ecd
vmovsd -0x68(%rbp), %xmm0
vmulsd 0xb1b8(%rip), %xmm0, %xmm0 # 0x14068
vdivsd -0x38(%rbp), %xmm0, %xmm0
vmovsd -0x8(%rbx,%rcx,8), %xmm1
leaq 0xb3ad(%rip), %rsi      # 0x1426f
movq -0x30(%rbp), %rdi
movb $0x2, %al
callq 0x6300
movq %rbx, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6060
callq 0x66ef
jmp 0x8d40