#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*/ EBADF;
int /*<<< orphan*/ EINVAL;
int /*<<< orphan*/ ENOSYS;
#define _PC_CHOWN_RESTRICTED 137
#define _PC_LINK_MAX 136
#define _PC_MAX_CANON 135
#define _PC_MAX_INPUT 134
#define _PC_NAME_MAX 133
#define _PC_NO_TRUNC 132
#define _PC_PATH_MAX 131
#define _PC_PIPE_BUF 130
#define _PC_SOCK_MAXBUF 129
#define _PC_VDISABLE 128
int /*<<< orphan*/ __set_errno(int /*<<< orphan*/);
long int __fpathconf(int fd, int name) {
  if (fd < 0) {
    __set_errno(EBADF);
    return -1;
  }
  switch (name) {
  default:
    __set_errno(EINVAL);
    return -1;
  case _PC_LINK_MAX:
  case _PC_MAX_CANON:
  case _PC_MAX_INPUT:
  case _PC_NAME_MAX:
  case _PC_PATH_MAX:
  case _PC_PIPE_BUF:
  case _PC_SOCK_MAXBUF:
  case _PC_CHOWN_RESTRICTED:
  case _PC_NO_TRUNC:
  case _PC_VDISABLE:
    break;
  }
  __set_errno(ENOSYS);
  return -1;
}


x86 assembly (clang, -O0):
<__fpathconf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1143 <__fpathconf+0x33>
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    118d <__fpathconf+0x7d>
mov    -0x10(%rbp),%eax
add    $0xffffff80,%eax
sub    $0xa,%eax
jb     1172 <__fpathconf+0x62>
jmp    1157 <__fpathconf+0x47>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    118d <__fpathconf+0x7d>
jmp    1177 <__fpathconf+0x67>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__fpathconf>:
push   %rax
add    $0xffffff80,%esi
cmp    $0xa,%esi
jae    1126 <__fpathconf+0x16>
mov    0x2ec8(%rip),%rax
test   %edi,%edi
js     1131 <__fpathconf+0x21>
jmp    1138 <__fpathconf+0x28>
mov    0x2eab(%rip),%rax
test   %edi,%edi
jns    1138 <__fpathconf+0x28>
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
mov    $0xffffffffffffffff,%rax
pop    %rcx
ret

LLVM IR (-O0):
@EBADF = global i32 0
@EINVAL = global i32 0
@ENOSYS = global i32 0
define i64 @__fpathconf(i32 %0, i32 %1) {
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* @EBADF
%10 = call i32 @__set_errno(i32 %9)
store i64 -1, i64* %3
br label %20
11: ; preds = %2
%12 = load i32, i32* %5
switch i32 %12, label %13 [
i32 136, label %16
i32 135, label %16
i32 134, label %16
i32 133, label %16
i32 131, label %16
i32 130, label %16
i32 129, label %16
i32 137, label %16
i32 132, label %16
i32 128, label %16
]
13: ; preds = %11
%14 = load i32, i32* @EINVAL
%15 = call i32 @__set_errno(i32 %14)
store i64 -1, i64* %3
br label %20
16: ; preds = %11, %11, %11, %11, %11, %11, %11, %11, %11, %11
br label %17
17: ; preds = %16
%18 = load i32, i32* @ENOSYS
%19 = call i32 @__set_errno(i32 %18)
store i64 -1, i64* %3
br label %20
20: ; preds = %17, %13, %8
%21 = load i64, i64* %3
ret i64 %21
}

LLVM IR (-O2):
@EBADF = global i32 0
@EINVAL = global i32 0
@ENOSYS = global i32 0
define i64 @__fpathconf(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, 0
%4 = add i32 %1, -128
%5 = icmp ult i32 %4, 10
%6 = load i32, i32* @EBADF
%7 = load i32, i32* @ENOSYS
%8 = load i32, i32* @EINVAL
%9 = select i1 %5, i32 %7, i32 %8
%10 = select i1 %3, i32 %6, i32 %9
%11 = tail call i32 @__set_errno(i32 %10)
ret i64 -1
}