#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;
};

/* Variables and functions */
int /*<<< orphan*/ dns_resconf_close(struct dns_resolv_conf *);
int dns_resconf_loadpath(struct dns_resolv_conf *, char *);
struct dns_resolv_conf *dns_resconf_open(int *);
struct dns_resolv_conf *dns_resconf_local(int *error_) {
  struct dns_resolv_conf *resconf;
  int error;
  if (!(resconf = dns_resconf_open(&error)))
    goto error;
  if ((error = dns_resconf_loadpath(resconf, "/etc/resolv.conf")))
    goto error;
  return resconf;
error:
  *error_ = error;
  dns_resconf_close(resconf);
  return 0;
}


x86 assembly (clang, -O0):
<dns_resconf_local>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x1c(%rbp),%rdi
call   1030 <dns_resconf_open@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1158 <dns_resconf_local+0x28>
jmp    1186 <dns_resconf_local+0x56>
mov    -0x18(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1050 <dns_resconf_loadpath@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
je     1179 <dns_resconf_local+0x49>
jmp    1186 <dns_resconf_local+0x56>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11a0 <dns_resconf_local+0x70>
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
call   1040 <dns_resconf_close@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dns_resconf_local>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0x4(%rsp),%rdi
call   1030 <dns_resconf_open@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1162 <dns_resconf_local+0x32>
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdi
call   1050 <dns_resconf_loadpath@plt>
mov    %eax,0x4(%rsp)
test   %eax,%eax
jne    1166 <dns_resconf_local+0x36>
jmp    1173 <dns_resconf_local+0x43>
mov    0x4(%rsp),%eax
mov    %eax,(%r14)
mov    %rbx,%rdi
call   1040 <dns_resconf_close@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.dns_resolv_conf = type { i32 }
@.str = [17 x i8] c"/etc/resolv.conf\00"
define %struct.dns_resolv_conf* @dns_resconf_local(i32* %0) {
%2 = alloca %struct.dns_resolv_conf*
%3 = alloca i32*
%4 = alloca %struct.dns_resolv_conf*
%5 = alloca i32
store i32* %0, i32** %3
%6 = call %struct.dns_resolv_conf* @dns_resconf_open(i32* %5)
store %struct.dns_resolv_conf* %6, %struct.dns_resolv_conf** %4
%7 = icmp ne %struct.dns_resolv_conf* %6, null
br i1 %7, label %9, label %8
8: ; preds = %1
br label %16
9: ; preds = %1
%10 = load %struct.dns_resolv_conf*, %struct.dns_resolv_conf** %4
%11 = call i32 @dns_resconf_loadpath(%struct.dns_resolv_conf* %10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i32 %11, i32* %5
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %9
br label %16
14: ; preds = %9
%15 = load %struct.dns_resolv_conf*, %struct.dns_resolv_conf** %4
store %struct.dns_resolv_conf* %15, %struct.dns_resolv_conf** %2
br label %21
16: ; preds = %13, %8
%17 = load i32, i32* %5
%18 = load i32*, i32** %3
store i32 %17, i32* %18
%19 = load %struct.dns_resolv_conf*, %struct.dns_resolv_conf** %4
%20 = call i32 @dns_resconf_close(%struct.dns_resolv_conf* %19)
store %struct.dns_resolv_conf* null, %struct.dns_resolv_conf** %2
br label %21
21: ; preds = %16, %14
%22 = load %struct.dns_resolv_conf*, %struct.dns_resolv_conf** %2
ret %struct.dns_resolv_conf* %22
}

LLVM IR (-O2):
%struct.dns_resolv_conf = type { i32 }
@.str = [17 x i8] c"/etc/resolv.conf\00"
define %struct.dns_resolv_conf* @dns_resconf_local(i32* nocapture writeonly %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call %struct.dns_resolv_conf* @dns_resconf_open(i32* %2)
%5 = icmp eq %struct.dns_resolv_conf* %4, null
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = load i32, i32* %2
br label %11
8: ; preds = %1
%9 = call i32 @dns_resconf_loadpath(%struct.dns_resolv_conf* %4, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i32 %9, i32* %2
%10 = icmp eq i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %6, %8
%12 = phi i32 [ %7, %6 ], [ %9, %8 ]
store i32 %12, i32* %0
%13 = call i32 @dns_resconf_close(%struct.dns_resolv_conf* %4)
br label %14
14: ; preds = %8, %11
%15 = phi %struct.dns_resolv_conf* [ null, %11 ], [ %4, %8 ]
ret %struct.dns_resolv_conf* %15
}