#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 */
struct rlimit {
  int /*<<< orphan*/ rlim_max;
  int /*<<< orphan*/ rlim_cur;
};

/* Variables and functions */
int /*<<< orphan*/ RLIMIT_NPROC;
int /*<<< orphan*/ _SC_CHILD_MAX;
int /*<<< orphan*/ getrlimit(int /*<<< orphan*/, struct rlimit *);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/, ...);
int /*<<< orphan*/ sysconf(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  printf("%ld\n", sysconf(_SC_CHILD_MAX));
  struct rlimit rl;
  getrlimit(RLIMIT_NPROC, &rl);
  printf("%ld, %ld\n", rl.rlim_cur, rl.rlim_max);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
call   1040 <sysconf@plt>
mov    %eax,%esi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1050 <getrlimit@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2ea0(%rip),%rax
mov    (%rax),%edi
call   1040 <sysconf@plt>
lea    0xebf(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1050 <getrlimit@plt>
mov    (%rsp),%edx
mov    0x4(%rsp),%esi
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.rlimit = type { i32, i32 }
@.str = [5 x i8] c"%ld\0A\00"
@_SC_CHILD_MAX = global i32 0
@RLIMIT_NPROC = global i32 0
@.str.1 = [10 x i8] c"%ld, %ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.rlimit
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* @_SC_CHILD_MAX
%8 = call i32 @sysconf(i32 %7)
%9 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load i32, i32* @RLIMIT_NPROC
%11 = call i32 @getrlimit(i32 %10, %struct.rlimit* %6)
%12 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i32 0, i32 1
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i32 0, i32 0
%15 = load i32, i32* %14
%16 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %15)
ret i32 0
}

LLVM IR (-O2):
%struct.rlimit = type { i32, i32 }
@.str = [5 x i8] c"%ld\0A\00"
@_SC_CHILD_MAX = global i32 0
@RLIMIT_NPROC = global i32 0
@.str.1 = [10 x i8] c"%ld, %ld\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.rlimit
%4 = load i32, i32* @_SC_CHILD_MAX
%5 = tail call i32 @sysconf(i32 %4)
%6 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = bitcast %struct.rlimit* %3 to i8*
%8 = load i32, i32* @RLIMIT_NPROC
%9 = call i32 @getrlimit(i32 %8, %struct.rlimit* %3)
%10 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i64 0, i32 1
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i64 0, i32 0
%13 = load i32, i32* %12
%14 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %13)
ret i32 0
}