#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int options;
};

/* Variables and functions */
int RES_INIT;
int RES_STAYOPEN;
int RES_USEVC;
TYPE_1__ _res;
int res_init();
void _sethostdnsent(int stayopen) {
  if ((_res.options & RES_INIT) == 0 && res_init() == -1)
    return;
  if (stayopen)
    _res.options |= RES_STAYOPEN | RES_USEVC;
}


x86 assembly (clang, -O0):
<_sethostdnsent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2ebe(%rip),%rax
mov    (%rax),%eax
mov    0x2ea5(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    114b <_sethostdnsent+0x3b>
mov    $0x0,%al
call   1030 <res_init@plt>
cmp    $0xffffffff,%eax
jne    114b <_sethostdnsent+0x3b>
jmp    1179 <_sethostdnsent+0x69>
cmpl   $0x0,-0x4(%rbp)
je     1179 <_sethostdnsent+0x69>
mov    0x2e6c(%rip),%rax
mov    (%rax),%ecx
mov    0x2e83(%rip),%rax
or     (%rax),%ecx
mov    0x2e72(%rip),%rax
or     (%rax),%ecx
mov    0x2e69(%rip),%rax
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_sethostdnsent>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    0x2ec3(%rip),%r14
mov    (%r14),%eax
mov    0x2ea9(%rip),%rcx
test   %eax,(%rcx)
je     1131 <_sethostdnsent+0x21>
test   %ebx,%ebx
jne    1144 <_sethostdnsent+0x34>
jmp    115b <_sethostdnsent+0x4b>
xor    %eax,%eax
call   1030 <res_init@plt>
test   %ebx,%ebx
je     115b <_sethostdnsent+0x4b>
cmp    $0xffffffff,%eax
je     115b <_sethostdnsent+0x4b>
mov    (%r14),%eax
mov    0x2e7d(%rip),%rcx
mov    0x2e96(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
or     %eax,%edx
mov    %edx,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_2__ = type { i32 }
@_res = global %struct.TYPE_2__ zeroinitializer
@RES_INIT = global i32 0
@RES_STAYOPEN = global i32 0
@RES_USEVC = global i32 0
define void @_sethostdnsent(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* getelementptr inbounds (%struct.TYPE_2__, %struct.TYPE_2__* @_res, i32 0, i32 0)
%4 = load i32, i32* @RES_INIT
%5 = and i32 %3, %4
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = call i32 (...) @res_init()
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %11
10: ; preds = %7
br label %20
11: ; preds = %7, %1
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = load i32, i32* @RES_STAYOPEN
%16 = load i32, i32* @RES_USEVC
%17 = or i32 %15, %16
%18 = load i32, i32* getelementptr inbounds (%struct.TYPE_2__, %struct.TYPE_2__* @_res, i32 0, i32 0)
%19 = or i32 %18, %17
store i32 %19, i32* getelementptr inbounds (%struct.TYPE_2__, %struct.TYPE_2__* @_res, i32 0, i32 0)
br label %20
20: ; preds = %10, %14, %11
ret void
}

LLVM IR (-O2):
%struct.TYPE_2__ = type { i32 }
@_res = global %struct.TYPE_2__ zeroinitializer
@RES_INIT = global i32 0
@RES_STAYOPEN = global i32 0
@RES_USEVC = global i32 0
define void @_sethostdnsent(i32 %0) {
%2 = load i32, i32* getelementptr inbounds (%struct.TYPE_2__, %struct.TYPE_2__* @_res, i64 0, i32 0)
%3 = load i32, i32* @RES_INIT
%4 = and i32 %3, %2
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %1
%7 = tail call i32 (...) @res_init()
%8 = icmp ne i32 %7, -1
%9 = icmp ne i32 %0, 0
%10 = and i1 %9, %8
br i1 %10, label %11, label %21
11: ; preds = %6
%12 = load i32, i32* getelementptr inbounds (%struct.TYPE_2__, %struct.TYPE_2__* @_res, i64 0, i32 0)
br label %15
13: ; preds = %1
%14 = icmp eq i32 %0, 0
br i1 %14, label %21, label %15
15: ; preds = %11, %13
%16 = phi i32 [ %12, %11 ], [ %2, %13 ]
%17 = load i32, i32* @RES_STAYOPEN
%18 = load i32, i32* @RES_USEVC
%19 = or i32 %18, %17
%20 = or i32 %19, %16
store i32 %20, i32* getelementptr inbounds (%struct.TYPE_2__, %struct.TYPE_2__* @_res, i64 0, i32 0)
br label %21
21: ; preds = %6, %15, %13
ret void
}