#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 {
  scalar_t__ rlim_cur;
};

/* Variables and functions */
int /*<<< orphan*/ RLIMIT_CORE;
int /*<<< orphan*/ RLIMIT_FSIZE;
int /*<<< orphan*/ RLIMIT_NOFILE;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ getrlimit(int /*<<< orphan*/, struct rlimit *);
int /*<<< orphan*/ printf(char *, ...);
main(int argc, char **argv) {
  struct rlimit u_limit;
  int exit_code = 0;
  (void)getrlimit(RLIMIT_CORE, &u_limit);
  printf("USER_CORE=%d\n", (int)u_limit.rlim_cur);
  (void)getrlimit(RLIMIT_FSIZE, &u_limit);
  printf("USER_FSIZE=%d\n", (int)u_limit.rlim_cur);
  (void)getrlimit(RLIMIT_NOFILE, &u_limit);
  printf("USER_NOFILE=%d\n", (int)u_limit.rlim_cur);
  printf("USER_NPROC unsupported\n");
  printf("USER_STACK unsupported\n");
  exit(exit_code);
}


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)
movl   $0x0,-0x1c(%rbp)
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1050 <getrlimit@plt>
mov    -0x18(%rbp),%rax
mov    %eax,%esi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1050 <getrlimit@plt>
mov    -0x18(%rbp),%rax
mov    %eax,%esi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1050 <getrlimit@plt>
mov    -0x18(%rbp),%rax
mov    %eax,%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e9c(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <getrlimit@plt>
mov    0x8(%rsp),%esi
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
call   1060 <getrlimit@plt>
mov    0x8(%rsp),%esi
lea    0xe85(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
call   1060 <getrlimit@plt>
mov    0x8(%rsp),%esi
lea    0xe71(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe73(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.rlimit = type { i64 }
@RLIMIT_CORE = global i32 0
@.str = [14 x i8] c"USER_CORE=%d\0A\00"
@RLIMIT_FSIZE = global i32 0
@.str.1 = [15 x i8] c"USER_FSIZE=%d\0A\00"
@RLIMIT_NOFILE = global i32 0
@.str.2 = [16 x i8] c"USER_NOFILE=%d\0A\00"
@.str.3 = [24 x i8] c"USER_NPROC unsupported\0A\00"
@.str.4 = [24 x i8] c"USER_STACK unsupported\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.rlimit
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%8 = load i32, i32* @RLIMIT_CORE
%9 = call i32 @getrlimit(i32 %8, %struct.rlimit* %6)
%10 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i32 0, i32 0
%11 = load i64, i64* %10
%12 = trunc i64 %11 to i32
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @RLIMIT_FSIZE
%15 = call i32 @getrlimit(i32 %14, %struct.rlimit* %6)
%16 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i32 0, i32 0
%17 = load i64, i64* %16
%18 = trunc i64 %17 to i32
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = load i32, i32* @RLIMIT_NOFILE
%21 = call i32 @getrlimit(i32 %20, %struct.rlimit* %6)
%22 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i32 0, i32 0
%23 = load i64, i64* %22
%24 = trunc i64 %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%28 = load i32, i32* %7
%29 = call i32 @exit(i32 %28)
unreachable
}

LLVM IR (-O2):
%struct.rlimit = type { i64 }
@RLIMIT_CORE = global i32 0
@.str = [14 x i8] c"USER_CORE=%d\0A\00"
@RLIMIT_FSIZE = global i32 0
@.str.1 = [15 x i8] c"USER_FSIZE=%d\0A\00"
@RLIMIT_NOFILE = global i32 0
@.str.2 = [16 x i8] c"USER_NOFILE=%d\0A\00"
@str = [23 x i8] c"USER_NPROC unsupported\00"
@str.5 = [23 x i8] c"USER_STACK unsupported\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.rlimit
%4 = bitcast %struct.rlimit* %3 to i8*
%5 = load i32, i32* @RLIMIT_CORE
%6 = call i32 @getrlimit(i32 %5, %struct.rlimit* %3)
%7 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i64 0, i32 0
%8 = load i64, i64* %7
%9 = trunc i64 %8 to i32
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i32, i32* @RLIMIT_FSIZE
%12 = call i32 @getrlimit(i32 %11, %struct.rlimit* %3)
%13 = load i64, i64* %7
%14 = trunc i64 %13 to i32
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i32, i32* @RLIMIT_NOFILE
%17 = call i32 @getrlimit(i32 %16, %struct.rlimit* %3)
%18 = load i64, i64* %7
%19 = trunc i64 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.5, i64 0, i64 0))
%23 = call i32 @exit(i32 0)
unreachable
}