#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 /*<<< orphan*/ ETIME;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ do_fork_exec(char **, int /*<<< orphan*/ *, int);
void test_do_fork_exec(int argc, char *argv[]) {
  char *test_argv[3] = {NULL, NULL, NULL};
  test_argv[0] = argv[0];
  test_argv[1] = "1";
  assert(do_fork_exec(test_argv, NULL, 500) == -ETIME);
  assert(do_fork_exec(test_argv, NULL, 1500) == 0);
}


x86 assembly (clang, -O0):
<test_do_fork_exec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
lea    0xe9f(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x1f4,%edx
call   1050 <do_fork_exec@plt>
xor    %ecx,%ecx
mov    0x2e68(%rip),%rdx
sub    (%rdx),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x5dc,%edx
call   1050 <do_fork_exec@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_do_fork_exec>:
push   %rbx
sub    $0x20,%rsp
movq   $0x0,0x10(%rsp)
mov    (%rsi),%rax
mov    %rax,(%rsp)
lea    0xec4(%rip),%rax
mov    %rax,0x8(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1f4,%edx
call   1040 <do_fork_exec@plt>
mov    0x2e8e(%rip),%rcx
xor    %edi,%edi
add    (%rcx),%eax
sete   %dil
call   1030 <assert@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x5dc,%edx
call   1040 <do_fork_exec@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"1\00"
@ETIME = global i32 0
define void @test_do_fork_exec(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [3 x i8*]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = bitcast [3 x i8*]* %5 to i8*
%7 = load i8**, i8*** %4
%8 = getelementptr inbounds i8*, i8** %7, i64 0
%9 = load i8*, i8** %8
%10 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 0
store i8* %9, i8** %10
%11 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 0
%13 = call i32 @do_fork_exec(i8** %12, i32* null, i32 500)
%14 = load i32, i32* @ETIME
%15 = sub nsw i32 0, %14
%16 = icmp eq i32 %13, %15
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 0
%20 = call i32 @do_fork_exec(i8** %19, i32* null, i32 1500)
%21 = icmp eq i32 %20, 0
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"1\00"
@ETIME = global i32 0
define void @test_do_fork_exec(i32 %0, i8** nocapture %1) {
%3 = alloca [3 x i8*]
%4 = bitcast [3 x i8*]* %3 to i8*
%5 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 2
%6 = bitcast i8** %5 to i64*
store i64 0, i64* %6
%7 = load i8*, i8** %1
%8 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 0
store i8* %7, i8** %8
%9 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %9
%10 = call i32 @do_fork_exec(i8** %8, i32* null, i32 500)
%11 = load i32, i32* @ETIME
%12 = sub nsw i32 0, %11
%13 = icmp eq i32 %10, %12
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = call i32 @do_fork_exec(i8** %8, i32* null, i32 1500)
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
ret void
}