#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 */
scalar_t__ AUFS_SUPER_MAGIC;
long do_fpathconf(int, int);
long fstatfs(int, struct statfs *);
int /*<<< orphan*/ libau_dl_fpathconf();
long real_fpathconf(int, int);
long libau_fpathconf(int fd, int name) {
  long err;
  struct statfs stfs;
  err = fstatfs(fd, &stfs);
  if (err)
    goto out;
  err = -1;
  if (stfs.f_type == AUFS_SUPER_MAGIC)
    err = do_fpathconf(fd, name);
  else if (!libau_dl_fpathconf())
    err = real_fpathconf(fd, name);
out:
  return err;
}


x86 assembly (clang, -O0):
<libau_fpathconf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   1060 <fstatfs@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     116e <libau_fpathconf+0x2e>
jmp    11c7 <libau_fpathconf+0x87>
movq   $0xffffffffffffffff,-0x10(%rbp)
ff
mov    -0x18(%rbp),%rax
mov    0x2e77(%rip),%rcx
cmp    (%rcx),%rax
jne    119e <libau_fpathconf+0x5e>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <do_fpathconf@plt>
mov    %rax,-0x10(%rbp)
jmp    11c2 <libau_fpathconf+0x82>
mov    $0x0,%al
call   1030 <libau_dl_fpathconf@plt>
cmp    $0x0,%eax
jne    11bd <libau_fpathconf+0x7d>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <real_fpathconf@plt>
mov    %rax,-0x10(%rbp)
jmp    11c2 <libau_fpathconf+0x82>
jmp    11c7 <libau_fpathconf+0x87>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<libau_fpathconf>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
mov    %rsp,%rsi
call   1060 <fstatfs@plt>
test   %rax,%rax
jne    118c <libau_fpathconf+0x4c>
mov    (%rsp),%rax
mov    0x2e99(%rip),%rcx
cmp    (%rcx),%rax
jne    116f <libau_fpathconf+0x2f>
mov    %ebp,%edi
mov    %ebx,%esi
call   1050 <do_fpathconf@plt>
jmp    118c <libau_fpathconf+0x4c>
xor    %eax,%eax
call   1030 <libau_dl_fpathconf@plt>
mov    %eax,%ecx
mov    $0xffffffffffffffff,%rax
test   %ecx,%ecx
jne    118c <libau_fpathconf+0x4c>
mov    %ebp,%edi
mov    %ebx,%esi
call   1040 <real_fpathconf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.statfs = type { i64 }
@AUFS_SUPER_MAGIC = global i64 0
define i64 @libau_fpathconf(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca %struct.statfs
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = call i64 @fstatfs(i32 %7, %struct.statfs* %6)
store i64 %8, i64* %5
%9 = load i64, i64* %5
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
br label %30
12: ; preds = %2
store i64 -1, i64* %5
%13 = getelementptr inbounds %struct.statfs, %struct.statfs* %6, i32 0, i32 0
%14 = load i64, i64* %13
%15 = load i64, i64* @AUFS_SUPER_MAGIC
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = call i64 @do_fpathconf(i32 %18, i32 %19)
store i64 %20, i64* %5
br label %29
21: ; preds = %12
%22 = call i32 (...) @libau_dl_fpathconf()
%23 = icmp ne i32 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %21
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = call i64 @real_fpathconf(i32 %25, i32 %26)
store i64 %27, i64* %5
br label %28
28: ; preds = %24, %21
br label %29
29: ; preds = %28, %17
br label %30
30: ; preds = %29, %11
%31 = load i64, i64* %5
ret i64 %31
}

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