#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 */
scalar_t__ errno;
int /*<<< orphan*/ printf(char *, char const *, ...);
char *strerror(scalar_t__);
long sysconf(int);
void print_conf_value(int name, const char *sym) {
  errno = 0;
  long value = sysconf(name);
  if (value == -1) {
    errno == 0 ? printf("%s (%d): No limit\n", sym, name)
               : printf("%s sysconf error: %s\n", sym, strerror(errno));
  } else {
    printf("%s (%d): %ld\n", sym, name, value);
  }
}


x86 assembly (clang, -O0):
<print_conf_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e9a(%rip),%rax
movq   $0x0,(%rax)
mov    -0x4(%rbp),%edi
call   1040 <sysconf@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0xffffffffffffffff,-0x18(%rbp)
jne    11c0 <print_conf_value+0x90>
mov    0x2e75(%rip),%rax
cmpq   $0x0,(%rax)
jne    118f <print_conf_value+0x5f>
mov    -0x10(%rbp),%rsi
mov    -0x4(%rbp),%edx
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11bb <print_conf_value+0x8b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e42(%rip),%rax
mov    (%rax),%rdi
call   1050 <strerror@plt>
mov    -0x20(%rbp),%rsi
mov    %rax,%rdx
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d9 <print_conf_value+0xa9>
mov    -0x10(%rbp),%rsi
mov    -0x4(%rbp),%edx
mov    -0x18(%rbp),%rcx
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_conf_value>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x2ea0(%rip),%rbx
movq   $0x0,(%rbx)
call   1040 <sysconf@plt>
cmp    $0xffffffffffffffff,%rax
je     116c <print_conf_value+0x3c>
lea    0xed0(%rip),%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>
mov    (%rbx),%rdi
test   %rdi,%rdi
je     1191 <print_conf_value+0x61>
call   1050 <strerror@plt>
lea    0xe93(%rip),%rdi
mov    %r14,%rsi
mov    %rax,%rdx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>
lea    0xe68(%rip),%rdi
mov    %r14,%rsi
mov    %ebp,%edx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@errno = global i64 0
@.str = [19 x i8] c"%s (%d): No limit\0A\00"
@.str.1 = [22 x i8] c"%s sysconf error: %s\0A\00"
@.str.2 = [14 x i8] c"%s (%d): %ld\0A\00"
define void @print_conf_value(i32 %0, i8* %1) {
store i64 0, i64* @errno
%3 = tail call i64 @sysconf(i32 %0)
%4 = icmp eq i64 %3, -1
br i1 %4, label %5, label %13
5: ; preds = %2
%6 = load i64, i64* @errno
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %0)
br label %15
10: ; preds = %5
%11 = tail call i8* @strerror(i64 %6)
%12 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %11)
br label %15
13: ; preds = %2
%14 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %1, i32 %0, i64 %3)
br label %15
15: ; preds = %8, %10, %13
ret void
}