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

/* Variables and functions */
int /*<<< orphan*/ RLIMIT_STACK;
int /*<<< orphan*/ abort();
int /*<<< orphan*/ down(int, int, int, int, int, int, int, int, int, int, int);
scalar_t__ setrlimit(int /*<<< orphan*/, struct rlimit *);
int main(void) {
  struct rlimit r;
  r.rlim_cur = 8192 * 1024;
  r.rlim_max = 8192 * 1024;
  if (setrlimit(RLIMIT_STACK, &r) != 0)
    abort();
  down(1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x800000,-0x10(%rbp)
movl   $0x800000,-0xc(%rbp)
mov    0x2e8c(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
call   1050 <setrlimit@plt>
cmp    $0x0,%rax
je     1170 <main+0x40>
mov    $0x0,%al
call   1030 <abort@plt>
mov    $0x3e8,%edi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x3,%ecx
mov    $0x4,%r8d
mov    $0x5,%r9d
movl   $0x6,(%rsp)
movl   $0x7,0x8(%rsp)
movl   $0x8,0x10(%rsp)
movl   $0x9,0x18(%rsp)
movl   $0xa,0x20(%rsp)
call   1040 <down@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movabs $0x80000000800000,%rax
mov    %rax,(%rsp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1050 <setrlimit@plt>
test   %rax,%rax
jne    1190 <main+0x60>
sub    $0x8,%rsp
mov    $0x3e8,%edi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x3,%ecx
mov    $0x4,%r8d
mov    $0x5,%r9d
push   $0xa
push   $0x9
push   $0x8
push   $0x7
push   $0x6
call   1040 <down@plt>
add    $0x30,%rsp
xor    %eax,%eax
pop    %rcx
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.rlimit = type { i32, i32 }
@RLIMIT_STACK = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.rlimit
store i32 0, i32* %1
%3 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %2, i32 0, i32 0
store i32 8388608, i32* %3
%4 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %2, i32 0, i32 1
store i32 8388608, i32* %4
%5 = load i32, i32* @RLIMIT_STACK
%6 = call i64 @setrlimit(i32 %5, %struct.rlimit* %2)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 (...) @abort()
unreachable
10: ; preds = %0
%11 = call i32 @down(i32 1000, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10)
ret i32 0
}

LLVM IR (-O2):
%struct.rlimit = type { i32, i32 }
@RLIMIT_STACK = global i32 0
define i32 @main() {
%1 = alloca %struct.rlimit
%2 = bitcast %struct.rlimit* %1 to i8*
%3 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i64 0, i32 0
store i32 8388608, i32* %3
%4 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %1, i64 0, i32 1
store i32 8388608, i32* %4
%5 = load i32, i32* @RLIMIT_STACK
%6 = call i64 @setrlimit(i32 %5, %struct.rlimit* %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = call i32 (...) @abort()
unreachable
10: ; preds = %0
%11 = call i32 @down(i32 1000, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10)
ret i32 0
}