#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int BUFSIZ;
int /*<<< orphan*/ F_OK;
int /*<<< orphan*/ X_OK;
scalar_t__ access(char *, int /*<<< orphan*/);
scalar_t__ child_wait(int *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ die(char *, ...);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fdopen(int, char *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int fork_exec(int *, int /*<<< orphan*/ *, char *, char **);
int /*<<< orphan*/ printf(char *, ...);
int snprintf(char *, int, char *, char const *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int run_test(const char *name, int expect_failure) {
  char filename[BUFSIZ];
  char *arg1[3], *arg2[3];
  int pid1 = -1, pin1, pid2 = -1, pin2;
  FILE *fpin1 = NULL, *fpin2 = NULL;
  char buf1[BUFSIZ], buf2[BUFSIZ];
  int ret = 1;
  if (snprintf(filename, BUFSIZ, "./%s", name) >= BUFSIZ)
    die("file name too long\n");
  if (access(filename, F_OK) != 0) {
    if (snprintf(filename, BUFSIZ, "./%s.sh", name) >= BUFSIZ)
      die("file name too long\n");
    if (access(filename, F_OK) != 0)
      die("test not found: %s\n", name);
  }
  if (access(filename, X_OK) != 0)
    die("script is not executable: %s\n", filename);
  arg1[0] = arg2[0] = filename;
  arg1[1] = "expected";
  arg2[1] = "actual";
  arg1[2] = arg2[2] = NULL;
  printf("Running %s...", name);
  if ((pid1 = fork_exec(&pin1, NULL, *arg1, arg1)) < 0)
    die("failed to execute %s: %s\n", filename, strerror(errno));
  if ((pid2 = fork_exec(&pin2, NULL, *arg2, arg2)) < 0)
    die("failed to execute %s: %s\n", filename, strerror(errno));
  fpin1 = fdopen(pin1, "r");
  fpin2 = fdopen(pin2, "r");
  while (fgets(buf1, BUFSIZ, fpin1)) {
    if (!fgets(buf2, BUFSIZ, fpin2) || strcmp(buf1, buf2) != 0) {
      ret = 0;
      break;
    }
  }
  if (fgets(buf2, BUFSIZ, fpin2))
    ret = 0;
  if (fpin1)
    fclose(fpin1);
  if (fpin2)
    fclose(fpin2);
  if (child_wait(&pin1, NULL, pid1) != 0)
    ret = 0;
  if (child_wait(&pin2, NULL, pid2) != 0)
    ret = 0;
  if (expect_failure)
    ret = 1 - ret;
  if (ret == 1)
    printf(" ok\n");
  else
    printf(" FAIL\n");
  return ret;
}


x86 assembly (clang, -O0):
<run_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2e0f(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdx
mov    %rdx,-0x18(%rbp)
mov    %rcx,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rdi
sub    %rdx,%rdi
mov    %rdi,-0xb0(%rbp)
mov    %rdi,%rsp
mov    %rcx,-0x20(%rbp)
movl   $0xffffffff,-0x64(%rbp)
movl   $0xffffffff,-0x6c(%rbp)
movq   $0x0,-0x78(%rbp)
movq   $0x0,-0x80(%rbp)
mov    (%rax),%ecx
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0xa8(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x88(%rbp)
mov    (%rax),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x90(%rbp)
movl   $0x1,-0x94(%rbp)
mov    0x2d70(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%rcx
lea    0xd8b(%rip),%rdx
call   1050 <snprintf@plt>
mov    0x2d57(%rip),%rcx
cmp    (%rcx),%eax
jl     1297 <run_test+0xe7>
lea    0xd75(%rip),%rdi
mov    $0x0,%al
call   10c0 <die@plt>
mov    -0xb0(%rbp),%rdi
mov    0x2d1b(%rip),%rax
mov    (%rax),%esi
call   10b0 <access@plt>
cmp    $0x0,%rax
je     1329 <run_test+0x179>
mov    -0xb0(%rbp),%rdi
mov    0x2d14(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%rcx
lea    0xd48(%rip),%rdx
call   1050 <snprintf@plt>
mov    0x2cfb(%rip),%rcx
cmp    (%rcx),%eax
jl     12f3 <run_test+0x143>
lea    0xd19(%rip),%rdi
mov    $0x0,%al
call   10c0 <die@plt>
mov    -0xb0(%rbp),%rdi
mov    0x2cbf(%rip),%rax
mov    (%rax),%esi
call   10b0 <access@plt>
cmp    $0x0,%rax
je     1324 <run_test+0x174>
mov    -0x8(%rbp),%rsi
lea    0xd04(%rip),%rdi
mov    $0x0,%al
call   10c0 <die@plt>
jmp    1329 <run_test+0x179>
mov    -0xb0(%rbp),%rdi
mov    0x2cb1(%rip),%rax
mov    (%rax),%esi
call   10b0 <access@plt>
cmp    $0x0,%rax
je     135d <run_test+0x1ad>
mov    -0xb0(%rbp),%rsi
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   10c0 <die@plt>
mov    -0xb0(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    %rax,-0x40(%rbp)
lea    0xce0(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xcde(%rip),%rax
mov    %rax,-0x58(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xcc6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x40(%rbp),%rdx
lea    -0x40(%rbp),%rcx
lea    -0x68(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <fork_exec@plt>
mov    %eax,-0x64(%rbp)
cmp    $0x0,%eax
jge    13ea <run_test+0x23a>
mov    0x2c04(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0xb0(%rbp),%rsi
mov    %eax,%edx
lea    0xc8e(%rip),%rdi
mov    $0x0,%al
call   10c0 <die@plt>
mov    -0x60(%rbp),%rdx
lea    -0x60(%rbp),%rcx
lea    -0x70(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1090 <fork_exec@plt>
mov    %eax,-0x6c(%rbp)
cmp    $0x0,%eax
jge    1430 <run_test+0x280>
mov    0x2bbe(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0xb0(%rbp),%rsi
mov    %eax,%edx
lea    0xc48(%rip),%rdi
mov    $0x0,%al
call   10c0 <die@plt>
mov    -0x68(%rbp),%edi
lea    0xc51(%rip),%rsi
call   10a0 <fdopen@plt>
mov    %rax,-0x78(%rbp)
mov    -0x70(%rbp),%edi
lea    0xc3e(%rip),%rsi
call   10a0 <fdopen@plt>
mov    %rax,-0x80(%rbp)
mov    -0xa8(%rbp),%rdi
mov    0x2b74(%rip),%rax
mov    (%rax),%esi
mov    -0x78(%rbp),%rdx
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     14cd <run_test+0x31d>
mov    -0xa0(%rbp),%rdi
mov    0x2b51(%rip),%rax
mov    (%rax),%esi
mov    -0x80(%rbp),%rdx
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     14b9 <run_test+0x309>
mov    -0xa0(%rbp),%rsi
mov    -0xa8(%rbp),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     14c8 <run_test+0x318>
movl   $0x0,-0x94(%rbp)
jmp    14cd <run_test+0x31d>
jmp    1456 <run_test+0x2a6>
mov    -0xa0(%rbp),%rdi
mov    0x2afd(%rip),%rax
mov    (%rax),%esi
mov    -0x80(%rbp),%rdx
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     14fa <run_test+0x34a>
movl   $0x0,-0x94(%rbp)
cmpq   $0x0,-0x78(%rbp)
je     150e <run_test+0x35e>
mov    -0x78(%rbp),%rdi
call   1030 <fclose@plt>
cmpq   $0x0,-0x80(%rbp)
je     1522 <run_test+0x372>
mov    -0x80(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x64(%rbp),%edx
lea    -0x68(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <child_wait@plt>
cmp    $0x0,%rax
je     1546 <run_test+0x396>
movl   $0x0,-0x94(%rbp)
mov    -0x6c(%rbp),%edx
lea    -0x70(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <child_wait@plt>
cmp    $0x0,%rax
je     156a <run_test+0x3ba>
movl   $0x0,-0x94(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1585 <run_test+0x3d5>
mov    $0x1,%eax
sub    -0x94(%rbp),%eax
mov    %eax,-0x94(%rbp)
cmpl   $0x1,-0x94(%rbp)
jne    15a5 <run_test+0x3f5>
lea    0xaf4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    15b3 <run_test+0x403>
lea    0xae6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x94(%rbp),%eax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_test>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %esi,-0x3c(%rbp)
mov    %rdi,%r13
mov    0x2dfa(%rip),%rbx
mov    (%rbx),%esi
mov    %rsp,%r12
mov    %rsi,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    %rsp,%rcx
sub    %rax,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rsp,%rcx
sub    %rax,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
lea    0xdeb(%rip),%rdx
mov    %r12,%rdi
mov    %r13,%rcx
call   1060 <snprintf@plt>
cmp    (%rbx),%eax
jl     1232 <run_test+0x72>
lea    0xdda(%rip),%rdi
xor    %eax,%eax
call   10d0 <die@plt>
mov    0x2d87(%rip),%r15
mov    (%r15),%esi
mov    %r12,%rdi
call   10c0 <access@plt>
test   %rax,%rax
je     1297 <run_test+0xd7>
mov    0x2d88(%rip),%rbx
mov    (%rbx),%esi
lea    0xdc0(%rip),%rdx
mov    %r12,%rdi
mov    %r13,%rcx
call   1060 <snprintf@plt>
cmp    (%rbx),%eax
jl     1276 <run_test+0xb6>
lea    0xd96(%rip),%rdi
xor    %eax,%eax
call   10d0 <die@plt>
mov    (%r15),%esi
mov    %r12,%rdi
call   10c0 <access@plt>
test   %rax,%rax
je     1297 <run_test+0xd7>
lea    0xd94(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   10d0 <die@plt>
mov    0x2d4a(%rip),%rax
mov    (%rax),%esi
mov    %r12,%rdi
call   10c0 <access@plt>
test   %rax,%rax
je     12be <run_test+0xfe>
lea    0xd81(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   10d0 <die@plt>
mov    %r12,-0x70(%rbp)
mov    %r12,-0x90(%rbp)
lea    0xd83(%rip),%rax
mov    %rax,-0x88(%rbp)
lea    0xd7e(%rip),%rax
mov    %rax,-0x68(%rbp)
movq   $0x0,-0x60(%rbp)
movq   $0x0,-0x80(%rbp)
lea    0xd6a(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdi
lea    -0x90(%rbp),%rcx
xor    %esi,%esi
mov    %r12,%rdx
call   10a0 <fork_exec@plt>
mov    %eax,-0x38(%rbp)
test   %eax,%eax
jns    1340 <run_test+0x180>
mov    0x2caa(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xd3d(%rip),%rdi
mov    %r12,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10d0 <die@plt>
lea    -0x2c(%rbp),%rdi
lea    -0x70(%rbp),%rcx
xor    %esi,%esi
mov    %r12,%rdx
call   10a0 <fork_exec@plt>
mov    %eax,-0x34(%rbp)
test   %eax,%eax
jns    137a <run_test+0x1ba>
mov    0x2c70(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xd03(%rip),%rdi
mov    %r12,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   10d0 <die@plt>
mov    -0x30(%rbp),%edi
lea    0xd07(%rip),%rbx
mov    %rbx,%rsi
call   10b0 <fdopen@plt>
mov    %rax,%r12
mov    -0x2c(%rbp),%edi
mov    %rbx,%rsi
call   10b0 <fdopen@plt>
mov    %rax,%r15
mov    -0x48(%rbp),%r14
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x2c21(%rip),%rbx
mov    (%rbx),%esi
mov    %r14,%rdi
mov    %r12,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     13f5 <run_test+0x235>
mov    (%rbx),%esi
mov    -0x50(%rbp),%rbx
mov    %rbx,%rdi
mov    %r15,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     13fb <run_test+0x23b>
mov    -0x48(%rbp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     13b0 <run_test+0x1f0>
jmp    13fb <run_test+0x23b>
mov    $0x1,%r13d
mov    0x2bd6(%rip),%rax
mov    (%rax),%esi
mov    -0x50(%rbp),%rdi
mov    %r15,%rdx
call   1070 <fgets@plt>
mov    %rax,%r14
test   %r12,%r12
je     1420 <run_test+0x260>
mov    %r12,%rdi
call   1040 <fclose@plt>
test   %r15,%r15
je     142d <run_test+0x26d>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %r15d,%r15d
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    -0x38(%rbp),%edx
call   1090 <child_wait@plt>
mov    %rax,%rbx
or     %r14,%rbx
lea    -0x2c(%rbp),%rdi
xor    %esi,%esi
mov    -0x34(%rbp),%edx
call   1090 <child_wait@plt>
or     %rbx,%rax
cmovne %r15d,%r13d
xor    %ebx,%ebx
cmpl   $0x0,-0x3c(%rbp)
setne  %bl
xor    %r13d,%ebx
cmp    $0x1,%ebx
lea    0xc24(%rip),%rax
lea    0xc17(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [5 x i8] c"./%s\00"
@.str.1 = [20 x i8] c"file name too long\0A\00"
@F_OK = global i32 0
@.str.2 = [8 x i8] c"./%s.sh\00"
@.str.3 = [20 x i8] c"test not found: %s\0A\00"
@X_OK = global i32 0
@.str.4 = [30 x i8] c"script is not executable: %s\0A\00"
@.str.5 = [9 x i8] c"expected\00"
@.str.6 = [7 x i8] c"actual\00"
@.str.7 = [14 x i8] c"Running %s...\00"
@.str.8 = [26 x i8] c"failed to execute %s: %s\0A\00"
@errno = global i32 0
@.str.9 = [2 x i8] c"r\00"
@.str.10 = [5 x i8] c" ok\0A\00"
@.str.11 = [7 x i8] c" FAIL\0A\00"
define i32 @run_test(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca [3 x i8*]
%8 = alloca [3 x i8*]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i64
%16 = alloca i64
%17 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%18 = load i32, i32* @BUFSIZ
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %5
%21 = alloca i8, i64 %19
store i64 %19, i64* %6
store i32 -1, i32* %9
store i32 -1, i32* %11
store i32* null, i32** %13
store i32* null, i32** %14
%22 = load i32, i32* @BUFSIZ
%23 = zext i32 %22 to i64
%24 = alloca i8, i64 %23
store i64 %23, i64* %15
%25 = load i32, i32* @BUFSIZ
%26 = zext i32 %25 to i64
%27 = alloca i8, i64 %26
store i64 %26, i64* %16
store i32 1, i32* %17
%28 = load i32, i32* @BUFSIZ
%29 = load i8*, i8** %3
%30 = call i32 @snprintf(i8* %21, i32 %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %29)
%31 = load i32, i32* @BUFSIZ
%32 = icmp sge i32 %30, %31
br i1 %32, label %33, label %35
33: ; preds = %2
%34 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %35
35: ; preds = %33, %2
%36 = load i32, i32* @F_OK
%37 = call i64 @access(i8* %21, i32 %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %55
39: ; preds = %35
%40 = load i32, i32* @BUFSIZ
%41 = load i8*, i8** %3
%42 = call i32 @snprintf(i8* %21, i32 %40, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %41)
%43 = load i32, i32* @BUFSIZ
%44 = icmp sge i32 %42, %43
br i1 %44, label %45, label %47
45: ; preds = %39
%46 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %47
47: ; preds = %45, %39
%48 = load i32, i32* @F_OK
%49 = call i64 @access(i8* %21, i32 %48)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %47
%52 = load i8*, i8** %3
%53 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %52)
br label %54
54: ; preds = %51, %47
br label %55
55: ; preds = %54, %35
%56 = load i32, i32* @X_OK
%57 = call i64 @access(i8* %21, i32 %56)
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %55
%60 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %21)
br label %61
61: ; preds = %59, %55
%62 = getelementptr inbounds [3 x i8*], [3 x i8*]* %8, i64 0, i64 0
store i8* %21, i8** %62
%63 = getelementptr inbounds [3 x i8*], [3 x i8*]* %7, i64 0, i64 0
store i8* %21, i8** %63
%64 = getelementptr inbounds [3 x i8*], [3 x i8*]* %7, i64 0, i64 1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8** %64
%65 = getelementptr inbounds [3 x i8*], [3 x i8*]* %8, i64 0, i64 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8** %65
%66 = getelementptr inbounds [3 x i8*], [3 x i8*]* %8, i64 0, i64 2
store i8* null, i8** %66
%67 = getelementptr inbounds [3 x i8*], [3 x i8*]* %7, i64 0, i64 2
store i8* null, i8** %67
%68 = load i8*, i8** %3
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %68)
%70 = getelementptr inbounds [3 x i8*], [3 x i8*]* %7, i64 0, i64 0
%71 = load i8*, i8** %70
%72 = getelementptr inbounds [3 x i8*], [3 x i8*]* %7, i64 0, i64 0
%73 = call i32 @fork_exec(i32* %10, i32* null, i8* %71, i8** %72)
store i32 %73, i32* %9
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %79
75: ; preds = %61
%76 = load i32, i32* @errno
%77 = call i32 @strerror(i32 %76)
%78 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8* %21, i32 %77)
br label %79
79: ; preds = %75, %61
%80 = getelementptr inbounds [3 x i8*], [3 x i8*]* %8, i64 0, i64 0
%81 = load i8*, i8** %80
%82 = getelementptr inbounds [3 x i8*], [3 x i8*]* %8, i64 0, i64 0
%83 = call i32 @fork_exec(i32* %12, i32* null, i8* %81, i8** %82)
store i32 %83, i32* %11
%84 = icmp slt i32 %83, 0
br i1 %84, label %85, label %89
85: ; preds = %79
%86 = load i32, i32* @errno
%87 = call i32 @strerror(i32 %86)
%88 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8* %21, i32 %87)
br label %89
89: ; preds = %85, %79
%90 = load i32, i32* %10
%91 = call i32* @fdopen(i32 %90, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32* %91, i32** %13
%92 = load i32, i32* %12
%93 = call i32* @fdopen(i32 %92, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32* %93, i32** %14
br label %94
94: ; preds = %108, %89
%95 = load i32, i32* @BUFSIZ
%96 = load i32*, i32** %13
%97 = call i64 @fgets(i8* %24, i32 %95, i32* %96)
%98 = icmp ne i64 %97, 0
br i1 %98, label %99, label %109
99: ; preds = %94
%100 = load i32, i32* @BUFSIZ
%101 = load i32*, i32** %14
%102 = call i64 @fgets(i8* %27, i32 %100, i32* %101)
%103 = icmp ne i64 %102, 0
br i1 %103, label %104, label %107
104: ; preds = %99
%105 = call i64 @strcmp(i8* %24, i8* %27)
%106 = icmp ne i64 %105, 0
br i1 %106, label %107, label %108
107: ; preds = %104, %99
store i32 0, i32* %17
br label %109
108: ; preds = %104
br label %94
109: ; preds = %107, %94
%110 = load i32, i32* @BUFSIZ
%111 = load i32*, i32** %14
%112 = call i64 @fgets(i8* %27, i32 %110, i32* %111)
%113 = icmp ne i64 %112, 0
br i1 %113, label %114, label %115
114: ; preds = %109
store i32 0, i32* %17
br label %115
115: ; preds = %114, %109
%116 = load i32*, i32** %13
%117 = icmp ne i32* %116, null
br i1 %117, label %118, label %121
118: ; preds = %115
%119 = load i32*, i32** %13
%120 = call i32 @fclose(i32* %119)
br label %121
121: ; preds = %118, %115
%122 = load i32*, i32** %14
%123 = icmp ne i32* %122, null
br i1 %123, label %124, label %127
124: ; preds = %121
%125 = load i32*, i32** %14
%126 = call i32 @fclose(i32* %125)
br label %127
127: ; preds = %124, %121
%128 = load i32, i32* %9
%129 = call i64 @child_wait(i32* %10, i32* null, i32 %128)
%130 = icmp ne i64 %129, 0
br i1 %130, label %131, label %132
131: ; preds = %127
store i32 0, i32* %17
br label %132
132: ; preds = %131, %127
%133 = load i32, i32* %11
%134 = call i64 @child_wait(i32* %12, i32* null, i32 %133)
%135 = icmp ne i64 %134, 0
br i1 %135, label %136, label %137
136: ; preds = %132
store i32 0, i32* %17
br label %137
137: ; preds = %136, %132
%138 = load i32, i32* %4
%139 = icmp ne i32 %138, 0
br i1 %139, label %140, label %143
140: ; preds = %137
%141 = load i32, i32* %17
%142 = sub nsw i32 1, %141
store i32 %142, i32* %17
br label %143
143: ; preds = %140, %137
%144 = load i32, i32* %17
%145 = icmp eq i32 %144, 1
br i1 %145, label %146, label %148
146: ; preds = %143
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
br label %150
148: ; preds = %143
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
br label %150
150: ; preds = %148, %146
%151 = load i32, i32* %17
%152 = load i8*, i8** %5
ret i32 %151
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [5 x i8] c"./%s\00"
@.str.1 = [20 x i8] c"file name too long\0A\00"
@F_OK = global i32 0
@.str.2 = [8 x i8] c"./%s.sh\00"
@.str.3 = [20 x i8] c"test not found: %s\0A\00"
@X_OK = global i32 0
@.str.4 = [30 x i8] c"script is not executable: %s\0A\00"
@.str.5 = [9 x i8] c"expected\00"
@.str.6 = [7 x i8] c"actual\00"
@.str.7 = [14 x i8] c"Running %s...\00"
@.str.8 = [26 x i8] c"failed to execute %s: %s\0A\00"
@errno = global i32 0
@.str.9 = [2 x i8] c"r\00"
@str = [6 x i8] c" FAIL\00"
@str.12 = [4 x i8] c" ok\00"
define i32 @run_test(i8* %0, i32 %1) {
%3 = alloca [3 x i8*]
%4 = alloca [3 x i8*]
%5 = alloca i32
%6 = alloca i32
%7 = load i32, i32* @BUFSIZ
%8 = zext i32 %7 to i64
%9 = alloca i8, i64 %8
%10 = bitcast [3 x i8*]* %3 to i8*
%11 = bitcast [3 x i8*]* %4 to i8*
%12 = bitcast i32* %5 to i8*
%13 = bitcast i32* %6 to i8*
%14 = alloca i8, i64 %8
%15 = alloca i8, i64 %8
%16 = call i32 @snprintf(i8* %9, i32 %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
%17 = load i32, i32* @BUFSIZ
%18 = icmp slt i32 %16, %17
br i1 %18, label %21, label %19
19: ; preds = %2
%20 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %2
%22 = load i32, i32* @F_OK
%23 = call i64 @access(i8* %9, i32 %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %38, label %25
25: ; preds = %21
%26 = load i32, i32* @BUFSIZ
%27 = call i32 @snprintf(i8* %9, i32 %26, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%28 = load i32, i32* @BUFSIZ
%29 = icmp slt i32 %27, %28
br i1 %29, label %32, label %30
30: ; preds = %25
%31 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %30, %25
%33 = load i32, i32* @F_OK
%34 = call i64 @access(i8* %9, i32 %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %38, label %36
36: ; preds = %32
%37 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %38
38: ; preds = %32, %36, %21
%39 = load i32, i32* @X_OK
%40 = call i64 @access(i8* %9, i32 %39)
%41 = icmp eq i64 %40, 0
br i1 %41, label %44, label %42
42: ; preds = %38
%43 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %9)
br label %44
44: ; preds = %42, %38
%45 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 0
store i8* %9, i8** %45
%46 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 0
store i8* %9, i8** %46
%47 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8** %47
%48 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8** %48
%49 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 2
store i8* null, i8** %49
%50 = getelementptr inbounds [3 x i8*], [3 x i8*]* %3, i64 0, i64 2
store i8* null, i8** %50
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %0)
%52 = call i32 @fork_exec(i32* %5, i32* null, i8* %9, i8** %46)
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %44
%55 = load i32, i32* @errno
%56 = call i32 @strerror(i32 %55)
%57 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8* %9, i32 %56)
br label %58
58: ; preds = %54, %44
%59 = call i32 @fork_exec(i32* %6, i32* null, i8* %9, i8** %45)
%60 = icmp slt i32 %59, 0
br i1 %60, label %61, label %65
61: ; preds = %58
%62 = load i32, i32* @errno
%63 = call i32 @strerror(i32 %62)
%64 = call i32 (i8*, ...) @die(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8* %9, i32 %63)
br label %65
65: ; preds = %61, %58
%66 = load i32, i32* %5
%67 = call i32* @fdopen(i32 %66, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%68 = load i32, i32* %6
%69 = call i32* @fdopen(i32 %68, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %70
70: ; preds = %78, %65
%71 = load i32, i32* @BUFSIZ
%72 = call i64 @fgets(i8* %14, i32 %71, i32* %67)
%73 = icmp eq i64 %72, 0
br i1 %73, label %81, label %74
74: ; preds = %70
%75 = load i32, i32* @BUFSIZ
%76 = call i64 @fgets(i8* %15, i32 %75, i32* %69)
%77 = icmp eq i64 %76, 0
br i1 %77, label %81, label %78
78: ; preds = %74
%79 = call i64 @strcmp(i8* %14, i8* %15)
%80 = icmp eq i64 %79, 0
br i1 %80, label %70, label %81
81: ; preds = %74, %78, %70
%82 = phi i32 [ 1, %70 ], [ 0, %78 ], [ 0, %74 ]
%83 = load i32, i32* @BUFSIZ
%84 = call i64 @fgets(i8* %15, i32 %83, i32* %69)
%85 = icmp eq i32* %67, null
br i1 %85, label %88, label %86
86: ; preds = %81
%87 = call i32 @fclose(i32* %67)
br label %88
88: ; preds = %86, %81
%89 = icmp eq i32* %69, null
br i1 %89, label %92, label %90
90: ; preds = %88
%91 = call i32 @fclose(i32* %69)
br label %92
92: ; preds = %90, %88
%93 = call i64 @child_wait(i32* %5, i32* null, i32 %52)
%94 = or i64 %93, %84
%95 = icmp eq i64 %94, 0
%96 = call i64 @child_wait(i32* %6, i32* null, i32 %59)
%97 = icmp eq i64 %96, 0
%98 = select i1 %97, i1 %95, i1 false
%99 = select i1 %98, i32 %82, i32 0
%100 = icmp ne i32 %1, 0
%101 = zext i1 %100 to i32
%102 = xor i32 %99, %101
%103 = icmp eq i32 %102, 1
%104 = select i1 %103, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str.12, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0)
%105 = call i32 @puts(i8* dereferenceable(1) %104)
ret i32 %102
}