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

/* Variables and functions */
int /*<<< orphan*/ free(char *);
scalar_t__ lstat(char *, struct stat *);
int /*<<< orphan*/ strcat(int /*<<< orphan*/, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *xmalloc(scalar_t__);
int is_mountpoint(char *path) {
  char *dotdot;
  struct stat stb, pstb;
  int rv;
  dotdot = xmalloc(strlen(path) + 4);
  strcat(strcpy(dotdot, path), "/..");
  if (lstat(path, &stb) != 0 || lstat(dotdot, &pstb) != 0)
    rv = 0;
  else if (stb.st_dev != pstb.st_dev || stb.st_ino == pstb.st_ino)
    rv = 1;
  else
    rv = 0;
  free(dotdot);
  return rv;
}


x86 assembly (clang, -O0):
<is_mountpoint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rdi
add    $0x4,%rdi
call   1060 <xmalloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    %eax,%edi
lea    0xe65(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1070 <lstat@plt>
cmp    $0x0,%rax
jne    11ce <is_mountpoint+0x6e>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1070 <lstat@plt>
cmp    $0x0,%rax
je     11da <is_mountpoint+0x7a>
movl   $0x0,-0x34(%rbp)
jmp    120e <is_mountpoint+0xae>
mov    -0x20(%rbp),%rax
cmp    -0x30(%rbp),%rax
jne    11f6 <is_mountpoint+0x96>
mov    -0x18(%rbp),%rax
cmp    -0x28(%rbp),%rax
jne    1202 <is_mountpoint+0xa2>
movl   $0x1,-0x34(%rbp)
jmp    1209 <is_mountpoint+0xa9>
movl   $0x0,-0x34(%rbp)
jmp    120e <is_mountpoint+0xae>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_mountpoint>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbp
call   1050 <strlen@plt>
lea    0x4(%rax),%rdi
call   1060 <xmalloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
call   1040 <strcpy@plt>
lea    0xe74(%rip),%rsi
mov    %eax,%edi
call   1080 <strcat@plt>
lea    0x18(%rsp),%rsi
mov    %rbp,%rdi
call   1070 <lstat@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    11da <is_mountpoint+0x7a>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <lstat@plt>
test   %rax,%rax
jne    11da <is_mountpoint+0x7a>
mov    0x18(%rsp),%rax
mov    $0x1,%ebp
cmp    0x8(%rsp),%rax
jne    11da <is_mountpoint+0x7a>
mov    0x20(%rsp),%rax
xor    %ebp,%ebp
cmp    0x10(%rsp),%rax
sete   %bpl
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i64, i64 }
@.str = [4 x i8] c"/..\00"
define i32 @is_mountpoint(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca %struct.stat
%5 = alloca %struct.stat
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i64 @strlen(i8* %7)
%9 = add nsw i64 %8, 4
%10 = call i8* @xmalloc(i64 %9)
store i8* %10, i8** %3
%11 = load i8*, i8** %3
%12 = load i8*, i8** %2
%13 = call i32 @strcpy(i8* %11, i8* %12)
%14 = call i32 @strcat(i32 %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%15 = load i8*, i8** %2
%16 = call i64 @lstat(i8* %15, %struct.stat* %4)
%17 = icmp ne i64 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %1
%19 = load i8*, i8** %3
%20 = call i64 @lstat(i8* %19, %struct.stat* %5)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18, %1
store i32 0, i32* %6
br label %38
23: ; preds = %18
%24 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 0
%25 = load i64, i64* %24
%26 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%27 = load i64, i64* %26
%28 = icmp ne i64 %25, %27
br i1 %28, label %35, label %29
29: ; preds = %23
%30 = getelementptr inbounds %struct.stat, %struct.stat* %4, i32 0, i32 1
%31 = load i64, i64* %30
%32 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 1
%33 = load i64, i64* %32
%34 = icmp eq i64 %31, %33
br i1 %34, label %35, label %36
35: ; preds = %29, %23
store i32 1, i32* %6
br label %37
36: ; preds = %29
store i32 0, i32* %6
br label %37
37: ; preds = %36, %35
br label %38
38: ; preds = %37, %22
%39 = load i8*, i8** %3
%40 = call i32 @free(i8* %39)
%41 = load i32, i32* %6
ret i32 %41
}

LLVM IR (-O2):
%struct.stat = type { i64, i64 }
@.str = [4 x i8] c"/..\00"
define i32 @is_mountpoint(i8* %0) {
%2 = alloca %struct.stat
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %2 to i8*
%5 = bitcast %struct.stat* %3 to i8*
%6 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%7 = add nsw i64 %6, 4
%8 = tail call i8* @xmalloc(i64 %7)
%9 = tail call i32 @strcpy(i8* %8, i8* %0)
%10 = tail call i32 @strcat(i32 %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%11 = call i64 @lstat(i8* %0, %struct.stat* %2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %29
13: ; preds = %1
%14 = call i64 @lstat(i8* %8, %struct.stat* %3)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %29
16: ; preds = %13
%17 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%18 = load i64, i64* %17
%19 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%20 = load i64, i64* %19
%21 = icmp eq i64 %18, %20
br i1 %21, label %22, label %29
22: ; preds = %16
%23 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 1
%24 = load i64, i64* %23
%25 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%26 = load i64, i64* %25
%27 = icmp eq i64 %24, %26
%28 = zext i1 %27 to i32
br label %29
29: ; preds = %22, %16, %1, %13
%30 = phi i32 [ 0, %13 ], [ 0, %1 ], [ 1, %16 ], [ %28, %22 ]
%31 = tail call i32 @free(i8* %8)
ret i32 %30
}