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

/* Variables and functions */
int /*<<< orphan*/ err(int, char *, char *);
int /*<<< orphan*/ exeoc_timeout(char **, char *, int *, int /*<<< orphan*/ *,
                                 int);
int /*<<< orphan*/ printf(char *, char *);
int main(void) {
  char buf[1024 * 2 * 2];
  int buflen;
  pid_t pid;
  char *cmd[] = {"execo-timeout.sh", NULL};
  buflen = sizeof(buf);
  if (!exeoc_timeout(cmd, buf, &buflen, &pid, 2))
    err(1, "Unable to run prog: %s", cmd[0]);
  printf("Got buffer:\n===\n%s\n===\n", buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2cc7(%rip),%rax
mov    %rax,-0x1030(%rbp)
mov    0x2cc1(%rip),%rax
mov    %rax,-0x1028(%rbp)
movl   $0x1000,-0x1014(%rbp)
lea    -0x1030(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
lea    -0x1014(%rbp),%rdx
lea    -0x1018(%rbp),%rcx
mov    $0x2,%r8d
call   1040 <exeoc_timeout@plt>
cmp    $0x0,%eax
jne    11b0 <main+0x80>
mov    -0x1030(%rbp),%rdx
mov    $0x1,%edi
lea    0xe66(%rip),%rsi
call   1050 <err@plt>
lea    -0x1010(%rbp),%rsi
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x1028,%rsp
movaps 0x2cd2(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x1000,0x8(%rsp)
lea    0x10(%rsp),%rdi
lea    0x20(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    $0x2,%r8d
call   1040 <exeoc_timeout@plt>
test   %eax,%eax
jne    1184 <main+0x54>
mov    0x10(%rsp),%rdx
lea    0xe97(%rip),%rsi
mov    $0x1,%edi
call   1050 <err@plt>
lea    0xe9d(%rip),%rdi
lea    0x20(%rsp),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1028,%rsp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"execo-timeout.sh\00"
@__const.main.cmd = [2 x i8*] [i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i32 0, i32 0), i8* null]
@.str.1 = [23 x i8] c"Unable to run prog: %s\00"
@.str.2 = [24 x i8] c"Got buffer:\0A===\0A%s\0A===\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4096 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca [2 x i8*]
store i32 0, i32* %1
%6 = bitcast [2 x i8*]* %5 to i8*
store i32 4096, i32* %3
%7 = getelementptr inbounds [2 x i8*], [2 x i8*]* %5, i64 0, i64 0
%8 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%9 = call i32 @exeoc_timeout(i8** %7, i8* %8, i32* %3, i32* %4, i32 2)
%10 = icmp ne i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %0
%12 = getelementptr inbounds [2 x i8*], [2 x i8*]* %5, i64 0, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @err(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %11, %0
%16 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%17 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %16)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"execo-timeout.sh\00"
@__const.main.cmd = [2 x i8*] [i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i32 0, i32 0), i8* null]
@.str.1 = [23 x i8] c"Unable to run prog: %s\00"
@.str.2 = [24 x i8] c"Got buffer:\0A===\0A%s\0A===\0A\00"
define i32 @main() {
%1 = alloca [4096 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = alloca [2 x i8*]
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast [2 x i8*]* %4 to i8*
store i32 4096, i32* %2
%9 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 0
%10 = call i32 @exeoc_timeout(i8** %9, i8* %5, i32* %2, i32* %3, i32 2)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = load i8*, i8** %9
%14 = call i32 @err(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %12, %0
%16 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %5)
ret i32 0
}