#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 */
typedef struct TYPE_6__ TYPE_2__;
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ u_short;
struct stat {
  scalar_t__ st_dev;
  scalar_t__ st_ino;
  int /*<<< orphan*/ st_mode;
  int /*<<< orphan*/ st_nlink;
};
typedef scalar_t__ ino_t;
typedef scalar_t__ dev_t;
struct TYPE_6__ {
  int fts_options;
};
struct TYPE_5__ {
  char *fts_accpath;
  char *fts_name;
  int fts_errno;
  scalar_t__ fts_dev;
  scalar_t__ fts_ino;
  scalar_t__ fts_level;
  struct TYPE_5__ *fts_cycle;
  struct TYPE_5__ *fts_parent;
  int /*<<< orphan*/ fts_nlink;
  struct stat *fts_statp;
};
typedef TYPE_1__ FTSENT;
typedef TYPE_2__ FTS;

/* Variables and functions */
int AT_FDCWD;
int /*<<< orphan*/ AT_SYMLINK_NOFOLLOW;
int /*<<< orphan*/ FTS_D;
int /*<<< orphan*/ FTS_DC;
int /*<<< orphan*/ FTS_DEFAULT;
int /*<<< orphan*/ FTS_DOT;
int /*<<< orphan*/ FTS_F;
int FTS_LOGICAL;
int FTS_NOSTAT;
int /*<<< orphan*/ FTS_NS;
scalar_t__ FTS_ROOTLEVEL;
int /*<<< orphan*/ FTS_SL;
int /*<<< orphan*/ FTS_SLNONE;
scalar_t__ S_ISDIR(int /*<<< orphan*/);
scalar_t__ S_ISLNK(int /*<<< orphan*/);
scalar_t__ S_ISREG(int /*<<< orphan*/);
void *errno;
scalar_t__ fstatat(int, char const *, struct stat *, int /*<<< orphan*/);
int /*<<< orphan*/ memset(struct stat *, int /*<<< orphan*/, int);
u_short fts_stat(FTS *sp, FTSENT *p, int follow, int dfd) {
  FTSENT *t;
  dev_t dev;
  ino_t ino;
  struct stat *sbp, sb;
  int saved_errno;
  const char *path;
  if (dfd == -1) {
    path = p->fts_accpath;
    dfd = AT_FDCWD;
  } else
    path = p->fts_name;
  sbp = (sp->fts_options & (FTS_NOSTAT)) ? &sb : p->fts_statp;
  if ((sp->fts_options & (FTS_LOGICAL)) || follow) {
    if (fstatat(dfd, path, sbp, 0)) {
      saved_errno = errno;
      if (!fstatat(dfd, path, sbp, AT_SYMLINK_NOFOLLOW)) {
        errno = 0;
        return (FTS_SLNONE);
      }
      p->fts_errno = saved_errno;
      goto err;
    }
  } else if (fstatat(dfd, path, sbp, AT_SYMLINK_NOFOLLOW)) {
    p->fts_errno = errno;
  err:
    memset(sbp, 0, sizeof(struct stat));
    return (FTS_NS);
  }
  if (S_ISDIR(sbp->st_mode)) {
    dev = p->fts_dev = sbp->st_dev;
    ino = p->fts_ino = sbp->st_ino;
    p->fts_nlink = sbp->st_nlink;
    if ((p->fts_name[0] == '.' &&
         (!p->fts_name[1] || (p->fts_name[1] == '.' && !p->fts_name[2]))))
      return (FTS_DOT);
    for (t = p->fts_parent; t->fts_level >= FTS_ROOTLEVEL; t = t->fts_parent)
      if (ino == t->fts_ino && dev == t->fts_dev) {
        p->fts_cycle = t;
        return (FTS_DC);
      }
    return (FTS_D);
  }
  if (S_ISLNK(sbp->st_mode))
    return (FTS_SL);
  if (S_ISREG(sbp->st_mode))
    return (FTS_F);
  return (FTS_DEFAULT);
}


x86 assembly (clang, -O0):
<fts_stat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    118c <fts_stat+0x3c>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x68(%rbp)
mov    0x2dee(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
jmp    1198 <fts_stat+0x48>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2df3(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11bd <fts_stat+0x6d>
lea    -0x58(%rbp),%rax
mov    %rax,-0x70(%rbp)
jmp    11c9 <fts_stat+0x79>
mov    -0x18(%rbp),%rax
mov    0x48(%rax),%rax
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2e0a(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    11f3 <fts_stat+0xa3>
cmpl   $0x0,-0x1c(%rbp)
je     1272 <fts_stat+0x122>
mov    -0x20(%rbp),%edi
mov    -0x68(%rbp),%rsi
mov    -0x40(%rbp),%rdx
xor    %ecx,%ecx
call   1070 <fstatat@plt>
cmp    $0x0,%rax
je     126d <fts_stat+0x11d>
mov    0x2d8a(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x5c(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x68(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    0x2d5a(%rip),%rax
mov    (%rax),%ecx
call   1070 <fstatat@plt>
cmp    $0x0,%rax
jne    125e <fts_stat+0x10e>
mov    0x2d5a(%rip),%rax
movq   $0x0,(%rax)
mov    0x2d6c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    145d <fts_stat+0x30d>
mov    -0x5c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x10(%rax)
jmp    12a8 <fts_stat+0x158>
jmp    12ce <fts_stat+0x17e>
mov    -0x20(%rbp),%edi
mov    -0x68(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    0x2d04(%rip),%rax
mov    (%rax),%ecx
call   1070 <fstatat@plt>
cmp    $0x0,%rax
je     12c9 <fts_stat+0x179>
mov    0x2d04(%rip),%rax
mov    (%rax),%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
mov    0x2cb9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    145d <fts_stat+0x30d>
jmp    12ce <fts_stat+0x17e>
mov    -0x40(%rbp),%rax
mov    0x10(%rax),%edi
call   1040 <S_ISDIR@plt>
cmp    $0x0,%rax
je     1403 <fts_stat+0x2b3>
mov    -0x40(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
mov    %rax,0x18(%rcx)
mov    %rax,-0x30(%rbp)
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x18(%rbp),%rcx
mov    %rax,0x20(%rcx)
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rax
mov    0x14(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x40(%rax)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1377 <fts_stat+0x227>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
cmpb   $0x0,0x1(%rax)
je     1366 <fts_stat+0x216>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2e,%eax
jne    1377 <fts_stat+0x227>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
cmpb   $0x0,0x2(%rax)
jne    1377 <fts_stat+0x227>
mov    0x2c5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    145d <fts_stat+0x30d>
mov    -0x18(%rbp),%rax
mov    0x38(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    0x28(%rax),%rax
mov    0x2c46(%rip),%rcx
cmp    (%rcx),%rax
jl     13f2 <fts_stat+0x2a2>
mov    -0x38(%rbp),%rax
mov    -0x28(%rbp),%rcx
cmp    0x20(%rcx),%rax
jne    13dc <fts_stat+0x28c>
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
cmp    0x18(%rcx),%rax
jne    13dc <fts_stat+0x28c>
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x30(%rax)
mov    0x2bbe(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    145d <fts_stat+0x30d>
jmp    13e1 <fts_stat+0x291>
mov    -0x28(%rbp),%rax
mov    0x38(%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1383 <fts_stat+0x233>
mov    0x2bb7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    145d <fts_stat+0x30d>
mov    -0x40(%rbp),%rax
mov    0x10(%rax),%edi
call   1030 <S_ISLNK@plt>
cmp    $0x0,%rax
je     142a <fts_stat+0x2da>
mov    0x2bb0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    145d <fts_stat+0x30d>
mov    -0x40(%rbp),%rax
mov    0x10(%rax),%edi
call   1060 <S_ISREG@plt>
cmp    $0x0,%rax
je     1451 <fts_stat+0x301>
mov    0x2b71(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    145d <fts_stat+0x30d>
mov    0x2b98(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fts_stat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%ebp
mov    %rsi,%r14
xor    %eax,%eax
cmp    $0xffffffff,%ecx
setne  %cl
jne    1176 <fts_stat+0x26>
mov    0x2dfc(%rip),%rsi
mov    (%rsi),%ebp
mov    %cl,%al
mov    (%rdi),%ecx
mov    0x2e17(%rip),%rsi
test   %ecx,(%rsi)
je     118a <fts_stat+0x3a>
mov    %rsp,%r15
jmp    118e <fts_stat+0x3e>
mov    0x48(%r14),%r15
mov    (%r14,%rax,8),%rbx
mov    0x2e4f(%rip),%rax
and    (%rax),%ecx
or     %edx,%ecx
je     11ee <fts_stat+0x9e>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
xor    %ecx,%ecx
call   1070 <fstatat@plt>
test   %rax,%rax
je     123e <fts_stat+0xee>
mov    0x2de2(%rip),%r13
mov    0x0(%r13),%r12
mov    0x2dbf(%rip),%rax
mov    (%rax),%ecx
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1070 <fstatat@plt>
test   %rax,%rax
jne    1213 <fts_stat+0xc3>
movq   $0x0,0x0(%r13)
mov    0x2dd4(%rip),%rax
jmp    122d <fts_stat+0xdd>
mov    0x2d93(%rip),%rax
mov    (%rax),%ecx
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1070 <fstatat@plt>
test   %rax,%rax
je     123e <fts_stat+0xee>
mov    0x2d90(%rip),%rax
mov    (%rax),%r12
mov    %r12d,0x10(%r14)
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
mov    0x2d4b(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x10(%r15),%edi
call   1040 <S_ISDIR@plt>
test   %rax,%rax
je     12ca <fts_stat+0x17a>
mov    (%r15),%rcx
mov    %rcx,0x18(%r14)
mov    0x8(%r15),%rdx
mov    %rdx,0x20(%r14)
mov    0x14(%r15),%eax
mov    %eax,0x40(%r14)
mov    0x8(%r14),%rsi
cmpb   $0x2e,(%rsi)
jne    1285 <fts_stat+0x135>
mov    0x1(%rsi),%bl
mov    0x2d52(%rip),%rax
test   %bl,%bl
je     122d <fts_stat+0xdd>
cmp    $0x2e,%bl
jne    1285 <fts_stat+0x135>
cmpb   $0x0,0x2(%rsi)
je     122d <fts_stat+0xdd>
mov    0x2d4c(%rip),%rax
mov    (%rax),%rdi
mov    0x38(%r14),%rsi
mov    0x2d16(%rip),%rax
jmp    12a4 <fts_stat+0x154>
nopl   0x0(%rax)
mov    0x38(%rsi),%rsi
cmp    %rdi,0x28(%rsi)
jl     122d <fts_stat+0xdd>
cmp    0x20(%rsi),%rdx
jne    12a0 <fts_stat+0x150>
cmp    0x18(%rsi),%rcx
jne    12a0 <fts_stat+0x150>
mov    %rsi,0x30(%r14)
mov    0x2ccb(%rip),%rax
jmp    122d <fts_stat+0xdd>
mov    0x10(%r15),%edi
call   1030 <S_ISLNK@plt>
test   %rax,%rax
je     12e4 <fts_stat+0x194>
mov    0x2cf1(%rip),%rax
jmp    122d <fts_stat+0xdd>
mov    0x10(%r15),%edi
call   1060 <S_ISREG@plt>
test   %rax,%rax
jne    12fe <fts_stat+0x1ae>
mov    0x2cf7(%rip),%rax
jmp    122d <fts_stat+0xdd>
mov    0x2cb3(%rip),%rax
jmp    122d <fts_stat+0xdd>

LLVM IR (-O0):
%struct.TYPE_6__ = type { i32 }
%struct.TYPE_5__ = type { i8*, i8*, i32, i64, i64, i64, %struct.TYPE_5__*, %struct.TYPE_5__*, i32, %struct.stat* }
%struct.stat = type { i64, i64, i32, i32 }
@AT_FDCWD = global i32 0
@FTS_NOSTAT = global i32 0
@FTS_LOGICAL = global i32 0
@errno = global i8* null
@AT_SYMLINK_NOFOLLOW = global i32 0
@FTS_SLNONE = global i32 0
@FTS_NS = global i32 0
@FTS_DOT = global i32 0
@FTS_ROOTLEVEL = global i64 0
@FTS_DC = global i32 0
@FTS_D = global i32 0
@FTS_SL = global i32 0
@FTS_F = global i32 0
@FTS_DEFAULT = global i32 0
define i32 @fts_stat(%struct.TYPE_6__* %0, %struct.TYPE_5__* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca %struct.TYPE_6__*
%7 = alloca %struct.TYPE_5__*
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.TYPE_5__*
%11 = alloca i64
%12 = alloca i64
%13 = alloca %struct.stat*
%14 = alloca %struct.stat
%15 = alloca i32
%16 = alloca i8*
store %struct.TYPE_6__* %0, %struct.TYPE_6__** %6
store %struct.TYPE_5__* %1, %struct.TYPE_5__** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%17 = load i32, i32* %9
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %24
19: ; preds = %4
%20 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%21 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %20, i32 0, i32 0
%22 = load i8*, i8** %21
store i8* %22, i8** %16
%23 = load i32, i32* @AT_FDCWD
store i32 %23, i32* %9
br label %28
24: ; preds = %4
%25 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%26 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %25, i32 0, i32 1
%27 = load i8*, i8** %26
store i8* %27, i8** %16
br label %28
28: ; preds = %24, %19
%29 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%30 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %29, i32 0, i32 0
%31 = load i32, i32* %30
%32 = load i32, i32* @FTS_NOSTAT
%33 = and i32 %31, %32
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %28
br label %40
36: ; preds = %28
%37 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%38 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %37, i32 0, i32 9
%39 = load %struct.stat*, %struct.stat** %38
br label %40
40: ; preds = %36, %35
%41 = phi %struct.stat* [ %14, %35 ], [ %39, %36 ]
store %struct.stat* %41, %struct.stat** %13
%42 = load %struct.TYPE_6__*, %struct.TYPE_6__** %6
%43 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %42, i32 0, i32 0
%44 = load i32, i32* %43
%45 = load i32, i32* @FTS_LOGICAL
%46 = and i32 %44, %45
%47 = icmp ne i32 %46, 0
br i1 %47, label %51, label %48
48: ; preds = %40
%49 = load i32, i32* %8
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %73
51: ; preds = %48, %40
%52 = load i32, i32* %9
%53 = load i8*, i8** %16
%54 = load %struct.stat*, %struct.stat** %13
%55 = call i64 @fstatat(i32 %52, i8* %53, %struct.stat* %54, i32 0)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %72
57: ; preds = %51
%58 = load i8*, i8** @errno
%59 = ptrtoint i8* %58 to i32
store i32 %59, i32* %15
%60 = load i32, i32* %9
%61 = load i8*, i8** %16
%62 = load %struct.stat*, %struct.stat** %13
%63 = load i32, i32* @AT_SYMLINK_NOFOLLOW
%64 = call i64 @fstatat(i32 %60, i8* %61, %struct.stat* %62, i32 %63)
%65 = icmp ne i64 %64, 0
br i1 %65, label %68, label %66
66: ; preds = %57
store i8* null, i8** @errno
%67 = load i32, i32* @FTS_SLNONE
store i32 %67, i32* %5
br label %195
68: ; preds = %57
%69 = load i32, i32* %15
%70 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%71 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %70, i32 0, i32 2
store i32 %69, i32* %71
br label %85
72: ; preds = %51
br label %90
73: ; preds = %48
%74 = load i32, i32* %9
%75 = load i8*, i8** %16
%76 = load %struct.stat*, %struct.stat** %13
%77 = load i32, i32* @AT_SYMLINK_NOFOLLOW
%78 = call i64 @fstatat(i32 %74, i8* %75, %struct.stat* %76, i32 %77)
%79 = icmp ne i64 %78, 0
br i1 %79, label %80, label %89
80: ; preds = %73
%81 = load i8*, i8** @errno
%82 = ptrtoint i8* %81 to i32
%83 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%84 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %83, i32 0, i32 2
store i32 %82, i32* %84
br label %85
85: ; preds = %80, %68
%86 = load %struct.stat*, %struct.stat** %13
%87 = call i32 @memset(%struct.stat* %86, i32 0, i32 24)
%88 = load i32, i32* @FTS_NS
store i32 %88, i32* %5
br label %195
89: ; preds = %73
br label %90
90: ; preds = %89, %72
%91 = load %struct.stat*, %struct.stat** %13
%92 = getelementptr inbounds %struct.stat, %struct.stat* %91, i32 0, i32 2
%93 = load i32, i32* %92
%94 = call i64 @S_ISDIR(i32 %93)
%95 = icmp ne i64 %94, 0
br i1 %95, label %96, label %177
96: ; preds = %90
%97 = load %struct.stat*, %struct.stat** %13
%98 = getelementptr inbounds %struct.stat, %struct.stat* %97, i32 0, i32 0
%99 = load i64, i64* %98
%100 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%101 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %100, i32 0, i32 3
store i64 %99, i64* %101
store i64 %99, i64* %11
%102 = load %struct.stat*, %struct.stat** %13
%103 = getelementptr inbounds %struct.stat, %struct.stat* %102, i32 0, i32 1
%104 = load i64, i64* %103
%105 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%106 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %105, i32 0, i32 4
store i64 %104, i64* %106
store i64 %104, i64* %12
%107 = load %struct.stat*, %struct.stat** %13
%108 = getelementptr inbounds %struct.stat, %struct.stat* %107, i32 0, i32 3
%109 = load i32, i32* %108
%110 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%111 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %110, i32 0, i32 8
store i32 %109, i32* %111
%112 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%113 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %112, i32 0, i32 1
%114 = load i8*, i8** %113
%115 = getelementptr inbounds i8, i8* %114, i64 0
%116 = load i8, i8* %115
%117 = sext i8 %116 to i32
%118 = icmp eq i32 %117, 46
br i1 %118, label %119, label %143
119: ; preds = %96
%120 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%121 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %120, i32 0, i32 1
%122 = load i8*, i8** %121
%123 = getelementptr inbounds i8, i8* %122, i64 1
%124 = load i8, i8* %123
%125 = icmp ne i8 %124, 0
br i1 %125, label %126, label %141
126: ; preds = %119
%127 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%128 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %127, i32 0, i32 1
%129 = load i8*, i8** %128
%130 = getelementptr inbounds i8, i8* %129, i64 1
%131 = load i8, i8* %130
%132 = sext i8 %131 to i32
%133 = icmp eq i32 %132, 46
br i1 %133, label %134, label %143
134: ; preds = %126
%135 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%136 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %135, i32 0, i32 1
%137 = load i8*, i8** %136
%138 = getelementptr inbounds i8, i8* %137, i64 2
%139 = load i8, i8* %138
%140 = icmp ne i8 %139, 0
br i1 %140, label %143, label %141
141: ; preds = %134, %119
%142 = load i32, i32* @FTS_DOT
store i32 %142, i32* %5
br label %195
143: ; preds = %134, %126, %96
%144 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%145 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %144, i32 0, i32 7
%146 = load %struct.TYPE_5__*, %struct.TYPE_5__** %145
store %struct.TYPE_5__* %146, %struct.TYPE_5__** %10
br label %147
147: ; preds = %171, %143
%148 = load %struct.TYPE_5__*, %struct.TYPE_5__** %10
%149 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %148, i32 0, i32 5
%150 = load i64, i64* %149
%151 = load i64, i64* @FTS_ROOTLEVEL
%152 = icmp sge i64 %150, %151
br i1 %152, label %153, label %175
153: ; preds = %147
%154 = load i64, i64* %12
%155 = load %struct.TYPE_5__*, %struct.TYPE_5__** %10
%156 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %155, i32 0, i32 4
%157 = load i64, i64* %156
%158 = icmp eq i64 %154, %157
br i1 %158, label %159, label %170
159: ; preds = %153
%160 = load i64, i64* %11
%161 = load %struct.TYPE_5__*, %struct.TYPE_5__** %10
%162 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %161, i32 0, i32 3
%163 = load i64, i64* %162
%164 = icmp eq i64 %160, %163
br i1 %164, label %165, label %170
165: ; preds = %159
%166 = load %struct.TYPE_5__*, %struct.TYPE_5__** %10
%167 = load %struct.TYPE_5__*, %struct.TYPE_5__** %7
%168 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %167, i32 0, i32 6
store %struct.TYPE_5__* %166, %struct.TYPE_5__** %168
%169 = load i32, i32* @FTS_DC
store i32 %169, i32* %5
br label %195
170: ; preds = %159, %153
br label %171
171: ; preds = %170
%172 = load %struct.TYPE_5__*, %struct.TYPE_5__** %10
%173 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %172, i32 0, i32 7
%174 = load %struct.TYPE_5__*, %struct.TYPE_5__** %173
store %struct.TYPE_5__* %174, %struct.TYPE_5__** %10
br label %147
175: ; preds = %147
%176 = load i32, i32* @FTS_D
store i32 %176, i32* %5
br label %195
177: ; preds = %90
%178 = load %struct.stat*, %struct.stat** %13
%179 = getelementptr inbounds %struct.stat, %struct.stat* %178, i32 0, i32 2
%180 = load i32, i32* %179
%181 = call i64 @S_ISLNK(i32 %180)
%182 = icmp ne i64 %181, 0
br i1 %182, label %183, label %185
183: ; preds = %177
%184 = load i32, i32* @FTS_SL
store i32 %184, i32* %5
br label %195
185: ; preds = %177
%186 = load %struct.stat*, %struct.stat** %13
%187 = getelementptr inbounds %struct.stat, %struct.stat* %186, i32 0, i32 2
%188 = load i32, i32* %187
%189 = call i64 @S_ISREG(i32 %188)
%190 = icmp ne i64 %189, 0
br i1 %190, label %191, label %193
191: ; preds = %185
%192 = load i32, i32* @FTS_F
store i32 %192, i32* %5
br label %195
193: ; preds = %185
%194 = load i32, i32* @FTS_DEFAULT
store i32 %194, i32* %5
br label %195
195: ; preds = %193, %191, %183, %175, %165, %141, %85, %66
%196 = load i32, i32* %5
ret i32 %196
}

LLVM IR (-O2):
%struct.TYPE_6__ = type { i32 }
%struct.TYPE_5__ = type { i8*, i8*, i32, i64, i64, i64, %struct.TYPE_5__*, %struct.TYPE_5__*, i32, %struct.stat* }
%struct.stat = type { i64, i64, i32, i32 }
@AT_FDCWD = global i32 0
@FTS_NOSTAT = global i32 0
@FTS_LOGICAL = global i32 0
@errno = global i8* null
@AT_SYMLINK_NOFOLLOW = global i32 0
@FTS_SLNONE = global i32 0
@FTS_NS = global i32 0
@FTS_DOT = global i32 0
@FTS_ROOTLEVEL = global i64 0
@FTS_DC = global i32 0
@FTS_D = global i32 0
@FTS_SL = global i32 0
@FTS_F = global i32 0
@FTS_DEFAULT = global i32 0
define i32 @fts_stat(%struct.TYPE_6__* nocapture %0, %struct.TYPE_5__* nocapture %1, i32 %2, i32 %3) {
%5 = alloca %struct.stat
%6 = bitcast %struct.stat* %5 to i8*
%7 = icmp eq i32 %3, -1
%8 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 0
%9 = load i32, i32* @AT_FDCWD
%10 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 1
%11 = select i1 %7, i32 %9, i32 %3
%12 = select i1 %7, i8** %8, i8** %10
%13 = load i8*, i8** %12
%14 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 0
%15 = load i32, i32* %14
%16 = load i32, i32* @FTS_NOSTAT
%17 = and i32 %16, %15
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %4
%20 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 9
%21 = load %struct.stat*, %struct.stat** %20
br label %22
22: ; preds = %4, %19
%23 = phi %struct.stat* [ %21, %19 ], [ %5, %4 ]
%24 = load i32, i32* @FTS_LOGICAL
%25 = and i32 %24, %15
%26 = or i32 %25, %2
%27 = icmp eq i32 %26, 0
br i1 %27, label %37, label %28
28: ; preds = %22
%29 = call i64 @fstatat(i32 %11, i8* %13, %struct.stat* %23, i32 0)
%30 = icmp eq i64 %29, 0
br i1 %30, label %49, label %31
31: ; preds = %28
%32 = load i8*, i8** @errno
%33 = load i32, i32* @AT_SYMLINK_NOFOLLOW
%34 = call i64 @fstatat(i32 %11, i8* %13, %struct.stat* %23, i32 %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %43
36: ; preds = %31
store i8* null, i8** @errno
br label %107
37: ; preds = %22
%38 = load i32, i32* @AT_SYMLINK_NOFOLLOW
%39 = call i64 @fstatat(i32 %11, i8* %13, %struct.stat* %23, i32 %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %49, label %41
41: ; preds = %37
%42 = load i8*, i8** @errno
br label %43
43: ; preds = %31, %41
%44 = phi i8* [ %42, %41 ], [ %32, %31 ]
%45 = ptrtoint i8* %44 to i64
%46 = trunc i64 %45 to i32
%47 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 2
store i32 %46, i32* %47
%48 = call i32 @memset(%struct.stat* %23, i32 0, i32 24)
br label %107
49: ; preds = %37, %28
%50 = getelementptr inbounds %struct.stat, %struct.stat* %23, i64 0, i32 2
%51 = load i32, i32* %50
%52 = call i64 @S_ISDIR(i32 %51)
%53 = icmp eq i64 %52, 0
br i1 %53, label %98, label %54
54: ; preds = %49
%55 = getelementptr inbounds %struct.stat, %struct.stat* %23, i64 0, i32 0
%56 = load i64, i64* %55
%57 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 3
store i64 %56, i64* %57
%58 = getelementptr inbounds %struct.stat, %struct.stat* %23, i64 0, i32 1
%59 = load i64, i64* %58
%60 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 4
store i64 %59, i64* %60
%61 = getelementptr inbounds %struct.stat, %struct.stat* %23, i64 0, i32 3
%62 = load i32, i32* %61
%63 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 8
store i32 %62, i32* %63
%64 = load i8*, i8** %10
%65 = load i8, i8* %64
%66 = icmp eq i8 %65, 46
br i1 %66, label %67, label %74
67: ; preds = %54
%68 = getelementptr inbounds i8, i8* %64, i64 1
%69 = load i8, i8* %68
switch i8 %69, label %74 [
i8 0, label %107
i8 46, label %70
]
70: ; preds = %67
%71 = getelementptr inbounds i8, i8* %64, i64 2
%72 = load i8, i8* %71
%73 = icmp eq i8 %72, 0
br i1 %73, label %107, label %74
74: ; preds = %67, %70, %54
%75 = load i64, i64* @FTS_ROOTLEVEL
%76 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 7
%77 = load %struct.TYPE_5__*, %struct.TYPE_5__** %76
%78 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %77, i64 0, i32 5
%79 = load i64, i64* %78
%80 = icmp slt i64 %79, %75
br i1 %80, label %107, label %81
81: ; preds = %74, %92
%82 = phi %struct.TYPE_5__* [ %94, %92 ], [ %77, %74 ]
%83 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %82, i64 0, i32 4
%84 = load i64, i64* %83
%85 = icmp eq i64 %59, %84
br i1 %85, label %86, label %92
86: ; preds = %81
%87 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %82, i64 0, i32 3
%88 = load i64, i64* %87
%89 = icmp eq i64 %56, %88
br i1 %89, label %90, label %92
90: ; preds = %86
%91 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 6
store %struct.TYPE_5__* %82, %struct.TYPE_5__** %91
br label %107
92: ; preds = %81, %86
%93 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %82, i64 0, i32 7
%94 = load %struct.TYPE_5__*, %struct.TYPE_5__** %93
%95 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %94, i64 0, i32 5
%96 = load i64, i64* %95
%97 = icmp slt i64 %96, %75
br i1 %97, label %107, label %81
98: ; preds = %49
%99 = load i32, i32* %50
%100 = call i64 @S_ISLNK(i32 %99)
%101 = icmp eq i64 %100, 0
br i1 %101, label %102, label %107
102: ; preds = %98
%103 = load i32, i32* %50
%104 = call i64 @S_ISREG(i32 %103)
%105 = icmp eq i64 %104, 0
%106 = select i1 %105, i32* @FTS_DEFAULT, i32* @FTS_F
br label %107
107: ; preds = %92, %74, %102, %98, %70, %67, %90, %43, %36
%108 = phi i32* [ @FTS_NS, %43 ], [ @FTS_SLNONE, %36 ], [ @FTS_DC, %90 ], [ @FTS_DOT, %67 ], [ @FTS_DOT, %70 ], [ @FTS_SL, %98 ], [ %106, %102 ], [ @FTS_D, %74 ], [ @FTS_D, %92 ]
%109 = load i32, i32* %108
ret i32 %109
}