#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*/ err_exit(char *, char const *, int /*<<< orphan*/);
scalar_t__ errno;
long fpathconf(int, int);
int /*<<< orphan*/ printf(char *, char const *, ...);
int /*<<< orphan*/ strerror(scalar_t__);
void fpathconf_print(const char *msg, int fd, int name) {
  long lim = 0;
  errno = 0;
  lim = fpathconf(fd, name);
  if (lim != -1) {
    printf("%s value is %ld\n", msg, lim);
  } else {
    if (errno == 0) {
      printf(
          "fpathconf(STDIN_FILENO, %s)succeeded and %s value indeterminate\n",
          msg, msg);
    } else {
      err_exit("Erron on fpathconf(STDIN_FILENO, %s), %s\n", msg,
               strerror(errno));
    }
  }
}


x86 assembly (clang, -O0):
<fpathconf_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    0x2e7f(%rip),%rax
movq   $0x0,(%rax)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <fpathconf@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0xffffffffffffffff,-0x18(%rbp)
je     119d <fpathconf_print+0x5d>
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f7 <fpathconf_print+0xb7>
mov    0x2e3c(%rip),%rax
cmpq   $0x0,(%rax)
jne    11c9 <fpathconf_print+0x89>
mov    -0x8(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f2 <fpathconf_print+0xb2>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e08(%rip),%rax
mov    (%rax),%rdi
call   1060 <strerror@plt>
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
lea    0xe65(%rip),%rdi
call   1050 <err_exit@plt>
jmp    11f7 <fpathconf_print+0xb7>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fpathconf_print>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2e92(%rip),%r14
movq   $0x0,(%r14)
mov    %esi,%edi
mov    %edx,%esi
call   1040 <fpathconf@plt>
cmp    $0xffffffffffffffff,%rax
je     117f <fpathconf_print+0x3f>
lea    0xe95(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>
mov    (%r14),%rdi
test   %rdi,%rdi
je     11a4 <fpathconf_print+0x64>
call   1060 <strerror@plt>
lea    0xebf(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <err_exit@plt>
lea    0xe66(%rip),%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
jmp    1171 <fpathconf_print+0x31>

LLVM IR (-O0):
@errno = global i64 0
@.str = [17 x i8] c"%s value is %ld\0A\00"
@.str.1 = [65 x i8] c"fpathconf(STDIN_FILENO, %s)succeeded and %s value indeterminate\0A\00"
@.str.2 = [42 x i8] c"Erron on fpathconf(STDIN_FILENO, %s), %s\0A\00"
define void @fpathconf_print(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i64 0, i64* %7
store i64 0, i64* @errno
%8 = load i32, i32* %5
%9 = load i32, i32* %6
%10 = call i64 @fpathconf(i32 %8, i32 %9)
store i64 %10, i64* %7
%11 = load i64, i64* %7
%12 = icmp ne i64 %11, -1
br i1 %12, label %13, label %17
13: ; preds = %3
%14 = load i8*, i8** %4
%15 = load i64, i64* %7
%16 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %14, i64 %15)
br label %30
17: ; preds = %3
%18 = load i64, i64* @errno
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i8*, i8** %4
%22 = load i8*, i8** %4
%23 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i8* %21, i8* %22)
br label %29
24: ; preds = %17
%25 = load i8*, i8** %4
%26 = load i64, i64* @errno
%27 = call i32 @strerror(i64 %26)
%28 = call i32 @err_exit(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %25, i32 %27)
br label %29
29: ; preds = %24, %20
br label %30
30: ; preds = %29, %13
ret void
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [17 x i8] c"%s value is %ld\0A\00"
@.str.1 = [65 x i8] c"fpathconf(STDIN_FILENO, %s)succeeded and %s value indeterminate\0A\00"
@.str.2 = [42 x i8] c"Erron on fpathconf(STDIN_FILENO, %s), %s\0A\00"
define void @fpathconf_print(i8* %0, i32 %1, i32 %2) {
store i64 0, i64* @errno
%4 = tail call i64 @fpathconf(i32 %1, i32 %2)
%5 = icmp eq i64 %4, -1
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %0, i64 %4)
br label %16
8: ; preds = %3
%9 = load i64, i64* @errno
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %0)
br label %16
13: ; preds = %8
%14 = tail call i32 @strerror(i64 %9)
%15 = tail call i32 @err_exit(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 %14)
br label %16
16: ; preds = %11, %13, %6
ret void
}