#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*/ BUG(char *);
int /*<<< orphan*/ domain_policy_test(unsigned int);
int /*<<< orphan*/ exception_policy_test(unsigned int);
int /*<<< orphan*/ get_meminfo(unsigned int *);
int /*<<< orphan*/ mount(char *, char *, char *, int /*<<< orphan*/,
                         int /*<<< orphan*/ *);
int main(void) {
  unsigned int before;
  mount("/proc", "/proc/", "proc", 0, NULL);
  get_meminfo(&before);
  domain_policy_test(before);
  exception_policy_test(before);
  BUG("Policy read/write test: Success\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe99(%rip),%rsi
lea    0xe8d(%rip),%rdx
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r8d
call   1050 <mount@plt>
lea    -0x8(%rbp),%rdi
call   1070 <get_meminfo@plt>
mov    -0x8(%rbp),%edi
call   1060 <domain_policy_test@plt>
mov    -0x8(%rbp),%edi
call   1040 <exception_policy_test@plt>
lea    0xe6d(%rip),%rdi
call   1030 <BUG@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xea8(%rip),%rdi
lea    0xea7(%rip),%rsi
lea    0xe9b(%rip),%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <mount@plt>
lea    0x4(%rsp),%rdi
call   1070 <get_meminfo@plt>
mov    0x4(%rsp),%edi
call   1060 <domain_policy_test@plt>
mov    0x4(%rsp),%edi
call   1040 <exception_policy_test@plt>
lea    0xe7a(%rip),%rdi
call   1030 <BUG@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"/proc\00"
@.str.1 = [7 x i8] c"/proc/\00"
@.str.2 = [5 x i8] c"proc\00"
@.str.3 = [33 x i8] c"Policy read/write test: Success\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @mount(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 0, i32* null)
%4 = call i32 @get_meminfo(i32* %2)
%5 = load i32, i32* %2
%6 = call i32 @domain_policy_test(i32 %5)
%7 = load i32, i32* %2
%8 = call i32 @exception_policy_test(i32 %7)
%9 = call i32 @BUG(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"/proc\00"
@.str.1 = [7 x i8] c"/proc/\00"
@.str.2 = [5 x i8] c"proc\00"
@.str.3 = [33 x i8] c"Policy read/write test: Success\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @mount(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 0, i32* null)
%4 = call i32 @get_meminfo(i32* %1)
%5 = load i32, i32* %1
%6 = call i32 @domain_policy_test(i32 %5)
%7 = load i32, i32* %1
%8 = call i32 @exception_policy_test(i32 %7)
%9 = call i32 @BUG(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}