#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 rlim_cur;
  int rlim_max;
};

/* Variables and functions */
int /*<<< orphan*/ RLIMIT_CORE;
void *RLIM_INFINITY;
int getrlimit(int /*<<< orphan*/, struct rlimit *);
int /*<<< orphan*/ printf(char *, int, int, int);
int setrlimit(int /*<<< orphan*/, struct rlimit *);
int main(void) {
  int ret;
  struct rlimit rlim;
  ret = getrlimit(RLIMIT_CORE, &rlim);
  printf("RLIMIT_CORE returned %d (%d, %d)\n", ret, rlim.rlim_cur,
         rlim.rlim_max);
  rlim.rlim_cur = RLIM_INFINITY;
  rlim.rlim_max = RLIM_INFINITY;
  ret = setrlimit(RLIMIT_CORE, &rlim);
  printf("RLIMIT_CORE returned %d (%d, %d)\n", ret, rlim.rlim_cur,
         rlim.rlim_max);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
call   1050 <getrlimit@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e68(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x10(%rbp)
mov    0x2e5b(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0xc(%rbp)
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
call   1040 <setrlimit@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2ea8(%rip),%r15
mov    (%r15),%edi
lea    0x8(%rsp),%r14
mov    %r14,%rsi
call   1050 <getrlimit@plt>
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%ecx
lea    0xea1(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x2e68(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
mov    %eax,0xc(%rsp)
mov    (%r15),%edi
mov    %r14,%rsi
call   1040 <setrlimit@plt>
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%ecx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.rlimit = type { i32, i32 }
@RLIMIT_CORE = global i32 0
@.str = [34 x i8] c"RLIMIT_CORE returned %d (%d, %d)\0A\00"
@RLIM_INFINITY = global i8* null
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.rlimit
store i32 0, i32* %1
%4 = load i32, i32* @RLIMIT_CORE
%5 = call i32 @getrlimit(i32 %4, %struct.rlimit* %3)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i32 0, i32 0
%8 = load i32, i32* %7
%9 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i32 0, i32 1
%10 = load i32, i32* %9
%11 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %8, i32 %10)
%12 = load i8*, i8** @RLIM_INFINITY
%13 = ptrtoint i8* %12 to i32
%14 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i32 0, i32 0
store i32 %13, i32* %14
%15 = load i8*, i8** @RLIM_INFINITY
%16 = ptrtoint i8* %15 to i32
%17 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i32 0, i32 1
store i32 %16, i32* %17
%18 = load i32, i32* @RLIMIT_CORE
%19 = call i32 @setrlimit(i32 %18, %struct.rlimit* %3)
store i32 %19, i32* %2
%20 = load i32, i32* %2
%21 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i32 0, i32 0
%22 = load i32, i32* %21
%23 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i32 0, i32 1
%24 = load i32, i32* %23
%25 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %22, i32 %24)
ret i32 0
}

LLVM IR (-O2):
%struct.rlimit = type { i32, i32 }
@RLIMIT_CORE = global i32 0
@.str = [34 x i8] c"RLIMIT_CORE returned %d (%d, %d)\0A\00"
@RLIM_INFINITY = global i8* null
define i32 @main() {
%1 = alloca %struct.rlimit
%2 = bitcast %struct.rlimit* %1 to i8*
%3 = load i32, i32* @RLIMIT_CORE
%4 = call i32 @getrlimit(i32 %3, %struct.rlimit* %1)
%5 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i64 0, i32 0
%6 = load i32, i32* %5
%7 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i64 0, i32 1
%8 = load i32, i32* %7
%9 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %6, i32 %8)
%10 = load i8*, i8** @RLIM_INFINITY
%11 = ptrtoint i8* %10 to i64
%12 = trunc i64 %11 to i32
store i32 %12, i32* %5
store i32 %12, i32* %7
%13 = load i32, i32* @RLIMIT_CORE
%14 = call i32 @setrlimit(i32 %13, %struct.rlimit* %1)
%15 = load i32, i32* %5
%16 = load i32, i32* %7
%17 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %15, i32 %16)
ret i32 0
}