#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 */

/* Variables and functions */
int __res_mkquery(int /*<<< orphan*/, char const *, int, int,
                  int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
                  unsigned char *, int);
int __res_send(unsigned char *, int, unsigned char *, int);
int res_query(const char *name, int class, int type, unsigned char *dest,
              int len) {
  unsigned char q[280];
  int ql = __res_mkquery(0, name, class, type, 0, 0, 0, q, sizeof q);
  if (ql < 0)
    return ql;
  return __res_send(q, ql, dest, len);
}


x86 assembly (clang, -O0):
<res_query>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    -0x140(%rbp),%rax
xor    %r9d,%r9d
mov    %r9d,%edi
mov    %r9d,%r8d
movl   $0x0,(%rsp)
mov    %rax,0x8(%rsp)
movl   $0x118,0x10(%rsp)
call   1030 <__res_mkquery@plt>
mov    %eax,-0x144(%rbp)
cmpl   $0x0,-0x144(%rbp)
jge    1191 <res_query+0x71>
mov    -0x144(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ad <res_query+0x8d>
lea    -0x140(%rbp),%rdi
mov    -0x144(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1040 <__res_send@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<res_query>:
push   %rbp
push   %rbx
sub    $0x118,%rsp
mov    %r8d,%ebp
mov    %rcx,%rbx
mov    %edx,%ecx
mov    %esi,%edx
mov    %rdi,%rsi
sub    $0x8,%rsp
lea    0x8(%rsp),%rax
xor    %edi,%edi
xor    %r8d,%r8d
xor    %r9d,%r9d
push   $0x118
push   %rax
push   $0x0
call   1030 <__res_mkquery@plt>
add    $0x20,%rsp
test   %eax,%eax
js     116b <res_query+0x4b>
mov    %rsp,%rdi
mov    %eax,%esi
mov    %rbx,%rdx
mov    %ebp,%ecx
call   1040 <__res_send@plt>
add    $0x118,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @res_query(i8* %0, i32 %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca [280 x i8]
%13 = alloca i32
store i8* %0, i8** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i32 %4, i32* %11
%14 = load i8*, i8** %7
%15 = load i32, i32* %8
%16 = load i32, i32* %9
%17 = getelementptr inbounds [280 x i8], [280 x i8]* %12, i64 0, i64 0
%18 = call i32 @__res_mkquery(i32 0, i8* %14, i32 %15, i32 %16, i32 0, i32 0, i32 0, i8* %17, i32 280)
store i32 %18, i32* %13
%19 = load i32, i32* %13
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %5
%22 = load i32, i32* %13
store i32 %22, i32* %6
br label %29
23: ; preds = %5
%24 = getelementptr inbounds [280 x i8], [280 x i8]* %12, i64 0, i64 0
%25 = load i32, i32* %13
%26 = load i8*, i8** %10
%27 = load i32, i32* %11
%28 = call i32 @__res_send(i8* %24, i32 %25, i8* %26, i32 %27)
store i32 %28, i32* %6
br label %29
29: ; preds = %23, %21
%30 = load i32, i32* %6
ret i32 %30
}

LLVM IR (-O2):
define i32 @res_query(i8* %0, i32 %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca [280 x i8]
%7 = getelementptr inbounds [280 x i8], [280 x i8]* %6, i64 0, i64 0
%8 = call i32 @__res_mkquery(i32 0, i8* %0, i32 %1, i32 %2, i32 0, i32 0, i32 0, i8* %7, i32 280)
%9 = icmp slt i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %5
%11 = call i32 @__res_send(i8* %7, i32 %8, i8* %3, i32 %4)
br label %12
12: ; preds = %5, %10
%13 = phi i32 [ %11, %10 ], [ %8, %5 ]
ret i32 %13
}