#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 */
struct dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
scalar_t__ EXIT_SUCCESS;
scalar_t__ WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ setenv(char *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
char *strchr(char *, char);
int system(char *);
int main(int argc, char *argv[]) {
  int ret, ok = 0, bad = 0, line;
  FILE *fp;
  DIR *d;
  char buf[1024];
  struct dirent *dent;
  char file[1024];
  if (argc < 2) {
    fprintf(stderr, "Usage: %s directory\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  d = opendir(argv[1]);
  if (d == NULL) {
    perror("opendir");
    exit(EXIT_FAILURE);
  }
  setenv("PATH", "/usr/sbin", 1);
  while ((dent = readdir(d)) != NULL) {
    sprintf(file, "%s/%s", argv[1], dent->d_name);
    line = 0;
    fp = fopen(file, "r");
    if (fp == NULL) {
      perror("cannot find testsuite file");
      exit(EXIT_FAILURE);
    }
    while (fgets(buf, sizeof(buf), fp)) {
      char *res;
      line++;
      if (buf[0] == '#' || buf[0] == ' ')
        continue;
      res = strchr(buf, ';');
      if (!res) {
        printf("malformed file %s at line %d\n", dent->d_name, line);
        exit(EXIT_FAILURE);
      }
      *res = '\0';
      res += 2;
      printf("(%d) Executing: %s\n", line, buf);
      ret = system(buf);
      if (WIFEXITED(ret) && WEXITSTATUS(ret) == EXIT_SUCCESS) {
        if (res[0] == 'O' && res[1] == 'K')
          ok++;
        else {
          bad++;
          printf("^----- BAD\n");
        }
      } else {
        if (res[0] == 'B' && res[1] == 'A' && res[2] == 'D')
          ok++;
        else {
          bad++;
          printf("^----- BAD\n");
        }
      }
      printf("=====\n");
    }
    fclose(fp);
  }
  closedir(d);
  fprintf(stdout, "OK: %d BAD: %d\n", ok, bad);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x850,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    125d <main+0x5d>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdb8(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1293 <main+0x93>
lea    0xd95(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2d4c(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
lea    0xd83(%rip),%rdi
lea    0xd81(%rip),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
mov    -0x30(%rbp),%rdi
call   10c0 <readdir@plt>
mov    %rax,-0x438(%rbp)
cmp    $0x0,%rax
je     1512 <main+0x312>
lea    -0x840(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x438(%rbp),%rax
mov    (%rax),%rcx
lea    0xd47(%rip),%rsi
call   1110 <sprintf@plt>
movl   $0x0,-0x20(%rbp)
lea    -0x840(%rbp),%rdi
lea    0xd1c(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    132d <main+0x12d>
lea    0xd18(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2cb2(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
jmp    1332 <main+0x132>
lea    -0x430(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x400,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
je     1504 <main+0x304>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movsbl -0x430(%rbp),%eax
cmp    $0x23,%eax
je     137a <main+0x17a>
movsbl -0x430(%rbp),%eax
cmp    $0x20,%eax
jne    137f <main+0x17f>
jmp    1332 <main+0x132>
lea    -0x430(%rbp),%rdi
mov    $0x3b,%esi
call   1070 <strchr@plt>
mov    %rax,-0x848(%rbp)
cmpq   $0x0,-0x848(%rbp)
jne    13ce <main+0x1ce>
mov    -0x438(%rbp),%rax
mov    (%rax),%rsi
mov    -0x20(%rbp),%edx
lea    0xc94(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x2c11(%rip),%rax
mov    (%rax),%edi
call   1120 <exit@plt>
mov    -0x848(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x848(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x848(%rbp)
mov    -0x20(%rbp),%esi
lea    -0x430(%rbp),%rdx
lea    0xc70(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x430(%rbp),%rdi
call   1060 <system@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1100 <WIFEXITED@plt>
cmp    $0x0,%rax
je     148c <main+0x28c>
mov    -0x14(%rbp),%edi
call   10d0 <WEXITSTATUS@plt>
mov    0x2b96(%rip),%rcx
cmp    (%rcx),%rax
jne    148c <main+0x28c>
mov    -0x848(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x4f,%eax
jne    1470 <main+0x270>
mov    -0x848(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x4b,%eax
jne    1470 <main+0x270>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1487 <main+0x287>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
lea    0xbff(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    14f1 <main+0x2f1>
mov    -0x848(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x42,%eax
jne    14d5 <main+0x2d5>
mov    -0x848(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x41,%eax
jne    14d5 <main+0x2d5>
mov    -0x848(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x44,%eax
jne    14d5 <main+0x2d5>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    14ec <main+0x2ec>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
lea    0xb9a(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    14f1 <main+0x2f1>
lea    0xb93(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    1332 <main+0x132>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
jmp    12ab <main+0xab>
mov    -0x30(%rbp),%rdi
call   1090 <closedir@plt>
mov    0x2aae(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xb61(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x850,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x828,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jle    1478 <main+0x268>
mov    0x8(%rbx),%rdi
call   1060 <opendir@plt>
test   %rax,%rax
je     1494 <main+0x284>
mov    %rax,%rbp
lea    0xdd4(%rip),%rdi
lea    0xdd2(%rip),%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
mov    %rbp,%rdi
call   10d0 <readdir@plt>
test   %rax,%rax
je     13f8 <main+0x1e8>
lea    0x20(%rsp),%r12
movl   $0x0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
mov    %rbx,0x18(%rsp)
jmp    12ae <main+0x9e>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1050 <fclose@plt>
mov    %rbp,%rdi
call   10d0 <readdir@plt>
test   %rax,%rax
mov    0x18(%rsp),%rbx
je     1408 <main+0x1f8>
mov    0x8(%rbx),%rdx
mov    %rax,0x10(%rsp)
mov    (%rax),%rcx
lea    0x420(%rsp),%r14
mov    %r14,%rdi
lea    0xd60(%rip),%rsi
call   1120 <sprintf@plt>
mov    %r14,%rdi
lea    0xd40(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     146a <main+0x25a>
mov    %rax,%r13
mov    %r12,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   10b0 <fgets@plt>
test   %rax,%rax
je     1290 <main+0x80>
mov    $0x1,%r14d
jmp    134a <main+0x13a>
nopl   0x0(%rax)
addl   $0x1,0xc(%rsp)
lea    0xd79(%rip),%rdi
call   1030 <puts@plt>
lea    0xd67(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    $0x400,%esi
mov    %r13,%rdx
call   10b0 <fgets@plt>
add    $0x1,%r14d
test   %rax,%rax
je     1290 <main+0x80>
movzbl 0x20(%rsp),%eax
cmp    $0x20,%al
je     132d <main+0x11d>
cmp    $0x23,%al
je     132d <main+0x11d>
mov    %r12,%rdi
mov    $0x3b,%esi
call   1080 <strchr@plt>
test   %rax,%rax
je     1443 <main+0x233>
mov    %rax,%rbx
movb   $0x0,(%rax)
lea    0xcf1(%rip),%rdi
mov    %r14d,%esi
mov    %r12,%rdx
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r12,%rdi
call   1070 <system@plt>
mov    %eax,%r15d
mov    %eax,%edi
call   1110 <WIFEXITED@plt>
test   %rax,%rax
je     13d0 <main+0x1c0>
mov    %r15d,%edi
call   10e0 <WEXITSTATUS@plt>
mov    0x2c1b(%rip),%rcx
cmp    (%rcx),%rax
jne    13d0 <main+0x1c0>
cmpb   $0x4f,0x2(%rbx)
jne    1310 <main+0x100>
cmpb   $0x4b,0x3(%rbx)
jne    1310 <main+0x100>
jmp    13ee <main+0x1de>
nopl   0x0(%rax,%rax,1)
cmpb   $0x42,0x2(%rbx)
jne    1310 <main+0x100>
cmpb   $0x41,0x3(%rbx)
jne    1310 <main+0x100>
cmpb   $0x44,0x4(%rbx)
jne    1310 <main+0x100>
addl   $0x1,0x8(%rsp)
jmp    1321 <main+0x111>
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
mov    %rbp,%rdi
call   10a0 <closedir@plt>
mov    0x2bb9(%rip),%rax
mov    (%rax),%edi
lea    0xc5f(%rip),%rsi
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%ecx
xor    %eax,%eax
call   10c0 <fprintf@plt>
xor    %eax,%eax
add    $0x828,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x10(%rsp),%rax
mov    (%rax),%rsi
lea    0xbfb(%rip),%rdi
mov    %r14d,%edx
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x2b75(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
lea    0xbc1(%rip),%rdi
call   1100 <perror@plt>
jmp    145c <main+0x24c>
mov    0x2b61(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xb75(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    145c <main+0x24c>
lea    0xb7a(%rip),%rdi
jmp    1471 <main+0x261>

LLVM IR (-O0):
%struct.dirent = type { i8* }
@stderr = global i32 0
@.str = [21 x i8] c"Usage: %s directory\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [8 x i8] c"opendir\00"
@.str.2 = [5 x i8] c"PATH\00"
@.str.3 = [10 x i8] c"/usr/sbin\00"
@.str.4 = [6 x i8] c"%s/%s\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [27 x i8] c"cannot find testsuite file\00"
@.str.7 = [30 x i8] c"malformed file %s at line %d\0A\00"
@.str.8 = [20 x i8] c"(%d) Executing: %s\0A\00"
@EXIT_SUCCESS = global i64 0
@.str.9 = [12 x i8] c"^----- BAD\0A\00"
@.str.10 = [7 x i8] c"=====\0A\00"
@stdout = global i32 0
@.str.11 = [16 x i8] c"OK: %d BAD: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca [1024 x i8]
%13 = alloca %struct.dirent*
%14 = alloca [1024 x i8]
%15 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %8
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 2
br i1 %17, label %18, label %26
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32* @opendir(i8* %29)
store i32* %30, i32** %11
%31 = load i32*, i32** %11
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %37
33: ; preds = %26
%34 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%35 = load i32, i32* @EXIT_FAILURE
%36 = call i32 @exit(i32 %35)
unreachable
37: ; preds = %26
%38 = call i32 @setenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 1)
br label %39
39: ; preds = %157, %37
%40 = load i32*, i32** %11
%41 = call %struct.dirent* @readdir(i32* %40)
store %struct.dirent* %41, %struct.dirent** %13
%42 = icmp ne %struct.dirent* %41, null
br i1 %42, label %43, label %160
43: ; preds = %39
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = load %struct.dirent*, %struct.dirent** %13
%49 = getelementptr inbounds %struct.dirent, %struct.dirent* %48, i32 0, i32 0
%50 = load i8*, i8** %49
%51 = call i32 @sprintf(i8* %44, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %47, i8* %50)
store i32 0, i32* %9
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%53 = call i32* @fopen(i8* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %53, i32** %10
%54 = load i32*, i32** %10
%55 = icmp eq i32* %54, null
br i1 %55, label %56, label %60
56: ; preds = %43
%57 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
%58 = load i32, i32* @EXIT_FAILURE
%59 = call i32 @exit(i32 %58)
unreachable
60: ; preds = %43
br label %61
61: ; preds = %155, %78, %60
%62 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%63 = load i32*, i32** %10
%64 = call i64 @fgets(i8* %62, i32 1024, i32* %63)
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %157
66: ; preds = %61
%67 = load i32, i32* %9
%68 = add nsw i32 %67, 1
store i32 %68, i32* %9
%69 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = icmp eq i32 %71, 35
br i1 %72, label %78, label %73
73: ; preds = %66
%74 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = icmp eq i32 %76, 32
br i1 %77, label %78, label %79
78: ; preds = %73, %66
br label %61
79: ; preds = %73
%80 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%81 = call i8* @strchr(i8* %80, i8 signext 59)
store i8* %81, i8** %15
%82 = load i8*, i8** %15
%83 = icmp ne i8* %82, null
br i1 %83, label %92, label %84
84: ; preds = %79
%85 = load %struct.dirent*, %struct.dirent** %13
%86 = getelementptr inbounds %struct.dirent, %struct.dirent* %85, i32 0, i32 0
%87 = load i8*, i8** %86
%88 = load i32, i32* %9
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i8* %87, i32 %88)
%90 = load i32, i32* @EXIT_FAILURE
%91 = call i32 @exit(i32 %90)
unreachable
92: ; preds = %79
%93 = load i8*, i8** %15
store i8 0, i8* %93
%94 = load i8*, i8** %15
%95 = getelementptr inbounds i8, i8* %94, i64 2
store i8* %95, i8** %15
%96 = load i32, i32* %9
%97 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i32 %96, i8* %97)
%99 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%100 = call i32 @system(i8* %99)
store i32 %100, i32* %6
%101 = load i32, i32* %6
%102 = call i64 @WIFEXITED(i32 %101)
%103 = icmp ne i64 %102, 0
br i1 %103, label %104, label %129
104: ; preds = %92
%105 = load i32, i32* %6
%106 = call i64 @WEXITSTATUS(i32 %105)
%107 = load i64, i64* @EXIT_SUCCESS
%108 = icmp eq i64 %106, %107
br i1 %108, label %109, label %129
109: ; preds = %104
%110 = load i8*, i8** %15
%111 = getelementptr inbounds i8, i8* %110, i64 0
%112 = load i8, i8* %111
%113 = sext i8 %112 to i32
%114 = icmp eq i32 %113, 79
br i1 %114, label %115, label %124
115: ; preds = %109
%116 = load i8*, i8** %15
%117 = getelementptr inbounds i8, i8* %116, i64 1
%118 = load i8, i8* %117
%119 = sext i8 %118 to i32
%120 = icmp eq i32 %119, 75
br i1 %120, label %121, label %124
121: ; preds = %115
%122 = load i32, i32* %7
%123 = add nsw i32 %122, 1
store i32 %123, i32* %7
br label %128
124: ; preds = %115, %109
%125 = load i32, i32* %8
%126 = add nsw i32 %125, 1
store i32 %126, i32* %8
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
br label %128
128: ; preds = %124, %121
br label %155
129: ; preds = %104, %92
%130 = load i8*, i8** %15
%131 = getelementptr inbounds i8, i8* %130, i64 0
%132 = load i8, i8* %131
%133 = sext i8 %132 to i32
%134 = icmp eq i32 %133, 66
br i1 %134, label %135, label %150
135: ; preds = %129
%136 = load i8*, i8** %15
%137 = getelementptr inbounds i8, i8* %136, i64 1
%138 = load i8, i8* %137
%139 = sext i8 %138 to i32
%140 = icmp eq i32 %139, 65
br i1 %140, label %141, label %150
141: ; preds = %135
%142 = load i8*, i8** %15
%143 = getelementptr inbounds i8, i8* %142, i64 2
%144 = load i8, i8* %143
%145 = sext i8 %144 to i32
%146 = icmp eq i32 %145, 68
br i1 %146, label %147, label %150
147: ; preds = %141
%148 = load i32, i32* %7
%149 = add nsw i32 %148, 1
store i32 %149, i32* %7
br label %154
150: ; preds = %141, %135, %129
%151 = load i32, i32* %8
%152 = add nsw i32 %151, 1
store i32 %152, i32* %8
%153 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0))
br label %154
154: ; preds = %150, %147
br label %155
155: ; preds = %154, %128
%156 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
br label %61
157: ; preds = %61
%158 = load i32*, i32** %10
%159 = call i32 @fclose(i32* %158)
br label %39
160: ; preds = %39
%161 = load i32*, i32** %11
%162 = call i32 @closedir(i32* %161)
%163 = load i32, i32* @stdout
%164 = load i32, i32* %7
%165 = load i32, i32* %8
%166 = call i32 (i32, i8*, ...) @fprintf(i32 %163, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i32 %164, i32 %165)
%167 = load i32, i32* %3
ret i32 %167
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@stderr = global i32 0
@.str = [21 x i8] c"Usage: %s directory\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [8 x i8] c"opendir\00"
@.str.2 = [5 x i8] c"PATH\00"
@.str.3 = [10 x i8] c"/usr/sbin\00"
@.str.4 = [6 x i8] c"%s/%s\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [27 x i8] c"cannot find testsuite file\00"
@.str.7 = [30 x i8] c"malformed file %s at line %d\0A\00"
@.str.8 = [20 x i8] c"(%d) Executing: %s\0A\00"
@EXIT_SUCCESS = global i64 0
@stdout = global i32 0
@.str.11 = [16 x i8] c"OK: %d BAD: %d\0A\00"
@str.12 = [6 x i8] c"=====\00"
@str.13 = [11 x i8] c"^----- BAD\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = icmp slt i32 %0, 2
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call i32* @opendir(i8* %16)
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
%22 = tail call i32 @exit(i32 %21)
unreachable
23: ; preds = %14
%24 = tail call i32 @setenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 1)
%25 = call %struct.dirent* @readdir(i32* %17)
%26 = icmp eq %struct.dirent* %25, null
br i1 %26, label %112, label %27
27: ; preds = %23, %106
%28 = phi %struct.dirent* [ %110, %106 ], [ %25, %23 ]
%29 = phi i32 [ %108, %106 ], [ 0, %23 ]
%30 = phi i32 [ %107, %106 ], [ 0, %23 ]
%31 = load i8*, i8** %15
%32 = getelementptr inbounds %struct.dirent, %struct.dirent* %28, i64 0, i32 0
%33 = load i8*, i8** %32
%34 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %31, i8* %33)
%35 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%36 = icmp eq i32* %35, null
br i1 %36, label %40, label %37
37: ; preds = %27
%38 = call i64 @fgets(i8* %5, i32 1024, i32* %35)
%39 = icmp eq i64 %38, 0
br i1 %39, label %106, label %44
40: ; preds = %27
%41 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
%42 = load i32, i32* @EXIT_FAILURE
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %37, %101
%45 = phi i32 [ %103, %101 ], [ %29, %37 ]
%46 = phi i32 [ %102, %101 ], [ %30, %37 ]
%47 = phi i32 [ %48, %101 ], [ 0, %37 ]
%48 = add nuw nsw i32 %47, 1
%49 = load i8, i8* %5
switch i8 %49, label %50 [
i8 35, label %101
i8 32, label %101
]
50: ; preds = %44
%51 = call i8* @strchr(i8* %5, i8 signext 59)
%52 = icmp eq i8* %51, null
br i1 %52, label %53, label %59
53: ; preds = %50
%54 = getelementptr inbounds %struct.dirent, %struct.dirent* %28, i64 0, i32 0
%55 = load i8*, i8** %54
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i8* %55, i32 %48)
%57 = load i32, i32* @EXIT_FAILURE
%58 = call i32 @exit(i32 %57)
unreachable
59: ; preds = %50
store i8 0, i8* %51
%60 = getelementptr inbounds i8, i8* %51, i64 2
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i32 %48, i8* %5)
%62 = call i32 @system(i8* %5)
%63 = call i64 @WIFEXITED(i32 %62)
%64 = icmp eq i64 %63, 0
br i1 %64, label %81, label %65
65: ; preds = %59
%66 = call i64 @WEXITSTATUS(i32 %62)
%67 = load i64, i64* @EXIT_SUCCESS
%68 = icmp eq i64 %66, %67
br i1 %68, label %69, label %81
69: ; preds = %65
%70 = load i8, i8* %60
%71 = icmp eq i8 %70, 79
br i1 %71, label %72, label %78
72: ; preds = %69
%73 = getelementptr inbounds i8, i8* %51, i64 3
%74 = load i8, i8* %73
%75 = icmp eq i8 %74, 75
br i1 %75, label %76, label %78
76: ; preds = %72
%77 = add nsw i32 %45, 1
br label %97
78: ; preds = %72, %69
%79 = add nsw i32 %46, 1
%80 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.13, i64 0, i64 0))
br label %97
81: ; preds = %65, %59
%82 = load i8, i8* %60
%83 = icmp eq i8 %82, 66
br i1 %83, label %84, label %94
84: ; preds = %81
%85 = getelementptr inbounds i8, i8* %51, i64 3
%86 = load i8, i8* %85
%87 = icmp eq i8 %86, 65
br i1 %87, label %88, label %94
88: ; preds = %84
%89 = getelementptr inbounds i8, i8* %51, i64 4
%90 = load i8, i8* %89
%91 = icmp eq i8 %90, 68
br i1 %91, label %92, label %94
92: ; preds = %88
%93 = add nsw i32 %45, 1
br label %97
94: ; preds = %88, %84, %81
%95 = add nsw i32 %46, 1
%96 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.13, i64 0, i64 0))
br label %97
97: ; preds = %92, %94, %76, %78
%98 = phi i32 [ %46, %76 ], [ %79, %78 ], [ %46, %92 ], [ %95, %94 ]
%99 = phi i32 [ %77, %76 ], [ %45, %78 ], [ %93, %92 ], [ %45, %94 ]
%100 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.12, i64 0, i64 0))
br label %101
101: ; preds = %44, %44, %97
%102 = phi i32 [ %98, %97 ], [ %46, %44 ], [ %46, %44 ]
%103 = phi i32 [ %99, %97 ], [ %45, %44 ], [ %45, %44 ]
%104 = call i64 @fgets(i8* %5, i32 1024, i32* %35)
%105 = icmp eq i64 %104, 0
br i1 %105, label %106, label %44
106: ; preds = %101, %37
%107 = phi i32 [ %30, %37 ], [ %102, %101 ]
%108 = phi i32 [ %29, %37 ], [ %103, %101 ]
%109 = call i32 @fclose(i32* %35)
%110 = call %struct.dirent* @readdir(i32* %17)
%111 = icmp eq %struct.dirent* %110, null
br i1 %111, label %112, label %27
112: ; preds = %106, %23
%113 = phi i32 [ 0, %23 ], [ %107, %106 ]
%114 = phi i32 [ 0, %23 ], [ %108, %106 ]
%115 = call i32 @closedir(i32* %17)
%116 = load i32, i32* @stdout
%117 = call i32 (i32, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i32 %114, i32 %113)
ret i32 0
}