#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_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*/ print_limit(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int main(int argc, char **argv) {
  struct rlimit u_limit;
  int exit_code = 0;
  (void)getrlimit(RLIMIT_CORE, &u_limit);
  print_limit("USER_CORE", u_limit.rlim_cur);
  (void)getrlimit(RLIMIT_FSIZE, &u_limit);
  print_limit("USER_FSIZE", u_limit.rlim_cur);
  (void)getrlimit(RLIMIT_NOFILE, &u_limit);
  print_limit("USER_NOFILE", 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    0x2e84(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1060 <getrlimit@plt>
mov    -0x18(%rbp),%esi
lea    0xe87(%rip),%rdi
call   1040 <print_limit@plt>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1060 <getrlimit@plt>
mov    -0x18(%rbp),%esi
lea    0xe70(%rip),%rdi
call   1040 <print_limit@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1060 <getrlimit@plt>
mov    -0x18(%rbp),%esi
lea    0xe5a(%rip),%rdi
call   1040 <print_limit@plt>
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1050 <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
call   1040 <print_limit@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
call   1060 <getrlimit@plt>
mov    0x8(%rsp),%esi
lea    0xe83(%rip),%rdi
call   1040 <print_limit@plt>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
call   1060 <getrlimit@plt>
mov    0x8(%rsp),%esi
lea    0xe6d(%rip),%rdi
call   1040 <print_limit@plt>
lea    0xe6d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe78(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.rlimit = type { i32 }
@RLIMIT_CORE = global i32 0
@.str = [10 x i8] c"USER_CORE\00"
@RLIMIT_FSIZE = global i32 0
@.str.1 = [11 x i8] c"USER_FSIZE\00"
@RLIMIT_NOFILE = global i32 0
@.str.2 = [12 x i8] c"USER_NOFILE\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 i32, i32* %10
%12 = call i32 @print_limit(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i32, i32* @RLIMIT_FSIZE
%14 = call i32 @getrlimit(i32 %13, %struct.rlimit* %6)
%15 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i32 0, i32 0
%16 = load i32, i32* %15
%17 = call i32 @print_limit(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load i32, i32* @RLIMIT_NOFILE
%19 = call i32 @getrlimit(i32 %18, %struct.rlimit* %6)
%20 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i32 0, i32 0
%21 = load i32, i32* %20
%22 = call i32 @print_limit(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%25 = load i32, i32* %7
%26 = call i32 @exit(i32 %25)
unreachable
}

LLVM IR (-O2):
%struct.rlimit = type { i32 }
@RLIMIT_CORE = global i32 0
@.str = [10 x i8] c"USER_CORE\00"
@RLIMIT_FSIZE = global i32 0
@.str.1 = [11 x i8] c"USER_FSIZE\00"
@RLIMIT_NOFILE = global i32 0
@.str.2 = [12 x i8] c"USER_NOFILE\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 i32, i32* %7
%9 = call i32 @print_limit(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load i32, i32* @RLIMIT_FSIZE
%11 = call i32 @getrlimit(i32 %10, %struct.rlimit* %3)
%12 = load i32, i32* %7
%13 = call i32 @print_limit(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @RLIMIT_NOFILE
%15 = call i32 @getrlimit(i32 %14, %struct.rlimit* %3)
%16 = load i32, i32* %7
%17 = call i32 @print_limit(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.5, i64 0, i64 0))
%20 = call i32 @exit(i32 0)
unreachable
}