#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 */
typedef int pid_t;

/* Variables and functions */
int EXIT_FAILURE;
scalar_t__ EXIT_SUCCESS;
int MS_NOSUID;
int MS_SYNCHRONOUS;
int /*<<< orphan*/ NBD_CLEAR_SOCK;
int /*<<< orphan*/ O_RDWR;
scalar_t__ WEXITSTATUS(int);
int /*<<< orphan*/ WIFEXITED(int);
int atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(scalar_t__);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int ioctl(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mount(char const *, char const *, char const *, int,
                         int /*<<< orphan*/);
int open(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ umount(char const *);
int waitpid(int, int *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  const char *mountpoint, *dev, *fstype;
  int loops, fd, i;
  if (argc != 5) {
    fprintf(stderr, "usage: %s DEV MOUNTPOINT FSTYPE LOOPS", argv[0]);
    return EXIT_FAILURE;
  }
  dev = argv[1];
  mountpoint = argv[2];
  fstype = argv[3];
  loops = atoi(argv[4]);
  fd = open(dev, O_RDWR);
  if (fd == -1) {
    perror("open");
    return EXIT_FAILURE;
  }
  for (i = 0; i < loops; i++) {
    pid_t mount_pid, clear_sock_pid;
    int wstatus;
    mount_pid = fork();
    if (mount_pid == -1) {
      perror("fork");
      return EXIT_FAILURE;
    }
    if (mount_pid == 0) {
      mount(dev, mountpoint, fstype, MS_NOSUID | MS_SYNCHRONOUS, 0);
      umount(mountpoint);
      exit(EXIT_SUCCESS);
    }
    clear_sock_pid = fork();
    if (clear_sock_pid == -1) {
      perror("fork");
      return EXIT_FAILURE;
    }
    if (clear_sock_pid == 0) {
      if (ioctl(fd, NBD_CLEAR_SOCK, 0) == -1) {
        perror("ioctl");
        exit(EXIT_FAILURE);
      }
      exit(EXIT_SUCCESS);
    }
    if (waitpid(mount_pid, &wstatus, 0) == -1) {
      perror("waitpid");
      return EXIT_FAILURE;
    }
    if (!WIFEXITED(wstatus) || WEXITSTATUS(wstatus) != EXIT_SUCCESS) {
      fprintf(stderr, "mount process failed");
      return EXIT_FAILURE;
    }
    if (waitpid(clear_sock_pid, &wstatus, 0) == -1) {
      perror("waitpid");
      return EXIT_FAILURE;
    }
    if (!WIFEXITED(wstatus) || WEXITSTATUS(wstatus) != EXIT_SUCCESS) {
      fprintf(stderr, "NBD_CLEAR_SOCK process failed");
      return EXIT_FAILURE;
    }
  }
  close(fd);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     121f <main+0x4f>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdf9(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2da3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14ce <main+0x2fe>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2d8a(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0xffffffff,-0x30(%rbp)
jne    128f <main+0xbf>
lea    0xdad(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2d33(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14ce <main+0x2fe>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    14b9 <main+0x2e9>
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0xffffffff,-0x38(%rbp)
jne    12d3 <main+0x103>
lea    0xd6e(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2cef(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14ce <main+0x2fe>
cmpl   $0x0,-0x38(%rbp)
jne    131b <main+0x14b>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    0x2cf0(%rip),%rax
mov    (%rax),%ecx
mov    0x2cd7(%rip),%rax
or     (%rax),%ecx
xor    %r8d,%r8d
call   1040 <mount@plt>
mov    -0x18(%rbp),%rdi
call   1030 <umount@plt>
mov    0x2c9d(%rip),%rax
mov    (%rax),%rdi
call   10e0 <exit@plt>
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
jne    134c <main+0x17c>
lea    0xcf5(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2c76(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14ce <main+0x2fe>
cmpl   $0x0,-0x3c(%rbp)
jne    139c <main+0x1cc>
mov    -0x30(%rbp),%edi
mov    0x2c78(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    138d <main+0x1bd>
lea    0xcb7(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2c33(%rip),%rax
movslq (%rax),%rdi
call   10e0 <exit@plt>
mov    0x2c1c(%rip),%rax
mov    (%rax),%rdi
call   10e0 <exit@plt>
mov    -0x38(%rbp),%edi
lea    -0x40(%rbp),%rsi
xor    %edx,%edx
call   1090 <waitpid@plt>
cmp    $0xffffffff,%eax
jne    13d0 <main+0x200>
lea    0xc7c(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2bf2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14ce <main+0x2fe>
mov    -0x40(%rbp),%edi
call   10d0 <WIFEXITED@plt>
cmp    $0x0,%eax
je     13f9 <main+0x229>
mov    -0x40(%rbp),%edi
call   1080 <WEXITSTATUS@plt>
mov    0x2bc0(%rip),%rcx
cmp    (%rcx),%rax
je     1421 <main+0x251>
mov    0x2bc0(%rip),%rax
mov    (%rax),%edi
lea    0xc35(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2ba1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14ce <main+0x2fe>
mov    -0x3c(%rbp),%edi
lea    -0x40(%rbp),%rsi
xor    %edx,%edx
call   1090 <waitpid@plt>
cmp    $0xffffffff,%eax
jne    1455 <main+0x285>
lea    0xbf7(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2b6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14ce <main+0x2fe>
mov    -0x40(%rbp),%edi
call   10d0 <WIFEXITED@plt>
cmp    $0x0,%eax
je     147e <main+0x2ae>
mov    -0x40(%rbp),%edi
call   1080 <WEXITSTATUS@plt>
mov    0x2b3b(%rip),%rcx
cmp    (%rcx),%rax
je     14a6 <main+0x2d6>
mov    0x2b3b(%rip),%rax
mov    (%rax),%edi
lea    0xbc5(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2b1c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14ce <main+0x2fe>
jmp    14ab <main+0x2db>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1296 <main+0xc6>
mov    -0x30(%rbp),%edi
call   1060 <close@plt>
mov    0x2ae8(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x5,%edi
jne    12f4 <main+0x124>
mov    0x8(%rsi),%rbx
mov    0x10(%rsi),%r14
mov    0x18(%rsi),%r15
mov    0x20(%rsi),%rdi
call   10c0 <atoi@plt>
mov    %eax,%ebp
mov    0x2de3(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10a0 <open@plt>
cmp    $0xffffffff,%eax
je     1351 <main+0x181>
mov    %eax,%r13d
mov    %r15,0x10(%rsp)
mov    %rbx,0x18(%rsp)
mov    %r14,0x20(%rsp)
test   %ebp,%ebp
jle    12e3 <main+0x113>
lea    0xc(%rsp),%rbx
mov    0x2d72(%rip),%r12
xchg   %ax,%ax
xor    %eax,%eax
call   10f0 <fork@plt>
cmp    $0xffffffff,%eax
je     135a <main+0x18a>
mov    %eax,%r15d
test   %eax,%eax
je     1371 <main+0x1a1>
xor    %eax,%eax
call   10f0 <fork@plt>
cmp    $0xffffffff,%eax
je     135a <main+0x18a>
mov    %eax,%r14d
test   %eax,%eax
je     13ae <main+0x1de>
mov    %r15d,%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1090 <waitpid@plt>
cmp    $0xffffffff,%eax
je     1363 <main+0x193>
mov    0xc(%rsp),%edi
call   10d0 <WIFEXITED@plt>
test   %eax,%eax
je     1310 <main+0x140>
mov    0xc(%rsp),%edi
call   1080 <WEXITSTATUS@plt>
cmp    (%r12),%rax
jne    1310 <main+0x140>
mov    %r14d,%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1090 <waitpid@plt>
cmp    $0xffffffff,%eax
je     1363 <main+0x193>
mov    0xc(%rsp),%edi
call   10d0 <WIFEXITED@plt>
test   %eax,%eax
je     1322 <main+0x152>
mov    0xc(%rsp),%edi
call   1080 <WEXITSTATUS@plt>
cmp    (%r12),%rax
jne    1322 <main+0x152>
add    $0xffffffff,%ebp
jne    1240 <main+0x70>
mov    %r13d,%edi
call   1060 <close@plt>
mov    0x2cbe(%rip),%rax
jmp    1340 <main+0x170>
mov    0x2cc5(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xcf9(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1339 <main+0x169>
mov    0x2ca9(%rip),%rax
mov    (%rax),%edi
lea    0xd1e(%rip),%rsi
jmp    1332 <main+0x162>
mov    0x2c97(%rip),%rax
mov    (%rax),%edi
lea    0xd21(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2c78(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcce(%rip),%rdi
jmp    136a <main+0x19a>
lea    0xcca(%rip),%rdi
jmp    136a <main+0x19a>
lea    0xccc(%rip),%rdi
call   10b0 <perror@plt>
jmp    1339 <main+0x169>
mov    0x2c68(%rip),%rax
mov    0x2c51(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x18(%rsp),%rdi
mov    0x20(%rsp),%rbx
mov    %rbx,%rsi
mov    0x10(%rsp),%rdx
xor    %r8d,%r8d
call   1040 <mount@plt>
mov    %rbx,%rdi
call   1030 <umount@plt>
mov    (%r12),%rdi
call   10e0 <exit@plt>
mov    0x2c23(%rip),%rax
mov    (%rax),%esi
mov    %r13d,%edi
xor    %edx,%edx
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    13e1 <main+0x211>
lea    0xc63(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2bdf(%rip),%rax
movslq (%rax),%rdi
call   10e0 <exit@plt>
mov    (%r12),%rdi
call   10e0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"usage: %s DEV MOUNTPOINT FSTYPE LOOPS\00"
@EXIT_FAILURE = global i32 0
@O_RDWR = global i32 0
@.str.1 = [5 x i8] c"open\00"
@.str.2 = [5 x i8] c"fork\00"
@MS_NOSUID = global i32 0
@MS_SYNCHRONOUS = global i32 0
@EXIT_SUCCESS = global i64 0
@NBD_CLEAR_SOCK = global i32 0
@.str.3 = [6 x i8] c"ioctl\00"
@.str.4 = [8 x i8] c"waitpid\00"
@.str.5 = [21 x i8] c"mount process failed\00"
@.str.6 = [30 x i8] c"NBD_CLEAR_SOCK process failed\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 5
br i1 %16, label %17, label %24
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = load i32, i32* @EXIT_FAILURE
store i32 %23, i32* %3
br label %145
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
store i8* %27, i8** %7
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
store i8* %30, i8** %6
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 3
%33 = load i8*, i8** %32
store i8* %33, i8** %8
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 4
%36 = load i8*, i8** %35
%37 = call i32 @atoi(i8* %36)
store i32 %37, i32* %9
%38 = load i8*, i8** %7
%39 = load i32, i32* @O_RDWR
%40 = call i32 @open(i8* %38, i32 %39)
store i32 %40, i32* %10
%41 = load i32, i32* %10
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %46
43: ; preds = %24
%44 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%45 = load i32, i32* @EXIT_FAILURE
store i32 %45, i32* %3
br label %145
46: ; preds = %24
store i32 0, i32* %11
br label %47
47: ; preds = %137, %46
%48 = load i32, i32* %11
%49 = load i32, i32* %9
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %140
51: ; preds = %47
%52 = call i32 (...) @fork()
store i32 %52, i32* %12
%53 = load i32, i32* %12
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %58
55: ; preds = %51
%56 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%57 = load i32, i32* @EXIT_FAILURE
store i32 %57, i32* %3
br label %145
58: ; preds = %51
%59 = load i32, i32* %12
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %73
61: ; preds = %58
%62 = load i8*, i8** %7
%63 = load i8*, i8** %6
%64 = load i8*, i8** %8
%65 = load i32, i32* @MS_NOSUID
%66 = load i32, i32* @MS_SYNCHRONOUS
%67 = or i32 %65, %66
%68 = call i32 @mount(i8* %62, i8* %63, i8* %64, i32 %67, i32 0)
%69 = load i8*, i8** %6
%70 = call i32 @umount(i8* %69)
%71 = load i64, i64* @EXIT_SUCCESS
%72 = call i32 @exit(i64 %71)
unreachable
73: ; preds = %58
%74 = call i32 (...) @fork()
store i32 %74, i32* %13
%75 = load i32, i32* %13
%76 = icmp eq i32 %75, -1
br i1 %76, label %77, label %80
77: ; preds = %73
%78 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%79 = load i32, i32* @EXIT_FAILURE
store i32 %79, i32* %3
br label %145
80: ; preds = %73
%81 = load i32, i32* %13
%82 = icmp eq i32 %81, 0
br i1 %82, label %83, label %96
83: ; preds = %80
%84 = load i32, i32* %10
%85 = load i32, i32* @NBD_CLEAR_SOCK
%86 = call i32 @ioctl(i32 %84, i32 %85, i32 0)
%87 = icmp eq i32 %86, -1
br i1 %87, label %88, label %93
88: ; preds = %83
%89 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%90 = load i32, i32* @EXIT_FAILURE
%91 = sext i32 %90 to i64
%92 = call i32 @exit(i64 %91)
unreachable
93: ; preds = %83
%94 = load i64, i64* @EXIT_SUCCESS
%95 = call i32 @exit(i64 %94)
unreachable
96: ; preds = %80
%97 = load i32, i32* %12
%98 = call i32 @waitpid(i32 %97, i32* %14, i32 0)
%99 = icmp eq i32 %98, -1
br i1 %99, label %100, label %103
100: ; preds = %96
%101 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%102 = load i32, i32* @EXIT_FAILURE
store i32 %102, i32* %3
br label %145
103: ; preds = %96
%104 = load i32, i32* %14
%105 = call i32 @WIFEXITED(i32 %104)
%106 = icmp ne i32 %105, 0
br i1 %106, label %107, label %112
107: ; preds = %103
%108 = load i32, i32* %14
%109 = call i64 @WEXITSTATUS(i32 %108)
%110 = load i64, i64* @EXIT_SUCCESS
%111 = icmp ne i64 %109, %110
br i1 %111, label %112, label %116
112: ; preds = %107, %103
%113 = load i32, i32* @stderr
%114 = call i32 (i32, i8*, ...) @fprintf(i32 %113, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%115 = load i32, i32* @EXIT_FAILURE
store i32 %115, i32* %3
br label %145
116: ; preds = %107
%117 = load i32, i32* %13
%118 = call i32 @waitpid(i32 %117, i32* %14, i32 0)
%119 = icmp eq i32 %118, -1
br i1 %119, label %120, label %123
120: ; preds = %116
%121 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%122 = load i32, i32* @EXIT_FAILURE
store i32 %122, i32* %3
br label %145
123: ; preds = %116
%124 = load i32, i32* %14
%125 = call i32 @WIFEXITED(i32 %124)
%126 = icmp ne i32 %125, 0
br i1 %126, label %127, label %132
127: ; preds = %123
%128 = load i32, i32* %14
%129 = call i64 @WEXITSTATUS(i32 %128)
%130 = load i64, i64* @EXIT_SUCCESS
%131 = icmp ne i64 %129, %130
br i1 %131, label %132, label %136
132: ; preds = %127, %123
%133 = load i32, i32* @stderr
%134 = call i32 (i32, i8*, ...) @fprintf(i32 %133, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%135 = load i32, i32* @EXIT_FAILURE
store i32 %135, i32* %3
br label %145
136: ; preds = %127
br label %137
137: ; preds = %136
%138 = load i32, i32* %11
%139 = add nsw i32 %138, 1
store i32 %139, i32* %11
br label %47
140: ; preds = %47
%141 = load i32, i32* %10
%142 = call i32 @close(i32 %141)
%143 = load i64, i64* @EXIT_SUCCESS
%144 = trunc i64 %143 to i32
store i32 %144, i32* %3
br label %145
145: ; preds = %140, %132, %120, %112, %100, %77, %55, %43, %17
%146 = load i32, i32* %3
ret i32 %146
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"usage: %s DEV MOUNTPOINT FSTYPE LOOPS\00"
@EXIT_FAILURE = global i32 0
@O_RDWR = global i32 0
@.str.1 = [5 x i8] c"open\00"
@.str.2 = [5 x i8] c"fork\00"
@MS_NOSUID = global i32 0
@MS_SYNCHRONOUS = global i32 0
@EXIT_SUCCESS = global i64 0
@NBD_CLEAR_SOCK = global i32 0
@.str.3 = [6 x i8] c"ioctl\00"
@.str.4 = [8 x i8] c"waitpid\00"
@.str.5 = [21 x i8] c"mount process failed\00"
@.str.6 = [30 x i8] c"NBD_CLEAR_SOCK process failed\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = icmp eq i32 %0, 5
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i32, i32* @EXIT_FAILURE
br label %102
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8*, i8** %1, i64 3
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8*, i8** %1, i64 4
%18 = load i8*, i8** %17
%19 = tail call i32 @atoi(i8* %18)
%20 = load i32, i32* @O_RDWR
%21 = tail call i32 @open(i8* %12, i32 %20)
%22 = icmp eq i32 %21, -1
br i1 %22, label %27, label %23
23: ; preds = %10
%24 = icmp sgt i32 %19, 0
br i1 %24, label %25, label %98
25: ; preds = %23
%26 = bitcast i32* %3 to i8*
br label %30
27: ; preds = %10
%28 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%29 = load i32, i32* @EXIT_FAILURE
br label %102
30: ; preds = %25, %95
%31 = phi i32 [ 0, %25 ], [ %96, %95 ]
%32 = call i32 (...) @fork()
switch i32 %32, label %43 [
i32 -1, label %33
i32 0, label %35
]
33: ; preds = %30
%34 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %93
35: ; preds = %30
%36 = load i32, i32* @MS_NOSUID
%37 = load i32, i32* @MS_SYNCHRONOUS
%38 = or i32 %37, %36
%39 = call i32 @mount(i8* %12, i8* %14, i8* %16, i32 %38, i32 0)
%40 = call i32 @umount(i8* %14)
%41 = load i64, i64* @EXIT_SUCCESS
%42 = call i32 @exit(i64 %41)
unreachable
43: ; preds = %30
%44 = call i32 (...) @fork()
switch i32 %44, label %59 [
i32 -1, label %45
i32 0, label %47
]
45: ; preds = %43
%46 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %93
47: ; preds = %43
%48 = load i32, i32* @NBD_CLEAR_SOCK
%49 = call i32 @ioctl(i32 %21, i32 %48, i32 0)
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %56
51: ; preds = %47
%52 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%53 = load i32, i32* @EXIT_FAILURE
%54 = sext i32 %53 to i64
%55 = call i32 @exit(i64 %54)
unreachable
56: ; preds = %47
%57 = load i64, i64* @EXIT_SUCCESS
%58 = call i32 @exit(i64 %57)
unreachable
59: ; preds = %43
%60 = call i32 @waitpid(i32 %32, i32* %3, i32 0)
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %64
62: ; preds = %59
%63 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %93
64: ; preds = %59
%65 = load i32, i32* %3
%66 = call i32 @WIFEXITED(i32 %65)
%67 = icmp eq i32 %66, 0
br i1 %67, label %73, label %68
68: ; preds = %64
%69 = load i32, i32* %3
%70 = call i64 @WEXITSTATUS(i32 %69)
%71 = load i64, i64* @EXIT_SUCCESS
%72 = icmp eq i64 %70, %71
br i1 %72, label %76, label %73
73: ; preds = %68, %64
%74 = load i32, i32* @stderr
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
br label %93
76: ; preds = %68
%77 = call i32 @waitpid(i32 %44, i32* %3, i32 0)
%78 = icmp eq i32 %77, -1
br i1 %78, label %79, label %81
79: ; preds = %76
%80 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %93
81: ; preds = %76
%82 = load i32, i32* %3
%83 = call i32 @WIFEXITED(i32 %82)
%84 = icmp eq i32 %83, 0
br i1 %84, label %90, label %85
85: ; preds = %81
%86 = load i32, i32* %3
%87 = call i64 @WEXITSTATUS(i32 %86)
%88 = load i64, i64* @EXIT_SUCCESS
%89 = icmp eq i64 %87, %88
br i1 %89, label %95, label %90
90: ; preds = %85, %81
%91 = load i32, i32* @stderr
%92 = call i32 (i32, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
br label %93
93: ; preds = %90, %79, %73, %62, %45, %33
%94 = load i32, i32* @EXIT_FAILURE
br label %102
95: ; preds = %85
%96 = add nuw nsw i32 %31, 1
%97 = icmp eq i32 %96, %19
br i1 %97, label %98, label %30
98: ; preds = %95, %23
%99 = call i32 @close(i32 %21)
%100 = load i64, i64* @EXIT_SUCCESS
%101 = trunc i64 %100 to i32
br label %102
102: ; preds = %93, %98, %27, %5
%103 = phi i32 [ %9, %5 ], [ %29, %27 ], [ %101, %98 ], [ %94, %93 ]
ret i32 %103
}