#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 {
  void *rlim_max;
  void *rlim_cur;
};

/* Variables and functions */
int /*<<< orphan*/ RLIMIT_CPU;
void *atoi(char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
scalar_t__ setrlimit(int /*<<< orphan*/, struct rlimit *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char **argv) {
  if (argc > 1) {
    struct rlimit cpu;
    cpu.rlim_cur = atoi(argv[1]);
    cpu.rlim_max = atoi(argv[1]);
    if (setrlimit(RLIMIT_CPU, &cpu) < 0) {
      fprintf(stderr, "%s: could not set limit: %s\n", argv[0],
              strerror(errno));
      return 0;
    }
  }
  for (;;) {
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11e6 <main+0xa6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %rax,-0x20(%rbp)
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
call   1040 <setrlimit@plt>
cmp    $0x0,%rax
jge    11e1 <main+0xa1>
mov    0x2e3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rdx
mov    %rax,%rcx
lea    0xe2c(%rip),%rsi
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret
jmp    11e6 <main+0xa6>
jmp    11eb <main+0xab>
jmp    11eb <main+0xab>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jl     1180 <main+0x40>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %rax,0x10(%rsp)
mov    %rax,0x8(%rsp)
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1040 <setrlimit@plt>
test   %rax,%rax
js     1182 <main+0x42>
nopl   0x0(%rax)
jmp    1180 <main+0x40>
mov    0x2e57(%rip),%rax
mov    (%rax),%ebp
mov    (%rbx),%rbx
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe5d(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.rlimit = type { i8*, i8* }
@RLIMIT_CPU = global i32 0
@stderr = global i32 0
@.str = [29 x i8] c"%s: could not set limit: %s\0A\00"
@errno = 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 = load i32, i32* %4
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %32
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i8* @atoi(i8* %12)
%14 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i32 0, i32 1
store i8* %13, i8** %14
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i8* @atoi(i8* %17)
%19 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %6, i32 0, i32 0
store i8* %18, i8** %19
%20 = load i32, i32* @RLIMIT_CPU
%21 = call i64 @setrlimit(i32 %20, %struct.rlimit* %6)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %31
23: ; preds = %9
%24 = load i32, i32* @stderr
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = load i32, i32* @errno
%29 = call i8* @strerror(i32 %28)
%30 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %27, i8* %29)
ret i32 0
31: ; preds = %9
br label %32
32: ; preds = %31, %2
br label %33
33: ; preds = %33, %32
br label %33
}

LLVM IR (-O2):
%struct.rlimit = type { i8*, i8* }
@RLIMIT_CPU = global i32 0
@stderr = global i32 0
@.str = [29 x i8] c"%s: could not set limit: %s\0A\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.rlimit
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %16
5: ; preds = %2
%6 = bitcast %struct.rlimit* %3 to i8*
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i8* @atoi(i8* %8)
%10 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i64 0, i32 1
store i8* %9, i8** %10
%11 = getelementptr inbounds %struct.rlimit, %struct.rlimit* %3, i64 0, i32 0
store i8* %9, i8** %11
%12 = load i32, i32* @RLIMIT_CPU
%13 = call i64 @setrlimit(i32 %12, %struct.rlimit* %3)
%14 = icmp slt i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %5
br label %16
16: ; preds = %15, %2
br label %17
17: ; preds = %16, %17
br label %17
18: ; preds = %5
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %1
%21 = load i32, i32* @errno
%22 = call i8* @strerror(i32 %21)
%23 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %20, i8* %22)
ret i32 0
}