// File: /workspace/github_cpp_makefile_star2_O3/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 0x9e65(%rip)            # 0xf24c
leaq 0x10(%rdi), %r14
leaq 0x9e5e(%rip), %r15      # 0xf250
movq %r15, %rdi
movq %r14, %rsi
callq 0x65c0
movq %r15, %rdi
movq %rax, %rsi
callq 0x6674
movl 0x8(%rbx), %eax
cmpq $0x4, %rax
ja 0x5559
leaq 0x4be8(%rip), %rcx      # 0xa004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%rbx), %rsi
leaq 0x4e71(%rip), %rdi      # 0xa2a1
xorl %eax, %eax
callq 0x2050
movq 0x30(%rbx), %r12
movq 0x38(%rbx), %r13
cmpq %r13, %r12
je 0x5559
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 0x67a2
movq %r15, 0x30(%rsp)
movq 0x28(%r12), %rsi
movq 0x30(%r12), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x67a2
movl 0x48(%r12), %eax
movl %eax, 0x50(%rsp)
movq 0x30(%rsp), %rdx
movq 0x10(%rsp), %rsi
movl 0x8(%rsp), %eax
cmpl $0x4, %eax
jg 0x54c8
cmpl $0x1, %eax
je 0x54ed
cmpl $0x2, %eax
jne 0x54db
leaq 0x4e1b(%rip), %rdi      # 0xa2e1
jmp 0x5517
cmpl $0x5, %eax
je 0x5510
cmpl $0xf, %eax
jne 0x54db
leaq 0x4df1(%rip), %rdi      # 0xa2ca
jmp 0x5517
leaq 0x4e09(%rip), %rdi      # 0xa2eb
movl %eax, %edx
xorl %eax, %eax
callq 0x2050
jmp 0x551e
movzbl (%rdx), %eax
movzbl 0x1(%rdx), %ecx
movzbl 0x2(%rdx), %r8d
movzbl 0x3(%rdx), %r9d
leaq 0x4db3(%rip), %rdi      # 0xa2b8
movl %eax, %edx
xorl %eax, %eax
callq 0x2050
jmp 0x551e
leaq 0x4dbd(%rip), %rdi      # 0xa2d4
xorl %eax, %eax
callq 0x2050
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x5535
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2280
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x554c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2280
addq $0x50, %r12
cmpq %r13, %r12
jne 0x545c
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rsi
leaq 0x4dbc(%rip), %rdi      # 0xa32e
jmp 0x55a4
movq (%r14), %rsi
leaq 0x4d81(%rip), %rdi      # 0xa2ff
jmp 0x55a4
leaq 0x4e08(%rip), %rdi      # 0xa38f
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2390
movq (%r14), %rsi
leaq 0x4d73(%rip), %rdi      # 0xa317
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 0x55d3
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2280
movq %rbx, %rdi
callq 0x23e0
nop