#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ show_rlimit(int);
int strtol(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int i;
  if (argc == 1) {
    goto do_all;
  } else {
    i = strtol(argv[1], NULL, 0);
    if (i >= 10) {
      printf("Error resource must be between 0 - %d\n", (10 - 1));
      return (-1);
    }
    show_rlimit(i);
    goto out;
  }
do_all:
  for (i = 0; i < 10; i++) {
    show_rlimit(i);
  }
out:
  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)
cmpl   $0x1,-0x8(%rbp)
jne    1155 <main+0x25>
jmp    119f <main+0x6f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jl     1192 <main+0x62>
lea    0xe84(%rip),%rdi
mov    $0x9,%esi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d2 <main+0xa2>
mov    -0x14(%rbp),%edi
call   1050 <show_rlimit@plt>
jmp    11cb <main+0x9b>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    11c6 <main+0x96>
mov    -0x14(%rbp),%edi
call   1050 <show_rlimit@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a6 <main+0x76>
jmp    11cb <main+0x9b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x1,%edi
jne    1196 <main+0x66>
xor    %ebx,%ebx
xor    %edi,%edi
call   1050 <show_rlimit@plt>
mov    $0x1,%edi
call   1050 <show_rlimit@plt>
mov    $0x2,%edi
call   1050 <show_rlimit@plt>
mov    $0x3,%edi
call   1050 <show_rlimit@plt>
mov    $0x4,%edi
call   1050 <show_rlimit@plt>
mov    $0x5,%edi
call   1050 <show_rlimit@plt>
mov    $0x6,%edi
call   1050 <show_rlimit@plt>
mov    $0x7,%edi
call   1050 <show_rlimit@plt>
mov    $0x8,%edi
call   1050 <show_rlimit@plt>
mov    $0x9,%edi
jmp    11c4 <main+0x94>
mov    0x8(%rsi),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
xor    %edx,%edx
call   1040 <strtol@plt>
cmp    $0xa,%eax
jl     11c2 <main+0x92>
lea    0xe4f(%rip),%rdi
mov    $0x9,%esi
call   1030 <printf@plt>
mov    $0xffffffff,%ebx
jmp    11c9 <main+0x99>
mov    %eax,%edi
call   1050 <show_rlimit@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [39 x i8] c"Error resource must be between 0 - %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %10
9: ; preds = %2
br label %22
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @strtol(i8* %13, i32* null, i32 0)
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = icmp sge i32 %15, 10
br i1 %16, label %17, label %19
17: ; preds = %10
%18 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 9)
store i32 -1, i32* %3
br label %34
19: ; preds = %10
%20 = load i32, i32* %6
%21 = call i32 @show_rlimit(i32 %20)
br label %33
22: ; preds = %9
store i32 0, i32* %6
br label %23
23: ; preds = %29, %22
%24 = load i32, i32* %6
%25 = icmp slt i32 %24, 10
br i1 %25, label %26, label %32
26: ; preds = %23
%27 = load i32, i32* %6
%28 = call i32 @show_rlimit(i32 %27)
br label %29
29: ; preds = %26
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %23
32: ; preds = %23
br label %33
33: ; preds = %32, %19
store i32 0, i32* %3
br label %34
34: ; preds = %33, %17
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@.str = [39 x i8] c"Error resource must be between 0 - %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %15
4: ; preds = %2
%5 = tail call i32 @show_rlimit(i32 0)
%6 = tail call i32 @show_rlimit(i32 1)
%7 = tail call i32 @show_rlimit(i32 2)
%8 = tail call i32 @show_rlimit(i32 3)
%9 = tail call i32 @show_rlimit(i32 4)
%10 = tail call i32 @show_rlimit(i32 5)
%11 = tail call i32 @show_rlimit(i32 6)
%12 = tail call i32 @show_rlimit(i32 7)
%13 = tail call i32 @show_rlimit(i32 8)
%14 = tail call i32 @show_rlimit(i32 9)
br label %24
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 @strtol(i8* nocapture %17, i32* null, i32 0)
%19 = icmp sgt i32 %18, 9
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 9)
br label %24
22: ; preds = %15
%23 = tail call i32 @show_rlimit(i32 %18)
br label %24
24: ; preds = %4, %22, %20
%25 = phi i32 [ -1, %20 ], [ 0, %22 ], [ 0, %4 ]
ret i32 %25
}