#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*/ posix_spawn(int *, char *, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *, char **, char **);
int /*<<< orphan*/ waitpid(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int pid;
  char *args[] = {
      NULL,
      NULL,
  };
  char *envp[] = {"PATH=.", "HOME=/home/user", NULL};
  args[0] = "t-abc";
  posix_spawn(&pid, "t-abc", NULL, NULL, args, envp);
  waitpid(pid, NULL, 0);
  args[0] = "t-openclose";
  posix_spawn(&pid, "t-openclose", NULL, NULL, args, envp);
  waitpid(pid, NULL, 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
mov    0x2ca3(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0x2ca0(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0x2c9d(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe99(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    -0x30(%rbp),%r8
lea    -0x50(%rbp),%r9
lea    -0x14(%rbp),%rdi
lea    0xe82(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1050 <posix_spawn@plt>
mov    -0x14(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1040 <waitpid@plt>
lea    0xe67(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    -0x30(%rbp),%r8
lea    -0x50(%rbp),%r9
lea    -0x14(%rbp),%rdi
lea    0xe50(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1050 <posix_spawn@plt>
mov    -0x14(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1040 <waitpid@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
mov    0x2cd8(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0x2cbc(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
lea    0xec7(%rip),%rsi
mov    %rsi,0x10(%rsp)
lea    0xc(%rsp),%rbx
lea    0x10(%rsp),%r14
lea    0x20(%rsp),%r15
mov    %rbx,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r14,%r8
mov    %r15,%r9
call   1040 <posix_spawn@plt>
mov    0xc(%rsp),%edi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <waitpid@plt>
lea    0xe93(%rip),%rsi
mov    %rsi,0x10(%rsp)
mov    %rbx,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r14,%r8
mov    %r15,%r9
call   1040 <posix_spawn@plt>
mov    0xc(%rsp),%edi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <waitpid@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"PATH=.\00"
@.str.1 = [16 x i8] c"HOME=/home/user\00"
@__const.main.envp = [3 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i32 0, i32 0), i8* null]
@.str.2 = [6 x i8] c"t-abc\00"
@.str.3 = [12 x i8] c"t-openclose\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [2 x i8*]
%8 = alloca [3 x i8*]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [2 x i8*]* %7 to i8*
%10 = bitcast [3 x i8*]* %8 to i8*
%11 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
%13 = getelementptr inbounds [3 x i8*], [3 x i8*]* %8, i64 0, i64 0
%14 = call i32 @posix_spawn(i32* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* null, i32* null, i8** %12, i8** %13)
%15 = load i32, i32* %6
%16 = call i32 @waitpid(i32 %15, i32* null, i32 0)
%17 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8** %17
%18 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
%19 = getelementptr inbounds [3 x i8*], [3 x i8*]* %8, i64 0, i64 0
%20 = call i32 @posix_spawn(i32* %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32* null, i32* null, i8** %18, i8** %19)
%21 = load i32, i32* %6
%22 = call i32 @waitpid(i32 %21, i32* null, i32 0)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"PATH=.\00"
@.str.1 = [16 x i8] c"HOME=/home/user\00"
@__const.main.envp = [3 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i32 0, i32 0), i8* null]
@.str.2 = [6 x i8] c"t-abc\00"
@.str.3 = [12 x i8] c"t-openclose\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [2 x i8*]
%5 = alloca [3 x i8*]
%6 = bitcast i32* %3 to i8*
%7 = bitcast [2 x i8*]* %4 to i8*
%8 = bitcast [3 x i8*]* %5 to i8*
%9 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 0
%11 = call i32 @posix_spawn(i32* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* null, i32* null, i8** %9, i8** %10)
%12 = load i32, i32* %3
%13 = call i32 @waitpid(i32 %12, i32* null, i32 0)
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8** %9
%14 = call i32 @posix_spawn(i32* %3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32* null, i32* null, i8** %9, i8** %10)
%15 = load i32, i32* %3
%16 = call i32 @waitpid(i32 %15, i32* null, i32 0)
ret i32 0
}