#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 /*<<< orphan*/ rlim_max;
};

/* Variables and functions */
int /*<<< orphan*/ RLIMIT_NOFILE;
int getrlimit(int /*<<< orphan*/, struct rlimit *);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ setrlimit(int /*<<< orphan*/, struct rlimit *);
int main() {
  int ret;
  struct rlimit rlimt;
  ret = getrlimit(RLIMIT_NOFILE, &rlimt);
  printf("the soft[%lu]\nthe hard[%lu]\n", rlimt.rlim_cur, rlimt.rlim_max);
  rlimt.rlim_cur = 10;
  setrlimit(RLIMIT_NOFILE, &rlimt);
  printf("The soft[%lu]\n", rlimt.rlim_cur);
  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    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xa,-0x10(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
call   1040 <setrlimit@plt>
mov    -0x10(%rbp),%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2ead(%rip),%r14
mov    (%r14),%edi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1050 <getrlimit@plt>
mov    (%rsp),%esi
mov    0x4(%rsp),%edx
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movl   $0xa,(%rsp)
mov    (%r14),%edi
mov    %rbx,%rsi
call   1040 <setrlimit@plt>
mov    (%rsp),%esi
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.rlimit = type { i32, i32 }
@RLIMIT_NOFILE = global i32 0
@.str = [29 x i8] c"the soft[%lu]\0Athe hard[%lu]\0A\00"
@.str.1 = [15 x i8] c"The soft[%lu]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.rlimit
store i32 0, i32* %1
%4 = load i32, i32* @RLIMIT_NOFILE
%5 = call i32 @getrlimit(i32 %4, %struct.rlimit* %3)
store i32 %5, i32* %2
%6 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i32 0, i32 0
%7 = load i32, i32* %6
%8 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i32 0, i32 1
%9 = load i32, i32* %8
%10 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %9)
%11 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i32 0, i32 0
store i32 10, i32* %11
%12 = load i32, i32* @RLIMIT_NOFILE
%13 = call i32 @setrlimit(i32 %12, %struct.rlimit* %3)
%14 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i32 0, i32 0
%15 = load i32, i32* %14
%16 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %15)
ret i32 0
}

LLVM IR (-O2):
%struct.rlimit = type { i32, i32 }
@RLIMIT_NOFILE = global i32 0
@.str = [29 x i8] c"the soft[%lu]\0Athe hard[%lu]\0A\00"
@.str.1 = [15 x i8] c"The soft[%lu]\0A\00"
define i32 @main() {
%1 = alloca %struct.rlimit
%2 = bitcast %struct.rlimit* %1 to i8*
%3 = load i32, i32* @RLIMIT_NOFILE
%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 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %8)
store i32 10, i32* %5
%10 = load i32, i32* @RLIMIT_NOFILE
%11 = call i32 @setrlimit(i32 %10, %struct.rlimit* %1)
%12 = load i32, i32* %5
%13 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %12)
ret i32 0
}