#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 scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ execvp(char *, char **);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ sprintf(char *, char *, double);
int /*<<< orphan*/ stderr;
int spawn(char *program, char **arg_list, int id, double t1) {
  arg_list[0] = program;
  char id_str[3];
  sprintf(id_str, "%d", id);
  char start_time[17];
  sprintf(start_time, "%f", t1);
  arg_list[2] = start_time;
  arg_list[4] = id_str;
  pid_t child_pid;
  child_pid = fork();
  if (child_pid != 0)
    return child_pid;
  else {
    execvp(program, arg_list);
    fprintf(stderr, "an error occurred in execvp\n");
    abort();
  }
}


x86 assembly (clang, -O0):
<spawn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
lea    -0x23(%rbp),%rdi
cvtsi2sdl -0x14(%rbp),%xmm0
lea    0xe7d(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x40(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
lea    0xe6b(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x40(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x10(%rax)
lea    -0x23(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x20(%rax)
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     11d5 <spawn+0x85>
mov    -0x48(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <execvp@plt>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
lea    0xe14(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>

x86 assembly (clang, -O2):
<spawn>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rdi,(%rsi)
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
lea    0xe88(%rip),%rsi
lea    0x5(%rsp),%r15
mov    %r15,%rdi
call   1060 <sprintf@plt>
lea    0xe77(%rip),%rsi
lea    0x10(%rsp),%r12
mov    %r12,%rdi
movsd  0x8(%rsp),%xmm0
call   1060 <sprintf@plt>
mov    %r12,0x10(%rbx)
mov    %r15,0x20(%rbx)
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
je     11bf <spawn+0x6f>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <execvp@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xe2c(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%f\00"
@stderr = global i32 0
@.str.2 = [29 x i8] c"an error occurred in execvp\0A\00"
define i32 @spawn(i8* %0, i8** %1, i32 %2, double %3) {
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32
%8 = alloca double
%9 = alloca [3 x i8]
%10 = alloca [17 x i8]
%11 = alloca i64
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
store double %3, double* %8
%12 = load i8*, i8** %5
%13 = load i8**, i8*** %6
%14 = getelementptr inbounds i8*, i8** %13, i64 0
store i8* %12, i8** %14
%15 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
%16 = load i32, i32* %7
%17 = sitofp i32 %16 to double
%18 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), double %17)
%19 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 0
%20 = load double, double* %8
%21 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), double %20)
%22 = getelementptr inbounds [17 x i8], [17 x i8]* %10, i64 0, i64 0
%23 = load i8**, i8*** %6
%24 = getelementptr inbounds i8*, i8** %23, i64 2
store i8* %22, i8** %24
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
%26 = load i8**, i8*** %6
%27 = getelementptr inbounds i8*, i8** %26, i64 4
store i8* %25, i8** %27
%28 = call i64 (...) @fork()
store i64 %28, i64* %11
%29 = load i64, i64* %11
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %4
%32 = load i64, i64* %11
%33 = trunc i64 %32 to i32
ret i32 %33
34: ; preds = %4
%35 = load i8*, i8** %5
%36 = load i8**, i8*** %6
%37 = call i32 @execvp(i8* %35, i8** %36)
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%40 = call i32 (...) @abort()
unreachable
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%f\00"
@stderr = global i32 0
@.str.2 = [29 x i8] c"an error occurred in execvp\0A\00"
define i32 @spawn(i8* %0, i8** %1, i32 %2, double %3) {
%5 = alloca [3 x i8]
%6 = alloca [17 x i8]
store i8* %0, i8** %1
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%8 = sitofp i32 %2 to double
%9 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), double %8)
%10 = getelementptr inbounds [17 x i8], [17 x i8]* %6, i64 0, i64 0
%11 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), double %3)
%12 = getelementptr inbounds i8*, i8** %1, i64 2
store i8* %10, i8** %12
%13 = getelementptr inbounds i8*, i8** %1, i64 4
store i8* %7, i8** %13
%14 = call i64 (...) @fork()
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %4
%17 = trunc i64 %14 to i32
ret i32 %17
18: ; preds = %4
%19 = call i32 @execvp(i8* %0, i8** %1)
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 (...) @abort()
unreachable
}