#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 */
typedef int /*<<< orphan*/ dnsreply;

/* Variables and functions */
int /*<<< orphan*/ C_IN;
int /*<<< orphan*/ T_TXT;
int /*<<< orphan*/ memset(unsigned char *, char, int);
int /*<<< orphan*/ printf(char *, ...);
int res_query(char *, int /*<<< orphan*/, int /*<<< orphan*/, unsigned char *,
              int);
int res_querydomain(char *, char *, int /*<<< orphan*/, int /*<<< orphan*/,
                    unsigned char *, int);
int res_search(char *, int /*<<< orphan*/, int /*<<< orphan*/, unsigned char *,
               int);
int res_send(unsigned char *, int, unsigned char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *);
char *txtquery(char const *, unsigned int *);
int main() {
  unsigned char dnsreply[1024];
  unsigned char host[128];
  char *dnsrep;
  int ret = 0;
  unsigned int ttl = 0;
  memset(dnsreply, '\0', sizeof(dnsreply));
  snprintf((char *)host, 127, "www.google.com");
  dnsrep = txtquery((const char *)host, &ttl);
  printf("RES_QUERY results: %s.", dnsrep);
  printf("return code: %i\n", ret);
  snprintf((char *)host, 127, "www.google.com");
  ret = res_query((char *)host, C_IN, T_TXT, dnsreply, sizeof(dnsreply));
  printf("RES_QUERY results: %s.", dnsreply);
  printf("return code: %i\n", ret);
  memset(dnsreply, '\0', sizeof(dnsreply));
  ret = res_search((char *)host, C_IN, T_TXT, dnsreply, sizeof(dnsreply));
  printf("RES_SEARCH results: %s.", dnsreply);
  printf("return code: %i\n", ret);
  memset(dnsreply, '\0', sizeof(dnsreply));
  ret = res_querydomain("www.google.com", "google.com", C_IN, T_TXT, dnsreply,
                        sizeof(dnsreply));
  printf("RES_QUERYDOMAIN results: %s.", dnsreply);
  printf("return code: %i\n", ret);
  memset(dnsreply, '\0', sizeof(dnsreply));
  ret = res_send(host, 32, dnsreply, sizeof(dnsreply));
  printf("RES_SEND results: %s.", dnsreply);
  printf("return code: %i\n", ret);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4a0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x49c(%rbp)
movl   $0x0,-0x4a0(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
lea    -0x490(%rbp),%rdi
mov    $0x7f,%esi
lea    0xe34(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x490(%rbp),%rdi
lea    -0x4a0(%rbp),%rsi
call   1080 <txtquery@plt>
mov    %rax,-0x498(%rbp)
mov    -0x498(%rbp),%rsi
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x49c(%rbp),%esi
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x490(%rbp),%rdi
mov    $0x7f,%esi
lea    0xdd9(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x490(%rbp),%rdi
mov    0x2dae(%rip),%rax
mov    (%rax),%esi
mov    0x2d95(%rip),%rax
mov    (%rax),%edx
lea    -0x410(%rbp),%rcx
mov    $0x400,%r8d
call   10a0 <res_query@plt>
mov    %eax,-0x49c(%rbp)
lea    -0x410(%rbp),%rsi
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x49c(%rbp),%esi
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
lea    -0x490(%rbp),%rdi
mov    0x2d41(%rip),%rax
mov    (%rax),%esi
mov    0x2d28(%rip),%rax
mov    (%rax),%edx
lea    -0x410(%rbp),%rcx
mov    $0x400,%r8d
call   1030 <res_search@plt>
mov    %eax,-0x49c(%rbp)
lea    -0x410(%rbp),%rsi
lea    0xd5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x49c(%rbp),%esi
lea    0xd3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
mov    0x2cdb(%rip),%rax
mov    (%rax),%edx
mov    0x2cc2(%rip),%rax
mov    (%rax),%ecx
lea    -0x410(%rbp),%r8
lea    0xcda(%rip),%rdi
lea    0xcd7(%rip),%rsi
mov    $0x400,%r9d
call   1070 <res_querydomain@plt>
mov    %eax,-0x49c(%rbp)
lea    -0x410(%rbp),%rsi
lea    0xd03(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x49c(%rbp),%esi
lea    0xcc6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
lea    -0x490(%rbp),%rdi
lea    -0x410(%rbp),%rdx
mov    $0x20,%esi
mov    $0x400,%ecx
call   1090 <res_send@plt>
mov    %eax,-0x49c(%rbp)
lea    -0x410(%rbp),%rsi
lea    0xcc1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x49c(%rbp),%esi
lea    0xc67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x49c(%rbp),%eax
add    $0x4a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x498,%rsp
movl   $0x0,0xc(%rsp)
lea    0x90(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
lea    0xe49(%rip),%r14
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x7f,%esi
mov    %r14,%rdx
call   1050 <snprintf@plt>
lea    0xc(%rsp),%rsi
mov    %rbp,%rdi
call   1080 <txtquery@plt>
lea    0xe2f(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe35(%rip),%r13
mov    %r13,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    $0x7f,%esi
mov    %r14,%rdx
call   1050 <snprintf@plt>
mov    0x2dd4(%rip),%r15
mov    (%r15),%esi
mov    0x2dba(%rip),%r12
mov    (%r12),%edx
mov    %rbp,%rdi
mov    %rbp,%r14
mov    %rbx,%rcx
mov    $0x400,%r8d
call   10a0 <res_query@plt>
mov    %eax,%ebp
lea    0xdd0(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
mov    (%r15),%esi
mov    (%r12),%edx
mov    %r14,%rdi
mov    %rbx,%rcx
mov    $0x400,%r8d
call   1030 <res_search@plt>
mov    %eax,%ebp
lea    0xdb2(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
mov    (%r15),%edx
mov    (%r12),%ecx
lea    0xd4c(%rip),%rsi
lea    0xd41(%rip),%rdi
mov    %rbx,%r8
mov    $0x400,%r9d
call   1070 <res_querydomain@plt>
mov    %eax,%ebp
lea    0xd79(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
mov    %r14,%rdi
mov    $0x20,%esi
mov    %rbx,%rdx
mov    $0x400,%ecx
call   1090 <res_send@plt>
mov    %eax,%ebp
lea    0xd53(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%eax
add    $0x498,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"www.google.com\00"
@.str.1 = [23 x i8] c"RES_QUERY results: %s.\00"
@.str.2 = [17 x i8] c"return code: %i\0A\00"
@C_IN = global i32 0
@T_TXT = global i32 0
@.str.3 = [24 x i8] c"RES_SEARCH results: %s.\00"
@.str.4 = [11 x i8] c"google.com\00"
@.str.5 = [29 x i8] c"RES_QUERYDOMAIN results: %s.\00"
@.str.6 = [22 x i8] c"RES_SEND results: %s.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca [128 x i8]
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%8 = call i32 @memset(i8* %7, i8 signext 0, i32 1024)
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%10 = call i32 @snprintf(i8* %9, i32 127, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%12 = call i8* @txtquery(i8* %11, i32* %6)
store i8* %12, i8** %4
%13 = load i8*, i8** %4
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = load i32, i32* %5
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%18 = call i32 @snprintf(i8* %17, i32 127, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%20 = load i32, i32* @C_IN
%21 = load i32, i32* @T_TXT
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%23 = call i32 @res_query(i8* %19, i32 %20, i32 %21, i8* %22, i32 1024)
store i32 %23, i32* %5
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = load i32, i32* %5
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%29 = call i32 @memset(i8* %28, i8 signext 0, i32 1024)
%30 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%31 = load i32, i32* @C_IN
%32 = load i32, i32* @T_TXT
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%34 = call i32 @res_search(i8* %30, i32 %31, i32 %32, i8* %33, i32 1024)
store i32 %34, i32* %5
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %35)
%37 = load i32, i32* %5
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %37)
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%40 = call i32 @memset(i8* %39, i8 signext 0, i32 1024)
%41 = load i32, i32* @C_IN
%42 = load i32, i32* @T_TXT
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%44 = call i32 @res_querydomain(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %41, i32 %42, i8* %43, i32 1024)
store i32 %44, i32* %5
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %45)
%47 = load i32, i32* %5
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %47)
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%50 = call i32 @memset(i8* %49, i8 signext 0, i32 1024)
%51 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%53 = call i32 @res_send(i8* %51, i32 32, i8* %52, i32 1024)
store i32 %53, i32* %5
%54 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %54)
%56 = load i32, i32* %5
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %56)
%58 = load i32, i32* %5
ret i32 %58
}

LLVM IR (-O2):
@.str = [15 x i8] c"www.google.com\00"
@.str.1 = [23 x i8] c"RES_QUERY results: %s.\00"
@.str.2 = [17 x i8] c"return code: %i\0A\00"
@C_IN = global i32 0
@T_TXT = global i32 0
@.str.3 = [24 x i8] c"RES_SEARCH results: %s.\00"
@.str.4 = [11 x i8] c"google.com\00"
@.str.5 = [29 x i8] c"RES_QUERYDOMAIN results: %s.\00"
@.str.6 = [22 x i8] c"RES_SEND results: %s.\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca [128 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = call i32 @memset(i8* %4, i8 signext 0, i32 1024)
%8 = call i32 @snprintf(i8* %5, i32 127, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%9 = call i8* @txtquery(i8* %5, i32* %3)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 0)
%12 = call i32 @snprintf(i8* %5, i32 127, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @C_IN
%14 = load i32, i32* @T_TXT
%15 = call i32 @res_query(i8* %5, i32 %13, i32 %14, i8* %4, i32 1024)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%18 = call i32 @memset(i8* %4, i8 signext 0, i32 1024)
%19 = load i32, i32* @C_IN
%20 = load i32, i32* @T_TXT
%21 = call i32 @res_search(i8* %5, i32 %19, i32 %20, i8* %4, i32 1024)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%24 = call i32 @memset(i8* %4, i8 signext 0, i32 1024)
%25 = load i32, i32* @C_IN
%26 = load i32, i32* @T_TXT
%27 = call i32 @res_querydomain(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %25, i32 %26, i8* %4, i32 1024)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* %4)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%30 = call i32 @memset(i8* %4, i8 signext 0, i32 1024)
%31 = call i32 @res_send(i8* %5, i32 32, i8* %4, i32 1024)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %4)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %31)
ret i32 %31
}