#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 */
int /*<<< orphan*/ STDIN_FILENO;
scalar_t__ apply_cipso(char *);
scalar_t__ apply_cipso_file(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int is_smackfs_mounted();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (is_smackfs_mounted() != 1) {
    fprintf(stderr, "SmackFS is not mounted.\n");
    exit(1);
  }
  if (argc > 2) {
    fprintf(stderr, "Usage: %s <path>\n", argv[0]);
    exit(1);
  }
  if (argc == 1) {
    if (apply_cipso_file(STDIN_FILENO)) {
      perror("apply_cipso_file");
      exit(1);
    }
  } else {
    if (apply_cipso(argv[1])) {
      perror("apply_cipso");
      exit(1);
    }
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1080 <is_smackfs_mounted@plt>
cmp    $0x1,%eax
je     11a7 <main+0x47>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
cmpl   $0x2,-0x8(%rbp)
jle    11d9 <main+0x79>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe51(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
cmpl   $0x1,-0x8(%rbp)
jne    1216 <main+0xb6>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
call   1050 <apply_cipso_file@plt>
cmp    $0x0,%rax
je     1211 <main+0xb1>
lea    0xe29(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    1248 <main+0xe8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <apply_cipso@plt>
cmp    $0x0,%rax
je     1243 <main+0xe3>
lea    0xe08(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    1248 <main+0xe8>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1080 <is_smackfs_mounted@plt>
cmp    $0x1,%eax
jne    119d <main+0x3d>
cmp    $0x3,%ebp
jl     11be <main+0x5e>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe8d(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe53(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
cmp    $0x1,%ebp
jne    11df <main+0x7f>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
call   1050 <apply_cipso_file@plt>
test   %rax,%rax
je     11ed <main+0x8d>
lea    0xe4e(%rip),%rdi
jmp    11fb <main+0x9b>
mov    0x8(%rbx),%rdi
call   1040 <apply_cipso@plt>
test   %rax,%rax
jne    11f4 <main+0x94>
xor    %edi,%edi
call   1070 <exit@plt>
lea    0xe41(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"SmackFS is not mounted.\0A\00"
@.str.1 = [18 x i8] c"Usage: %s <path>\0A\00"
@STDIN_FILENO = global i32 0
@.str.2 = [17 x i8] c"apply_cipso_file\00"
@.str.3 = [12 x i8] c"apply_cipso\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 (...) @is_smackfs_mounted()
%7 = icmp ne i32 %6, 1
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 2
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %12
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %33
25: ; preds = %22
%26 = load i32, i32* @STDIN_FILENO
%27 = call i64 @apply_cipso_file(i32 %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %25
br label %43
33: ; preds = %22
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i64 @apply_cipso(i8* %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %33
%40 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %33
br label %43
43: ; preds = %42, %32
%44 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"SmackFS is not mounted.\0A\00"
@.str.1 = [18 x i8] c"Usage: %s <path>\0A\00"
@STDIN_FILENO = global i32 0
@.str.2 = [17 x i8] c"apply_cipso_file\00"
@.str.3 = [12 x i8] c"apply_cipso\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 (...) @is_smackfs_mounted()
%4 = icmp eq i32 %3, 1
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = icmp sgt i32 %0, 2
br i1 %10, label %11, label %16
11: ; preds = %9
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %1
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %9
%17 = icmp eq i32 %0, 1
br i1 %17, label %18, label %25
18: ; preds = %16
%19 = load i32, i32* @STDIN_FILENO
%20 = tail call i64 @apply_cipso_file(i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %33, label %22
22: ; preds = %18
%23 = tail call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %16
%26 = getelementptr inbounds i8*, i8** %1, i64 1
%27 = load i8*, i8** %26
%28 = tail call i64 @apply_cipso(i8* %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %25
%31 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%32 = tail call i32 @exit(i32 1)
unreachable
33: ; preds = %25, %18
%34 = tail call i32 @exit(i32 0)
unreachable
}