#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_pathconf();
long libau_pathconf(char const *, int);
scalar_t__ libau_test_func(char *);
long real_pathconf(char const *, int);
long pathconf(const char *path, int name) {
  long ret;
  ret = -1;
  if (name == _PC_LINK_MAX &&
      (libau_test_func("pathconf") || libau_test_func("fpathconf")))
    ret = libau_pathconf(path, name);
  else if (!libau_dl_pathconf())
    ret = real_pathconf(path, name);
  return ret;
}


x86 assembly (clang, -O0):
<pathconf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0xffffffffffffffff,-0x18(%rbp)
ff
mov    -0xc(%rbp),%eax
mov    0x2e77(%rip),%rcx
cmp    (%rcx),%eax
jne    11aa <pathconf+0x6a>
lea    0xe91(%rip),%rdi
call   1050 <libau_test_func@plt>
cmp    $0x0,%rax
jne    1195 <pathconf+0x55>
lea    0xe7a(%rip),%rdi
call   1050 <libau_test_func@plt>
cmp    $0x0,%rax
je     11aa <pathconf+0x6a>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1060 <libau_pathconf@plt>
mov    %rax,-0x18(%rbp)
jmp    11cf <pathconf+0x8f>
mov    $0x0,%al
call   1040 <libau_dl_pathconf@plt>
cmp    $0x0,%eax
jne    11ca <pathconf+0x8a>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <real_pathconf@plt>
mov    %rax,-0x18(%rbp)
jmp    11cf <pathconf+0x8f>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pathconf>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%r14
mov    0x2e88(%rip),%rax
cmp    %esi,(%rax)
jne    1187 <pathconf+0x47>
lea    0xea6(%rip),%rdi
call   1050 <libau_test_func@plt>
test   %rax,%rax
jne    1176 <pathconf+0x36>
lea    0xe94(%rip),%rdi
call   1050 <libau_test_func@plt>
test   %rax,%rax
je     1187 <pathconf+0x47>
mov    %r14,%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <libau_pathconf@plt>
xor    %eax,%eax
call   1040 <libau_dl_pathconf@plt>
test   %eax,%eax
je     11a1 <pathconf+0x61>
mov    $0xffffffffffffffff,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %r14,%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <real_pathconf@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 @pathconf(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i64
store i8* %0, i8** %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 i8*, i8** %3
%17 = load i32, i32* %4
%18 = call i64 @libau_pathconf(i8* %16, i32 %17)
store i64 %18, i64* %5
br label %27
19: ; preds = %12, %2
%20 = call i32 (...) @libau_dl_pathconf()
%21 = icmp ne i32 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = load i8*, i8** %3
%24 = load i32, i32* %4
%25 = call i64 @real_pathconf(i8* %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 @pathconf(i8* %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_pathconf(i8* %0, i32 %1)
br label %18
13: ; preds = %8, %2
%14 = tail call i32 (...) @libau_dl_pathconf()
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i64 @real_pathconf(i8* %0, i32 %1)
br label %18
18: ; preds = %13, %16, %11
%19 = phi i64 [ %12, %11 ], [ -1, %13 ], [ %17, %16 ]
ret i64 %19
}