#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 if_dqinfo {
  int dummy;
};
typedef int /*<<< orphan*/ caddr_t;

/* Variables and functions */
scalar_t__ ENOTSUP;
scalar_t__ ESRCH;
int /*<<< orphan*/ QCMD(int /*<<< orphan*/, int);
int /*<<< orphan*/ Q_GETINFO;
scalar_t__ errno;
scalar_t__ project_quota_on(char const *, char const *);
scalar_t__ quotactl(int /*<<< orphan*/, char const *, int /*<<< orphan*/,
                    int /*<<< orphan*/);
scalar_t__ strcmp(char const *, char *);
bool ext4_support_project(const char *device, const char *fstype,
                          const char *root_path) {
  struct if_dqinfo dqinfo;
  if (strcmp(fstype, "ext4")) {
    errno = ENOTSUP;
    return false;
  }
  if (quotactl(QCMD(Q_GETINFO, 2), device, 0, (caddr_t)&dqinfo) == 0)
    return true;
  if (errno != ESRCH)
    return false;
  return project_quota_on(device, root_path) == 0;
}


x86 assembly (clang, -O0):
<ext4_support_project>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     118e <ext4_support_project+0x4e>
mov    0x2e73(%rip),%rax
mov    (%rax),%rcx
mov    0x2e59(%rip),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    120c <ext4_support_project+0xcc>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
mov    $0x2,%esi
call   1060 <QCMD@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
lea    -0x28(%rbp),%rax
mov    %eax,%ecx
xor    %edx,%edx
call   1030 <quotactl@plt>
cmp    $0x0,%rax
jne    11ca <ext4_support_project+0x8a>
movl   $0x1,-0x4(%rbp)
jmp    120c <ext4_support_project+0xcc>
mov    0x2e07(%rip),%rax
mov    (%rax),%rax
mov    0x2de5(%rip),%rcx
cmp    (%rcx),%rax
je     11f0 <ext4_support_project+0xb0>
movl   $0x0,-0x4(%rbp)
jmp    120c <ext4_support_project+0xcc>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <project_quota_on@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ext4_support_project>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%rax
mov    %rdi,%rbx
lea    0xea8(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1186 <ext4_support_project+0x46>
mov    0x2e7c(%rip),%rax
mov    (%rax),%rax
mov    0x2e62(%rip),%rcx
mov    %rax,(%rcx)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
mov    $0x2,%esi
call   1060 <QCMD@plt>
lea    0x8(%rsp),%rcx
xor    %ebp,%ebp
mov    %eax,%edi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <quotactl@plt>
test   %rax,%rax
je     11dd <ext4_support_project+0x9d>
mov    0x2e20(%rip),%rax
mov    (%rax),%rax
mov    0x2dfe(%rip),%rcx
cmp    (%rcx),%rax
jne    117b <ext4_support_project+0x3b>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <project_quota_on@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
jmp    117b <ext4_support_project+0x3b>
mov    $0x1,%ebp
jmp    117b <ext4_support_project+0x3b>

LLVM IR (-O0):
%struct.if_dqinfo = type { i32 }
@.str = [5 x i8] c"ext4\00"
@ENOTSUP = global i64 0
@errno = global i64 0
@Q_GETINFO = global i32 0
@ESRCH = global i64 0
define i32 @ext4_support_project(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca %struct.if_dqinfo
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%9 = load i8*, i8** %6
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = load i64, i64* @ENOTSUP
store i64 %13, i64* @errno
store i32 0, i32* %4
br label %33
14: ; preds = %3
%15 = load i32, i32* @Q_GETINFO
%16 = call i32 @QCMD(i32 %15, i32 2)
%17 = load i8*, i8** %5
%18 = ptrtoint %struct.if_dqinfo* %8 to i32
%19 = call i64 @quotactl(i32 %16, i8* %17, i32 0, i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %14
store i32 1, i32* %4
br label %33
22: ; preds = %14
%23 = load i64, i64* @errno
%24 = load i64, i64* @ESRCH
%25 = icmp ne i64 %23, %24
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 0, i32* %4
br label %33
27: ; preds = %22
%28 = load i8*, i8** %5
%29 = load i8*, i8** %7
%30 = call i64 @project_quota_on(i8* %28, i8* %29)
%31 = icmp eq i64 %30, 0
%32 = zext i1 %31 to i32
store i32 %32, i32* %4
br label %33
33: ; preds = %27, %26, %21, %12
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
%struct.if_dqinfo = type { i32 }
@.str = [5 x i8] c"ext4\00"
@ENOTSUP = global i64 0
@errno = global i64 0
@Q_GETINFO = global i32 0
@ESRCH = global i64 0
define i32 @ext4_support_project(i8* %0, i8* %1, i8* %2) {
%4 = alloca %struct.if_dqinfo
%5 = bitcast %struct.if_dqinfo* %4 to i8*
%6 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %3
%9 = load i64, i64* @ENOTSUP
store i64 %9, i64* @errno
br label %25
10: ; preds = %3
%11 = load i32, i32* @Q_GETINFO
%12 = tail call i32 @QCMD(i32 %11, i32 2)
%13 = ptrtoint %struct.if_dqinfo* %4 to i64
%14 = trunc i64 %13 to i32
%15 = call i64 @quotactl(i32 %12, i8* %0, i32 0, i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %25, label %17
17: ; preds = %10
%18 = load i64, i64* @errno
%19 = load i64, i64* @ESRCH
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = call i64 @project_quota_on(i8* %0, i8* %2)
%23 = icmp eq i64 %22, 0
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %17, %10, %21, %8
%26 = phi i32 [ 0, %8 ], [ %24, %21 ], [ 1, %10 ], [ 0, %17 ]
ret i32 %26
}