#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 test {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ expect(char *, int, int /*<<< orphan*/, int /*<<< orphan*/);
int sysctlbyname(char *, int /*<<< orphan*/ *, size_t *, int /*<<< orphan*/ *,
                 int /*<<< orphan*/);
void priv_msgbuf_unprivok(int asroot, int injail, struct test *test) {
  size_t len;
  int error;
  error = sysctlbyname("kern.msgbuf", NULL, &len, NULL, 0);
  if (asroot && injail)
    expect("priv_msgbuf_unprivok(asroot, injail)", error, 0, 0);
  if (asroot && !injail)
    expect("priv_msgbuf_unprivok(asroot, !injail)", error, 0, 0);
  if (!asroot && injail)
    expect("priv_msgbuf_unprivok(!asroot, injail)", error, 0, 0);
  if (!asroot && !injail)
    expect("priv_msgbuf_unprivok(!asroot, !injail)", error, 0, 0);
}


x86 assembly (clang, -O0):
<priv_msgbuf_unprivok>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
lea    0xec7(%rip),%rdi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x18(%rbp),%rdx
xor    %r8d,%r8d
mov    %rcx,%rsi
call   1040 <sysctlbyname@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1176 <priv_msgbuf_unprivok+0x56>
cmpl   $0x0,-0x8(%rbp)
je     1176 <priv_msgbuf_unprivok+0x56>
mov    -0x1c(%rbp),%esi
lea    0xe9f(%rip),%rdi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1030 <expect@plt>
cmpl   $0x0,-0x4(%rbp)
je     119d <priv_msgbuf_unprivok+0x7d>
cmpl   $0x0,-0x8(%rbp)
jne    119d <priv_msgbuf_unprivok+0x7d>
mov    -0x1c(%rbp),%esi
lea    0xe9d(%rip),%rdi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1030 <expect@plt>
cmpl   $0x0,-0x4(%rbp)
jne    11c4 <priv_msgbuf_unprivok+0xa4>
cmpl   $0x0,-0x8(%rbp)
je     11c4 <priv_msgbuf_unprivok+0xa4>
mov    -0x1c(%rbp),%esi
lea    0xe9c(%rip),%rdi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1030 <expect@plt>
cmpl   $0x0,-0x4(%rbp)
jne    11eb <priv_msgbuf_unprivok+0xcb>
cmpl   $0x0,-0x8(%rbp)
jne    11eb <priv_msgbuf_unprivok+0xcb>
mov    -0x1c(%rbp),%esi
lea    0xe9b(%rip),%rdi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1030 <expect@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<priv_msgbuf_unprivok>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
lea    0xecd(%rip),%rdi
lea    0x8(%rsp),%rdx
xor    %esi,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <sysctlbyname@plt>
mov    %eax,%r14d
test   %ebp,%ebp
je     1162 <priv_msgbuf_unprivok+0x42>
test   %ebx,%ebx
je     1162 <priv_msgbuf_unprivok+0x42>
lea    0xeb6(%rip),%rdi
mov    %r14d,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <expect@plt>
test   %ebp,%ebp
je     117d <priv_msgbuf_unprivok+0x5d>
test   %ebx,%ebx
jne    117d <priv_msgbuf_unprivok+0x5d>
lea    0xec0(%rip),%rdi
mov    %r14d,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <expect@plt>
test   %ebp,%ebp
jne    1198 <priv_msgbuf_unprivok+0x78>
test   %ebx,%ebx
je     1198 <priv_msgbuf_unprivok+0x78>
lea    0xecb(%rip),%rdi
mov    %r14d,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <expect@plt>
or     %ebp,%ebx
jne    11af <priv_msgbuf_unprivok+0x8f>
lea    0xeda(%rip),%rdi
mov    %r14d,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <expect@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.test = type { i32 }
@.str = [12 x i8] c"kern.msgbuf\00"
@.str.1 = [37 x i8] c"priv_msgbuf_unprivok(asroot, injail)\00"
@.str.2 = [38 x i8] c"priv_msgbuf_unprivok(asroot, !injail)\00"
@.str.3 = [38 x i8] c"priv_msgbuf_unprivok(!asroot, injail)\00"
@.str.4 = [39 x i8] c"priv_msgbuf_unprivok(!asroot, !injail)\00"
define void @priv_msgbuf_unprivok(i32 %0, i32 %1, %struct.test* nocapture readnone %2) {
%4 = alloca i64
%5 = bitcast i64* %4 to i8*
%6 = call i32 @sysctlbyname(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32* null, i64* %4, i32* null, i32 0)
%7 = icmp ne i32 %0, 0
%8 = icmp ne i32 %1, 0
%9 = and i1 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = call i32 @expect(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 0, i32 0)
br label %12
12: ; preds = %10, %3
%13 = icmp eq i32 %0, 0
%14 = or i1 %13, %8
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = call i32 @expect(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %6, i32 0, i32 0)
br label %17
17: ; preds = %15, %12
%18 = and i1 %13, %8
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = call i32 @expect(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %6, i32 0, i32 0)
br label %21
21: ; preds = %19, %17
%22 = or i32 %1, %0
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @expect(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 %6, i32 0, i32 0)
br label %26
26: ; preds = %24, %21
ret void
}