#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 const *, char const *, ...);
void cmp_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", "cmp",
                                      "/dev/null", "/dev/null", NULL);
  assert(istat == 0);
  istat = lace_compat_fd_spawnlp_wait(0, 1, 2, NULL, lace_exe, "-as", "cmp",
                                      "-", NULL);
  assert(istat == 64);
  istat = lace_compat_fd_spawnlp_wait(0, 1, 2, NULL, lace_exe, "-as", "cmp",
                                      "/dev/null", "/dev/null",
                                      "too_many_files", NULL);
  assert(istat == 64);
  istat = lace_compat_fd_spawnlp_wait(0, 1, 2, NULL, lace_exe, "-as", "cmp",
                                      "-o", bad_filename, NULL);
  assert(istat == 73);
  istat = lace_compat_fd_spawnlp_wait(0, 1, 2, NULL, lace_exe, "-as", "cmp",
                                      bad_filename, "-", NULL);
  assert(istat == 66);
  istat = lace_compat_fd_spawnlp_wait(0, 1, 2, NULL, lace_exe, "-as", "cmp",
                                      "-", "-", NULL);
  assert(istat == 66);
}


x86 assembly (clang, -O0):
<cmp_usage_tests>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%r8
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    0xeb5(%rip),%r9
lea    0xeb2(%rip),%r10
lea    0xeaf(%rip),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    %rax,0x10(%rsp)
movq   $0x0,0x18(%rsp)
mov    $0x0,%al
call   1030 <lace_compat_fd_spawnlp_wait@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%r8
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    0xe5a(%rip),%r9
lea    0xe57(%rip),%r10
lea    0xe5e(%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,-0x14(%rbp)
cmpl   $0x40,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%r8
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    0xe04(%rip),%r9
lea    0xe01(%rip),%r11
lea    0xdfe(%rip),%r10
lea    0xe03(%rip),%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
movq   $0x0,0x20(%rsp)
mov    $0x0,%al
call   1030 <lace_compat_fd_spawnlp_wait@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x40,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%r8
mov    -0x10(%rbp),%rax
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
lea    0xd9b(%rip),%r9
lea    0xd98(%rip),%r11
lea    0xdb0(%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,-0x14(%rbp)
cmpl   $0x49,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%r8
mov    -0x10(%rbp),%r10
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    0xd3c(%rip),%r9
lea    0xd39(%rip),%r11
lea    0xd40(%rip),%rax
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,-0x14(%rbp)
cmpl   $0x42,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%r8
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    0xce1(%rip),%r9
lea    0xcde(%rip),%r10
lea    0xce5(%rip),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    %rax,0x10(%rsp)
movq   $0x0,0x18(%rsp)
mov    $0x0,%al
call   1030 <lace_compat_fd_spawnlp_wait@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x42,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmp_usage_tests>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xed0(%rip),%r13
lea    0xec5(%rip),%r12
lea    0xeba(%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   %r13
push   %r13
push   %r12
call   1030 <lace_compat_fd_spawnlp_wait@plt>
add    $0x20,%rsp
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
sub    $0x8,%rsp
lea    0xe8d(%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   %rbp
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    0xe52(%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   %rbp
push   %r13
push   %r13
push   %r12
call   1030 <lace_compat_fd_spawnlp_wait@plt>
add    $0x30,%rsp
xor    %edi,%edi
cmp    $0x40,%eax
sete   %dil
call   1040 <assert@plt>
lea    0xe24(%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   %r15
push   %rbp
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>
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
mov    %r14,%r9
xor    %eax,%eax
push   $0x0
lea    0xdc0(%rip),%rbp
push   %rbp
push   %r15
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>
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
mov    %r14,%r9
xor    %eax,%eax
push   $0x0
push   %rbp
push   %rbp
push   %r12
call   1030 <lace_compat_fd_spawnlp_wait@plt>
add    $0x20,%rsp
xor    %edi,%edi
cmp    $0x42,%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 = [4 x i8] c"cmp\00"
@.str.2 = [10 x i8] c"/dev/null\00"
@.str.3 = [2 x i8] c"-\00"
@.str.4 = [15 x i8] c"too_many_files\00"
@.str.5 = [3 x i8] c"-o\00"
define void @cmp_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*, 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 ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* null)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp eq i32 %8, 0
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i8*, i8** %3
%13 = call i32 (i32, i32, i32, i32*, i8*, 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 ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* null)
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 64
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i8*, i8** %3
%19 = call i32 (i32, i32, i32, i32*, i8*, i8*, i8*, i8*, i8*, ...) @lace_compat_fd_spawnlp_wait(i32 0, i32 1, i32 2, i32* null, i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* null)
store i32 %19, i32* %5
%20 = load i32, i32* %5
%21 = icmp eq i32 %20, 64
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = load i8*, i8** %3
%25 = load i8*, i8** %4
%26 = call i32 (i32, i32, i32, i32*, i8*, i8*, i8*, i8*, i8*, ...) @lace_compat_fd_spawnlp_wait(i32 0, i32 1, i32 2, i32* null, i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %25, i8* null)
store i32 %26, i32* %5
%27 = load i32, i32* %5
%28 = icmp eq i32 %27, 73
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = load i8*, i8** %3
%32 = load i8*, i8** %4
%33 = call i32 (i32, i32, i32, i32*, i8*, i8*, i8*, i8*, i8*, ...) @lace_compat_fd_spawnlp_wait(i32 0, i32 1, i32 2, i32* null, i8* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* null)
store i32 %33, i32* %5
%34 = load i32, i32* %5
%35 = icmp eq i32 %34, 66
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load i8*, i8** %3
%39 = call i32 (i32, i32, i32, i32*, i8*, i8*, i8*, i8*, i8*, ...) @lace_compat_fd_spawnlp_wait(i32 0, i32 1, i32 2, i32* null, i8* %38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* null)
store i32 %39, i32* %5
%40 = load i32, i32* %5
%41 = icmp eq i32 %40, 66
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"-as\00"
@.str.1 = [4 x i8] c"cmp\00"
@.str.2 = [10 x i8] c"/dev/null\00"
@.str.3 = [2 x i8] c"-\00"
@.str.4 = [15 x i8] c"too_many_files\00"
@.str.5 = [3 x i8] c"-o\00"
define void @cmp_usage_tests(i8* %0, i8* %1) {
%3 = tail call i32 (i32, i32, i32, i32*, i8*, 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 ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* null)
%4 = icmp eq i32 %3, 0
%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*, 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 ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* null)
%8 = icmp eq i32 %7, 64
%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*, 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 ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* null)
%12 = icmp eq i32 %11, 64
%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*, 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 ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %1, i8* null)
%16 = icmp eq i32 %15, 73
%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*, 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 ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* null)
%20 = icmp eq i32 %19, 66
%21 = zext i1 %20 to i32
%22 = tail call i32 @assert(i32 %21)
%23 = tail call i32 (i32, i32, i32, i32*, i8*, 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 ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* null)
%24 = icmp eq i32 %23, 66
%25 = zext i1 %24 to i32
%26 = tail call i32 @assert(i32 %25)
ret void
}