// File: /workspace/github_cpp_makefile_star2_O2/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, %r14d
movq %rcx, %r13
movq %rdx, %r12
movl %esi, 0x14(%rsp)
movq %rdi, 0x8(%rsp)
movq %rcx, (%rsp)
leaq 0xd0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorps %xmm0, %xmm0
andq $0x0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movq (%rdx), %rbx
movq 0x8(%rdx), %r15
xorl %ebp, %ebp
cmpq %rbp, %r15
je 0x5705
movsbl (%rbx,%rbp), %edi
callq 0x3390
movb %al, (%rbx,%rbp)
incq %rbp
jmp 0x56ef
leaq 0x40(%rsp), %rdi
movq %r12, %rsi
callq 0x3360
leaq 0x40(%rsp), %rdx
movq 0x8(%rsp), %r15
movq %r15, %rdi
movl %r14d, %esi
callq 0x42e6
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x3140
testq %rbx, %rbx
je 0x5761
testq %r13, %r13
je 0x5844
leaq 0x4a6e(%rip), %rdi      # 0xa1b7
leaq 0x4958(%rip), %rsi      # 0xa0a8
leaq 0x4a6c(%rip), %rcx      # 0xa1c3
movl $0x29a, %edx            # imm = 0x29A
callq 0x31c0
leaq 0x88(%rsp), %rdi
movq %r12, %rsi
callq 0x3360
leaq 0x88(%rsp), %rsi
movl %r14d, 0x20(%rsi)
leaq 0x60(%rsp), %rdi
callq 0x5f4e
leaq 0x70(%r15), %rdi
leaq 0x60(%rsp), %rsi
callq 0x8288
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x3140
leaq 0x78(%r15), %rax
cmpq %rax, %rbx
je 0x57d2
testq %r13, %r13
je 0x5837
movq 0x48(%rbx), %rdi
addq $0x40, %rdi
movq %rsp, %rsi
callq 0x82c6
movq 0x48(%rbx), %rax
movq (%rsp), %rcx
movq %rax, 0x70(%rcx)
jmp 0x5837
leaq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x3360
leaq 0x20(%rsp), %rcx
movq 0x8(%rsp), %rdi
movl 0x14(%rsp), %esi
xorl %edx, %edx
movl %r14d, %r8d
xorl %r9d, %r9d
callq 0x58b6
movq %rax, %r15
leaq 0x20(%rsp), %rdi
callq 0x3140
cmpq $0x0, (%rsp)
je 0x5825
movq %r15, %rdi
addq $0x40, %rdi
movq %rsp, %rsi
callq 0x82c6
movq (%rsp), %rax
movq %r15, 0x70(%rax)
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq 0x18(%rsp), %rdx
callq 0x5b64
leaq 0x88(%rsp), %rdi
callq 0x3140
leaq 0xb0(%rsp), %rdi
callq 0x630a
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
jmp 0x5879
jmp 0x5880
jmp 0x5880
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x3140
jmp 0x5883
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
jmp 0x5897
jmp 0x589e
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x3140
jmp 0x58a1
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x630a
movq %rbx, %rdi
callq 0x33f0