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


x86 assembly (clang, -O0):
<sysconf_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
mov    0x2e82(%rip),%rax
movq   $0x0,(%rax)
mov    -0xc(%rbp),%edi
call   1050 <sysconf@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0xffffffffffffffff,-0x18(%rbp)
je     1197 <sysconf_print+0x57>
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f1 <sysconf_print+0xb1>
mov    0x2e42(%rip),%rax
cmpq   $0x0,(%rax)
jne    11c3 <sysconf_print+0x83>
mov    -0x8(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ec <sysconf_print+0xac>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e0e(%rip),%rax
mov    (%rax),%rdi
call   1060 <strerror@plt>
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
lea    0xe5b(%rip),%rdi
call   1040 <err_exit@plt>
jmp    11f1 <sysconf_print+0xb1>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sysconf_print>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2e92(%rip),%r14
movq   $0x0,(%r14)
mov    %esi,%edi
call   1050 <sysconf@plt>
cmp    $0xffffffffffffffff,%rax
je     117d <sysconf_print+0x3d>
lea    0xe97(%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     11a2 <sysconf_print+0x62>
call   1060 <strerror@plt>
lea    0xeb1(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <err_exit@plt>
lea    0xe68(%rip),%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
jmp    116f <sysconf_print+0x2f>

LLVM IR (-O0):
@errno = global i64 0
@.str = [17 x i8] c"%s value is %ld\0A\00"
@.str.1 = [49 x i8] c"sysconf(%s)succeeded and %s value indeterminate\0A\00"
@.str.2 = [26 x i8] c"Erron on sysconf(%s), %s\0A\00"
define void @sysconf_print(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* %5
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 ne i64 %8, -1
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = load i64, i64* %5
%13 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %11, i64 %12)
br label %27
14: ; preds = %2
%15 = load i64, i64* @errno
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load i8*, i8** %3
%19 = load i8*, i8** %3
%20 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i8* %18, i8* %19)
br label %26
21: ; preds = %14
%22 = load i8*, i8** %3
%23 = load i64, i64* @errno
%24 = call i32 @strerror(i64 %23)
%25 = call i32 @err_exit(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %22, i32 %24)
br label %26
26: ; preds = %21, %17
br label %27
27: ; preds = %26, %10
ret void
}

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