#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 char *strtok_r;
typedef int mount;
typedef char *malloc;

/* Variables and functions */
unsigned long MS_NOSUID;
unsigned long MS_RDONLY;
int /*<<< orphan*/ crash();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ mkdirP(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
scalar_t__ strlen(char *);
void handleHostMount(char **saveptr) {
  int tmpi;
  char *rrw, *host, *rhost, *guest, *rguest;
  unsigned long flags;
  do {
    (rrw) = (strtok_r)(NULL, " ", saveptr);
    if ((rrw) == (NULL)) {
      perror("strtok_r"
             "(NULL, \" \", saveptr)");
      crash();
    }
  } while (0);
  do {
    (host) = (strtok_r)(NULL, " ", saveptr);
    if ((host) == (NULL)) {
      perror("strtok_r"
             "(NULL, \" \", saveptr)");
      crash();
    }
  } while (0);
  do {
    (guest) = (strtok_r)(NULL, " ", saveptr);
    if ((guest) == (NULL)) {
      perror("strtok_r"
             "(NULL, \" \", saveptr)");
      crash();
    }
  } while (0);
  flags = MS_NOSUID;
  if (!strcmp(rrw, "r")) {
    flags |= MS_RDONLY;
  } else if (!strcmp(rrw, "rw")) {
  } else {
    fprintf(stderr, "Unrecognized hostmount flag %s\n", rrw);
    exit(1);
  }
  do {
    (rhost) = (malloc)(strlen(host) + 2);
    if ((rhost) == (NULL)) {
      perror("malloc"
             "(strlen(host) + 2)");
      crash();
    }
  } while (0);
  sprintf(rhost, "%s/", host);
  do {
    (rguest) = (malloc)(strlen(guest) + 6);
    if ((rguest) == (NULL)) {
      perror("malloc"
             "(strlen(guest) + 6)");
      crash();
    }
  } while (0);
  sprintf(rguest, "/host%s", guest);
  mkdirP(rguest);
  do {
    (tmpi) = (mount)("none", rguest, "hostfs", flags, rhost);
    if ((tmpi) == (-1)) {
      perror("mount"
             "(\"none\", rguest, \"hostfs\", flags, rhost)");
      crash();
    }
  } while (0);
  free(rguest);
  free(rhost);
}


x86 assembly (clang, -O0):
<handleHostMount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c2 <handleHostMount+0x32>
lea    0xe4c(%rip),%rdi
call   1090 <perror@plt>
mov    $0x0,%al
call   1040 <crash@plt>
jmp    11c7 <handleHostMount+0x37>
jmp    11cc <handleHostMount+0x3c>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11f2 <handleHostMount+0x62>
lea    0xe1c(%rip),%rdi
call   1090 <perror@plt>
mov    $0x0,%al
call   1040 <crash@plt>
jmp    11f7 <handleHostMount+0x67>
jmp    11fc <handleHostMount+0x6c>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1222 <handleHostMount+0x92>
lea    0xdec(%rip),%rdi
call   1090 <perror@plt>
mov    $0x0,%al
call   1040 <crash@plt>
jmp    1227 <handleHostMount+0x97>
mov    0x2dba(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xddf(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1265 <handleHostMount+0xd5>
mov    0x2d8b(%rip),%rax
mov    (%rax),%rax
or     -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    12ab <handleHostMount+0x11b>
mov    -0x18(%rbp),%rdi
lea    0xdb1(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1283 <handleHostMount+0xf3>
jmp    12a6 <handleHostMount+0x116>
mov    0x2d46(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xd8d(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    12ab <handleHostMount+0x11b>
jmp    12b0 <handleHostMount+0x120>
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
add    $0x2,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12df <handleHostMount+0x14f>
lea    0xd71(%rip),%rdi
call   1090 <perror@plt>
mov    $0x0,%al
call   1040 <crash@plt>
jmp    12e4 <handleHostMount+0x154>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xd6a(%rip),%rsi
call   10a0 <sprintf@plt>
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
add    $0x6,%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1327 <handleHostMount+0x197>
lea    0xd46(%rip),%rdi
call   1090 <perror@plt>
mov    $0x0,%al
call   1040 <crash@plt>
jmp    132c <handleHostMount+0x19c>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xd40(%rip),%rsi
call   10a0 <sprintf@plt>
mov    -0x38(%rbp),%rdi
call   1050 <mkdirP@plt>
mov    -0x28(%rbp),%rax
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    136d <handleHostMount+0x1dd>
lea    0xd2e(%rip),%rdi
call   1090 <perror@plt>
mov    $0x0,%al
call   1040 <crash@plt>
jmp    1372 <handleHostMount+0x1e2>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handleHostMount>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
test   %rdi,%rdi
je     123c <handleHostMount+0xac>
lea    0xe75(%rip),%rsi
mov    %r14,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     11cb <handleHostMount+0x3b>
lea    0xe64(%rip),%rsi
mov    %r14,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
jne    12bd <handleHostMount+0x12d>
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %rax,%r15
add    $0x2,%r15
je     1275 <handleHostMount+0xe5>
lea    0xe74(%rip),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
call   10a0 <sprintf@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %rax,%rbx
add    $0x6,%rbx
je     128d <handleHostMount+0xfd>
lea    0xe6b(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <mkdirP@plt>
cmp    $0xffffffff,%r15d
je     12a5 <handleHostMount+0x115>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>
lea    0xdbd(%rip),%rbx
mov    %rbx,%rdi
call   1090 <perror@plt>
xor    %eax,%eax
call   1040 <crash@plt>
mov    %rbx,%rdi
call   1090 <perror@plt>
xor    %eax,%eax
call   1040 <crash@plt>
mov    %rbx,%rdi
call   1090 <perror@plt>
xor    %eax,%eax
call   1040 <crash@plt>
jmp    11a1 <handleHostMount+0x11>
lea    0xdc6(%rip),%rdi
call   1090 <perror@plt>
xor    %eax,%eax
call   1040 <crash@plt>
jmp    11e0 <handleHostMount+0x50>
lea    0xdcb(%rip),%rdi
call   1090 <perror@plt>
xor    %eax,%eax
call   1040 <crash@plt>
jmp    1207 <handleHostMount+0x77>
lea    0xdd5(%rip),%rdi
call   1090 <perror@plt>
xor    %eax,%eax
call   1040 <crash@plt>
jmp    1227 <handleHostMount+0x97>
mov    0x2d1c(%rip),%rax
mov    (%rax),%edi
lea    0xd55(%rip),%rsi
mov    %r14,%rdx
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [29 x i8] c"strtok_r(NULL, \22 \22, saveptr)\00"
@MS_NOSUID = global i64 0
@.str.2 = [2 x i8] c"r\00"
@MS_RDONLY = global i64 0
@.str.3 = [3 x i8] c"rw\00"
@stderr = global i32 0
@.str.4 = [32 x i8] c"Unrecognized hostmount flag %s\0A\00"
@.str.5 = [25 x i8] c"malloc(strlen(host) + 2)\00"
@.str.6 = [4 x i8] c"%s/\00"
@.str.7 = [26 x i8] c"malloc(strlen(guest) + 6)\00"
@.str.8 = [8 x i8] c"/host%s\00"
@.str.9 = [5 x i8] c"none\00"
@.str.10 = [7 x i8] c"hostfs\00"
@.str.11 = [46 x i8] c"mount(\22none\22, rguest, \22hostfs\22, flags, rhost)\00"
define void @handleHostMount(i8** %0) {
%2 = alloca i8**
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
store i8** %0, i8*** %2
br label %10
10: ; preds = %1
%11 = load i8**, i8*** %2
%12 = bitcast i8** %11 to i8*
store i8* %12, i8** %4
%13 = load i8*, i8** %4
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 (...) @crash()
br label %18
18: ; preds = %15, %10
br label %19
19: ; preds = %18
br label %20
20: ; preds = %19
%21 = load i8**, i8*** %2
%22 = bitcast i8** %21 to i8*
store i8* %22, i8** %5
%23 = load i8*, i8** %5
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 (...) @crash()
br label %28
28: ; preds = %25, %20
br label %29
29: ; preds = %28
br label %30
30: ; preds = %29
%31 = load i8**, i8*** %2
%32 = bitcast i8** %31 to i8*
store i8* %32, i8** %7
%33 = load i8*, i8** %7
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %38
35: ; preds = %30
%36 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%37 = call i32 (...) @crash()
br label %38
38: ; preds = %35, %30
br label %39
39: ; preds = %38
%40 = load i64, i64* @MS_NOSUID
store i64 %40, i64* %9
%41 = load i8*, i8** %4
%42 = call i32 @strcmp(i8* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%43 = icmp ne i32 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %39
%45 = load i64, i64* @MS_RDONLY
%46 = load i64, i64* %9
%47 = or i64 %46, %45
store i64 %47, i64* %9
br label %59
48: ; preds = %39
%49 = load i8*, i8** %4
%50 = call i32 @strcmp(i8* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%51 = icmp ne i32 %50, 0
br i1 %51, label %53, label %52
52: ; preds = %48
br label %58
53: ; preds = %48
%54 = load i32, i32* @stderr
%55 = load i8*, i8** %4
%56 = call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i8* %55)
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %52
br label %59
59: ; preds = %58, %44
br label %60
60: ; preds = %59
%61 = load i8*, i8** %5
%62 = call i64 @strlen(i8* %61)
%63 = add nsw i64 %62, 2
%64 = inttoptr i64 %63 to i8*
store i8* %64, i8** %6
%65 = load i8*, i8** %6
%66 = icmp eq i8* %65, null
br i1 %66, label %67, label %70
67: ; preds = %60
%68 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%69 = call i32 (...) @crash()
br label %70
70: ; preds = %67, %60
br label %71
71: ; preds = %70
%72 = load i8*, i8** %6
%73 = load i8*, i8** %5
%74 = call i32 @sprintf(i8* %72, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %73)
br label %75
75: ; preds = %71
%76 = load i8*, i8** %7
%77 = call i64 @strlen(i8* %76)
%78 = add nsw i64 %77, 6
%79 = inttoptr i64 %78 to i8*
store i8* %79, i8** %8
%80 = load i8*, i8** %8
%81 = icmp eq i8* %80, null
br i1 %81, label %82, label %85
82: ; preds = %75
%83 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%84 = call i32 (...) @crash()
br label %85
85: ; preds = %82, %75
br label %86
86: ; preds = %85
%87 = load i8*, i8** %8
%88 = load i8*, i8** %7
%89 = call i32 @sprintf(i8* %87, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %88)
%90 = load i8*, i8** %8
%91 = call i32 @mkdirP(i8* %90)
br label %92
92: ; preds = %86
%93 = load i8*, i8** %8
%94 = load i64, i64* %9
%95 = load i8*, i8** %6
%96 = ptrtoint i8* %95 to i32
store i32 %96, i32* %3
%97 = load i32, i32* %3
%98 = icmp eq i32 %97, -1
br i1 %98, label %99, label %102
99: ; preds = %92
%100 = call i32 @perror(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.11, i64 0, i64 0))
%101 = call i32 (...) @crash()
br label %102
102: ; preds = %99, %92
br label %103
103: ; preds = %102
%104 = load i8*, i8** %8
%105 = call i32 @free(i8* %104)
%106 = load i8*, i8** %6
%107 = call i32 @free(i8* %106)
ret void
}

LLVM IR (-O2):
@.str.1 = [29 x i8] c"strtok_r(NULL, \22 \22, saveptr)\00"
@MS_NOSUID = global i64 0
@.str.2 = [2 x i8] c"r\00"
@MS_RDONLY = global i64 0
@.str.3 = [3 x i8] c"rw\00"
@stderr = global i32 0
@.str.4 = [32 x i8] c"Unrecognized hostmount flag %s\0A\00"
@.str.5 = [25 x i8] c"malloc(strlen(host) + 2)\00"
@.str.6 = [4 x i8] c"%s/\00"
@.str.7 = [26 x i8] c"malloc(strlen(guest) + 6)\00"
@.str.8 = [8 x i8] c"/host%s\00"
@.str.11 = [46 x i8] c"mount(\22none\22, rguest, \22hostfs\22, flags, rhost)\00"
define void @handleHostMount(i8** %0) {
%2 = bitcast i8** %0 to i8*
%3 = icmp eq i8** %0, null
br i1 %3, label %4, label %11
4: ; preds = %1
%5 = tail call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 (...) @crash()
%7 = tail call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 (...) @crash()
%9 = tail call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 (...) @crash()
br label %11
11: ; preds = %1, %4
%12 = tail call i32 @strcmp(i8* dereferenceable(1) %2, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %21, label %14
14: ; preds = %11
%15 = tail call i32 @strcmp(i8* dereferenceable(1) %2, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %11, %14
%22 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%23 = add nsw i64 %22, 2
%24 = inttoptr i64 %23 to i8*
%25 = icmp eq i64 %23, 0
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = tail call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%28 = tail call i32 (...) @crash()
br label %29
29: ; preds = %26, %21
%30 = tail call i32 @sprintf(i8* dereferenceable(1) %24, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %2)
%31 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%32 = add nsw i64 %31, 6
%33 = inttoptr i64 %32 to i8*
%34 = icmp eq i64 %32, 0
br i1 %34, label %35, label %38
35: ; preds = %29
%36 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%37 = tail call i32 (...) @crash()
br label %38
38: ; preds = %35, %29
%39 = tail call i32 @sprintf(i8* dereferenceable(1) %33, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* %2)
%40 = tail call i32 @mkdirP(i8* %33)
%41 = trunc i64 %23 to i32
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %46
43: ; preds = %38
%44 = tail call i32 @perror(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.11, i64 0, i64 0))
%45 = tail call i32 (...) @crash()
br label %46
46: ; preds = %43, %38
%47 = tail call i32 @free(i8* %33)
%48 = tail call i32 @free(i8* %24)
ret void
}