#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 *, char const *, ...);
void elastic_pthread_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",
                                      "elastic_pthread", "-x", NULL);
  assert(istat == 66);
  istat =
      lace_compat_fd_spawnlp_wait(0, 1, 2, NULL, lace_exe, "-as",
                                  "elastic_pthread", "-x", bad_filename, NULL);
  assert(istat == 66);
  istat = lace_compat_fd_spawnlp_wait(0, 1, 2, NULL, lace_exe, "-as",
                                      "elastic_pthread", "-o", NULL);
  assert(istat == 64);
  istat =
      lace_compat_fd_spawnlp_wait(0, 1, 2, NULL, lace_exe, "-as",
                                  "elastic_pthread", "-o", bad_filename, NULL);
  assert(istat == 73);
}


x86 assembly (clang, -O0):
<elastic_pthread_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    0xebb(%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   $0x42,-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    0xe5d(%rip),%r9
lea    0xe5a(%rip),%r11
lea    0xe63(%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   $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    0xe02(%rip),%r9
lea    0xdff(%rip),%r10
lea    0xe0b(%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
mov    -0x10(%rbp),%rax
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
lea    0xdaa(%rip),%r9
lea    0xda7(%rip),%r11
lea    0xdb3(%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>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<elastic_pthread_usage_tests>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
sub    $0x8,%rsp
lea    0xeda(%rip),%r13
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   %r13
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    %r15,%r9
xor    %eax,%eax
push   $0x0
push   %r14
push   %r13
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>
sub    $0x8,%rsp
lea    0xe5c(%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   %r13
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>
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
mov    %r15,%r9
xor    %eax,%eax
push   $0x0
push   %r14
push   %r13
push   %r12
call   1030 <lace_compat_fd_spawnlp_wait@plt>
add    $0x20,%rsp
xor    %edi,%edi
cmp    $0x49,%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 = [16 x i8] c"elastic_pthread\00"
@.str.2 = [3 x i8] c"-x\00"
@.str.3 = [3 x i8] c"-o\00"
define void @elastic_pthread_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 ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 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, 66
%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*, 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 ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 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 = 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* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 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, 64
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load i8*, i8** %3
%26 = load i8*, i8** %4
%27 = 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* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %26, i8* null)
store i32 %27, i32* %5
%28 = load i32, i32* %5
%29 = icmp eq i32 %28, 73
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"-as\00"
@.str.1 = [16 x i8] c"elastic_pthread\00"
@.str.2 = [3 x i8] c"-x\00"
@.str.3 = [3 x i8] c"-o\00"
define void @elastic_pthread_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 ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* null)
%4 = icmp eq i32 %3, 66
%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 ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 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*, 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 ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, 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 ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, 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)
ret void
}