#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*/ MNT_DETACH;
int errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ mount(char const *, char *, char *, int /*<<< orphan*/,
                 int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
char *strerror(int);
scalar_t__ umount2(char *, int /*<<< orphan*/);
int remount_proc(const char *name) {
  if (umount2("/proc", MNT_DETACH) < 0) {
    fprintf(stderr, "umount of /proc failed: %s\n", strerror(errno));
    return errno;
  }
  if (mount(name, "/proc", "proc", 0, NULL) < 0) {
    fprintf(stderr, "mount of /proc failed: %s\n", strerror(errno));
    return errno;
  }
  return 0;
}


x86 assembly (clang, -O0):
<remount_proc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
lea    0xea4(%rip),%rdi
call   1030 <umount2@plt>
cmp    $0x0,%rax
jge    11a8 <remount_proc+0x68>
mov    0x2e6e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%rdx
lea    0xe74(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1214 <remount_proc+0xd4>
mov    -0x10(%rbp),%rdi
lea    0xe4d(%rip),%rsi
lea    0xe47(%rip),%rdx
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <mount@plt>
cmp    $0x0,%rax
jge    120d <remount_proc+0xcd>
mov    0x2e09(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x18(%rbp),%edi
mov    %rax,%rdx
lea    0xe10(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dd5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1214 <remount_proc+0xd4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remount_proc>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    0x2e82(%rip),%rax
mov    (%rax),%esi
lea    0xea9(%rip),%rdi
call   1030 <umount2@plt>
test   %rax,%rax
js     118c <remount_proc+0x4c>
lea    0xe98(%rip),%rsi
lea    0xe92(%rip),%rdx
xor    %ebx,%ebx
mov    %r14,%rdi
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <mount@plt>
test   %rax,%rax
jns    11bb <remount_proc+0x7b>
lea    0xe7d(%rip),%rbx
jmp    1193 <remount_proc+0x53>
lea    0xe73(%rip),%rbx
mov    0x2e46(%rip),%rax
mov    (%rax),%ebp
mov    0x2e35(%rip),%r14
mov    (%r14),%edi
call   1060 <strerror@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    (%r14),%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"/proc\00"
@MNT_DETACH = global i32 0
@stderr = global i32 0
@.str.1 = [28 x i8] c"umount of /proc failed: %s\0A\00"
@errno = global i32 0
@.str.2 = [5 x i8] c"proc\00"
@.str.3 = [27 x i8] c"mount of /proc failed: %s\0A\00"
define i32 @remount_proc(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i32, i32* @MNT_DETACH
%5 = call i64 @umount2(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = call i8* @strerror(i32 %9)
%11 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @errno
store i32 %12, i32* %2
br label %24
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = call i64 @mount(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 0, i32* null)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = load i32, i32* @errno
%20 = call i8* @strerror(i32 %19)
%21 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @errno
store i32 %22, i32* %2
br label %24
23: ; preds = %13
store i32 0, i32* %2
br label %24
24: ; preds = %23, %17, %7
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@.str = [6 x i8] c"/proc\00"
@MNT_DETACH = global i32 0
@stderr = global i32 0
@.str.1 = [28 x i8] c"umount of /proc failed: %s\0A\00"
@errno = global i32 0
@.str.2 = [5 x i8] c"proc\00"
@.str.3 = [27 x i8] c"mount of /proc failed: %s\0A\00"
define i32 @remount_proc(i8* %0) {
%2 = load i32, i32* @MNT_DETACH
%3 = tail call i64 @umount2(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = icmp slt i64 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %1
%6 = tail call i64 @mount(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 0, i32* null)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %5, %1
%9 = phi i8* [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), %1 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), %5 ]
%10 = load i32, i32* @stderr
%11 = load i32, i32* @errno
%12 = tail call i8* @strerror(i32 %11)
%13 = tail call i32 @fprintf(i32 %10, i8* %9, i8* %12)
%14 = load i32, i32* @errno
br label %15
15: ; preds = %8, %5
%16 = phi i32 [ 0, %5 ], [ %14, %8 ]
ret i32 %16
}