#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 debugfs_valid_mountpoint(const char *debugfs) {
  struct statfs st_fs;
  if (statfs(debugfs, &st_fs) < 0)
    return -ENOENT;
  else if ((long)st_fs.f_type != (long)0x64626720)
    return -ENOENT;
  return 0;
}


x86 assembly (clang, -O0):
<debugfs_valid_mountpoint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <statfs@plt>
cmp    $0x0,%rax
jge    1146 <debugfs_valid_mountpoint+0x36>
xor    %eax,%eax
mov    0x2e9c(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1173 <debugfs_valid_mountpoint+0x63>
cmpq   $0x64626720,-0x18(%rbp)
64
je     1167 <debugfs_valid_mountpoint+0x57>
xor    %eax,%eax
mov    0x2e7b(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1173 <debugfs_valid_mountpoint+0x63>
jmp    116c <debugfs_valid_mountpoint+0x5c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debugfs_valid_mountpoint>:
push   %rax
mov    %rsp,%rsi
call   1030 <statfs@plt>
test   %rax,%rax
js     112a <debugfs_valid_mountpoint+0x1a>
xor    %eax,%eax
cmpq   $0x64626720,(%rsp)
64
je     1135 <debugfs_valid_mountpoint+0x25>
mov    0x2ea7(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
pop    %rcx
ret

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

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