#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 */
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ exit(int);
int read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ sleep(int);
int main(int argc, char **argv) {
  int timeout, outcome;
  char buffer[1];
  if (argc == 1)
    timeout = -1;
  else if (argc == 2)
    timeout = -1;
  else if (argc == 3)
    timeout = atoi(argv[1]);
  else
    exit(101);
  if (timeout == -1) {
    outcome = read(0, buffer, sizeof(buffer));
    if (outcome == 0)
      exit(0);
    else if (outcome > 0)
      exit(101);
    else
      exit(102);
  } else {
    sleep(timeout);
    exit(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    116c <main+0x2c>
movl   $0xffffffff,-0x14(%rbp)
jmp    11b5 <main+0x75>
cmpl   $0x2,-0x8(%rbp)
jne    1182 <main+0x42>
movl   $0xffffffff,-0x14(%rbp)
jmp    11b0 <main+0x70>
cmpl   $0x3,-0x8(%rbp)
jne    11a1 <main+0x61>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    11ab <main+0x6b>
mov    $0x65,%edi
call   1050 <exit@plt>
jmp    11b0 <main+0x70>
jmp    11b5 <main+0x75>
cmpl   $0xffffffff,-0x14(%rbp)
jne    1201 <main+0xc1>
lea    -0x19(%rbp),%rsi
xor    %edi,%edi
mov    $0x1,%edx
call   1030 <read@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    11e3 <main+0xa3>
xor    %edi,%edi
call   1050 <exit@plt>
cmpl   $0x0,-0x18(%rbp)
jle    11f7 <main+0xb7>
mov    $0x65,%edi
call   1050 <exit@plt>
mov    $0x66,%edi
call   1050 <exit@plt>
mov    -0x14(%rbp),%edi
call   1060 <sleep@plt>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    -0x1(%rdi),%eax
cmp    $0x2,%eax
jb     115c <main+0x1c>
cmp    $0x3,%edi
jne    117a <main+0x3a>
mov    0x8(%rsi),%rdi
call   1040 <atoi@plt>
cmp    $0xffffffff,%eax
jne    118e <main+0x4e>
lea    0x7(%rsp),%rsi
xor    %edi,%edi
mov    $0x1,%edx
call   1030 <read@plt>
test   %eax,%eax
jne    1178 <main+0x38>
xor    %edi,%edi
call   1050 <exit@plt>
jle    1184 <main+0x44>
mov    $0x65,%edi
call   1050 <exit@plt>
mov    $0x66,%edi
call   1050 <exit@plt>
mov    %eax,%edi
call   1060 <sleep@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [1 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %6
br label %28
12: ; preds = %2
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 2
br i1 %14, label %15, label %16
15: ; preds = %12
store i32 -1, i32* %6
br label %27
16: ; preds = %12
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 3
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %6
br label %26
24: ; preds = %16
%25 = call i32 @exit(i32 101)
unreachable
26: ; preds = %19
br label %27
27: ; preds = %26, %15
br label %28
28: ; preds = %27, %11
%29 = load i32, i32* %6
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %45
31: ; preds = %28
%32 = getelementptr inbounds [1 x i8], [1 x i8]* %8, i64 0, i64 0
%33 = call i32 @read(i32 0, i8* %32, i32 1)
store i32 %33, i32* %7
%34 = load i32, i32* %7
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %31
%37 = call i32 @exit(i32 0)
unreachable
38: ; preds = %31
%39 = load i32, i32* %7
%40 = icmp sgt i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = call i32 @exit(i32 101)
unreachable
43: ; preds = %38
%44 = call i32 @exit(i32 102)
unreachable
45: ; preds = %28
%46 = load i32, i32* %6
%47 = call i32 @sleep(i32 %46)
%48 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1 x i8]
%4 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
switch i32 %0, label %5 [
i32 1, label %12
i32 2, label %12
i32 3, label %7
]
5: ; preds = %2
%6 = tail call i32 @exit(i32 101)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %23
12: ; preds = %2, %2, %7
%13 = call i32 @read(i32 0, i8* %4, i32 1)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 @exit(i32 0)
unreachable
17: ; preds = %12
%18 = icmp sgt i32 %13, 0
br i1 %18, label %19, label %21
19: ; preds = %17
%20 = tail call i32 @exit(i32 101)
unreachable
21: ; preds = %17
%22 = tail call i32 @exit(i32 102)
unreachable
23: ; preds = %7
%24 = tail call i32 @sleep(i32 %10)
%25 = tail call i32 @exit(i32 0)
unreachable
}