#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 */
unsigned long MS_BIND;
unsigned long MS_REC;
unsigned long MS_REMOUNT;
unsigned long MS_UNBINDABLE;
int /*<<< orphan*/ errno;
scalar_t__ file_confirm_mountpoint(char *, char *, unsigned long);
scalar_t__ mount(char *, char *, int /*<<< orphan*/ *, unsigned long,
                 int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
char *strerror(int /*<<< orphan*/);
scalar_t__ umount(char *);
int file_bind(char *src, char *dest, unsigned long mntflags,
              unsigned long propflags, unsigned long esflags) {
  if (src == NULL || dest == NULL)
    return -1;
  if (file_confirm_mountpoint(src, dest, esflags))
    return -1;
  if (mount(src, dest, NULL, MS_BIND, NULL)) {
    printf("mount: %s\n", strerror(errno));
    return -1;
  }
  if (mount(NULL, dest, NULL, MS_BIND | MS_REMOUNT | mntflags, NULL)) {
    printf("remount: %s\n", strerror(errno));
    if (umount(dest))
      printf("umount: %s\n", strerror(errno));
    return -1;
  }
  if (esflags & 8) {
    unsigned long ubflags = MS_UNBINDABLE;
    if (!(esflags & 4))
      ubflags |= MS_REC;
    if (mount(NULL, dest, NULL, ubflags, NULL)) {
      printf("remount: %s\n", strerror(errno));
      if (umount(dest))
        printf("umount: %s\n", strerror(errno));
      return -1;
    }
  }
  if (mount(NULL, dest, NULL, propflags, NULL)) {
    printf("remount: %s\n", strerror(errno));
    if (umount(dest))
      printf("umount: %s\n", strerror(errno));
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<file_bind>:
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)
cmpq   $0x0,-0x10(%rbp)
je     1182 <file_bind+0x32>
cmpq   $0x0,-0x18(%rbp)
jne    118e <file_bind+0x3e>
movl   $0xffffffff,-0x4(%rbp)
jmp    13dc <file_bind+0x28c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1060 <file_confirm_mountpoint@plt>
cmp    $0x0,%rax
je     11b5 <file_bind+0x65>
movl   $0xffffffff,-0x4(%rbp)
jmp    13dc <file_bind+0x28c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2e1c(%rip),%rax
mov    (%rax),%rcx
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
call   1040 <mount@plt>
cmp    $0x0,%rax
je     1207 <file_bind+0xb7>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    %rax,%rsi
lea    0xe0c(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13dc <file_bind+0x28c>
mov    -0x18(%rbp),%rsi
mov    0x2dce(%rip),%rax
mov    (%rax),%rcx
mov    0x2da4(%rip),%rax
or     (%rax),%rcx
or     -0x20(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdi
mov    %r8,%rdx
call   1040 <mount@plt>
cmp    $0x0,%rax
je     1296 <file_bind+0x146>
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    %rax,%rsi
lea    0xdab(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <umount@plt>
cmp    $0x0,%rax
je     128a <file_bind+0x13a>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    %rax,%rsi
lea    0xd88(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13dc <file_bind+0x28c>
mov    -0x30(%rbp),%rax
and    $0x8,%rax
cmp    $0x0,%rax
je     135a <file_bind+0x20a>
mov    0x2d39(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
and    $0x4,%rax
cmp    $0x0,%rax
jne    12da <file_bind+0x18a>
mov    0x2d09(%rip),%rax
mov    (%rax),%rax
or     -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x38(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdi
mov    %r8,%rdx
call   1040 <mount@plt>
cmp    $0x0,%rax
je     1355 <file_bind+0x205>
mov    0x2cc5(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    %rax,%rsi
lea    0xcec(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <umount@plt>
cmp    $0x0,%rax
je     1349 <file_bind+0x1f9>
mov    0x2c95(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    %rax,%rsi
lea    0xcc9(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13dc <file_bind+0x28c>
jmp    135a <file_bind+0x20a>
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdi
mov    %r8,%rdx
call   1040 <mount@plt>
cmp    $0x0,%rax
je     13d5 <file_bind+0x285>
mov    0x2c45(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    %rax,%rsi
lea    0xc6c(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <umount@plt>
cmp    $0x0,%rax
je     13c9 <file_bind+0x279>
mov    0x2c15(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    %rax,%rsi
lea    0xc49(%rip),%rdi
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13dc <file_bind+0x28c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_bind>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     127d <file_bind+0x12d>
mov    %rsi,%r15
test   %rsi,%rsi
je     127d <file_bind+0x12d>
mov    %r8,%r12
mov    %rcx,%r14
mov    %rdx,%r13
mov    %rdi,%rbx
mov    %r15,%rsi
mov    %r8,%rdx
call   1060 <file_confirm_mountpoint@plt>
test   %rax,%rax
jne    127d <file_bind+0x12d>
mov    0x2e49(%rip),%rbp
mov    0x0(%rbp),%rcx
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %edx,%edx
xor    %r8d,%r8d
call   1040 <mount@plt>
test   %rax,%rax
je     11bc <file_bind+0x6c>
lea    0xe4b(%rip),%rbx
jmp    1264 <file_bind+0x114>
mov    0x2dfd(%rip),%rax
or     0x0(%rbp),%r13
or     (%rax),%r13
xor    %edi,%edi
mov    %r15,%rsi
xor    %edx,%edx
mov    %r13,%rcx
xor    %r8d,%r8d
call   1040 <mount@plt>
test   %rax,%rax
jne    1233 <file_bind+0xe3>
test   $0x8,%r12b
je     121a <file_bind+0xca>
mov    0x2dfa(%rip),%rax
mov    $0x0,%ecx
test   $0x4,%r12b
jne    1203 <file_bind+0xb3>
mov    0x2dd8(%rip),%rcx
mov    (%rcx),%rcx
or     (%rax),%rcx
xor    %edi,%edi
mov    %r15,%rsi
xor    %edx,%edx
xor    %r8d,%r8d
call   1040 <mount@plt>
test   %rax,%rax
jne    1233 <file_bind+0xe3>
xor    %ebx,%ebx
xor    %edi,%edi
mov    %r15,%rsi
xor    %edx,%edx
mov    %r14,%rcx
xor    %r8d,%r8d
call   1040 <mount@plt>
test   %rax,%rax
je     1282 <file_bind+0x132>
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xdb8(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
mov    %r15,%rdi
call   1030 <umount@plt>
test   %rax,%rax
je     127d <file_bind+0x12d>
lea    0xda9(%rip),%rbx
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@MS_BIND = global i64 0
@.str = [11 x i8] c"mount: %s\0A\00"
@errno = global i32 0
@MS_REMOUNT = global i64 0
@.str.1 = [13 x i8] c"remount: %s\0A\00"
@.str.2 = [12 x i8] c"umount: %s\0A\00"
@MS_UNBINDABLE = global i64 0
@MS_REC = global i64 0
define i32 @file_bind(i8* %0, i8* %1, i64 %2, i64 %3, i64 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
store i8* %0, i8** %7
store i8* %1, i8** %8
store i64 %2, i64* %9
store i64 %3, i64* %10
store i64 %4, i64* %11
%13 = load i8*, i8** %7
%14 = icmp eq i8* %13, null
br i1 %14, label %18, label %15
15: ; preds = %5
%16 = load i8*, i8** %8
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %19
18: ; preds = %15, %5
store i32 -1, i32* %6
br label %106
19: ; preds = %15
%20 = load i8*, i8** %7
%21 = load i8*, i8** %8
%22 = load i64, i64* %11
%23 = call i64 @file_confirm_mountpoint(i8* %20, i8* %21, i64 %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %19
store i32 -1, i32* %6
br label %106
26: ; preds = %19
%27 = load i8*, i8** %7
%28 = load i8*, i8** %8
%29 = load i64, i64* @MS_BIND
%30 = call i64 @mount(i8* %27, i8* %28, i32* null, i64 %29, i32* null)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %26
%33 = load i32, i32* @errno
%34 = call i8* @strerror(i32 %33)
%35 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %34)
store i32 -1, i32* %6
br label %106
36: ; preds = %26
%37 = load i8*, i8** %8
%38 = load i64, i64* @MS_BIND
%39 = load i64, i64* @MS_REMOUNT
%40 = or i64 %38, %39
%41 = load i64, i64* %9
%42 = or i64 %40, %41
%43 = call i64 @mount(i8* null, i8* %37, i32* null, i64 %42, i32* null)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %57
45: ; preds = %36
%46 = load i32, i32* @errno
%47 = call i8* @strerror(i32 %46)
%48 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %47)
%49 = load i8*, i8** %8
%50 = call i64 @umount(i8* %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %56
52: ; preds = %45
%53 = load i32, i32* @errno
%54 = call i8* @strerror(i32 %53)
%55 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %54)
br label %56
56: ; preds = %52, %45
store i32 -1, i32* %6
br label %106
57: ; preds = %36
%58 = load i64, i64* %11
%59 = and i64 %58, 8
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %88
61: ; preds = %57
%62 = load i64, i64* @MS_UNBINDABLE
store i64 %62, i64* %12
%63 = load i64, i64* %11
%64 = and i64 %63, 4
%65 = icmp ne i64 %64, 0
br i1 %65, label %70, label %66
66: ; preds = %61
%67 = load i64, i64* @MS_REC
%68 = load i64, i64* %12
%69 = or i64 %68, %67
store i64 %69, i64* %12
br label %70
70: ; preds = %66, %61
%71 = load i8*, i8** %8
%72 = load i64, i64* %12
%73 = call i64 @mount(i8* null, i8* %71, i32* null, i64 %72, i32* null)
%74 = icmp ne i64 %73, 0
br i1 %74, label %75, label %87
75: ; preds = %70
%76 = load i32, i32* @errno
%77 = call i8* @strerror(i32 %76)
%78 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %77)
%79 = load i8*, i8** %8
%80 = call i64 @umount(i8* %79)
%81 = icmp ne i64 %80, 0
br i1 %81, label %82, label %86
82: ; preds = %75
%83 = load i32, i32* @errno
%84 = call i8* @strerror(i32 %83)
%85 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %84)
br label %86
86: ; preds = %82, %75
store i32 -1, i32* %6
br label %106
87: ; preds = %70
br label %88
88: ; preds = %87, %57
%89 = load i8*, i8** %8
%90 = load i64, i64* %10
%91 = call i64 @mount(i8* null, i8* %89, i32* null, i64 %90, i32* null)
%92 = icmp ne i64 %91, 0
br i1 %92, label %93, label %105
93: ; preds = %88
%94 = load i32, i32* @errno
%95 = call i8* @strerror(i32 %94)
%96 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %95)
%97 = load i8*, i8** %8
%98 = call i64 @umount(i8* %97)
%99 = icmp ne i64 %98, 0
br i1 %99, label %100, label %104
100: ; preds = %93
%101 = load i32, i32* @errno
%102 = call i8* @strerror(i32 %101)
%103 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %102)
br label %104
104: ; preds = %100, %93
store i32 -1, i32* %6
br label %106
105: ; preds = %88
store i32 0, i32* %6
br label %106
106: ; preds = %105, %104, %86, %56, %32, %25, %18
%107 = load i32, i32* %6
ret i32 %107
}

LLVM IR (-O2):
@MS_BIND = global i64 0
@.str = [11 x i8] c"mount: %s\0A\00"
@errno = global i32 0
@MS_REMOUNT = global i64 0
@.str.1 = [13 x i8] c"remount: %s\0A\00"
@.str.2 = [12 x i8] c"umount: %s\0A\00"
@MS_UNBINDABLE = global i64 0
@MS_REC = global i64 0
define i32 @file_bind(i8* %0, i8* %1, i64 %2, i64 %3, i64 %4) {
%6 = icmp eq i8* %0, null
%7 = icmp eq i8* %1, null
%8 = or i1 %6, %7
br i1 %8, label %61, label %9
9: ; preds = %5
%10 = tail call i64 @file_confirm_mountpoint(i8* %0, i8* %1, i64 %4)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %61
12: ; preds = %9
%13 = load i64, i64* @MS_BIND
%14 = tail call i64 @mount(i8* %0, i8* %1, i32* null, i64 %13, i32* null)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %56
16: ; preds = %12
%17 = load i64, i64* @MS_BIND
%18 = load i64, i64* @MS_REMOUNT
%19 = or i64 %17, %2
%20 = or i64 %19, %18
%21 = tail call i64 @mount(i8* null, i8* %1, i32* null, i64 %20, i32* null)
%22 = icmp eq i64 %21, 0
br i1 %22, label %29, label %23
23: ; preds = %16
%24 = load i32, i32* @errno
%25 = tail call i8* @strerror(i32 %24)
%26 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = tail call i64 @umount(i8* %1)
%28 = icmp eq i64 %27, 0
br i1 %28, label %61, label %56
29: ; preds = %16
%30 = and i64 %4, 8
%31 = icmp eq i64 %30, 0
br i1 %31, label %47, label %32
32: ; preds = %29
%33 = load i64, i64* @MS_UNBINDABLE
%34 = and i64 %4, 4
%35 = icmp eq i64 %34, 0
%36 = load i64, i64* @MS_REC
%37 = select i1 %35, i64 %36, i64 0
%38 = or i64 %37, %33
%39 = tail call i64 @mount(i8* null, i8* %1, i32* null, i64 %38, i32* null)
%40 = icmp eq i64 %39, 0
br i1 %40, label %47, label %41
41: ; preds = %32
%42 = load i32, i32* @errno
%43 = tail call i8* @strerror(i32 %42)
%44 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %43)
%45 = tail call i64 @umount(i8* %1)
%46 = icmp eq i64 %45, 0
br i1 %46, label %61, label %56
47: ; preds = %32, %29
%48 = tail call i64 @mount(i8* null, i8* %1, i32* null, i64 %3, i32* null)
%49 = icmp eq i64 %48, 0
br i1 %49, label %61, label %50
50: ; preds = %47
%51 = load i32, i32* @errno
%52 = tail call i8* @strerror(i32 %51)
%53 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %52)
%54 = tail call i64 @umount(i8* %1)
%55 = icmp eq i64 %54, 0
br i1 %55, label %61, label %56
56: ; preds = %50, %41, %23, %12
%57 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), %12 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), %23 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), %41 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), %50 ]
%58 = load i32, i32* @errno
%59 = tail call i8* @strerror(i32 %58)
%60 = tail call i32 @printf(i8* %57, i8* %59)
br label %61
61: ; preds = %56, %41, %47, %50, %23, %9, %5
%62 = phi i32 [ -1, %5 ], [ -1, %9 ], [ -1, %23 ], [ -1, %50 ], [ 0, %47 ], [ -1, %41 ], [ -1, %56 ]
ret i32 %62
}