// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/htslib/cram/thread_pool.c
// Function: t_pool_destroy
void t_pool_destroy(t_pool *p, int kill) {
    int i;
    
#ifdef DEBUG
    fprintf(stderr, "Destroying pool %p, kill=%d\n", p, kill);
#endif

    /* Send shutdown message to worker threads */
    if (!kill) {
	pthread_mutex_lock(&p->pool_m);
	p->shutdown = 1;

#ifdef DEBUG
	fprintf(stderr, "Sending shutdown request\n");
#endif

#ifdef IN_ORDER
	for (i = 0; i < p->tsize; i++)
	    pthread_cond_signal(&p->t[i].pending_c);
#else
	pthread_cond_broadcast(&p->pending_c);
#endif
	pthread_mutex_unlock(&p->pool_m);

#ifdef DEBUG
	fprintf(stderr, "Shutdown complete\n");
#endif
	for (i = 0; i < p->tsize; i++)
	    pthread_join(p->t[i].tid, NULL);
    } else {
	for (i = 0; i < p->tsize; i++)
	    pthread_kill(p->t[i].tid, SIGINT);
    }

    pthread_mutex_destroy(&p->pool_m);
    pthread_cond_destroy(&p->empty_c);
    pthread_cond_destroy(&p->full_c);
#ifdef IN_ORDER
    for (i = 0; i < p->tsize; i++)
	pthread_cond_destroy(&p->t[i].pending_c);
#else
    pthread_cond_destroy(&p->pending_c);
#endif

#ifdef DEBUG_TIME
    fprintf(stderr, "Total time=%f\n", p->total_time / 1000000.0);
    fprintf(stderr, "Wait  time=%f\n", p->wait_time  / 1000000.0);
    fprintf(stderr, "%d%% utilisation\n",
	    (int)(100 - ((100.0 * p->wait_time) / p->total_time + 0.5)));
    for (i = 0; i < p->tsize; i++)
	fprintf(stderr, "%d: Wait time=%f\n", i,
		p->t[i].wait_time / 1000000.0);
#endif

    if (p->t_stack)
	free(p->t_stack);

    free(p->t);
    free(p);

#ifdef DEBUG
    fprintf(stderr, "Destroyed pool %p\n", p);
#endif
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
jne 0x98f98
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x6ae0
movq -0x8(%rbp), %rax
movl $0x1, 0xc(%rax)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x20(%rcx), %eax
jge 0x98f4b
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdi
movslq -0x10(%rbp), %rax
imulq $0x50, %rax, %rax
addq %rax, %rdi
addq $0x18, %rdi
callq 0x6040
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x98f18
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x64e0
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x20(%rcx), %eax
jge 0x98f96
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x10(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x6610
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x98f5f
jmp 0x98fd9
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x20(%rcx), %eax
jge 0x98fd7
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x10(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
movl $0x2, %esi
callq 0x6980
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x98f9f
jmp 0x98fd9
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
callq 0x6840
movq -0x8(%rbp), %rdi
addq $0x58, %rdi
callq 0x6e70
movq -0x8(%rbp), %rdi
addq $0xb8, %rdi
callq 0x6e70
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x20(%rcx), %eax
jge 0x9903d
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdi
movslq -0x10(%rbp), %rax
imulq $0x50, %rax, %rax
addq %rax, %rdi
addq $0x18, %rdi
callq 0x6e70
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x9900a
movq -0x8(%rbp), %rax
cmpq $0x0, 0xe8(%rax)
je 0x9905b
movq -0x8(%rbp), %rax
movq 0xe8(%rax), %rdi
callq 0x6880
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x6880
movq -0x8(%rbp), %rdi
callq 0x6880
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)