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

/* Variables and functions */
scalar_t__ FTS_DP;
int /*<<< orphan*/ FTS_PHYSICAL;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fts_close(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fts_open(char *const *, int /*<<< orphan*/,
                             int /*<<< orphan*/ *);
TYPE_1__ *fts_read(int /*<<< orphan*/ *);
int /*<<< orphan*/ kse_setcon(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
void process_one(char *name) {
  FTS *handle = NULL;
  FTSENT *fsent = NULL;
  char *const namelist[2] = {name, NULL};
  handle = fts_open((char *const *)namelist, FTS_PHYSICAL, NULL);
  if (handle == NULL) {
    perror("fts_open: ");
    exit(-1);
  }
  while ((fsent = fts_read(handle)) != NULL) {
    if (fsent->fts_info == FTS_DP)
      continue;
    if (fsent->fts_statp)
      kse_setcon(fsent->fts_path);
  }
  fts_close(handle);
}


x86 assembly (clang, -O0):
<process_one>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x28(%rbp)
lea    -0x30(%rbp),%rdi
mov    0x2e59(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <fts_open@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11c7 <process_one+0x67>
lea    0xe48(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
jmp    11cc <process_one+0x6c>
mov    -0x10(%rbp),%rdi
call   1040 <fts_read@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     121f <process_one+0xbf>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2def(%rip),%rcx
cmp    (%rcx),%rax
jne    11ff <process_one+0x9f>
jmp    11cc <process_one+0x6c>
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     121a <process_one+0xba>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edi
call   1060 <kse_setcon@plt>
jmp    11cc <process_one+0x6c>
mov    -0x10(%rbp),%rdi
call   1030 <fts_close@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_one>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,(%rsp)
movq   $0x0,0x8(%rsp)
mov    0x2e75(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdi
xor    %edx,%edx
call   1050 <fts_open@plt>
test   %rax,%rax
je     11e6 <process_one+0x86>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <fts_read@plt>
test   %rax,%rax
je     11d6 <process_one+0x76>
mov    0x2e3d(%rip),%r14
jmp    11bd <process_one+0x5d>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1040 <fts_read@plt>
test   %rax,%rax
je     11d6 <process_one+0x76>
mov    (%rax),%rcx
cmp    (%r14),%rcx
je     11b0 <process_one+0x50>
cmpq   $0x0,0x10(%rax)
je     11b0 <process_one+0x50>
mov    0x8(%rax),%edi
call   1060 <kse_setcon@plt>
jmp    11b0 <process_one+0x50>
mov    %rbx,%rdi
call   1030 <fts_close@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe13(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64, i32, i64 }
@FTS_PHYSICAL = global i32 0
@.str = [11 x i8] c"fts_open: \00"
@FTS_DP = global i64 0
define void @process_one(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca %struct.TYPE_3__*
%5 = alloca [2 x i8*]
store i8* %0, i8** %2
store i32* null, i32** %3
store %struct.TYPE_3__* null, %struct.TYPE_3__** %4
%6 = getelementptr inbounds [2 x i8*], [2 x i8*]* %5, i64 0, i64 0
%7 = load i8*, i8** %2
store i8* %7, i8** %6
%8 = getelementptr inbounds i8*, i8** %6, i64 1
store i8* null, i8** %8
%9 = getelementptr inbounds [2 x i8*], [2 x i8*]* %5, i64 0, i64 0
%10 = load i32, i32* @FTS_PHYSICAL
%11 = call i32* @fts_open(i8** %9, 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 %17
14: ; preds = %1
%15 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 -1)
unreachable
17: ; preds = %1
br label %18
18: ; preds = %39, %28, %17
%19 = load i32*, i32** %3
%20 = call %struct.TYPE_3__* @fts_read(i32* %19)
store %struct.TYPE_3__* %20, %struct.TYPE_3__** %4
%21 = icmp ne %struct.TYPE_3__* %20, null
br i1 %21, label %22, label %40
22: ; preds = %18
%23 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%24 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %23, i32 0, i32 0
%25 = load i64, i64* %24
%26 = load i64, i64* @FTS_DP
%27 = icmp eq i64 %25, %26
br i1 %27, label %28, label %29
28: ; preds = %22
br label %18
29: ; preds = %22
%30 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%31 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %30, i32 0, i32 2
%32 = load i64, i64* %31
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %29
%35 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%36 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %35, i32 0, i32 1
%37 = load i32, i32* %36
%38 = call i32 @kse_setcon(i32 %37)
br label %39
39: ; preds = %34, %29
br label %18
40: ; preds = %18
%41 = load i32*, i32** %3
%42 = call i32 @fts_close(i32* %41)
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64, i32, i64 }
@FTS_PHYSICAL = global i32 0
@.str = [11 x i8] c"fts_open: \00"
@FTS_DP = global i64 0
define void @process_one(i8* %0) {
%2 = alloca [2 x i8*]
%3 = bitcast [2 x i8*]* %2 to i8*
%4 = getelementptr inbounds [2 x i8*], [2 x i8*]* %2, i64 0, i64 0
store i8* %0, i8** %4
%5 = getelementptr inbounds [2 x i8*], [2 x i8*]* %2, i64 0, i64 1
store i8* null, i8** %5
%6 = load i32, i32* @FTS_PHYSICAL
%7 = call i32* @fts_open(i8** %4, i32 %6, i32* null)
%8 = icmp eq i32* %7, null
br i1 %8, label %12, label %9
9: ; preds = %1
%10 = call %struct.TYPE_3__* @fts_read(i32* %7)
%11 = icmp eq %struct.TYPE_3__* %10, null
br i1 %11, label %32, label %15
12: ; preds = %1
%13 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 -1)
unreachable
15: ; preds = %9, %29
%16 = phi %struct.TYPE_3__* [ %30, %29 ], [ %10, %9 ]
%17 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %16, i64 0, i32 0
%18 = load i64, i64* %17
%19 = load i64, i64* @FTS_DP
%20 = icmp eq i64 %18, %19
br i1 %20, label %29, label %21
21: ; preds = %15
%22 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %16, i64 0, i32 2
%23 = load i64, i64* %22
%24 = icmp eq i64 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %16, i64 0, i32 1
%27 = load i32, i32* %26
%28 = call i32 @kse_setcon(i32 %27)
br label %29
29: ; preds = %21, %25, %15
%30 = call %struct.TYPE_3__* @fts_read(i32* %7)
%31 = icmp eq %struct.TYPE_3__* %30, null
br i1 %31, label %32, label %15
32: ; preds = %29, %9
%33 = call i32 @fts_close(i32* %7)
ret void
}