#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__ EINVAL;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, long);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
long sysconf(int);
void pr_sysconf(char *mesg, int name) {
  long val;
  fputs(mesg, stdout);
  errno = 0;
  if ((val = sysconf(name)) < 0) {
    if (errno != 0) {
      if (errno == EINVAL) {
        fputs(" (not supported)\n", stdout);
      } else {
        fprintf(stderr, "sysconf error\n");
      }
    } else {
      fputs(" (no limit)\n", stdout);
    }
  } else {
    printf(" %ld\n", val);
  }
}


x86 assembly (clang, -O0):
<pr_sysconf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e6e(%rip),%rax
mov    (%rax),%esi
call   1040 <fputs@plt>
mov    0x2e70(%rip),%rax
movq   $0x0,(%rax)
mov    -0xc(%rbp),%edi
call   1060 <sysconf@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jge    11fe <pr_sysconf+0xbe>
mov    0x2e4c(%rip),%rax
cmpq   $0x0,(%rax)
je     11e4 <pr_sysconf+0xa4>
mov    0x2e3b(%rip),%rax
mov    (%rax),%rax
mov    0x2e29(%rip),%rcx
cmp    (%rcx),%rax
jne    11ca <pr_sysconf+0x8a>
mov    0x2e11(%rip),%rax
mov    (%rax),%esi
lea    0xe40(%rip),%rdi
call   1040 <fputs@plt>
jmp    11df <pr_sysconf+0x9f>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xe38(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11f9 <pr_sysconf+0xb9>
mov    0x2ddd(%rip),%rax
mov    (%rax),%esi
lea    0xe2d(%rip),%rdi
call   1040 <fputs@plt>
jmp    120e <pr_sysconf+0xce>
mov    -0x18(%rbp),%rsi
lea    0xe25(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pr_sysconf>:
push   %r15
push   %r14
push   %rbx
mov    %esi,%ebx
mov    0x2e7a(%rip),%r14
mov    (%r14),%esi
call   1040 <fputs@plt>
mov    0x2e7b(%rip),%r15
movq   $0x0,(%r15)
mov    %ebx,%edi
call   1060 <sysconf@plt>
test   %rax,%rax
js     1184 <pr_sysconf+0x44>
lea    0xeb7(%rip),%rdi
mov    %rax,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <printf@plt>
mov    (%r15),%rax
test   %rax,%rax
je     11a4 <pr_sysconf+0x64>
mov    0x2e3d(%rip),%rcx
cmp    (%rcx),%rax
jne    11b8 <pr_sysconf+0x78>
mov    (%r14),%esi
lea    0xe5e(%rip),%rdi
jmp    11ae <pr_sysconf+0x6e>
mov    (%r14),%esi
lea    0xe73(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <fputs@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
lea    0xe4a(%rip),%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <fprintf@plt>

LLVM IR (-O0):
@stdout = global i32 0
@errno = global i64 0
@EINVAL = global i64 0
@.str = [18 x i8] c" (not supported)\0A\00"
@stderr = global i32 0
@.str.1 = [15 x i8] c"sysconf error\0A\00"
@.str.2 = [13 x i8] c" (no limit)\0A\00"
@.str.3 = [6 x i8] c" %ld\0A\00"
define void @pr_sysconf(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i64
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = load i32, i32* @stdout
%8 = call i32 @fputs(i8* %6, i32 %7)
store i64 0, i64* @errno
%9 = load i32, i32* %4
%10 = call i64 @sysconf(i32 %9)
store i64 %10, i64* %5
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %30
12: ; preds = %2
%13 = load i64, i64* @errno
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %12
%16 = load i64, i64* @errno
%17 = load i64, i64* @EINVAL
%18 = icmp eq i64 %16, %17
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i32, i32* @stdout
%21 = call i32 @fputs(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %20)
br label %25
22: ; preds = %15
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %22, %19
br label %29
26: ; preds = %12
%27 = load i32, i32* @stdout
%28 = call i32 @fputs(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %26, %25
br label %33
30: ; preds = %2
%31 = load i64, i64* %5
%32 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %31)
br label %33
33: ; preds = %30, %29
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@errno = global i64 0
@EINVAL = global i64 0
@.str = [18 x i8] c" (not supported)\0A\00"
@stderr = global i32 0
@.str.1 = [15 x i8] c"sysconf error\0A\00"
@.str.2 = [13 x i8] c" (no limit)\0A\00"
@.str.3 = [6 x i8] c" %ld\0A\00"
define void @pr_sysconf(i8* %0, i32 %1) {
%3 = load i32, i32* @stdout
%4 = tail call i32 @fputs(i8* %0, i32 %3)
store i64 0, i64* @errno
%5 = tail call i64 @sysconf(i32 %1)
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %22
7: ; preds = %2
%8 = load i64, i64* @errno
%9 = icmp eq i64 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %7
%11 = load i64, i64* @EINVAL
%12 = icmp eq i64 %8, %11
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i32, i32* @stdout
%15 = tail call i32 @fputs(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %24
16: ; preds = %10
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %24
19: ; preds = %7
%20 = load i32, i32* @stdout
%21 = tail call i32 @fputs(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %20)
br label %24
22: ; preds = %2
%23 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %5)
br label %24
24: ; preds = %19, %16, %13, %22
ret void
}