#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_CPU;
int /*<<< orphan*/ RLIMIT_FSIZE;
int /*<<< orphan*/ RLIMIT_MEMLOCK;
int /*<<< orphan*/ RLIMIT_NOFILE;
int /*<<< orphan*/ RLIMIT_NPROC;
int /*<<< orphan*/ RLIMIT_STACK;
int /*<<< orphan*/ alarm(int);
int /*<<< orphan*/ execvp(char *, char **);
int /*<<< orphan*/ setrlimit(int /*<<< orphan*/, struct rlimit *);
int main(int argc, char *argv[]) {
  struct rlimit limit;
  limit.rlim_cur = 4;
  limit.rlim_max = 4;
  setrlimit(RLIMIT_CPU, &limit);
  limit.rlim_cur = 512;
  limit.rlim_max = 512;
  setrlimit(RLIMIT_NPROC, &limit);
  limit.rlim_cur = 512;
  limit.rlim_max = 512;
  setrlimit(RLIMIT_NOFILE, &limit);
  limit.rlim_cur = 65535;
  limit.rlim_max = 65535;
  setrlimit(RLIMIT_FSIZE, &limit);
  setrlimit(RLIMIT_MEMLOCK, &limit);
  setrlimit(RLIMIT_STACK, &limit);
  alarm(8);
  execvp(argv[1], &argv[1]);
  return 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)
movl   $0x4,-0x18(%rbp)
movl   $0x4,-0x14(%rbp)
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1040 <setrlimit@plt>
movl   $0x200,-0x18(%rbp)
movl   $0x200,-0x14(%rbp)
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1040 <setrlimit@plt>
movl   $0x200,-0x18(%rbp)
movl   $0x200,-0x14(%rbp)
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1040 <setrlimit@plt>
movl   $0xffff,-0x18(%rbp)
movl   $0xffff,-0x14(%rbp)
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1040 <setrlimit@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1040 <setrlimit@plt>
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1040 <setrlimit@plt>
mov    $0x8,%edi
call   1030 <alarm@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1050 <execvp@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
movabs $0x400000004,%rax
mov    %rax,0x8(%rsp)
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%r14
mov    %r14,%rsi
call   1040 <setrlimit@plt>
movabs $0x20000000200,%r15
mov    %r15,0x8(%rsp)
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
call   1040 <setrlimit@plt>
mov    %r15,0x8(%rsp)
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
call   1040 <setrlimit@plt>
movabs $0xffff0000ffff,%rax
mov    %rax,0x8(%rsp)
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
call   1040 <setrlimit@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
call   1040 <setrlimit@plt>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
call   1040 <setrlimit@plt>
mov    $0x8,%edi
call   1030 <alarm@plt>
mov    0x8(%rbx),%rdi
add    $0x8,%rbx
mov    %rbx,%rsi
call   1050 <execvp@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.rlimit = type { i32, i32 }
@RLIMIT_CPU = global i32 0
@RLIMIT_NPROC = global i32 0
@RLIMIT_NOFILE = global i32 0
@RLIMIT_FSIZE = global i32 0
@RLIMIT_MEMLOCK = global i32 0
@RLIMIT_STACK = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.rlimit
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i32 0, i32 0
store i32 4, i32* %7
%8 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i32 0, i32 1
store i32 4, i32* %8
%9 = load i32, i32* @RLIMIT_CPU
%10 = call i32 @setrlimit(i32 %9, %struct.rlimit* %6)
%11 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i32 0, i32 0
store i32 512, i32* %11
%12 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i32 0, i32 1
store i32 512, i32* %12
%13 = load i32, i32* @RLIMIT_NPROC
%14 = call i32 @setrlimit(i32 %13, %struct.rlimit* %6)
%15 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i32 0, i32 0
store i32 512, i32* %15
%16 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i32 0, i32 1
store i32 512, i32* %16
%17 = load i32, i32* @RLIMIT_NOFILE
%18 = call i32 @setrlimit(i32 %17, %struct.rlimit* %6)
%19 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i32 0, i32 0
store i32 65535, i32* %19
%20 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i32 0, i32 1
store i32 65535, i32* %20
%21 = load i32, i32* @RLIMIT_FSIZE
%22 = call i32 @setrlimit(i32 %21, %struct.rlimit* %6)
%23 = load i32, i32* @RLIMIT_MEMLOCK
%24 = call i32 @setrlimit(i32 %23, %struct.rlimit* %6)
%25 = load i32, i32* @RLIMIT_STACK
%26 = call i32 @setrlimit(i32 %25, %struct.rlimit* %6)
%27 = call i32 @alarm(i32 8)
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = call i32 @execvp(i8* %30, i8** %32)
ret i32 0
}

LLVM IR (-O2):
%struct.rlimit = type { i32, i32 }
@RLIMIT_CPU = global i32 0
@RLIMIT_NPROC = global i32 0
@RLIMIT_NOFILE = global i32 0
@RLIMIT_FSIZE = global i32 0
@RLIMIT_MEMLOCK = global i32 0
@RLIMIT_STACK = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.rlimit
%4 = bitcast %struct.rlimit* %3 to i8*
%5 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i64 0, i32 0
store i32 4, i32* %5
%6 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i64 0, i32 1
store i32 4, i32* %6
%7 = load i32, i32* @RLIMIT_CPU
%8 = call i32 @setrlimit(i32 %7, %struct.rlimit* %3)
store i32 512, i32* %5
store i32 512, i32* %6
%9 = load i32, i32* @RLIMIT_NPROC
%10 = call i32 @setrlimit(i32 %9, %struct.rlimit* %3)
store i32 512, i32* %5
store i32 512, i32* %6
%11 = load i32, i32* @RLIMIT_NOFILE
%12 = call i32 @setrlimit(i32 %11, %struct.rlimit* %3)
store i32 65535, i32* %5
store i32 65535, i32* %6
%13 = load i32, i32* @RLIMIT_FSIZE
%14 = call i32 @setrlimit(i32 %13, %struct.rlimit* %3)
%15 = load i32, i32* @RLIMIT_MEMLOCK
%16 = call i32 @setrlimit(i32 %15, %struct.rlimit* %3)
%17 = load i32, i32* @RLIMIT_STACK
%18 = call i32 @setrlimit(i32 %17, %struct.rlimit* %3)
%19 = call i32 @alarm(i32 8)
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @execvp(i8* %21, i8** %20)
ret i32 0
}