#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 */
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;
  }
  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    $0x20,%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     11ec <fts_load+0xbc>
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     11ec <fts_load+0xbc>
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),%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    $0x20,%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     119d <fts_load+0x6d>
mov    %rax,%r12
cmp    %r15,%rax
jne    117b <fts_load+0x4b>
cmpb   $0x0,0x1(%r15)
je     119d <fts_load+0x6d>
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    %r13,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 }
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 %52
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 %52
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 %struct.TYPE_5__*, %struct.TYPE_5__** %4
%51 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %50, i32 0, i32 1
store i64 %49, i64* %51
br label %52
52: ; preds = %38, %32, %2
%53 = load %struct.TYPE_6__*, %struct.TYPE_6__** %3
%54 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %53, i32 0, i32 0
%55 = load i8*, i8** %54
%56 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%57 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %56, i32 0, i32 4
store i8* %55, i8** %57
%58 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%59 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %58, i32 0, i32 3
store i8* %55, i8** %59
%60 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%61 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %60, i32 0, i32 5
%62 = load i32, i32* %61
%63 = load %struct.TYPE_6__*, %struct.TYPE_6__** %3
%64 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %63, i32 0, i32 1
store i32 %62, i32* %64
ret void
}

LLVM IR (-O2):
%struct.TYPE_6__ = type { i8*, i32 }
%struct.TYPE_5__ = type { i64, i64, i8*, i8*, i8*, i32 }
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 %26, 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 %26, 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)
store i64 %23, i64* %3
br label %26
26: ; preds = %21, %17, %2
%27 = load i8*, i8** %6
%28 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 4
store i8* %27, i8** %28
%29 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 3
store i8* %27, i8** %29
%30 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 5
%31 = load i32, i32* %30
%32 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 1
store i32 %31, i32* %32
ret void
}