#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 */

/* Variables and functions */
int /*<<< orphan*/ AUFS_CTL_WBR_FD;
int /*<<< orphan*/ close(int);
int errno;
int ioctl(int, int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ libau_dl_fpathconf();
long real_fpathconf(int, int);
long do_fpathconf(int fd, int name) {
  long err;
  int wbr_fd, e;
  err = -1;
  wbr_fd = ioctl(fd, AUFS_CTL_WBR_FD, NULL);
  if (wbr_fd >= 0) {
    if (!libau_dl_fpathconf())
      err = real_fpathconf(wbr_fd, name);
    e = errno;
    close(wbr_fd);
    errno = e;
  }
  return err;
}


x86 assembly (clang, -O0):
<do_fpathconf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movq   $0xffffffffffffffff,-0x10(%rbp)
ff
mov    -0x4(%rbp),%edi
mov    0x2e78(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <ioctl@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11b7 <do_fpathconf+0x77>
mov    $0x0,%al
call   1030 <libau_dl_fpathconf@plt>
cmp    $0x0,%eax
jne    1197 <do_fpathconf+0x57>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <real_fpathconf@plt>
mov    %rax,-0x10(%rbp)
mov    0x2e42(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
mov    -0x18(%rbp),%ecx
mov    0x2e2b(%rip),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_fpathconf>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    0x2e87(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1050 <ioctl@plt>
test   %eax,%eax
js     1195 <do_fpathconf+0x55>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <libau_dl_fpathconf@plt>
mov    $0xffffffffffffffff,%rbx
test   %eax,%eax
jne    117f <do_fpathconf+0x3f>
mov    %ebp,%edi
mov    %r14d,%esi
call   1040 <real_fpathconf@plt>
mov    %rax,%rbx
mov    0x2e5a(%rip),%r14
mov    (%r14),%r15d
mov    %ebp,%edi
call   1060 <close@plt>
mov    %r15d,(%r14)
jmp    119c <do_fpathconf+0x5c>
mov    $0xffffffffffffffff,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@AUFS_CTL_WBR_FD = global i32 0
@errno = global i32 0
define i64 @do_fpathconf(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i64 -1, i64* %5
%8 = load i32, i32* %3
%9 = load i32, i32* @AUFS_CTL_WBR_FD
%10 = call i32 @ioctl(i32 %8, i32 %9, i32* null)
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = icmp sge i32 %11, 0
br i1 %12, label %13, label %25
13: ; preds = %2
%14 = call i32 (...) @libau_dl_fpathconf()
%15 = icmp ne i32 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %13
%17 = load i32, i32* %6
%18 = load i32, i32* %4
%19 = call i64 @real_fpathconf(i32 %17, i32 %18)
store i64 %19, i64* %5
br label %20
20: ; preds = %16, %13
%21 = load i32, i32* @errno
store i32 %21, i32* %7
%22 = load i32, i32* %6
%23 = call i32 @close(i32 %22)
%24 = load i32, i32* %7
store i32 %24, i32* @errno
br label %25
25: ; preds = %20, %2
%26 = load i64, i64* %5
ret i64 %26
}

LLVM IR (-O2):
@AUFS_CTL_WBR_FD = global i32 0
@errno = global i32 0
define i64 @do_fpathconf(i32 %0, i32 %1) {
%3 = load i32, i32* @AUFS_CTL_WBR_FD
%4 = tail call i32 @ioctl(i32 %0, i32 %3, i32* null)
%5 = icmp sgt i32 %4, -1
br i1 %5, label %6, label %15
6: ; preds = %2
%7 = tail call i32 (...) @libau_dl_fpathconf()
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i64 @real_fpathconf(i32 %4, i32 %1)
br label %11
11: ; preds = %9, %6
%12 = phi i64 [ -1, %6 ], [ %10, %9 ]
%13 = load i32, i32* @errno
%14 = tail call i32 @close(i32 %4)
store i32 %13, i32* @errno
br label %15
15: ; preds = %11, %2
%16 = phi i64 [ %12, %11 ], [ -1, %2 ]
ret i64 %16
}