#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*/ _DIAGASSERT(int /*<<< orphan*/);
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;
  _DIAGASSERT(sp != NULL);
  _DIAGASSERT(p != NULL);
  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)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <_DIAGASSERT@plt>
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <_DIAGASSERT@plt>
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   1060 <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     1251 <fts_load+0x111>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    0x10(%rcx),%rax
jne    11e6 <fts_load+0xa6>
mov    -0x20(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     1251 <fts_load+0x111>
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   1060 <memmove@plt>
mov    -0x18(%rbp),%rax
mov    0x2dc9(%rip),%rcx
cmp    (%rcx),%rax
jbe    123b <fts_load+0xfb>
mov    0x2db9(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1245 <fts_load+0x105>
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,%r12
mov    %rdi,%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1050 <_DIAGASSERT@plt>
xor    %edi,%edi
test   %r12,%r12
setne  %dil
call   1050 <_DIAGASSERT@plt>
mov    0x8(%r12),%rdx
mov    0x10(%r12),%rsi
mov    %rdx,(%r12)
mov    (%r14),%rdi
add    $0x1,%rdx
call   1060 <memmove@plt>
mov    0x10(%r12),%r15
mov    %r15,%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     11e2 <fts_load+0xa2>
mov    %rax,%rbx
cmp    %r15,%rax
jne    11ab <fts_load+0x6b>
cmpb   $0x0,0x1(%r15)
je     11e2 <fts_load+0xa2>
add    $0x1,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rax,%r13
lea    0x1(%rax),%rdx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <memmove@plt>
mov    0x2e18(%rip),%rax
mov    (%rax),%rax
cmp    %rax,%r13
mov    %r13d,%ecx
cmova  %rax,%rcx
mov    %rcx,0x8(%r12)
mov    (%r14),%rax
mov    %rax,0x20(%r12)
mov    %rax,0x18(%r12)
mov    0x28(%r12),%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_6__*, %struct.TYPE_6__** %3
%8 = icmp ne %struct.TYPE_6__* %7, null
%9 = zext i1 %8 to i32
%10 = call i32 @_DIAGASSERT(i32 %9)
%11 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%12 = icmp ne %struct.TYPE_5__* %11, null
%13 = zext i1 %12 to i32
%14 = call i32 @_DIAGASSERT(i32 %13)
%15 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%16 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, i32 0, i32 1
%17 = load i64, i64* %16
%18 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%19 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %18, i32 0, i32 0
store i64 %17, i64* %19
store i64 %17, i64* %5
%20 = load %struct.TYPE_6__*, %struct.TYPE_6__** %3
%21 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %20, i32 0, i32 0
%22 = load i8*, i8** %21
%23 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%24 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %23, i32 0, i32 2
%25 = load i8*, i8** %24
%26 = load i64, i64* %5
%27 = add i64 %26, 1
%28 = call i32 @memmove(i8* %22, i8* %25, i64 %27)
%29 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%30 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %29, i32 0, i32 2
%31 = load i8*, i8** %30
%32 = call i8* @strrchr(i8* %31, i8 signext 47)
store i8* %32, i8** %6
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %70
34: ; preds = %2
%35 = load i8*, i8** %6
%36 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%37 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %36, i32 0, i32 2
%38 = load i8*, i8** %37
%39 = icmp ne i8* %35, %38
br i1 %39, label %46, label %40
40: ; preds = %34
%41 = load i8*, i8** %6
%42 = getelementptr inbounds i8, i8* %41, i64 1
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %70
46: ; preds = %40, %34
%47 = load i8*, i8** %6
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %6
%49 = call i64 @strlen(i8* %48)
store i64 %49, i64* %5
%50 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%51 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %50, i32 0, i32 2
%52 = load i8*, i8** %51
%53 = load i8*, i8** %6
%54 = load i64, i64* %5
%55 = add i64 %54, 1
%56 = call i32 @memmove(i8* %52, i8* %53, i64 %55)
%57 = load i64, i64* %5
%58 = load i64, i64* @UINT_MAX
%59 = icmp ugt i64 %57, %58
br i1 %59, label %60, label %62
60: ; preds = %46
%61 = load i64, i64* @UINT_MAX
br label %66
62: ; preds = %46
%63 = load i64, i64* %5
%64 = trunc i64 %63 to i32
%65 = zext i32 %64 to i64
br label %66
66: ; preds = %62, %60
%67 = phi i64 [ %61, %60 ], [ %65, %62 ]
%68 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%69 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %68, i32 0, i32 1
store i64 %67, i64* %69
br label %70
70: ; preds = %66, %40, %2
%71 = load %struct.TYPE_6__*, %struct.TYPE_6__** %3
%72 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %71, i32 0, i32 0
%73 = load i8*, i8** %72
%74 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%75 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %74, i32 0, i32 4
store i8* %73, i8** %75
%76 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%77 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %76, i32 0, i32 3
store i8* %73, i8** %77
%78 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%79 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %78, i32 0, i32 5
%80 = load i32, i32* %79
%81 = load %struct.TYPE_6__*, %struct.TYPE_6__** %3
%82 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %81, i32 0, i32 1
store i32 %80, i32* %82
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__* %0, %struct.TYPE_5__* %1) {
%3 = icmp ne %struct.TYPE_6__* %0, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @_DIAGASSERT(i32 %4)
%6 = icmp ne %struct.TYPE_5__* %1, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @_DIAGASSERT(i32 %7)
%9 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 1
%10 = load i64, i64* %9
%11 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 0
store i64 %10, i64* %11
%12 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 0
%13 = load i8*, i8** %12
%14 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 2
%15 = load i8*, i8** %14
%16 = add i64 %10, 1
%17 = tail call i32 @memmove(i8* %13, i8* %15, i64 %16)
%18 = load i8*, i8** %14
%19 = tail call i8* @strrchr(i8* dereferenceable(1) %18, i8 signext 47)
%20 = icmp eq i8* %19, null
br i1 %20, label %36, label %21
21: ; preds = %2
%22 = icmp eq i8* %19, %18
br i1 %22, label %23, label %27
23: ; preds = %21
%24 = getelementptr inbounds i8, i8* %18, i64 1
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %36, label %27
27: ; preds = %23, %21
%28 = getelementptr inbounds i8, i8* %19, i64 1
%29 = tail call i64 @strlen(i8* %28)
%30 = add i64 %29, 1
%31 = tail call i32 @memmove(i8* %18, i8* %28, i64 %30)
%32 = load i64, i64* @UINT_MAX
%33 = icmp ugt i64 %29, %32
%34 = and i64 %29, 4294967295
%35 = select i1 %33, i64 %32, i64 %34
store i64 %35, i64* %9
br label %36
36: ; preds = %27, %23, %2
%37 = load i8*, i8** %12
%38 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 4
store i8* %37, i8** %38
%39 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 3
store i8* %37, i8** %39
%40 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %1, i64 0, i32 5
%41 = load i32, i32* %40
%42 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 1
store i32 %41, i32* %42
ret void
}