#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*/ EACCES;
int /*<<< orphan*/ PRIO_PROCESS;
int /*<<< orphan*/ expect(char *, int, int, int /*<<< orphan*/);
int setpriority(int /*<<< orphan*/, int /*<<< orphan*/, int);
void priv_sched_setpriority_myproc(int asroot, int injail, struct test *test) {
  int error;
  error = setpriority(PRIO_PROCESS, 0, -1);
  if (asroot && injail)
    expect("priv_sched_setpriority_myproc(asroot, injail)", error, -1, EACCES);
  if (asroot && !injail)
    expect("priv_sched_setpriority_myproc(asroot, !injail)", error, 0, 0);
  if (!asroot && injail)
    expect("priv_sched_setpriority_myproc(!asroot, injail)", error, -1, EACCES);
  if (!asroot && !injail)
    expect("priv_sched_setpriority_myproc(!asroot, !injail)", error, -1,
           EACCES);
}


x86 assembly (clang, -O0):
<priv_sched_setpriority_myproc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    0x2e9f(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
mov    $0xffffffff,%edx
call   1040 <setpriority@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     117b <priv_sched_setpriority_myproc+0x5b>
cmpl   $0x0,-0x8(%rbp)
je     117b <priv_sched_setpriority_myproc+0x5b>
mov    -0x14(%rbp),%esi
mov    0x2e80(%rip),%rax
mov    (%rax),%ecx
lea    0xe8f(%rip),%rdi
mov    $0xffffffff,%edx
call   1030 <expect@plt>
cmpl   $0x0,-0x4(%rbp)
je     11a2 <priv_sched_setpriority_myproc+0x82>
cmpl   $0x0,-0x8(%rbp)
jne    11a2 <priv_sched_setpriority_myproc+0x82>
mov    -0x14(%rbp),%esi
lea    0xe95(%rip),%rdi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1030 <expect@plt>
cmpl   $0x0,-0x4(%rbp)
jne    11d3 <priv_sched_setpriority_myproc+0xb3>
cmpl   $0x0,-0x8(%rbp)
je     11d3 <priv_sched_setpriority_myproc+0xb3>
mov    -0x14(%rbp),%esi
mov    0x2e28(%rip),%rax
mov    (%rax),%ecx
lea    0xe94(%rip),%rdi
mov    $0xffffffff,%edx
call   1030 <expect@plt>
cmpl   $0x0,-0x4(%rbp)
jne    1204 <priv_sched_setpriority_myproc+0xe4>
cmpl   $0x0,-0x8(%rbp)
jne    1204 <priv_sched_setpriority_myproc+0xe4>
mov    -0x14(%rbp),%esi
mov    0x2df7(%rip),%rax
mov    (%rax),%ecx
lea    0xe92(%rip),%rdi
mov    $0xffffffff,%edx
call   1030 <expect@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<priv_sched_setpriority_myproc>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%ebp
mov    0x2ea9(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
mov    $0xffffffff,%edx
call   1040 <setpriority@plt>
mov    %eax,%r14d
test   %ebp,%ebp
je     1165 <priv_sched_setpriority_myproc+0x45>
test   %ebx,%ebx
je     1165 <priv_sched_setpriority_myproc+0x45>
mov    0x2e99(%rip),%rax
mov    (%rax),%ecx
lea    0xea8(%rip),%rdi
mov    %r14d,%esi
mov    $0xffffffff,%edx
call   1030 <expect@plt>
test   %ebp,%ebp
je     1180 <priv_sched_setpriority_myproc+0x60>
test   %ebx,%ebx
jne    1180 <priv_sched_setpriority_myproc+0x60>
lea    0xeba(%rip),%rdi
mov    %r14d,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <expect@plt>
test   %ebp,%ebp
jne    11a5 <priv_sched_setpriority_myproc+0x85>
test   %ebx,%ebx
je     11a5 <priv_sched_setpriority_myproc+0x85>
mov    0x2e59(%rip),%rax
mov    (%rax),%ecx
lea    0xec5(%rip),%rdi
mov    %r14d,%esi
mov    $0xffffffff,%edx
call   1030 <expect@plt>
or     %ebp,%ebx
je     11ae <priv_sched_setpriority_myproc+0x8e>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e33(%rip),%rax
mov    (%rax),%ecx
lea    0xece(%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 }
@PRIO_PROCESS = global i32 0
@.str = [46 x i8] c"priv_sched_setpriority_myproc(asroot, injail)\00"
@EACCES = global i32 0
@.str.1 = [47 x i8] c"priv_sched_setpriority_myproc(asroot, !injail)\00"
@.str.2 = [47 x i8] c"priv_sched_setpriority_myproc(!asroot, injail)\00"
@.str.3 = [48 x i8] c"priv_sched_setpriority_myproc(!asroot, !injail)\00"
define void @priv_sched_setpriority_myproc(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 = load i32, i32* @PRIO_PROCESS
%9 = call i32 @setpriority(i32 %8, i32 0, i32 -1)
store i32 %9, i32* %7
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %3
%13 = load i32, i32* %5
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i32, i32* %7
%17 = load i32, i32* @EACCES
%18 = call i32 @expect(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %16, i32 -1, i32 %17)
br label %19
19: ; preds = %15, %12, %3
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = load i32, i32* %5
%24 = icmp ne i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load i32, i32* %7
%27 = call i32 @expect(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %26, i32 0, i32 0)
br label %28
28: ; preds = %25, %22, %19
%29 = load i32, i32* %4
%30 = icmp ne i32 %29, 0
br i1 %30, label %38, label %31
31: ; preds = %28
%32 = load i32, i32* %5
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %31
%35 = load i32, i32* %7
%36 = load i32, i32* @EACCES
%37 = call i32 @expect(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32 %35, i32 -1, i32 %36)
br label %38
38: ; preds = %34, %31, %28
%39 = load i32, i32* %4
%40 = icmp ne i32 %39, 0
br i1 %40, label %48, label %41
41: ; preds = %38
%42 = load i32, i32* %5
%43 = icmp ne i32 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %41
%45 = load i32, i32* %7
%46 = load i32, i32* @EACCES
%47 = call i32 @expect(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i32 %45, i32 -1, i32 %46)
br label %48
48: ; preds = %44, %41, %38
ret void
}

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