#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*/ member_1;
  int /*<<< orphan*/ member_0;
};

/* Variables and functions */
int /*<<< orphan*/ RLIMIT_STACK;
int /*<<< orphan*/ RLIM_INFINITY;
int /*<<< orphan*/ perror(char *);
int setrlimit(int /*<<< orphan*/, struct rlimit *);
void remove_stack_limit_(void) {
  struct rlimit rlim = {RLIM_INFINITY, RLIM_INFINITY};
  if (setrlimit(RLIMIT_STACK, &rlim) == -1) {
    perror("Cannot set stack size to infinity");
  }
}


x86 assembly (clang, -O0):
<remove_stack_limit_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ea9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
call   1030 <setrlimit@plt>
cmp    $0xffffffff,%eax
jne    1167 <remove_stack_limit_+0x47>
lea    0xe9e(%rip),%rdi
call   1040 <perror@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_stack_limit_>:
push   %rax
mov    0x2eb0(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    %eax,0x4(%rsp)
mov    0x2ea8(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1030 <setrlimit@plt>
cmp    $0xffffffff,%eax
je     1149 <remove_stack_limit_+0x29>
pop    %rax
ret
lea    0xeb0(%rip),%rdi
call   1040 <perror@plt>
pop    %rax
ret

LLVM IR (-O0):
%struct.rlimit = type { i32, i32 }
@RLIM_INFINITY = global i32 0
@RLIMIT_STACK = global i32 0
@.str = [34 x i8] c"Cannot set stack size to infinity\00"
define void @remove_stack_limit_() {
%1 = alloca %struct.rlimit
%2 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i32 0, i32 0
%3 = load i32, i32* @RLIM_INFINITY
store i32 %3, i32* %2
%4 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i32 0, i32 1
%5 = load i32, i32* @RLIM_INFINITY
store i32 %5, i32* %4
%6 = load i32, i32* @RLIMIT_STACK
%7 = call i32 @setrlimit(i32 %6, %struct.rlimit* %1)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %0
ret void
}

LLVM IR (-O2):
%struct.rlimit = type { i32, i32 }
@RLIM_INFINITY = global i32 0
@RLIMIT_STACK = global i32 0
@.str = [34 x i8] c"Cannot set stack size to infinity\00"
define void @remove_stack_limit_() {
%1 = alloca %struct.rlimit
%2 = bitcast %struct.rlimit* %1 to i8*
%3 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i64 0, i32 0
%4 = load i32, i32* @RLIM_INFINITY
store i32 %4, i32* %3
%5 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i64 0, i32 1
store i32 %4, i32* %5
%6 = load i32, i32* @RLIMIT_STACK
%7 = call i32 @setrlimit(i32 %6, %struct.rlimit* %1)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %0
ret void
}