#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*/ EX_OSERR;
int /*<<< orphan*/ err(int /*<<< orphan*/, char *, char const *);
scalar_t__ errno;
int /*<<< orphan*/ printf(char *, ...);
long sysconf(int);
void do_sysconf(const char *name, int key) {
  long value;
  errno = 0;
  value = sysconf(key);
  if (value == -1 && errno != 0)
    err(EX_OSERR, "sysconf: %s", name);
  else if (value == -1)
    printf("undefined\n");
  else
    printf("%ld\n", value);
}


x86 assembly (clang, -O0):
<do_sysconf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2e9a(%rip),%rax
movq   $0x0,(%rax)
mov    -0xc(%rbp),%edi
call   1050 <sysconf@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0xffffffffffffffff,-0x18(%rbp)
jne    1193 <do_sysconf+0x63>
mov    0x2e75(%rip),%rax
cmpq   $0x0,(%rax)
je     1193 <do_sysconf+0x63>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe77(%rip),%rsi
call   1040 <err@plt>
jmp    11c8 <do_sysconf+0x98>
cmpq   $0xffffffffffffffff,-0x18(%rbp)
jne    11b1 <do_sysconf+0x81>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c3 <do_sysconf+0x93>
mov    -0x18(%rbp),%rsi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c8 <do_sysconf+0x98>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_sysconf>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2e92(%rip),%rbx
movq   $0x0,(%rbx)
mov    %esi,%edi
call   1060 <sysconf@plt>
cmp    $0xffffffffffffffff,%rax
jne    1187 <do_sysconf+0x47>
cmpq   $0x0,(%rbx)
je     1187 <do_sysconf+0x47>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe88(%rip),%rsi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <err@plt>
cmp    $0xffffffffffffffff,%rax
je     11a5 <do_sysconf+0x65>
lea    0xe78(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>
lea    0xe65(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <puts@plt>

LLVM IR (-O0):
@errno = global i64 0
@EX_OSERR = global i32 0
@.str = [12 x i8] c"sysconf: %s\00"
@.str.1 = [11 x i8] c"undefined\0A\00"
@.str.2 = [5 x i8] c"%ld\0A\00"
define void @do_sysconf(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i64
store i8* %0, i8** %3
store i32 %1, i32* %4
store i64 0, i64* @errno
%6 = load i32, i32* %4
%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 %17
10: ; preds = %2
%11 = load i64, i64* @errno
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i32, i32* @EX_OSERR
%15 = load i8*, i8** %3
%16 = call i32 @err(i32 %14, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %26
17: ; preds = %10, %2
%18 = load i64, i64* %5
%19 = icmp eq i64 %18, -1
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %25
22: ; preds = %17
%23 = load i64, i64* %5
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %23)
br label %25
25: ; preds = %22, %20
br label %26
26: ; preds = %25, %13
ret void
}

LLVM IR (-O2):
@errno = global i64 0
@EX_OSERR = global i32 0
@.str = [12 x i8] c"sysconf: %s\00"
@.str.2 = [5 x i8] c"%ld\0A\00"
@str = [10 x i8] c"undefined\00"
define void @do_sysconf(i8* %0, i32 %1) {
store i64 0, i64* @errno
%3 = tail call i64 @sysconf(i32 %1)
%4 = icmp eq i64 %3, -1
%5 = load i64, i64* @errno
%6 = icmp ne i64 %5, 0
%7 = select i1 %4, i1 %6, i1 false
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* @EX_OSERR
%10 = tail call i32 @err(i32 %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %16
11: ; preds = %2
br i1 %4, label %12, label %14
12: ; preds = %11
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
br label %16
14: ; preds = %11
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %3)
br label %16
16: ; preds = %12, %14, %8
ret void
}