#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__ {
  int fts_errno;
  scalar_t__ fts_dev;
  scalar_t__ fts_ino;
  char *fts_name;
  scalar_t__ fts_level;
  struct TYPE_5__ *fts_cycle;
  struct TYPE_5__ *fts_parent;
  int /*<<< orphan*/ fts_nlink;
  int /*<<< orphan*/ fts_accpath;
  struct stat *fts_statp;
};
typedef TYPE_1__ FTSENT;
typedef TYPE_2__ FTS;

/* Variables and functions */
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__ lstat(int /*<<< orphan*/, struct stat *);
int /*<<< orphan*/ memset(struct stat *, int /*<<< orphan*/, int);
scalar_t__ stat(int /*<<< orphan*/, struct stat *);
u_short fts_stat(FTS *sp, FTSENT *p, int follow) {
  FTSENT *t;
  dev_t dev;
  ino_t ino;
  struct stat *sbp, sb;
  int saved_errno;
  sbp = (sp->fts_options & (FTS_NOSTAT)) ? &sb : p->fts_statp;
  if ((sp->fts_options & (FTS_LOGICAL)) || follow) {
    if (stat(p->fts_accpath, sbp)) {
      saved_errno = errno;
      if (!lstat(p->fts_accpath, sbp)) {
        errno = 0;
        return (FTS_SLNONE);
      }
      p->fts_errno = saved_errno;
      goto err;
    }
  } else if (lstat(p->fts_accpath, sbp)) {
    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    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2e18(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1198 <fts_stat+0x38>
lea    -0x58(%rbp),%rax
mov    %rax,-0x68(%rbp)
jmp    11a4 <fts_stat+0x44>
mov    -0x18(%rbp),%rax
mov    0x40(%rax),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2e2f(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    11ce <fts_stat+0x6e>
cmpl   $0x0,-0x1c(%rbp)
je     1241 <fts_stat+0xe1>
mov    -0x18(%rbp),%rax
mov    0x3c(%rax),%edi
mov    -0x40(%rbp),%rsi
call   1070 <stat@plt>
cmp    $0x0,%rax
je     123c <fts_stat+0xdc>
mov    0x2db1(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x5c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x3c(%rax),%edi
mov    -0x40(%rbp),%rsi
call   1060 <lstat@plt>
cmp    $0x0,%rax
jne    122e <fts_stat+0xce>
mov    0x2d8a(%rip),%rax
movq   $0x0,(%rax)
mov    0x2d9c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1422 <fts_stat+0x2c2>
mov    -0x5c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    126d <fts_stat+0x10d>
jmp    1293 <fts_stat+0x133>
mov    -0x18(%rbp),%rax
mov    0x3c(%rax),%edi
mov    -0x40(%rbp),%rsi
call   1060 <lstat@plt>
cmp    $0x0,%rax
je     128e <fts_stat+0x12e>
mov    0x2d3e(%rip),%rax
mov    (%rax),%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
mov    0x2cfc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1422 <fts_stat+0x2c2>
jmp    1293 <fts_stat+0x133>
mov    -0x40(%rbp),%rax
mov    0x10(%rax),%edi
call   1040 <S_ISDIR@plt>
cmp    $0x0,%rax
je     13c8 <fts_stat+0x268>
mov    -0x40(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%rcx
mov    %rax,0x8(%rcx)
mov    %rax,-0x30(%rbp)
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x18(%rbp),%rcx
mov    %rax,0x10(%rcx)
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rax
mov    0x14(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x38(%rax)
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    133c <fts_stat+0x1dc>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
cmpb   $0x0,0x1(%rax)
je     132b <fts_stat+0x1cb>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2e,%eax
jne    133c <fts_stat+0x1dc>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
cmpb   $0x0,0x2(%rax)
jne    133c <fts_stat+0x1dc>
mov    0x2c96(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1422 <fts_stat+0x2c2>
mov    -0x18(%rbp),%rax
mov    0x30(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    0x20(%rax),%rax
mov    0x2c81(%rip),%rcx
cmp    (%rcx),%rax
jl     13b7 <fts_stat+0x257>
mov    -0x38(%rbp),%rax
mov    -0x28(%rbp),%rcx
cmp    0x10(%rcx),%rax
jne    13a1 <fts_stat+0x241>
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
cmp    0x8(%rcx),%rax
jne    13a1 <fts_stat+0x241>
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x28(%rax)
mov    0x2bf9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1422 <fts_stat+0x2c2>
jmp    13a6 <fts_stat+0x246>
mov    -0x28(%rbp),%rax
mov    0x30(%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1348 <fts_stat+0x1e8>
mov    0x2bf2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1422 <fts_stat+0x2c2>
mov    -0x40(%rbp),%rax
mov    0x10(%rax),%edi
call   1030 <S_ISLNK@plt>
cmp    $0x0,%rax
je     13ef <fts_stat+0x28f>
mov    0x2beb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1422 <fts_stat+0x2c2>
mov    -0x40(%rbp),%rax
mov    0x10(%rax),%edi
call   1080 <S_ISREG@plt>
cmp    $0x0,%rax
je     1416 <fts_stat+0x2b6>
mov    0x2bac(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1422 <fts_stat+0x2c2>
mov    0x2bd3(%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   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    (%rdi),%eax
mov    0x2e21(%rip),%rcx
test   %eax,(%rcx)
je     1180 <fts_stat+0x20>
mov    %rsp,%rbx
jmp    1184 <fts_stat+0x24>
mov    0x40(%r14),%rbx
mov    0x2e5d(%rip),%rcx
and    (%rcx),%eax
or     %edx,%eax
mov    0x3c(%r14),%edi
mov    %rbx,%rsi
je     11cf <fts_stat+0x6f>
call   1070 <stat@plt>
test   %rax,%rax
je     120a <fts_stat+0xaa>
mov    0x2df7(%rip),%r12
mov    (%r12),%r15
mov    0x3c(%r14),%edi
mov    %rbx,%rsi
call   1060 <lstat@plt>
test   %rax,%rax
jne    11e3 <fts_stat+0x83>
movq   $0x0,(%r12)
mov    0x2df3(%rip),%rax
jmp    11fc <fts_stat+0x9c>
call   1060 <lstat@plt>
test   %rax,%rax
je     120a <fts_stat+0xaa>
mov    0x2dc0(%rip),%rax
mov    (%rax),%r15
mov    %r15d,(%r14)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
mov    0x2d84(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x10(%rbx),%edi
call   1040 <S_ISDIR@plt>
test   %rax,%rax
je     1296 <fts_stat+0x136>
mov    (%rbx),%rcx
mov    %rcx,0x8(%r14)
mov    0x8(%rbx),%rdx
mov    %rdx,0x10(%r14)
mov    0x14(%rbx),%eax
mov    %eax,0x38(%r14)
mov    0x18(%r14),%rsi
cmpb   $0x2e,(%rsi)
jne    124f <fts_stat+0xef>
mov    0x1(%rsi),%bl
mov    0x2d88(%rip),%rax
test   %bl,%bl
je     11fc <fts_stat+0x9c>
cmp    $0x2e,%bl
jne    124f <fts_stat+0xef>
cmpb   $0x0,0x2(%rsi)
je     11fc <fts_stat+0x9c>
mov    0x2d82(%rip),%rax
mov    (%rax),%rdi
mov    0x30(%r14),%rsi
mov    0x2d4c(%rip),%rax
jmp    1274 <fts_stat+0x114>
cs nopw 0x0(%rax,%rax,1)
mov    0x30(%rsi),%rsi
cmp    %rdi,0x20(%rsi)
jl     11fc <fts_stat+0x9c>
cmp    0x10(%rsi),%rdx
jne    1270 <fts_stat+0x110>
cmp    0x8(%rsi),%rcx
jne    1270 <fts_stat+0x110>
mov    %rsi,0x28(%r14)
mov    0x2cff(%rip),%rax
jmp    11fc <fts_stat+0x9c>
mov    0x10(%rbx),%edi
call   1030 <S_ISLNK@plt>
test   %rax,%rax
je     12af <fts_stat+0x14f>
mov    0x2d26(%rip),%rax
jmp    11fc <fts_stat+0x9c>
mov    0x10(%rbx),%edi
call   1080 <S_ISREG@plt>
test   %rax,%rax
jne    12c8 <fts_stat+0x168>
mov    0x2d2d(%rip),%rax
jmp    11fc <fts_stat+0x9c>
mov    0x2ce9(%rip),%rax
jmp    11fc <fts_stat+0x9c>

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

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