#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 */
scalar_t__ EINVAL;
scalar_t__ ENOSYS;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int parrot_timeout(char const *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int main(int argc, char *argv[]) {
  const char *buf;
  int result;
  if (argc < 2) {
    buf = NULL;
  } else {
    buf = argv[1];
  }
  if (argc > 2 || (buf && buf[0] == '-')) {
    printf("use: parrot_timeout [time]\n");
    return 0;
  }
  result = parrot_timeout(buf);
  if (result < 0) {
    if (errno == ENOSYS || errno == EINVAL)
      fprintf(stderr,
              "timeout: This filesystem doesn't support parrot_timeout\n");
    else
      fprintf(stderr, "timeout: %s\n", strerror(errno));
    return 1;
  } else {
    printf("timeout set to %d seconds\n", result);
  }
  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   $0x2,-0x8(%rbp)
jge    116d <main+0x2d>
movq   $0x0,-0x18(%rbp)
jmp    1179 <main+0x39>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jg     119e <main+0x5e>
cmpq   $0x0,-0x18(%rbp)
je     11b8 <main+0x78>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11b8 <main+0x78>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1271 <main+0x131>
mov    -0x18(%rbp),%rdi
call   1040 <parrot_timeout@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1259 <main+0x119>
mov    0x2dfb(%rip),%rax
mov    (%rax),%rax
mov    0x2e09(%rip),%rcx
cmp    (%rcx),%rax
je     1202 <main+0xc2>
mov    0x2de1(%rip),%rax
mov    (%rax),%rax
mov    0x2dcf(%rip),%rcx
cmp    (%rcx),%rax
jne    121e <main+0xde>
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
lea    0xe0a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    124d <main+0x10d>
mov    0x2db3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2d9f(%rip),%rax
mov    (%rax),%rdi
call   1060 <strerror@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%rdx
lea    0xe0f(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1271 <main+0x131>
mov    -0x1c(%rbp),%esi
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jge    1175 <main+0x25>
xor    %edi,%edi
call   1050 <parrot_timeout@plt>
test   %eax,%eax
js     1195 <main+0x45>
lea    0xede(%rip),%rdi
xor    %ebx,%ebx
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ef <main+0x9f>
jne    1185 <main+0x35>
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     1156 <main+0x6>
cmpb   $0x2d,(%rdi)
jne    1158 <main+0x8>
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
jmp    11ef <main+0x9f>
mov    0x2e34(%rip),%rax
mov    (%rax),%rdi
mov    0x2e42(%rip),%rax
mov    0x2e2b(%rip),%rcx
mov    (%rcx),%ebx
cmp    (%rax),%rdi
je     11da <main+0x8a>
mov    0x2e0d(%rip),%rax
cmp    (%rax),%rdi
je     11da <main+0x8a>
call   1070 <strerror@plt>
lea    0xe6d(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    11ea <main+0x9a>
lea    0xe1f(%rip),%rsi
mov    %ebx,%edi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"use: parrot_timeout [time]\0A\00"
@errno = global i64 0
@ENOSYS = global i64 0
@EINVAL = global i64 0
@stderr = global i32 0
@.str.1 = [57 x i8] c"timeout: This filesystem doesn't support parrot_timeout\0A\00"
@.str.2 = [13 x i8] c"timeout: %s\0A\00"
@.str.3 = [27 x i8] c"timeout set to %d seconds\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %11
10: ; preds = %2
store i8* null, i8** %6
br label %15
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
store i8* %14, i8** %6
br label %15
15: ; preds = %11, %10
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 2
br i1 %17, label %27, label %18
18: ; preds = %15
%19 = load i8*, i8** %6
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %29
21: ; preds = %18
%22 = load i8*, i8** %6
%23 = getelementptr inbounds i8, i8* %22, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 45
br i1 %26, label %27, label %29
27: ; preds = %21, %15
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %55
29: ; preds = %21, %18
%30 = load i8*, i8** %6
%31 = call i32 @parrot_timeout(i8* %30)
store i32 %31, i32* %7
%32 = load i32, i32* %7
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %51
34: ; preds = %29
%35 = load i64, i64* @errno
%36 = load i64, i64* @ENOSYS
%37 = icmp eq i64 %35, %36
br i1 %37, label %42, label %38
38: ; preds = %34
%39 = load i64, i64* @errno
%40 = load i64, i64* @EINVAL
%41 = icmp eq i64 %39, %40
br i1 %41, label %42, label %45
42: ; preds = %38, %34
%43 = load i32, i32* @stderr
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
br label %50
45: ; preds = %38
%46 = load i32, i32* @stderr
%47 = load i64, i64* @errno
%48 = call i8* @strerror(i64 %47)
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %48)
br label %50
50: ; preds = %45, %42
store i32 1, i32* %3
br label %55
51: ; preds = %29
%52 = load i32, i32* %7
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %52)
br label %54
54: ; preds = %51
store i32 0, i32* %3
br label %55
55: ; preds = %54, %50, %27
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@errno = global i64 0
@ENOSYS = global i64 0
@EINVAL = global i64 0
@stderr = global i32 0
@.str.1 = [57 x i8] c"timeout: This filesystem doesn't support parrot_timeout\0A\00"
@.str.2 = [13 x i8] c"timeout: %s\0A\00"
@.str.3 = [27 x i8] c"timeout set to %d seconds\0A\00"
@str = [27 x i8] c"use: parrot_timeout [time]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %15, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = icmp eq i32 %0, 2
br i1 %7, label %8, label %13
8: ; preds = %4
%9 = icmp eq i8* %6, null
br i1 %9, label %15, label %10
10: ; preds = %8
%11 = load i8, i8* %6
%12 = icmp eq i8 %11, 45
br i1 %12, label %13, label %15
13: ; preds = %10, %4
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %34
15: ; preds = %2, %10, %8
%16 = phi i8* [ %6, %10 ], [ null, %8 ], [ null, %2 ]
%17 = tail call i32 @parrot_timeout(i8* %16)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %32
19: ; preds = %15
%20 = load i64, i64* @errno
%21 = load i64, i64* @ENOSYS
%22 = icmp eq i64 %20, %21
%23 = load i64, i64* @EINVAL
%24 = icmp eq i64 %20, %23
%25 = select i1 %22, i1 true, i1 %24
%26 = load i32, i32* @stderr
br i1 %25, label %27, label %29
27: ; preds = %19
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
br label %34
29: ; preds = %19
%30 = tail call i8* @strerror(i64 %20)
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %30)
br label %34
32: ; preds = %15
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %17)
br label %34
34: ; preds = %27, %29, %32, %13
%35 = phi i32 [ 0, %13 ], [ 0, %32 ], [ 1, %29 ], [ 1, %27 ]
ret i32 %35
}