// File: /workspace/github_c_makefile_star2_O1/deplinenoise[P]tundra/src/BuildQueue.cpp
// Function: t2::BuildQueueDestroy(t2::BuildQueue*)
void BuildQueueDestroy(BuildQueue* queue)
  {
    ProfilerScope prof_scope("Tundra BuildQueueDestroy", 0);
    Log(kDebug, "destroying build queue");
    const BuildQueueConfig* config = &queue->m_Config;

    MutexLock(&queue->m_Lock);
    queue->m_QuitSignalled = true;
    MutexUnlock(&queue->m_Lock);

    CondBroadcast(&queue->m_WorkAvailable);

    for (int i = 0, thread_count = config->m_ThreadCount; i < thread_count; ++i)
    {
      if (i > 0)
      {
        Log(kDebug, "joining with build thread %d", i);
        ThreadJoin(queue->m_Threads[i]);
      }

      ThreadStateDestroy(&queue->m_ThreadState[i]);
    }

    // Deallocate storage.
    MemAllocHeap* heap = queue->m_Config.m_Heap;
    HeapFree(heap, queue->m_ExpensiveWaitList);
    HeapFree(heap, queue->m_Queue);

    CondDestroy(&queue->m_WorkAvailable);
    MutexDestroy(&queue->m_Lock);

    HeapFree(config->m_Heap, queue->m_ThreadState);
    HeapFree(config->m_Heap, queue->m_Threads);

    // Unblock all signals on the main thread.
    SignalHandlerSetCondition(nullptr);
    SignalBlockThread(false);
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl $0x0, 0xc(%rsp)
leaq 0x1904d(%rip), %rax     # 0x1d680
cmpb $0x1, (%rax)
jne 0x4646
leaq 0x1139c(%rip), %rdi     # 0x159db
xorl %esi, %esi
callq 0xfb72
leaq 0x113a7(%rip), %rsi     # 0x159f4
movl $0x8, %edi
xorl %eax, %eax
callq 0x5ef0
movq %rbx, %rdi
callq 0x34b0
testl %eax, %eax
jne 0x4784
movb $0x1, 0x118(%rbx)
movq %rbx, %rdi
callq 0x3250
testl %eax, %eax
jne 0x478d
leaq 0x28(%rbx), %r14
movq %r14, %rdi
callq 0x3110
testl %eax, %eax
jne 0x4796
movq %r14, 0x10(%rsp)
movslq 0x80(%rbx), %r13
testq %r13, %r13
jle 0x4704
movl $0x8, %ebp
leaq 0x1135a(%rip), %r15     # 0x15a0b
xorl %r12d, %r12d
testq %r12, %r12
je 0x46db
movl $0x8, %edi
movq %r15, %rsi
movl %r12d, %edx
xorl %eax, %eax
callq 0x5ef0
movq 0xf8(%rbx), %rax
movq (%rax,%r12,8), %rdi
callq 0x1270a
movq 0x100(%rbx), %r14
leaq (%r14,%rbp), %rdi
callq 0xf012
leaq (%r14,%rbp), %rdi
addq $-0x8, %rdi
callq 0xef61
incq %r12
addq $0x50, %rbp
cmpq %r12, %r13
jne 0x46b4
movq 0x78(%rbx), %r15
movq 0x110(%rbx), %rsi
movq %r15, %rdi
callq 0xef6a
movq 0x58(%rbx), %rsi
movq %r15, %rdi
callq 0xef6a
movq 0x10(%rsp), %rdi
callq 0x3640
testl %eax, %eax
jne 0x47a4
movq %rbx, %rdi
callq 0x33b0
testl %eax, %eax
jne 0x47ad
movq 0x78(%rbx), %rdi
movq 0x100(%rbx), %rsi
callq 0xef6a
movq 0x78(%rbx), %rdi
movq 0xf8(%rbx), %rsi
callq 0xef6a
xorl %edi, %edi
callq 0x11c29
xorl %edi, %edi
callq 0x11c6d
leaq 0xc(%rsp), %rdi
callq 0x5b82
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x112e9(%rip), %rdi     # 0x15a74
jmp 0x479d
leaq 0x112fc(%rip), %rdi     # 0x15a90
jmp 0x479d
leaq 0x11311(%rip), %rdi     # 0x15aae
xorl %eax, %eax
callq 0x5c85
leaq 0x11323(%rip), %rdi     # 0x15ace
jmp 0x47b4
leaq 0x11338(%rip), %rdi     # 0x15aec
xorl %eax, %eax
callq 0x5c85
jmp 0x47c1
jmp 0x47c1
jmp 0x47c1
movq %rax, %rbx
leaq 0xc(%rsp), %rdi
callq 0x5b82
movq %rbx, %rdi
callq 0x35e0