#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 */
struct stat {
  scalar_t__ st_dev;
  scalar_t__ st_ino;
};
typedef int /*<<< orphan*/ parent;

/* Variables and functions */
scalar_t__ ENOENT;
int PATH_MAX;
scalar_t__ errno;
int /*<<< orphan*/ logger(int, scalar_t__, char *, char const *);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *);
scalar_t__ stat(char const *, struct stat *);
int vps_is_mounted(const char *root, const char *private) {
  struct stat st1, st2;
  char parent[PATH_MAX];
  if (!root || !private)
    return -1;
  if (stat(root, &st1)) {
    logger(-1, errno, "stat(%s)", root);
    return -1;
  }
  snprintf(parent, sizeof(parent), "%s/..", root);
  if (stat(parent, &st2)) {
    logger(-1, errno, "stat(%s)", parent);
    return -1;
  }
  if (st1.st_dev != st2.st_dev)
    return 1;
  if (stat(private, &st2)) {
    if (errno == ENOENT)
      return 0;
    logger(-1, errno, "stat(%s)", private);
    return -1;
  }
  return (st1.st_dev == st2.st_dev) && (st1.st_ino == st2.st_ino);
}


x86 assembly (clang, -O0):
<vps_is_mounted>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2ea9(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x60(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1186 <vps_is_mounted+0x56>
cmpq   $0x0,-0x18(%rbp)
jne    1199 <vps_is_mounted+0x69>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    130f <vps_is_mounted+0x1df>
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <stat@plt>
cmp    $0x0,%rax
je     11e2 <vps_is_mounted+0xb2>
mov    0x2e21(%rip),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rcx
mov    $0xffffffff,%edi
lea    0xe36(%rip),%rdx
call   1050 <logger@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    130f <vps_is_mounted+0x1df>
mov    -0x58(%rbp),%rdi
mov    -0x60(%rbp),%rax
mov    %eax,%esi
mov    -0x10(%rbp),%rcx
lea    0xe12(%rip),%rdx
call   1030 <snprintf@plt>
mov    -0x58(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1040 <stat@plt>
cmp    $0x0,%rax
je     1245 <vps_is_mounted+0x115>
mov    -0x58(%rbp),%rcx
mov    0x2dba(%rip),%rax
mov    (%rax),%rsi
mov    $0xffffffff,%edi
lea    0xdd3(%rip),%rdx
call   1050 <logger@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    130f <vps_is_mounted+0x1df>
mov    -0x28(%rbp),%rax
cmp    -0x38(%rbp),%rax
je     1266 <vps_is_mounted+0x136>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    130f <vps_is_mounted+0x1df>
mov    -0x18(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1040 <stat@plt>
cmp    $0x0,%rax
je     12dc <vps_is_mounted+0x1ac>
mov    0x2d54(%rip),%rax
mov    (%rax),%rax
mov    0x2d3a(%rip),%rcx
cmp    (%rcx),%rax
jne    12aa <vps_is_mounted+0x17a>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    130f <vps_is_mounted+0x1df>
mov    0x2d27(%rip),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rcx
mov    $0xffffffff,%edi
lea    0xd3c(%rip),%rdx
call   1050 <logger@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    130f <vps_is_mounted+0x1df>
mov    -0x28(%rbp),%rcx
xor    %eax,%eax
cmp    -0x38(%rbp),%rcx
mov    %al,-0x61(%rbp)
jne    12fd <vps_is_mounted+0x1cd>
mov    -0x20(%rbp),%rax
cmp    -0x30(%rbp),%rax
sete   %al
mov    %al,-0x61(%rbp)
mov    -0x61(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vps_is_mounted>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsp,%rcx
mov    0x2ea5(%rip),%rax
mov    (%rax),%r13d
mov    %rsp,%rbx
lea    0xf(%r13),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    $0xffffffff,%r15d
test   %rdi,%rdi
je     11fe <vps_is_mounted+0xce>
mov    %rsi,%r14
test   %rsi,%rsi
je     11fe <vps_is_mounted+0xce>
mov    %rdi,%r12
mov    %rcx,-0x30(%rbp)
lea    -0x50(%rbp),%rsi
call   1040 <stat@plt>
test   %rax,%rax
je     11b0 <vps_is_mounted+0x80>
mov    0x2e42(%rip),%rax
mov    (%rax),%rsi
lea    0xe60(%rip),%rdx
mov    $0xffffffff,%r15d
mov    $0xffffffff,%edi
mov    %r12,%rcx
jmp    11f5 <vps_is_mounted+0xc5>
lea    0xe52(%rip),%rdx
mov    %rbx,%rdi
mov    %r13d,%esi
mov    %r12,%rcx
call   1030 <snprintf@plt>
lea    -0x40(%rbp),%rsi
mov    %rbx,%rdi
call   1040 <stat@plt>
test   %rax,%rax
je     1213 <vps_is_mounted+0xe3>
mov    0x2dfb(%rip),%rax
mov    (%rax),%rsi
lea    0xe19(%rip),%rdx
mov    $0xffffffff,%r15d
mov    $0xffffffff,%edi
mov    %rbx,%rcx
call   1050 <logger@plt>
mov    -0x30(%rbp),%rcx
mov    %rcx,%rsp
mov    %r15d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    -0x50(%rbp),%rax
mov    $0x1,%r15d
cmp    -0x40(%rbp),%rax
mov    -0x30(%rbp),%rcx
jne    11fe <vps_is_mounted+0xce>
lea    -0x40(%rbp),%rsi
mov    %r14,%rdi
call   1040 <stat@plt>
test   %rax,%rax
je     126c <vps_is_mounted+0x13c>
mov    0x2d99(%rip),%rax
mov    (%rax),%rsi
mov    0x2d7f(%rip),%rax
xor    %r15d,%r15d
cmp    (%rax),%rsi
mov    -0x30(%rbp),%rcx
je     11fe <vps_is_mounted+0xce>
lea    0xda4(%rip),%rdx
mov    $0xffffffff,%r15d
mov    $0xffffffff,%edi
mov    %r14,%rcx
jmp    11f5 <vps_is_mounted+0xc5>
mov    -0x50(%rbp),%rax
mov    -0x48(%rbp),%rcx
xor    -0x40(%rbp),%rax
xor    -0x38(%rbp),%rcx
xor    %r15d,%r15d
or     %rax,%rcx
sete   %r15b
jmp    11fa <vps_is_mounted+0xca>

LLVM IR (-O0):
%struct.stat = type { i64, i64 }
@PATH_MAX = global i32 0
@errno = global i64 0
@.str = [9 x i8] c"stat(%s)\00"
@.str.1 = [6 x i8] c"%s/..\00"
@ENOENT = global i64 0
define i32 @vps_is_mounted(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.stat
%7 = alloca %struct.stat
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%11 = load i32, i32* @PATH_MAX
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %8
%14 = alloca i8, i64 %12
store i64 %12, i64* %9
%15 = load i8*, i8** %4
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i8*, i8** %5
%19 = icmp ne i8* %18, null
br i1 %19, label %21, label %20
20: ; preds = %17, %2
store i32 -1, i32* %3
store i32 1, i32* %10
br label %73
21: ; preds = %17
%22 = load i8*, i8** %4
%23 = call i64 @stat(i8* %22, %struct.stat* %6)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load i64, i64* @errno
%27 = load i8*, i8** %4
%28 = call i32 @logger(i32 -1, i64 %26, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %27)
store i32 -1, i32* %3
store i32 1, i32* %10
br label %73
29: ; preds = %21
%30 = trunc i64 %12 to i32
%31 = load i8*, i8** %4
%32 = call i32 @snprintf(i8* %14, i32 %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %31)
%33 = call i64 @stat(i8* %14, %struct.stat* %7)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %29
%36 = load i64, i64* @errno
%37 = call i32 @logger(i32 -1, i64 %36, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 -1, i32* %3
store i32 1, i32* %10
br label %73
38: ; preds = %29
%39 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%40 = load i64, i64* %39
%41 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%42 = load i64, i64* %41
%43 = icmp ne i64 %40, %42
br i1 %43, label %44, label %45
44: ; preds = %38
store i32 1, i32* %3
store i32 1, i32* %10
br label %73
45: ; preds = %38
%46 = load i8*, i8** %5
%47 = call i64 @stat(i8* %46, %struct.stat* %7)
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %58
49: ; preds = %45
%50 = load i64, i64* @errno
%51 = load i64, i64* @ENOENT
%52 = icmp eq i64 %50, %51
br i1 %52, label %53, label %54
53: ; preds = %49
store i32 0, i32* %3
store i32 1, i32* %10
br label %73
54: ; preds = %49
%55 = load i64, i64* @errno
%56 = load i8*, i8** %5
%57 = call i32 @logger(i32 -1, i64 %55, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %56)
store i32 -1, i32* %3
store i32 1, i32* %10
br label %73
58: ; preds = %45
%59 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%60 = load i64, i64* %59
%61 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%62 = load i64, i64* %61
%63 = icmp eq i64 %60, %62
br i1 %63, label %64, label %70
64: ; preds = %58
%65 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 1
%66 = load i64, i64* %65
%67 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 1
%68 = load i64, i64* %67
%69 = icmp eq i64 %66, %68
br label %70
70: ; preds = %64, %58
%71 = phi i1 [ false, %58 ], [ %69, %64 ]
%72 = zext i1 %71 to i32
store i32 %72, i32* %3
store i32 1, i32* %10
br label %73
73: ; preds = %70, %54, %53, %44, %35, %25, %20
%74 = load i8*, i8** %8
%75 = load i32, i32* %3
ret i32 %75
}

LLVM IR (-O2):
%struct.stat = type { i64, i64 }
@PATH_MAX = global i32 0
@errno = global i64 0
@.str = [9 x i8] c"stat(%s)\00"
@.str.1 = [6 x i8] c"%s/..\00"
@ENOENT = global i64 0
define i32 @vps_is_mounted(i8* %0, i8* %1) {
%3 = alloca %struct.stat
%4 = alloca %struct.stat
%5 = bitcast %struct.stat* %3 to i8*
%6 = bitcast %struct.stat* %4 to i8*
%7 = load i32, i32* @PATH_MAX
%8 = zext i32 %7 to i64
%9 = tail call i8* @llvm.stacksave()
%10 = alloca i8, i64 %8
%11 = icmp ne i8* %0, null
%12 = icmp ne i8* %1, null
%13 = and i1 %11, %12
br i1 %13, label %14, label %53
14: ; preds = %2
%15 = call i64 @stat(i8* %0, %struct.stat* %3)
%16 = icmp eq i64 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i64, i64* @errno
%19 = call i32 @logger(i32 -1, i64 %18, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %53
20: ; preds = %14
%21 = call i32 @snprintf(i8* %10, i32 %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%22 = call i64 @stat(i8* %10, %struct.stat* %4)
%23 = icmp eq i64 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %20
%25 = load i64, i64* @errno
%26 = call i32 @logger(i32 -1, i64 %25, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %53
27: ; preds = %20
%28 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%29 = load i64, i64* %28
%30 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%31 = load i64, i64* %30
%32 = icmp eq i64 %29, %31
br i1 %32, label %33, label %53
33: ; preds = %27
%34 = call i64 @stat(i8* %1, %struct.stat* %4)
%35 = icmp eq i64 %34, 0
br i1 %35, label %42, label %36
36: ; preds = %33
%37 = load i64, i64* @errno
%38 = load i64, i64* @ENOENT
%39 = icmp eq i64 %37, %38
br i1 %39, label %53, label %40
40: ; preds = %36
%41 = call i32 @logger(i32 -1, i64 %37, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %53
42: ; preds = %33
%43 = load i64, i64* %28
%44 = load i64, i64* %30
%45 = icmp eq i64 %43, %44
%46 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%47 = load i64, i64* %46
%48 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 1
%49 = load i64, i64* %48
%50 = icmp eq i64 %47, %49
%51 = select i1 %45, i1 %50, i1 false
%52 = zext i1 %51 to i32
br label %53
53: ; preds = %36, %27, %2, %42, %40, %24, %17
%54 = phi i32 [ -1, %17 ], [ -1, %24 ], [ -1, %40 ], [ %52, %42 ], [ -1, %2 ], [ 1, %27 ], [ 0, %36 ]
ret i32 %54
}