#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 */
struct stat {
  scalar_t__ st_dev;
};
typedef int /*<<< orphan*/ procbuff;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ *mkdtemp(char *);
int /*<<< orphan*/ mount(char *, char *, char *, int /*<<< orphan*/, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ stat(char *, struct stat *);
int /*<<< orphan*/ umount(char *);
int main(void) {
  struct stat proc_st1, proc_st2;
  char procbuff[] = "/tmp/proc.XXXXXX/meminfo";
  char procdir1[] = "/tmp/proc.XXXXXX";
  char procdir2[] = "/tmp/proc.XXXXXX";
  assert(mkdtemp(procdir1) != NULL);
  assert(mkdtemp(procdir2) != NULL);
  assert(!mount("proc", procdir1, "proc", 0, "hidepid=1"));
  assert(!mount("proc", procdir2, "proc", 0, "hidepid=2"));
  snprintf(procbuff, sizeof(procbuff), "%s/meminfo", procdir1);
  assert(!stat(procbuff, &proc_st1));
  snprintf(procbuff, sizeof(procbuff), "%s/meminfo", procdir2);
  assert(!stat(procbuff, &proc_st2));
  umount(procdir1);
  umount(procdir2);
  assert(proc_st1.st_dev != proc_st2.st_dev);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe87(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe84(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe81(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe7f(%rip),%al
mov    %al,-0x28(%rbp)
mov    0xe7d(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xe7a(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xe78(%rip),%al
mov    %al,-0x50(%rbp)
mov    0xe5e(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0xe5b(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    0xe59(%rip),%al
mov    %al,-0x70(%rbp)
lea    -0x60(%rbp),%rdi
call   1080 <mkdtemp@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x80(%rbp),%rdi
call   1080 <mkdtemp@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x60(%rbp),%rsi
lea    0xe18(%rip),%rdx
xor    %ecx,%ecx
lea    0xe14(%rip),%r8
mov    %rdx,%rdi
call   1040 <mount@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x80(%rbp),%rsi
lea    0xdea(%rip),%rdx
xor    %ecx,%ecx
lea    0xdf0(%rip),%r8
mov    %rdx,%rdi
call   1040 <mount@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rcx
mov    $0x19,%esi
lea    0xdcc(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x40(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <stat@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x40(%rbp),%rdi
lea    -0x80(%rbp),%rcx
mov    $0x19,%esi
lea    0xd94(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x40(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <stat@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x60(%rbp),%rdi
call   1030 <umount@plt>
lea    -0x80(%rbp),%rdi
call   1030 <umount@plt>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x78,%rsp
movups 0xe97(%rip),%xmm0
movups %xmm0,0x59(%rsp)
movaps 0xe82(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe96(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movb   $0x0,0x40(%rsp)
movaps %xmm0,0x10(%rsp)
movb   $0x0,0x20(%rsp)
lea    0x30(%rsp),%r14
mov    %r14,%rdi
call   1080 <mkdtemp@plt>
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1060 <assert@plt>
lea    0x10(%rsp),%r15
mov    %r15,%rdi
call   1080 <mkdtemp@plt>
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1060 <assert@plt>
lea    0xe56(%rip),%rbx
lea    0xe54(%rip),%r8
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1040 <mount@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
lea    0xe3a(%rip),%r8
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1040 <mount@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
lea    0xe20(%rip),%r12
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x19,%esi
mov    %r12,%rdx
mov    %r14,%rcx
call   1050 <snprintf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <stat@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
mov    $0x19,%esi
mov    %r12,%rdx
mov    %r15,%rcx
call   1050 <snprintf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1070 <stat@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
mov    %r14,%rdi
call   1030 <umount@plt>
mov    %r15,%rdi
call   1030 <umount@plt>
mov    0x8(%rsp),%rax
xor    %edi,%edi
cmp    (%rsp),%rax
setne  %dil
call   1060 <assert@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.stat = type { i64 }
@__const.main.procbuff = [25 x i8] c"/tmp/proc.XXXXXX/meminfo\00"
@__const.main.procdir1 = [17 x i8] c"/tmp/proc.XXXXXX\00"
@__const.main.procdir2 = [17 x i8] c"/tmp/proc.XXXXXX\00"
@.str = [5 x i8] c"proc\00"
@.str.1 = [10 x i8] c"hidepid=1\00"
@.str.2 = [10 x i8] c"hidepid=2\00"
@.str.3 = [11 x i8] c"%s/meminfo\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.stat
%3 = alloca %struct.stat
%4 = alloca [25 x i8]
%5 = alloca [17 x i8]
%6 = alloca [17 x i8]
store i32 0, i32* %1
%7 = bitcast [25 x i8]* %4 to i8*
%8 = bitcast [17 x i8]* %5 to i8*
%9 = bitcast [17 x i8]* %6 to i8*
%10 = getelementptr inbounds [17 x i8], [17 x i8]* %5, i64 0, i64 0
%11 = call i32* @mkdtemp(i8* %10)
%12 = icmp ne i32* %11, null
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%16 = call i32* @mkdtemp(i8* %15)
%17 = icmp ne i32* %16, null
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = getelementptr inbounds [17 x i8], [17 x i8]* %5, i64 0, i64 0
%21 = call i32 @mount(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%27 = call i32 @mount(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp ne i32 %27, 0
%29 = xor i1 %28, true
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = getelementptr inbounds [25 x i8], [25 x i8]* %4, i64 0, i64 0
%33 = getelementptr inbounds [17 x i8], [17 x i8]* %5, i64 0, i64 0
%34 = call i32 @snprintf(i8* %32, i32 25, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %33)
%35 = getelementptr inbounds [25 x i8], [25 x i8]* %4, i64 0, i64 0
%36 = call i32 @stat(i8* %35, %struct.stat* %2)
%37 = icmp ne i32 %36, 0
%38 = xor i1 %37, true
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
%41 = getelementptr inbounds [25 x i8], [25 x i8]* %4, i64 0, i64 0
%42 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%43 = call i32 @snprintf(i8* %41, i32 25, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %42)
%44 = getelementptr inbounds [25 x i8], [25 x i8]* %4, i64 0, i64 0
%45 = call i32 @stat(i8* %44, %struct.stat* %3)
%46 = icmp ne i32 %45, 0
%47 = xor i1 %46, true
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = getelementptr inbounds [17 x i8], [17 x i8]* %5, i64 0, i64 0
%51 = call i32 @umount(i8* %50)
%52 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%53 = call i32 @umount(i8* %52)
%54 = getelementptr inbounds %struct.stat, %struct.stat* %2, i32 0, i32 0
%55 = load i64, i64* %54
%56 = getelementptr inbounds %struct.stat, %struct.stat* %3, i32 0, i32 0
%57 = load i64, i64* %56
%58 = icmp ne i64 %55, %57
%59 = zext i1 %58 to i32
%60 = call i32 @assert(i32 %59)
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i64 }
@__const.main.procbuff = [25 x i8] c"/tmp/proc.XXXXXX/meminfo\00"
@__const.main.procdir2 = [17 x i8] c"/tmp/proc.XXXXXX\00"
@.str = [5 x i8] c"proc\00"
@.str.1 = [10 x i8] c"hidepid=1\00"
@.str.2 = [10 x i8] c"hidepid=2\00"
@.str.3 = [11 x i8] c"%s/meminfo\00"
define i32 @main() {
%1 = alloca %struct.stat
%2 = alloca %struct.stat
%3 = alloca [25 x i8]
%4 = alloca [17 x i8]
%5 = alloca [17 x i8]
%6 = bitcast %struct.stat* %1 to i8*
%7 = bitcast %struct.stat* %2 to i8*
%8 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [17 x i8], [17 x i8]* %5, i64 0, i64 0
%11 = call i32* @mkdtemp(i8* %9)
%12 = icmp ne i32* %11, null
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = call i32* @mkdtemp(i8* %10)
%16 = icmp ne i32* %15, null
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = call i32 @mount(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = call i32 @mount(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i32 %23, 0
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = call i32 @snprintf(i8* %8, i32 25, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%28 = call i32 @stat(i8* %8, %struct.stat* %1)
%29 = icmp eq i32 %28, 0
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = call i32 @snprintf(i8* %8, i32 25, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%33 = call i32 @stat(i8* %8, %struct.stat* %2)
%34 = icmp eq i32 %33, 0
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = call i32 @umount(i8* %9)
%38 = call i32 @umount(i8* %10)
%39 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%40 = load i64, i64* %39
%41 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%42 = load i64, i64* %41
%43 = icmp ne i64 %40, %42
%44 = zext i1 %43 to i32
%45 = call i32 @assert(i32 %44)
ret i32 0
}