// File: /workspace/github_cpp_makefile_star2_O1/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, 0x18(%rsp)
movl %r8d, %ebp
movq %rdx, %r12
movl %esi, 0x14(%rsp)
movq %rdi, %r14
movq %rcx, 0x8(%rsp)
leaq 0xd0(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rcx)
movq %rax, 0x20(%rcx)
movq 0x8(%rdx), %rbx
testq %rbx, %rbx
je 0x649a
movq (%r12), %r13
xorl %r15d, %r15d
movsbl (%r13,%r15), %edi
callq 0x3390
movb %al, (%r13,%r15)
incq %r15
cmpq %r15, %rbx
jne 0x6482
leaq 0x78(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
leaq 0x68(%rsp), %rdi
callq 0x3c70
leaq 0x68(%rsp), %rdx
movq %r14, %rdi
movl %ebp, %esi
callq 0x46c0
movq %rax, %r13
movq 0x68(%rsp), %rdi
cmpq %rbx, %rdi
je 0x64e2
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x32b0
testq %r13, %r13
je 0x6512
cmpq $0x0, 0x8(%rsp)
je 0x6669
leaq 0x4ced(%rip), %rdi      # 0xb1e7
leaq 0x4bd7(%rip), %rsi      # 0xb0d8
leaq 0x4ceb(%rip), %rcx      # 0xb1f3
movl $0x29a, %edx            # imm = 0x29A
callq 0x31b0
leaq 0x30(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
leaq 0x20(%rsp), %rdi
callq 0x3c70
movl %ebp, 0x40(%rsp)
leaq 0x98(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
leaq 0x88(%rsp), %rdi
callq 0x3c70
leaq 0x70(%r14), %rdi
movzwl 0x40(%rsp), %eax
leaq 0x88(%rsp), %rsi
movw %ax, 0x20(%rsi)
callq 0x8f40
movq %rax, %r13
movq 0x88(%rsp), %rdi
cmpq %rbx, %rdi
je 0x6595
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x32b0
leaq 0x78(%r14), %rax
cmpq %rax, %r13
je 0x65ce
cmpq $0x0, 0x8(%rsp)
je 0x6652
movq 0x48(%r13), %rdi
addq $0x40, %rdi
leaq 0x8(%rsp), %rsi
callq 0x8fac
movq 0x48(%r13), %rax
movq 0x8(%rsp), %rcx
movq %rax, 0x70(%rcx)
jmp 0x6652
leaq 0x58(%rsp), %r13
movq %r13, -0x10(%r13)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %rdi
callq 0x3c70
leaq 0x48(%rsp), %rcx
movq %r14, %rdi
movl 0x14(%rsp), %esi
xorl %edx, %edx
movl %ebp, %r8d
xorl %r9d, %r9d
callq 0x6730
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x6620
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x32b0
cmpq $0x0, 0x8(%rsp)
je 0x6642
movq %rbx, %rdi
addq $0x40, %rdi
leaq 0x8(%rsp), %rsi
callq 0x8fac
movq 0x8(%rsp), %rax
movq %rbx, 0x70(%rax)
movq %r14, %rdi
movq %rbx, %rsi
movq 0x18(%rsp), %rdx
callq 0x6ae8
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x6669
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x32b0
leaq 0xe0(%rsp), %rbx
movq %rbx, %rdi
callq 0x3b82
movq -0x20(%rbx), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x669a
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, %r14
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0x66e9
movq 0x58(%rsp), %rsi
jmp 0x66dc
jmp 0x66e6
jmp 0x66e6
movq %rax, %r14
movq 0x88(%rsp), %rdi
cmpq %rbx, %rdi
je 0x66e9
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x32b0
jmp 0x66e9
movq %rax, %r14
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0x671b
movq 0x30(%rsp), %rsi
jmp 0x670e
jmp 0x6718
movq %rax, %r14
movq 0x68(%rsp), %rdi
cmpq %rbx, %rdi
je 0x671b
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x32b0
jmp 0x671b
movq %rax, %r14
leaq 0xb0(%rsp), %rdi
callq 0x72da
movq %r14, %rdi
callq 0x3400