#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*/ tmp;
struct stat {
  int st_mode;
  int /*<<< orphan*/ st_gid;
  int /*<<< orphan*/ st_uid;
};
struct dirent {
  int /*<<< orphan*/ d_name;
};
typedef int /*<<< orphan*/ namebuf;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
scalar_t__ ENOENT;
int S_IFMT;
scalar_t__ S_ISDIR(int);
scalar_t__ S_ISLNK(int);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
scalar_t__ errno;
int lstat(char const *, struct stat *);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ perror(char const *);
int /*<<< orphan*/ printf(char *, char *, char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, ...);
int /*<<< orphan*/ strcmp(int /*<<< orphan*/, char *);
char *strerror(scalar_t__);
int strlen(char const *);
int validate_dir(char *, int, int /*<<< orphan*/, int /*<<< orphan*/);
int validate_file(char const *, int, int /*<<< orphan*/, int /*<<< orphan*/);
int validate_link(char const *, int, int /*<<< orphan*/, int /*<<< orphan*/);
int check_path(const char *name) {
  char namebuf[4096 + 1];
  char tmp[4096 + 1];
  DIR *d;
  struct dirent *de;
  struct stat s;
  int err;
  int retval = 0;
  err = lstat(name, &s);
  if (err < 0) {
    if (errno != ENOENT) {
      perror(name);
      return 1;
    }
    return 0;
  }
  if (S_ISDIR(s.st_mode)) {
    if (name[strlen(name) - 1] != '/')
      snprintf(namebuf, sizeof(namebuf), "%s/", name);
    else
      snprintf(namebuf, sizeof(namebuf), "%s", name);
    retval |= validate_dir(namebuf, (s.st_mode & ~S_IFMT), s.st_uid, s.st_gid);
    d = opendir(namebuf);
    if (d == 0) {
      printf("%s : opendir failed: %s\n", namebuf, strerror(errno));
      return 1;
    }
    while ((de = readdir(d)) != 0) {
      if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, ".."))
        continue;
      snprintf(tmp, sizeof(tmp), "%s%s", namebuf, de->d_name);
      retval |= check_path(tmp);
    }
    closedir(d);
    return retval;
  } else if (S_ISLNK(s.st_mode)) {
    return validate_link(name, (s.st_mode & ~S_IFMT), s.st_uid, s.st_gid);
  } else {
    return validate_file(name, (s.st_mode & ~S_IFMT), s.st_uid, s.st_gid);
  }
}


x86 assembly (clang, -O0):
<check_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2070,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x2058(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x2050(%rbp),%rsi
call   10b0 <lstat@plt>
mov    %eax,-0x2054(%rbp)
cmpl   $0x0,-0x2054(%rbp)
jge    1277 <check_path+0x77>
mov    0x2d95(%rip),%rax
mov    (%rax),%rax
mov    0x2d7b(%rip),%rcx
cmp    (%rcx),%rax
je     126b <check_path+0x6b>
mov    -0x10(%rbp),%rdi
call   1110 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14cc <check_path+0x2cc>
movl   $0x0,-0x4(%rbp)
jmp    14cc <check_path+0x2cc>
mov    -0x2050(%rbp),%edi
call   1080 <S_ISDIR@plt>
cmp    $0x0,%rax
je     145a <check_path+0x25a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x2060(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x2060(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
je     12df <check_path+0xdf>
lea    -0x1020(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1001,%esi
lea    0xd2d(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
jmp    12fd <check_path+0xfd>
lea    -0x1020(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1001,%esi
lea    0xd2c(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
lea    -0x1020(%rbp),%rdi
mov    -0x2050(%rbp),%esi
mov    0x2ccf(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    %eax,%esi
mov    -0x2048(%rbp),%edx
mov    -0x204c(%rbp),%ecx
call   1040 <validate_dir@plt>
or     -0x2058(%rbp),%eax
mov    %eax,-0x2058(%rbp)
lea    -0x1020(%rbp),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x2038(%rbp)
cmpq   $0x0,-0x2038(%rbp)
jne    1395 <check_path+0x195>
lea    -0x1020(%rbp),%rax
mov    %rax,-0x2068(%rbp)
mov    0x2c6d(%rip),%rax
mov    (%rax),%rdi
call   1120 <strerror@plt>
mov    -0x2068(%rbp),%rsi
mov    %rax,%rdx
lea    0xc80(%rip),%rdi
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14cc <check_path+0x2cc>
jmp    139a <check_path+0x19a>
mov    -0x2038(%rbp),%rdi
call   10d0 <readdir@plt>
mov    %rax,-0x2040(%rbp)
cmp    $0x0,%rax
je     1440 <check_path+0x240>
mov    -0x2040(%rbp),%rax
mov    (%rax),%edi
lea    0xc57(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%eax
je     13f3 <check_path+0x1f3>
mov    -0x2040(%rbp),%rax
mov    (%rax),%edi
lea    0xc38(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%eax
jne    13f8 <check_path+0x1f8>
jmp    139a <check_path+0x19a>
lea    -0x2030(%rbp),%rdi
lea    -0x1020(%rbp),%rcx
mov    -0x2040(%rbp),%rax
mov    (%rax),%r8d
mov    $0x1001,%esi
lea    0xc04(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
lea    -0x2030(%rbp),%rdi
call   1100 <check_path@plt>
or     -0x2058(%rbp),%eax
mov    %eax,-0x2058(%rbp)
jmp    139a <check_path+0x19a>
mov    -0x2038(%rbp),%rdi
call   10a0 <closedir@plt>
mov    -0x2058(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14cc <check_path+0x2cc>
mov    -0x2050(%rbp),%edi
call   1030 <S_ISLNK@plt>
cmp    $0x0,%rax
je     14a0 <check_path+0x2a0>
mov    -0x10(%rbp),%rdi
mov    -0x2050(%rbp),%esi
mov    0x2b60(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    %eax,%esi
mov    -0x2048(%rbp),%edx
mov    -0x204c(%rbp),%ecx
call   10f0 <validate_link@plt>
mov    %eax,-0x4(%rbp)
jmp    14cc <check_path+0x2cc>
mov    -0x10(%rbp),%rdi
mov    -0x2050(%rbp),%esi
mov    0x2b2f(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    %eax,%esi
mov    -0x2048(%rbp),%edx
mov    -0x204c(%rbp),%ecx
call   10e0 <validate_file@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2070,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_path>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2028,%rsp
mov    %rdi,%rbx
mov    %rsp,%rsi
call   10b0 <lstat@plt>
test   %eax,%eax
js     133c <check_path+0x13c>
mov    (%rsp),%ebp
mov    %ebp,%edi
call   1080 <S_ISDIR@plt>
test   %rax,%rax
je     1369 <check_path+0x169>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%rbx,1)
lea    0xdd5(%rip),%rax
lea    0xdac(%rip),%rdx
cmove  %rax,%rdx
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    $0x1001,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   1090 <snprintf@plt>
mov    0x2d6a(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,%ebp
mov    0x4(%rsp),%ecx
mov    0x8(%rsp),%edx
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <validate_dir@plt>
mov    %eax,%r14d
mov    %r15,%rdi
call   1050 <opendir@plt>
test   %rax,%rax
je     13a3 <check_path+0x1a3>
mov    %rax,%rbx
mov    %rax,%rdi
call   10d0 <readdir@plt>
test   %rax,%rax
je     135f <check_path+0x15f>
mov    %rax,%r12
lea    0xd5e(%rip),%rbp
lea    0xd56(%rip),%r15
lea    0x1020(%rsp),%r13
jmp    12f0 <check_path+0xf0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   10d0 <readdir@plt>
mov    %rax,%r12
test   %rax,%rax
je     135f <check_path+0x15f>
mov    (%r12),%edi
mov    %rbp,%rsi
call   10c0 <strcmp@plt>
test   %eax,%eax
je     12e0 <check_path+0xe0>
mov    (%r12),%edi
mov    %r15,%rsi
call   10c0 <strcmp@plt>
test   %eax,%eax
je     12e0 <check_path+0xe0>
mov    (%r12),%r8d
mov    %r13,%rdi
mov    $0x1001,%esi
lea    0xcfd(%rip),%rdx
lea    0x10(%rsp),%rcx
xor    %eax,%eax
call   1090 <snprintf@plt>
mov    %r13,%rdi
call   1100 <check_path@plt>
or     %eax,%r14d
jmp    12e0 <check_path+0xe0>
mov    0x2c95(%rip),%rax
mov    (%rax),%rax
mov    0x2c7b(%rip),%rcx
xor    %r14d,%r14d
cmp    (%rcx),%rax
je     13cc <check_path+0x1cc>
mov    %rbx,%rdi
call   1110 <perror@plt>
jmp    13c6 <check_path+0x1c6>
mov    %rbx,%rdi
call   10a0 <closedir@plt>
jmp    13cc <check_path+0x1cc>
mov    %ebp,%edi
call   1030 <S_ISLNK@plt>
mov    0x2c69(%rip),%rcx
mov    (%rcx),%esi
not    %esi
and    %ebp,%esi
mov    0x4(%rsp),%ecx
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
add    $0x2028,%rsp
test   %rax,%rax
je     13e1 <check_path+0x1e1>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10f0 <validate_link@plt>
mov    0x2c2e(%rip),%rax
mov    (%rax),%rdi
call   1120 <strerror@plt>
lea    0xc4b(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    %rax,%rdx
call   1070 <printf@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x2028,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10e0 <validate_file@plt>

LLVM IR (-O0):
%struct.dirent = type { i32 }
%struct.stat = type { i32, i32, i32 }
@errno = global i64 0
@ENOENT = global i64 0
@.str = [4 x i8] c"%s/\00"
@.str.1 = [3 x i8] c"%s\00"
@S_IFMT = global i32 0
@.str.2 = [25 x i8] c"%s : opendir failed: %s\0A\00"
@.str.3 = [2 x i8] c".\00"
@.str.4 = [3 x i8] c"..\00"
@.str.5 = [5 x i8] c"%s%s\00"
define i32 @check_path(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [4097 x i8]
%5 = alloca [4097 x i8]
%6 = alloca i32*
%7 = alloca %struct.dirent*
%8 = alloca %struct.stat
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %10
%11 = load i8*, i8** %3
%12 = call i32 @lstat(i8* %11, %struct.stat* %8)
store i32 %12, i32* %9
%13 = load i32, i32* %9
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %1
%16 = load i64, i64* @errno
%17 = load i64, i64* @ENOENT
%18 = icmp ne i64 %16, %17
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i8*, i8** %3
%21 = call i32 @perror(i8* %20)
store i32 1, i32* %2
br label %131
22: ; preds = %15
store i32 0, i32* %2
br label %131
23: ; preds = %1
%24 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%25 = load i32, i32* %24
%26 = call i64 @S_ISDIR(i32 %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %102
28: ; preds = %23
%29 = load i8*, i8** %3
%30 = load i8*, i8** %3
%31 = call i32 @strlen(i8* %30)
%32 = sub nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %29, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 47
br i1 %37, label %38, label %42
38: ; preds = %28
%39 = getelementptr inbounds [4097 x i8], [4097 x i8]* %4, i64 0, i64 0
%40 = load i8*, i8** %3
%41 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %39, i32 4097, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %40)
br label %46
42: ; preds = %28
%43 = getelementptr inbounds [4097 x i8], [4097 x i8]* %4, i64 0, i64 0
%44 = load i8*, i8** %3
%45 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %43, i32 4097, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %44)
br label %46
46: ; preds = %42, %38
%47 = getelementptr inbounds [4097 x i8], [4097 x i8]* %4, i64 0, i64 0
%48 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%49 = load i32, i32* %48
%50 = load i32, i32* @S_IFMT
%51 = xor i32 %50, -1
%52 = and i32 %49, %51
%53 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 2
%54 = load i32, i32* %53
%55 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 1
%56 = load i32, i32* %55
%57 = call i32 @validate_dir(i8* %47, i32 %52, i32 %54, i32 %56)
%58 = load i32, i32* %10
%59 = or i32 %58, %57
store i32 %59, i32* %10
%60 = getelementptr inbounds [4097 x i8], [4097 x i8]* %4, i64 0, i64 0
%61 = call i32* @opendir(i8* %60)
store i32* %61, i32** %6
%62 = load i32*, i32** %6
%63 = icmp eq i32* %62, null
br i1 %63, label %64, label %69
64: ; preds = %46
%65 = getelementptr inbounds [4097 x i8], [4097 x i8]* %4, i64 0, i64 0
%66 = load i64, i64* @errno
%67 = call i8* @strerror(i64 %66)
%68 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %65, i8* %67)
store i32 1, i32* %2
br label %131
69: ; preds = %46
br label %70
70: ; preds = %87, %86, %69
%71 = load i32*, i32** %6
%72 = call %struct.dirent* @readdir(i32* %71)
store %struct.dirent* %72, %struct.dirent** %7
%73 = icmp ne %struct.dirent* %72, null
br i1 %73, label %74, label %98
74: ; preds = %70
%75 = load %struct.dirent*, %struct.dirent** %7
%76 = getelementptr inbounds %struct.dirent, %struct.dirent* %75, i32 0, i32 0
%77 = load i32, i32* %76
%78 = call i32 @strcmp(i32 %77, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%79 = icmp ne i32 %78, 0
br i1 %79, label %80, label %86
80: ; preds = %74
%81 = load %struct.dirent*, %struct.dirent** %7
%82 = getelementptr inbounds %struct.dirent, %struct.dirent* %81, i32 0, i32 0
%83 = load i32, i32* %82
%84 = call i32 @strcmp(i32 %83, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%85 = icmp ne i32 %84, 0
br i1 %85, label %87, label %86
86: ; preds = %80, %74
br label %70
87: ; preds = %80
%88 = getelementptr inbounds [4097 x i8], [4097 x i8]* %5, i64 0, i64 0
%89 = getelementptr inbounds [4097 x i8], [4097 x i8]* %4, i64 0, i64 0
%90 = load %struct.dirent*, %struct.dirent** %7
%91 = getelementptr inbounds %struct.dirent, %struct.dirent* %90, i32 0, i32 0
%92 = load i32, i32* %91
%93 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %88, i32 4097, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %89, i32 %92)
%94 = getelementptr inbounds [4097 x i8], [4097 x i8]* %5, i64 0, i64 0
%95 = call i32 @check_path(i8* %94)
%96 = load i32, i32* %10
%97 = or i32 %96, %95
store i32 %97, i32* %10
br label %70
98: ; preds = %70
%99 = load i32*, i32** %6
%100 = call i32 @closedir(i32* %99)
%101 = load i32, i32* %10
store i32 %101, i32* %2
br label %131
102: ; preds = %23
%103 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%104 = load i32, i32* %103
%105 = call i64 @S_ISLNK(i32 %104)
%106 = icmp ne i64 %105, 0
br i1 %106, label %107, label %119
107: ; preds = %102
%108 = load i8*, i8** %3
%109 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%110 = load i32, i32* %109
%111 = load i32, i32* @S_IFMT
%112 = xor i32 %111, -1
%113 = and i32 %110, %112
%114 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 2
%115 = load i32, i32* %114
%116 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 1
%117 = load i32, i32* %116
%118 = call i32 @validate_link(i8* %108, i32 %113, i32 %115, i32 %117)
store i32 %118, i32* %2
br label %131
119: ; preds = %102
%120 = load i8*, i8** %3
%121 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%122 = load i32, i32* %121
%123 = load i32, i32* @S_IFMT
%124 = xor i32 %123, -1
%125 = and i32 %122, %124
%126 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 2
%127 = load i32, i32* %126
%128 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 1
%129 = load i32, i32* %128
%130 = call i32 @validate_file(i8* %120, i32 %125, i32 %127, i32 %129)
store i32 %130, i32* %2
br label %131
131: ; preds = %119, %107, %98, %64, %22, %19
%132 = load i32, i32* %2
ret i32 %132
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32 }
%struct.dirent = type { i32 }
@errno = global i64 0
@ENOENT = global i64 0
@.str = [4 x i8] c"%s/\00"
@.str.1 = [3 x i8] c"%s\00"
@S_IFMT = global i32 0
@.str.2 = [25 x i8] c"%s : opendir failed: %s\0A\00"
@.str.3 = [2 x i8] c".\00"
@.str.4 = [3 x i8] c"..\00"
@.str.5 = [5 x i8] c"%s%s\00"
define i32 @check_path(i8* %0) {
%2 = alloca [4097 x i8]
%3 = alloca [4097 x i8]
%4 = alloca %struct.stat
%5 = getelementptr inbounds [4097 x i8], [4097 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [4097 x i8], [4097 x i8]* %3, i64 0, i64 0
%7 = bitcast %struct.stat* %4 to i8*
%8 = call i32 @lstat(i8* %0, %struct.stat* %4)
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %1
%11 = load i64, i64* @errno
%12 = load i64, i64* @ENOENT
%13 = icmp eq i64 %11, %12
br i1 %13, label %87, label %14
14: ; preds = %10
%15 = tail call i32 @perror(i8* %0)
br label %87
16: ; preds = %1
%17 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%18 = load i32, i32* %17
%19 = tail call i64 @S_ISDIR(i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %73, label %21
21: ; preds = %16
%22 = tail call i32 @strlen(i8* %0)
%23 = add nsw i32 %22, -1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %0, i64 %24
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 47
%28 = select i1 %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0)
%29 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %5, i32 4097, i8* %28, i8* %0)
%30 = load i32, i32* @S_IFMT
%31 = xor i32 %30, -1
%32 = and i32 %18, %31
%33 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 2
%34 = load i32, i32* %33
%35 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 1
%36 = load i32, i32* %35
%37 = call i32 @validate_dir(i8* %5, i32 %32, i32 %34, i32 %36)
%38 = call i32* @opendir(i8* %5)
%39 = icmp eq i32* %38, null
br i1 %39, label %43, label %40
40: ; preds = %21
%41 = call %struct.dirent* @readdir(i32* %38)
%42 = icmp eq %struct.dirent* %41, null
br i1 %42, label %70, label %67
43: ; preds = %21
%44 = load i64, i64* @errno
%45 = call i8* @strerror(i64 %44)
%46 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %5, i8* %45)
br label %87
47: ; preds = %67, %57
%48 = phi %struct.dirent* [ %68, %67 ], [ %58, %57 ]
%49 = getelementptr inbounds %struct.dirent, %struct.dirent* %48, i64 0, i32 0
%50 = load i32, i32* %49
%51 = call i32 @strcmp(i32 %50, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%52 = icmp eq i32 %51, 0
br i1 %52, label %57, label %53
53: ; preds = %47
%54 = load i32, i32* %49
%55 = call i32 @strcmp(i32 %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %53, %47
%58 = call %struct.dirent* @readdir(i32* %38)
%59 = icmp eq %struct.dirent* %58, null
br i1 %59, label %70, label %47
60: ; preds = %53
%61 = load i32, i32* %49
%62 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %6, i32 4097, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %5, i32 %61)
%63 = call i32 @check_path(i8* %6)
%64 = or i32 %63, %69
%65 = call %struct.dirent* @readdir(i32* %38)
%66 = icmp eq %struct.dirent* %65, null
br i1 %66, label %70, label %67
67: ; preds = %40, %60
%68 = phi %struct.dirent* [ %65, %60 ], [ %41, %40 ]
%69 = phi i32 [ %64, %60 ], [ %37, %40 ]
br label %47
70: ; preds = %60, %57, %40
%71 = phi i32 [ %37, %40 ], [ %69, %57 ], [ %64, %60 ]
%72 = call i32 @closedir(i32* %38)
br label %87
73: ; preds = %16
%74 = tail call i64 @S_ISLNK(i32 %18)
%75 = icmp eq i64 %74, 0
%76 = load i32, i32* @S_IFMT
%77 = xor i32 %76, -1
%78 = and i32 %18, %77
%79 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 2
%80 = load i32, i32* %79
%81 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 1
%82 = load i32, i32* %81
br i1 %75, label %85, label %83
83: ; preds = %73
%84 = tail call i32 @validate_link(i8* %0, i32 %78, i32 %80, i32 %82)
br label %87
85: ; preds = %73
%86 = tail call i32 @validate_file(i8* %0, i32 %78, i32 %80, i32 %82)
br label %87
87: ; preds = %10, %85, %83, %70, %43, %14
%88 = phi i32 [ 1, %14 ], [ 1, %43 ], [ %71, %70 ], [ %84, %83 ], [ %86, %85 ], [ 0, %10 ]
ret i32 %88
}