#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 AF_INET;
int AF_INET6;
int __dns_doqueries(unsigned char *, void const *, int *, int);
int /*<<< orphan*/ mkptr4(char *, void const *);
int /*<<< orphan*/ mkptr6(char *, void const *);
int __dns_query(unsigned char *r, const void *a, int family, int ptr) {
  char buf[(64 + sizeof ".in-addr.arpa")];
  int rr[2], rrcnt = 1;
  if (ptr) {
    if (family == AF_INET6)
      mkptr6(buf, a);
    else
      mkptr4(buf, a);
    rr[0] = 12;
    a = buf;
  } else if (family == AF_INET6) {
    rr[0] = 28;
  } else {
    rr[0] = 1;
    if (family != AF_INET)
      rr[rrcnt++] = 28;
  }
  return __dns_doqueries(r, a, rr, rrcnt);
}


x86 assembly (clang, -O0):
<__dns_query>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x1,-0x7c(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     119f <__dns_query+0x6f>
mov    -0x14(%rbp),%eax
mov    0x2e7c(%rip),%rcx
cmp    (%rcx),%eax
jne    117e <__dns_query+0x4e>
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <mkptr6@plt>
jmp    118b <__dns_query+0x5b>
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <mkptr4@plt>
movl   $0xc,-0x78(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    11f5 <__dns_query+0xc5>
mov    -0x14(%rbp),%eax
mov    0x2e37(%rip),%rcx
cmp    (%rcx),%eax
jne    11bd <__dns_query+0x8d>
movl   $0x1c,-0x78(%rbp)
jmp    11f0 <__dns_query+0xc0>
movl   $0x1,-0x78(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e1a(%rip),%rcx
cmp    (%rcx),%eax
je     11eb <__dns_query+0xbb>
mov    -0x7c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x7c(%rbp)
cltq
movl   $0x1c,-0x78(%rbp,%rax,4)
jmp    11f0 <__dns_query+0xc0>
jmp    11f5 <__dns_query+0xc5>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x78(%rbp),%rdx
mov    -0x7c(%rbp),%ecx
call   1030 <__dns_doqueries@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__dns_query>:
push   %rbx
sub    $0x60,%rsp
mov    %rdi,%rbx
mov    0x2ea1(%rip),%rax
mov    (%rax),%eax
test   %ecx,%ecx
je     1155 <__dns_query+0x25>
lea    0x10(%rsp),%rdi
cmp    %edx,%eax
jne    1163 <__dns_query+0x33>
call   1040 <mkptr6@plt>
jmp    1168 <__dns_query+0x38>
cmp    %edx,%eax
jne    118d <__dns_query+0x5d>
movl   $0x1c,0x8(%rsp)
jmp    1175 <__dns_query+0x45>
call   1050 <mkptr4@plt>
lea    0x10(%rsp),%rsi
movl   $0xc,0x8(%rsp)
mov    $0x1,%ecx
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1030 <__dns_doqueries@plt>
add    $0x60,%rsp
pop    %rbx
ret
movl   $0x1,0x8(%rsp)
mov    0x2e4c(%rip),%rax
mov    $0x1,%ecx
cmp    %edx,(%rax)
je     117a <__dns_query+0x4a>
movl   $0x1c,0xc(%rsp)
mov    $0x2,%ecx
jmp    117a <__dns_query+0x4a>

LLVM IR (-O0):
@AF_INET6 = global i32 0
@AF_INET = global i32 0
define i32 @__dns_query(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [78 x i8]
%10 = alloca [2 x i32]
%11 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 1, i32* %11
%12 = load i32, i32* %8
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %29
14: ; preds = %4
%15 = load i32, i32* %7
%16 = load i32, i32* @AF_INET6
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = getelementptr inbounds [78 x i8], [78 x i8]* %9, i64 0, i64 0
%20 = load i8*, i8** %6
%21 = call i32 @mkptr6(i8* %19, i8* %20)
br label %26
22: ; preds = %14
%23 = getelementptr inbounds [78 x i8], [78 x i8]* %9, i64 0, i64 0
%24 = load i8*, i8** %6
%25 = call i32 @mkptr4(i8* %23, i8* %24)
br label %26
26: ; preds = %22, %18
%27 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
store i32 12, i32* %27
%28 = getelementptr inbounds [78 x i8], [78 x i8]* %9, i64 0, i64 0
store i8* %28, i8** %6
br label %47
29: ; preds = %4
%30 = load i32, i32* %7
%31 = load i32, i32* @AF_INET6
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
store i32 28, i32* %34
br label %46
35: ; preds = %29
%36 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
store i32 1, i32* %36
%37 = load i32, i32* %7
%38 = load i32, i32* @AF_INET
%39 = icmp ne i32 %37, %38
br i1 %39, label %40, label %45
40: ; preds = %35
%41 = load i32, i32* %11
%42 = add nsw i32 %41, 1
store i32 %42, i32* %11
%43 = sext i32 %41 to i64
%44 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 %43
store i32 28, i32* %44
br label %45
45: ; preds = %40, %35
br label %46
46: ; preds = %45, %33
br label %47
47: ; preds = %46, %26
%48 = load i8*, i8** %5
%49 = load i8*, i8** %6
%50 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%51 = load i32, i32* %11
%52 = call i32 @__dns_doqueries(i8* %48, i8* %49, i32* %50, i32 %51)
ret i32 %52
}

LLVM IR (-O2):
@AF_INET6 = global i32 0
@AF_INET = global i32 0
define i32 @__dns_query(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca [78 x i8]
%6 = alloca [2 x i32]
%7 = getelementptr inbounds [78 x i8], [78 x i8]* %5, i64 0, i64 0
%8 = bitcast [2 x i32]* %6 to i8*
%9 = icmp eq i32 %3, 0
%10 = load i32, i32* @AF_INET6
%11 = icmp eq i32 %10, %2
br i1 %9, label %19, label %12
12: ; preds = %4
br i1 %11, label %13, label %15
13: ; preds = %12
%14 = call i32 @mkptr6(i8* %7, i8* %1)
br label %17
15: ; preds = %12
%16 = call i32 @mkptr4(i8* %7, i8* %1)
br label %17
17: ; preds = %15, %13
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
store i32 12, i32* %18
br label %27
19: ; preds = %4
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
br i1 %11, label %21, label %22
21: ; preds = %19
store i32 28, i32* %20
br label %27
22: ; preds = %19
store i32 1, i32* %20
%23 = load i32, i32* @AF_INET
%24 = icmp eq i32 %23, %2
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
store i32 28, i32* %26
br label %27
27: ; preds = %21, %25, %22, %17
%28 = phi i8* [ %7, %17 ], [ %1, %21 ], [ %1, %25 ], [ %1, %22 ]
%29 = phi i32 [ 1, %17 ], [ 1, %21 ], [ 2, %25 ], [ 1, %22 ]
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%31 = call i32 @__dns_doqueries(i8* %0, i8* %28, i32* %30, i32 %29)
ret i32 %31
}