#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*/ EPERM;
int /*<<< orphan*/ errno;
scalar_t__ is_licensed_prog();
scalar_t__ is_protected_file(char const *);
int real_mount(char const *, char const *, char const *, unsigned long,
               void const *);
int evil_mount(const char *source, const char *target,
               const char *filesystemtype, unsigned long mountflags,
               const void *data) {
  int ret = 0;
  if (is_licensed_prog())
    goto green;
  if (is_protected_file(target))
    goto red;
green:
  ret = real_mount(source, target, filesystemtype, mountflags, data);
  return ret;
red:
  errno = EPERM;
  return -1;
}


x86 assembly (clang, -O0):
<evil_mount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    $0x0,%al
call   1040 <is_licensed_prog@plt>
cmp    $0x0,%rax
je     1169 <evil_mount+0x39>
jmp    1186 <evil_mount+0x56>
mov    -0x18(%rbp),%rdi
call   1050 <is_protected_file@plt>
cmp    $0x0,%rax
je     1181 <evil_mount+0x51>
jmp    11ad <evil_mount+0x7d>
jmp    1186 <evil_mount+0x56>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1030 <real_mount@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c6 <evil_mount+0x96>
mov    0x2e1c(%rip),%rax
mov    (%rax),%ecx
mov    0x2e23(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<evil_mount>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %rdi,%r13
xor    %eax,%eax
call   1040 <is_licensed_prog@plt>
test   %rax,%rax
je     1171 <evil_mount+0x41>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <real_mount@plt>
mov    %rbx,%rdi
call   1050 <is_protected_file@plt>
test   %rax,%rax
je     1154 <evil_mount+0x24>
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
mov    0x2e52(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffff,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EPERM = global i32 0
@errno = global i32 0
define i32 @evil_mount(i8* %0, i8* %1, i8* %2, i64 %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i32
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i64 %3, i64* %10
store i8* %4, i8** %11
store i32 0, i32* %12
%13 = call i64 (...) @is_licensed_prog()
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %5
br label %22
16: ; preds = %5
%17 = load i8*, i8** %8
%18 = call i64 @is_protected_file(i8* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
br label %30
21: ; preds = %16
br label %22
22: ; preds = %21, %15
%23 = load i8*, i8** %7
%24 = load i8*, i8** %8
%25 = load i8*, i8** %9
%26 = load i64, i64* %10
%27 = load i8*, i8** %11
%28 = call i32 @real_mount(i8* %23, i8* %24, i8* %25, i64 %26, i8* %27)
store i32 %28, i32* %12
%29 = load i32, i32* %12
store i32 %29, i32* %6
br label %32
30: ; preds = %20
%31 = load i32, i32* @EPERM
store i32 %31, i32* @errno
store i32 -1, i32* %6
br label %32
32: ; preds = %30, %22
%33 = load i32, i32* %6
ret i32 %33
}

LLVM IR (-O2):
@EPERM = global i32 0
@errno = global i32 0
define i32 @evil_mount(i8* %0, i8* %1, i8* %2, i64 %3, i8* %4) {
%6 = tail call i64 (...) @is_licensed_prog()
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = tail call i64 @is_protected_file(i8* %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8, %5
%12 = tail call i32 @real_mount(i8* %0, i8* %1, i8* %2, i64 %3, i8* %4)
br label %15
13: ; preds = %8
%14 = load i32, i32* @EPERM
store i32 %14, i32* @errno
br label %15
15: ; preds = %13, %11
%16 = phi i32 [ %12, %11 ], [ -1, %13 ]
ret i32 %16
}