#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;
int /*<<< orphan*/ err_sys(char *);
scalar_t__ errno;
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, long);
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 {
        err_sys("sysconf error");
      }
    } else {
      fputs(" (no limits)\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    0x2e76(%rip),%rax
mov    (%rax),%esi
call   1050 <fputs@plt>
mov    0x2e78(%rip),%rax
movq   $0x0,(%rax)
mov    -0xc(%rbp),%edi
call   1060 <sysconf@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jge    11f5 <pr_sysconf+0xb5>
mov    0x2e54(%rip),%rax
cmpq   $0x0,(%rax)
je     11db <pr_sysconf+0x9b>
mov    0x2e43(%rip),%rax
mov    (%rax),%rax
mov    0x2e31(%rip),%rcx
cmp    (%rcx),%rax
jne    11ca <pr_sysconf+0x8a>
mov    0x2e19(%rip),%rax
mov    (%rax),%esi
lea    0xe40(%rip),%rdi
call   1050 <fputs@plt>
jmp    11d6 <pr_sysconf+0x96>
lea    0xe41(%rip),%rdi
call   1030 <err_sys@plt>
jmp    11f0 <pr_sysconf+0xb0>
mov    0x2dee(%rip),%rax
mov    (%rax),%esi
lea    0xe35(%rip),%rdi
call   1050 <fputs@plt>
jmp    1205 <pr_sysconf+0xc5>
mov    -0x18(%rbp),%rsi
lea    0xe2e(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pr_sysconf>:
push   %r15
push   %r14
push   %rbx
mov    %esi,%ebx
mov    0x2e82(%rip),%r14
mov    (%r14),%esi
call   1050 <fputs@plt>
mov    0x2e83(%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    1040 <printf@plt>
mov    (%r15),%rax
test   %rax,%rax
je     11a4 <pr_sysconf+0x64>
mov    0x2e45(%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    0xe72(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <fputs@plt>
lea    0xe53(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <err_sys@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"
@.str.1 = [14 x i8] c"sysconf error\00"
@.str.2 = [14 x i8] c" (no limits)\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 %29
12: ; preds = %2
%13 = load i64, i64* @errno
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %25
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 %24
22: ; preds = %15
%23 = call i32 @err_sys(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %19
br label %28
25: ; preds = %12
%26 = load i32, i32* @stdout
%27 = call i32 @fputs(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %25, %24
br label %32
29: ; preds = %2
%30 = load i64, i64* %5
%31 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %30)
br label %32
32: ; preds = %29, %28
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"
@.str.1 = [14 x i8] c"sysconf error\00"
@.str.2 = [14 x i8] c" (no limits)\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 %21
7: ; preds = %2
%8 = load i64, i64* @errno
%9 = icmp eq i64 %8, 0
br i1 %9, label %18, 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 %23
16: ; preds = %10
%17 = tail call i32 @err_sys(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %23
18: ; preds = %7
%19 = load i32, i32* @stdout
%20 = tail call i32 @fputs(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %19)
br label %23
21: ; preds = %2
%22 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %5)
br label %23
23: ; preds = %18, %16, %13, %21
ret void
}