#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 */
typedef struct TYPE_8__ TYPE_2__;
typedef struct TYPE_7__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ u_int;
typedef int /*<<< orphan*/ u_char;
typedef TYPE_1__ *res_state;
typedef int /*<<< orphan*/ buf;
struct TYPE_8__ {
  int rcode;
  int /*<<< orphan*/ arcount;
  int /*<<< orphan*/ nscount;
  int /*<<< orphan*/ ancount;
};
struct TYPE_7__ {
  int options;
  int /*<<< orphan*/ _flags;
};
typedef TYPE_2__ HEADER;

/* Variables and functions */
#define FORMERR 133
int /*<<< orphan*/ HOST_NOT_FOUND;
#define NOERROR 132
#define NOTIMP 131
int /*<<< orphan*/ NO_DATA;
int /*<<< orphan*/ NO_RECOVERY;
#define NXDOMAIN 130
int /*<<< orphan*/ QUERY;
#define REFUSED 129
int RES_DEBUG;
int /*<<< orphan*/ RES_SET_H_ERRNO(TYPE_1__ *, int /*<<< orphan*/);
#define SERVFAIL 128
int /*<<< orphan*/ TRY_AGAIN;
int ntohs(int /*<<< orphan*/);
char *p_rcode(int);
int /*<<< orphan*/ printf(char *, ...);
int res_nmkquery(TYPE_1__ *, int /*<<< orphan*/, char const *, int, int,
                 int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/ *,
                 int /*<<< orphan*/ *, int);
int res_nsend(TYPE_1__ *, int /*<<< orphan*/ *, int, int /*<<< orphan*/ *, int);
int res_nquery(res_state statp, const char *name, int class, int type,
               u_char *answer, int anslen) {
  u_char buf[1024];
  HEADER *hp = (HEADER *)(void *)answer;
  int n;
  u_int oflags;
  oflags = statp->_flags;
again:
  hp->rcode = NOERROR;
  if (statp->options & RES_DEBUG)
    printf(";; res_query(%s, %d, %d)\n", name, class, type);
  n = res_nmkquery(statp, QUERY, name, class, type, NULL, 0, NULL, buf,
                   sizeof(buf));
  if (n <= 0) {
    if (statp->options & RES_DEBUG)
      printf(";; res_query: mkquery failed\n");
    RES_SET_H_ERRNO(statp, NO_RECOVERY);
    return (n);
  }
  n = res_nsend(statp, buf, n, answer, anslen);
  if (n < 0) {
    if (statp->options & RES_DEBUG)
      printf(";; res_query: send error\n");
    RES_SET_H_ERRNO(statp, TRY_AGAIN);
    return (n);
  }
  if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) {
    if (statp->options & RES_DEBUG)
      printf(";; rcode = (%s), counts = an:%d ns:%d ar:%d\n",
             p_rcode(hp->rcode), ntohs(hp->ancount), ntohs(hp->nscount),
             ntohs(hp->arcount));
    switch (hp->rcode) {
    case NXDOMAIN:
      RES_SET_H_ERRNO(statp, HOST_NOT_FOUND);
      break;
    case SERVFAIL:
      RES_SET_H_ERRNO(statp, TRY_AGAIN);
      break;
    case NOERROR:
      RES_SET_H_ERRNO(statp, NO_DATA);
      break;
    case FORMERR:
    case NOTIMP:
    case REFUSED:
    default:
      RES_SET_H_ERRNO(statp, NO_RECOVERY);
      break;
    }
    return (-1);
  }
  return (n);
}


x86 assembly (clang, -O0):
<res_nquery>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1080,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x1038(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x1040(%rbp)
mov    -0x1038(%rbp),%rax
movl   $0x84,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2e35(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11d6 <res_nquery+0x76>
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    0x2dd7(%rip),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
lea    -0x1030(%rbp),%rax
xor    %r9d,%r9d
xor    %r10d,%r10d
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %rax,0x10(%rsp)
movl   $0x1000,0x18(%rsp)
call   1040 <res_nmkquery@plt>
mov    %eax,-0x103c(%rbp)
cmpl   $0x0,-0x103c(%rbp)
jg     1276 <res_nquery+0x116>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2dab(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1256 <res_nquery+0xf6>
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    0x2d67(%rip),%rax
mov    (%rax),%esi
call   1030 <RES_SET_H_ERRNO@plt>
mov    -0x103c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1448 <res_nquery+0x2e8>
mov    -0x10(%rbp),%rdi
lea    -0x1030(%rbp),%rsi
mov    -0x103c(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
call   1070 <res_nsend@plt>
mov    %eax,-0x103c(%rbp)
cmpl   $0x0,-0x103c(%rbp)
jge    12ed <res_nquery+0x18d>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2d34(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     12cd <res_nquery+0x16d>
lea    0xd8a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    0x2cf8(%rip),%rax
mov    (%rax),%esi
call   1030 <RES_SET_H_ERRNO@plt>
mov    -0x103c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1448 <res_nquery+0x2e8>
mov    -0x1038(%rbp),%rax
cmpl   $0x84,(%rax)
jne    1318 <res_nquery+0x1b8>
mov    -0x1038(%rbp),%rax
mov    0xc(%rax),%edi
call   1080 <ntohs@plt>
cmp    $0x0,%eax
jne    143f <res_nquery+0x2df>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2cc3(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     13a2 <res_nquery+0x242>
mov    -0x1038(%rbp),%rax
mov    (%rax),%edi
call   1060 <p_rcode@plt>
mov    %rax,-0x1050(%rbp)
mov    -0x1038(%rbp),%rax
mov    0xc(%rax),%edi
call   1080 <ntohs@plt>
mov    %eax,-0x1048(%rbp)
mov    -0x1038(%rbp),%rax
mov    0x8(%rax),%edi
call   1080 <ntohs@plt>
mov    %eax,-0x1044(%rbp)
mov    -0x1038(%rbp),%rax
mov    0x4(%rax),%edi
call   1080 <ntohs@plt>
mov    -0x1050(%rbp),%rsi
mov    -0x1048(%rbp),%edx
mov    -0x1044(%rbp),%ecx
mov    %eax,%r8d
lea    0xccf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x1038(%rbp),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x1058(%rbp)
sub    $0x5,%eax
ja     1421 <res_nquery+0x2c1>
mov    -0x1058(%rbp),%rax
lea    0xc32(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
mov    0x2bfe(%rip),%rax
mov    (%rax),%esi
call   1030 <RES_SET_H_ERRNO@plt>
jmp    1433 <res_nquery+0x2d3>
mov    -0x10(%rbp),%rdi
mov    0x2bd7(%rip),%rax
mov    (%rax),%esi
call   1030 <RES_SET_H_ERRNO@plt>
jmp    1433 <res_nquery+0x2d3>
mov    -0x10(%rbp),%rdi
mov    0x2bb0(%rip),%rax
mov    (%rax),%esi
call   1030 <RES_SET_H_ERRNO@plt>
jmp    1433 <res_nquery+0x2d3>
jmp    1421 <res_nquery+0x2c1>
mov    -0x10(%rbp),%rdi
mov    0x2b9c(%rip),%rax
mov    (%rax),%esi
call   1030 <RES_SET_H_ERRNO@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1448 <res_nquery+0x2e8>
mov    -0x103c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1080,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<res_nquery>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1008,%rsp
mov    %r9d,%r15d
mov    %r8,%r12
mov    %ecx,%r13d
mov    %edx,%ebx
mov    %rsi,%rbp
mov    %rdi,%r14
movl   $0x84,(%r8)
mov    0x2e48(%rip),%rax
mov    (%rax),%eax
test   %eax,(%rdi)
je     11bc <res_nquery+0x4c>
lea    0xe53(%rip),%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rax
mov    %r14,%rdi
mov    %rbp,%rdx
mov    %ebx,%ecx
mov    %r13d,%r8d
xor    %r9d,%r9d
push   $0x1000
push   %rax
push   $0x0
push   $0x0
call   1040 <res_nmkquery@plt>
add    $0x20,%rsp
mov    %eax,%ebp
test   %eax,%eax
jle    12a0 <res_nquery+0x130>
mov    %rsp,%rsi
mov    %r14,%rdi
mov    %ebp,%edx
mov    %r12,%rcx
mov    %r15d,%r8d
call   1080 <res_nsend@plt>
mov    %eax,%ebp
test   %eax,%eax
js     12c3 <res_nquery+0x153>
cmpl   $0x84,(%r12)
jne    122c <res_nquery+0xbc>
mov    0xc(%r12),%edi
call   1090 <ntohs@plt>
test   %eax,%eax
jne    12f7 <res_nquery+0x187>
mov    0x2db5(%rip),%rax
mov    (%rax),%eax
test   %eax,(%r14)
je     1280 <res_nquery+0x110>
mov    (%r12),%edi
call   1070 <p_rcode@plt>
mov    %rax,%r15
mov    0xc(%r12),%edi
call   1090 <ntohs@plt>
mov    %eax,%ebp
mov    0x8(%r12),%edi
call   1090 <ntohs@plt>
mov    %eax,%ebx
mov    0x4(%r12),%edi
call   1090 <ntohs@plt>
lea    0xdab(%rip),%rdi
mov    %r15,%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%r12),%eax
add    $0xffffff80,%eax
mov    $0xffffffff,%ebp
cmp    $0x4,%eax
ja     12e6 <res_nquery+0x176>
cltq
lea    0x2b3e(%rip),%rcx
mov    (%rcx,%rax,8),%rbx
jmp    12ed <res_nquery+0x17d>
mov    0x2d41(%rip),%rax
mov    (%rax),%eax
mov    0x2d20(%rip),%rbx
test   %eax,(%r14)
je     12ed <res_nquery+0x17d>
lea    0xda4(%rip),%rdi
call   1050 <puts@plt>
jmp    12ed <res_nquery+0x17d>
mov    0x2d1e(%rip),%rax
mov    (%rax),%eax
mov    0x2d05(%rip),%rbx
test   %eax,(%r14)
je     12ed <res_nquery+0x17d>
lea    0xd68(%rip),%rdi
call   1050 <puts@plt>
jmp    12ed <res_nquery+0x17d>
mov    0x2ce3(%rip),%rbx
mov    (%rbx),%esi
mov    %r14,%rdi
call   1030 <RES_SET_H_ERRNO@plt>
mov    %ebp,%eax
add    $0x1008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_7__ = type { i32, i32 }
%struct.TYPE_8__ = type { i32, i32, i32, i32 }
@RES_DEBUG = global i32 0
@.str = [26 x i8] c";; res_query(%s, %d, %d)\0A\00"
@QUERY = global i32 0
@.str.1 = [30 x i8] c";; res_query: mkquery failed\0A\00"
@NO_RECOVERY = global i32 0
@.str.2 = [26 x i8] c";; res_query: send error\0A\00"
@TRY_AGAIN = global i32 0
@.str.3 = [45 x i8] c";; rcode = (%s), counts = an:%d ns:%d ar:%d\0A\00"
@HOST_NOT_FOUND = global i32 0
@NO_DATA = global i32 0
define i32 @res_nquery(%struct.TYPE_7__* %0, i8* %1, i32 %2, i32 %3, i32* %4, i32 %5) {
%7 = alloca i32
%8 = alloca %struct.TYPE_7__*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32
%14 = alloca [1024 x i32]
%15 = alloca %struct.TYPE_8__*
%16 = alloca i32
%17 = alloca i32
store %struct.TYPE_7__* %0, %struct.TYPE_7__** %8
store i8* %1, i8** %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32* %4, i32** %12
store i32 %5, i32* %13
%18 = load i32*, i32** %12
%19 = bitcast i32* %18 to i8*
%20 = bitcast i8* %19 to %struct.TYPE_8__*
store %struct.TYPE_8__* %20, %struct.TYPE_8__** %15
%21 = load %struct.TYPE_7__*, %struct.TYPE_7__** %8
%22 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %21, i32 0, i32 1
%23 = load i32, i32* %22
store i32 %23, i32* %17
br label %24
24: ; preds = %6
%25 = load %struct.TYPE_8__*, %struct.TYPE_8__** %15
%26 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %25, i32 0, i32 0
store i32 132, i32* %26
%27 = load %struct.TYPE_7__*, %struct.TYPE_7__** %8
%28 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %27, i32 0, i32 0
%29 = load i32, i32* %28
%30 = load i32, i32* @RES_DEBUG
%31 = and i32 %29, %30
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %24
%34 = load i8*, i8** %9
%35 = load i32, i32* %10
%36 = load i32, i32* %11
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %34, i32 %35, i32 %36)
br label %38
38: ; preds = %33, %24
%39 = load %struct.TYPE_7__*, %struct.TYPE_7__** %8
%40 = load i32, i32* @QUERY
%41 = load i8*, i8** %9
%42 = load i32, i32* %10
%43 = load i32, i32* %11
%44 = getelementptr inbounds [1024 x i32], [1024 x i32]* %14, i64 0, i64 0
%45 = call i32 @res_nmkquery(%struct.TYPE_7__* %39, i32 %40, i8* %41, i32 %42, i32 %43, i32* null, i32 0, i32* null, i32* %44, i32 4096)
store i32 %45, i32* %16
%46 = load i32, i32* %16
%47 = icmp sle i32 %46, 0
br i1 %47, label %48, label %62
48: ; preds = %38
%49 = load %struct.TYPE_7__*, %struct.TYPE_7__** %8
%50 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %49, i32 0, i32 0
%51 = load i32, i32* %50
%52 = load i32, i32* @RES_DEBUG
%53 = and i32 %51, %52
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %48
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %57
57: ; preds = %55, %48
%58 = load %struct.TYPE_7__*, %struct.TYPE_7__** %8
%59 = load i32, i32* @NO_RECOVERY
%60 = call i32 @RES_SET_H_ERRNO(%struct.TYPE_7__* %58, i32 %59)
%61 = load i32, i32* %16
store i32 %61, i32* %7
br label %145
62: ; preds = %38
%63 = load %struct.TYPE_7__*, %struct.TYPE_7__** %8
%64 = getelementptr inbounds [1024 x i32], [1024 x i32]* %14, i64 0, i64 0
%65 = load i32, i32* %16
%66 = load i32*, i32** %12
%67 = load i32, i32* %13
%68 = call i32 @res_nsend(%struct.TYPE_7__* %63, i32* %64, i32 %65, i32* %66, i32 %67)
store i32 %68, i32* %16
%69 = load i32, i32* %16
%70 = icmp slt i32 %69, 0
br i1 %70, label %71, label %85
71: ; preds = %62
%72 = load %struct.TYPE_7__*, %struct.TYPE_7__** %8
%73 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %72, i32 0, i32 0
%74 = load i32, i32* %73
%75 = load i32, i32* @RES_DEBUG
%76 = and i32 %74, %75
%77 = icmp ne i32 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %71
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %80
80: ; preds = %78, %71
%81 = load %struct.TYPE_7__*, %struct.TYPE_7__** %8
%82 = load i32, i32* @TRY_AGAIN
%83 = call i32 @RES_SET_H_ERRNO(%struct.TYPE_7__* %81, i32 %82)
%84 = load i32, i32* %16
store i32 %84, i32* %7
br label %145
85: ; preds = %62
%86 = load %struct.TYPE_8__*, %struct.TYPE_8__** %15
%87 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %86, i32 0, i32 0
%88 = load i32, i32* %87
%89 = icmp ne i32 %88, 132
br i1 %89, label %96, label %90
90: ; preds = %85
%91 = load %struct.TYPE_8__*, %struct.TYPE_8__** %15
%92 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %91, i32 0, i32 3
%93 = load i32, i32* %92
%94 = call i32 @ntohs(i32 %93)
%95 = icmp eq i32 %94, 0
br i1 %95, label %96, label %143
96: ; preds = %90, %85
%97 = load %struct.TYPE_7__*, %struct.TYPE_7__** %8
%98 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %97, i32 0, i32 0
%99 = load i32, i32* %98
%100 = load i32, i32* @RES_DEBUG
%101 = and i32 %99, %100
%102 = icmp ne i32 %101, 0
br i1 %102, label %103, label %121
103: ; preds = %96
%104 = load %struct.TYPE_8__*, %struct.TYPE_8__** %15
%105 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %104, i32 0, i32 0
%106 = load i32, i32* %105
%107 = call i8* @p_rcode(i32 %106)
%108 = load %struct.TYPE_8__*, %struct.TYPE_8__** %15
%109 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %108, i32 0, i32 3
%110 = load i32, i32* %109
%111 = call i32 @ntohs(i32 %110)
%112 = load %struct.TYPE_8__*, %struct.TYPE_8__** %15
%113 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %112, i32 0, i32 2
%114 = load i32, i32* %113
%115 = call i32 @ntohs(i32 %114)
%116 = load %struct.TYPE_8__*, %struct.TYPE_8__** %15
%117 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %116, i32 0, i32 1
%118 = load i32, i32* %117
%119 = call i32 @ntohs(i32 %118)
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i8* %107, i32 %111, i32 %115, i32 %119)
br label %121
121: ; preds = %103, %96
%122 = load %struct.TYPE_8__*, %struct.TYPE_8__** %15
%123 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %122, i32 0, i32 0
%124 = load i32, i32* %123
switch i32 %124, label %138 [
i32 130, label %125
i32 128, label %129
i32 132, label %133
i32 133, label %137
i32 131, label %137
i32 129, label %137
]
125: ; preds = %121
%126 = load %struct.TYPE_7__*, %struct.TYPE_7__** %8
%127 = load i32, i32* @HOST_NOT_FOUND
%128 = call i32 @RES_SET_H_ERRNO(%struct.TYPE_7__* %126, i32 %127)
br label %142
129: ; preds = %121
%130 = load %struct.TYPE_7__*, %struct.TYPE_7__** %8
%131 = load i32, i32* @TRY_AGAIN
%132 = call i32 @RES_SET_H_ERRNO(%struct.TYPE_7__* %130, i32 %131)
br label %142
133: ; preds = %121
%134 = load %struct.TYPE_7__*, %struct.TYPE_7__** %8
%135 = load i32, i32* @NO_DATA
%136 = call i32 @RES_SET_H_ERRNO(%struct.TYPE_7__* %134, i32 %135)
br label %142
137: ; preds = %121, %121, %121
br label %138
138: ; preds = %121, %137
%139 = load %struct.TYPE_7__*, %struct.TYPE_7__** %8
%140 = load i32, i32* @NO_RECOVERY
%141 = call i32 @RES_SET_H_ERRNO(%struct.TYPE_7__* %139, i32 %140)
br label %142
142: ; preds = %138, %133, %129, %125
store i32 -1, i32* %7
br label %145
143: ; preds = %90
%144 = load i32, i32* %16
store i32 %144, i32* %7
br label %145
145: ; preds = %143, %142, %80, %57
%146 = load i32, i32* %7
ret i32 %146
}

LLVM IR (-O2):
%struct.TYPE_7__ = type { i32, i32 }
@RES_DEBUG = global i32 0
@.str = [26 x i8] c";; res_query(%s, %d, %d)\0A\00"
@QUERY = global i32 0
@NO_RECOVERY = global i32 0
@TRY_AGAIN = global i32 0
@.str.3 = [45 x i8] c";; rcode = (%s), counts = an:%d ns:%d ar:%d\0A\00"
@HOST_NOT_FOUND = global i32 0
@NO_DATA = global i32 0
@str = [25 x i8] c";; res_query: send error\00"
@str.4 = [29 x i8] c";; res_query: mkquery failed\00"
@switch.table.res_nquery = [5 x i32*] [i32* @TRY_AGAIN, i32* @NO_RECOVERY, i32* @HOST_NOT_FOUND, i32* @NO_RECOVERY, i32* @NO_DATA]
define i32 @res_nquery(%struct.TYPE_7__* %0, i8* %1, i32 %2, i32 %3, i32* %4, i32 %5) {
%7 = alloca [1024 x i32]
%8 = bitcast [1024 x i32]* %7 to i8*
store i32 132, i32* %4
%9 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %0, i64 0, i32 0
%10 = load i32, i32* %9
%11 = load i32, i32* @RES_DEBUG
%12 = and i32 %11, %10
%13 = icmp eq i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %6
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %2, i32 %3)
br label %16
16: ; preds = %14, %6
%17 = load i32, i32* @QUERY
%18 = getelementptr inbounds [1024 x i32], [1024 x i32]* %7, i64 0, i64 0
%19 = call i32 @res_nmkquery(%struct.TYPE_7__* %0, i32 %17, i8* %1, i32 %2, i32 %3, i32* null, i32 0, i32* null, i32* %18, i32 4096)
%20 = icmp slt i32 %19, 1
br i1 %20, label %21, label %28
21: ; preds = %16
%22 = load i32, i32* %9
%23 = load i32, i32* @RES_DEBUG
%24 = and i32 %23, %22
%25 = icmp eq i32 %24, 0
br i1 %25, label %72, label %26
26: ; preds = %21
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.4, i64 0, i64 0))
br label %72
28: ; preds = %16
%29 = call i32 @res_nsend(%struct.TYPE_7__* %0, i32* %18, i32 %19, i32* %4, i32 %5)
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %38
31: ; preds = %28
%32 = load i32, i32* %9
%33 = load i32, i32* @RES_DEBUG
%34 = and i32 %33, %32
%35 = icmp eq i32 %34, 0
br i1 %35, label %72, label %36
36: ; preds = %31
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %72
38: ; preds = %28
%39 = load i32, i32* %4
%40 = icmp eq i32 %39, 132
br i1 %40, label %41, label %46
41: ; preds = %38
%42 = getelementptr inbounds i32, i32* %4, i64 3
%43 = load i32, i32* %42
%44 = call i32 @ntohs(i32 %43)
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %77
46: ; preds = %41, %38
%47 = load i32, i32* %9
%48 = load i32, i32* @RES_DEBUG
%49 = and i32 %48, %47
%50 = icmp eq i32 %49, 0
br i1 %50, label %64, label %51
51: ; preds = %46
%52 = load i32, i32* %4
%53 = call i8* @p_rcode(i32 %52)
%54 = getelementptr inbounds i32, i32* %4, i64 3
%55 = load i32, i32* %54
%56 = call i32 @ntohs(i32 %55)
%57 = getelementptr inbounds i32, i32* %4, i64 2
%58 = load i32, i32* %57
%59 = call i32 @ntohs(i32 %58)
%60 = getelementptr inbounds i32, i32* %4, i64 1
%61 = load i32, i32* %60
%62 = call i32 @ntohs(i32 %61)
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i8* %53, i32 %56, i32 %59, i32 %62)
br label %64
64: ; preds = %51, %46
%65 = load i32, i32* %4
%66 = add i32 %65, -128
%67 = icmp ult i32 %66, 5
br i1 %67, label %68, label %72
68: ; preds = %64
%69 = sext i32 %66 to i64
%70 = getelementptr inbounds [5 x i32*], [5 x i32*]* @switch.table.res_nquery, i64 0, i64 %69
%71 = load i32*, i32** %70
br label %72
72: ; preds = %64, %68, %31, %36, %21, %26
%73 = phi i32* [ @NO_RECOVERY, %26 ], [ @NO_RECOVERY, %21 ], [ @TRY_AGAIN, %36 ], [ @TRY_AGAIN, %31 ], [ %71, %68 ], [ @NO_RECOVERY, %64 ]
%74 = phi i32 [ %19, %26 ], [ %19, %21 ], [ %29, %36 ], [ %29, %31 ], [ -1, %68 ], [ -1, %64 ]
%75 = load i32, i32* %73
%76 = call i32 @RES_SET_H_ERRNO(%struct.TYPE_7__* %0, i32 %75)
br label %77
77: ; preds = %72, %41
%78 = phi i32 [ %29, %41 ], [ %74, %72 ]
ret i32 %78
}