#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;
  scalar_t__ rlim_max;
};
typedef scalar_t__ rlim_t;

/* Variables and functions */
int /*<<< orphan*/ getrlimit(int, struct rlimit *);
int /*<<< orphan*/ print_rlimit(int);
int /*<<< orphan*/ print_string(char const *);
int /*<<< orphan*/ setrlimit(int, struct rlimit *);
void maximize_rlimit(int resource, const char *prefix) {
  struct rlimit rl;
  print_string("  ");
  print_string(prefix);
  print_string(": ");
  print_rlimit(resource);
  getrlimit(resource, &rl);
  rl.rlim_cur = rl.rlim_max;
  if (sizeof(rl.rlim_cur) >= sizeof((1ULL << 34)))
    rl.rlim_cur = (rlim_t)(1ULL << 34);
  setrlimit(resource, &rl);
  print_string(" -> ");
  print_rlimit(resource);
  print_string("\n");
}


x86 assembly (clang, -O0):
<maximize_rlimit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeaa(%rip),%rdi
call   1040 <print_string@plt>
mov    -0x10(%rbp),%rdi
call   1040 <print_string@plt>
lea    0xe98(%rip),%rdi
call   1040 <print_string@plt>
mov    -0x4(%rbp),%edi
call   1030 <print_rlimit@plt>
mov    -0x4(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1060 <getrlimit@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
movabs $0x400000000,%rax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1050 <setrlimit@plt>
lea    0xe59(%rip),%rdi
call   1040 <print_string@plt>
mov    -0x4(%rbp),%edi
call   1030 <print_rlimit@plt>
lea    0xe4a(%rip),%rdi
call   1040 <print_string@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<maximize_rlimit>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %edi,%ebx
lea    0xead(%rip),%rdi
call   1040 <print_string@plt>
mov    %r14,%rdi
call   1040 <print_string@plt>
lea    0xe9c(%rip),%rdi
call   1040 <print_string@plt>
mov    %ebx,%edi
call   1030 <print_rlimit@plt>
lea    0x8(%rsp),%r14
mov    %ebx,%edi
mov    %r14,%rsi
call   1060 <getrlimit@plt>
movabs $0x400000000,%rax
mov    %rax,0x8(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <setrlimit@plt>
lea    0xe64(%rip),%rdi
call   1040 <print_string@plt>
mov    %ebx,%edi
call   1030 <print_rlimit@plt>
lea    0xe56(%rip),%rdi
call   1040 <print_string@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.rlimit = type { i64, i64 }
@.str = [3 x i8] c" \00"
@.str.1 = [3 x i8] c": \00"
@.str.2 = [5 x i8] c" -> \00"
@.str.3 = [2 x i8] c"\0A\00"
define void @maximize_rlimit(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.rlimit
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = call i32 @print_string(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = load i8*, i8** %4
%8 = call i32 @print_string(i8* %7)
%9 = call i32 @print_string(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* %3
%11 = call i32 @print_rlimit(i32 %10)
%12 = load i32, i32* %3
%13 = call i32 @getrlimit(i32 %12, %struct.rlimit* %5)
%14 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %5, i32 0, i32 1
%15 = load i64, i64* %14
%16 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %5, i32 0, i32 0
store i64 %15, i64* %16
%17 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %5, i32 0, i32 0
store i64 17179869184, i64* %17
%18 = load i32, i32* %3
%19 = call i32 @setrlimit(i32 %18, %struct.rlimit* %5)
%20 = call i32 @print_string(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32, i32* %3
%22 = call i32 @print_rlimit(i32 %21)
%23 = call i32 @print_string(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.rlimit = type { i64, i64 }
@.str = [3 x i8] c" \00"
@.str.1 = [3 x i8] c": \00"
@.str.2 = [5 x i8] c" -> \00"
@.str.3 = [2 x i8] c"\0A\00"
define void @maximize_rlimit(i32 %0, i8* %1) {
%3 = alloca %struct.rlimit
%4 = bitcast %struct.rlimit* %3 to i8*
%5 = tail call i32 @print_string(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @print_string(i8* %1)
%7 = tail call i32 @print_string(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @print_rlimit(i32 %0)
%9 = call i32 @getrlimit(i32 %0, %struct.rlimit* %3)
%10 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i64 0, i32 0
store i64 17179869184, i64* %10
%11 = call i32 @setrlimit(i32 %0, %struct.rlimit* %3)
%12 = call i32 @print_string(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @print_rlimit(i32 %0)
%14 = call i32 @print_string(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}