#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 */

/* Type definitions */
typedef int /*<<< orphan*/ FTSENT;
typedef int /*<<< orphan*/ FTS;

/* Variables and functions */
int FTS_NOCHDIR;
int FTS_PHYSICAL;
int /*<<< orphan*/ FTS_SKIP;
scalar_t__ fts_close(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fts_open(char *const *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fts_read(int /*<<< orphan*/ *);
scalar_t__ fts_set(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                   int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int main(void) {
  const char *argv[2];
  FTS *ftsp;
  FTSENT *entry;
  argv[0] = ".";
  argv[1] = (char *)NULL;
  ftsp = fts_open((char *const *)argv, FTS_PHYSICAL | FTS_NOCHDIR, NULL);
  if (ftsp == NULL) {
    perror("fts_open");
    return 1;
  }
  entry = fts_read(ftsp);
  if (entry == NULL) {
    perror("fts_read");
    return 1;
  }
  if (fts_set(ftsp, entry, FTS_SKIP) != 0) {
    perror("fts_set");
    return 1;
  }
  if (fts_close(ftsp) != 0) {
    perror("fts_close");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
mov    0x2e73(%rip),%rax
mov    (%rax),%esi
mov    0x2e4a(%rip),%rax
or     (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <fts_open@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11b8 <main+0x68>
lea    0xe5b(%rip),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1252 <main+0x102>
mov    -0x28(%rbp),%rdi
call   1050 <fts_read@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11e8 <main+0x98>
lea    0xe34(%rip),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1252 <main+0x102>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    0x2de9(%rip),%rax
mov    (%rax),%edx
call   1030 <fts_set@plt>
cmp    $0x0,%rax
je     1220 <main+0xd0>
lea    0xe05(%rip),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1252 <main+0x102>
mov    -0x28(%rbp),%rdi
call   1040 <fts_close@plt>
cmp    $0x0,%rax
je     124b <main+0xfb>
lea    0xde2(%rip),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1252 <main+0x102>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xea4(%rip),%rax
mov    %rax,(%rsp)
movq   $0x0,0x8(%rsp)
mov    0x2e80(%rip),%rax
mov    0x2e59(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %rsp,%rdi
xor    %edx,%edx
call   1060 <fts_open@plt>
test   %rax,%rax
je     11ce <main+0x7e>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <fts_read@plt>
test   %rax,%rax
je     11d7 <main+0x87>
mov    0x2e3f(%rip),%rcx
mov    (%rcx),%edx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <fts_set@plt>
test   %rax,%rax
jne    11e0 <main+0x90>
mov    %rbx,%rdi
call   1040 <fts_close@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     11f1 <main+0xa1>
lea    0xe50(%rip),%rdi
jmp    11e7 <main+0x97>
lea    0xe2d(%rip),%rdi
jmp    11e7 <main+0x97>
lea    0xe2d(%rip),%rdi
jmp    11e7 <main+0x97>
lea    0xe2d(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
@FTS_PHYSICAL = global i32 0
@FTS_NOCHDIR = global i32 0
@.str.1 = [9 x i8] c"fts_open\00"
@.str.2 = [9 x i8] c"fts_read\00"
@FTS_SKIP = global i32 0
@.str.3 = [8 x i8] c"fts_set\00"
@.str.4 = [10 x i8] c"fts_close\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i8*]
%3 = alloca i32*
%4 = alloca i32*
store i32 0, i32* %1
%5 = getelementptr inbounds [2 x i8*], [2 x i8*]* %2, i64 0, i64 0
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [2 x i8*], [2 x i8*]* %2, i64 0, i64 1
store i8* null, i8** %6
%7 = getelementptr inbounds [2 x i8*], [2 x i8*]* %2, i64 0, i64 0
%8 = load i32, i32* @FTS_PHYSICAL
%9 = load i32, i32* @FTS_NOCHDIR
%10 = or i32 %8, %9
%11 = call i32* @fts_open(i8** %7, i32 %10, i32* null)
store i32* %11, i32** %3
%12 = load i32*, i32** %3
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %38
16: ; preds = %0
%17 = load i32*, i32** %3
%18 = call i32* @fts_read(i32* %17)
store i32* %18, i32** %4
%19 = load i32*, i32** %4
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %38
23: ; preds = %16
%24 = load i32*, i32** %3
%25 = load i32*, i32** %4
%26 = load i32, i32* @FTS_SKIP
%27 = call i64 @fts_set(i32* %24, i32* %25, i32 %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %23
%30 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %1
br label %38
31: ; preds = %23
%32 = load i32*, i32** %3
%33 = call i64 @fts_close(i32* %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %1
br label %38
37: ; preds = %31
store i32 0, i32* %1
br label %38
38: ; preds = %37, %35, %29, %21, %14
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
@FTS_PHYSICAL = global i32 0
@FTS_NOCHDIR = global i32 0
@.str.1 = [9 x i8] c"fts_open\00"
@.str.2 = [9 x i8] c"fts_read\00"
@FTS_SKIP = global i32 0
@.str.3 = [8 x i8] c"fts_set\00"
@.str.4 = [10 x i8] c"fts_close\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
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 1
store i8* null, i8** %4
%5 = load i32, i32* @FTS_PHYSICAL
%6 = load i32, i32* @FTS_NOCHDIR
%7 = or i32 %6, %5
%8 = call i32* @fts_open(i8** %3, i32 %7, i32* null)
%9 = icmp eq i32* %8, null
br i1 %9, label %20, label %10
10: ; preds = %0
%11 = call i32* @fts_read(i32* %8)
%12 = icmp eq i32* %11, null
br i1 %12, label %20, label %13
13: ; preds = %10
%14 = load i32, i32* @FTS_SKIP
%15 = call i64 @fts_set(i32* %8, i32* %11, i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = call i64 @fts_close(i32* %8)
%19 = icmp eq i64 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %17, %13, %10, %0
%21 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %0 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), %10 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), %13 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), %17 ]
%22 = call i32 @perror(i8* %21)
br label %23
23: ; preds = %20, %17
%24 = phi i32 [ 0, %17 ], [ 1, %20 ]
ret i32 %24
}