#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 in_addr {
  unsigned char s_addr;
};
typedef int /*<<< orphan*/ ns_rr;
typedef int /*<<< orphan*/ ns_msg;
typedef int /*<<< orphan*/ name;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int NS_PACKETSZ;
int dn_expand(int /*<<< orphan*/, int /*<<< orphan*/, unsigned char *, char *,
              int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
char *inet_ntoa(struct in_addr);
int /*<<< orphan*/ ns_c_in;
scalar_t__ ns_initparse(unsigned char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ ns_msg_base(int /*<<< orphan*/);
int ns_msg_count(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ ns_msg_end(int /*<<< orphan*/);
scalar_t__ ns_parserr(int /*<<< orphan*/ *, int /*<<< orphan*/, int,
                      int /*<<< orphan*/ *);
char *ns_rr_name(int /*<<< orphan*/);
unsigned char *ns_rr_rdata(int /*<<< orphan*/);
scalar_t__ ns_rr_type(int /*<<< orphan*/);
int /*<<< orphan*/ ns_s_an;
int /*<<< orphan*/ ns_s_ar;
scalar_t__ ns_t_a;
scalar_t__ ns_t_srv;
int /*<<< orphan*/ printf(char *, ...);
int res_query(char *, int /*<<< orphan*/, scalar_t__, unsigned char *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  unsigned char buffer[NS_PACKETSZ];
  int resp_len;
  ns_msg h;
  ns_rr rr;
  int rrnum;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s <hostname>\n", argv[0]);
    exit(1);
  }
  if ((resp_len =
           res_query(argv[1], ns_c_in, ns_t_srv, buffer, sizeof(buffer))) < 0) {
    fprintf(stderr, "Query for %s failed!\n", argv[1]);
    exit(1);
  }
  if (ns_initparse(buffer, resp_len, &h)) {
    fprintf(stderr, "Failed to parse response buffer!\n");
    exit(2);
  }
  printf("%d records returned in the answer section.\n",
         ns_msg_count(h, ns_s_an));
  for (rrnum = 0; rrnum < ns_msg_count(h, ns_s_an); rrnum++) {
    if (ns_parserr(&h, ns_s_an, rrnum, &rr)) {
      fprintf(stderr, "ns_parserr: %s\n", strerror(errno));
      exit(2);
    }
    if (ns_rr_type(rr) == ns_t_srv) {
      char name[1024];
      int ret;
      struct in_addr ip;
      const unsigned char *p;
      ret = dn_expand(ns_msg_base(h), ns_msg_end(h), ns_rr_rdata(rr) + 6, name,
                      sizeof(name));
      if (ret < 0) {
        fprintf(stderr, "Failed to uncompress name (%d)!\n", ret);
        exit(2);
      }
      printf("%s\n", name);
    }
  }
  for (rrnum = 0; rrnum < ns_msg_count(h, ns_s_ar); rrnum++) {
    if (ns_parserr(&h, ns_s_ar, rrnum, &rr)) {
      fprintf(stderr, "ns_parserr: %s\n", strerror(errno));
      continue;
    }
    if (ns_rr_type(rr) == ns_t_a) {
      char name[1024];
      int ret;
      struct in_addr ip;
      const unsigned char *p;
      p = ns_rr_rdata(rr);
      ip.s_addr = (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0];
      printf("%s has address %s\n", ns_rr_name(rr), inet_ntoa(ip));
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x880,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2d98(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x860(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x858(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1271 <main+0x81>
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xda0(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x858(%rbp),%rcx
mov    -0x860(%rbp),%rax
mov    -0x10(%rbp),%rdx
mov    0x8(%rdx),%rdi
mov    0x2d4a(%rip),%rdx
mov    (%rdx),%esi
mov    0x2d51(%rip),%rdx
mov    (%rdx),%rdx
mov    %eax,%r8d
call   10f0 <res_query@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    12d7 <main+0xe7>
mov    0x2d13(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd50(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x858(%rbp),%rdi
mov    -0x24(%rbp),%esi
lea    -0x28(%rbp),%rdx
call   1030 <ns_initparse@plt>
cmp    $0x0,%rax
je     1315 <main+0x125>
mov    0x2ccd(%rip),%rax
mov    (%rax),%edi
lea    0xd28(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x2,%edi
call   1100 <exit@plt>
mov    -0x28(%rbp),%edi
mov    0x2c91(%rip),%rax
mov    (%rax),%esi
call   1040 <ns_msg_count@plt>
mov    %eax,%esi
lea    0xd1f(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x864(%rbp)
mov    -0x28(%rbp),%edi
mov    0x2c60(%rip),%rax
mov    (%rax),%esi
call   1040 <ns_msg_count@plt>
mov    %eax,%ecx
mov    -0x864(%rbp),%eax
cmp    %ecx,%eax
jge    148b <main+0x29b>
mov    0x2c42(%rip),%rax
mov    (%rax),%esi
mov    -0x30(%rbp),%edx
lea    -0x28(%rbp),%rdi
lea    -0x2c(%rbp),%rcx
call   1050 <ns_parserr@plt>
cmp    $0x0,%rax
je     13c8 <main+0x1d8>
mov    0x2c37(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x868(%rbp)
mov    0x2c20(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x868(%rbp),%edi
mov    %rax,%rdx
lea    0xcc3(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x2,%edi
call   1100 <exit@plt>
mov    -0x2c(%rbp),%edi
call   10b0 <ns_rr_type@plt>
mov    0x2c11(%rip),%rcx
cmp    (%rcx),%rax
jne    1478 <main+0x288>
mov    -0x28(%rbp),%edi
call   10d0 <ns_msg_base@plt>
mov    %eax,-0x870(%rbp)
mov    -0x28(%rbp),%edi
call   1060 <ns_msg_end@plt>
mov    %eax,-0x86c(%rbp)
mov    -0x2c(%rbp),%edi
call   10a0 <ns_rr_rdata@plt>
mov    -0x870(%rbp),%edi
mov    -0x86c(%rbp),%esi
mov    %rax,%rdx
add    $0x6,%rdx
lea    -0x430(%rbp),%rcx
mov    $0x400,%r8d
call   10c0 <dn_expand@plt>
mov    %eax,-0x434(%rbp)
cmpl   $0x0,-0x434(%rbp)
jge    1463 <main+0x273>
mov    0x2b85(%rip),%rax
mov    (%rax),%edi
mov    -0x434(%rbp),%edx
lea    0xc38(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x2,%edi
call   1100 <exit@plt>
lea    -0x430(%rbp),%rsi
lea    0xc15(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    147d <main+0x28d>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    133d <main+0x14d>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x874(%rbp)
mov    -0x28(%rbp),%edi
mov    0x2b13(%rip),%rax
mov    (%rax),%esi
call   1040 <ns_msg_count@plt>
mov    %eax,%ecx
mov    -0x874(%rbp),%eax
cmp    %ecx,%eax
jge    15c5 <main+0x3d5>
mov    0x2af5(%rip),%rax
mov    (%rax),%esi
mov    -0x30(%rbp),%edx
lea    -0x28(%rbp),%rdi
lea    -0x2c(%rbp),%rcx
call   1050 <ns_parserr@plt>
cmp    $0x0,%rax
je     1518 <main+0x328>
mov    0x2ae2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x878(%rbp)
mov    0x2acb(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
mov    -0x878(%rbp),%edi
mov    %rax,%rdx
lea    0xb6e(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    15b7 <main+0x3c7>
mov    -0x2c(%rbp),%edi
call   10b0 <ns_rr_type@plt>
mov    0x2ab9(%rip),%rcx
cmp    (%rcx),%rax
jne    15b2 <main+0x3c2>
mov    -0x2c(%rbp),%edi
call   10a0 <ns_rr_rdata@plt>
mov    %rax,-0x850(%rbp)
mov    -0x850(%rbp),%rax
movzbl 0x3(%rax),%eax
shl    $0x18,%eax
mov    -0x850(%rbp),%rcx
movzbl 0x2(%rcx),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x850(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x850(%rbp),%rcx
movzbl (%rcx),%ecx
or     %ecx,%eax
mov    %al,-0x848(%rbp)
mov    -0x2c(%rbp),%edi
call   10e0 <ns_rr_name@plt>
mov    %rax,-0x880(%rbp)
movzbl -0x848(%rbp),%edi
call   1070 <inet_ntoa@plt>
mov    -0x880(%rbp),%rsi
mov    %rax,%rdx
lea    0xb00(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    15b7 <main+0x3c7>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1492 <main+0x2a2>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rsi,%r14
mov    0x2d8a(%rip),%rax
mov    (%rax),%r8d
mov    %rsp,%rbx
lea    0xf(%r8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
cmp    $0x2,%edi
jne    149a <main+0x29a>
mov    0x8(%r14),%rdi
mov    0x2d92(%rip),%rax
mov    (%rax),%esi
mov    0x2d99(%rip),%r13
mov    0x0(%r13),%rdx
mov    %rbx,%rcx
call   1100 <res_query@plt>
test   %eax,%eax
js     14af <main+0x2af>
lea    -0x2c(%rbp),%rdx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <ns_initparse@plt>
test   %rax,%rax
jne    14d4 <main+0x2d4>
mov    -0x2c(%rbp),%edi
mov    0x2d2c(%rip),%r15
mov    (%r15),%esi
call   1040 <ns_msg_count@plt>
lea    0xdbb(%rip),%rdi
xor    %ebx,%ebx
mov    %eax,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    -0x2c(%rbp),%edi
mov    (%r15),%esi
call   1040 <ns_msg_count@plt>
test   %eax,%eax
jle    134f <main+0x14f>
lea    -0x2c(%rbp),%r14
lea    -0x30(%rbp),%r12
jmp    12d2 <main+0xd2>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
mov    -0x2c(%rbp),%edi
mov    (%r15),%esi
call   1040 <ns_msg_count@plt>
cmp    %eax,%ebx
jge    134f <main+0x14f>
mov    (%r15),%esi
mov    %r14,%rdi
mov    %ebx,%edx
mov    %r12,%rcx
call   1050 <ns_parserr@plt>
test   %rax,%rax
jne    1443 <main+0x243>
mov    -0x30(%rbp),%edi
call   10c0 <ns_rr_type@plt>
cmp    0x0(%r13),%rax
jne    12c0 <main+0xc0>
mov    -0x2c(%rbp),%edi
call   10e0 <ns_msg_base@plt>
mov    %eax,%r12d
mov    -0x2c(%rbp),%edi
call   1070 <ns_msg_end@plt>
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%edi
call   10b0 <ns_rr_rdata@plt>
lea    0x6(%rax),%rdx
mov    %r12d,%edi
mov    -0x34(%rbp),%esi
lea    -0x440(%rbp),%r12
mov    %r12,%rcx
mov    $0x400,%r8d
call   10d0 <dn_expand@plt>
test   %eax,%eax
js     1477 <main+0x277>
mov    %r12,%rdi
call   1060 <puts@plt>
lea    -0x30(%rbp),%r12
jmp    12c0 <main+0xc0>
mov    -0x2c(%rbp),%edi
mov    0x2c5f(%rip),%r14
mov    (%r14),%esi
call   1040 <ns_msg_count@plt>
test   %eax,%eax
jle    1432 <main+0x232>
lea    -0x2c(%rbp),%r12
lea    -0x30(%rbp),%r13
xor    %ebx,%ebx
jmp    13be <main+0x1be>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x2c41(%rip),%rax
mov    (%rax),%r15d
mov    0x2c2f(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    %r15d,%edi
lea    0xcd8(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
add    $0x1,%ebx
mov    -0x2c(%rbp),%edi
mov    (%r14),%esi
call   1040 <ns_msg_count@plt>
cmp    %eax,%ebx
jge    1432 <main+0x232>
mov    (%r14),%esi
mov    %r12,%rdi
mov    %ebx,%edx
mov    %r13,%rcx
call   1050 <ns_parserr@plt>
test   %rax,%rax
jne    1380 <main+0x180>
mov    -0x30(%rbp),%edi
call   10c0 <ns_rr_type@plt>
mov    0x2bfe(%rip),%rcx
cmp    (%rcx),%rax
jne    13ac <main+0x1ac>
mov    -0x30(%rbp),%edi
call   10b0 <ns_rr_rdata@plt>
mov    -0x30(%rbp),%edi
movzbl (%rax),%r15d
call   10f0 <ns_rr_name@plt>
mov    %r13,%r14
mov    %r12,%r13
mov    %rax,%r12
mov    %r15d,%edi
call   1080 <inet_ntoa@plt>
lea    0xc98(%rip),%rdi
mov    %r12,%rsi
mov    %r13,%r12
mov    %r14,%r13
mov    0x2b95(%rip),%r14
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <printf@plt>
jmp    13ac <main+0x1ac>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b7e(%rip),%rax
mov    (%rax),%ebx
mov    0x2b6d(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xc19(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x2,%edi
call   1110 <exit@plt>
mov    0x2b4a(%rip),%rcx
mov    (%rcx),%edi
lea    0xc03(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x2,%edi
call   1110 <exit@plt>
mov    0x2b27(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xb53(%rip),%rsi
jmp    14c3 <main+0x2c3>
mov    0x2b12(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r14),%rdx
lea    0xb53(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x2aed(%rip),%rax
mov    (%rax),%edi
lea    0xb48(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x2,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.in_addr = type { i8 }
@NS_PACKETSZ = global i32 0
@stderr = global i32 0
@.str = [22 x i8] c"Usage: %s <hostname>\0A\00"
@ns_c_in = global i32 0
@ns_t_srv = global i64 0
@.str.1 = [22 x i8] c"Query for %s failed!\0A\00"
@.str.2 = [34 x i8] c"Failed to parse response buffer!\0A\00"
@.str.3 = [44 x i8] c"%d records returned in the answer section.\0A\00"
@ns_s_an = global i32 0
@.str.4 = [16 x i8] c"ns_parserr: %s\0A\00"
@errno = global i32 0
@.str.5 = [33 x i8] c"Failed to uncompress name (%d)!\0A\00"
@.str.6 = [4 x i8] c"%s\0A\00"
@ns_s_ar = global i32 0
@ns_t_a = global i64 0
@.str.7 = [19 x i8] c"%s has address %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [1024 x i8]
%13 = alloca i32
%14 = alloca %struct.in_addr
%15 = alloca i8*
%16 = alloca [1024 x i8]
%17 = alloca i32
%18 = alloca %struct.in_addr
%19 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = load i32, i32* @NS_PACKETSZ
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
store i8* %22, i8** %6
%23 = alloca i8, i64 %21
store i64 %21, i64* %7
%24 = load i32, i32* %4
%25 = icmp ne i32 %24, 2
br i1 %25, label %26, label %33
26: ; preds = %2
%27 = load i32, i32* @stderr
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %30)
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %2
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = load i32, i32* @ns_c_in
%38 = load i64, i64* @ns_t_srv
%39 = trunc i64 %21 to i32
%40 = call i32 @res_query(i8* %36, i32 %37, i64 %38, i8* %23, i32 %39)
store i32 %40, i32* %8
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %49
42: ; preds = %33
%43 = load i32, i32* @stderr
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 1
%46 = load i8*, i8** %45
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %46)
%48 = call i32 @exit(i32 1)
unreachable
49: ; preds = %33
%50 = load i32, i32* %8
%51 = call i64 @ns_initparse(i8* %23, i32 %50, i32* %9)
%52 = icmp ne i64 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %49
%54 = load i32, i32* @stderr
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%56 = call i32 @exit(i32 2)
unreachable
57: ; preds = %49
%58 = load i32, i32* %9
%59 = load i32, i32* @ns_s_an
%60 = call i32 @ns_msg_count(i32 %58, i32 %59)
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 %60)
store i32 0, i32* %11
br label %62
62: ; preds = %105, %57
%63 = load i32, i32* %11
%64 = load i32, i32* %9
%65 = load i32, i32* @ns_s_an
%66 = call i32 @ns_msg_count(i32 %64, i32 %65)
%67 = icmp slt i32 %63, %66
br i1 %67, label %68, label %108
68: ; preds = %62
%69 = load i32, i32* @ns_s_an
%70 = load i32, i32* %11
%71 = call i64 @ns_parserr(i32* %9, i32 %69, i32 %70, i32* %10)
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %79
73: ; preds = %68
%74 = load i32, i32* @stderr
%75 = load i32, i32* @errno
%76 = call i8* @strerror(i32 %75)
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %76)
%78 = call i32 @exit(i32 2)
unreachable
79: ; preds = %68
%80 = load i32, i32* %10
%81 = call i64 @ns_rr_type(i32 %80)
%82 = load i64, i64* @ns_t_srv
%83 = icmp eq i64 %81, %82
br i1 %83, label %84, label %104
84: ; preds = %79
%85 = load i32, i32* %9
%86 = call i32 @ns_msg_base(i32 %85)
%87 = load i32, i32* %9
%88 = call i32 @ns_msg_end(i32 %87)
%89 = load i32, i32* %10
%90 = call i8* @ns_rr_rdata(i32 %89)
%91 = getelementptr inbounds i8, i8* %90, i64 6
%92 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%93 = call i32 @dn_expand(i32 %86, i32 %88, i8* %91, i8* %92, i32 1024)
store i32 %93, i32* %13
%94 = load i32, i32* %13
%95 = icmp slt i32 %94, 0
br i1 %95, label %96, label %101
96: ; preds = %84
%97 = load i32, i32* @stderr
%98 = load i32, i32* %13
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i32 %98)
%100 = call i32 @exit(i32 2)
unreachable
101: ; preds = %84
%102 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %102)
br label %104
104: ; preds = %101, %79
br label %105
105: ; preds = %104
%106 = load i32, i32* %11
%107 = add nsw i32 %106, 1
store i32 %107, i32* %11
br label %62
108: ; preds = %62
store i32 0, i32* %11
br label %109
109: ; preds = %164, %108
%110 = load i32, i32* %11
%111 = load i32, i32* %9
%112 = load i32, i32* @ns_s_ar
%113 = call i32 @ns_msg_count(i32 %111, i32 %112)
%114 = icmp slt i32 %110, %113
br i1 %114, label %115, label %167
115: ; preds = %109
%116 = load i32, i32* @ns_s_ar
%117 = load i32, i32* %11
%118 = call i64 @ns_parserr(i32* %9, i32 %116, i32 %117, i32* %10)
%119 = icmp ne i64 %118, 0
br i1 %119, label %120, label %125
120: ; preds = %115
%121 = load i32, i32* @stderr
%122 = load i32, i32* @errno
%123 = call i8* @strerror(i32 %122)
%124 = call i32 (i32, i8*, ...) @fprintf(i32 %121, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %123)
br label %164
125: ; preds = %115
%126 = load i32, i32* %10
%127 = call i64 @ns_rr_type(i32 %126)
%128 = load i64, i64* @ns_t_a
%129 = icmp eq i64 %127, %128
br i1 %129, label %130, label %163
130: ; preds = %125
%131 = load i32, i32* %10
%132 = call i8* @ns_rr_rdata(i32 %131)
store i8* %132, i8** %19
%133 = load i8*, i8** %19
%134 = getelementptr inbounds i8, i8* %133, i64 3
%135 = load i8, i8* %134
%136 = zext i8 %135 to i32
%137 = shl i32 %136, 24
%138 = load i8*, i8** %19
%139 = getelementptr inbounds i8, i8* %138, i64 2
%140 = load i8, i8* %139
%141 = zext i8 %140 to i32
%142 = shl i32 %141, 16
%143 = or i32 %137, %142
%144 = load i8*, i8** %19
%145 = getelementptr inbounds i8, i8* %144, i64 1
%146 = load i8, i8* %145
%147 = zext i8 %146 to i32
%148 = shl i32 %147, 8
%149 = or i32 %143, %148
%150 = load i8*, i8** %19
%151 = getelementptr inbounds i8, i8* %150, i64 0
%152 = load i8, i8* %151
%153 = zext i8 %152 to i32
%154 = or i32 %149, %153
%155 = trunc i32 %154 to i8
%156 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %18, i32 0, i32 0
store i8 %155, i8* %156
%157 = load i32, i32* %10
%158 = call i8* @ns_rr_name(i32 %157)
%159 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %18, i32 0, i32 0
%160 = load i8, i8* %159
%161 = call i8* @inet_ntoa(i8 %160)
%162 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %158, i8* %161)
br label %163
163: ; preds = %130, %125
br label %164
164: ; preds = %163, %120
%165 = load i32, i32* %11
%166 = add nsw i32 %165, 1
store i32 %166, i32* %11
br label %109
167: ; preds = %109
store i32 0, i32* %3
%168 = load i8*, i8** %6
%169 = load i32, i32* %3
ret i32 %169
}

LLVM IR (-O2):
@NS_PACKETSZ = global i32 0
@stderr = global i32 0
@.str = [22 x i8] c"Usage: %s <hostname>\0A\00"
@ns_c_in = global i32 0
@ns_t_srv = global i64 0
@.str.1 = [22 x i8] c"Query for %s failed!\0A\00"
@.str.2 = [34 x i8] c"Failed to parse response buffer!\0A\00"
@.str.3 = [44 x i8] c"%d records returned in the answer section.\0A\00"
@ns_s_an = global i32 0
@.str.4 = [16 x i8] c"ns_parserr: %s\0A\00"
@errno = global i32 0
@.str.5 = [33 x i8] c"Failed to uncompress name (%d)!\0A\00"
@ns_s_ar = global i32 0
@ns_t_a = global i64 0
@.str.7 = [19 x i8] c"%s has address %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [1024 x i8]
%6 = load i32, i32* @NS_PACKETSZ
%7 = zext i32 %6 to i64
%8 = alloca i8, i64 %7
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = icmp eq i32 %0, 2
br i1 %11, label %17, label %12
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %1
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = load i32, i32* @ns_c_in
%21 = load i64, i64* @ns_t_srv
%22 = call i32 @res_query(i8* %19, i32 %20, i64 %21, i8* %8, i32 %6)
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %17
%25 = load i32, i32* @stderr
%26 = load i8*, i8** %18
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %17
%30 = call i64 @ns_initparse(i8* %8, i32 %22, i32* %3)
%31 = icmp eq i64 %30, 0
br i1 %31, label %36, label %32
32: ; preds = %29
%33 = load i32, i32* @stderr
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%35 = call i32 @exit(i32 2)
unreachable
36: ; preds = %29
%37 = load i32, i32* %3
%38 = load i32, i32* @ns_s_an
%39 = call i32 @ns_msg_count(i32 %37, i32 %38)
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %3
%42 = load i32, i32* @ns_s_an
%43 = call i32 @ns_msg_count(i32 %41, i32 %42)
%44 = icmp sgt i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %36
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
br label %52
47: ; preds = %84, %36
%48 = load i32, i32* %3
%49 = load i32, i32* @ns_s_ar
%50 = call i32 @ns_msg_count(i32 %48, i32 %49)
%51 = icmp sgt i32 %50, 0
br i1 %51, label %90, label %119
52: ; preds = %45, %84
%53 = phi i32 [ 0, %45 ], [ %85, %84 ]
%54 = load i32, i32* @ns_s_an
%55 = call i64 @ns_parserr(i32* %3, i32 %54, i32 %53, i32* %4)
%56 = icmp eq i64 %55, 0
br i1 %56, label %63, label %57
57: ; preds = %52
%58 = load i32, i32* @stderr
%59 = load i32, i32* @errno
%60 = call i8* @strerror(i32 %59)
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %60)
%62 = call i32 @exit(i32 2)
unreachable
63: ; preds = %52
%64 = load i32, i32* %4
%65 = call i64 @ns_rr_type(i32 %64)
%66 = load i64, i64* @ns_t_srv
%67 = icmp eq i64 %65, %66
br i1 %67, label %68, label %84
68: ; preds = %63
%69 = load i32, i32* %3
%70 = call i32 @ns_msg_base(i32 %69)
%71 = load i32, i32* %3
%72 = call i32 @ns_msg_end(i32 %71)
%73 = load i32, i32* %4
%74 = call i8* @ns_rr_rdata(i32 %73)
%75 = getelementptr inbounds i8, i8* %74, i64 6
%76 = call i32 @dn_expand(i32 %70, i32 %72, i8* %75, i8* %46, i32 1024)
%77 = icmp slt i32 %76, 0
br i1 %77, label %78, label %82
78: ; preds = %68
%79 = load i32, i32* @stderr
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i32 %76)
%81 = call i32 @exit(i32 2)
unreachable
82: ; preds = %68
%83 = call i32 @puts(i8* %46)
br label %84
84: ; preds = %63, %82
%85 = add nuw nsw i32 %53, 1
%86 = load i32, i32* %3
%87 = load i32, i32* @ns_s_an
%88 = call i32 @ns_msg_count(i32 %86, i32 %87)
%89 = icmp slt i32 %85, %88
br i1 %89, label %52, label %47
90: ; preds = %47, %113
%91 = phi i32 [ %114, %113 ], [ 0, %47 ]
%92 = load i32, i32* @ns_s_ar
%93 = call i64 @ns_parserr(i32* %3, i32 %92, i32 %91, i32* %4)
%94 = icmp eq i64 %93, 0
br i1 %94, label %100, label %95
95: ; preds = %90
%96 = load i32, i32* @stderr
%97 = load i32, i32* @errno
%98 = call i8* @strerror(i32 %97)
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %98)
br label %113
100: ; preds = %90
%101 = load i32, i32* %4
%102 = call i64 @ns_rr_type(i32 %101)
%103 = load i64, i64* @ns_t_a
%104 = icmp eq i64 %102, %103
br i1 %104, label %105, label %113
105: ; preds = %100
%106 = load i32, i32* %4
%107 = call i8* @ns_rr_rdata(i32 %106)
%108 = load i8, i8* %107
%109 = load i32, i32* %4
%110 = call i8* @ns_rr_name(i32 %109)
%111 = call i8* @inet_ntoa(i8 %108)
%112 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i8* %110, i8* %111)
br label %113
113: ; preds = %100, %105, %95
%114 = add nuw nsw i32 %91, 1
%115 = load i32, i32* %3
%116 = load i32, i32* @ns_s_ar
%117 = call i32 @ns_msg_count(i32 %115, i32 %116)
%118 = icmp slt i32 %114, %117
br i1 %118, label %90, label %119
119: ; preds = %113, %47
ret i32 0
}