#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_6__ TYPE_2__;
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_6__ {
  char *fts_path;
  int /*<<< orphan*/ fts_dev;
};
struct TYPE_5__ {
  size_t fts_pathlen;
  size_t fts_namelen;
  char *fts_name;
  char *fts_accpath;
  char *fts_path;
  int /*<<< orphan*/ fts_dev;
};
typedef TYPE_1__ FTSENT;
typedef TYPE_2__ FTS;

/* Variables and functions */
size_t UINT_MAX;
int /*<<< orphan*/ memmove(char *, char *, size_t);
size_t strlen(char *);
char *strrchr(char *, char);
void fts_load(FTS *sp, FTSENT *p) {
  size_t len;
  char *cp;
  ;
  ;
  len = p->fts_pathlen = p->fts_namelen;
  memmove(sp->fts_path, p->fts_name, len + 1);
  if ((cp = strrchr(p->fts_name, '/')) && (cp != p->fts_name || cp[1])) {
    len = strlen(++cp);
    memmove(p->fts_name, cp, len + 1);
    p->fts_namelen = ((len) > UINT_MAX ? UINT_MAX : (unsigned int)(len));
  }
  p->fts_accpath = p->fts_path = sp->fts_path;
  sp->fts_dev = p->fts_dev;
}


x86 assembly (clang, -O0):
<fts_load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x10(%rbp),%rcx
mov    %rax,(%rcx)
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x18(%rbp),%rdx
add    $0x1,%rdx
call   1050 <memmove@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     121d <fts_load+0xed>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    0x10(%rcx),%rax
jne    11b2 <fts_load+0x82>
mov    -0x20(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     121d <fts_load+0xed>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
mov    %rdi,-0x20(%rbp)
call   1030 <strlen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
add    $0x1,%rdx
call   1050 <memmove@plt>
mov    -0x18(%rbp),%rax
mov    0x2dfd(%rip),%rcx
cmp    (%rcx),%rax
jbe    1207 <fts_load+0xd7>
mov    0x2ded(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1211 <fts_load+0xe1>
mov    -0x18(%rbp),%rax
mov    %eax,%eax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x20(%rax)
mov    -0x10(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fts_load>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x8(%rsi),%rdx
mov    0x10(%rsi),%rsi
mov    %rdx,(%rbx)
mov    (%rdi),%rdi
add    $0x1,%rdx
call   1050 <memmove@plt>
mov    0x10(%rbx),%r15
mov    %r15,%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     11b1 <fts_load+0x81>
mov    %rax,%r12
cmp    %r15,%rax
jne    117b <fts_load+0x4b>
cmpb   $0x0,0x1(%r15)
je     11b1 <fts_load+0x81>
add    $0x1,%r12
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %rax,%r13
lea    0x1(%rax),%rdx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <memmove@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%rax
cmp    %rax,%r13
mov    %r13d,%ecx
cmova  %rax,%rcx
mov    %rcx,0x8(%rbx)
mov    (%r14),%rax
mov    %rax,0x20(%rbx)
mov    %rax,0x18(%rbx)
mov    0x28(%rbx),%eax
mov    %eax,0x8(%r14)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_6__ = type { i8*, i32 }
%struct.TYPE_5__ = type { i64, i64, i8*, i8*, i8*, i32 }
@UINT_MAX = global i64 0
define void @fts_load(%struct.TYPE_6__* %0, %struct.TYPE_5__* %1) {
%3 = alloca %struct.TYPE_6__*
%4 = alloca %struct.TYPE_5__*
%5 = alloca i64
%6 = alloca i8*
store %struct.TYPE_6__* %0, %struct.TYPE_6__** %3
store %struct.TYPE_5__* %1, %struct.TYPE_5__** %4
%7 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%8 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 1
%9 = load i64, i64* %8
%10 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%11 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %10, i32 0, i32 0
store i64 %9, i64* %11
store i64 %9, i64* %5
%12 = load %struct.TYPE_6__*, %struct.TYPE_6__** %3
%13 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %12, i32 0, i32 0
%14 = load i8*, i8** %13
%15 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%16 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, i32 0, i32 2
%17 = load i8*, i8** %16
%18 = load i64, i64* %5
%19 = add i64 %18, 1
%20 = call i32 @memmove(i8* %14, i8* %17, i64 %19)
%21 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%22 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %21, i32 0, i32 2
%23 = load i8*, i8** %22
%24 = call i8* @strrchr(i8* %23, i8 signext 47)
store i8* %24, i8** %6
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %62
26: ; preds = %2
%27 = load i8*, i8** %6
%28 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%29 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %28, i32 0, i32 2
%30 = load i8*, i8** %29
%31 = icmp ne i8* %27, %30
br i1 %31, label %38, label %32
32: ; preds = %26
%33 = load i8*, i8** %6
%34 = getelementptr inbounds i8, i8* %33, i64 1
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %62
38: ; preds = %32, %26
%39 = load i8*, i8** %6
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %6
%41 = call i64 @strlen(i8* %40)
store i64 %41, i64* %5
%42 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%43 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %42, i32 0, i32 2
%44 = load i8*, i8** %43
%45 = load i8*, i8** %6
%46 = load i64, i64* %5
%47 = add i64 %46, 1
%48 = call i32 @memmove(i8* %44, i8* %45, i64 %47)
%49 = load i64, i64* %5
%50 = load i64, i64* @UINT_MAX
%51 = icmp ugt i64 %49, %50
br i1 %51, label %52, label %54
52: ; preds = %38
%53 = load i64, i64* @UINT_MAX
br label %58
54: ; preds = %38
%55 = load i64, i64* %5
%56 = trunc i64 %55 to i32
%57 = zext i32 %56 to i64
br label %58
58: ; preds = %54, %52
%59 = phi i64 [ %53, %52 ], [ %57, %54 ]
%60 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%61 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %60, i32 0, i32 1
store i64 %59, i64* %61
br label %62
62: ; preds = %58, %32, %2
%63 = load %struct.TYPE_6__*, %struct.TYPE_6__** %3
%64 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %63, i32 0, i32 0
%65 = load i8*, i8** %64
%66 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%67 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %66, i32 0, i32 4
store i8* %65, i8** %67
%68 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%69 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %68, i32 0, i32 3
store i8* %65, i8** %69
%70 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%71 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %70, i32 0, i32 5
%72 = load i32, i32* %71
%73 = load %struct.TYPE_6__*, %struct.TYPE_6__** %3
%74 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %73, i32 0, i32 1
store i32 %72, i32* %74
ret void
}

LLVM IR (-O2):
%struct.TYPE_6__ = type { i8*, i32 }
%struct.TYPE_5__ = type { i64, i64, i8*, i8*, i8*, i32 }
@UINT_MAX = global i64 0
define void @fts_load(%struct.TYPE_6__* nocapture %0, %struct.TYPE_5__* nocapture %1) {
%3 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 1
%4 = load i64, i64* %3
%5 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 0
store i64 %4, i64* %5
%6 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 0
%7 = load i8*, i8** %6
%8 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 2
%9 = load i8*, i8** %8
%10 = add i64 %4, 1
%11 = tail call i32 @memmove(i8* %7, i8* %9, i64 %10)
%12 = load i8*, i8** %8
%13 = tail call i8* @strrchr(i8* dereferenceable(1) %12, i8 signext 47)
%14 = icmp eq i8* %13, null
br i1 %14, label %30, label %15
15: ; preds = %2
%16 = icmp eq i8* %13, %12
br i1 %16, label %17, label %21
17: ; preds = %15
%18 = getelementptr inbounds i8, i8* %12, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %30, label %21
21: ; preds = %17, %15
%22 = getelementptr inbounds i8, i8* %13, i64 1
%23 = tail call i64 @strlen(i8* %22)
%24 = add i64 %23, 1
%25 = tail call i32 @memmove(i8* %12, i8* %22, i64 %24)
%26 = load i64, i64* @UINT_MAX
%27 = icmp ugt i64 %23, %26
%28 = and i64 %23, 4294967295
%29 = select i1 %27, i64 %26, i64 %28
store i64 %29, i64* %3
br label %30
30: ; preds = %21, %17, %2
%31 = load i8*, i8** %6
%32 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 4
store i8* %31, i8** %32
%33 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 3
store i8* %31, i8** %33
%34 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 5
%35 = load i32, i32* %34
%36 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 1
store i32 %35, i32* %36
ret void
}