#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*/ assert(int);
int lace_compat_fd_spawnlp_wait(int /*<<< orphan*/, int, int,
                                int /*<<< orphan*/ *, char const *, char *,
                                char *, char *, ...);
void execfd_usage_tests(const char *lace_exe, const char *bad_filename) {
  int istat;
  istat = lace_compat_fd_spawnlp_wait(0, 1, 2, NULL, lace_exe, "-as", "execfd",
                                      NULL);
  assert(istat == 64);
  istat = lace_compat_fd_spawnlp_wait(0, 1, 2, NULL, lace_exe, "-as", "execfd",
                                      "-stdin", bad_filename, NULL);
  assert(istat == 66);
  istat = lace_compat_fd_spawnlp_wait(0, 1, 2, NULL, lace_exe, "-as", "execfd",
                                      "-stdout", bad_filename, NULL);
  assert(istat == 73);
  istat = lace_compat_fd_spawnlp_wait(0, 1, 2, NULL, lace_exe, "-as", "execfd",
                                      "--", NULL);
  assert(istat == 64);
  istat =
      lace_compat_fd_spawnlp_wait(0, 1, 2, NULL, lace_exe, "-as", "execfd", "3",
                                  "--", "missing", "index", "three", NULL);
  assert(istat == 64);
}


x86 assembly (clang, -O0):
<execfd_usage_tests>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    -0x20(%rbp),%r8
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    0xeb0(%rip),%r9
lea    0xead(%rip),%rax
mov    %rax,(%rsp)
movq   $0x0,0x8(%rsp)
mov    $0x0,%al
call   1030 <lace_compat_fd_spawnlp_wait@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x40,-0x2c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%rax
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
lea    0xe64(%rip),%r9
lea    0xe61(%rip),%r11
lea    0xe61(%rip),%r10
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
movq   $0x0,0x18(%rsp)
mov    $0x0,%al
call   1030 <lace_compat_fd_spawnlp_wait@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x42,-0x2c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%rax
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
lea    0xe07(%rip),%r9
lea    0xe04(%rip),%r11
lea    0xe0b(%rip),%r10
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
movq   $0x0,0x18(%rsp)
mov    $0x0,%al
call   1030 <lace_compat_fd_spawnlp_wait@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x49,-0x2c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x20(%rbp),%r8
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    0xdac(%rip),%r9
lea    0xda9(%rip),%r10
lea    0xdb8(%rip),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    $0x0,%al
call   1030 <lace_compat_fd_spawnlp_wait@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x40,-0x2c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x20(%rbp),%r8
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    0xd56(%rip),%r9
lea    0xd53(%rip),%r15
lea    0xd65(%rip),%r14
lea    0xd5b(%rip),%rbx
lea    0xd59(%rip),%r11
lea    0xd5a(%rip),%r10
lea    0xd59(%rip),%rax
mov    %r15,(%rsp)
mov    %r14,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r11,0x18(%rsp)
mov    %r10,0x20(%rsp)
mov    %rax,0x28(%rsp)
movq   $0x0,0x30(%rsp)
mov    $0x0,%al
call   1030 <lace_compat_fd_spawnlp_wait@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x40,-0x2c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<execfd_usage_tests>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xecc(%rip),%r12
lea    0xec1(%rip),%r14
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
mov    %r14,%r9
xor    %eax,%eax
push   $0x0
push   %r12
call   1030 <lace_compat_fd_spawnlp_wait@plt>
add    $0x10,%rsp
xor    %edi,%edi
cmp    $0x40,%eax
sete   %dil
call   1040 <assert@plt>
lea    0xe94(%rip),%r10
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
mov    %r14,%r9
xor    %eax,%eax
push   $0x0
push   %r15
push   %r10
push   %r12
call   1030 <lace_compat_fd_spawnlp_wait@plt>
add    $0x20,%rsp
xor    %edi,%edi
cmp    $0x42,%eax
sete   %dil
call   1040 <assert@plt>
lea    0xe5f(%rip),%r10
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
mov    %r14,%r9
xor    %eax,%eax
push   $0x0
push   %r15
push   %r10
push   %r12
call   1030 <lace_compat_fd_spawnlp_wait@plt>
add    $0x20,%rsp
xor    %edi,%edi
cmp    $0x49,%eax
sete   %dil
call   1040 <assert@plt>
sub    $0x8,%rsp
lea    0xe27(%rip),%r15
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
mov    %r14,%r9
xor    %eax,%eax
push   $0x0
push   %r15
push   %r12
call   1030 <lace_compat_fd_spawnlp_wait@plt>
add    $0x20,%rsp
xor    %edi,%edi
cmp    $0x40,%eax
sete   %dil
call   1040 <assert@plt>
sub    $0x8,%rsp
lea    0xdfc(%rip),%r10
lea    0xdef(%rip),%r11
lea    0xde0(%rip),%r13
lea    0xdd7(%rip),%rbp
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
mov    %r14,%r9
xor    %eax,%eax
push   $0x0
push   %r10
push   %r11
push   %r13
push   %r15
push   %rbp
push   %r12
call   1030 <lace_compat_fd_spawnlp_wait@plt>
add    $0x40,%rsp
xor    %edi,%edi
cmp    $0x40,%eax
sete   %dil
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <assert@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"-as\00"
@.str.1 = [7 x i8] c"execfd\00"
@.str.2 = [7 x i8] c"-stdin\00"
@.str.3 = [8 x i8] c"-stdout\00"
@.str.4 = [3 x i8] c"--\00"
@.str.5 = [2 x i8] c"3\00"
@.str.6 = [8 x i8] c"missing\00"
@.str.7 = [6 x i8] c"index\00"
@.str.8 = [6 x i8] c"three\00"
define void @execfd_usage_tests(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = call i32 (i32, i32, i32, i32*, i8*, i8*, i8*, i8*, ...) @lace_compat_fd_spawnlp_wait(i32 0, i32 1, i32 2, i32* null, i8* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* null)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp eq i32 %8, 64
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i8*, i8** %3
%13 = load i8*, i8** %4
%14 = call i32 (i32, i32, i32, i32*, i8*, i8*, i8*, i8*, ...) @lace_compat_fd_spawnlp_wait(i32 0, i32 1, i32 2, i32* null, i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %13, i8* null)
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, 66
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i8*, i8** %3
%20 = load i8*, i8** %4
%21 = call i32 (i32, i32, i32, i32*, i8*, i8*, i8*, i8*, ...) @lace_compat_fd_spawnlp_wait(i32 0, i32 1, i32 2, i32* null, i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %20, i8* null)
store i32 %21, i32* %5
%22 = load i32, i32* %5
%23 = icmp eq i32 %22, 73
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = load i8*, i8** %3
%27 = call i32 (i32, i32, i32, i32*, i8*, i8*, i8*, i8*, ...) @lace_compat_fd_spawnlp_wait(i32 0, i32 1, i32 2, i32* null, i8* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* null)
store i32 %27, i32* %5
%28 = load i32, i32* %5
%29 = icmp eq i32 %28, 64
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = load i8*, i8** %3
%33 = call i32 (i32, i32, i32, i32*, i8*, i8*, i8*, i8*, ...) @lace_compat_fd_spawnlp_wait(i32 0, i32 1, i32 2, i32* null, i8* %32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8* null)
store i32 %33, i32* %5
%34 = load i32, i32* %5
%35 = icmp eq i32 %34, 64
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"-as\00"
@.str.1 = [7 x i8] c"execfd\00"
@.str.2 = [7 x i8] c"-stdin\00"
@.str.3 = [8 x i8] c"-stdout\00"
@.str.4 = [3 x i8] c"--\00"
@.str.5 = [2 x i8] c"3\00"
@.str.6 = [8 x i8] c"missing\00"
@.str.7 = [6 x i8] c"index\00"
@.str.8 = [6 x i8] c"three\00"
define void @execfd_usage_tests(i8* %0, i8* %1) {
%3 = tail call i32 (i32, i32, i32, i32*, i8*, i8*, i8*, i8*, ...) @lace_compat_fd_spawnlp_wait(i32 0, i32 1, i32 2, i32* null, i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* null)
%4 = icmp eq i32 %3, 64
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = tail call i32 (i32, i32, i32, i32*, i8*, i8*, i8*, i8*, ...) @lace_compat_fd_spawnlp_wait(i32 0, i32 1, i32 2, i32* null, i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* null)
%8 = icmp eq i32 %7, 66
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = tail call i32 (i32, i32, i32, i32*, i8*, i8*, i8*, i8*, ...) @lace_compat_fd_spawnlp_wait(i32 0, i32 1, i32 2, i32* null, i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %1, i8* null)
%12 = icmp eq i32 %11, 73
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = tail call i32 (i32, i32, i32, i32*, i8*, i8*, i8*, i8*, ...) @lace_compat_fd_spawnlp_wait(i32 0, i32 1, i32 2, i32* null, i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* null)
%16 = icmp eq i32 %15, 64
%17 = zext i1 %16 to i32
%18 = tail call i32 @assert(i32 %17)
%19 = tail call i32 (i32, i32, i32, i32*, i8*, i8*, i8*, i8*, ...) @lace_compat_fd_spawnlp_wait(i32 0, i32 1, i32 2, i32* null, i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8* null)
%20 = icmp eq i32 %19, 64
%21 = zext i1 %20 to i32
%22 = tail call i32 @assert(i32 %21)
ret void
}