// File: /workspace/github_c_makefile_star2_O0/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
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x861c
vpxor %xmm0, %xmm0, %xmm0
vmovsd %xmm0, -0x8(%rbp)
jmp 0x89df
movl $0x53, %edi
callq 0x6470
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rsp, %rcx
movq %rcx, -0x30(%rbp)
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x120(%rbp)
movq %rcx, %rsp
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x82c0
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rdx
xorl %edi, %edi
callq 0x6550
movl %eax, %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, -0x49(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x8754
testb $0x1, -0x49(%rbp)
jne 0x8722
movq -0x60(%rbp), %rax
cltq
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
shrq $0x3, %rax
cmpq -0x40(%rbp), %rax
jae 0x8709
movq -0x48(%rbp), %rax
movq -0x68(%rbp), %rcx
shrq $0x6, %rcx
movq (%rax,%rcx,8), %rax
movq -0x68(%rbp), %rcx
andq $0x3f, %rcx
movl $0x1, %edx
shlq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x124(%rbp)
jmp 0x8713
xorl %eax, %eax
movl %eax, -0x124(%rbp)
jmp 0x8713
movl -0x124(%rbp), %eax
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x6c(%rbp)
je 0x8741
movq -0x120(%rbp), %rax
movq -0x60(%rbp), %rcx
movl %ecx, %edx
movq -0x58(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x58(%rbp)
movl %edx, (%rax,%rcx,4)
jmp 0x8743
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x86a3
movq -0x58(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x8770
movq -0x10(%rbp), %rax
movq %rax, -0x130(%rbp)
jmp 0x877b
movq -0x78(%rbp), %rax
movq %rax, -0x130(%rbp)
movq -0x130(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
leaq 0xf(,%rax,8), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x138(%rbp)
movq %rcx, %rsp
movq %rax, -0x88(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x6290
leaq -0xc0(%rbp), %rdi
xorl %esi, %esi
callq 0x6360
callq 0x72d0
vmovsd %xmm0, -0xe8(%rbp)
movq $0x0, -0xf0(%rbp)
movq -0xf0(%rbp), %rax
cmpq -0x80(%rbp), %rax
jae 0x8943
jmp 0x87f2
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rdx
xorl %esi, %esi
callq 0x6200
jmp 0x8803
movq -0xf0(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
divq -0x78(%rbp)
movq -0x120(%rbp), %rax
movslq (%rax,%rdx,4), %rax
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
shrq $0x3, %rax
cmpq -0x40(%rbp), %rax
jae 0x8868
movq -0xf8(%rbp), %rcx
andq $0x3f, %rcx
movl $0x1, %eax
shlq %cl, %rax
movq -0x48(%rbp), %rcx
movq -0xf8(%rbp), %rdx
shrq $0x6, %rdx
orq (%rcx,%rdx,8), %rax
movq %rax, (%rcx,%rdx,8)
movq %rax, -0x140(%rbp)
jmp 0x8873
xorl %eax, %eax
movq %rax, -0x140(%rbp)
jmp 0x8873
movq -0x140(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rdx
leaq -0xc0(%rbp), %rdi
callq 0x6080
movq -0x138(%rbp), %rdi
movq -0xf0(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rax
movq -0xf0(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
leaq -0xc0(%rbp), %rsi
callq 0x6400
movl %eax, -0x104(%rbp)
cmpl $0x0, -0x104(%rbp)
je 0x88f0
movq -0x138(%rbp), %rax
movq -0xf0(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
jmp 0x892a
leaq -0xe0(%rbp), %rdi
movq -0xf0(%rbp), %rdx
leaq 0x12973(%rip), %rsi     # 0x1b278
movb $0x0, %al
callq 0x64f0
movq -0x138(%rbp), %rax
movq -0xf0(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x61d0
jmp 0x892c
movq -0xf0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xf0(%rbp)
jmp 0x87df
movq $0x0, -0x110(%rbp)
movq -0x110(%rbp), %rax
cmpq -0x80(%rbp), %rax
jae 0x89a1
movq -0x138(%rbp), %rax
movq -0x110(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x898b
movq -0x138(%rbp), %rax
movq -0x110(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x6570
jmp 0x898d
movq -0x110(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x110(%rbp)
jmp 0x894e
vmovsd -0xe8(%rbp), %xmm0
callq 0x7320
vmovsd %xmm0, -0x118(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x6490
movq -0x48(%rbp), %rdi
callq 0x6060
vmovsd -0x118(%rbp), %xmm0
vmovsd %xmm0, -0x8(%rbp)
movq -0x30(%rbp), %rax
movq %rax, %rsp
vmovsd -0x8(%rbp), %xmm0
movq %rbp, %rsp
popq %rbp
retq
nopl (%rax)