#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__ {
  int fts_pathlen;
  int 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 *, int);
int strlen(char *);
char *strrchr(char *, char);
void fts_load(FTS *sp, FTSENT *p) {
  int 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    0x4(%rax),%eax
mov    -0x10(%rbp),%rcx
mov    %eax,(%rcx)
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x14(%rbp),%edx
add    $0x1,%edx
call   1050 <memmove@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11e2 <fts_load+0xb2>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    0x8(%rcx),%rax
jne    11ad <fts_load+0x7d>
mov    -0x20(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     11e2 <fts_load+0xb2>
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
mov    %rdi,-0x20(%rbp)
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
add    $0x1,%edx
call   1050 <memmove@plt>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x10(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x10(%rbp),%rax
mov    0x20(%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   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x4(%rsi),%edx
mov    %edx,(%rsi)
mov    (%rdi),%rdi
mov    0x8(%rsi),%rsi
add    $0x1,%edx
call   1050 <memmove@plt>
mov    0x8(%rbx),%r12
mov    %r12,%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     119c <fts_load+0x6c>
mov    %rax,%r15
cmp    %r12,%rax
jne    1178 <fts_load+0x48>
cmpb   $0x0,0x1(%r12)
je     119c <fts_load+0x6c>
add    $0x1,%r15
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%r12d
mov    0x8(%rbx),%rdi
lea    0x1(%r12),%edx
mov    %r15,%rsi
call   1050 <memmove@plt>
mov    %r12d,0x4(%rbx)
mov    (%r14),%rax
mov    %rax,0x18(%rbx)
mov    %rax,0x10(%rbx)
mov    0x20(%rbx),%eax
mov    %eax,0x8(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_6__ = type { i8*, i32 }
%struct.TYPE_5__ = type { i32, i32, 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 i32
%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 i32, i32* %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 i32 %9, i32* %11
store i32 %9, i32* %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 i32, i32* %5
%19 = add nsw i32 %18, 1
%20 = call i32 @memmove(i8* %14, i8* %17, i32 %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 i32 @strlen(i8* %40)
store i32 %41, i32* %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 i32, i32* %5
%47 = add nsw i32 %46, 1
%48 = call i32 @memmove(i8* %44, i8* %45, i32 %47)
%49 = load i32, i32* %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 i32 %49, i32* %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 { i32, i32, 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 i32, i32* %3
%5 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 0
store i32 %4, i32* %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 nsw i32 %4, 1
%11 = tail call i32 @memmove(i8* %7, i8* %9, i32 %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 %27, 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 %27, label %21
21: ; preds = %17, %15
%22 = getelementptr inbounds i8, i8* %13, i64 1
%23 = tail call i32 @strlen(i8* %22)
%24 = load i8*, i8** %8
%25 = add nsw i32 %23, 1
%26 = tail call i32 @memmove(i8* %24, i8* %22, i32 %25)
store i32 %23, i32* %3
br label %27
27: ; preds = %21, %17, %2
%28 = load i8*, i8** %6
%29 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 4
store i8* %28, i8** %29
%30 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 3
store i8* %28, i8** %30
%31 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 5
%32 = load i32, i32* %31
%33 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 1
store i32 %32, i32* %33
ret void
}