// File: /workspace/github_c_makefile_star2_O3/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 0x190fd(%rip), %rax     # 0x1d680
cmpb $0x1, (%rax)
jne 0x4596
leaq 0x11434(%rip), %rdi     # 0x159c3
xorl %esi, %esi
callq 0xf4a3
leaq 0x1143f(%rip), %rsi     # 0x159dc
movl $0x8, %edi
xorl %eax, %eax
callq 0x5d74
movq %rbx, %rdi
callq 0x34b0
testl %eax, %eax
jne 0x46d4
movb $0x1, 0x118(%rbx)
movq %rbx, %rdi
callq 0x3250
testl %eax, %eax
jne 0x46dd
leaq 0x28(%rbx), %r14
movq %r14, %rdi
callq 0x3110
testl %eax, %eax
jne 0x46e6
movq %r14, 0x10(%rsp)
movslq 0x80(%rbx), %r13
testq %r13, %r13
jle 0x4654
movl $0x8, %ebp
leaq 0x113f2(%rip), %r15     # 0x159f3
xorl %r12d, %r12d
testq %r12, %r12
je 0x462b
movl $0x8, %edi
movq %r15, %rsi
movl %r12d, %edx
xorl %eax, %eax
callq 0x5d74
movq 0xf8(%rbx), %rax
movq (%rax,%r12,8), %rdi
callq 0x11fce
movq 0x100(%rbx), %r14
leaq (%r14,%rbp), %rdi
callq 0xe932
leaq (%r14,%rbp), %rdi
addq $-0x8, %rdi
callq 0xe881
incq %r12
addq $0x50, %rbp
cmpq %r12, %r13
jne 0x4604
movq 0x78(%rbx), %r15
movq 0x110(%rbx), %rsi
movq %r15, %rdi
callq 0xe88a
movq 0x58(%rbx), %rsi
movq %r15, %rdi
callq 0xe88a
movq 0x10(%rsp), %rdi
callq 0x3640
testl %eax, %eax
jne 0x46f4
movq %rbx, %rdi
callq 0x33b0
testl %eax, %eax
jne 0x46fd
movq 0x78(%rbx), %rdi
movq 0x100(%rbx), %rsi
callq 0xe88a
movq 0x78(%rbx), %rdi
movq 0xf8(%rbx), %rsi
callq 0xe88a
xorl %edi, %edi
callq 0x1155d
xorl %edi, %edi
callq 0x115a1
leaq 0xc(%rsp), %rdi
callq 0x5a06
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11381(%rip), %rdi     # 0x15a5c
jmp 0x46ed
leaq 0x11394(%rip), %rdi     # 0x15a78
jmp 0x46ed
leaq 0x113a9(%rip), %rdi     # 0x15a96
xorl %eax, %eax
callq 0x5b09
leaq 0x113bb(%rip), %rdi     # 0x15ab6
jmp 0x4704
leaq 0x113d0(%rip), %rdi     # 0x15ad4
xorl %eax, %eax
callq 0x5b09
jmp 0x4711
jmp 0x4711
jmp 0x4711
movq %rax, %rbx
leaq 0xc(%rsp), %rdi
callq 0x5a06
movq %rbx, %rdi
callq 0x35e0