#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*/ EX_OSERR;
int /*<<< orphan*/ err(int /*<<< orphan*/, char *, char const *);
scalar_t__ errno;
long pathconf(char const *, int);
int /*<<< orphan*/ printf(char *, ...);
void do_pathconf(const char *name, int key, const char *path) {
  long value;
  errno = 0;
  value = pathconf(path, key);
  if (value == -1 && errno != 0)
    err(EX_OSERR, "pathconf: %s", name);
  else if (value == -1)
    printf("undefined\n");
  else
    printf("%ld\n", value);
}


x86 assembly (clang, -O0):
<do_pathconf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2e96(%rip),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <pathconf@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0xffffffffffffffff,-0x20(%rbp)
jne    119b <do_pathconf+0x6b>
mov    0x2e6d(%rip),%rax
cmpq   $0x0,(%rax)
je     119b <do_pathconf+0x6b>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe6f(%rip),%rsi
call   1050 <err@plt>
jmp    11d0 <do_pathconf+0xa0>
cmpq   $0xffffffffffffffff,-0x20(%rbp)
jne    11b9 <do_pathconf+0x89>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11cb <do_pathconf+0x9b>
mov    -0x20(%rbp),%rsi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11d0 <do_pathconf+0xa0>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_pathconf>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2e92(%rip),%rbx
movq   $0x0,(%rbx)
mov    %rdx,%rdi
call   1040 <pathconf@plt>
cmp    $0xffffffffffffffff,%rax
jne    1188 <do_pathconf+0x48>
cmpq   $0x0,(%rbx)
je     1188 <do_pathconf+0x48>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
lea    0xe87(%rip),%rsi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <err@plt>
cmp    $0xffffffffffffffff,%rax
je     11a6 <do_pathconf+0x66>
lea    0xe78(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <printf@plt>
lea    0xe65(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <puts@plt>

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

LLVM IR (-O2):
@errno = global i64 0
@EX_OSERR = global i32 0
@.str = [13 x i8] c"pathconf: %s\00"
@.str.2 = [5 x i8] c"%ld\0A\00"
@str = [10 x i8] c"undefined\00"
define void @do_pathconf(i8* %0, i32 %1, i8* %2) {
store i64 0, i64* @errno
%4 = tail call i64 @pathconf(i8* %2, i32 %1)
%5 = icmp eq i64 %4, -1
%6 = load i64, i64* @errno
%7 = icmp ne i64 %6, 0
%8 = select i1 %5, i1 %7, i1 false
br i1 %8, label %9, label %12
9: ; preds = %3
%10 = load i32, i32* @EX_OSERR
%11 = tail call i32 @err(i32 %10, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %17
12: ; preds = %3
br i1 %5, label %13, label %15
13: ; preds = %12
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
br label %17
15: ; preds = %12
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %4)
br label %17
17: ; preds = %13, %15, %9
ret void
}