#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*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int exit_status();
int /*<<< orphan*/ ok_at_loc(char *, int, int, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ perror(char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
scalar_t__ strchr(char *, char);
int /*<<< orphan*/ strcmp(char *, char *);
int system(char *);
int main() {
  DIR *dp = opendir("t");
  if (!dp) {
    perror("opendir");
    exit(1);
  }
  struct dirent *ep;
  while ((ep = readdir(dp))) {
    char *name = ep->d_name;
    if (strchr(name, '.') || !strcmp(name, "test"))
      continue;
    char command[1024];
    snprintf(command, 1024, "./t/%s >t/%s.got 2>&1", name, name);
    system(command);
    snprintf(command, 1024, "diff -up t/%s.expected t/%s.got", name, name);
    int retval = system(command);
    ok_at_loc("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/ErnWong/NothingButNet-Mark-III/refs/"
              "heads/master/t/test.c",
              23, !(retval >> 8), name, NULL);
  }
  closedir(dp);
  return exit_status();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe78(%rip),%rdi
call   1030 <opendir@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11f3 <main+0x43>
lea    0xe1c(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
jmp    11f8 <main+0x48>
mov    -0x10(%rbp),%rdi
call   10b0 <readdir@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     12e3 <main+0x133>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x2e,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
jne    124b <main+0x9b>
mov    -0x20(%rbp),%rdi
lea    0xdcb(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    1250 <main+0xa0>
jmp    11f8 <main+0x48>
lea    -0x420(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    $0x400,%esi
lea    0xda2(%rip),%rdx
call   1080 <snprintf@plt>
lea    -0x420(%rbp),%rdi
call   1040 <system@plt>
lea    -0x420(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    $0x400,%esi
lea    0xd8c(%rip),%rdx
call   1080 <snprintf@plt>
lea    -0x420(%rbp),%rdi
call   1040 <system@plt>
mov    %eax,-0x424(%rbp)
mov    -0x424(%rbp),%eax
sar    $0x8,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edx
mov    -0x20(%rbp),%rcx
lea    0xd74(%rip),%rdi
mov    $0x17,%esi
xor    %eax,%eax
mov    %eax,%r8d
call   1070 <ok_at_loc@plt>
jmp    11f8 <main+0x48>
mov    -0x10(%rbp),%rdi
call   1090 <closedir@plt>
mov    $0x0,%al
call   1060 <exit_status@plt>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
lea    0xe79(%rip),%rdi
call   1030 <opendir@plt>
test   %rax,%rax
je     12c8 <main+0x118>
mov    %rax,%rbx
mov    %rax,%rdi
call   10b0 <readdir@plt>
test   %rax,%rax
je     12a7 <main+0xf7>
lea    0xe17(%rip),%r14
mov    %rsp,%r12
lea    0xe28(%rip),%r13
lea    0xe41(%rip),%rbp
jmp    1221 <main+0x71>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   10b0 <readdir@plt>
test   %rax,%rax
je     12a7 <main+0xf7>
mov    (%rax),%r15
mov    %r15,%rdi
mov    $0x2e,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    1210 <main+0x60>
mov    %r15,%rdi
mov    %r14,%rsi
call   10a0 <strcmp@plt>
test   %eax,%eax
je     1210 <main+0x60>
mov    %r12,%rdi
mov    $0x400,%esi
lea    0xdb9(%rip),%rdx
mov    %r15,%rcx
mov    %r15,%r8
call   1080 <snprintf@plt>
mov    %r12,%rdi
call   1040 <system@plt>
mov    %r12,%rdi
mov    $0x400,%esi
mov    %r13,%rdx
mov    %r15,%rcx
mov    %r15,%r8
call   1080 <snprintf@plt>
mov    %r12,%rdi
call   1040 <system@plt>
xor    %edx,%edx
cmp    $0x100,%eax
setb   %dl
mov    %rbp,%rdi
mov    $0x17,%esi
mov    %r15,%rcx
xor    %r8d,%r8d
call   1070 <ok_at_loc@plt>
jmp    1210 <main+0x60>
mov    %rbx,%rdi
call   1090 <closedir@plt>
xor    %eax,%eax
call   1060 <exit_status@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd31(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [2 x i8] c"t\00"
@.str.1 = [8 x i8] c"opendir\00"
@.str.2 = [5 x i8] c"test\00"
@.str.3 = [22 x i8] c"./t/%s >t/%s.got 2>&1\00"
@.str.4 = [32 x i8] c"diff -up t/%s.expected t/%s.got\00"
@.str.5 = [148 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ErnWong/NothingButNet-Mark-III/refs/heads/master/t/test.c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca %struct.dirent*
%4 = alloca i8*
%5 = alloca [1024 x i8]
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32* @opendir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %2
%8 = load i32*, i32** %2
%9 = icmp ne i32* %8, null
br i1 %9, label %13, label %10
10: ; preds = %0
%11 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %0
br label %14
14: ; preds = %30, %29, %13
%15 = load i32*, i32** %2
%16 = call %struct.dirent* @readdir(i32* %15)
store %struct.dirent* %16, %struct.dirent** %3
%17 = icmp ne %struct.dirent* %16, null
br i1 %17, label %18, label %50
18: ; preds = %14
%19 = load %struct.dirent*, %struct.dirent** %3
%20 = getelementptr inbounds %struct.dirent, %struct.dirent* %19, i32 0, i32 0
%21 = load i8*, i8** %20
store i8* %21, i8** %4
%22 = load i8*, i8** %4
%23 = call i64 @strchr(i8* %22, i8 signext 46)
%24 = icmp ne i64 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %18
%26 = load i8*, i8** %4
%27 = call i32 @strcmp(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp ne i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %25, %18
br label %14
30: ; preds = %25
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%32 = load i8*, i8** %4
%33 = load i8*, i8** %4
%34 = call i32 @snprintf(i8* %31, i32 1024, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %32, i8* %33)
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%36 = call i32 @system(i8* %35)
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%38 = load i8*, i8** %4
%39 = load i8*, i8** %4
%40 = call i32 @snprintf(i8* %37, i32 1024, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i8* %38, i8* %39)
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%42 = call i32 @system(i8* %41)
store i32 %42, i32* %6
%43 = load i32, i32* %6
%44 = ashr i32 %43, 8
%45 = icmp ne i32 %44, 0
%46 = xor i1 %45, true
%47 = zext i1 %46 to i32
%48 = load i8*, i8** %4
%49 = call i32 @ok_at_loc(i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.5, i64 0, i64 0), i32 23, i32 %47, i8* %48, i32* null)
br label %14
50: ; preds = %14
%51 = load i32*, i32** %2
%52 = call i32 @closedir(i32* %51)
%53 = call i32 (...) @exit_status()
ret i32 %53
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [2 x i8] c"t\00"
@.str.1 = [8 x i8] c"opendir\00"
@.str.2 = [5 x i8] c"test\00"
@.str.3 = [22 x i8] c"./t/%s >t/%s.got 2>&1\00"
@.str.4 = [32 x i8] c"diff -up t/%s.expected t/%s.got\00"
@.str.5 = [148 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ErnWong/NothingButNet-Mark-III/refs/heads/master/t/test.c\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = tail call i32* @opendir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %9, label %4
4: ; preds = %0
%5 = call %struct.dirent* @readdir(i32* %2)
%6 = icmp eq %struct.dirent* %5, null
br i1 %6, label %32, label %7
7: ; preds = %4
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
br label %12
9: ; preds = %0
%10 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %7, %29
%13 = phi %struct.dirent* [ %5, %7 ], [ %30, %29 ]
%14 = getelementptr inbounds %struct.dirent, %struct.dirent* %13, i64 0, i32 0
%15 = load i8*, i8** %14
%16 = call i64 @strchr(i8* %15, i8 signext 46)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %29
18: ; preds = %12
%19 = call i32 @strcmp(i8* dereferenceable(1) %15, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %29, label %21
21: ; preds = %18
%22 = call i32 @snprintf(i8* %8, i32 1024, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %15, i8* %15)
%23 = call i32 @system(i8* %8)
%24 = call i32 @snprintf(i8* %8, i32 1024, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i8* %15, i8* %15)
%25 = call i32 @system(i8* %8)
%26 = icmp ult i32 %25, 256
%27 = zext i1 %26 to i32
%28 = call i32 @ok_at_loc(i8* getelementptr inbounds ([148 x i8], [148 x i8]* @.str.5, i64 0, i64 0), i32 23, i32 %27, i8* %15, i32* null)
br label %29
29: ; preds = %12, %18, %21
%30 = call %struct.dirent* @readdir(i32* %2)
%31 = icmp eq %struct.dirent* %30, null
br i1 %31, label %32, label %12
32: ; preds = %29, %4
%33 = call i32 @closedir(i32* %2)
%34 = call i32 (...) @exit_status()
ret i32 %34
}