// File: /workspace/github_cpp_makefile_star2_O3/FreeSlave[P]vhlt/common/threads.cpp
// Function: RunThreadsOn(int, bool, void (*)(int))
void            RunThreadsOn(int workcnt, bool showpacifier, q_threadfunction func)
{
    intptr_t        i;
    pthread_t       work_threads[MAX_THREADS];
    pthread_addr_t  status;
    pthread_attr_t  attrib;
    double          start, end;

    threadstart = I_FloatTime();
    start = threadstart;
    for (i = 0; i < THREADTIMES_SIZE; i++)
    {
        threadtimes[i] = 0;
    }

    dispatch = 0;
    workcount = workcnt;
    oldf = -1;
    pacifier = showpacifier;
    threaded = true;
    q_entry = func;

    if (pacifier)
    {
        setbuf(stdout, NULL);
    }

    threads_InitCrit();

    if (pthread_attr_init(&attrib) == -1)
    {
        Error("pthread_attr_init failed");
    }
#ifdef _POSIX_THREAD_ATTR_STACKSIZE
    if (pthread_attr_setstacksize(&attrib, 0x400000) == -1)
    {
        Error("pthread_attr_setstacksize failed");
    }
#endif

    for (i = 0; i < g_numthreads; i++)
    {
        if (pthread_create(&work_threads[i], &attrib, ThreadEntryStub, (void*)i) == -1)
        {
            Error("pthread_create failed");
        }
    }

    for (i = 0; i < g_numthreads; i++)
    {
        if (pthread_join(work_threads[i], &status) == -1)
        {
            Error("pthread_join failed");
        }
    }

    threads_UninitCrit();

    q_entry = NULL;
    threaded = false;

    end = I_FloatTime();
    if (pacifier)
    {
#ifdef ZHLT_CONSOLE
		PrintConsole
#else
        printf
#endif
			("\r%60s\r", "");
    }

    Log(" (%.2f seconds)\n", end - start);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movq %rdx, %rbx
movl %esi, %ebp
movl %edi, %r14d
callq 0x8478
movsd %xmm0, 0x8(%rsp)
leaq 0x20c103f(%rip), %rdi   # 0x20cc5f0
movl $0x320, %edx            # imm = 0x320
xorl %esi, %esi
callq 0x41c0
movl $0x0, 0x20c1011(%rip)   # 0x20cc5d8
movl %r14d, 0x20c1012(%rip)  # 0x20cc5e0
movl $0xffffffff, 0x20c1004(%rip) # imm = 0xFFFFFFFF
movb %bpl, 0x20c1005(%rip)   # 0x20cc5e4
movq %rbx, 0x20c133a(%rip)   # 0x20cc920
testl %ebp, %ebp
je 0xb5fb
movq 0x1c99f(%rip), %rax     # 0x27f90
movq (%rax), %rdi
xorl %esi, %esi
callq 0x4450
callq 0xb851
leaq 0x18(%rsp), %rdi
callq 0x43b0
cmpl $-0x1, %eax
jne 0xb61d
leaq 0x13beb(%rip), %rdi     # 0x1f201
xorl %eax, %eax
callq 0xa164
leaq 0x18(%rsp), %rdi
movl $0x400000, %esi         # imm = 0x400000
callq 0x4430
cmpl $-0x1, %eax
jne 0xb63f
leaq 0x13be2(%rip), %rdi     # 0x1f21a
xorl %eax, %eax
callq 0xa164
cmpl $0x0, 0x1dd0e(%rip)     # 0x29354
jle 0xb6d8
leaq 0x50(%rsp), %rbx
leaq 0x276(%rip), %r14       # 0xb8ce
leaq 0x18(%rsp), %r15
leaq 0x13bd7(%rip), %r12     # 0x1f23b
xorl %r13d, %r13d
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %r13, %rcx
callq 0x4590
cmpl $-0x1, %eax
jne 0xb687
movq %r12, %rdi
xorl %eax, %eax
callq 0xa164
incq %r13
movslq 0x1dcc3(%rip), %rax     # 0x29354
addq $0x8, %rbx
cmpq %rax, %r13
jl 0xb667
testl %eax, %eax
jle 0xb6d8
leaq 0x10(%rsp), %rbx
leaq 0x13ba7(%rip), %r14     # 0x1f251
xorl %r15d, %r15d
movq 0x50(%rsp,%r15,8), %rdi
movq %rbx, %rsi
callq 0x4290
cmpl $-0x1, %eax
jne 0xb6c9
movq %r14, %rdi
xorl %eax, %eax
callq 0xa164
incq %r15
movslq 0x1dc81(%rip), %rax     # 0x29354
cmpq %rax, %r15
jl 0xb6ad
movq 0x20c1239(%rip), %rdi   # 0x20cc918
callq 0x4979
xorl %eax, %eax
movq %rax, 0x20c122b(%rip)   # 0x20cc918
movq %rax, 0x20c122c(%rip)   # 0x20cc920
callq 0x8478
cmpb $0x1, 0x20c0ee4(%rip)   # 0x20cc5e4
jne 0xb721
leaq 0x13b5c(%rip), %rdi     # 0x1f265
leaq 0x12599(%rip), %rsi     # 0x1dca9
xorl %eax, %eax
movsd %xmm0, (%rsp)
callq 0xaa78
movsd (%rsp), %xmm0
subsd 0x8(%rsp), %xmm0
leaq 0x13b3e(%rip), %rdi     # 0x1f26c
movb $0x1, %al
callq 0x9e76
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq