#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__ bind_umount(char *, int /*<<< orphan*/);
char *malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
int bind_umount_all(char *path) {
  char *tmp_dir;
  tmp_dir = malloc(12 * sizeof(char));
  if (bind_umount(path, strcpy(tmp_dir, "/usr")) != 0)
    return 1;
  if (bind_umount(path, strcpy(tmp_dir, "/lib")) != 0)
    return 2;
  if (bind_umount(path, strcpy(tmp_dir, "/lib64")) != 0)
    return 3;
  if (bind_umount(path, strcpy(tmp_dir, "/bin")) != 0)
    return 4;
  if (bind_umount(path, strcpy(tmp_dir, "/dev")) != 0)
    return 5;
  if (bind_umount(path, strcpy(tmp_dir, "/etc")) != 0)
    return 6;
  if (bind_umount(path, strcpy(tmp_dir, "/proc")) != 0)
    return 7;
  if (bind_umount(path, strcpy(tmp_dir, "/var")) != 0)
    return 8;
  return 0;
}


x86 assembly (clang, -O0):
<bind_umount_all>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0xc,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1050 <bind_umount@plt>
cmp    $0x0,%rax
je     1183 <bind_umount_all+0x53>
movl   $0x1,-0x4(%rbp)
jmp    1319 <bind_umount_all+0x1e9>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1050 <bind_umount@plt>
cmp    $0x0,%rax
je     11bc <bind_umount_all+0x8c>
movl   $0x2,-0x4(%rbp)
jmp    1319 <bind_umount_all+0x1e9>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe3b(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
call   1050 <bind_umount@plt>
cmp    $0x0,%rax
je     11f5 <bind_umount_all+0xc5>
movl   $0x3,-0x4(%rbp)
jmp    1319 <bind_umount_all+0x1e9>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe09(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
call   1050 <bind_umount@plt>
cmp    $0x0,%rax
je     122e <bind_umount_all+0xfe>
movl   $0x4,-0x4(%rbp)
jmp    1319 <bind_umount_all+0x1e9>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xdd5(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
call   1050 <bind_umount@plt>
cmp    $0x0,%rax
je     1267 <bind_umount_all+0x137>
movl   $0x5,-0x4(%rbp)
jmp    1319 <bind_umount_all+0x1e9>
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xda1(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%esi
call   1050 <bind_umount@plt>
cmp    $0x0,%rax
je     12a0 <bind_umount_all+0x170>
movl   $0x6,-0x4(%rbp)
jmp    1319 <bind_umount_all+0x1e9>
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xd6d(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x50(%rbp),%rdi
mov    %eax,%esi
call   1050 <bind_umount@plt>
cmp    $0x0,%rax
je     12d9 <bind_umount_all+0x1a9>
movl   $0x7,-0x4(%rbp)
jmp    1319 <bind_umount_all+0x1e9>
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xd3a(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x58(%rbp),%rdi
mov    %eax,%esi
call   1050 <bind_umount@plt>
cmp    $0x0,%rax
je     1312 <bind_umount_all+0x1e2>
movl   $0x8,-0x4(%rbp)
jmp    1319 <bind_umount_all+0x1e9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bind_umount_all>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0xc,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
lea    0xeb5(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <bind_umount@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    1285 <bind_umount_all+0x155>
lea    0xe90(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <bind_umount@plt>
mov    %rax,%rcx
mov    $0x2,%eax
test   %rcx,%rcx
jne    1285 <bind_umount_all+0x155>
lea    0xe6b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <bind_umount@plt>
mov    %rax,%rcx
mov    $0x3,%eax
test   %rcx,%rcx
jne    1285 <bind_umount_all+0x155>
lea    0xe48(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <bind_umount@plt>
mov    %rax,%rcx
mov    $0x4,%eax
test   %rcx,%rcx
jne    1285 <bind_umount_all+0x155>
lea    0xe23(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <bind_umount@plt>
mov    %rax,%rcx
mov    $0x5,%eax
test   %rcx,%rcx
jne    1285 <bind_umount_all+0x155>
lea    0xe02(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <bind_umount@plt>
mov    %rax,%rcx
mov    $0x6,%eax
test   %rcx,%rcx
jne    1285 <bind_umount_all+0x155>
lea    0xde1(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <bind_umount@plt>
mov    %rax,%rcx
mov    $0x7,%eax
test   %rcx,%rcx
jne    1285 <bind_umount_all+0x155>
lea    0xdc1(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <bind_umount@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
shl    $0x3,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"/usr\00"
@.str.1 = [5 x i8] c"/lib\00"
@.str.2 = [7 x i8] c"/lib64\00"
@.str.3 = [5 x i8] c"/bin\00"
@.str.4 = [5 x i8] c"/dev\00"
@.str.5 = [5 x i8] c"/etc\00"
@.str.6 = [6 x i8] c"/proc\00"
@.str.7 = [5 x i8] c"/var\00"
define i32 @bind_umount_all(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = call i8* @malloc(i32 12)
store i8* %5, i8** %4
%6 = load i8*, i8** %3
%7 = load i8*, i8** %4
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = call i64 @bind_umount(i8* %6, i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %1
store i32 1, i32* %2
br label %62
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = load i8*, i8** %4
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%16 = call i64 @bind_umount(i8* %13, i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %12
store i32 2, i32* %2
br label %62
19: ; preds = %12
%20 = load i8*, i8** %3
%21 = load i8*, i8** %4
%22 = call i32 @strcpy(i8* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%23 = call i64 @bind_umount(i8* %20, i32 %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %19
store i32 3, i32* %2
br label %62
26: ; preds = %19
%27 = load i8*, i8** %3
%28 = load i8*, i8** %4
%29 = call i32 @strcpy(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%30 = call i64 @bind_umount(i8* %27, i32 %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %26
store i32 4, i32* %2
br label %62
33: ; preds = %26
%34 = load i8*, i8** %3
%35 = load i8*, i8** %4
%36 = call i32 @strcpy(i8* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%37 = call i64 @bind_umount(i8* %34, i32 %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %33
store i32 5, i32* %2
br label %62
40: ; preds = %33
%41 = load i8*, i8** %3
%42 = load i8*, i8** %4
%43 = call i32 @strcpy(i8* %42, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%44 = call i64 @bind_umount(i8* %41, i32 %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %40
store i32 6, i32* %2
br label %62
47: ; preds = %40
%48 = load i8*, i8** %3
%49 = load i8*, i8** %4
%50 = call i32 @strcpy(i8* %49, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%51 = call i64 @bind_umount(i8* %48, i32 %50)
%52 = icmp ne i64 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %47
store i32 7, i32* %2
br label %62
54: ; preds = %47
%55 = load i8*, i8** %3
%56 = load i8*, i8** %4
%57 = call i32 @strcpy(i8* %56, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%58 = call i64 @bind_umount(i8* %55, i32 %57)
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %61
60: ; preds = %54
store i32 8, i32* %2
br label %62
61: ; preds = %54
store i32 0, i32* %2
br label %62
62: ; preds = %61, %60, %53, %46, %39, %32, %25, %18, %11
%63 = load i32, i32* %2
ret i32 %63
}

LLVM IR (-O2):
@.str = [5 x i8] c"/usr\00"
@.str.1 = [5 x i8] c"/lib\00"
@.str.2 = [7 x i8] c"/lib64\00"
@.str.3 = [5 x i8] c"/bin\00"
@.str.4 = [5 x i8] c"/dev\00"
@.str.5 = [5 x i8] c"/etc\00"
@.str.6 = [6 x i8] c"/proc\00"
@.str.7 = [5 x i8] c"/var\00"
define i32 @bind_umount_all(i8* %0) {
%2 = tail call dereferenceable_or_null(12) i8* @malloc(i32 12)
%3 = tail call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = tail call i64 @bind_umount(i8* %0, i32 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %35
6: ; preds = %1
%7 = tail call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i64 @bind_umount(i8* %0, i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %35
10: ; preds = %6
%11 = tail call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i64 @bind_umount(i8* %0, i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %35
14: ; preds = %10
%15 = tail call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%16 = tail call i64 @bind_umount(i8* %0, i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %35
18: ; preds = %14
%19 = tail call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%20 = tail call i64 @bind_umount(i8* %0, i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %35
22: ; preds = %18
%23 = tail call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%24 = tail call i64 @bind_umount(i8* %0, i32 %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %35
26: ; preds = %22
%27 = tail call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%28 = tail call i64 @bind_umount(i8* %0, i32 %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %26
%31 = tail call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%32 = tail call i64 @bind_umount(i8* %0, i32 %31)
%33 = icmp eq i64 %32, 0
%34 = select i1 %33, i32 0, i32 8
br label %35
35: ; preds = %30, %26, %22, %18, %14, %10, %6, %1
%36 = phi i32 [ 1, %1 ], [ 2, %6 ], [ 3, %10 ], [ 4, %14 ], [ 5, %18 ], [ 6, %22 ], [ 7, %26 ], [ %34, %30 ]
ret i32 %36
}