// File: /workspace/github_cpp_makefile_star2_O2/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, %r14
decl 0xace1(%rip)            # 0xf254
leaq 0x10(%rdi), %rbx
leaq 0xacda(%rip), %rdi      # 0xf258
movq %rbx, %rsi
callq 0x58f2
movl 0x8(%r14), %eax
cmpq $0x4, %rax
ja 0x4668
leaq 0x4a69(%rip), %rcx      # 0x9004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%r14), %rsi
leaq 0x4d68(%rip), %rdi      # 0x9317
xorl %eax, %eax
callq 0x2040
movq 0x30(%r14), %rbx
movq 0x38(%r14), %r12
leaq 0x8(%rsp), %r14
leaq 0x4d80(%rip), %r13      # 0x934a
leaq 0x4d5d(%rip), %rbp      # 0x932e
leaq 0x4d89(%rip), %r15      # 0x9361
cmpq %r12, %rbx
je 0x4668
movq %r14, %rdi
movq %rbx, %rsi
callq 0x588a
movq 0x30(%rsp), %rdx
movq 0x10(%rsp), %rsi
movl 0x8(%rsp), %eax
cmpl $0xf, %eax
je 0x463b
cmpl $0x2, %eax
je 0x462d
cmpl $0x5, %eax
je 0x4636
cmpl $0x1, %eax
jne 0x464b
movzbl (%rdx), %eax
movzbl 0x1(%rdx), %ecx
movzbl 0x2(%rdx), %r8d
movzbl 0x3(%rdx), %r9d
movq %rbp, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x2040
jmp 0x4657
leaq 0x4d23(%rip), %rdi      # 0x9357
jmp 0x4642
movq %r13, %rdi
jmp 0x4642
leaq 0x4cfe(%rip), %rdi      # 0x9340
xorl %eax, %eax
callq 0x2040
jmp 0x4657
movq %r15, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x2040
movq %r14, %rdi
callq 0x58d8
addq $0x50, %rbx
jmp 0x45d8
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rbx), %rsi
leaq 0x4d23(%rip), %rdi      # 0x93a4
jmp 0x46b3
movq (%rbx), %rsi
leaq 0x4ce8(%rip), %rdi      # 0x9375
jmp 0x46b3
leaq 0x4d6f(%rip), %rdi      # 0x9405
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2390
movq (%rbx), %rsi
leaq 0x4cda(%rip), %rdi      # 0x938d
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2040