// File: ctSkennerton[P]fxtract/util/gai.c
// Function: main
int main(int argc, char **argv)
{
    if (argc == 1) usage("host... -- display getaddrinfo results");

    struct addrinfo crap, *gaip = NULL, *aip,
           hint = { AI_NUMERICSERV | AI_CANONNAME, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP,
                    /*addrlen*/0, /*addr*/0, /*canonname*/0, /*next*/0 };

    while (*++argv) {
        gaip = &crap;
        int ret = getaddrinfo(*argv, 0, &hint, &gaip);
        if (ret)  {
            fprintf(stderr, "%s error:%d %s\n", *argv, ret, eainame[-ret]);
        } else if (gaip) {

            printf("%s %s\n", *argv, 
                    gaip->ai_canonname && strcmp(gaip->ai_canonname, *argv)
                        ? gaip->ai_canonname : "");

            for (aip = gaip; aip; aip = aip->ai_next) {
                IPSTR    ip = {};
                inet_ntop(aip->ai_family, 
                            aip->ai_family == AF_INET6 
                                ? (void*)&((struct sockaddr_in6*)aip->ai_addr)->sin6_addr
                                : (void*)&((struct sockaddr_in *)aip->ai_addr)->sin_addr, 
                            ip, sizeof(ip));
                printf("\t%s\n", ip);
            }

            freeaddrinfo(gaip);
        }
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x1, -0x8(%rbp)
jne 0x341b
leaq 0x2bee(%rip), %rdi      # 0x6004
callq 0x3610
movq $0x0, -0x48(%rbp)
leaq -0x80(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x30b0
movl $0x402, -0x80(%rbp)     # imm = 0x402
movl $0x1, -0x78(%rbp)
movl $0x6, -0x74(%rbp)
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, -0x10(%rbp)
cmpq $0x0, 0x8(%rax)
je 0x3604
leaq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
leaq -0x80(%rbp), %rdx
leaq -0x48(%rbp), %rcx
callq 0x31c0
movl %eax, -0x84(%rbp)
cmpl $0x0, -0x84(%rbp)
je 0x34d1
movq 0x5b48(%rip), %rax      # 0x8fe0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
movl -0x84(%rbp), %ecx
xorl %eax, %eax
subl -0x84(%rbp), %eax
movslq %eax, %rsi
leaq 0x6216(%rip), %rax      # 0x96d0
movq (%rax,%rsi,8), %r8
leaq 0x2b66(%rip), %rsi      # 0x602b
movb $0x0, %al
callq 0x3210
jmp 0x35ff
cmpq $0x0, -0x48(%rbp)
je 0x35fd
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0xc8(%rbp)
movq -0x48(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x351f
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x3200
cmpl $0x0, %eax
je 0x351f
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xd0(%rbp)
jmp 0x352f
leaq 0x2b19(%rip), %rax      # 0x603f
movq %rax, -0xd0(%rbp)
jmp 0x352f
movq -0xc8(%rbp), %rsi
movq -0xd0(%rbp), %rdx
leaq 0x2b03(%rip), %rdi      # 0x6047
movb $0x0, %al
callq 0x3040
movq -0x48(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x35f4
leaq -0xc0(%rbp), %rdi
xorl %esi, %esi
movl $0x2e, %edx
callq 0x30b0
movq -0x50(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0xd4(%rbp)
movq -0x50(%rbp), %rax
cmpl $0xa, 0x4(%rax)
jne 0x359d
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rax
addq $0x8, %rax
movq %rax, -0xe0(%rbp)
jmp 0x35b0
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rax
addq $0x4, %rax
movq %rax, -0xe0(%rbp)
movl -0xd4(%rbp), %edi
movq -0xe0(%rbp), %rsi
leaq -0xc0(%rbp), %rdx
movl $0x2e, %ecx
callq 0x3140
leaq -0xc0(%rbp), %rsi
leaq 0x2a5f(%rip), %rdi      # 0x603b
movb $0x0, %al
callq 0x3040
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0x3553
movq -0x48(%rbp), %rdi
callq 0x31d0
jmp 0x35ff
jmp 0x3448
xorl %eax, %eax
addq $0xe0, %rsp
popq %rbp
retq
nop