// File: /workspace/github_c_makefile_star2_O3/wuxb45[P]SLB/lib1.c
// Function: thread_fork_join_private
double
thread_fork_join_private(const u64 nr, void *(*func) (void *), void * const * const argv)
{
  if (nr == 0) return 0.0;
  const u64 ncpu = sysconf(_SC_NPROCESSORS_CONF);
  int cores[ncpu];
  size_t xsize = 0;
  cpu_set_t * const set = __cpu_set_alloc(&xsize);

  const bool force_use = (sched_getaffinity(0, xsize, set) != 0) ? true : false;
  u64 j = 0;
  for (u64 i = 0; i < ncpu; i++) {
    if (force_use || CPU_ISSET_S((int)i, xsize, set)) {
      cores[j++] = i;
    }
  }
  const u64 ncores = j;

  const u64 nr_threads = nr ? nr : ncores;
  pthread_t tids[nr_threads];
  pthread_attr_t attr;
  pthread_attr_init(&attr);
  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
  char thname[32];
  const double t0 = time_sec();
  for (u64 i = 0; i < nr_threads; i++) {
    CPU_ZERO_S(xsize, set);
    CPU_SET_S(cores[i % ncores], xsize, set);
    pthread_attr_setaffinity_np(&attr, xsize, set);
    const int r = pthread_create(&(tids[i]), &attr, func, argv[i]);
    if (r != 0) {
      tids[i] = 0;
    } else {
      sprintf(thname, "fork_join_%"PRIu64, i);
      pthread_setname_np(tids[i], thname);
    }
  }
  for (u64 i = 0; i < nr_threads; i++) {
    if (tids[i]) pthread_join(tids[i], NULL);
  }
  const double dt = time_diff_sec(t0);
  pthread_attr_destroy(&attr);
  free(set);
  return dt;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdx, -0x68(%rbp)
movq %rsi, -0x60(%rbp)
testq %rdi, %rdi
je 0x805b
movq %rdi, %r14
movl $0x53, %edi
callq 0x64a0
movq %rax, %r15
movq %rsp, -0x50(%rbp)
movq %rsp, %rcx
leaq 0xf(,%rax,4), %rax
andq $-0x10, %rax
subq %rax, %rcx
movq %rcx, -0x30(%rbp)
movq %rcx, %rsp
movl $0x53, %edi
callq 0x64a0
cltq
addq $0x3f, %rax
shrq $0x3, %rax
andq $-0x8, %rax
cmpq $0x81, %rax
movl $0x80, %r13d
cmovaeq %rax, %r13
movq %r13, %rdi
callq 0x63a0
xorl %ebx, %ebx
xorl %edi, %edi
movq %r13, %rsi
movq %rax, -0x38(%rbp)
movq %rax, %rdx
callq 0x6580
testq %r15, %r15
je 0x7eb6
xorl %ecx, %ecx
movabsq $0x100000000, %rdx      # imm = 0x100000000
xorl %ebx, %ebx
xorl %esi, %esi
movq -0x38(%rbp), %r9
testl %eax, %eax
je 0x7e8a
movq -0x30(%rbp), %rdi
movl %esi, (%rdi,%rbx,4)
incq %rbx
jmp 0x7eab
movq %rcx, %rdi
sarq $0x20, %rdi
movq %rdi, %r8
shrq $0x3, %r8
cmpq %r13, %r8
jae 0x7eab
shrq $0x6, %rdi
movq (%r9,%rdi,8), %rdi
btq %rsi, %rdi
jb 0x7e7e
incq %rsi
addq %rdx, %rcx
cmpq %rsi, %r15
jne 0x7e7a
movq %rbx, -0x58(%rbp)
movq %rsp, %r15
movq %r14, -0x40(%rbp)
leaq 0xf(,%r14,8), %rax
andq $-0x10, %rax
subq %rax, %r15
movq %r15, %rsp
leaq -0xd8(%rbp), %rbx
movq %rbx, %rdi
callq 0x62b0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x6380
leaq -0x90(%rbp), %rbx
movl $0x4, %edi
movq %rbx, %rsi
callq 0x6110
movq -0x38(%rbp), %rdi
imulq $0x3b9aca00, (%rbx), %rax # imm = 0x3B9ACA00
addq 0x8(%rbx), %rax
vcvtusi2sd %rax, %xmm0, %xmm0
vmovsd %xmm0, -0x48(%rbp)
xorl %r14d, %r14d
xorl %r12d, %r12d
xorl %esi, %esi
movq %r13, %rdx
callq 0x6210
movq -0x38(%rbp), %r8
movq %r12, %rax
xorl %edx, %edx
divq -0x58(%rbp)
movq -0x30(%rbp), %rax
movslq (%rax,%rdx,4), %rax
movq %rax, %rcx
shrq $0x3, %rcx
cmpq %r13, %rcx
jae 0x7f5d
movl $0x1, %ecx
shlxq %rax, %rcx, %rcx
shrq $0x6, %rax
orq %rcx, (%r8,%rax,8)
leaq -0xd8(%rbp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
movq %r8, %rdx
callq 0x6080
leaq (%r15,%r14), %rdi
movq -0x68(%rbp), %rax
movq (%rax,%r12,8), %rcx
movq %rbx, %rsi
movq -0x60(%rbp), %rdx
callq 0x6430
testl %eax, %eax
je 0x7f98
movq $0x0, (%r15,%r12,8)
jmp 0x7fbf
leaq -0x90(%rbp), %rbx
movq %rbx, %rdi
leaq 0xc2a7(%rip), %rsi      # 0x14250
movq %r12, %rdx
xorl %eax, %eax
callq 0x6520
movq (%r15,%r12,8), %rdi
movq %rbx, %rsi
callq 0x61d0
incq %r12
addq $0x8, %r14
cmpq %r12, -0x40(%rbp)
movq -0x38(%rbp), %rdi
jne 0x7f20
xorl %ebx, %ebx
movq -0x40(%rbp), %r14
movq (%r15,%rbx,8), %rdi
testq %rdi, %rdi
je 0x7fea
xorl %esi, %esi
callq 0x65a0
incq %rbx
cmpq %rbx, %r14
jne 0x7fda
vmovsd -0x48(%rbp), %xmm0
vdivsd 0xc059(%rip), %xmm0, %xmm0 # 0x14058
vmovsd %xmm0, -0x30(%rbp)
leaq -0xa0(%rbp), %rbx
movl $0x4, %edi
movq %rbx, %rsi
callq 0x6110
imulq $0x3b9aca00, (%rbx), %rax # imm = 0x3B9ACA00
addq 0x8(%rbx), %rax
vcvtusi2sd %rax, %xmm1, %xmm0
vdivsd 0xc027(%rip), %xmm0, %xmm0 # 0x14058
vsubsd -0x30(%rbp), %xmm0, %xmm0
vmovsd %xmm0, -0x30(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x64c0
movq -0x38(%rbp), %rdi
callq 0x6060
vmovsd -0x30(%rbp), %xmm0
movq -0x50(%rbp), %rsp
jmp 0x805f
vxorps %xmm0, %xmm0, %xmm0
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq