#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__ {
  char *fts_path;
  int fts_level;
};
typedef TYPE_1__ FTSENT;
typedef int /*<<< orphan*/ FTS;

/* Variables and functions */
int /*<<< orphan*/ FTS_LOGICAL;
int /*<<< orphan*/ assert(int /*<<< orphan*/ *);
int /*<<< orphan*/ fts_close(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fts_open(char *const *, int /*<<< orphan*/,
                             int /*<<< orphan*/ *);
TYPE_1__ *fts_read(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *, int);
int main() {
  char *const path_argv[] = {"/Users/styx/zion/projects/ssearcher", NULL};
  FTSENT *entry = NULL;
  FTS *pfts = fts_open(path_argv, FTS_LOGICAL, NULL);
  assert(pfts);
  while (entry = fts_read(pfts)) {
    printf("%s %d\n", entry->fts_path, entry->fts_level);
  }
  fts_close(pfts);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2c9a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c97(%rip),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
mov    0x2e60(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <fts_open@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1070 <assert@plt>
mov    -0x30(%rbp),%rdi
call   1050 <fts_read@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     11d6 <main+0x86>
mov    -0x28(%rbp),%rax
mov    (%rax),%rsi
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%edx
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
jmp    11a0 <main+0x50>
mov    -0x30(%rbp),%rdi
call   1030 <fts_close@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movaps 0x2ca2(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    0x2e7f(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdi
xor    %edx,%edx
call   1060 <fts_open@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <assert@plt>
mov    %rbx,%rdi
call   1050 <fts_read@plt>
test   %rax,%rax
je     11bb <main+0x6b>
lea    0xe90(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rax),%rsi
mov    0x8(%rax),%edx
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <fts_read@plt>
test   %rax,%rax
jne    11a0 <main+0x50>
mov    %rbx,%rdi
call   1030 <fts_close@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i8*, i32 }
@.str = [36 x i8] c"/Users/styx/zion/projects/ssearcher\00"
@__const.main.path_argv = [2 x i8*] [i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i32 0, i32 0), i8* null]
@FTS_LOGICAL = global i32 0
@.str.1 = [7 x i8] c"%s %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i8*]
%3 = alloca %struct.TYPE_3__*
%4 = alloca i32*
store i32 0, i32* %1
%5 = bitcast [2 x i8*]* %2 to i8*
store %struct.TYPE_3__* null, %struct.TYPE_3__** %3
%6 = getelementptr inbounds [2 x i8*], [2 x i8*]* %2, i64 0, i64 0
%7 = load i32, i32* @FTS_LOGICAL
%8 = call i32* @fts_open(i8** %6, i32 %7, i32* null)
store i32* %8, i32** %4
%9 = load i32*, i32** %4
%10 = call i32 @assert(i32* %9)
br label %11
11: ; preds = %15, %0
%12 = load i32*, i32** %4
%13 = call %struct.TYPE_3__* @fts_read(i32* %12)
store %struct.TYPE_3__* %13, %struct.TYPE_3__** %3
%14 = icmp ne %struct.TYPE_3__* %13, null
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load %struct.TYPE_3__*, %struct.TYPE_3__** %3
%17 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %16, i32 0, i32 0
%18 = load i8*, i8** %17
%19 = load %struct.TYPE_3__*, %struct.TYPE_3__** %3
%20 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %19, i32 0, i32 1
%21 = load i32, i32* %20
%22 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %18, i32 %21)
br label %11
23: ; preds = %11
%24 = load i32*, i32** %4
%25 = call i32 @fts_close(i32* %24)
ret i32 0
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i8*, i32 }
@.str = [36 x i8] c"/Users/styx/zion/projects/ssearcher\00"
@__const.main.path_argv = [2 x i8*] [i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i32 0, i32 0), i8* null]
@FTS_LOGICAL = global i32 0
@.str.1 = [7 x i8] c"%s %d\0A\00"
define i32 @main() {
%1 = alloca [2 x i8*]
%2 = bitcast [2 x i8*]* %1 to i8*
%3 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 0
%4 = load i32, i32* @FTS_LOGICAL
%5 = call i32* @fts_open(i8** %3, i32 %4, i32* null)
%6 = call i32 @assert(i32* %5)
%7 = call %struct.TYPE_3__* @fts_read(i32* %5)
%8 = icmp eq %struct.TYPE_3__* %7, null
br i1 %8, label %18, label %9
9: ; preds = %0, %9
%10 = phi %struct.TYPE_3__* [ %16, %9 ], [ %7, %0 ]
%11 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i64 0, i32 0
%12 = load i8*, i8** %11
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i64 0, i32 1
%14 = load i32, i32* %13
%15 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %12, i32 %14)
%16 = call %struct.TYPE_3__* @fts_read(i32* %5)
%17 = icmp eq %struct.TYPE_3__* %16, null
br i1 %17, label %18, label %9
18: ; preds = %9, %0
%19 = call i32 @fts_close(i32* %5)
ret i32 0
}