#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;
};

/* Variables and functions */
int /*<<< orphan*/ RLIMIT_STACK;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, unsigned long, int, int);
int getrlimit(int /*<<< orphan*/, struct rlimit *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  struct rlimit limit;
  int rc;
  rc = getrlimit(RLIMIT_STACK, &limit);
  if (rc != 0)
    exit(0);
  if (limit.rlim_cur < (384 * 1024 * sizeof(long))) {
    fprintf(stderr,
            "\nThe current stack size limit is too low (%luk)\n"
            "You must increase it with one of the following commands:\n"
            "Under sh, bash, zsh:  ulimit -s %lu\n"
            "Under csh, tcsh:      limit stacksize %lu\n\n",
            (unsigned long)(limit.rlim_cur / 1024),
            (384 * 1024 * sizeof(long)) / 1024,
            (384 * 1024 * sizeof(long)) / 1024);
    exit(3);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1050 <getrlimit@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     116c <main+0x3c>
xor    %edi,%edi
call   1040 <exit@plt>
movslq -0x18(%rbp),%rax
cmp    $0x300000,%rax
jae    11b2 <main+0x82>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
movslq %eax,%rdx
lea    0xe66(%rip),%rsi
mov    $0xc00,%r8d
mov    %r8d,%ecx
call   1030 <fprintf@plt>
mov    $0x3,%edi
call   1040 <exit@plt>
xor    %edi,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2ea0(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1050 <getrlimit@plt>
test   %eax,%eax
jne    1180 <main+0x50>
mov    (%rsp),%edx
cmp    $0x2fffff,%rdx
ja     1180 <main+0x50>
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
shr    $0xa,%rdx
lea    0xe9a(%rip),%rsi
mov    $0xc00,%ecx
mov    $0xc00,%r8d
call   1030 <fprintf@plt>
mov    $0x3,%edi
call   1040 <exit@plt>
xor    %edi,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
%struct.rlimit = type { i32 }
@RLIMIT_STACK = global i32 0
@stderr = global i32 0
@.str = [185 x i8] c"\0AThe current stack size limit is too low (%luk)\0AYou must increase it with one of the following commands:\0AUnder sh, bash, zsh: ulimit -s %lu\0AUnder csh, tcsh: limit stacksize %lu\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.rlimit
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* @RLIMIT_STACK
%9 = call i32 @getrlimit(i32 %8, %struct.rlimit* %6)
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @exit(i32 0)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i32 0, i32 0
%16 = load i32, i32* %15
%17 = sext i32 %16 to i64
%18 = icmp ult i64 %17, 3145728
br i1 %18, label %19, label %27
19: ; preds = %14
%20 = load i32, i32* @stderr
%21 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i32 0, i32 0
%22 = load i32, i32* %21
%23 = sdiv i32 %22, 1024
%24 = sext i32 %23 to i64
%25 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([185 x i8], [185 x i8]* @.str, i64 0, i64 0), i64 %24, i32 3072, i32 3072)
%26 = call i32 @exit(i32 3)
unreachable
27: ; preds = %14
%28 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.rlimit = type { i32 }
@RLIMIT_STACK = global i32 0
@stderr = global i32 0
@.str = [185 x i8] c"\0AThe current stack size limit is too low (%luk)\0AYou must increase it with one of the following commands:\0AUnder sh, bash, zsh: ulimit -s %lu\0AUnder csh, tcsh: limit stacksize %lu\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.rlimit
%4 = bitcast %struct.rlimit* %3 to i8*
%5 = load i32, i32* @RLIMIT_STACK
%6 = call i32 @getrlimit(i32 %5, %struct.rlimit* %3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = call i32 @exit(i32 0)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i64 0, i32 0
%12 = load i32, i32* %11
%13 = icmp ult i32 %12, 3145728
br i1 %13, label %14, label %20
14: ; preds = %10
%15 = load i32, i32* @stderr
%16 = lshr i32 %12, 10
%17 = zext i32 %16 to i64
%18 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([185 x i8], [185 x i8]* @.str, i64 0, i64 0), i64 %17, i32 3072, i32 3072)
%19 = call i32 @exit(i32 3)
unreachable
20: ; preds = %10
%21 = call i32 @exit(i32 0)
unreachable
}