// File: /workspace/github_cpp_makefile_star2_O1/davidgfnet[P]tadns/tadns.cc
// Function: callback(dns_cb_data*)
static void callback(struct dns_cb_data *cbd) {
    inflight--;
    stillrunning.erase(cbd->name);

    switch (cbd->error) {
    case DNS_OK:
        printf("DNS response for [%s]\n", cbd->name.c_str());
        for (auto rec: cbd->replies) {
            const unsigned char *addr = (unsigned char*)rec.addr.data();
            const unsigned char *name = (unsigned char*)rec.name.data();

            switch (rec.rtype) {
            case DNS_A_RECORD:
                printf("%s A %u.%u.%u.%u\n", name,
                    addr[0], addr[1],
                    addr[2], addr[3]);
                break;
            case DNS_MX_RECORD:
                printf("%s MX %s\n", name, addr);
                break;
            case DNS_CNAME_RECORD:
                printf("%s CNAME %s\n", name, addr);
                break;
            case DNS_NS_RECORD:
                printf("%s NS %s\n", name, addr);
                break;
            default:
                printf("Other Record %s %d\n", name, rec.rtype);
                break;
            }
        }
        break;
    case DNS_TIMEOUT:
        printf("Query timeout for [%s]\n", cbd->name.c_str());
        break;
    case DNS_DOES_NOT_EXIST:
        printf("No such address: [%s]\n", cbd->name.c_str());
        break;
    case DNS_NET_ERROR:
        printf("Network error: [%s]\n", cbd->name.c_str());
        break;
    case DNS_ERROR:
        printf("System error occured\n");
        break;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
decl 0x9e54(%rip)            # 0xf24c
leaq 0x10(%rdi), %r14
leaq 0x9e4d(%rip), %r15      # 0xf250
movq %r15, %rdi
movq %r14, %rsi
callq 0x65f0
movq %r15, %rdi
movq %rax, %rsi
callq 0x6698
movl 0x8(%rbx), %eax
cmpq $0x4, %rax
ja 0x556a
leaq 0x4bd7(%rip), %rcx      # 0xa004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%rbx), %rsi
leaq 0x4eda(%rip), %rdi      # 0xa31b
xorl %eax, %eax
callq 0x2050
movq 0x30(%rbx), %r12
movq 0x38(%rbx), %r13
cmpq %r13, %r12
je 0x556a
leaq 0x10(%rsp), %rbx
leaq 0x20(%rsp), %rbp
leaq 0x30(%rsp), %r14
leaq 0x40(%rsp), %r15
movq (%r12), %rax
movq %rax, 0x8(%rsp)
movq %rbp, 0x10(%rsp)
movq 0x8(%r12), %rsi
movq 0x10(%r12), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x67c6
movq %r15, 0x30(%rsp)
movq 0x28(%r12), %rsi
movq 0x30(%r12), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x67c6
movl 0x48(%r12), %eax
movl %eax, 0x50(%rsp)
movq 0x30(%rsp), %rdx
movq 0x10(%rsp), %rsi
movl 0x8(%rsp), %eax
cmpl $0x4, %eax
jg 0x54d9
cmpl $0x1, %eax
je 0x54fe
cmpl $0x2, %eax
jne 0x54ec
leaq 0x4e84(%rip), %rdi      # 0xa35b
jmp 0x5528
cmpl $0x5, %eax
je 0x5521
cmpl $0xf, %eax
jne 0x54ec
leaq 0x4e5a(%rip), %rdi      # 0xa344
jmp 0x5528
leaq 0x4e72(%rip), %rdi      # 0xa365
movl %eax, %edx
xorl %eax, %eax
callq 0x2050
jmp 0x552f
movzbl (%rdx), %eax
movzbl 0x1(%rdx), %ecx
movzbl 0x2(%rdx), %r8d
movzbl 0x3(%rdx), %r9d
leaq 0x4e1c(%rip), %rdi      # 0xa332
movl %eax, %edx
xorl %eax, %eax
callq 0x2050
jmp 0x552f
leaq 0x4e26(%rip), %rdi      # 0xa34e
xorl %eax, %eax
callq 0x2050
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x5546
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2280
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x555d
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2280
addq $0x50, %r12
cmpq %r13, %r12
jne 0x546d
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rsi
leaq 0x4e25(%rip), %rdi      # 0xa3a8
jmp 0x55b5
movq (%r14), %rsi
leaq 0x4dea(%rip), %rdi      # 0xa379
jmp 0x55b5
leaq 0x4e71(%rip), %rdi      # 0xa409
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2390
movq (%r14), %rsi
leaq 0x4ddc(%rip), %rdi      # 0xa391
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2050
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x55e4
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2280
movq %rbx, %rdi
callq 0x23e0