#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;
#define _PC_ALLOC_SIZE_MIN 146
#define _PC_ASYNC_IO 145
#define _PC_CHOWN_RESTRICTED 144
#define _PC_FILESIZEBITS 143
int _PC_LINK_MAX;
#define _PC_MAX_CANON 142
#define _PC_MAX_INPUT 141
#define _PC_NAME_MAX 140
#define _PC_NO_TRUNC 139
#define _PC_PATH_MAX 138
#define _PC_PIPE_BUF 137
#define _PC_PRIO_IO 136
#define _PC_REC_INCR_XFER_SIZE 135
#define _PC_REC_MAX_XFER_SIZE 134
#define _PC_REC_MIN_XFER_SIZE 133
#define _PC_REC_XFER_ALIGN 132
#define _PC_SOCK_MAXBUF 131
#define _PC_SYMLINK_MAX 130
#define _PC_SYNC_IO 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;
  }
  if (name == _PC_LINK_MAX) {
    return 127;
  }
  switch (name) {
  default:
    __set_errno(EINVAL);
    return -1;
  case _PC_MAX_CANON:
    return -1;
  case _PC_MAX_INPUT:
    return -1;
  case _PC_NAME_MAX:
    return -1;
  case _PC_PATH_MAX:
    return -1;
  case _PC_PIPE_BUF:
    return -1;
  case _PC_CHOWN_RESTRICTED:
    return -1;
  case _PC_NO_TRUNC:
    return -1;
  case _PC_VDISABLE:
    return -1;
  case _PC_SYNC_IO:
    return -1;
  case _PC_ASYNC_IO:
    return -1;
  case _PC_PRIO_IO:
    return -1;
  case _PC_SOCK_MAXBUF:
    return -1;
  case _PC_FILESIZEBITS:
    return 32;
  case _PC_REC_INCR_XFER_SIZE:
  case _PC_REC_MAX_XFER_SIZE:
  case _PC_REC_MIN_XFER_SIZE:
  case _PC_REC_XFER_ALIGN:
  case _PC_ALLOC_SIZE_MIN:
  case _PC_SYMLINK_MAX:
    return -1;
  }
}


x86 assembly (clang, -O0):
<fpathconf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1143 <fpathconf+0x33>
mov    0x2ea9(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1257 <fpathconf+0x147>
mov    -0x10(%rbp),%eax
mov    0x2e7b(%rip),%rcx
cmp    (%rcx),%eax
jne    1162 <fpathconf+0x52>
movq   $0x7f,-0x8(%rbp)
jmp    1257 <fpathconf+0x147>
mov    -0x10(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x12,%eax
ja     118b <fpathconf+0x7b>
mov    -0x18(%rbp),%rax
lea    0xe7e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1257 <fpathconf+0x147>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1257 <fpathconf+0x147>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1257 <fpathconf+0x147>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1257 <fpathconf+0x147>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1257 <fpathconf+0x147>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1257 <fpathconf+0x147>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1257 <fpathconf+0x147>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1257 <fpathconf+0x147>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1257 <fpathconf+0x147>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1257 <fpathconf+0x147>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1257 <fpathconf+0x147>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1257 <fpathconf+0x147>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1257 <fpathconf+0x147>
movq   $0x20,-0x8(%rbp)
jmp    1257 <fpathconf+0x147>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fpathconf>:
push   %rax
test   %edi,%edi
js     113d <fpathconf+0x2d>
mov    0x2eac(%rip),%rcx
mov    $0x7f,%eax
cmp    %esi,(%rcx)
je     113b <fpathconf+0x2b>
add    $0xffffff80,%esi
cmp    $0x13,%esi
jae    1146 <fpathconf+0x36>
movslq %esi,%rax
lea    0xec9(%rip),%rcx
mov    (%rcx,%rax,8),%rax
pop    %rcx
ret
mov    0x2e94(%rip),%rax
jmp    114d <fpathconf+0x3d>
mov    0x2e93(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
mov    $0xffffffffffffffff,%rax
pop    %rcx
ret

LLVM IR (-O0):
@EBADF = global i32 0
@_PC_LINK_MAX = global i32 0
@EINVAL = 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 %35
11: ; preds = %2
%12 = load i32, i32* %5
%13 = load i32, i32* @_PC_LINK_MAX
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %11
store i64 127, i64* %3
br label %35
16: ; preds = %11
%17 = load i32, i32* %5
switch i32 %17, label %18 [
i32 142, label %21
i32 141, label %22
i32 140, label %23
i32 138, label %24
i32 137, label %25
i32 144, label %26
i32 139, label %27
i32 128, label %28
i32 129, label %29
i32 145, label %30
i32 136, label %31
i32 131, label %32
i32 143, label %33
i32 135, label %34
i32 134, label %34
i32 133, label %34
i32 132, label %34
i32 146, label %34
i32 130, label %34
]
18: ; preds = %16
%19 = load i32, i32* @EINVAL
%20 = call i32 @__set_errno(i32 %19)
store i64 -1, i64* %3
br label %35
21: ; preds = %16
store i64 -1, i64* %3
br label %35
22: ; preds = %16
store i64 -1, i64* %3
br label %35
23: ; preds = %16
store i64 -1, i64* %3
br label %35
24: ; preds = %16
store i64 -1, i64* %3
br label %35
25: ; preds = %16
store i64 -1, i64* %3
br label %35
26: ; preds = %16
store i64 -1, i64* %3
br label %35
27: ; preds = %16
store i64 -1, i64* %3
br label %35
28: ; preds = %16
store i64 -1, i64* %3
br label %35
29: ; preds = %16
store i64 -1, i64* %3
br label %35
30: ; preds = %16
store i64 -1, i64* %3
br label %35
31: ; preds = %16
store i64 -1, i64* %3
br label %35
32: ; preds = %16
store i64 -1, i64* %3
br label %35
33: ; preds = %16
store i64 32, i64* %3
br label %35
34: ; preds = %16, %16, %16, %16, %16, %16
store i64 -1, i64* %3
br label %35
35: ; preds = %34, %33, %32, %31, %30, %29, %28, %27, %26, %25, %24, %23, %22, %21, %18, %15, %8
%36 = load i64, i64* %3
ret i64 %36
}

LLVM IR (-O2):
@EBADF = global i32 0
@_PC_LINK_MAX = global i32 0
@EINVAL = global i32 0
@switch.table.fpathconf = [19 x i64] [i64 -1, i64 -1, i64 -1, i64 -1, i64 -1, i64 -1, i64 -1, i64 -1, i64 -1, i64 -1, i64 -1, i64 -1, i64 -1, i64 -1, i64 -1, i64 32, i64 -1, i64 -1, i64 -1]
define i64 @fpathconf(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, 0
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @EBADF
%6 = tail call i32 @__set_errno(i32 %5)
br label %20
7: ; preds = %2
%8 = load i32, i32* @_PC_LINK_MAX
%9 = icmp eq i32 %8, %1
br i1 %9, label %20, label %10
10: ; preds = %7
%11 = add i32 %1, -128
%12 = icmp ult i32 %11, 19
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* @EINVAL
%15 = tail call i32 @__set_errno(i32 %14)
br label %20
16: ; preds = %10
%17 = sext i32 %11 to i64
%18 = getelementptr inbounds [19 x i64], [19 x i64]* @switch.table.fpathconf, i64 0, i64 %17
%19 = load i64, i64* %18
br label %20
20: ; preds = %16, %7, %13, %4
%21 = phi i64 [ -1, %4 ], [ -1, %13 ], [ 127, %7 ], [ %19, %16 ]
ret i64 %21
}