#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 /*<<< orphan*/, 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, 0, 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
xor    %edx,%edx
mov    %edx,%esi
call   1060 <fts_open@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1213 <main+0x93>
lea    0xe1e(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
jmp    1218 <main+0x98>
mov    -0x18(%rbp),%rdi
call   1050 <fts_read@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     126b <main+0xeb>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    0x2dac(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2d9b(%rip),%rdx
or     (%rdx),%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1266 <main+0xe6>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdca(%rip),%rdi
call   1040 <printf@plt>
jmp    1218 <main+0x98>
mov    0x2d56(%rip),%rax
cmpq   $0x0,(%rax)
je     1292 <main+0x112>
lea    0xdac(%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    12bc <main+0x13c>
lea    0xd8d(%rip),%rdi
call   1080 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    12c3 <main+0x143>
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
cmp    $0x2,%edi
jle    1233 <main+0xc3>
add    $0x10,%rsi
mov    %rsi,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <fts_open@plt>
test   %rax,%rax
je     1255 <main+0xe5>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <fts_read@plt>
test   %rax,%rax
je     11f6 <main+0x86>
mov    0x2e37(%rip),%r15
mov    0x2e28(%rip),%r12
lea    0xe6c(%rip),%r14
jmp    11dd <main+0x6d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <fts_read@plt>
test   %rax,%rax
je     11f6 <main+0x86>
mov    (%r12),%ecx
or     (%r15),%ecx
test   %ecx,(%rax)
je     11d0 <main+0x60>
mov    0x8(%rax),%rsi
mov    %r14,%rdi
call   1040 <printf@plt>
jmp    11d0 <main+0x60>
mov    0x2dcb(%rip),%rax
cmpq   $0x0,(%rax)
jne    125e <main+0xee>
mov    %rbx,%rdi
call   1030 <fts_close@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
je     1220 <main+0xb0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe11(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%eax
jmp    1214 <main+0xa4>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xdba(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x2,%edi
call   1090 <exit@plt>
lea    0xdc6(%rip),%rdi
jmp    1265 <main+0xf5>
lea    0xdca(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <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 = call i32* @fts_open(i8** %26, i32 0, i32 0)
store i32* %27, i32** %6
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %32
29: ; preds = %19
%30 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %19
br label %33
33: ; preds = %51, %32
%34 = load i32*, i32** %6
%35 = call %struct.TYPE_3__* @fts_read(i32* %34)
store %struct.TYPE_3__* %35, %struct.TYPE_3__** %7
%36 = icmp ne %struct.TYPE_3__* %35, null
br i1 %36, label %37, label %52
37: ; preds = %33
%38 = load %struct.TYPE_3__*, %struct.TYPE_3__** %7
%39 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %38, i32 0, i32 0
%40 = load i32, i32* %39
%41 = load i32, i32* @FTS_F
%42 = load i32, i32* @FTS_D
%43 = or i32 %41, %42
%44 = and i32 %40, %43
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %51
46: ; preds = %37
%47 = load %struct.TYPE_3__*, %struct.TYPE_3__** %7
%48 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %47, i32 0, i32 1
%49 = load i8*, i8** %48
%50 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %46, %37
br label %33
52: ; preds = %33
%53 = load i64, i64* @errno
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %52
%56 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %52
%59 = load i32*, i32** %6
%60 = call i32 @fts_close(i32* %59)
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %64
62: ; preds = %58
%63 = 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 %65
64: ; preds = %58
store i32 0, i32* %3
br label %65
65: ; preds = %64, %62
%66 = load i32, i32* %3
ret i32 %66
}

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 2
%11 = tail call i32* @fts_open(i8** %10, i32 0, i32 0)
%12 = icmp eq i32* %11, null
br i1 %12, label %16, label %13
13: ; preds = %9
%14 = tail call %struct.TYPE_3__* @fts_read(i32* %11)
%15 = icmp eq %struct.TYPE_3__* %14, null
br i1 %15, label %35, label %19
16: ; preds = %9
%17 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %13, %32
%20 = phi %struct.TYPE_3__* [ %33, %32 ], [ %14, %13 ]
%21 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %20, i64 0, i32 0
%22 = load i32, i32* %21
%23 = load i32, i32* @FTS_F
%24 = load i32, i32* @FTS_D
%25 = or i32 %24, %23
%26 = and i32 %25, %22
%27 = icmp eq i32 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %19
%29 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %20, i64 0, i32 1
%30 = load i8*, i8** %29
%31 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %28, %19
%33 = tail call %struct.TYPE_3__* @fts_read(i32* %11)
%34 = icmp eq %struct.TYPE_3__* %33, null
br i1 %34, label %35, label %19
35: ; preds = %32, %13
%36 = load i64, i64* @errno
%37 = icmp eq i64 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %35
%39 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%40 = tail call i32 @exit(i32 1)
unreachable
41: ; preds = %35
%42 = tail call i32 @fts_close(i32* %11)
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = tail call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %46
46: ; preds = %41, %44
%47 = phi i32 [ 1, %44 ], [ 0, %41 ]
ret i32 %47
}