#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct sockaddr_in {
  int /*<<< orphan*/ sin_addr;
};
struct sockaddr {
  int dummy;
};
struct addrinfo {
  scalar_t__ ai_family;
  struct addrinfo *ai_next;
  scalar_t__ ai_addr;
  int /*<<< orphan*/ ai_socktype;
};
typedef int /*<<< orphan*/ rev_dns_buf;
typedef int /*<<< orphan*/ hints;

/* Variables and functions */
scalar_t__ AF_INET;
scalar_t__ AF_INET6;
scalar_t__ AF_UNSPEC;
int EINVAL;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ INET6_ADDRSTRLEN;
int /*<<< orphan*/ INET_ADDRSTRLEN;
int /*<<< orphan*/ SOCK_STREAM;
scalar_t__ checkEndian();
int errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
int getaddrinfo(char *, int /*<<< orphan*/ *, struct addrinfo *,
                struct addrinfo **);
scalar_t__ getnameinfo(struct sockaddr *, int /*<<< orphan*/, char *, int,
                       int /*<<< orphan*/ *, int /*<<< orphan*/,
                       int /*<<< orphan*/);
int /*<<< orphan*/ *inet_ntop(scalar_t__, int /*<<< orphan*/ *, char *,
                              int /*<<< orphan*/);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
char *strerror(int);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    fprintf(stderr, "Invalid arguments. Usage: dnsresolve <host>\n");
    errno = EINVAL;
    exit(EXIT_FAILURE);
  }
  struct addrinfo hints;
  memset(&hints, 0, sizeof(hints));
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_family = AF_UNSPEC;
  struct addrinfo *results;
  int error;
  error = getaddrinfo(argv[1], NULL, &hints, &results);
  if (error != 0) {
    fprintf(stderr, "Error in getaddrinfo(): %s\n", gai_strerror(error));
    exit(EXIT_FAILURE);
  }
  if (checkEndian() == 0)
    printf("The system and network are big-endian (MSB first).\n");
  else
    printf("The system is little-endian (LSB first), the network is big-endian "
           "(MSB first).\n");
  struct addrinfo *loop;
  struct sockaddr_in *sa_in;
  char ip_buf[512], rev_dns_buf[512];
  for (loop = results; loop != NULL; loop = loop->ai_next) {
    sa_in = (struct sockaddr_in *)loop->ai_addr;
    if (loop->ai_family == AF_INET) {
      if (inet_ntop(AF_INET, &(sa_in->sin_addr), ip_buf, INET_ADDRSTRLEN) ==
          NULL) {
        fprintf(stderr, "Error translating name (inet_ntop): %s\n",
                strerror(error));
        exit(EXIT_FAILURE);
      }
      if (getnameinfo((struct sockaddr *)sa_in, INET_ADDRSTRLEN, rev_dns_buf,
                      sizeof(rev_dns_buf), NULL, 0, 0)) {
        fprintf(stderr, "Error in getnameinfo(): %s\n", gai_strerror(errno));
        exit(EXIT_FAILURE);
      }
      fprintf(stdout, "ipv4: %s -- reverse dns lookup: %s\n", ip_buf,
              rev_dns_buf);
    } else {
      if (inet_ntop(AF_INET6, &(sa_in->sin_addr), ip_buf, INET6_ADDRSTRLEN) ==
          NULL) {
        fprintf(stderr, "Error translating name (inet_ntop): %s\n",
                strerror(error));
        exit(EXIT_FAILURE);
      }
      if (getnameinfo((struct sockaddr *)sa_in, INET6_ADDRSTRLEN, rev_dns_buf,
                      sizeof(rev_dns_buf), NULL, 0, 0)) {
        fprintf(stderr, "Error in getnameinfo(): %s\n", gai_strerror(errno));
        exit(EXIT_FAILURE);
      }
      fprintf(stdout, "ipv6: %s -- reverse dns lookup: %s\n", ip_buf,
              rev_dns_buf);
    }
    if (loop->ai_next == NULL)
      break;
  }
  freeaddrinfo(results);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x470,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     120a <main+0x5a>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
lea    0xe1d(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2da7(%rip),%rax
mov    (%rax),%ecx
mov    0x2db6(%rip),%rax
mov    %ecx,(%rax)
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
mov    0x2d97(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2dab(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x30(%rbp),%rdx
lea    -0x38(%rbp),%rcx
call   10b0 <getaddrinfo@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     1296 <main+0xe6>
mov    0x2d5f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x454(%rbp)
mov    -0x3c(%rbp),%edi
call   1050 <gai_strerror@plt>
mov    -0x454(%rbp),%edi
mov    %rax,%rdx
lea    0xdac(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2d11(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    $0x0,%al
call   1080 <checkEndian@plt>
cmp    $0x0,%rax
jne    12b8 <main+0x108>
lea    0xd9b(%rip),%rdi
call   1040 <printf@plt>
jmp    12c4 <main+0x114>
lea    0xdbe(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     1537 <main+0x387>
mov    -0x48(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x48(%rbp),%rax
mov    (%rax),%rax
mov    0x2cef(%rip),%rcx
cmp    (%rcx),%rax
jne    1406 <main+0x256>
mov    0x2cdf(%rip),%rax
mov    (%rax),%rdi
mov    -0x50(%rbp),%rsi
lea    -0x250(%rbp),%rdx
mov    0x2c92(%rip),%rax
mov    (%rax),%ecx
call   1030 <inet_ntop@plt>
cmp    $0x0,%rax
jne    1363 <main+0x1b3>
mov    0x2c92(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x458(%rbp)
mov    -0x3c(%rbp),%edi
call   10c0 <strerror@plt>
mov    -0x458(%rbp),%edi
mov    %rax,%rdx
lea    0xd80(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2c44(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x50(%rbp),%rdi
mov    0x2c3a(%rip),%rax
mov    (%rax),%esi
lea    -0x450(%rbp),%rdx
mov    $0x200,%ecx
xor    %eax,%eax
mov    %eax,%r8d
xor    %r9d,%r9d
movl   $0x0,(%rsp)
call   1070 <getnameinfo@plt>
cmp    $0x0,%rax
je     13dc <main+0x22c>
mov    0x2c1f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x45c(%rbp)
mov    0x2c00(%rip),%rax
mov    (%rax),%edi
call   1050 <gai_strerror@plt>
mov    -0x45c(%rbp),%edi
mov    %rax,%rdx
lea    0xd2f(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2bcb(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    0x2bad(%rip),%rax
mov    (%rax),%edi
lea    -0x250(%rbp),%rdx
lea    -0x450(%rbp),%rcx
lea    0xd18(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    150d <main+0x35d>
mov    0x2bc3(%rip),%rax
mov    (%rax),%rdi
mov    -0x50(%rbp),%rsi
lea    -0x250(%rbp),%rdx
mov    0x2bc6(%rip),%rax
mov    (%rax),%ecx
call   1030 <inet_ntop@plt>
cmp    $0x0,%rax
jne    146f <main+0x2bf>
mov    0x2b86(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x460(%rbp)
mov    -0x3c(%rbp),%edi
call   10c0 <strerror@plt>
mov    -0x460(%rbp),%edi
mov    %rax,%rdx
lea    0xc74(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2b38(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x50(%rbp),%rdi
mov    0x2b6e(%rip),%rax
mov    (%rax),%esi
lea    -0x450(%rbp),%rdx
mov    $0x200,%ecx
xor    %eax,%eax
mov    %eax,%r8d
xor    %r9d,%r9d
movl   $0x0,(%rsp)
call   1070 <getnameinfo@plt>
cmp    $0x0,%rax
je     14e8 <main+0x338>
mov    0x2b13(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x464(%rbp)
mov    0x2af4(%rip),%rax
mov    (%rax),%edi
call   1050 <gai_strerror@plt>
mov    -0x464(%rbp),%edi
mov    %rax,%rdx
lea    0xc23(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2abf(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    0x2aa1(%rip),%rax
mov    (%rax),%edi
lea    -0x250(%rbp),%rdx
lea    -0x450(%rbp),%rcx
lea    0xc30(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x48(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    1521 <main+0x371>
jmp    1537 <main+0x387>
jmp    1526 <main+0x376>
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x48(%rbp)
jmp    12cc <main+0x11c>
mov    -0x38(%rbp),%rdi
call   10d0 <freeaddrinfo@plt>
mov    0x2a41(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x438,%rsp
cmp    $0x2,%edi
jne    1363 <main+0x1b3>
mov    %rsi,%rbx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
mov    0x2dd0(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x28(%rsp)
mov    0x2de3(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x10(%rsp)
mov    0x8(%rbx),%rdi
lea    0x8(%rsp),%rcx
xor    %esi,%esi
mov    %r14,%rdx
call   10b0 <getaddrinfo@plt>
test   %eax,%eax
jne    138e <main+0x1de>
xor    %eax,%eax
call   1080 <checkEndian@plt>
test   %rax,%rax
lea    0xefc(%rip),%rax
lea    0xea5(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
mov    0x8(%rsp),%rbx
mov    0x2d63(%rip),%rcx
lea    0x230(%rsp),%r13
lea    0x30(%rsp),%r15
mov    0x2d8f(%rip),%r14
nopl   0x0(%rax)
test   %rbx,%rbx
je     134b <main+0x19b>
mov    (%rbx),%rdi
mov    0x10(%rbx),%r12
mov    0x2d69(%rip),%rax
cmp    (%rax),%rdi
jne    12d0 <main+0x120>
mov    %r13,%rdx
mov    %rcx,%rbp
mov    (%rcx),%ecx
mov    %r12,%rsi
call   1030 <inet_ntop@plt>
test   %rax,%rax
je     13a7 <main+0x1f7>
mov    0x0(%rbp),%esi
movl   $0x0,(%rsp)
mov    %r12,%rdi
mov    %r15,%rdx
mov    $0x200,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1070 <getnameinfo@plt>
lea    0xdd1(%rip),%rsi
test   %rax,%rax
je     1321 <main+0x171>
jmp    13c0 <main+0x210>
cs nopw 0x0(%rax,%rax,1)
mov    0x2cf9(%rip),%rax
mov    (%rax),%rdi
mov    (%r14),%ecx
mov    %r12,%rsi
mov    %r13,%rdx
call   1030 <inet_ntop@plt>
test   %rax,%rax
je     13a7 <main+0x1f7>
mov    (%r14),%esi
movl   $0x0,(%rsp)
mov    %r12,%rdi
mov    %r15,%rdx
mov    $0x200,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1070 <getnameinfo@plt>
lea    0xd99(%rip),%rsi
test   %rax,%rax
jne    13c0 <main+0x210>
mov    0x2c68(%rip),%rax
mov    (%rax),%edi
mov    %r13,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x8(%rbx),%rbx
test   %rbx,%rbx
mov    0x2c63(%rip),%rcx
jne    1260 <main+0xb0>
mov    0x8(%rsp),%rdi
call   10d0 <freeaddrinfo@plt>
mov    0x2c2c(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    0x2c56(%rip),%rax
mov    (%rax),%edi
lea    0xc8d(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x2c17(%rip),%rax
mov    (%rax),%eax
mov    0x2c26(%rip),%rcx
mov    %eax,(%rcx)
jmp    13ea <main+0x23a>
mov    0x2c2b(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1050 <gai_strerror@plt>
lea    0xc88(%rip),%rsi
jmp    13de <main+0x22e>
mov    0x2c12(%rip),%rax
mov    (%rax),%ebx
xor    %edi,%edi
call   10c0 <strerror@plt>
lea    0xc8b(%rip),%rsi
jmp    13de <main+0x22e>
mov    0x2bf9(%rip),%rax
mov    (%rax),%ebx
mov    0x2be0(%rip),%rax
mov    (%rax),%edi
call   1050 <gai_strerror@plt>
lea    0xc93(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x2baf(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.addrinfo = type { i64, %struct.addrinfo*, i64, i32 }
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [45 x i8] c"Invalid arguments. Usage: dnsresolve <host>\0A\00"
@EINVAL = global i32 0
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@SOCK_STREAM = global i32 0
@AF_UNSPEC = global i64 0
@.str.1 = [28 x i8] c"Error in getaddrinfo(): %s\0A\00"
@.str.2 = [52 x i8] c"The system and network are big-endian (MSB first).\0A\00"
@.str.3 = [81 x i8] c"The system is little-endian (LSB first), the network is big-endian (MSB first).\0A\00"
@AF_INET = global i64 0
@INET_ADDRSTRLEN = global i32 0
@.str.4 = [40 x i8] c"Error translating name (inet_ntop): %s\0A\00"
@.str.5 = [28 x i8] c"Error in getnameinfo(): %s\0A\00"
@stdout = global i32 0
@.str.6 = [36 x i8] c"ipv4: %s -- reverse dns lookup: %s\0A\00"
@AF_INET6 = global i64 0
@INET6_ADDRSTRLEN = global i32 0
@.str.7 = [36 x i8] c"ipv6: %s -- reverse dns lookup: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.addrinfo
%7 = alloca %struct.addrinfo*
%8 = alloca i32
%9 = alloca %struct.addrinfo*
%10 = alloca %struct.sockaddr_in*
%11 = alloca [512 x i8]
%12 = alloca [512 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %21
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @EINVAL
store i32 %18, i32* @errno
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %2
%22 = call i32 @memset(%struct.addrinfo* %6, i32 0, i32 32)
%23 = load i32, i32* @SOCK_STREAM
%24 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 3
store i32 %23, i32* %24
%25 = load i64, i64* @AF_UNSPEC
%26 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 0
store i64 %25, i64* %26
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @getaddrinfo(i8* %29, i32* null, %struct.addrinfo* %6, %struct.addrinfo** %7)
store i32 %30, i32* %8
%31 = load i32, i32* %8
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %40
33: ; preds = %21
%34 = load i32, i32* @stderr
%35 = load i32, i32* %8
%36 = call i8* @gai_strerror(i32 %35)
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %36)
%38 = load i32, i32* @EXIT_FAILURE
%39 = call i32 @exit(i32 %38)
unreachable
40: ; preds = %21
%41 = call i64 (...) @checkEndian()
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0))
br label %47
45: ; preds = %40
%46 = call i32 @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.3, i64 0, i64 0))
br label %47
47: ; preds = %45, %43
%48 = load %struct.addrinfo*, %struct.addrinfo** %7
store %struct.addrinfo* %48, %struct.addrinfo** %9
br label %49
49: ; preds = %137, %47
%50 = load %struct.addrinfo*, %struct.addrinfo** %9
%51 = icmp ne %struct.addrinfo* %50, null
br i1 %51, label %52, label %141
52: ; preds = %49
%53 = load %struct.addrinfo*, %struct.addrinfo** %9
%54 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %53, i32 0, i32 2
%55 = load i64, i64* %54
%56 = inttoptr i64 %55 to %struct.sockaddr_in*
store %struct.sockaddr_in* %56, %struct.sockaddr_in** %10
%57 = load %struct.addrinfo*, %struct.addrinfo** %9
%58 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %57, i32 0, i32 0
%59 = load i64, i64* %58
%60 = load i64, i64* @AF_INET
%61 = icmp eq i64 %59, %60
br i1 %61, label %62, label %96
62: ; preds = %52
%63 = load i64, i64* @AF_INET
%64 = load %struct.sockaddr_in*, %struct.sockaddr_in** %10
%65 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %64, i32 0, i32 0
%66 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%67 = load i32, i32* @INET_ADDRSTRLEN
%68 = call i32* @inet_ntop(i64 %63, i32* %65, i8* %66, i32 %67)
%69 = icmp eq i32* %68, null
br i1 %69, label %70, label %77
70: ; preds = %62
%71 = load i32, i32* @stderr
%72 = load i32, i32* %8
%73 = call i8* @strerror(i32 %72)
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %73)
%75 = load i32, i32* @EXIT_FAILURE
%76 = call i32 @exit(i32 %75)
unreachable
77: ; preds = %62
%78 = load %struct.sockaddr_in*, %struct.sockaddr_in** %10
%79 = bitcast %struct.sockaddr_in* %78 to %struct.sockaddr*
%80 = load i32, i32* @INET_ADDRSTRLEN
%81 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%82 = call i64 @getnameinfo(%struct.sockaddr* %79, i32 %80, i8* %81, i32 512, i32* null, i32 0, i32 0)
%83 = icmp ne i64 %82, 0
br i1 %83, label %84, label %91
84: ; preds = %77
%85 = load i32, i32* @stderr
%86 = load i32, i32* @errno
%87 = call i8* @gai_strerror(i32 %86)
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %87)
%89 = load i32, i32* @EXIT_FAILURE
%90 = call i32 @exit(i32 %89)
unreachable
91: ; preds = %77
%92 = load i32, i32* @stdout
%93 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%94 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i8* %93, i8* %94)
br label %130
96: ; preds = %52
%97 = load i64, i64* @AF_INET6
%98 = load %struct.sockaddr_in*, %struct.sockaddr_in** %10
%99 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %98, i32 0, i32 0
%100 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%101 = load i32, i32* @INET6_ADDRSTRLEN
%102 = call i32* @inet_ntop(i64 %97, i32* %99, i8* %100, i32 %101)
%103 = icmp eq i32* %102, null
br i1 %103, label %104, label %111
104: ; preds = %96
%105 = load i32, i32* @stderr
%106 = load i32, i32* %8
%107 = call i8* @strerror(i32 %106)
%108 = call i32 (i32, i8*, ...) @fprintf(i32 %105, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %107)
%109 = load i32, i32* @EXIT_FAILURE
%110 = call i32 @exit(i32 %109)
unreachable
111: ; preds = %96
%112 = load %struct.sockaddr_in*, %struct.sockaddr_in** %10
%113 = bitcast %struct.sockaddr_in* %112 to %struct.sockaddr*
%114 = load i32, i32* @INET6_ADDRSTRLEN
%115 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%116 = call i64 @getnameinfo(%struct.sockaddr* %113, i32 %114, i8* %115, i32 512, i32* null, i32 0, i32 0)
%117 = icmp ne i64 %116, 0
br i1 %117, label %118, label %125
118: ; preds = %111
%119 = load i32, i32* @stderr
%120 = load i32, i32* @errno
%121 = call i8* @gai_strerror(i32 %120)
%122 = call i32 (i32, i8*, ...) @fprintf(i32 %119, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %121)
%123 = load i32, i32* @EXIT_FAILURE
%124 = call i32 @exit(i32 %123)
unreachable
125: ; preds = %111
%126 = load i32, i32* @stdout
%127 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%128 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%129 = call i32 (i32, i8*, ...) @fprintf(i32 %126, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0), i8* %127, i8* %128)
br label %130
130: ; preds = %125, %91
%131 = load %struct.addrinfo*, %struct.addrinfo** %9
%132 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %131, i32 0, i32 1
%133 = load %struct.addrinfo*, %struct.addrinfo** %132
%134 = icmp eq %struct.addrinfo* %133, null
br i1 %134, label %135, label %136
135: ; preds = %130
br label %141
136: ; preds = %130
br label %137
137: ; preds = %136
%138 = load %struct.addrinfo*, %struct.addrinfo** %9
%139 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %138, i32 0, i32 1
%140 = load %struct.addrinfo*, %struct.addrinfo** %139
store %struct.addrinfo* %140, %struct.addrinfo** %9
br label %49
141: ; preds = %135, %49
%142 = load %struct.addrinfo*, %struct.addrinfo** %7
%143 = call i32 @freeaddrinfo(%struct.addrinfo* %142)
%144 = load i32, i32* @EXIT_SUCCESS
%145 = call i32 @exit(i32 %144)
unreachable
}

LLVM IR (-O2):
%struct.addrinfo = type { i64, %struct.addrinfo*, i64, i32 }
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [45 x i8] c"Invalid arguments. Usage: dnsresolve <host>\0A\00"
@EINVAL = global i32 0
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@SOCK_STREAM = global i32 0
@AF_UNSPEC = global i64 0
@.str.1 = [28 x i8] c"Error in getaddrinfo(): %s\0A\00"
@AF_INET = global i64 0
@INET_ADDRSTRLEN = global i32 0
@.str.4 = [40 x i8] c"Error translating name (inet_ntop): %s\0A\00"
@.str.5 = [28 x i8] c"Error in getnameinfo(): %s\0A\00"
@stdout = global i32 0
@.str.6 = [36 x i8] c"ipv4: %s -- reverse dns lookup: %s\0A\00"
@AF_INET6 = global i64 0
@INET6_ADDRSTRLEN = global i32 0
@.str.7 = [36 x i8] c"ipv6: %s -- reverse dns lookup: %s\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [80 x i8] c"The system is little-endian (LSB first), the network is big-endian (MSB first).\00"
@str.8 = [51 x i8] c"The system and network are big-endian (MSB first).\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.addrinfo
%4 = alloca %struct.addrinfo*
%5 = alloca [512 x i8]
%6 = alloca [512 x i8]
%7 = icmp eq i32 %0, 2
br i1 %7, label %14, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @EINVAL
store i32 %11, i32* @errno
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
%15 = bitcast %struct.addrinfo* %3 to i8*
%16 = call i32 @memset(%struct.addrinfo* %3, i32 0, i32 32)
%17 = load i32, i32* @SOCK_STREAM
%18 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 3
store i32 %17, i32* %18
%19 = load i64, i64* @AF_UNSPEC
%20 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 0
store i64 %19, i64* %20
%21 = bitcast %struct.addrinfo** %4 to i8*
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @getaddrinfo(i8* %23, i32* null, %struct.addrinfo* %3, %struct.addrinfo** %4)
%25 = icmp eq i32 %24, 0
br i1 %25, label %32, label %26
26: ; preds = %14
%27 = load i32, i32* @stderr
%28 = call i8* @gai_strerror(i32 %24)
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = load i32, i32* @EXIT_FAILURE
%31 = call i32 @exit(i32 %30)
unreachable
32: ; preds = %14
%33 = call i64 (...) @checkEndian()
%34 = icmp eq i64 %33, 0
%35 = select i1 %34, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @str.8, i64 0, i64 0), i8* getelementptr inbounds ([80 x i8], [80 x i8]* @str, i64 0, i64 0)
%36 = call i32 @puts(i8* dereferenceable(1) %35)
%37 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%38 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%39 = load %struct.addrinfo*, %struct.addrinfo** %4
br label %40
40: ; preds = %98, %32
%41 = phi %struct.addrinfo* [ %39, %32 ], [ %103, %98 ]
%42 = icmp eq %struct.addrinfo* %41, null
br i1 %42, label %105, label %43
43: ; preds = %40
%44 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %41, i64 0, i32 2
%45 = load i64, i64* %44
%46 = inttoptr i64 %45 to %struct.sockaddr_in*
%47 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %41, i64 0, i32 0
%48 = load i64, i64* %47
%49 = load i64, i64* @AF_INET
%50 = icmp eq i64 %48, %49
br i1 %50, label %51, label %74
51: ; preds = %43
%52 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %46, i64 0, i32 0
%53 = load i32, i32* @INET_ADDRSTRLEN
%54 = call i32* @inet_ntop(i64 %48, i32* %52, i8* %37, i32 %53)
%55 = icmp eq i32* %54, null
br i1 %55, label %56, label %62
56: ; preds = %51
%57 = load i32, i32* @stderr
%58 = call i8* @strerror(i32 0)
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %58)
%60 = load i32, i32* @EXIT_FAILURE
%61 = call i32 @exit(i32 %60)
unreachable
62: ; preds = %51
%63 = inttoptr i64 %45 to %struct.sockaddr*
%64 = load i32, i32* @INET_ADDRSTRLEN
%65 = call i64 @getnameinfo(%struct.sockaddr* %63, i32 %64, i8* %38, i32 512, i32* null, i32 0, i32 0)
%66 = icmp eq i64 %65, 0
br i1 %66, label %98, label %67
67: ; preds = %62
%68 = load i32, i32* @stderr
%69 = load i32, i32* @errno
%70 = call i8* @gai_strerror(i32 %69)
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %70)
%72 = load i32, i32* @EXIT_FAILURE
%73 = call i32 @exit(i32 %72)
unreachable
74: ; preds = %43
%75 = load i64, i64* @AF_INET6
%76 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %46, i64 0, i32 0
%77 = load i32, i32* @INET6_ADDRSTRLEN
%78 = call i32* @inet_ntop(i64 %75, i32* %76, i8* %37, i32 %77)
%79 = icmp eq i32* %78, null
br i1 %79, label %80, label %86
80: ; preds = %74
%81 = load i32, i32* @stderr
%82 = call i8* @strerror(i32 0)
%83 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %82)
%84 = load i32, i32* @EXIT_FAILURE
%85 = call i32 @exit(i32 %84)
unreachable
86: ; preds = %74
%87 = inttoptr i64 %45 to %struct.sockaddr*
%88 = load i32, i32* @INET6_ADDRSTRLEN
%89 = call i64 @getnameinfo(%struct.sockaddr* %87, i32 %88, i8* %38, i32 512, i32* null, i32 0, i32 0)
%90 = icmp eq i64 %89, 0
br i1 %90, label %98, label %91
91: ; preds = %86
%92 = load i32, i32* @stderr
%93 = load i32, i32* @errno
%94 = call i8* @gai_strerror(i32 %93)
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %94)
%96 = load i32, i32* @EXIT_FAILURE
%97 = call i32 @exit(i32 %96)
unreachable
98: ; preds = %86, %62
%99 = phi i8* [ getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), %62 ], [ getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0), %86 ]
%100 = load i32, i32* @stdout
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* %99, i8* %37, i8* %38)
%102 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %41, i64 0, i32 1
%103 = load %struct.addrinfo*, %struct.addrinfo** %102
%104 = icmp eq %struct.addrinfo* %103, null
br i1 %104, label %105, label %40
105: ; preds = %98, %40
%106 = load %struct.addrinfo*, %struct.addrinfo** %4
%107 = call i32 @freeaddrinfo(%struct.addrinfo* %106)
%108 = load i32, i32* @EXIT_SUCCESS
%109 = call i32 @exit(i32 %108)
unreachable
}