#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*/ EPERM;
int acct(int /*<<< orphan*/ *);
int /*<<< orphan*/ expect(char *, int, int, int /*<<< orphan*/);
void priv_acct_disable(int asroot, int injail, struct test *test) {
  int error;
  error = acct(NULL);
  if (asroot && injail)
    expect("priv_acct_disable(root, jail)", error, -1, EPERM);
  if (asroot && !injail)
    expect("priv_acct_disable(root, !jail)", error, 0, 0);
  if (!asroot && injail)
    expect("priv_acct_disable(!root, jail)", error, -1, EPERM);
  if (!asroot && !injail)
    expect("priv_acct_disable(!root, !jail)", error, -1, EPERM);
}


x86 assembly (clang, -O0):
<priv_acct_disable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <acct@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     116f <priv_acct_disable+0x4f>
cmpl   $0x0,-0x8(%rbp)
je     116f <priv_acct_disable+0x4f>
mov    -0x14(%rbp),%esi
mov    0x2e7c(%rip),%rax
mov    (%rax),%ecx
lea    0xe9b(%rip),%rdi
mov    $0xffffffff,%edx
call   1030 <expect@plt>
cmpl   $0x0,-0x4(%rbp)
je     1196 <priv_acct_disable+0x76>
cmpl   $0x0,-0x8(%rbp)
jne    1196 <priv_acct_disable+0x76>
mov    -0x14(%rbp),%esi
lea    0xe91(%rip),%rdi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1030 <expect@plt>
cmpl   $0x0,-0x4(%rbp)
jne    11c7 <priv_acct_disable+0xa7>
cmpl   $0x0,-0x8(%rbp)
je     11c7 <priv_acct_disable+0xa7>
mov    -0x14(%rbp),%esi
mov    0x2e24(%rip),%rax
mov    (%rax),%ecx
lea    0xe80(%rip),%rdi
mov    $0xffffffff,%edx
call   1030 <expect@plt>
cmpl   $0x0,-0x4(%rbp)
jne    11f8 <priv_acct_disable+0xd8>
cmpl   $0x0,-0x8(%rbp)
jne    11f8 <priv_acct_disable+0xd8>
mov    -0x14(%rbp),%esi
mov    0x2df3(%rip),%rax
mov    (%rax),%ecx
lea    0xe6e(%rip),%rdi
mov    $0xffffffff,%edx
call   1030 <expect@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<priv_acct_disable>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %edi,%ebx
xor    %edi,%edi
call   1040 <acct@plt>
mov    %eax,%r14d
test   %ebx,%ebx
je     1157 <priv_acct_disable+0x37>
test   %ebp,%ebp
je     1157 <priv_acct_disable+0x37>
mov    0x2e97(%rip),%rax
mov    (%rax),%ecx
lea    0xeb6(%rip),%rdi
mov    %r14d,%esi
mov    $0xffffffff,%edx
call   1030 <expect@plt>
test   %ebx,%ebx
je     1172 <priv_acct_disable+0x52>
test   %ebp,%ebp
jne    1172 <priv_acct_disable+0x52>
lea    0xeb8(%rip),%rdi
mov    %r14d,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <expect@plt>
test   %ebx,%ebx
jne    1197 <priv_acct_disable+0x77>
test   %ebp,%ebp
je     1197 <priv_acct_disable+0x77>
mov    0x2e57(%rip),%rax
mov    (%rax),%ecx
lea    0xeb3(%rip),%rdi
mov    %r14d,%esi
mov    $0xffffffff,%edx
call   1030 <expect@plt>
or     %ebx,%ebp
je     11a0 <priv_acct_disable+0x80>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e31(%rip),%rax
mov    (%rax),%ecx
lea    0xeac(%rip),%rdi
mov    %r14d,%esi
mov    $0xffffffff,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <expect@plt>

LLVM IR (-O0):
%struct.test = type { i32 }
@.str = [30 x i8] c"priv_acct_disable(root, jail)\00"
@EPERM = global i32 0
@.str.1 = [31 x i8] c"priv_acct_disable(root, !jail)\00"
@.str.2 = [31 x i8] c"priv_acct_disable(!root, jail)\00"
@.str.3 = [32 x i8] c"priv_acct_disable(!root, !jail)\00"
define void @priv_acct_disable(i32 %0, i32 %1, %struct.test* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.test*
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store %struct.test* %2, %struct.test** %6
%8 = call i32 @acct(i32* null)
store i32 %8, i32* %7
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %3
%12 = load i32, i32* %5
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = load i32, i32* %7
%16 = load i32, i32* @EPERM
%17 = call i32 @expect(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %15, i32 -1, i32 %16)
br label %18
18: ; preds = %14, %11, %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* %7
%26 = call i32 @expect(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, 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 %37, label %30
30: ; preds = %27
%31 = load i32, i32* %5
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = load i32, i32* %7
%35 = load i32, i32* @EPERM
%36 = call i32 @expect(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %34, i32 -1, i32 %35)
br label %37
37: ; preds = %33, %30, %27
%38 = load i32, i32* %4
%39 = icmp ne i32 %38, 0
br i1 %39, label %47, label %40
40: ; preds = %37
%41 = load i32, i32* %5
%42 = icmp ne i32 %41, 0
br i1 %42, label %47, label %43
43: ; preds = %40
%44 = load i32, i32* %7
%45 = load i32, i32* @EPERM
%46 = call i32 @expect(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %44, i32 -1, i32 %45)
br label %47
47: ; preds = %43, %40, %37
ret void
}

LLVM IR (-O2):
%struct.test = type { i32 }
@.str = [30 x i8] c"priv_acct_disable(root, jail)\00"
@EPERM = global i32 0
@.str.1 = [31 x i8] c"priv_acct_disable(root, !jail)\00"
@.str.2 = [31 x i8] c"priv_acct_disable(!root, jail)\00"
@.str.3 = [32 x i8] c"priv_acct_disable(!root, !jail)\00"
define void @priv_acct_disable(i32 %0, i32 %1, %struct.test* nocapture readnone %2) {
%4 = tail call i32 @acct(i32* null)
%5 = icmp ne i32 %0, 0
%6 = icmp ne i32 %1, 0
%7 = and i1 %5, %6
br i1 %7, label %8, label %11
8: ; preds = %3
%9 = load i32, i32* @EPERM
%10 = tail call i32 @expect(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %4, i32 -1, i32 %9)
br label %11
11: ; preds = %8, %3
%12 = icmp eq i32 %0, 0
%13 = or i1 %12, %6
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 @expect(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 0, i32 0)
br label %16
16: ; preds = %14, %11
%17 = and i1 %12, %6
br i1 %17, label %18, label %21
18: ; preds = %16
%19 = load i32, i32* @EPERM
%20 = tail call i32 @expect(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %4, i32 -1, i32 %19)
br label %21
21: ; preds = %18, %16
%22 = or i32 %1, %0
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i32, i32* @EPERM
%26 = tail call i32 @expect(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %4, i32 -1, i32 %25)
br label %27
27: ; preds = %24, %21
ret void
}