#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 */
long MS_BIND;
long MS_MGC_VAL;
long MS_RDONLY;
long MS_REMOUNT;
char *alloca(int);
scalar_t__ mkdirChain(char *);
scalar_t__ mount(char *, char *, char *, long, char *);
scalar_t__ nfsmount(char *, char *, int *, char **, char **,
                    int /*<<< orphan*/);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strdup(void *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int doPwMount(char *dev, char *where, char *fs, int options, void *data) {
  char *buf = NULL;
  int isnfs = 0;
  char *mount_opt = NULL;
  long int flag;
  char *chptr __attribute__((unused));
  if (!strcmp(fs, "nfs"))
    isnfs = 1;
  if (mkdirChain(where))
    return 1;
  flag = MS_MGC_VAL;
  if (options & 1)
    flag |= MS_RDONLY;
  if (options & 2)
    flag |= MS_BIND;
  if (options & 4)
    flag |= MS_REMOUNT;
  if (!isnfs && (*dev == '/' || !strcmp(dev, "none"))) {
    buf = dev;
  } else if (!isnfs) {
    buf = alloca(200);
    strcpy(buf, "/tmp/");
    strcat(buf, dev);
  } else {
    char *extra_opts = NULL;
    int flags = 0;
    if (data)
      extra_opts = strdup(data);
    buf = dev;
    if (nfsmount(buf, where, &flags, &extra_opts, &mount_opt, 0)) {
      return 2;
    }
  }
  if (!strncmp(fs, "vfat", 4))
    mount_opt = "check=relaxed";
  if (mount(buf, where, fs, flag, mount_opt)) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<doPwMount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    11e2 <doPwMount+0x52>
movl   $0x1,-0x3c(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <mkdirChain@plt>
cmp    $0x0,%rax
je     1201 <doPwMount+0x71>
movl   $0x1,-0x4(%rbp)
jmp    13b6 <doPwMount+0x226>
mov    0x2dc8(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x24(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1230 <doPwMount+0xa0>
mov    0x2dbb(%rip),%rax
mov    (%rax),%rax
or     -0x50(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x24(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1251 <doPwMount+0xc1>
mov    0x2da2(%rip),%rax
mov    (%rax),%rax
or     -0x50(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x24(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1272 <doPwMount+0xe2>
mov    0x2d61(%rip),%rax
mov    (%rax),%rax
or     -0x50(%rbp),%rax
mov    %rax,-0x50(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jne    12b2 <doPwMount+0x122>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
je     12a5 <doPwMount+0x115>
mov    -0x10(%rbp),%rdi
lea    0xd6d(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12b2 <doPwMount+0x122>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1357 <doPwMount+0x1c7>
cmpl   $0x0,-0x3c(%rbp)
jne    12ec <doPwMount+0x15c>
mov    $0xc8,%edi
call   1080 <alloca@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xd34(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1090 <strcat@plt>
jmp    1352 <doPwMount+0x1c2>
movq   $0x0,-0x60(%rbp)
movl   $0x0,-0x64(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1313 <doPwMount+0x183>
mov    -0x30(%rbp),%rdi
call   10a0 <strdup@plt>
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x64(%rbp),%rdx
lea    -0x60(%rbp),%rcx
lea    -0x48(%rbp),%r8
xor    %r9d,%r9d
call   10b0 <nfsmount@plt>
cmp    $0x0,%rax
je     134d <doPwMount+0x1bd>
movl   $0x2,-0x4(%rbp)
jmp    13b6 <doPwMount+0x226>
jmp    1352 <doPwMount+0x1c2>
jmp    1357 <doPwMount+0x1c7>
mov    -0x20(%rbp),%rdi
lea    0xcad(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1380 <doPwMount+0x1f0>
lea    0xc98(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x50(%rbp),%rcx
mov    -0x48(%rbp),%r8
call   1050 <mount@plt>
cmp    $0x0,%rax
je     13af <doPwMount+0x21f>
movl   $0x1,-0x4(%rbp)
jmp    13b6 <doPwMount+0x226>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doPwMount>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,%r13
mov    %ecx,%ebp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xe43(%rip),%rsi
mov    %rdx,%rdi
call   1070 <strcmp@plt>
mov    %eax,%r15d
mov    %r14,%rdi
call   1060 <mkdirChain@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    1333 <doPwMount+0x1a3>
xor    %ecx,%ecx
mov    $0x0,%r12d
test   $0x1,%bpl
je     11f9 <doPwMount+0x69>
mov    0x2dea(%rip),%rax
mov    (%rax),%r12
mov    $0x0,%edx
test   $0x2,%bpl
je     120e <doPwMount+0x7e>
mov    0x2ddd(%rip),%rax
mov    (%rax),%rdx
mov    0x2dbb(%rip),%rax
test   $0x4,%bpl
je     1225 <doPwMount+0x95>
mov    0x2da6(%rip),%rcx
mov    (%rcx),%rcx
or     (%rax),%r12
test   %r15d,%r15d
je     128b <doPwMount+0xfb>
mov    (%rsp),%rbp
cmpb   $0x2f,0x0(%rbp)
je     12e5 <doPwMount+0x155>
mov    %rdx,0x18(%rsp)
mov    %rcx,%r13
lea    0xdba(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1281 <doPwMount+0xf1>
mov    $0xc8,%edi
call   1080 <alloca@plt>
mov    %rax,%r15
lea    0xd9f(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
call   1090 <strcat@plt>
mov    %r15,(%rsp)
mov    %r13,%rcx
mov    0x18(%rsp),%rdx
jmp    12e5 <doPwMount+0x155>
mov    %rdx,%r15
mov    %rcx,%rbp
movq   $0x0,0x20(%rsp)
movl   $0x0,0x14(%rsp)
test   %r13,%r13
je     12b4 <doPwMount+0x124>
mov    %r13,%rdi
call   10a0 <strdup@plt>
mov    %rax,0x20(%rsp)
lea    0x14(%rsp),%rdx
lea    0x20(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    (%rsp),%rdi
mov    %r14,%rsi
xor    %r9d,%r9d
call   10b0 <nfsmount@plt>
mov    %rax,%rcx
mov    $0x2,%eax
test   %rcx,%rcx
mov    %rbp,%rcx
mov    %r15,%rdx
jne    1333 <doPwMount+0x1a3>
or     %rcx,%rdx
or     %rdx,%r12
lea    0xd1d(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     130a <doPwMount+0x17a>
mov    0x8(%rsp),%r8
jmp    1316 <doPwMount+0x186>
lea    0xd03(%rip),%r8
mov    %r8,0x8(%rsp)
mov    (%rsp),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
call   1050 <mount@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"nfs\00"
@MS_MGC_VAL = global i64 0
@MS_RDONLY = global i64 0
@MS_BIND = global i64 0
@MS_REMOUNT = global i64 0
@.str.1 = [5 x i8] c"none\00"
@.str.2 = [6 x i8] c"/tmp/\00"
@.str.3 = [5 x i8] c"vfat\00"
@.str.4 = [14 x i8] c"check=relaxed\00"
define i32 @doPwMount(i8* %0, i8* %1, i8* %2, i32 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = bitcast i8** %6 to i8*
store i8* null, i8** %6
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %2, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%11 = tail call i64 @mkdirChain(i8* %1)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %62
13: ; preds = %5
%14 = icmp eq i32 %10, 0
%15 = load i64, i64* @MS_MGC_VAL
%16 = and i32 %3, 1
%17 = icmp eq i32 %16, 0
%18 = load i64, i64* @MS_RDONLY
%19 = select i1 %17, i64 0, i64 %18
%20 = or i64 %19, %15
%21 = and i32 %3, 2
%22 = icmp eq i32 %21, 0
%23 = load i64, i64* @MS_BIND
%24 = select i1 %22, i64 0, i64 %23
%25 = or i64 %20, %24
%26 = and i32 %3, 4
%27 = icmp eq i32 %26, 0
%28 = load i64, i64* @MS_REMOUNT
%29 = select i1 %27, i64 0, i64 %28
%30 = or i64 %25, %29
br i1 %14, label %41, label %31
31: ; preds = %13
%32 = load i8, i8* %0
%33 = icmp eq i8 %32, 47
br i1 %33, label %50, label %34
34: ; preds = %31
%35 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%36 = icmp eq i32 %35, 0
br i1 %36, label %50, label %37
37: ; preds = %34
%38 = tail call i8* @alloca(i32 200)
%39 = tail call i32 @strcpy(i8* %38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%40 = tail call i32 @strcat(i8* %38, i8* %0)
br label %50
41: ; preds = %13
%42 = bitcast i8** %7 to i8*
store i8* null, i8** %7
%43 = bitcast i32* %8 to i8*
store i32 0, i32* %8
%44 = icmp eq i8* %4, null
br i1 %44, label %47, label %45
45: ; preds = %41
%46 = tail call i8* @strdup(i8* %4)
store i8* %46, i8** %7
br label %47
47: ; preds = %45, %41
%48 = call i64 @nfsmount(i8* %0, i8* %1, i32* %8, i8** %7, i8** %6, i32 0)
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %62
50: ; preds = %31, %34, %37, %47
%51 = phi i8* [ %0, %47 ], [ %38, %37 ], [ %0, %34 ], [ %0, %31 ]
%52 = call i32 @strncmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%53 = icmp eq i32 %52, 0
br i1 %53, label %56, label %54
54: ; preds = %50
%55 = load i8*, i8** %6
br label %57
56: ; preds = %50
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8** %6
br label %57
57: ; preds = %54, %56
%58 = phi i8* [ %55, %54 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), %56 ]
%59 = call i64 @mount(i8* %51, i8* %1, i8* %2, i64 %30, i8* %58)
%60 = icmp ne i64 %59, 0
%61 = zext i1 %60 to i32
br label %62
62: ; preds = %57, %5, %47
%63 = phi i32 [ 2, %47 ], [ 1, %5 ], [ %61, %57 ]
ret i32 %63
}