#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 */
struct dns_resolv_conf {
  int dummy;
};
struct dns_hints {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ dns_hints_close(struct dns_hints *);
scalar_t__ dns_hints_insert_resconf(struct dns_hints *, char *,
                                    struct dns_resolv_conf *, int *);
struct dns_hints *dns_hints_open(struct dns_resolv_conf *, int *);
int /*<<< orphan*/ dns_resconf_acquire(struct dns_resolv_conf *);
int /*<<< orphan*/ dns_resconf_close(struct dns_resolv_conf *);
struct dns_resolv_conf *dns_resconf_local(int *);
struct dns_hints *dns_hints_local(struct dns_resolv_conf *resconf,
                                  int *error_) {
  struct dns_hints *hints = 0;
  int error;
  if (resconf)
    dns_resconf_acquire(resconf);
  else if (!(resconf = dns_resconf_local(&error)))
    goto error;
  if (!(hints = dns_hints_open(resconf, &error)))
    goto error;
  error = 0;
  if (0 == dns_hints_insert_resconf(hints, ".", resconf, &error) && error)
    goto error;
  dns_resconf_close(resconf);
  return hints;
error:
  *error_ = error;
  dns_resconf_close(resconf);
  dns_hints_close(hints);
  return 0;
}


x86 assembly (clang, -O0):
<dns_hints_local>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1191 <dns_hints_local+0x31>
mov    -0x10(%rbp),%rdi
call   1070 <dns_resconf_acquire@plt>
jmp    11b2 <dns_hints_local+0x52>
lea    -0x24(%rbp),%rdi
call   1060 <dns_resconf_local@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11ad <dns_hints_local+0x4d>
jmp    1224 <dns_hints_local+0xc4>
jmp    11b2 <dns_hints_local+0x52>
mov    -0x10(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1040 <dns_hints_open@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11d2 <dns_hints_local+0x72>
jmp    1224 <dns_hints_local+0xc4>
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe18(%rip),%rsi
lea    -0x24(%rbp),%rcx
call   1030 <dns_hints_insert_resconf@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    120e <dns_hints_local+0xae>
cmpl   $0x0,-0x24(%rbp)
je     120e <dns_hints_local+0xae>
jmp    1224 <dns_hints_local+0xc4>
mov    -0x10(%rbp),%rdi
call   1050 <dns_resconf_close@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1247 <dns_hints_local+0xe7>
mov    -0x24(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
call   1050 <dns_resconf_close@plt>
mov    -0x20(%rbp),%rdi
call   1080 <dns_hints_close@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dns_hints_local>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
test   %rdi,%rdi
je     117b <dns_hints_local+0x1b>
mov    %rdi,%r15
call   1070 <dns_resconf_acquire@plt>
jmp    118d <dns_hints_local+0x2d>
lea    0xc(%rsp),%rdi
call   1060 <dns_resconf_local@plt>
mov    %rax,%r15
test   %rax,%rax
je     11d7 <dns_hints_local+0x77>
lea    0xc(%rsp),%rsi
mov    %r15,%rdi
call   1040 <dns_hints_open@plt>
test   %rax,%rax
je     11da <dns_hints_local+0x7a>
mov    %rax,%rbx
movl   $0x0,0xc(%rsp)
lea    0xe4f(%rip),%rsi
lea    0xc(%rsp),%rcx
mov    %rax,%rdi
mov    %r15,%rdx
call   1030 <dns_hints_insert_resconf@plt>
test   %rax,%rax
jne    11cd <dns_hints_local+0x6d>
cmpl   $0x0,0xc(%rsp)
jne    11dc <dns_hints_local+0x7c>
mov    %r15,%rdi
call   1050 <dns_resconf_close@plt>
jmp    11f5 <dns_hints_local+0x95>
xor    %r15d,%r15d
xor    %ebx,%ebx
mov    0xc(%rsp),%eax
mov    %eax,(%r14)
mov    %r15,%rdi
call   1050 <dns_resconf_close@plt>
mov    %rbx,%rdi
call   1080 <dns_hints_close@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.dns_hints = type { i32 }
%struct.dns_resolv_conf = type { i32 }
@.str = [2 x i8] c".\00"
define %struct.dns_hints* @dns_hints_local(%struct.dns_resolv_conf* %0, i32* %1) {
%3 = alloca %struct.dns_hints*
%4 = alloca %struct.dns_resolv_conf*
%5 = alloca i32*
%6 = alloca %struct.dns_hints*
%7 = alloca i32
store %struct.dns_resolv_conf* %0, %struct.dns_resolv_conf** %4
store i32* %1, i32** %5
store %struct.dns_hints* null, %struct.dns_hints** %6
%8 = load %struct.dns_resolv_conf*, %struct.dns_resolv_conf** %4
%9 = icmp ne %struct.dns_resolv_conf* %8, null
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load %struct.dns_resolv_conf*, %struct.dns_resolv_conf** %4
%12 = call i32 @dns_resconf_acquire(%struct.dns_resolv_conf* %11)
br label %18
13: ; preds = %2
%14 = call %struct.dns_resolv_conf* @dns_resconf_local(i32* %7)
store %struct.dns_resolv_conf* %14, %struct.dns_resolv_conf** %4
%15 = icmp ne %struct.dns_resolv_conf* %14, null
br i1 %15, label %17, label %16
16: ; preds = %13
br label %36
17: ; preds = %13
br label %18
18: ; preds = %17, %10
%19 = load %struct.dns_resolv_conf*, %struct.dns_resolv_conf** %4
%20 = call %struct.dns_hints* @dns_hints_open(%struct.dns_resolv_conf* %19, i32* %7)
store %struct.dns_hints* %20, %struct.dns_hints** %6
%21 = icmp ne %struct.dns_hints* %20, null
br i1 %21, label %23, label %22
22: ; preds = %18
br label %36
23: ; preds = %18
store i32 0, i32* %7
%24 = load %struct.dns_hints*, %struct.dns_hints** %6
%25 = load %struct.dns_resolv_conf*, %struct.dns_resolv_conf** %4
%26 = call i64 @dns_hints_insert_resconf(%struct.dns_hints* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %struct.dns_resolv_conf* %25, i32* %7)
%27 = icmp eq i64 0, %26
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = load i32, i32* %7
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %28
br label %36
32: ; preds = %28, %23
%33 = load %struct.dns_resolv_conf*, %struct.dns_resolv_conf** %4
%34 = call i32 @dns_resconf_close(%struct.dns_resolv_conf* %33)
%35 = load %struct.dns_hints*, %struct.dns_hints** %6
store %struct.dns_hints* %35, %struct.dns_hints** %3
br label %43
36: ; preds = %31, %22, %16
%37 = load i32, i32* %7
%38 = load i32*, i32** %5
store i32 %37, i32* %38
%39 = load %struct.dns_resolv_conf*, %struct.dns_resolv_conf** %4
%40 = call i32 @dns_resconf_close(%struct.dns_resolv_conf* %39)
%41 = load %struct.dns_hints*, %struct.dns_hints** %6
%42 = call i32 @dns_hints_close(%struct.dns_hints* %41)
store %struct.dns_hints* null, %struct.dns_hints** %3
br label %43
43: ; preds = %36, %32
%44 = load %struct.dns_hints*, %struct.dns_hints** %3
ret %struct.dns_hints* %44
}

LLVM IR (-O2):
%struct.dns_hints = type { i32 }
%struct.dns_resolv_conf = type { i32 }
@.str = [2 x i8] c".\00"
define %struct.dns_hints* @dns_hints_local(%struct.dns_resolv_conf* %0, i32* nocapture writeonly %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq %struct.dns_resolv_conf* %0, null
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @dns_resconf_acquire(%struct.dns_resolv_conf* %0)
br label %11
8: ; preds = %2
%9 = call %struct.dns_resolv_conf* @dns_resconf_local(i32* %3)
%10 = icmp eq %struct.dns_resolv_conf* %9, null
br i1 %10, label %23, label %11
11: ; preds = %8, %6
%12 = phi %struct.dns_resolv_conf* [ %0, %6 ], [ %9, %8 ]
%13 = call %struct.dns_hints* @dns_hints_open(%struct.dns_resolv_conf* %12, i32* %3)
%14 = icmp eq %struct.dns_hints* %13, null
br i1 %14, label %23, label %15
15: ; preds = %11
store i32 0, i32* %3
%16 = call i64 @dns_hints_insert_resconf(%struct.dns_hints* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %struct.dns_resolv_conf* %12, i32* %3)
%17 = icmp eq i64 %16, 0
%18 = load i32, i32* %3
%19 = icmp ne i32 %18, 0
%20 = select i1 %17, i1 %19, i1 false
br i1 %20, label %23, label %21
21: ; preds = %15
%22 = call i32 @dns_resconf_close(%struct.dns_resolv_conf* %12)
br label %29
23: ; preds = %15, %11, %8
%24 = phi %struct.dns_resolv_conf* [ %12, %15 ], [ %12, %11 ], [ null, %8 ]
%25 = phi %struct.dns_hints* [ %13, %15 ], [ null, %11 ], [ null, %8 ]
%26 = load i32, i32* %3
store i32 %26, i32* %1
%27 = call i32 @dns_resconf_close(%struct.dns_resolv_conf* %24)
%28 = call i32 @dns_hints_close(%struct.dns_hints* %25)
br label %29
29: ; preds = %23, %21
%30 = phi %struct.dns_hints* [ null, %23 ], [ %13, %21 ]
ret %struct.dns_hints* %30
}