#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__ EBUSY;
scalar_t__ EINVAL;
int MS_NODEV;
int MS_NOEXEC;
int MS_NOSUID;
int MS_RELATIME;
int /*<<< orphan*/ err(int, char *, char const *);
scalar_t__ errno;
scalar_t__ mount(char *, char const *, char *, int, int /*<<< orphan*/ *);
scalar_t__ umount(char const *);
void _daemon_replace_proc(const char *path) {
  if (umount(path) && !(errno == EINVAL || errno == EBUSY))
    err(1, "could not umount %s", path);
  if (mount("none", path, "proc",
            MS_NOSUID | MS_NODEV | MS_NOEXEC | MS_RELATIME, NULL))
    err(1, "could not mount %s", path);
}


x86 assembly (clang, -O0):
<_daemon_replace_proc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <umount@plt>
cmp    $0x0,%rax
je     1198 <_daemon_replace_proc+0x68>
mov    0x2e72(%rip),%rax
mov    (%rax),%rax
mov    0x2e60(%rip),%rcx
cmp    (%rcx),%rax
je     1198 <_daemon_replace_proc+0x68>
mov    0x2e58(%rip),%rax
mov    (%rax),%rax
mov    0x2e3e(%rip),%rcx
cmp    (%rcx),%rax
je     1198 <_daemon_replace_proc+0x68>
mov    -0x8(%rbp),%rdx
mov    $0x1,%edi
lea    0xe6d(%rip),%rsi
call   1050 <err@plt>
mov    -0x8(%rbp),%rsi
mov    0x2e3d(%rip),%rax
mov    (%rax),%ecx
mov    0x2e44(%rip),%rax
or     (%rax),%ecx
mov    0x2df3(%rip),%rax
or     (%rax),%ecx
mov    0x2e12(%rip),%rax
or     (%rax),%ecx
lea    0xe4d(%rip),%rdi
lea    0xe4b(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <mount@plt>
cmp    $0x0,%rax
je     11f7 <_daemon_replace_proc+0xc7>
mov    -0x8(%rbp),%rdx
mov    $0x1,%edi
lea    0xe2c(%rip),%rsi
call   1050 <err@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_daemon_replace_proc>:
push   %rbx
mov    %rdi,%rbx
call   1030 <umount@plt>
test   %rax,%rax
je     1174 <_daemon_replace_proc+0x44>
mov    0x2e83(%rip),%rax
mov    (%rax),%rax
mov    0x2e71(%rip),%rcx
cmp    (%rcx),%rax
je     1174 <_daemon_replace_proc+0x44>
mov    0x2e5d(%rip),%rcx
cmp    (%rcx),%rax
je     1174 <_daemon_replace_proc+0x44>
lea    0xe99(%rip),%rsi
mov    $0x1,%edi
mov    %rbx,%rdx
call   1050 <err@plt>
mov    0x2e65(%rip),%rax
mov    0x2e6e(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2e1b(%rip),%rax
or     (%rax),%ecx
mov    0x2e3a(%rip),%rax
or     (%rax),%ecx
lea    0xe75(%rip),%rdi
lea    0xe73(%rip),%rdx
mov    %rbx,%rsi
xor    %r8d,%r8d
call   1040 <mount@plt>
test   %rax,%rax
je     11cb <_daemon_replace_proc+0x9b>
lea    0xe61(%rip),%rsi
mov    $0x1,%edi
mov    %rbx,%rdx
pop    %rbx
jmp    1050 <err@plt>
pop    %rbx
ret

LLVM IR (-O0):
@errno = global i64 0
@EINVAL = global i64 0
@EBUSY = global i64 0
@.str = [20 x i8] c"could not umount %s\00"
@.str.1 = [5 x i8] c"none\00"
@.str.2 = [5 x i8] c"proc\00"
@MS_NOSUID = global i32 0
@MS_NODEV = global i32 0
@MS_NOEXEC = global i32 0
@MS_RELATIME = global i32 0
@.str.3 = [19 x i8] c"could not mount %s\00"
define void @_daemon_replace_proc(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i64 @umount(i8* %3)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %17
6: ; preds = %1
%7 = load i64, i64* @errno
%8 = load i64, i64* @EINVAL
%9 = icmp eq i64 %7, %8
br i1 %9, label %17, label %10
10: ; preds = %6
%11 = load i64, i64* @errno
%12 = load i64, i64* @EBUSY
%13 = icmp eq i64 %11, %12
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = load i8*, i8** %2
%16 = call i32 @err(i32 1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %14, %10, %6, %1
%18 = load i8*, i8** %2
%19 = load i32, i32* @MS_NOSUID
%20 = load i32, i32* @MS_NODEV
%21 = or i32 %19, %20
%22 = load i32, i32* @MS_NOEXEC
%23 = or i32 %21, %22
%24 = load i32, i32* @MS_RELATIME
%25 = or i32 %23, %24
%26 = call i64 @mount(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %25, i32* null)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %17
%29 = load i8*, i8** %2
%30 = call i32 @err(i32 1, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %28, %17
ret void
}

LLVM IR (-O2):
@errno = global i64 0
@EINVAL = global i64 0
@EBUSY = global i64 0
@.str = [20 x i8] c"could not umount %s\00"
@.str.1 = [5 x i8] c"none\00"
@.str.2 = [5 x i8] c"proc\00"
@MS_NOSUID = global i32 0
@MS_NODEV = global i32 0
@MS_NOEXEC = global i32 0
@MS_RELATIME = global i32 0
@.str.3 = [19 x i8] c"could not mount %s\00"
define void @_daemon_replace_proc(i8* %0) {
%2 = tail call i64 @umount(i8* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %13, label %4
4: ; preds = %1
%5 = load i64, i64* @errno
%6 = load i64, i64* @EINVAL
%7 = icmp eq i64 %5, %6
%8 = load i64, i64* @EBUSY
%9 = icmp eq i64 %5, %8
%10 = select i1 %7, i1 true, i1 %9
br i1 %10, label %13, label %11
11: ; preds = %4
%12 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %13
13: ; preds = %11, %4, %1
%14 = load i32, i32* @MS_NOSUID
%15 = load i32, i32* @MS_NODEV
%16 = or i32 %15, %14
%17 = load i32, i32* @MS_NOEXEC
%18 = or i32 %16, %17
%19 = load i32, i32* @MS_RELATIME
%20 = or i32 %18, %19
%21 = tail call i64 @mount(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32* null)
%22 = icmp eq i64 %21, 0
br i1 %22, label %25, label %23
23: ; preds = %13
%24 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %25
25: ; preds = %23, %13
ret void
}