// File: /workspace/github_cpp_makefile_star2_O3/davidgfnet[P]tadns/tadns.cc
// Function: DNSResolver::queue(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, Query*, dns_record_type, sockaddr*)
void DNSResolver::queue(unsigned niter, std::string name, Query *dep, enum dns_record_type qtype, struct sockaddr * dnss) {
    struct cache_entry * centry;
    struct dns_cb_data cbd;

    std::transform(name.begin(), name.end(), name.begin(), ::tolower);

    /* Search the cache first */
    if ((centry = find_cached_query(qtype, name)) != NULL) {
        assert(dep == NULL);
        return;
    }

    /* Check ongoing requests */
    // Dependants get merged and will be waken all together
    // if there is no callback to the user, safe to ignore it
    auto lookup = std::make_pair(name, qtype);
    auto existingq = ongoing.find(lookup);
    if (existingq != ongoing.end()) {
        if (dep) {
            existingq->second->deps.insert(dep);
            dep->deps_on = existingq->second;
        }
        return;
    }

    /* Allocate new query */
    Query * query = createQuery(niter, NULL, name, qtype, NULL);
    if (dep) {
        query->deps.insert(dep);
        dep->deps_on = query;
    }

    send_dns_packet(query, dnss);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %r9, 0x40(%rsp)
movl %r8d, %ebp
movq %rdx, %r12
movl %esi, 0x14(%rsp)
movq %rdi, %r14
movq %rcx, 0x8(%rsp)
leaq 0xd0(%rsp), %r15
movq %r15, -0x10(%r15)
xorl %edx, %edx
movq %rdx, -0x8(%r15)
movb $0x0, (%r15)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r15)
movq %rdx, 0x20(%r15)
movq (%r12), %r13
movq 0x8(%r12), %rbx
testq %rbx, %rbx
je 0x6468
xorl %r15d, %r15d
movsbl (%r13,%r15), %edi
callq 0x3390
movb %al, (%r13,%r15)
incq %r15
cmpq %r15, %rbx
jne 0x643f
movq (%r12), %r13
movq 0x8(%r12), %rdx
leaq 0xd0(%rsp), %r15
leaq 0x78(%rsp), %rbx
movq %rbx, -0x10(%rbx)
addq %r13, %rdx
leaq 0x68(%rsp), %rdi
movq %r13, %rsi
callq 0x3c72
leaq 0x68(%rsp), %rdx
movq %r14, %rdi
movl %ebp, %esi
callq 0x46a4
movq %rax, %r13
movq 0x68(%rsp), %rdi
cmpq %rbx, %rdi
je 0x64aa
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x32b0
testq %r13, %r13
je 0x64da
cmpq $0x0, 0x8(%rsp)
je 0x6636
leaq 0x4caf(%rip), %rdi      # 0xb171
leaq 0x4c0f(%rip), %rsi      # 0xb0d8
leaq 0x4cad(%rip), %rcx      # 0xb17d
movl $0x29a, %edx            # imm = 0x29A
callq 0x31b0
leaq 0x28(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
leaq 0x18(%rsp), %rdi
callq 0x3c72
movl %ebp, 0x38(%rsp)
leaq 0x98(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
addq %rsi, %rdx
leaq 0x88(%rsp), %rdi
callq 0x3c72
leaq 0x70(%r14), %rdi
movzwl 0x38(%rsp), %eax
leaq 0x88(%rsp), %rsi
movw %ax, 0x20(%rsi)
callq 0x8eb6
movq %rax, %r13
movq 0x88(%rsp), %rdi
cmpq %rbx, %rdi
je 0x655d
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x32b0
leaq 0x78(%r14), %rax
cmpq %rax, %r13
je 0x6596
cmpq $0x0, 0x8(%rsp)
je 0x661a
movq 0x48(%r13), %rdi
addq $0x40, %rdi
leaq 0x8(%rsp), %rsi
callq 0x8f20
movq 0x48(%r13), %rax
movq 0x8(%rsp), %rcx
movq %rax, 0x70(%rcx)
jmp 0x661a
leaq 0x58(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %rdi
callq 0x3c72
leaq 0x48(%rsp), %rcx
movq %r14, %rdi
movl 0x14(%rsp), %esi
xorl %edx, %edx
movl %ebp, %r8d
xorl %r9d, %r9d
callq 0x66fa
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x65e8
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x32b0
cmpq $0x0, 0x8(%rsp)
je 0x660a
movq %rbx, %rdi
addq $0x40, %rdi
leaq 0x8(%rsp), %rsi
callq 0x8f20
movq 0x8(%rsp), %rax
movq %rbx, 0x70(%rax)
movq %r14, %rdi
movq %rbx, %rsi
movq 0x40(%rsp), %rdx
callq 0x6ac8
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x6636
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x32b0
leaq 0xe0(%rsp), %rbx
movq %rbx, %rdi
callq 0x3b80
movq -0x20(%rbx), %rdi
cmpq %r15, %rdi
je 0x665f
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x32b0
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x66ae
movq 0x58(%rsp), %rsi
jmp 0x66a1
jmp 0x66ab
jmp 0x66ab
movq %rax, %r15
movq 0x88(%rsp), %rdi
cmpq %rbx, %rdi
je 0x66ae
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x32b0
jmp 0x66ae
movq %rax, %r15
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x66e5
movq 0x28(%rsp), %rsi
jmp 0x66d8
jmp 0x66e2
movq %rax, %r15
movq 0x68(%rsp), %rdi
cmpq %rbx, %rdi
je 0x66e5
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x32b0
jmp 0x66e5
movq %rax, %r15
leaq 0xb0(%rsp), %rdi
callq 0x72be
movq %r15, %rdi
callq 0x3400