#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_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  scalar_t__ fts_info;
  char *fts_name;
  int fts_level;
};
typedef TYPE_1__ FTSENT;
typedef int /*<<< orphan*/ FTS;

/* Variables and functions */
scalar_t__ FTS_D;
scalar_t__ FTS_NS;
int FTS_PHYSICAL;
int /*<<< orphan*/ FTS_SKIP;
scalar_t__ FTS_W;
int FTS_WHITEOUT;
int /*<<< orphan*/ fts_close(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fts_open(char **, int, int /*<<< orphan*/ *);
TYPE_1__ *fts_read(int /*<<< orphan*/ *);
int /*<<< orphan*/ fts_set(int /*<<< orphan*/ *, TYPE_1__ *,
                           int /*<<< orphan*/);
char *getcwd(char *, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int main(int argc, char **argv) {
  char **pathnames;
  char *errormsg;
  FTS *tree_stream;
  FTSENT *tree_entry;
  char *dummy;
  if (argc > 1) {
    pathnames = argv;
    pathnames++;
  } else {
    pathnames = (char **)malloc(2 * sizeof(char *));
    pathnames[0] = (char *)malloc(1024);
    dummy = getcwd(pathnames[0], 1024);
    pathnames[1] = NULL;
  }
  if (!(tree_stream = fts_open(pathnames, FTS_PHYSICAL | FTS_WHITEOUT, NULL))) {
    errormsg = (char *)malloc(1024);
    sprintf(errormsg, "cannot fts_open(\"%s\", ...)", pathnames[0]);
    perror(errormsg);
    return 1;
  }
  while (tree_entry = fts_read(tree_stream)) {
    if (tree_entry->fts_info != FTS_NS) {
      if (tree_entry->fts_info == FTS_W) {
        printf("%s\n", tree_entry->fts_name);
      } else if ((tree_entry->fts_info == FTS_D) &&
                 (tree_entry->fts_level == 1)) {
        fts_set(tree_stream, tree_entry, FTS_SKIP);
      }
    }
  }
  fts_close(tree_stream);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11c9 <main+0x39>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    120c <main+0x7c>
mov    $0x10,%edi
call   1090 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x400,%edi
call   1090 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    $0x400,%esi
call   1070 <getcwd@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
movq   $0x0,0x8(%rax)
mov    -0x18(%rbp),%rdi
mov    0x2dd1(%rip),%rax
mov    (%rax),%esi
mov    0x2db0(%rip),%rax
or     (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1080 <fts_open@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1273 <main+0xe3>
mov    $0x400,%edi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
lea    0xda7(%rip),%rsi
call   10b0 <sprintf@plt>
mov    -0x20(%rbp),%rdi
call   10a0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1330 <main+0x1a0>
jmp    1278 <main+0xe8>
mov    -0x28(%rbp),%rdi
call   1060 <fts_read@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1320 <main+0x190>
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
mov    0x2d13(%rip),%rcx
cmp    (%rcx),%rax
je     131b <main+0x18b>
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
mov    0x2d3c(%rip),%rcx
cmp    (%rcx),%rax
jne    12d6 <main+0x146>
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd4f(%rip),%rdi
call   1050 <printf@plt>
jmp    1316 <main+0x186>
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
mov    0x2ce4(%rip),%rcx
cmp    (%rcx),%rax
jne    1311 <main+0x181>
mov    -0x30(%rbp),%rax
cmpl   $0x1,0x10(%rax)
jne    1311 <main+0x181>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    0x2cce(%rip),%rax
mov    (%rax),%edx
call   1030 <fts_set@plt>
jmp    1316 <main+0x186>
jmp    131b <main+0x18b>
jmp    1278 <main+0xe8>
mov    -0x28(%rbp),%rdi
call   1040 <fts_close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     11a9 <main+0x19>
mov    %rsi,%r14
add    $0x8,%r14
jmp    11d8 <main+0x48>
mov    $0x10,%edi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    $0x400,%edi
call   1090 <malloc@plt>
mov    %rax,(%r14)
mov    %rax,%rdi
mov    $0x400,%esi
call   1070 <getcwd@plt>
movq   $0x0,0x8(%r14)
mov    0x2e09(%rip),%rax
mov    0x2dea(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %r14,%rdi
xor    %edx,%edx
call   1080 <fts_open@plt>
test   %rax,%rax
je     129c <main+0x10c>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <fts_read@plt>
test   %rax,%rax
je     1283 <main+0xf3>
mov    0x2d9c(%rip),%r15
mov    0x2dd5(%rip),%r12
lea    0xdf9(%rip),%r14
mov    0x2d9f(%rip),%r13
mov    0x2da8(%rip),%rbp
jmp    1259 <main+0xc9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x8(%rax),%rsi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1060 <fts_read@plt>
test   %rax,%rax
je     1283 <main+0xf3>
mov    (%rax),%rcx
cmp    (%r15),%rcx
je     124c <main+0xbc>
cmp    (%r12),%rcx
je     1240 <main+0xb0>
cmp    0x0(%r13),%rcx
jne    124c <main+0xbc>
cmpl   $0x1,0x10(%rax)
jne    124c <main+0xbc>
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <fts_set@plt>
jmp    124c <main+0xbc>
mov    %rbx,%rdi
call   1040 <fts_close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x400,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    (%r14),%rdx
lea    0xd4d(%rip),%rsi
mov    %rax,%rdi
call   10b0 <sprintf@plt>
mov    %rbx,%rdi
call   10a0 <perror@plt>
mov    $0x1,%eax
jmp    128d <main+0xfd>

LLVM IR (-O0):
%struct.TYPE_4__ = type { i64, i8*, i32 }
@FTS_PHYSICAL = global i32 0
@FTS_WHITEOUT = global i32 0
@.str = [27 x i8] c"cannot fts_open(\22%s\22, ...)\00"
@FTS_NS = global i64 0
@FTS_W = global i64 0
@.str.1 = [4 x i8] c"%s\0A\00"
@FTS_D = global i64 0
@FTS_SKIP = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca %struct.TYPE_4__*
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i8**, i8*** %5
store i8** %14, i8*** %6
%15 = load i8**, i8*** %6
%16 = getelementptr inbounds i8*, i8** %15, i32 1
store i8** %16, i8*** %6
br label %30
17: ; preds = %2
%18 = call i64 @malloc(i32 16)
%19 = inttoptr i64 %18 to i8**
store i8** %19, i8*** %6
%20 = call i64 @malloc(i32 1024)
%21 = inttoptr i64 %20 to i8*
%22 = load i8**, i8*** %6
%23 = getelementptr inbounds i8*, i8** %22, i64 0
store i8* %21, i8** %23
%24 = load i8**, i8*** %6
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i8* @getcwd(i8* %26, i32 1024)
store i8* %27, i8** %10
%28 = load i8**, i8*** %6
%29 = getelementptr inbounds i8*, i8** %28, i64 1
store i8* null, i8** %29
br label %30
30: ; preds = %17, %13
%31 = load i8**, i8*** %6
%32 = load i32, i32* @FTS_PHYSICAL
%33 = load i32, i32* @FTS_WHITEOUT
%34 = or i32 %32, %33
%35 = call i32* @fts_open(i8** %31, i32 %34, i32* null)
store i32* %35, i32** %8
%36 = icmp ne i32* %35, null
br i1 %36, label %47, label %37
37: ; preds = %30
%38 = call i64 @malloc(i32 1024)
%39 = inttoptr i64 %38 to i8*
store i8* %39, i8** %7
%40 = load i8*, i8** %7
%41 = load i8**, i8*** %6
%42 = getelementptr inbounds i8*, i8** %41, i64 0
%43 = load i8*, i8** %42
%44 = call i32 @sprintf(i8* %40, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %43)
%45 = load i8*, i8** %7
%46 = call i32 @perror(i8* %45)
store i32 1, i32* %3
br label %91
47: ; preds = %30
br label %48
48: ; preds = %87, %47
%49 = load i32*, i32** %8
%50 = call %struct.TYPE_4__* @fts_read(i32* %49)
store %struct.TYPE_4__* %50, %struct.TYPE_4__** %9
%51 = icmp ne %struct.TYPE_4__* %50, null
br i1 %51, label %52, label %88
52: ; preds = %48
%53 = load %struct.TYPE_4__*, %struct.TYPE_4__** %9
%54 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %53, i32 0, i32 0
%55 = load i64, i64* %54
%56 = load i64, i64* @FTS_NS
%57 = icmp ne i64 %55, %56
br i1 %57, label %58, label %87
58: ; preds = %52
%59 = load %struct.TYPE_4__*, %struct.TYPE_4__** %9
%60 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %59, i32 0, i32 0
%61 = load i64, i64* %60
%62 = load i64, i64* @FTS_W
%63 = icmp eq i64 %61, %62
br i1 %63, label %64, label %69
64: ; preds = %58
%65 = load %struct.TYPE_4__*, %struct.TYPE_4__** %9
%66 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %65, i32 0, i32 1
%67 = load i8*, i8** %66
%68 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %67)
br label %86
69: ; preds = %58
%70 = load %struct.TYPE_4__*, %struct.TYPE_4__** %9
%71 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %70, i32 0, i32 0
%72 = load i64, i64* %71
%73 = load i64, i64* @FTS_D
%74 = icmp eq i64 %72, %73
br i1 %74, label %75, label %85
75: ; preds = %69
%76 = load %struct.TYPE_4__*, %struct.TYPE_4__** %9
%77 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %76, i32 0, i32 2
%78 = load i32, i32* %77
%79 = icmp eq i32 %78, 1
br i1 %79, label %80, label %85
80: ; preds = %75
%81 = load i32*, i32** %8
%82 = load %struct.TYPE_4__*, %struct.TYPE_4__** %9
%83 = load i32, i32* @FTS_SKIP
%84 = call i32 @fts_set(i32* %81, %struct.TYPE_4__* %82, i32 %83)
br label %85
85: ; preds = %80, %75, %69
br label %86
86: ; preds = %85, %64
br label %87
87: ; preds = %86, %52
br label %48
88: ; preds = %48
%89 = load i32*, i32** %8
%90 = call i32 @fts_close(i32* %89)
store i32 0, i32* %3
br label %91
91: ; preds = %88, %37
%92 = load i32, i32* %3
ret i32 %92
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i64, i8*, i32 }
@FTS_PHYSICAL = global i32 0
@FTS_WHITEOUT = global i32 0
@.str = [27 x i8] c"cannot fts_open(\22%s\22, ...)\00"
@FTS_NS = global i64 0
@FTS_W = global i64 0
@.str.1 = [4 x i8] c"%s\0A\00"
@FTS_D = global i64 0
@FTS_SKIP = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
br label %13
6: ; preds = %2
%7 = tail call i64 @malloc(i32 16)
%8 = inttoptr i64 %7 to i8**
%9 = tail call i64 @malloc(i32 1024)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %8
%11 = tail call i8* @getcwd(i8* %10, i32 1024)
%12 = getelementptr inbounds i8*, i8** %8, i64 1
store i8* null, i8** %12
br label %13
13: ; preds = %6, %4
%14 = phi i8** [ %5, %4 ], [ %8, %6 ]
%15 = load i32, i32* @FTS_PHYSICAL
%16 = load i32, i32* @FTS_WHITEOUT
%17 = or i32 %16, %15
%18 = tail call i32* @fts_open(i8** %14, i32 %17, i32* null)
%19 = icmp eq i32* %18, null
br i1 %19, label %23, label %20
20: ; preds = %13
%21 = tail call %struct.TYPE_4__* @fts_read(i32* %18)
%22 = icmp eq %struct.TYPE_4__* %21, null
br i1 %22, label %55, label %29
23: ; preds = %13
%24 = tail call i64 @malloc(i32 1024)
%25 = inttoptr i64 %24 to i8*
%26 = load i8*, i8** %14
%27 = tail call i32 @sprintf(i8* dereferenceable(1) %25, i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = tail call i32 @perror(i8* %25)
br label %57
29: ; preds = %20, %52
%30 = phi %struct.TYPE_4__* [ %53, %52 ], [ %21, %20 ]
%31 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %30, i64 0, i32 0
%32 = load i64, i64* %31
%33 = load i64, i64* @FTS_NS
%34 = icmp eq i64 %32, %33
br i1 %34, label %52, label %35
35: ; preds = %29
%36 = load i64, i64* @FTS_W
%37 = icmp eq i64 %32, %36
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %30, i64 0, i32 1
%40 = load i8*, i8** %39
%41 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %40)
br label %52
42: ; preds = %35
%43 = load i64, i64* @FTS_D
%44 = icmp eq i64 %32, %43
br i1 %44, label %45, label %52
45: ; preds = %42
%46 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %30, i64 0, i32 2
%47 = load i32, i32* %46
%48 = icmp eq i32 %47, 1
br i1 %48, label %49, label %52
49: ; preds = %45
%50 = load i32, i32* @FTS_SKIP
%51 = tail call i32 @fts_set(i32* %18, %struct.TYPE_4__* %30, i32 %50)
br label %52
52: ; preds = %38, %49, %45, %42, %29
%53 = tail call %struct.TYPE_4__* @fts_read(i32* %18)
%54 = icmp eq %struct.TYPE_4__* %53, null
br i1 %54, label %55, label %29
55: ; preds = %52, %20
%56 = tail call i32 @fts_close(i32* %18)
br label %57
57: ; preds = %55, %23
%58 = phi i32 [ 0, %55 ], [ 1, %23 ]
ret i32 %58
}