#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 *, ...);
void bestmatch_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", "bestmatch",
                                  "need_one_more_than_this", NULL);
  assert(istat == 64);
  istat =
      lace_compat_fd_spawnlp_wait(0, 1, 2, NULL, lace_exe, "-as", "bestmatch",
                                  "-", "-", "--invalid-flag", NULL);
  assert(istat == 64);
  istat = lace_compat_fd_spawnlp_wait(0, 1, 2, NULL, lace_exe, "-as",
                                      "bestmatch", bad_filename, "-", NULL);
  assert(istat == 66);
}


x86 assembly (clang, -O0):
<bestmatch_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    0xeb5(%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    0xe5f(%rip),%r9
lea    0xe5c(%rip),%r11
lea    0xe77(%rip),%r10
lea    0xe72(%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),%r10
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    0xdf4(%rip),%r9
lea    0xdf1(%rip),%r11
lea    0xe0c(%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>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bestmatch_usage_tests>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
sub    $0x8,%rsp
lea    0xed4(%rip),%r10
lea    0xec3(%rip),%r12
lea    0xeb8(%rip),%r15
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
mov    %r15,%r9
xor    %eax,%eax
push   $0x0
push   %r10
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    0xea2(%rip),%r10
lea    0xe99(%rip),%r13
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
mov    %r15,%r9
xor    %eax,%eax
push   $0x0
push   %r10
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>
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
mov    %r15,%r9
xor    %eax,%eax
push   $0x0
push   %r13
push   %r14
push   %r12
call   1030 <lace_compat_fd_spawnlp_wait@plt>
add    $0x20,%rsp
xor    %edi,%edi
cmp    $0x42,%eax
sete   %dil
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <assert@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"-as\00"
@.str.1 = [10 x i8] c"bestmatch\00"
@.str.2 = [24 x i8] c"need_one_more_than_this\00"
@.str.3 = [2 x i8] c"-\00"
@.str.4 = [15 x i8] c"--invalid-flag\00"
define void @bestmatch_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 ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 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, 64
%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 ([10 x i8], [10 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* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, 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 = load i8*, i8** %4
%20 = 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 ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* null)
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = icmp eq i32 %21, 66
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"-as\00"
@.str.1 = [10 x i8] c"bestmatch\00"
@.str.2 = [24 x i8] c"need_one_more_than_this\00"
@.str.3 = [2 x i8] c"-\00"
@.str.4 = [15 x i8] c"--invalid-flag\00"
define void @bestmatch_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 ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, 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*, 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 ([10 x i8], [10 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* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, 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 ([10 x i8], [10 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)
%12 = icmp eq i32 %11, 66
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
ret void
}