#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 statfs {
  scalar_t__ f_type;
};

/* Variables and functions */
int ENOENT;
scalar_t__ statfs(char const *, struct statfs *);
int valid_mountpoint(const char *mount, long magic) {
  struct statfs st_fs;
  if (statfs(mount, &st_fs) < 0)
    return -ENOENT;
  else if ((long)st_fs.f_type != magic)
    return -ENOENT;
  return 0;
}


x86 assembly (clang, -O0):
<valid_mountpoint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <statfs@plt>
cmp    $0x0,%rax
jge    114a <valid_mountpoint+0x3a>
xor    %eax,%eax
mov    0x2e98(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1177 <valid_mountpoint+0x67>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
je     116b <valid_mountpoint+0x5b>
xor    %eax,%eax
mov    0x2e77(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1177 <valid_mountpoint+0x67>
jmp    1170 <valid_mountpoint+0x60>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valid_mountpoint>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
lea    0x8(%rsp),%rsi
call   1030 <statfs@plt>
test   %rax,%rax
js     1130 <valid_mountpoint+0x20>
xor    %eax,%eax
cmp    %rbx,0x8(%rsp)
je     113b <valid_mountpoint+0x2b>
mov    0x2ea1(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.statfs = type { i64 }
@ENOENT = global i32 0
define i32 @valid_mountpoint(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca %struct.statfs
store i8* %0, i8** %4
store i64 %1, i64* %5
%7 = load i8*, i8** %4
%8 = call i64 @statfs(i8* %7, %struct.statfs* %6)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @ENOENT
%12 = sub nsw i32 0, %11
store i32 %12, i32* %3
br label %23
13: ; preds = %2
%14 = getelementptr inbounds %struct.statfs, %struct.statfs* %6, i32 0, i32 0
%15 = load i64, i64* %14
%16 = load i64, i64* %5
%17 = icmp ne i64 %15, %16
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i32, i32* @ENOENT
%20 = sub nsw i32 0, %19
store i32 %20, i32* %3
br label %23
21: ; preds = %13
br label %22
22: ; preds = %21
store i32 0, i32* %3
br label %23
23: ; preds = %22, %18, %10
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
%struct.statfs = type { i64 }
@ENOENT = global i32 0
define i32 @valid_mountpoint(i8* %0, i64 %1) {
%3 = alloca %struct.statfs
%4 = bitcast %struct.statfs* %3 to i8*
%5 = call i64 @statfs(i8* %0, %struct.statfs* %3)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i32, i32* @ENOENT
%9 = sub nsw i32 0, %8
br label %17
10: ; preds = %2
%11 = getelementptr inbounds %struct.statfs, %struct.statfs* %3, i64 0, i32 0
%12 = load i64, i64* %11
%13 = icmp eq i64 %12, %1
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = load i32, i32* @ENOENT
%16 = sub nsw i32 0, %15
br label %17
17: ; preds = %10, %14, %7
%18 = phi i32 [ %9, %7 ], [ %16, %14 ], [ 0, %10 ]
ret i32 %18
}