#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 mntent {
  int /*<<< orphan*/ mnt_dir;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ endmntent(int /*<<< orphan*/ *);
struct mntent *getmntent(int /*<<< orphan*/ *);
int /*<<< orphan*/ *setmntent(char *, char *);
scalar_t__ strcmp(int /*<<< orphan*/, char const *);
int path_is_mount_point(const char *path) {
  FILE *f;
  struct mntent *mnt;
  int ret = 0;
  f = setmntent("/proc/self/mounts", "r");
  if (f == NULL)
    return -1;
  while ((mnt = getmntent(f)) != NULL) {
    if (strcmp(mnt->mnt_dir, path))
      continue;
    ret = 1;
    break;
  }
  endmntent(f);
  return ret;
}


x86 assembly (clang, -O0):
<path_is_mount_point>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xea6(%rip),%rdi
lea    0xeb1(%rip),%rsi
call   1060 <setmntent@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1181 <path_is_mount_point+0x41>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d1 <path_is_mount_point+0x91>
jmp    1186 <path_is_mount_point+0x46>
mov    -0x18(%rbp),%rdi
call   1050 <getmntent@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11c2 <path_is_mount_point+0x82>
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11bb <path_is_mount_point+0x7b>
jmp    1186 <path_is_mount_point+0x46>
movl   $0x1,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <endmntent@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<path_is_mount_point>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xeb2(%rip),%rdi
lea    0xebd(%rip),%rsi
call   1060 <setmntent@plt>
test   %rax,%rax
je     1193 <path_is_mount_point+0x53>
mov    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1050 <getmntent@plt>
test   %rax,%rax
je     119a <path_is_mount_point+0x5a>
mov    (%rax),%edi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1170 <path_is_mount_point+0x30>
mov    $0x1,%ebp
jmp    119c <path_is_mount_point+0x5c>
mov    $0xffffffff,%ebp
jmp    11a4 <path_is_mount_point+0x64>
xor    %ebp,%ebp
mov    %rbx,%rdi
call   1030 <endmntent@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.mntent = type { i32 }
@.str = [18 x i8] c"/proc/self/mounts\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @path_is_mount_point(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca %struct.mntent*
%6 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %6
%7 = call i32* @setmntent(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %4
%8 = load i32*, i32** %4
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 -1, i32* %2
br label %29
11: ; preds = %1
br label %12
12: ; preds = %23, %11
%13 = load i32*, i32** %4
%14 = call %struct.mntent* @getmntent(i32* %13)
store %struct.mntent* %14, %struct.mntent** %5
%15 = icmp ne %struct.mntent* %14, null
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = load %struct.mntent*, %struct.mntent** %5
%18 = getelementptr inbounds %struct.mntent, %struct.mntent* %17, i32 0, i32 0
%19 = load i32, i32* %18
%20 = load i8*, i8** %3
%21 = call i64 @strcmp(i32 %19, i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %16
br label %12
24: ; preds = %16
store i32 1, i32* %6
br label %25
25: ; preds = %24, %12
%26 = load i32*, i32** %4
%27 = call i32 @endmntent(i32* %26)
%28 = load i32, i32* %6
store i32 %28, i32* %2
br label %29
29: ; preds = %25, %10
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
%struct.mntent = type { i32 }
@.str = [18 x i8] c"/proc/self/mounts\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @path_is_mount_point(i8* %0) {
%2 = tail call i32* @setmntent(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %15, label %4
4: ; preds = %1, %7
%5 = tail call %struct.mntent* @getmntent(i32* %2)
%6 = icmp eq %struct.mntent* %5, null
br i1 %6, label %12, label %7
7: ; preds = %4
%8 = getelementptr inbounds %struct.mntent, %struct.mntent* %5, i64 0, i32 0
%9 = load i32, i32* %8
%10 = tail call i64 @strcmp(i32 %9, i8* %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %4
12: ; preds = %7, %4
%13 = phi i32 [ 0, %4 ], [ 1, %7 ]
%14 = tail call i32 @endmntent(i32* %2)
br label %15
15: ; preds = %1, %12
%16 = phi i32 [ %13, %12 ], [ -1, %1 ]
ret i32 %16
}