#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 _PC_LINK_MAX;
int /*<<< orphan*/ libau_dl_fpathconf();
long libau_fpathconf(int, int);
scalar_t__ libau_test_func(char *);
long real_fpathconf(int, int);
long fpathconf(int fd, int name) {
  long ret;
  ret = -1;
  if (name == _PC_LINK_MAX &&
      (libau_test_func("pathconf") || libau_test_func("fpathconf")))
    ret = libau_fpathconf(fd, name);
  else if (!libau_dl_fpathconf())
    ret = real_fpathconf(fd, name);
  return ret;
}


x86 assembly (clang, -O0):
<fpathconf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movq   $0xffffffffffffffff,-0x10(%rbp)
ff
mov    -0x8(%rbp),%eax
mov    0x2e78(%rip),%rcx
cmp    (%rcx),%eax
jne    11a8 <fpathconf+0x68>
lea    0xe92(%rip),%rdi
call   1060 <libau_test_func@plt>
cmp    $0x0,%rax
jne    1194 <fpathconf+0x54>
lea    0xe7b(%rip),%rdi
call   1060 <libau_test_func@plt>
cmp    $0x0,%rax
je     11a8 <fpathconf+0x68>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <libau_fpathconf@plt>
mov    %rax,-0x10(%rbp)
jmp    11cc <fpathconf+0x8c>
mov    $0x0,%al
call   1030 <libau_dl_fpathconf@plt>
cmp    $0x0,%eax
jne    11c7 <fpathconf+0x87>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <real_fpathconf@plt>
mov    %rax,-0x10(%rbp)
jmp    11cc <fpathconf+0x8c>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fpathconf>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
mov    0x2e8a(%rip),%rax
cmp    %esi,(%rax)
jne    1183 <fpathconf+0x43>
lea    0xea8(%rip),%rdi
call   1060 <libau_test_func@plt>
test   %rax,%rax
jne    1174 <fpathconf+0x34>
lea    0xe96(%rip),%rdi
call   1060 <libau_test_func@plt>
test   %rax,%rax
je     1183 <fpathconf+0x43>
mov    %ebp,%edi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <libau_fpathconf@plt>
xor    %eax,%eax
call   1030 <libau_dl_fpathconf@plt>
test   %eax,%eax
je     119c <fpathconf+0x5c>
mov    $0xffffffffffffffff,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %ebp,%edi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <real_fpathconf@plt>

LLVM IR (-O0):
@_PC_LINK_MAX = global i32 0
@.str = [9 x i8] c"pathconf\00"
@.str.1 = [10 x i8] c"fpathconf\00"
define i64 @fpathconf(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
store i32 %0, i32* %3
store i32 %1, i32* %4
store i64 -1, i64* %5
%6 = load i32, i32* %4
%7 = load i32, i32* @_PC_LINK_MAX
%8 = icmp eq i32 %6, %7
br i1 %8, label %9, label %19
9: ; preds = %2
%10 = call i64 @libau_test_func(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%11 = icmp ne i64 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = call i64 @libau_test_func(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %12, %9
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = call i64 @libau_fpathconf(i32 %16, i32 %17)
store i64 %18, i64* %5
br label %27
19: ; preds = %12, %2
%20 = call i32 (...) @libau_dl_fpathconf()
%21 = icmp ne i32 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = call i64 @real_fpathconf(i32 %23, i32 %24)
store i64 %25, i64* %5
br label %26
26: ; preds = %22, %19
br label %27
27: ; preds = %26, %15
%28 = load i64, i64* %5
ret i64 %28
}

LLVM IR (-O2):
@_PC_LINK_MAX = global i32 0
@.str = [9 x i8] c"pathconf\00"
@.str.1 = [10 x i8] c"fpathconf\00"
define i64 @fpathconf(i32 %0, i32 %1) {
%3 = load i32, i32* @_PC_LINK_MAX
%4 = icmp eq i32 %3, %1
br i1 %4, label %5, label %13
5: ; preds = %2
%6 = tail call i64 @libau_test_func(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = tail call i64 @libau_test_func(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8, %5
%12 = tail call i64 @libau_fpathconf(i32 %0, i32 %1)
br label %18
13: ; preds = %8, %2
%14 = tail call i32 (...) @libau_dl_fpathconf()
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i64 @real_fpathconf(i32 %0, i32 %1)
br label %18
18: ; preds = %13, %16, %11
%19 = phi i64 [ %12, %11 ], [ -1, %13 ], [ %17, %16 ]
ret i64 %19
}