#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 */

/* Variables and functions */
scalar_t__ WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ execl(char *, char *, char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ logMessage(int, char *, ...);
int /*<<< orphan*/ setenv(char *, char *, int);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ waitpid(int, int *, int /*<<< orphan*/);
int loadpolicy() {
  int pid, status;
  logMessage(20, "Loading SELinux policy");
  if (!(pid = fork())) {
    setenv("LD_LIBRARY_PATH",
           "/lib64:/usr/lib64:/usr/X11R6/lib64:/usr/kerberos/lib64:/mnt/usr/"
           "lib64:/mnt/sysimage/lib64:/mnt/sysimage/usr/lib64",
           1);
    execl("/usr/sbin/load_policy", "/usr/sbin/load_policy", "-q", "-b", NULL);
    logMessage(40, "exec of load_policy failed: %s", strerror(errno));
    exit(1);
  }
  waitpid(pid, &status, 0);
  if (WIFEXITED(status) && (WEXITSTATUS(status) != 0))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<loadpolicy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x14,%edi
lea    0xe5c(%rip),%rsi
mov    $0x0,%al
call   1030 <logMessage@plt>
mov    $0x0,%al
call   10b0 <fork@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jne    1225 <loadpolicy+0x95>
lea    0xe52(%rip),%rdi
lea    0xe5b(%rip),%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
lea    0xebc(%rip),%rsi
lea    0xecb(%rip),%rdx
lea    0xec7(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
mov    %rsi,%rdi
call   10a0 <execl@plt>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %eax,%edx
mov    $0x28,%edi
lea    0xea1(%rip),%rsi
mov    $0x0,%al
call   1030 <logMessage@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%edi
lea    -0xc(%rbp),%rsi
xor    %edx,%edx
call   1060 <waitpid@plt>
mov    -0xc(%rbp),%edi
call   1070 <WIFEXITED@plt>
cmp    $0x0,%rax
je     1263 <loadpolicy+0xd3>
mov    -0xc(%rbp),%edi
call   1050 <WEXITSTATUS@plt>
cmp    $0x0,%rax
je     1263 <loadpolicy+0xd3>
movl   $0x1,-0x4(%rbp)
jmp    126a <loadpolicy+0xda>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loadpolicy>:
push   %rax
lea    0xe68(%rip),%rsi
mov    $0x14,%edi
xor    %eax,%eax
call   1030 <logMessage@plt>
xor    %eax,%eax
call   10b0 <fork@plt>
test   %eax,%eax
je     11e7 <loadpolicy+0x57>
lea    0x4(%rsp),%rsi
mov    %eax,%edi
xor    %edx,%edx
call   1060 <waitpid@plt>
mov    0x4(%rsp),%edi
call   1070 <WIFEXITED@plt>
test   %rax,%rax
je     11e3 <loadpolicy+0x53>
mov    0x4(%rsp),%edi
call   1050 <WEXITSTATUS@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
je     11e3 <loadpolicy+0x53>
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret
lea    0xe29(%rip),%rdi
lea    0xe32(%rip),%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
lea    0xe93(%rip),%rdi
lea    0xea2(%rip),%rdx
lea    0xe9e(%rip),%rcx
mov    %rdi,%rsi
xor    %r8d,%r8d
call   10a0 <execl@plt>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe81(%rip),%rsi
mov    $0x28,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <logMessage@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Loading SELinux policy\00"
@.str.1 = [16 x i8] c"LD_LIBRARY_PATH\00"
@.str.2 = [114 x i8] c"/lib64:/usr/lib64:/usr/X11R6/lib64:/usr/kerberos/lib64:/mnt/usr/lib64:/mnt/sysimage/lib64:/mnt/sysimage/usr/lib64\00"
@.str.3 = [22 x i8] c"/usr/sbin/load_policy\00"
@.str.4 = [3 x i8] c"-q\00"
@.str.5 = [3 x i8] c"-b\00"
@.str.6 = [31 x i8] c"exec of load_policy failed: %s\00"
@errno = global i32 0
define i32 @loadpolicy() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 (i32, i8*, ...) @logMessage(i32 20, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (...) @fork()
store i32 %5, i32* %2
%6 = icmp ne i32 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %0
%8 = call i32 @setenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([114 x i8], [114 x i8]* @.str.2, i64 0, i64 0), i32 1)
%9 = call i32 @execl(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* null)
%10 = load i32, i32* @errno
%11 = call i32 @strerror(i32 %10)
%12 = call i32 (i32, i8*, ...) @logMessage(i32 40, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %11)
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %0
%15 = load i32, i32* %2
%16 = call i32 @waitpid(i32 %15, i32* %3, i32 0)
%17 = load i32, i32* %3
%18 = call i64 @WIFEXITED(i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %14
%21 = load i32, i32* %3
%22 = call i64 @WEXITSTATUS(i32 %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 1, i32* %1
br label %26
25: ; preds = %20, %14
store i32 0, i32* %1
br label %26
26: ; preds = %25, %24
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
@.str = [23 x i8] c"Loading SELinux policy\00"
@.str.1 = [16 x i8] c"LD_LIBRARY_PATH\00"
@.str.2 = [114 x i8] c"/lib64:/usr/lib64:/usr/X11R6/lib64:/usr/kerberos/lib64:/mnt/usr/lib64:/mnt/sysimage/lib64:/mnt/sysimage/usr/lib64\00"
@.str.3 = [22 x i8] c"/usr/sbin/load_policy\00"
@.str.4 = [3 x i8] c"-q\00"
@.str.5 = [3 x i8] c"-b\00"
@.str.6 = [31 x i8] c"exec of load_policy failed: %s\00"
@errno = global i32 0
define i32 @loadpolicy() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i32, i8*, ...) @logMessage(i32 20, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 (...) @fork()
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %0
%7 = tail call i32 @setenv(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([114 x i8], [114 x i8]* @.str.2, i64 0, i64 0), i32 1)
%8 = tail call i32 @execl(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* null)
%9 = load i32, i32* @errno
%10 = tail call i32 @strerror(i32 %9)
%11 = tail call i32 (i32, i8*, ...) @logMessage(i32 40, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %10)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %0
%14 = call i32 @waitpid(i32 %4, i32* %1, i32 0)
%15 = load i32, i32* %1
%16 = call i64 @WIFEXITED(i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %13
%19 = load i32, i32* %1
%20 = call i64 @WEXITSTATUS(i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18, %13
br label %23
23: ; preds = %18, %22
%24 = phi i32 [ 0, %22 ], [ 1, %18 ]
ret i32 %24
}