#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 mode_t;

/* Variables and functions */
int eslib_file_exists(char *);
int eslib_file_isdir(char *);
scalar_t__ eslib_file_mkdirpath(char *, int const);
scalar_t__ eslib_file_mkfile(char *, int const);
scalar_t__ eslib_file_path_check(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int file_confirm_mountpoint(char *src, char *dest, unsigned long esflags) {
  int r;
  int exists = 0;
  const mode_t mode = 0755;
  if (eslib_file_path_check(src) || eslib_file_path_check(dest))
    return -1;
  r = eslib_file_exists(dest);
  if (r == -1)
    goto err;
  exists = r;
  r = eslib_file_isdir(src);
  if (r == 1) {
    if (exists) {
      if (eslib_file_isdir(dest) != 1) {
        printf("dest(%s) is not a directory.\n", dest);
        return -1;
      }
    } else {
      if (esflags & 16) {
        if (eslib_file_mkdirpath(dest, mode)) {
          printf("mkdirpath(%s) failed\n", dest);
          return -1;
        }
      } else {
        printf("dest(%s) did not exist\n", dest);
        return -1;
      }
    }
    return 0;
  } else if (r == -1) {
    goto err;
  }
  if (exists) {
    r = eslib_file_isdir(dest);
    if (r == 1) {
      printf("dest(%s) should not be a directory\n", dest);
      return -1;
    }
    if (r == 0) {
      return 0;
    } else {
      goto err;
    }
  } else {
    if (esflags & 16) {
      if (eslib_file_mkfile(dest, mode)) {
        printf("mkfile(%s) failed\n", dest);
        return -1;
      }
    } else {
      printf("dest(%s) did not exist\n", dest);
      return -1;
    }
    return 0;
  }
err:
  printf("create mountpoint(%s, %s) failed\n", src, dest);
  return -1;
}


x86 assembly (clang, -O0):
<file_confirm_mountpoint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x1ed,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <eslib_file_path_check@plt>
cmp    $0x0,%rax
jne    11a8 <file_confirm_mountpoint+0x48>
mov    -0x18(%rbp),%rdi
call   1030 <eslib_file_path_check@plt>
cmp    $0x0,%rax
je     11b4 <file_confirm_mountpoint+0x54>
movl   $0xffffffff,-0x4(%rbp)
jmp    13a7 <file_confirm_mountpoint+0x247>
mov    -0x18(%rbp),%rdi
call   1060 <eslib_file_exists@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    11cf <file_confirm_mountpoint+0x6f>
jmp    138a <file_confirm_mountpoint+0x22a>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <eslib_file_isdir@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jne    12a6 <file_confirm_mountpoint+0x146>
cmpl   $0x0,-0x28(%rbp)
je     122a <file_confirm_mountpoint+0xca>
mov    -0x18(%rbp),%rdi
call   1080 <eslib_file_isdir@plt>
cmp    $0x1,%eax
je     1225 <file_confirm_mountpoint+0xc5>
mov    -0x18(%rbp),%rsi
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13a7 <file_confirm_mountpoint+0x247>
jmp    129a <file_confirm_mountpoint+0x13a>
mov    -0x20(%rbp),%rax
and    $0x10,%rax
cmp    $0x0,%rax
je     1277 <file_confirm_mountpoint+0x117>
mov    -0x18(%rbp),%rdi
mov    $0x1ed,%esi
call   1070 <eslib_file_mkdirpath@plt>
cmp    $0x0,%rax
je     1272 <file_confirm_mountpoint+0x112>
mov    -0x18(%rbp),%rsi
lea    0xdbf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13a7 <file_confirm_mountpoint+0x247>
jmp    1295 <file_confirm_mountpoint+0x135>
mov    -0x18(%rbp),%rsi
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13a7 <file_confirm_mountpoint+0x247>
jmp    129a <file_confirm_mountpoint+0x13a>
movl   $0x0,-0x4(%rbp)
jmp    13a7 <file_confirm_mountpoint+0x247>
cmpl   $0xffffffff,-0x24(%rbp)
jne    12b5 <file_confirm_mountpoint+0x155>
jmp    138a <file_confirm_mountpoint+0x22a>
jmp    12ba <file_confirm_mountpoint+0x15a>
cmpl   $0x0,-0x28(%rbp)
je     1313 <file_confirm_mountpoint+0x1b3>
mov    -0x18(%rbp),%rdi
call   1080 <eslib_file_isdir@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jne    12f8 <file_confirm_mountpoint+0x198>
mov    -0x18(%rbp),%rsi
lea    0xd67(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13a7 <file_confirm_mountpoint+0x247>
cmpl   $0x0,-0x24(%rbp)
jne    130e <file_confirm_mountpoint+0x1ae>
movl   $0x0,-0x4(%rbp)
jmp    13a7 <file_confirm_mountpoint+0x247>
jmp    138a <file_confirm_mountpoint+0x22a>
mov    -0x20(%rbp),%rax
and    $0x10,%rax
cmp    $0x0,%rax
je     1360 <file_confirm_mountpoint+0x200>
mov    -0x18(%rbp),%rdi
mov    $0x1ed,%esi
call   1040 <eslib_file_mkfile@plt>
cmp    $0x0,%rax
je     135b <file_confirm_mountpoint+0x1fb>
mov    -0x18(%rbp),%rsi
lea    0xd28(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13a7 <file_confirm_mountpoint+0x247>
jmp    137e <file_confirm_mountpoint+0x21e>
mov    -0x18(%rbp),%rsi
lea    0xcc9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13a7 <file_confirm_mountpoint+0x247>
movl   $0x0,-0x4(%rbp)
jmp    13a7 <file_confirm_mountpoint+0x247>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xcea(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_confirm_mountpoint>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%rbp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <eslib_file_path_check@plt>
mov    $0xffffffff,%r15d
test   %rax,%rax
jne    1219 <file_confirm_mountpoint+0xb9>
mov    %r14,%rdi
call   1030 <eslib_file_path_check@plt>
test   %rax,%rax
jne    1219 <file_confirm_mountpoint+0xb9>
mov    %r14,%rdi
call   1060 <eslib_file_exists@plt>
cmp    $0xffffffff,%eax
je     11ff <file_confirm_mountpoint+0x9f>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1080 <eslib_file_isdir@plt>
cmp    $0xffffffff,%eax
je     11ff <file_confirm_mountpoint+0x9f>
cmp    $0x1,%eax
jne    11e0 <file_confirm_mountpoint+0x80>
test   %r12d,%r12d
je     1225 <file_confirm_mountpoint+0xc5>
mov    %r14,%rdi
call   1080 <eslib_file_isdir@plt>
xor    %r15d,%r15d
cmp    $0x1,%eax
je     1219 <file_confirm_mountpoint+0xb9>
lea    0xe2c(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1213 <file_confirm_mountpoint+0xb3>
test   %r12d,%r12d
je     1246 <file_confirm_mountpoint+0xe6>
mov    %r14,%rdi
call   1080 <eslib_file_isdir@plt>
test   %eax,%eax
je     1255 <file_confirm_mountpoint+0xf5>
cmp    $0x1,%eax
jne    11ff <file_confirm_mountpoint+0x9f>
lea    0xe4f(%rip),%rdi
jmp    1273 <file_confirm_mountpoint+0x113>
lea    0xe7d(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
test   $0x10,%bpl
je     124c <file_confirm_mountpoint+0xec>
mov    %r14,%rdi
mov    $0x1ed,%esi
call   1070 <eslib_file_mkdirpath@plt>
test   %rax,%rax
je     127f <file_confirm_mountpoint+0x11f>
lea    0xdda(%rip),%rdi
jmp    1273 <file_confirm_mountpoint+0x113>
test   $0x10,%bpl
jne    125a <file_confirm_mountpoint+0xfa>
lea    0xde1(%rip),%rdi
jmp    1273 <file_confirm_mountpoint+0x113>
mov    %eax,%r15d
jmp    1219 <file_confirm_mountpoint+0xb9>
mov    %r14,%rdi
mov    $0x1ed,%esi
call   1040 <eslib_file_mkfile@plt>
test   %rax,%rax
je     127f <file_confirm_mountpoint+0x11f>
lea    0xdfd(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1219 <file_confirm_mountpoint+0xb9>
xor    %r15d,%r15d
jmp    1219 <file_confirm_mountpoint+0xb9>

LLVM IR (-O0):
@.str = [30 x i8] c"dest(%s) is not a directory.\0A\00"
@.str.1 = [22 x i8] c"mkdirpath(%s) failed\0A\00"
@.str.2 = [24 x i8] c"dest(%s) did not exist\0A\00"
@.str.3 = [36 x i8] c"dest(%s) should not be a directory\0A\00"
@.str.4 = [19 x i8] c"mkfile(%s) failed\0A\00"
@.str.5 = [34 x i8] c"create mountpoint(%s, %s) failed\0A\00"
define i32 @file_confirm_mountpoint(i8* %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
store i32 0, i32* %9
store i32 493, i32* %10
%11 = load i8*, i8** %5
%12 = call i64 @eslib_file_path_check(i8* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %3
%15 = load i8*, i8** %6
%16 = call i64 @eslib_file_path_check(i8* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14, %3
store i32 -1, i32* %4
br label %100
19: ; preds = %14
%20 = load i8*, i8** %6
%21 = call i32 @eslib_file_exists(i8* %20)
store i32 %21, i32* %8
%22 = load i32, i32* %8
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %25
24: ; preds = %19
br label %96
25: ; preds = %19
%26 = load i32, i32* %8
store i32 %26, i32* %9
%27 = load i8*, i8** %5
%28 = call i32 @eslib_file_isdir(i8* %27)
store i32 %28, i32* %8
%29 = load i32, i32* %8
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %59
31: ; preds = %25
%32 = load i32, i32* %9
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %42
34: ; preds = %31
%35 = load i8*, i8** %6
%36 = call i32 @eslib_file_isdir(i8* %35)
%37 = icmp ne i32 %36, 1
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = load i8*, i8** %6
%40 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %39)
store i32 -1, i32* %4
br label %100
41: ; preds = %34
br label %58
42: ; preds = %31
%43 = load i64, i64* %7
%44 = and i64 %43, 16
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %54
46: ; preds = %42
%47 = load i8*, i8** %6
%48 = call i64 @eslib_file_mkdirpath(i8* %47, i32 493)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %46
%51 = load i8*, i8** %6
%52 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %51)
store i32 -1, i32* %4
br label %100
53: ; preds = %46
br label %57
54: ; preds = %42
%55 = load i8*, i8** %6
%56 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %55)
store i32 -1, i32* %4
br label %100
57: ; preds = %53
br label %58
58: ; preds = %57, %41
store i32 0, i32* %4
br label %100
59: ; preds = %25
%60 = load i32, i32* %8
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %63
62: ; preds = %59
br label %96
63: ; preds = %59
br label %64
64: ; preds = %63
%65 = load i32, i32* %9
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %80
67: ; preds = %64
%68 = load i8*, i8** %6
%69 = call i32 @eslib_file_isdir(i8* %68)
store i32 %69, i32* %8
%70 = load i32, i32* %8
%71 = icmp eq i32 %70, 1
br i1 %71, label %72, label %75
72: ; preds = %67
%73 = load i8*, i8** %6
%74 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* %73)
store i32 -1, i32* %4
br label %100
75: ; preds = %67
%76 = load i32, i32* %8
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %79
78: ; preds = %75
store i32 0, i32* %4
br label %100
79: ; preds = %75
br label %96
80: ; preds = %64
%81 = load i64, i64* %7
%82 = and i64 %81, 16
%83 = icmp ne i64 %82, 0
br i1 %83, label %84, label %92
84: ; preds = %80
%85 = load i8*, i8** %6
%86 = call i64 @eslib_file_mkfile(i8* %85, i32 493)
%87 = icmp ne i64 %86, 0
br i1 %87, label %88, label %91
88: ; preds = %84
%89 = load i8*, i8** %6
%90 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %89)
store i32 -1, i32* %4
br label %100
91: ; preds = %84
br label %95
92: ; preds = %80
%93 = load i8*, i8** %6
%94 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %93)
store i32 -1, i32* %4
br label %100
95: ; preds = %91
store i32 0, i32* %4
br label %100
96: ; preds = %79, %62, %24
%97 = load i8*, i8** %5
%98 = load i8*, i8** %6
%99 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i8* %97, i8* %98)
store i32 -1, i32* %4
br label %100
100: ; preds = %96, %95, %92, %88, %78, %72, %58, %54, %50, %38, %18
%101 = load i32, i32* %4
ret i32 %101
}

LLVM IR (-O2):
@.str = [30 x i8] c"dest(%s) is not a directory.\0A\00"
@.str.1 = [22 x i8] c"mkdirpath(%s) failed\0A\00"
@.str.2 = [24 x i8] c"dest(%s) did not exist\0A\00"
@.str.3 = [36 x i8] c"dest(%s) should not be a directory\0A\00"
@.str.4 = [19 x i8] c"mkfile(%s) failed\0A\00"
@.str.5 = [34 x i8] c"create mountpoint(%s, %s) failed\0A\00"
define i32 @file_confirm_mountpoint(i8* %0, i8* %1, i64 %2) {
%4 = tail call i64 @eslib_file_path_check(i8* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %49
6: ; preds = %3
%7 = tail call i64 @eslib_file_path_check(i8* %1)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %49
9: ; preds = %6
%10 = tail call i32 @eslib_file_exists(i8* %1)
%11 = icmp eq i32 %10, -1
br i1 %11, label %47, label %12
12: ; preds = %9
%13 = tail call i32 @eslib_file_isdir(i8* %0)
switch i32 %13, label %31 [
i32 1, label %14
i32 -1, label %47
]
14: ; preds = %12
%15 = icmp eq i32 %10, 0
br i1 %15, label %21, label %16
16: ; preds = %14
%17 = tail call i32 @eslib_file_isdir(i8* %1)
%18 = icmp eq i32 %17, 1
br i1 %18, label %49, label %19
19: ; preds = %16
%20 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %49
21: ; preds = %14
%22 = and i64 %2, 16
%23 = icmp eq i64 %22, 0
br i1 %23, label %29, label %24
24: ; preds = %21
%25 = tail call i64 @eslib_file_mkdirpath(i8* %1, i32 493)
%26 = icmp eq i64 %25, 0
br i1 %26, label %49, label %27
27: ; preds = %24
%28 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %49
29: ; preds = %21
%30 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %1)
br label %49
31: ; preds = %12
%32 = icmp eq i32 %10, 0
br i1 %32, label %37, label %33
33: ; preds = %31
%34 = tail call i32 @eslib_file_isdir(i8* %1)
switch i32 %34, label %47 [
i32 1, label %35
i32 0, label %49
]
35: ; preds = %33
%36 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* %1)
br label %49
37: ; preds = %31
%38 = and i64 %2, 16
%39 = icmp eq i64 %38, 0
br i1 %39, label %45, label %40
40: ; preds = %37
%41 = tail call i64 @eslib_file_mkfile(i8* %1, i32 493)
%42 = icmp eq i64 %41, 0
br i1 %42, label %49, label %43
43: ; preds = %40
%44 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %1)
br label %49
45: ; preds = %37
%46 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %1)
br label %49
47: ; preds = %33, %12, %9
%48 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i8* %0, i8* %1)
br label %49
49: ; preds = %40, %33, %16, %24, %3, %6, %47, %45, %43, %35, %29, %27, %19
%50 = phi i32 [ -1, %47 ], [ -1, %19 ], [ -1, %27 ], [ -1, %29 ], [ -1, %35 ], [ -1, %43 ], [ -1, %45 ], [ -1, %6 ], [ -1, %3 ], [ 0, %24 ], [ 0, %16 ], [ %34, %33 ], [ 0, %40 ]
ret i32 %50
}