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

/* Type definitions */
struct TYPE_3__ {
  int fts_info;
  char *fts_path;
};
typedef TYPE_1__ FTSENT;
typedef int /*<<< orphan*/ FTS;

/* Variables and functions */
int FTS_D;
int FTS_F;
int atoi(char *);
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int fts_close(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fts_open(char **, int, int /*<<< orphan*/);
TYPE_1__ *fts_read(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FTS *tree;
  FTSENT *node;
  int options;
  char **paths;
  if (argc < 3) {
    fprintf(stderr, "Usage: %s options path [path...]\n", argv[0]);
    exit(2);
  }
  options = atoi(argv[1]);
  paths = argv + 2;
  if ((tree = fts_open(paths, options, 0)) == NULL) {
    perror("fts_open");
    exit(1);
  }
  while ((node = fts_read(tree)) != NULL) {
    if (node->fts_info & (FTS_F | FTS_D)) {
      printf("%s\n", node->fts_path);
    }
  }
  if (errno) {
    perror("fts_read");
    exit(1);
  }
  if ((fts_close(tree)) == -1) {
    perror("fts_close");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11c6 <main+0x46>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe49(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x2,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%esi
xor    %edx,%edx
call   1060 <fts_open@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1214 <main+0x94>
lea    0xe1d(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
jmp    1219 <main+0x99>
mov    -0x18(%rbp),%rdi
call   1050 <fts_read@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     126c <main+0xec>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    0x2dab(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2d9a(%rip),%rdx
or     (%rdx),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1267 <main+0xe7>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdc9(%rip),%rdi
call   1040 <printf@plt>
jmp    1219 <main+0x99>
mov    0x2d55(%rip),%rax
cmpq   $0x0,(%rax)
je     1293 <main+0x113>
lea    0xdab(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fts_close@plt>
cmp    $0xffffffff,%eax
jne    12bd <main+0x13d>
lea    0xd8c(%rip),%rdi
call   1080 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    12c4 <main+0x144>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jle    1243 <main+0xc3>
mov    0x8(%rbx),%rdi
call   1090 <atoi@plt>
add    $0x10,%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %edx,%edx
call   1060 <fts_open@plt>
test   %rax,%rax
je     1265 <main+0xe5>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <fts_read@plt>
test   %rax,%rax
je     1206 <main+0x86>
mov    0x2e1b(%rip),%r15
mov    0x2e0c(%rip),%r12
lea    0xe50(%rip),%r14
jmp    11ed <main+0x6d>
nopl   (%rax)
mov    %rbx,%rdi
call   1050 <fts_read@plt>
test   %rax,%rax
je     1206 <main+0x86>
mov    (%r12),%ecx
or     (%r15),%ecx
test   %ecx,(%rax)
je     11e0 <main+0x60>
mov    0x8(%rax),%rsi
mov    %r14,%rdi
call   1040 <printf@plt>
jmp    11e0 <main+0x60>
mov    0x2dbb(%rip),%rax
cmpq   $0x0,(%rax)
jne    126e <main+0xee>
mov    %rbx,%rdi
call   1030 <fts_close@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
je     1230 <main+0xb0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe01(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%eax
jmp    1224 <main+0xa4>
mov    0x2d86(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdaa(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x2,%edi
call   10a0 <exit@plt>
lea    0xdb6(%rip),%rdi
jmp    1275 <main+0xf5>
lea    0xdba(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i8* }
@stderr = global i32 0
@.str = [34 x i8] c"Usage: %s options path [path...]\0A\00"
@.str.1 = [9 x i8] c"fts_open\00"
@FTS_F = global i32 0
@FTS_D = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
@errno = global i64 0
@.str.3 = [9 x i8] c"fts_read\00"
@.str.4 = [10 x i8] c"fts_close\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca %struct.TYPE_3__*
%8 = alloca i32
%9 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 2)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %8
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
store i8** %25, i8*** %9
%26 = load i8**, i8*** %9
%27 = load i32, i32* %8
%28 = call i32* @fts_open(i8** %26, i32 %27, i32 0)
store i32* %28, i32** %6
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %33
30: ; preds = %19
%31 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %19
br label %34
34: ; preds = %52, %33
%35 = load i32*, i32** %6
%36 = call %struct.TYPE_3__* @fts_read(i32* %35)
store %struct.TYPE_3__* %36, %struct.TYPE_3__** %7
%37 = icmp ne %struct.TYPE_3__* %36, null
br i1 %37, label %38, label %53
38: ; preds = %34
%39 = load %struct.TYPE_3__*, %struct.TYPE_3__** %7
%40 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %39, i32 0, i32 0
%41 = load i32, i32* %40
%42 = load i32, i32* @FTS_F
%43 = load i32, i32* @FTS_D
%44 = or i32 %42, %43
%45 = and i32 %41, %44
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %52
47: ; preds = %38
%48 = load %struct.TYPE_3__*, %struct.TYPE_3__** %7
%49 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %48, i32 0, i32 1
%50 = load i8*, i8** %49
%51 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %50)
br label %52
52: ; preds = %47, %38
br label %34
53: ; preds = %34
%54 = load i64, i64* @errno
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %53
%57 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%58 = call i32 @exit(i32 1)
unreachable
59: ; preds = %53
%60 = load i32*, i32** %6
%61 = call i32 @fts_close(i32* %60)
%62 = icmp eq i32 %61, -1
br i1 %62, label %63, label %65
63: ; preds = %59
%64 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %66
65: ; preds = %59
store i32 0, i32* %3
br label %66
66: ; preds = %65, %63
%67 = load i32, i32* %3
ret i32 %67
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i8* }
@stderr = global i32 0
@.str = [34 x i8] c"Usage: %s options path [path...]\0A\00"
@.str.1 = [9 x i8] c"fts_open\00"
@FTS_F = global i32 0
@FTS_D = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
@errno = global i64 0
@.str.3 = [9 x i8] c"fts_read\00"
@.str.4 = [10 x i8] c"fts_close\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 2)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = tail call i32* @fts_open(i8** %13, i32 %12, i32 0)
%15 = icmp eq i32* %14, null
br i1 %15, label %19, label %16
16: ; preds = %9
%17 = tail call %struct.TYPE_3__* @fts_read(i32* %14)
%18 = icmp eq %struct.TYPE_3__* %17, null
br i1 %18, label %38, label %22
19: ; preds = %9
%20 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %16, %35
%23 = phi %struct.TYPE_3__* [ %36, %35 ], [ %17, %16 ]
%24 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %23, i64 0, i32 0
%25 = load i32, i32* %24
%26 = load i32, i32* @FTS_F
%27 = load i32, i32* @FTS_D
%28 = or i32 %27, %26
%29 = and i32 %28, %25
%30 = icmp eq i32 %29, 0
br i1 %30, label %35, label %31
31: ; preds = %22
%32 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %23, i64 0, i32 1
%33 = load i8*, i8** %32
%34 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %31, %22
%36 = tail call %struct.TYPE_3__* @fts_read(i32* %14)
%37 = icmp eq %struct.TYPE_3__* %36, null
br i1 %37, label %38, label %22
38: ; preds = %35, %16
%39 = load i64, i64* @errno
%40 = icmp eq i64 %39, 0
br i1 %40, label %44, label %41
41: ; preds = %38
%42 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%43 = tail call i32 @exit(i32 1)
unreachable
44: ; preds = %38
%45 = tail call i32 @fts_close(i32* %14)
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = tail call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %49
49: ; preds = %44, %47
%50 = phi i32 [ 1, %47 ], [ 0, %44 ]
ret i32 %50
}