#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 */
struct timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};
typedef int /*<<< orphan*/ pid_t;

/* Variables and functions */
int exeoc_stdselect(char **, char *, int *, int /*<<< orphan*/ *,
                    int /*<<< orphan*/, struct timeval *);
int /*<<< orphan*/ printf(char *);
int exeoc_timeout(char *exeargv[], char documentfinishedbuf[],
                  int *documentfinishedbufsize, pid_t *ret, int timeout) {
  struct timeval tv;
  int n;
  tv.tv_sec = timeout;
  tv.tv_usec = 0;
  n = exeoc_stdselect(exeargv, documentfinishedbuf, documentfinishedbufsize,
                      ret, 0, &tv);
  if (tv.tv_sec == 0 && tv.tv_usec == 0) {
    printf("exeoc_timeout did time out.\n");
    return 0;
  } else {
    return n;
  }
}


x86 assembly (clang, -O0):
<exeoc_timeout>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x40(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
xor    %r8d,%r8d
lea    -0x40(%rbp),%r9
call   1040 <exeoc_stdselect@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x40(%rbp)
jne    1196 <exeoc_timeout+0x76>
cmpq   $0x0,-0x38(%rbp)
jne    1196 <exeoc_timeout+0x76>
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    119c <exeoc_timeout+0x7c>
mov    -0x44(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exeoc_timeout>:
sub    $0x18,%rsp
mov    %r8d,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0x8(%rsp),%r9
xor    %r8d,%r8d
call   1040 <exeoc_stdselect@plt>
cmpl   $0x0,0x8(%rsp)
jne    115c <exeoc_timeout+0x3c>
cmpq   $0x0,0x10(%rsp)
jne    115c <exeoc_timeout+0x3c>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i64 }
@.str = [29 x i8] c"exeoc_timeout did time out.\0A\00"
define i32 @exeoc_timeout(i8** %0, i8* %1, i32* %2, i32* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca %struct.timeval
%13 = alloca i32
store i8** %0, i8*** %7
store i8* %1, i8** %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i32 %4, i32* %11
%14 = load i32, i32* %11
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
store i32 %14, i32* %15
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 1
store i64 0, i64* %16
%17 = load i8**, i8*** %7
%18 = load i8*, i8** %8
%19 = load i32*, i32** %9
%20 = load i32*, i32** %10
%21 = call i32 @exeoc_stdselect(i8** %17, i8* %18, i32* %19, i32* %20, i32 0, %struct.timeval* %12)
store i32 %21, i32* %13
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %5
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 1
%27 = load i64, i64* %26
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %33
31: ; preds = %25, %5
%32 = load i32, i32* %13
store i32 %32, i32* %6
br label %33
33: ; preds = %31, %29
%34 = load i32, i32* %6
ret i32 %34
}

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
@str = [28 x i8] c"exeoc_timeout did time out.\00"
define i32 @exeoc_timeout(i8** %0, i8* %1, i32* %2, i32* %3, i32 %4) {
%6 = alloca %struct.timeval
%7 = bitcast %struct.timeval* %6 to i8*
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 0
store i32 %4, i32* %8
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 1
store i64 0, i64* %9
%10 = call i32 @exeoc_stdselect(i8** %0, i8* %1, i32* %2, i32* %3, i32 0, %struct.timeval* %6)
%11 = load i32, i32* %8
%12 = icmp eq i32 %11, 0
%13 = load i64, i64* %9
%14 = icmp eq i64 %13, 0
%15 = select i1 %12, i1 %14, i1 false
br i1 %15, label %16, label %18
16: ; preds = %5
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %18
18: ; preds = %5, %16
%19 = phi i32 [ 0, %16 ], [ %10, %5 ]
ret i32 %19
}