#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_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ u_char;
typedef int /*<<< orphan*/ buf;
struct TYPE_4__ {
  int options;
};
struct TYPE_3__ {
  int rcode;
  int /*<<< orphan*/ ancount;
};
typedef TYPE_1__ HEADER;

/* Variables and functions */
#define FORMERR 133
int /*<<< orphan*/ HOST_NOT_FOUND;
int /*<<< orphan*/ NETDB_INTERNAL;
#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 RES_INIT;
#define SERVFAIL 128
int /*<<< orphan*/ TRY_AGAIN;
TYPE_2__ _res;
int /*<<< orphan*/ h_errno;
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int res_init();
int res_mkquery(int /*<<< orphan*/, char const *, int, int,
                int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/ *,
                int /*<<< orphan*/ *, int);
int res_send(int /*<<< orphan*/ *, int, int /*<<< orphan*/ *, int);
int res_query(const char *name, int class, int type, u_char *answer,
              int anslen) {
  u_char buf[1024];
  HEADER *hp = (HEADER *)answer;
  int n;
  hp->rcode = NOERROR;
  if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
    h_errno = NETDB_INTERNAL;
    return (-1);
  }
  if (_res.options & RES_DEBUG)
    printf(";; res_query(%s, %d, %d)\n", name, class, type);
  n = res_mkquery(QUERY, name, class, type, NULL, 0, NULL, buf, sizeof(buf));
  if (n <= 0) {
    if (_res.options & RES_DEBUG)
      printf(";; res_query: mkquery failed\n");
    h_errno = NO_RECOVERY;
    return (n);
  }
  n = res_send(buf, n, answer, anslen);
  if (n < 0) {
    if (_res.options & RES_DEBUG)
      printf(";; res_query: send error\n");
    h_errno = TRY_AGAIN;
    return (n);
  }
  if (hp->rcode != NOERROR || ntohs(hp->ancount) == 0) {
    if (_res.options & RES_DEBUG)
      printf(";; rcode = %d, ancount=%d\n", hp->rcode, ntohs(hp->ancount));
    switch (hp->rcode) {
    case NXDOMAIN:
      h_errno = HOST_NOT_FOUND;
      break;
    case SERVFAIL:
      h_errno = TRY_AGAIN;
      break;
    case NOERROR:
      h_errno = NO_DATA;
      break;
    case FORMERR:
    case NOTIMP:
    case REFUSED:
    default:
      h_errno = NO_RECOVERY;
      break;
    }
    return (-1);
  }
  return (n);
}


x86 assembly (clang, -O0):
<res_query>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1060,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x1038(%rbp)
mov    -0x1038(%rbp),%rax
movl   $0x84,(%rax)
mov    0x2e5c(%rip),%rax
mov    (%rax),%eax
mov    0x2e03(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    11ce <res_query+0x7e>
mov    $0x0,%al
call   1040 <res_init@plt>
cmp    $0xffffffff,%eax
jne    11ce <res_query+0x7e>
mov    0x2e11(%rip),%rax
mov    (%rax),%ecx
mov    0x2e18(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    142c <res_query+0x2dc>
mov    0x2e13(%rip),%rax
mov    (%rax),%eax
mov    0x2e02(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1201 <res_query+0xb1>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d98(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    -0x1030(%rbp),%rax
xor    %r8d,%r8d
xor    %r9d,%r9d
movq   $0x0,(%rsp)
mov    %rax,0x8(%rsp)
movl   $0x1000,0x10(%rsp)
call   1070 <res_mkquery@plt>
mov    %eax,-0x103c(%rbp)
cmpl   $0x0,-0x103c(%rbp)
jg     1297 <res_query+0x147>
mov    0x2d93(%rip),%rax
mov    (%rax),%eax
mov    0x2d82(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1277 <res_query+0x127>
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d32(%rip),%rax
mov    (%rax),%ecx
mov    0x2d51(%rip),%rax
mov    %ecx,(%rax)
mov    -0x103c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    142c <res_query+0x2dc>
lea    -0x1030(%rbp),%rdi
mov    -0x103c(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1050 <res_send@plt>
mov    %eax,-0x103c(%rbp)
cmpl   $0x0,-0x103c(%rbp)
jge    130c <res_query+0x1bc>
mov    0x2d1e(%rip),%rax
mov    (%rax),%eax
mov    0x2d0d(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     12ec <res_query+0x19c>
lea    0xd6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2cc5(%rip),%rax
mov    (%rax),%ecx
mov    0x2cdc(%rip),%rax
mov    %ecx,(%rax)
mov    -0x103c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    142c <res_query+0x2dc>
mov    -0x1038(%rbp),%rax
cmpl   $0x84,(%rax)
jne    1337 <res_query+0x1e7>
mov    -0x1038(%rbp),%rax
mov    0x4(%rax),%edi
call   1060 <ntohs@plt>
cmp    $0x0,%eax
jne    1423 <res_query+0x2d3>
mov    0x2caa(%rip),%rax
mov    (%rax),%eax
mov    0x2c99(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1386 <res_query+0x236>
mov    -0x1038(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1040(%rbp)
mov    -0x1038(%rbp),%rax
mov    0x4(%rax),%edi
call   1060 <ntohs@plt>
mov    -0x1040(%rbp),%esi
mov    %eax,%edx
lea    0xceb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1038(%rbp),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x1048(%rbp)
sub    $0x5,%eax
ja     1405 <res_query+0x2b5>
mov    -0x1048(%rbp),%rax
lea    0xc4e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2c0e(%rip),%rax
mov    (%rax),%ecx
mov    0x2c0d(%rip),%rax
mov    %ecx,(%rax)
jmp    1417 <res_query+0x2c7>
mov    0x2bdf(%rip),%rax
mov    (%rax),%ecx
mov    0x2bf6(%rip),%rax
mov    %ecx,(%rax)
jmp    1417 <res_query+0x2c7>
mov    0x2bb8(%rip),%rax
mov    (%rax),%ecx
mov    0x2bdf(%rip),%rax
mov    %ecx,(%rax)
jmp    1417 <res_query+0x2c7>
jmp    1405 <res_query+0x2b5>
mov    0x2ba4(%rip),%rax
mov    (%rax),%ecx
mov    0x2bc3(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    142c <res_query+0x2dc>
mov    -0x103c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1060,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<res_query>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1008,%rsp
mov    %r8d,%r14d
mov    %rcx,%r15
mov    %edx,%r12d
mov    %esi,%r13d
mov    %rdi,%rbp
movl   $0x84,(%rcx)
mov    0x2e5b(%rip),%rbx
mov    (%rbx),%eax
mov    0x2e12(%rip),%rcx
test   %eax,(%rcx)
jne    11ac <res_query+0x4c>
xor    %eax,%eax
call   1050 <res_init@plt>
cmp    $0xffffffff,%eax
je     12c8 <res_query+0x168>
mov    (%rbx),%eax
mov    0x2e2d(%rip),%rbx
test   %eax,(%rbx)
je     11ce <res_query+0x6e>
lea    0xe42(%rip),%rdi
mov    %rbp,%rsi
mov    %r13d,%edx
mov    %r12d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
sub    $0x8,%rsp
lea    0x8(%rsp),%rax
mov    %rbp,%rsi
mov    %r13d,%edx
mov    %r12d,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
push   $0x1000
push   %rax
push   $0x0
call   1080 <res_mkquery@plt>
add    $0x20,%rsp
mov    %eax,%ebp
test   %eax,%eax
jle    1284 <res_query+0x124>
mov    %rsp,%rdi
mov    %ebp,%esi
mov    %r15,%rdx
mov    %r14d,%ecx
call   1060 <res_send@plt>
mov    %eax,%ebp
test   %eax,%eax
js     12a6 <res_query+0x146>
cmpl   $0x84,(%r15)
jne    123a <res_query+0xda>
mov    0x4(%r15),%edi
call   1070 <ntohs@plt>
test   %eax,%eax
jne    12e8 <res_query+0x188>
mov    (%rbx),%eax
mov    0x2da5(%rip),%rcx
test   %eax,(%rcx)
je     1265 <res_query+0x105>
mov    (%r15),%ebx
mov    0x4(%r15),%edi
call   1070 <ntohs@plt>
lea    0xdc0(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r15),%eax
add    $0xffffff80,%eax
mov    $0xffffffff,%ebp
cmp    $0x4,%eax
ja     12d6 <res_query+0x176>
cltq
lea    0x2b3a(%rip),%rcx
mov    (%rcx,%rax,8),%rbx
jmp    12dd <res_query+0x17d>
mov    (%rbx),%eax
mov    0x2d2b(%rip),%rbx
mov    0x2d54(%rip),%rcx
test   %eax,(%rcx)
je     12dd <res_query+0x17d>
lea    0xdaf(%rip),%rdi
call   1030 <puts@plt>
jmp    12dd <res_query+0x17d>
mov    (%rbx),%eax
mov    0x2d11(%rip),%rbx
mov    0x2d32(%rip),%rcx
test   %eax,(%rcx)
je     12dd <res_query+0x17d>
lea    0xd74(%rip),%rdi
call   1030 <puts@plt>
jmp    12dd <res_query+0x17d>
mov    $0xffffffff,%ebp
mov    0x2cfc(%rip),%rbx
jmp    12dd <res_query+0x17d>
mov    0x2cdb(%rip),%rbx
mov    (%rbx),%eax
mov    0x2cf2(%rip),%rcx
mov    %eax,(%rcx)
mov    %ebp,%eax
add    $0x1008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32 }
%struct.TYPE_3__ = type { i32, i32 }
@_res = global %struct.TYPE_4__ zeroinitializer
@RES_INIT = global i32 0
@NETDB_INTERNAL = global i32 0
@h_errno = global i32 0
@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 = [27 x i8] c";; rcode = %d, ancount=%d\0A\00"
@HOST_NOT_FOUND = global i32 0
@NO_DATA = global i32 0
define i32 @res_query(i8* %0, i32 %1, i32 %2, i32* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32
%12 = alloca [1024 x i32]
%13 = alloca %struct.TYPE_3__*
%14 = alloca i32
store i8* %0, i8** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32* %3, i32** %10
store i32 %4, i32* %11
%15 = load i32*, i32** %10
%16 = bitcast i32* %15 to %struct.TYPE_3__*
store %struct.TYPE_3__* %16, %struct.TYPE_3__** %13
%17 = load %struct.TYPE_3__*, %struct.TYPE_3__** %13
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i32 0, i32 0
store i32 132, i32* %18
%19 = load i32, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @_res, i32 0, i32 0)
%20 = load i32, i32* @RES_INIT
%21 = and i32 %19, %20
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %5
%24 = call i32 (...) @res_init()
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = load i32, i32* @NETDB_INTERNAL
store i32 %27, i32* @h_errno
store i32 -1, i32* %6
br label %116
28: ; preds = %23, %5
%29 = load i32, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @_res, i32 0, i32 0)
%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 = %28
%34 = load i8*, i8** %7
%35 = load i32, i32* %8
%36 = load i32, i32* %9
%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, %28
%39 = load i32, i32* @QUERY
%40 = load i8*, i8** %7
%41 = load i32, i32* %8
%42 = load i32, i32* %9
%43 = getelementptr inbounds [1024 x i32], [1024 x i32]* %12, i64 0, i64 0
%44 = call i32 @res_mkquery(i32 %39, i8* %40, i32 %41, i32 %42, i32* null, i32 0, i32* null, i32* %43, i32 4096)
store i32 %44, i32* %14
%45 = load i32, i32* %14
%46 = icmp sle i32 %45, 0
br i1 %46, label %47, label %57
47: ; preds = %38
%48 = load i32, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @_res, i32 0, i32 0)
%49 = load i32, i32* @RES_DEBUG
%50 = and i32 %48, %49
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %47
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %54
54: ; preds = %52, %47
%55 = load i32, i32* @NO_RECOVERY
store i32 %55, i32* @h_errno
%56 = load i32, i32* %14
store i32 %56, i32* %6
br label %116
57: ; preds = %38
%58 = getelementptr inbounds [1024 x i32], [1024 x i32]* %12, i64 0, i64 0
%59 = load i32, i32* %14
%60 = load i32*, i32** %10
%61 = load i32, i32* %11
%62 = call i32 @res_send(i32* %58, i32 %59, i32* %60, i32 %61)
store i32 %62, i32* %14
%63 = load i32, i32* %14
%64 = icmp slt i32 %63, 0
br i1 %64, label %65, label %75
65: ; preds = %57
%66 = load i32, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @_res, i32 0, i32 0)
%67 = load i32, i32* @RES_DEBUG
%68 = and i32 %66, %67
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %72
70: ; preds = %65
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %72
72: ; preds = %70, %65
%73 = load i32, i32* @TRY_AGAIN
store i32 %73, i32* @h_errno
%74 = load i32, i32* %14
store i32 %74, i32* %6
br label %116
75: ; preds = %57
%76 = load %struct.TYPE_3__*, %struct.TYPE_3__** %13
%77 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %76, i32 0, i32 0
%78 = load i32, i32* %77
%79 = icmp ne i32 %78, 132
br i1 %79, label %86, label %80
80: ; preds = %75
%81 = load %struct.TYPE_3__*, %struct.TYPE_3__** %13
%82 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %81, i32 0, i32 1
%83 = load i32, i32* %82
%84 = call i32 @ntohs(i32 %83)
%85 = icmp eq i32 %84, 0
br i1 %85, label %86, label %114
86: ; preds = %80, %75
%87 = load i32, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @_res, i32 0, i32 0)
%88 = load i32, i32* @RES_DEBUG
%89 = and i32 %87, %88
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %100
91: ; preds = %86
%92 = load %struct.TYPE_3__*, %struct.TYPE_3__** %13
%93 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %92, i32 0, i32 0
%94 = load i32, i32* %93
%95 = load %struct.TYPE_3__*, %struct.TYPE_3__** %13
%96 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %95, i32 0, i32 1
%97 = load i32, i32* %96
%98 = call i32 @ntohs(i32 %97)
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %94, i32 %98)
br label %100
100: ; preds = %91, %86
%101 = load %struct.TYPE_3__*, %struct.TYPE_3__** %13
%102 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %101, i32 0, i32 0
%103 = load i32, i32* %102
switch i32 %103, label %111 [
i32 130, label %104
i32 128, label %106
i32 132, label %108
i32 133, label %110
i32 131, label %110
i32 129, label %110
]
104: ; preds = %100
%105 = load i32, i32* @HOST_NOT_FOUND
store i32 %105, i32* @h_errno
br label %113
106: ; preds = %100
%107 = load i32, i32* @TRY_AGAIN
store i32 %107, i32* @h_errno
br label %113
108: ; preds = %100
%109 = load i32, i32* @NO_DATA
store i32 %109, i32* @h_errno
br label %113
110: ; preds = %100, %100, %100
br label %111
111: ; preds = %100, %110
%112 = load i32, i32* @NO_RECOVERY
store i32 %112, i32* @h_errno
br label %113
113: ; preds = %111, %108, %106, %104
store i32 -1, i32* %6
br label %116
114: ; preds = %80
%115 = load i32, i32* %14
store i32 %115, i32* %6
br label %116
116: ; preds = %114, %113, %72, %54, %26
%117 = load i32, i32* %6
ret i32 %117
}

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