#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*/ uint8_t;
struct stat {
  scalar_t__ st_size;
};
struct dirent {
  char *d_name;
};
typedef scalar_t__ ssize_t;
typedef int /*<<< orphan*/ fname;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int ENOMEM;
int /*<<< orphan*/ LLVMFuzzerTestOneInput(int /*<<< orphan*/ *, scalar_t__);
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int errno;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
scalar_t__ fstat(int, struct stat *);
int /*<<< orphan*/ *malloc(scalar_t__);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ *opendir(char const *);
int /*<<< orphan*/ printf(char *, unsigned long long, char *);
scalar_t__ read(int, int /*<<< orphan*/ *, scalar_t__);
struct dirent *readdir(int /*<<< orphan*/ *);
int snprintf(char *, int, char *, char const *, char const *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
scalar_t__ strlen(char const *);
void test_all_from(const char *dirname) {
  DIR *dirp = opendir(dirname);
  if (dirp == NULL) {
    return;
  }
  struct dirent *dp;
  while ((dp = readdir(dirp))) {
    if (*dp->d_name == '.') {
      continue;
    }
    char fname[strlen(dirname) + strlen(dp->d_name) + 2];
    int ret = snprintf(fname, sizeof(fname), "%s/%s", dirname, dp->d_name);
    if (ret < 0 || ret >= sizeof(fname)) {
      fprintf(stderr, "Invalid path %s/%s\n", dirname, dp->d_name);
    }
    int fd;
    if ((fd = open(fname, O_RDONLY)) == -1) {
      fprintf(stderr, "Failed to open %s (%d)\n", fname, errno);
      continue;
    }
    struct stat st;
    if (fstat(fd, &st) != 0) {
      fprintf(stderr, "Failed to stat %d (%d)\n", fd, errno);
      close(fd);
      continue;
    }
    uint8_t *data = malloc(st.st_size);
    if (data == NULL) {
      fprintf(stderr, "Failed to stat %d (%d)\n", fd, ENOMEM);
      close(fd);
      continue;
    }
    ssize_t n;
    if ((n = read(fd, data, st.st_size)) == st.st_size) {
      printf("testing %llu bytes from '%s'\n", (unsigned long long)st.st_size,
             fname);
      fflush(stdout);
      LLVMFuzzerTestOneInput(data, st.st_size);
      fflush(stderr);
    } else {
      fprintf(stderr, "Failed to read %llu bytes from %s (%d), got %zd\n",
              (unsigned long long)st.st_size, fname, errno, n);
    }
    free(data);
    close(fd);
  }
  closedir(dirp);
}


x86 assembly (clang, -O0):
<test_all_from>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <opendir@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1219 <test_all_from+0x29>
jmp    14a9 <test_all_from+0x2b9>
jmp    121e <test_all_from+0x2e>
mov    -0x10(%rbp),%rdi
call   10d0 <readdir@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     14a0 <test_all_from+0x2b0>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    124d <test_all_from+0x5d>
jmp    121e <test_all_from+0x2e>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x68(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1050 <strlen@plt>
mov    -0x68(%rbp),%rcx
mov    %rax,%rdx
lea    0x2(%rcx,%rdx,1),%rax
mov    %rax,-0x60(%rbp)
mov    %rsp,%rsi
mov    %rsi,-0x20(%rbp)
lea    0x11(%rcx,%rdx,1),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x58(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    %eax,%esi
mov    -0x8(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    (%rax),%r8
lea    0xd55(%rip),%rdx
call   1080 <snprintf@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jl     12ce <test_all_from+0xde>
mov    -0x60(%rbp),%rcx
movslq -0x2c(%rbp),%rax
cmp    %rcx,%rax
jb     12f0 <test_all_from+0x100>
mov    0x2cfb(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
lea    0xd1d(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x58(%rbp),%rdi
mov    0x2ced(%rip),%rax
mov    (%rax),%esi
call   1100 <open@plt>
mov    %eax,-0x30(%rbp)
cmp    $0xffffffff,%eax
jne    133e <test_all_from+0x14e>
mov    -0x58(%rbp),%rdx
mov    0x2cb7(%rip),%rax
mov    (%rax),%edi
mov    0x2ca6(%rip),%rax
mov    (%rax),%ecx
lea    0xcef(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
movl   $0x2,-0x34(%rbp)
jmp    147f <test_all_from+0x28f>
mov    -0x30(%rbp),%edi
lea    -0x40(%rbp),%rsi
call   1110 <fstat@plt>
cmp    $0x0,%rax
je     138b <test_all_from+0x19b>
mov    0x2c75(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%edx
mov    0x2c61(%rip),%rax
mov    (%rax),%ecx
lea    0xcc2(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x30(%rbp),%edi
call   1090 <close@plt>
movl   $0x2,-0x34(%rbp)
jmp    147f <test_all_from+0x28f>
mov    -0x40(%rbp),%rdi
call   10e0 <malloc@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    13da <test_all_from+0x1ea>
mov    0x2c26(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%edx
mov    0x2c22(%rip),%rax
mov    (%rax),%ecx
lea    0xc73(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x30(%rbp),%edi
call   1090 <close@plt>
movl   $0x2,-0x34(%rbp)
jmp    147f <test_all_from+0x28f>
mov    -0x30(%rbp),%edi
mov    -0x48(%rbp),%rsi
mov    -0x40(%rbp),%rdx
call   10b0 <read@plt>
mov    %rax,-0x50(%rbp)
cmp    -0x40(%rbp),%rax
jne    143a <test_all_from+0x24a>
mov    -0x58(%rbp),%rdx
mov    -0x40(%rbp),%rsi
lea    0xc43(%rip),%rdi
call   1060 <printf@plt>
mov    0x2bad(%rip),%rax
mov    (%rax),%edi
call   10f0 <fflush@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1070 <LLVMFuzzerTestOneInput@plt>
mov    0x2ba2(%rip),%rax
mov    (%rax),%edi
call   10f0 <fflush@plt>
jmp    1467 <test_all_from+0x277>
mov    -0x58(%rbp),%rcx
mov    0x2b8b(%rip),%rax
mov    (%rax),%edi
mov    -0x40(%rbp),%rdx
mov    0x2b76(%rip),%rax
mov    (%rax),%r8d
mov    -0x50(%rbp),%r9
lea    0xc08(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%edi
call   1090 <close@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x34(%rbp),%eax
test   %eax,%eax
je     149b <test_all_from+0x2ab>
jmp    1496 <test_all_from+0x2a6>
jmp    121e <test_all_from+0x2e>
jmp    121e <test_all_from+0x2e>
mov    -0x10(%rbp),%rdi
call   10a0 <closedir@plt>
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_all_from>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r15
call   1040 <opendir@plt>
test   %rax,%rax
je     1427 <test_all_from+0x237>
mov    %rax,%r14
mov    %rax,%rdi
call   10d0 <readdir@plt>
test   %rax,%rax
je     141f <test_all_from+0x22f>
mov    %rax,%r12
mov    %r14,-0x30(%rbp)
jmp    1274 <test_all_from+0x84>
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
mov    0x2d89(%rip),%rax
mov    (%rax),%ecx
lea    0xdd2(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    %rbx,%rsp
mov    -0x30(%rbp),%r14
nopl   0x0(%rax)
mov    %r14,%rdi
call   10d0 <readdir@plt>
mov    %rax,%r12
test   %rax,%rax
je     141f <test_all_from+0x22f>
mov    (%r12),%rbx
cmpb   $0x2e,(%rbx)
je     1260 <test_all_from+0x70>
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %rax,%r13
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rsp,%rbx
lea    (%rax,%r13,1),%r14
add    $0x2,%r14
add    %r13,%rax
add    $0x11,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r13
sub    %rax,%r13
mov    %r13,%rsp
mov    (%r12),%r8
mov    %r13,%rdi
mov    %r14d,%esi
lea    0xd40(%rip),%rdx
mov    %r15,%rcx
call   1080 <snprintf@plt>
test   %eax,%eax
js     12d3 <test_all_from+0xe3>
cltq
cmp    %rax,%r14
ja     12f1 <test_all_from+0x101>
mov    0x2cf6(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%rcx
lea    0xd1f(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    0x2cf0(%rip),%rax
mov    (%rax),%esi
mov    %r13,%rdi
call   1100 <open@plt>
cmp    $0xffffffff,%eax
je     122f <test_all_from+0x3f>
mov    %eax,%r12d
mov    %eax,%edi
lea    -0x40(%rbp),%rsi
call   1110 <fstat@plt>
test   %rax,%rax
je     134a <test_all_from+0x15a>
mov    0x2cab(%rip),%rax
mov    (%rax),%edi
mov    0x2c9a(%rip),%rax
mov    (%rax),%ecx
lea    0xcfb(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    -0x30(%rbp),%r14
jmp    140f <test_all_from+0x21f>
mov    %rbx,-0x38(%rbp)
mov    -0x40(%rbp),%r14
mov    %r14,%rdi
call   10e0 <malloc@plt>
test   %rax,%rax
je     13b0 <test_all_from+0x1c0>
mov    %rax,%rbx
mov    %r12d,%edi
mov    %rax,%rsi
mov    %r14,%rdx
call   10b0 <read@plt>
cmp    %r14,%rax
jne    13d5 <test_all_from+0x1e5>
lea    0xcce(%rip),%rdi
mov    %r14,%rsi
mov    %r13,%rdx
call   1060 <printf@plt>
mov    0x2c32(%rip),%rax
mov    (%rax),%edi
call   10f0 <fflush@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <LLVMFuzzerTestOneInput@plt>
mov    0x2c29(%rip),%rax
mov    (%rax),%edi
call   10f0 <fflush@plt>
jmp    13ff <test_all_from+0x20f>
mov    0x2c19(%rip),%rax
mov    (%rax),%edi
mov    0x2c18(%rip),%rax
mov    (%rax),%ecx
lea    0xc69(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    1407 <test_all_from+0x217>
mov    0x2bf4(%rip),%rcx
mov    (%rcx),%edi
mov    0x2be3(%rip),%rcx
mov    (%rcx),%r8d
lea    0xc79(%rip),%rsi
mov    %r14,%rdx
mov    %r13,%rcx
mov    %rax,%r9
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%r14
mov    -0x38(%rbp),%rbx
mov    %r12d,%edi
call   1090 <close@plt>
mov    %rbx,%rsp
jmp    1260 <test_all_from+0x70>
mov    %r14,%rdi
call   10a0 <closedir@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i8* }
%struct.stat = type { i64 }
@.str = [6 x i8] c"%s/%s\00"
@stderr = global i32 0
@.str.1 = [20 x i8] c"Invalid path %s/%s\0A\00"
@O_RDONLY = global i32 0
@.str.2 = [24 x i8] c"Failed to open %s (%d)\0A\00"
@errno = global i32 0
@.str.3 = [24 x i8] c"Failed to stat %d (%d)\0A\00"
@ENOMEM = global i32 0
@.str.4 = [30 x i8] c"testing %llu bytes from '%s'\0A\00"
@stdout = global i32 0
@.str.5 = [49 x i8] c"Failed to read %llu bytes from %s (%d), got %zd\0A\00"
define void @test_all_from(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca %struct.dirent*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.stat
%11 = alloca i32*
%12 = alloca i64
store i8* %0, i8** %2
%13 = load i8*, i8** %2
%14 = call i32* @opendir(i8* %13)
store i32* %14, i32** %3
%15 = load i32*, i32** %3
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %18
17: ; preds = %1
br label %133
18: ; preds = %1
br label %19
19: ; preds = %129, %126, %30, %18
%20 = load i32*, i32** %3
%21 = call %struct.dirent* @readdir(i32* %20)
store %struct.dirent* %21, %struct.dirent** %4
%22 = icmp ne %struct.dirent* %21, null
br i1 %22, label %23, label %130
23: ; preds = %19
%24 = load %struct.dirent*, %struct.dirent** %4
%25 = getelementptr inbounds %struct.dirent, %struct.dirent* %24, i32 0, i32 0
%26 = load i8*, i8** %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 46
br i1 %29, label %30, label %31
30: ; preds = %23
br label %19
31: ; preds = %23
%32 = load i8*, i8** %2
%33 = call i64 @strlen(i8* %32)
%34 = load %struct.dirent*, %struct.dirent** %4
%35 = getelementptr inbounds %struct.dirent, %struct.dirent* %34, i32 0, i32 0
%36 = load i8*, i8** %35
%37 = call i64 @strlen(i8* %36)
%38 = add nsw i64 %33, %37
%39 = add nsw i64 %38, 2
%40 = call i8* @llvm.stacksave()
store i8* %40, i8** %5
%41 = alloca i8, i64 %39
store i64 %39, i64* %6
%42 = trunc i64 %39 to i32
%43 = load i8*, i8** %2
%44 = load %struct.dirent*, %struct.dirent** %4
%45 = getelementptr inbounds %struct.dirent, %struct.dirent* %44, i32 0, i32 0
%46 = load i8*, i8** %45
%47 = call i32 @snprintf(i8* %41, i32 %42, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %43, i8* %46)
store i32 %47, i32* %7
%48 = load i32, i32* %7
%49 = icmp slt i32 %48, 0
br i1 %49, label %54, label %50
50: ; preds = %31
%51 = load i32, i32* %7
%52 = sext i32 %51 to i64
%53 = icmp uge i64 %52, %39
br i1 %53, label %54, label %61
54: ; preds = %50, %31
%55 = load i32, i32* @stderr
%56 = load i8*, i8** %2
%57 = load %struct.dirent*, %struct.dirent** %4
%58 = getelementptr inbounds %struct.dirent, %struct.dirent* %57, i32 0, i32 0
%59 = load i8*, i8** %58
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %56, i8* %59)
br label %61
61: ; preds = %54, %50
%62 = load i32, i32* @O_RDONLY
%63 = call i32 @open(i8* %41, i32 %62)
store i32 %63, i32* %8
%64 = icmp eq i32 %63, -1
br i1 %64, label %65, label %69
65: ; preds = %61
%66 = load i32, i32* @stderr
%67 = load i32, i32* @errno
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %41, i32 %67)
store i32 2, i32* %9
br label %126
69: ; preds = %61
%70 = load i32, i32* %8
%71 = call i64 @fstat(i32 %70, %struct.stat* %10)
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %80
73: ; preds = %69
%74 = load i32, i32* @stderr
%75 = load i32, i32* %8
%76 = load i32, i32* @errno
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %75, i32 %76)
%78 = load i32, i32* %8
%79 = call i32 @close(i32 %78)
store i32 2, i32* %9
br label %126
80: ; preds = %69
%81 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%82 = load i64, i64* %81
%83 = call i32* @malloc(i64 %82)
store i32* %83, i32** %11
%84 = load i32*, i32** %11
%85 = icmp eq i32* %84, null
br i1 %85, label %86, label %93
86: ; preds = %80
%87 = load i32, i32* @stderr
%88 = load i32, i32* %8
%89 = load i32, i32* @ENOMEM
%90 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %88, i32 %89)
%91 = load i32, i32* %8
%92 = call i32 @close(i32 %91)
store i32 2, i32* %9
br label %126
93: ; preds = %80
%94 = load i32, i32* %8
%95 = load i32*, i32** %11
%96 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%97 = load i64, i64* %96
%98 = call i64 @read(i32 %94, i32* %95, i64 %97)
store i64 %98, i64* %12
%99 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%100 = load i64, i64* %99
%101 = icmp eq i64 %98, %100
br i1 %101, label %102, label %114
102: ; preds = %93
%103 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%104 = load i64, i64* %103
%105 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i64 %104, i8* %41)
%106 = load i32, i32* @stdout
%107 = call i32 @fflush(i32 %106)
%108 = load i32*, i32** %11
%109 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%110 = load i64, i64* %109
%111 = call i32 @LLVMFuzzerTestOneInput(i32* %108, i64 %110)
%112 = load i32, i32* @stderr
%113 = call i32 @fflush(i32 %112)
br label %121
114: ; preds = %93
%115 = load i32, i32* @stderr
%116 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%117 = load i64, i64* %116
%118 = load i32, i32* @errno
%119 = load i64, i64* %12
%120 = call i32 (i32, i8*, ...) @fprintf(i32 %115, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0), i64 %117, i8* %41, i32 %118, i64 %119)
br label %121
121: ; preds = %114, %102
%122 = load i32*, i32** %11
%123 = call i32 @free(i32* %122)
%124 = load i32, i32* %8
%125 = call i32 @close(i32 %124)
store i32 0, i32* %9
br label %126
126: ; preds = %121, %86, %73, %65
%127 = load i8*, i8** %5
%128 = load i32, i32* %9
switch i32 %128, label %134 [
i32 0, label %129
i32 2, label %19
]
129: ; preds = %126
br label %19
130: ; preds = %19
%131 = load i32*, i32** %3
%132 = call i32 @closedir(i32* %131)
br label %133
133: ; preds = %130, %17
ret void
134: ; preds = %126
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i64 }
%struct.dirent = type { i8* }
@.str = [6 x i8] c"%s/%s\00"
@stderr = global i32 0
@.str.1 = [20 x i8] c"Invalid path %s/%s\0A\00"
@O_RDONLY = global i32 0
@.str.2 = [24 x i8] c"Failed to open %s (%d)\0A\00"
@errno = global i32 0
@.str.3 = [24 x i8] c"Failed to stat %d (%d)\0A\00"
@ENOMEM = global i32 0
@.str.4 = [30 x i8] c"testing %llu bytes from '%s'\0A\00"
@stdout = global i32 0
@.str.5 = [49 x i8] c"Failed to read %llu bytes from %s (%d), got %zd\0A\00"
define void @test_all_from(i8* %0) {
%2 = alloca %struct.stat
%3 = tail call i32* @opendir(i8* %0)
%4 = icmp eq i32* %3, null
br i1 %4, label %82, label %5
5: ; preds = %1
%6 = call %struct.dirent* @readdir(i32* %3)
%7 = icmp eq %struct.dirent* %6, null
br i1 %7, label %80, label %8
8: ; preds = %5
%9 = bitcast %struct.stat* %2 to i8*
%10 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
br label %11
11: ; preds = %8, %17
%12 = phi %struct.dirent* [ %6, %8 ], [ %18, %17 ]
%13 = getelementptr inbounds %struct.dirent, %struct.dirent* %12, i64 0, i32 0
%14 = load i8*, i8** %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 46
br i1 %16, label %17, label %20
17: ; preds = %11, %79
%18 = call %struct.dirent* @readdir(i32* %3)
%19 = icmp eq %struct.dirent* %18, null
br i1 %19, label %80, label %11
20: ; preds = %11
%21 = call i64 @strlen(i8* dereferenceable(1) %0)
%22 = call i64 @strlen(i8* %14)
%23 = add i64 %21, 2
%24 = add i64 %23, %22
%25 = call i8* @llvm.stacksave()
%26 = alloca i8, i64 %24
%27 = trunc i64 %24 to i32
%28 = load i8*, i8** %13
%29 = call i32 @snprintf(i8* %26, i32 %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %28)
%30 = icmp slt i32 %29, 0
%31 = sext i32 %29 to i64
%32 = icmp ule i64 %24, %31
%33 = select i1 %30, i1 true, i1 %32
br i1 %33, label %34, label %38
34: ; preds = %20
%35 = load i32, i32* @stderr
%36 = load i8*, i8** %13
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %36)
br label %38
38: ; preds = %20, %34
%39 = load i32, i32* @O_RDONLY
%40 = call i32 @open(i8* %26, i32 %39)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %46
42: ; preds = %38
%43 = load i32, i32* @stderr
%44 = load i32, i32* @errno
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %26, i32 %44)
br label %79
46: ; preds = %38
%47 = call i64 @fstat(i32 %40, %struct.stat* %2)
%48 = icmp eq i64 %47, 0
br i1 %48, label %53, label %49
49: ; preds = %46
%50 = load i32, i32* @stderr
%51 = load i32, i32* @errno
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %40, i32 %51)
br label %77
53: ; preds = %46
%54 = load i64, i64* %10
%55 = call i32* @malloc(i64 %54)
%56 = icmp eq i32* %55, null
br i1 %56, label %57, label %61
57: ; preds = %53
%58 = load i32, i32* @stderr
%59 = load i32, i32* @ENOMEM
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %40, i32 %59)
br label %77
61: ; preds = %53
%62 = call i64 @read(i32 %40, i32* %55, i64 %54)
%63 = icmp eq i64 %62, %54
br i1 %63, label %64, label %71
64: ; preds = %61
%65 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i64 %54, i8* %26)
%66 = load i32, i32* @stdout
%67 = call i32 @fflush(i32 %66)
%68 = call i32 @LLVMFuzzerTestOneInput(i32* %55, i64 %54)
%69 = load i32, i32* @stderr
%70 = call i32 @fflush(i32 %69)
br label %75
71: ; preds = %61
%72 = load i32, i32* @stderr
%73 = load i32, i32* @errno
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0), i64 %54, i8* %26, i32 %73, i64 %62)
br label %75
75: ; preds = %71, %64
%76 = call i32 @free(i32* %55)
br label %77
77: ; preds = %57, %75, %49
%78 = call i32 @close(i32 %40)
br label %79
79: ; preds = %77, %42
br label %17
80: ; preds = %17, %5
%81 = call i32 @closedir(i32* %3)
br label %82
82: ; preds = %1, %80
ret void
}