#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ gimme(unsigned long);
int loop();
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ sleep(int);
unsigned long strtoul(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  unsigned long target;
  switch (argc) {
  case 1:
    puts("Just keep entering how much memory you'd like, in megabytes:");
    return loop();
  case 2:
    target = strtoul(argv[1], NULL, 0);
    if (!target) {
      usage(argv[0]);
      return EXIT_FAILURE;
    }
    gimme(target);
    sleep(3600);
    puts("Timing out");
    return EXIT_SUCCESS;
  default:
    usage(argv[0]);
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}


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    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x1,%eax
je     119b <main+0x3b>
jmp    118a <main+0x2a>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
je     11b6 <main+0x56>
jmp    1225 <main+0xc5>
lea    0xe5e(%rip),%rdi
call   1030 <puts@plt>
mov    $0x0,%al
call   1040 <loop@plt>
mov    %eax,-0x4(%rbp)
jmp    123d <main+0xdd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1060 <strtoul@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f5 <main+0x95>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usage@plt>
mov    0x2df5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    123d <main+0xdd>
mov    -0x18(%rbp),%rdi
call   1070 <gimme@plt>
mov    $0xe10,%edi
call   1080 <sleep@plt>
lea    0xe2e(%rip),%rdi
call   1030 <puts@plt>
mov    0x2dbd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    123d <main+0xdd>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usage@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
je     1182 <main+0x22>
cmp    $0x1,%edi
jne    11bb <main+0x5b>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
jmp    1040 <loop@plt>
mov    0x8(%rbx),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <strtoul@plt>
test   %rax,%rax
je     11bb <main+0x5b>
mov    %rax,%rdi
call   1070 <gimme@plt>
mov    $0xe10,%edi
call   1080 <sleep@plt>
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e1f(%rip),%rax
jmp    11ca <main+0x6a>
mov    (%rbx),%rdi
call   1050 <usage@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [61 x i8] c"Just keep entering how much memory you'd like, in megabytes:\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [11 x i8] c"Timing out\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
switch i32 %7, label %30 [
i32 1, label %8
i32 2, label %11
]
8: ; preds = %2
%9 = call i32 @puts(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (...) @loop()
store i32 %10, i32* %3
br label %36
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @strtoul(i8* %14, i32* null, i32 0)
store i64 %15, i64* %6
%16 = load i64, i64* %6
%17 = icmp ne i64 %16, 0
br i1 %17, label %24, label %18
18: ; preds = %11
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 @usage(i8* %21)
%23 = load i32, i32* @EXIT_FAILURE
store i32 %23, i32* %3
br label %36
24: ; preds = %11
%25 = load i64, i64* %6
%26 = call i32 @gimme(i64 %25)
%27 = call i32 @sleep(i32 3600)
%28 = call i32 @puts(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%29 = load i32, i32* @EXIT_SUCCESS
store i32 %29, i32* %3
br label %36
30: ; preds = %2
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 0
%33 = load i8*, i8** %32
%34 = call i32 @usage(i8* %33)
%35 = load i32, i32* @EXIT_FAILURE
store i32 %35, i32* %3
br label %36
36: ; preds = %30, %24, %18, %8
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [61 x i8] c"Just keep entering how much memory you'd like, in megabytes:\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [11 x i8] c"Timing out\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %20 [
i32 1, label %3
i32 2, label %6
]
3: ; preds = %2
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 (...) @loop()
br label %24
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strtoul(i8* nocapture %8, i32* null, i32 0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %6
%12 = load i8*, i8** %1
%13 = tail call i32 @usage(i8* %12)
%14 = load i32, i32* @EXIT_FAILURE
br label %24
15: ; preds = %6
%16 = tail call i32 @gimme(i64 %9)
%17 = tail call i32 @sleep(i32 3600)
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* @EXIT_SUCCESS
br label %24
20: ; preds = %2
%21 = load i8*, i8** %1
%22 = tail call i32 @usage(i8* %21)
%23 = load i32, i32* @EXIT_FAILURE
br label %24
24: ; preds = %20, %15, %11, %3
%25 = phi i32 [ %23, %20 ], [ %19, %15 ], [ %14, %11 ], [ %5, %3 ]
ret i32 %25
}