#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_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  scalar_t__ nscount;
};
struct TYPE_4__ {
  TYPE_1__ _ext;
};
struct __res_state {
  int options;
  TYPE_2__ _u;
};

/* Variables and functions */
int RES_INIT;
int /*<<< orphan*/ abort();
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ herror(char *);
int res_init();
int /*<<< orphan*/ res_nclose(struct __res_state *);
int res_ninit(struct __res_state *);
int main(int argc, char **argv) {
  int r;
  struct __res_state state;
  r = res_ninit(&state);
  if (r) {
    herror("ninit");
    abort();
  }
  r = res_init();
  if (r) {
    herror("init");
    abort();
  }
  assert(state._u._ext.nscount == 0);
  assert(state.options & RES_INIT);
  res_nclose(&state);
  assert(state._u._ext.nscount == 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x28(%rbp),%rdi
call   1050 <res_ninit@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     119f <main+0x3f>
lea    0xe6d(%rip),%rdi
call   1080 <herror@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    $0x0,%al
call   1060 <res_init@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11c6 <main+0x66>
lea    0xe47(%rip),%rdi
call   1080 <herror@plt>
mov    $0x0,%al
call   1030 <abort@plt>
cmpq   $0x0,-0x20(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x28(%rbp),%edi
mov    0x2dfe(%rip),%rax
and    (%rax),%edi
call   1070 <assert@plt>
lea    -0x28(%rbp),%rdi
call   1040 <res_nclose@plt>
cmpq   $0x0,-0x20(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rdi
call   1050 <res_ninit@plt>
test   %eax,%eax
jne    11c2 <main+0x62>
xor    %eax,%eax
call   1060 <res_init@plt>
test   %eax,%eax
jne    11cb <main+0x6b>
xor    %edi,%edi
cmpq   $0x0,0x10(%rsp)
sete   %dil
call   1070 <assert@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
and    0x8(%rsp),%edi
call   1070 <assert@plt>
lea    0x8(%rsp),%rdi
call   1040 <res_nclose@plt>
xor    %edi,%edi
cmpq   $0x0,0x10(%rsp)
sete   %dil
call   1070 <assert@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
lea    0xe37(%rip),%rdi
jmp    11d2 <main+0x72>
lea    0xe2f(%rip),%rdi
call   1080 <herror@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.__res_state = type { i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i64 }
@.str = [6 x i8] c"ninit\00"
@.str.1 = [5 x i8] c"init\00"
@RES_INIT = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.__res_state
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @res_ninit(%struct.__res_state* %7)
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 @herror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (...) @abort()
unreachable
14: ; preds = %2
%15 = call i32 (...) @res_init()
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = call i32 @herror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 (...) @abort()
unreachable
21: ; preds = %14
%22 = getelementptr inbounds %struct.__res_state, %struct.__res_state* %7, i32 0, i32 1
%23 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %22, i32 0, i32 0
%24 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %23, i32 0, i32 0
%25 = load i64, i64* %24
%26 = icmp eq i64 %25, 0
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = getelementptr inbounds %struct.__res_state, %struct.__res_state* %7, i32 0, i32 0
%30 = load i32, i32* %29
%31 = load i32, i32* @RES_INIT
%32 = and i32 %30, %31
%33 = call i32 @assert(i32 %32)
%34 = call i32 @res_nclose(%struct.__res_state* %7)
%35 = getelementptr inbounds %struct.__res_state, %struct.__res_state* %7, i32 0, i32 1
%36 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %35, i32 0, i32 0
%37 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %36, i32 0, i32 0
%38 = load i64, i64* %37
%39 = icmp eq i64 %38, 0
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
ret i32 0
}

LLVM IR (-O2):
%struct.__res_state = type { i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i64 }
@.str = [6 x i8] c"ninit\00"
@.str.1 = [5 x i8] c"init\00"
@RES_INIT = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.__res_state
%4 = bitcast %struct.__res_state* %3 to i8*
%5 = call i32 @res_ninit(%struct.__res_state* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = call i32 @herror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (...) @abort()
unreachable
10: ; preds = %2
%11 = call i32 (...) @res_init()
%12 = icmp eq i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = call i32 @herror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 (...) @abort()
unreachable
16: ; preds = %10
%17 = getelementptr inbounds %struct.__res_state, %struct.__res_state* %3, i64 0, i32 1, i32 0, i32 0
%18 = load i64, i64* %17
%19 = icmp eq i64 %18, 0
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = getelementptr inbounds %struct.__res_state, %struct.__res_state* %3, i64 0, i32 0
%23 = load i32, i32* %22
%24 = load i32, i32* @RES_INIT
%25 = and i32 %24, %23
%26 = call i32 @assert(i32 %25)
%27 = call i32 @res_nclose(%struct.__res_state* %3)
%28 = load i64, i64* %17
%29 = icmp eq i64 %28, 0
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
ret i32 0
}