#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 */
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 */
unsigned short FTS_D;
unsigned short FTS_DC;
unsigned short FTS_DEFAULT;
unsigned short FTS_DOT;
unsigned short FTS_F;
int FTS_LOGICAL;
int FTS_NOSTAT;
unsigned short FTS_NS;
scalar_t__ FTS_ROOTLEVEL;
unsigned short FTS_SL;
unsigned short FTS_SLNONE;
scalar_t__ S_ISDIR(int /*<<< orphan*/);
scalar_t__ S_ISLNK(int /*<<< orphan*/);
scalar_t__ S_ISREG(int /*<<< orphan*/);
int /*<<< orphan*/ _DIAGASSERT(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 *);
unsigned short fts_stat(FTS *sp, FTSENT *p, int follow) {
  FTSENT *t;
  dev_t dev;
  ino_t ino;
  struct stat *sbp, sb;
  int saved_errno;
  _DIAGASSERT(sp != NULL);
  _DIAGASSERT(p != NULL);
  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(*sbp));
    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)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <_DIAGASSERT@plt>
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <_DIAGASSERT@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2de4(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11cc <fts_stat+0x5c>
lea    -0x58(%rbp),%rax
mov    %rax,-0x68(%rbp)
jmp    11d8 <fts_stat+0x68>
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    0x2dfb(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    1202 <fts_stat+0x92>
cmpl   $0x0,-0x1c(%rbp)
je     1277 <fts_stat+0x107>
mov    -0x18(%rbp),%rax
mov    0x3c(%rax),%edi
mov    -0x40(%rbp),%rsi
call   1070 <stat@plt>
cmp    $0x0,%rax
je     1272 <fts_stat+0x102>
mov    0x2d7d(%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    1264 <fts_stat+0xf4>
mov    0x2d56(%rip),%rax
movq   $0x0,(%rax)
mov    0x2d68(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x2(%rbp)
jmp    1466 <fts_stat+0x2f6>
mov    -0x5c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    12a3 <fts_stat+0x133>
jmp    12cb <fts_stat+0x15b>
mov    -0x18(%rbp),%rax
mov    0x3c(%rax),%edi
mov    -0x40(%rbp),%rsi
call   1060 <lstat@plt>
cmp    $0x0,%rax
je     12c6 <fts_stat+0x156>
mov    0x2d08(%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    0x2cc6(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x2(%rbp)
jmp    1466 <fts_stat+0x2f6>
jmp    12cb <fts_stat+0x15b>
mov    -0x40(%rbp),%rax
mov    0x10(%rax),%edi
call   1040 <S_ISDIR@plt>
cmp    $0x0,%rax
je     1406 <fts_stat+0x296>
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    1376 <fts_stat+0x206>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
cmpb   $0x0,0x1(%rax)
je     1363 <fts_stat+0x1f3>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2e,%eax
jne    1376 <fts_stat+0x206>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
cmpb   $0x0,0x2(%rax)
jne    1376 <fts_stat+0x206>
mov    0x2c5e(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x2(%rbp)
jmp    1466 <fts_stat+0x2f6>
mov    -0x18(%rbp),%rax
mov    0x30(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    0x20(%rax),%rax
mov    0x2c47(%rip),%rcx
cmp    (%rcx),%rax
jl     13f3 <fts_stat+0x283>
mov    -0x38(%rbp),%rax
mov    -0x28(%rbp),%rcx
cmp    0x10(%rcx),%rax
jne    13dd <fts_stat+0x26d>
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
cmp    0x8(%rcx),%rax
jne    13dd <fts_stat+0x26d>
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,0x28(%rax)
mov    0x2bbf(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x2(%rbp)
jmp    1466 <fts_stat+0x2f6>
jmp    13e2 <fts_stat+0x272>
mov    -0x28(%rbp),%rax
mov    0x30(%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1382 <fts_stat+0x212>
mov    0x2bb6(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x2(%rbp)
jmp    1466 <fts_stat+0x2f6>
mov    -0x40(%rbp),%rax
mov    0x10(%rax),%edi
call   1030 <S_ISLNK@plt>
cmp    $0x0,%rax
je     142f <fts_stat+0x2bf>
mov    0x2bad(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x2(%rbp)
jmp    1466 <fts_stat+0x2f6>
mov    -0x40(%rbp),%rax
mov    0x10(%rax),%edi
call   1080 <S_ISREG@plt>
cmp    $0x0,%rax
je     1458 <fts_stat+0x2e8>
mov    0x2b6c(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x2(%rbp)
jmp    1466 <fts_stat+0x2f6>
mov    0x2b91(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x2(%rbp)
movzwl -0x2(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fts_stat>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1090 <_DIAGASSERT@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1090 <_DIAGASSERT@plt>
mov    (%rbx),%eax
mov    0x2df1(%rip),%rcx
test   %eax,(%rcx)
je     11b0 <fts_stat+0x40>
mov    %rsp,%rbx
jmp    11b4 <fts_stat+0x44>
mov    0x40(%r14),%rbx
mov    0x2e2d(%rip),%rcx
and    (%rcx),%eax
or     %ebp,%eax
mov    0x3c(%r14),%edi
mov    %rbx,%rsi
je     11fd <fts_stat+0x8d>
call   1070 <stat@plt>
test   %rax,%rax
je     1238 <fts_stat+0xc8>
mov    0x2dc7(%rip),%r15
mov    (%r15),%rbp
mov    0x3c(%r14),%edi
mov    %rbx,%rsi
call   1060 <lstat@plt>
test   %rax,%rax
jne    1211 <fts_stat+0xa1>
movq   $0x0,(%r15)
mov    0x2dc5(%rip),%rax
jmp    122a <fts_stat+0xba>
call   1060 <lstat@plt>
test   %rax,%rax
je     1238 <fts_stat+0xc8>
mov    0x2d92(%rip),%rax
mov    (%rax),%rbp
mov    %ebp,(%r14)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
mov    0x2d56(%rip),%rax
movzwl (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x10(%rbx),%edi
call   1040 <S_ISDIR@plt>
test   %rax,%rax
je     12c6 <fts_stat+0x156>
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    1281 <fts_stat+0x111>
mov    0x1(%rsi),%bl
mov    0x2d56(%rip),%rax
test   %bl,%bl
je     122a <fts_stat+0xba>
cmp    $0x2e,%bl
jne    1281 <fts_stat+0x111>
cmpb   $0x0,0x2(%rsi)
je     122a <fts_stat+0xba>
mov    0x2d50(%rip),%rax
mov    (%rax),%rdi
mov    0x30(%r14),%rsi
mov    0x2d1a(%rip),%rax
jmp    12a4 <fts_stat+0x134>
nopl   0x0(%rax,%rax,1)
mov    0x30(%rsi),%rsi
cmp    %rdi,0x20(%rsi)
jl     122a <fts_stat+0xba>
cmp    0x10(%rsi),%rdx
jne    12a0 <fts_stat+0x130>
cmp    0x8(%rsi),%rcx
jne    12a0 <fts_stat+0x130>
mov    %rsi,0x28(%r14)
mov    0x2ccf(%rip),%rax
jmp    122a <fts_stat+0xba>
mov    0x10(%rbx),%edi
call   1030 <S_ISLNK@plt>
test   %rax,%rax
je     12df <fts_stat+0x16f>
mov    0x2cf6(%rip),%rax
jmp    122a <fts_stat+0xba>
mov    0x10(%rbx),%edi
call   1080 <S_ISREG@plt>
test   %rax,%rax
jne    12f8 <fts_stat+0x188>
mov    0x2cfd(%rip),%rax
jmp    122a <fts_stat+0xba>
mov    0x2cb9(%rip),%rax
jmp    122a <fts_stat+0xba>

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

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