#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;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
scalar_t__ AUFS_SUPER_MAGIC;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
long do_fpathconf(int, int);
int errno;
int /*<<< orphan*/ libau_dl_pathconf();
int open_aufs_fd(char const *, int /*<<< orphan*/ **);
long real_pathconf(char const *, int);
long statfs(char const *, struct statfs *);
long libau_pathconf(const char *path, int name) {
  long err;
  struct statfs stfs;
  int fd, e;
  DIR *dp;
  err = statfs(path, &stfs);
  if (err)
    goto out;
  err = -1;
  if (stfs.f_type == AUFS_SUPER_MAGIC) {
    fd = open_aufs_fd(path, &dp);
    if (fd >= 0) {
      err = do_fpathconf(fd, name);
      e = errno;
      if (!dp)
        close(fd);
      else
        closedir(dp);
      errno = e;
    }
  } else if (!libau_dl_pathconf())
    err = real_pathconf(path, name);
out:
  return err;
}


x86 assembly (clang, -O0):
<libau_pathconf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1080 <statfs@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11a0 <libau_pathconf+0x30>
jmp    124d <libau_pathconf+0xdd>
movq   $0xffffffffffffffff,-0x18(%rbp)
ff
mov    -0x20(%rbp),%rax
mov    0x2e45(%rip),%rcx
cmp    (%rcx),%rax
jne    1223 <libau_pathconf+0xb3>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <open_aufs_fd@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     121e <libau_pathconf+0xae>
mov    -0x24(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1090 <do_fpathconf@plt>
mov    %rax,-0x18(%rbp)
mov    0x2dec(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1209 <libau_pathconf+0x99>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
jmp    1212 <libau_pathconf+0xa2>
mov    -0x30(%rbp),%rdi
call   1070 <closedir@plt>
mov    -0x28(%rbp),%ecx
mov    0x2dbc(%rip),%rax
mov    %ecx,(%rax)
jmp    1248 <libau_pathconf+0xd8>
mov    $0x0,%al
call   1050 <libau_dl_pathconf@plt>
cmp    $0x0,%eax
jne    1243 <libau_pathconf+0xd3>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <real_pathconf@plt>
mov    %rax,-0x18(%rbp)
jmp    1248 <libau_pathconf+0xd8>
jmp    124d <libau_pathconf+0xdd>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<libau_pathconf>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r14d
mov    %rdi,%rbp
lea    0x10(%rsp),%rsi
call   1080 <statfs@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11a0 <libau_pathconf+0x30>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x10(%rsp),%rax
mov    0x2e4c(%rip),%rcx
cmp    (%rcx),%rax
jne    11ef <libau_pathconf+0x7f>
lea    0x8(%rsp),%rsi
mov    %rbp,%rdi
call   1040 <open_aufs_fd@plt>
test   %eax,%eax
js     1211 <libau_pathconf+0xa1>
mov    %eax,%ebp
mov    %eax,%edi
mov    %r14d,%esi
call   1090 <do_fpathconf@plt>
mov    %rax,%rbx
mov    0x2e00(%rip),%r14
mov    (%r14),%r15d
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     121d <libau_pathconf+0xad>
call   1070 <closedir@plt>
mov    %r15d,(%r14)
jmp    1192 <libau_pathconf+0x22>
xor    %eax,%eax
call   1050 <libau_dl_pathconf@plt>
mov    $0xffffffffffffffff,%rbx
test   %eax,%eax
jne    1192 <libau_pathconf+0x22>
mov    %rbp,%rdi
mov    %r14d,%esi
call   1030 <real_pathconf@plt>
mov    %rax,%rbx
jmp    1192 <libau_pathconf+0x22>
mov    $0xffffffffffffffff,%rbx
jmp    1192 <libau_pathconf+0x22>
mov    %ebp,%edi
call   1060 <close@plt>
mov    %r15d,(%r14)
jmp    1192 <libau_pathconf+0x22>

LLVM IR (-O0):
%struct.statfs = type { i64 }
@AUFS_SUPER_MAGIC = global i64 0
@errno = global i32 0
define i64 @libau_pathconf(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i64
%6 = alloca %struct.statfs
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store i8* %0, i8** %3
store i32 %1, i32* %4
%10 = load i8*, i8** %3
%11 = call i64 @statfs(i8* %10, %struct.statfs* %6)
store i64 %11, i64* %5
%12 = load i64, i64* %5
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %2
br label %50
15: ; preds = %2
store i64 -1, i64* %5
%16 = getelementptr inbounds %struct.statfs, %struct.statfs* %6, i32 0, i32 0
%17 = load i64, i64* %16
%18 = load i64, i64* @AUFS_SUPER_MAGIC
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %41
20: ; preds = %15
%21 = load i8*, i8** %3
%22 = call i32 @open_aufs_fd(i8* %21, i32** %9)
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = icmp sge i32 %23, 0
br i1 %24, label %25, label %40
25: ; preds = %20
%26 = load i32, i32* %7
%27 = load i32, i32* %4
%28 = call i64 @do_fpathconf(i32 %26, i32 %27)
store i64 %28, i64* %5
%29 = load i32, i32* @errno
store i32 %29, i32* %8
%30 = load i32*, i32** %9
%31 = icmp ne i32* %30, null
br i1 %31, label %35, label %32
32: ; preds = %25
%33 = load i32, i32* %7
%34 = call i32 @close(i32 %33)
br label %38
35: ; preds = %25
%36 = load i32*, i32** %9
%37 = call i32 @closedir(i32* %36)
br label %38
38: ; preds = %35, %32
%39 = load i32, i32* %8
store i32 %39, i32* @errno
br label %40
40: ; preds = %38, %20
br label %49
41: ; preds = %15
%42 = call i32 (...) @libau_dl_pathconf()
%43 = icmp ne i32 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %41
%45 = load i8*, i8** %3
%46 = load i32, i32* %4
%47 = call i64 @real_pathconf(i8* %45, i32 %46)
store i64 %47, i64* %5
br label %48
48: ; preds = %44, %41
br label %49
49: ; preds = %48, %40
br label %50
50: ; preds = %49, %14
%51 = load i64, i64* %5
ret i64 %51
}

LLVM IR (-O2):
%struct.statfs = type { i64 }
@AUFS_SUPER_MAGIC = global i64 0
@errno = global i32 0
define i64 @libau_pathconf(i8* %0, i32 %1) {
%3 = alloca %struct.statfs
%4 = alloca i32*
%5 = bitcast %struct.statfs* %3 to i8*
%6 = bitcast i32** %4 to i8*
%7 = call i64 @statfs(i8* %0, %struct.statfs* %3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %32
9: ; preds = %2
%10 = getelementptr inbounds %struct.statfs, %struct.statfs* %3, i64 0, i32 0
%11 = load i64, i64* %10
%12 = load i64, i64* @AUFS_SUPER_MAGIC
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %27
14: ; preds = %9
%15 = call i32 @open_aufs_fd(i8* %0, i32** %4)
%16 = icmp sgt i32 %15, -1
br i1 %16, label %17, label %32
17: ; preds = %14
%18 = call i64 @do_fpathconf(i32 %15, i32 %1)
%19 = load i32, i32* @errno
%20 = load i32*, i32** %4
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = call i32 @close(i32 %15)
br label %26
24: ; preds = %17
%25 = call i32 @closedir(i32* %20)
br label %26
26: ; preds = %24, %22
store i32 %19, i32* @errno
br label %32
27: ; preds = %9
%28 = call i32 (...) @libau_dl_pathconf()
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i64 @real_pathconf(i8* %0, i32 %1)
br label %32
32: ; preds = %26, %14, %30, %27, %2
%33 = phi i64 [ %7, %2 ], [ %18, %26 ], [ -1, %14 ], [ -1, %27 ], [ %31, %30 ]
ret i64 %33
}