#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__ apply_cipso(char *);
scalar_t__ apply_rules(char *, int /*<<< orphan*/);
scalar_t__ clear();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int is_smackfs_mounted();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int apply_all(void) {
  if (is_smackfs_mounted() != 1) {
    fprintf(stderr, "ERROR: SmackFS is not mounted.\n");
    return -1;
  }
  if (clear())
    return -1;
  if (apply_rules("/etc/smack/accesses.d", 0))
    perror("apply_rules");
  if (apply_cipso("/etc/smack/cipso.d"))
    perror("apply_cipso");
  return 0;
}


x86 assembly (clang, -O0):
<apply_all>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1060 <is_smackfs_mounted@plt>
cmp    $0x1,%eax
je     1199 <apply_all+0x39>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
lea    0xe78(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1203 <apply_all+0xa3>
mov    $0x0,%al
call   1070 <clear@plt>
cmp    $0x0,%rax
je     11b6 <apply_all+0x56>
movl   $0xffffffff,-0x4(%rbp)
jmp    1203 <apply_all+0xa3>
lea    0xe63(%rip),%rdi
xor    %esi,%esi
call   1080 <apply_rules@plt>
cmp    $0x0,%rax
je     11da <apply_all+0x7a>
lea    0xe61(%rip),%rdi
call   1050 <perror@plt>
lea    0xe61(%rip),%rdi
call   1040 <apply_cipso@plt>
cmp    $0x0,%rax
je     11fc <apply_all+0x9c>
lea    0xe5e(%rip),%rdi
call   1050 <perror@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<apply_all>:
push   %rbx
xor    %eax,%eax
call   1060 <is_smackfs_mounted@plt>
cmp    $0x1,%eax
jne    11b2 <apply_all+0x52>
xor    %eax,%eax
call   1070 <clear@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
jne    11cc <apply_all+0x6c>
lea    0xe9b(%rip),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
call   1080 <apply_rules@plt>
test   %rax,%rax
jne    11d0 <apply_all+0x70>
lea    0xea8(%rip),%rdi
call   1040 <apply_cipso@plt>
test   %rax,%rax
je     11cc <apply_all+0x6c>
lea    0xeaa(%rip),%rdi
call   1050 <perror@plt>
jmp    11cc <apply_all+0x6c>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
lea    0xe3e(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret
lea    0xe5f(%rip),%rdi
call   1050 <perror@plt>
jmp    1193 <apply_all+0x33>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"ERROR: SmackFS is not mounted.\0A\00"
@.str.1 = [22 x i8] c"/etc/smack/accesses.d\00"
@.str.2 = [12 x i8] c"apply_rules\00"
@.str.3 = [19 x i8] c"/etc/smack/cipso.d\00"
@.str.4 = [12 x i8] c"apply_cipso\00"
define i32 @apply_all() {
%1 = alloca i32
%2 = call i32 (...) @is_smackfs_mounted()
%3 = icmp ne i32 %2, 1
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = load i32, i32* @stderr
%6 = call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %22
7: ; preds = %0
%8 = call i64 (...) @clear()
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %7
store i32 -1, i32* %1
br label %22
11: ; preds = %7
%12 = call i64 @apply_rules(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 0)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
%17 = call i64 @apply_cipso(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %21
21: ; preds = %19, %16
store i32 0, i32* %1
br label %22
22: ; preds = %21, %10, %4
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"ERROR: SmackFS is not mounted.\0A\00"
@.str.1 = [22 x i8] c"/etc/smack/accesses.d\00"
@.str.2 = [12 x i8] c"apply_rules\00"
@.str.3 = [19 x i8] c"/etc/smack/cipso.d\00"
@.str.4 = [12 x i8] c"apply_cipso\00"
define i32 @apply_all() {
%1 = tail call i32 (...) @is_smackfs_mounted()
%2 = icmp eq i32 %1, 1
br i1 %2, label %6, label %3
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %19
6: ; preds = %0
%7 = tail call i64 (...) @clear()
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %6
%10 = tail call i64 @apply_rules(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %9
%15 = tail call i64 @apply_cipso(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
br label %19
19: ; preds = %14, %17, %6, %3
%20 = phi i32 [ -1, %3 ], [ -1, %6 ], [ 0, %17 ], [ 0, %14 ]
ret i32 %20
}