#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*/ 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;
  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    -0x18(%rbp),%rsi
call   1060 <getrlimit@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   1050 <setrlimit@plt>
lea    0xe69(%rip),%rdi
call   1040 <print_string@plt>
mov    -0x4(%rbp),%edi
call   1030 <print_rlimit@plt>
lea    0xe5a(%rip),%rdi
call   1040 <print_string@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<maximize_rlimit>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebx
lea    0xeb0(%rip),%rdi
call   1040 <print_string@plt>
mov    %r14,%rdi
call   1040 <print_string@plt>
lea    0xe9f(%rip),%rdi
call   1040 <print_string@plt>
mov    %ebx,%edi
call   1030 <print_rlimit@plt>
mov    %rsp,%r14
mov    %ebx,%edi
mov    %r14,%rsi
call   1060 <getrlimit@plt>
mov    (%rsp),%eax
mov    %eax,0x4(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <setrlimit@plt>
lea    0xe71(%rip),%rdi
call   1040 <print_string@plt>
mov    %ebx,%edi
call   1030 <print_rlimit@plt>
lea    0xe63(%rip),%rdi
call   1040 <print_string@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.rlimit = type { i32, i32 }
@.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 0
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %5, i32 0, i32 1
store i32 %15, i32* %16
%17 = load i32, i32* %3
%18 = call i32 @setrlimit(i32 %17, %struct.rlimit* %5)
%19 = call i32 @print_string(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%20 = load i32, i32* %3
%21 = call i32 @print_rlimit(i32 %20)
%22 = 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 { i32, i32 }
@.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
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i64 0, i32 1
store i32 %11, i32* %12
%13 = call i32 @setrlimit(i32 %0, %struct.rlimit* %3)
%14 = call i32 @print_string(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @print_rlimit(i32 %0)
%16 = call i32 @print_string(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}