#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_7__ TYPE_2__;
typedef struct TYPE_6__ TYPE_1__;

/* Type definitions */
struct TYPE_7__ {
  int fts_options;
  int /*<<< orphan*/ fts_path;
};
struct TYPE_6__ {
  size_t fts_namelen;
  int /*<<< orphan*/ *fts_pointer;
  scalar_t__ fts_number;
  int /*<<< orphan*/ fts_instr;
  scalar_t__ fts_flags;
  scalar_t__ fts_errno;
  int /*<<< orphan*/ fts_path;
  int /*<<< orphan*/ fts_name;
  int /*<<< orphan*/ *fts_statp;
};
typedef TYPE_1__ FTSENT;
typedef TYPE_2__ FTS;

/* Variables and functions */
int /*<<< orphan*/ FTS_NOINSTR;
int FTS_NOSTAT;
size_t UINT_MAX;
int /*<<< orphan*/ free(TYPE_1__ *);
void *malloc(int);
int /*<<< orphan*/ memmove(int /*<<< orphan*/, char const *, size_t);
FTSENT *fts_alloc(FTS *sp, const char *name, size_t namelen) {
  FTSENT *p;
  ;
  ;
  if ((p = malloc(sizeof(FTSENT) + namelen)) == NULL)
    return (NULL);
  if (!(sp->fts_options & (FTS_NOSTAT)))
    if ((p->fts_statp = malloc(sizeof(*(p->fts_statp)))) == NULL) {
      free(p);
      return (NULL);
    }
  if ((sp->fts_options & (FTS_NOSTAT)))
    p->fts_statp = NULL;
  memmove(p->fts_name, name, namelen + 1);
  p->fts_namelen = ((namelen) > UINT_MAX ? UINT_MAX : (unsigned int)(namelen));
  p->fts_path = sp->fts_path;
  p->fts_errno = 0;
  p->fts_flags = 0;
  p->fts_instr = FTS_NOINSTR;
  p->fts_number = 0;
  p->fts_pointer = NULL;
  return (p);
}


x86 assembly (clang, -O0):
<fts_alloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x40,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    116e <fts_alloc+0x3e>
movq   $0x0,-0x8(%rbp)
jmp    128b <fts_alloc+0x15b>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2e55(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    11bd <fts_alloc+0x8d>
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    -0x28(%rbp),%rcx
mov    %rax,0x38(%rcx)
cmp    $0x0,%rax
jne    11b8 <fts_alloc+0x88>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    128b <fts_alloc+0x15b>
jmp    11bd <fts_alloc+0x8d>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2e06(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11e1 <fts_alloc+0xb1>
mov    -0x28(%rbp),%rax
movq   $0x0,0x38(%rax)
mov    -0x28(%rbp),%rax
mov    0x34(%rax),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
add    $0x1,%rdx
call   1050 <memmove@plt>
mov    -0x20(%rbp),%rax
mov    0x2de4(%rip),%rcx
cmp    (%rcx),%rax
jbe    1220 <fts_alloc+0xf0>
mov    0x2dd4(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    122a <fts_alloc+0xfa>
mov    -0x20(%rbp),%rax
mov    %eax,%eax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x30(%rax)
mov    -0x28(%rbp),%rax
movq   $0x0,0x28(%rax)
mov    -0x28(%rbp),%rax
movq   $0x0,0x20(%rax)
mov    0x2d76(%rip),%rax
mov    (%rax),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x28(%rbp),%rax
movq   $0x0,0x10(%rax)
mov    -0x28(%rbp),%rax
movq   $0x0,0x8(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fts_alloc>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r14
lea    0x40(%rdx),%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     1169 <fts_alloc+0x39>
mov    %rax,%rbx
mov    0x2e78(%rip),%rax
mov    (%rax),%eax
test   %eax,(%r14)
je     116d <fts_alloc+0x3d>
movq   $0x0,0x38(%rbx)
jmp    1180 <fts_alloc+0x50>
xor    %ebx,%ebx
jmp    11c1 <fts_alloc+0x91>
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,0x38(%rbx)
test   %rax,%rax
je     11d0 <fts_alloc+0xa0>
lea    0x1(%r15),%rdx
mov    %r12,%rsi
call   1050 <memmove@plt>
mov    0x2e55(%rip),%rax
mov    (%rax),%rax
cmp    %r15,%rax
mov    %r15d,%ecx
cmovb  %rax,%rcx
mov    %rcx,(%rbx)
mov    0x4(%r14),%eax
mov    %eax,0x30(%rbx)
xorps  %xmm0,%xmm0
movups %xmm0,0x20(%rbx)
mov    0x2e20(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rbx)
movups %xmm0,0x8(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
jmp    11c1 <fts_alloc+0x91>

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

LLVM IR (-O2):
%struct.TYPE_6__ = type { i64, i32*, i64, i32, i64, i64, i32, i32, i32* }
%struct.TYPE_7__ = type { i32, i32 }
@FTS_NOSTAT = global i32 0
@UINT_MAX = global i64 0
@FTS_NOINSTR = global i32 0
define noalias %struct.TYPE_6__* @fts_alloc(%struct.TYPE_7__* nocapture %0, i8* %1, i64 %2) {
%4 = trunc i64 %2 to i32
%5 = add i32 %4, 64
%6 = tail call i8* @malloc(i32 %5)
%7 = bitcast i8* %6 to %struct.TYPE_6__*
%8 = icmp eq i8* %6, null
br i1 %8, label %41, label %9
9: ; preds = %3
%10 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %0, i64 0, i32 0
%11 = load i32, i32* %10
%12 = load i32, i32* @FTS_NOSTAT
%13 = and i32 %12, %11
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %9
%16 = tail call dereferenceable_or_null(4) i8* @malloc(i32 4)
%17 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %7, i64 0, i32 8
%18 = bitcast i32** %17 to i8**
store i8* %16, i8** %18
%19 = icmp eq i8* %16, null
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = tail call i32 @free(%struct.TYPE_6__* %7)
br label %41
22: ; preds = %9
%23 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %7, i64 0, i32 8
store i32* null, i32** %23
br label %24
24: ; preds = %15, %22
%25 = add i64 %2, 1
%26 = tail call i32 @memmove(i32 undef, i8* %1, i64 %25)
%27 = load i64, i64* @UINT_MAX
%28 = icmp ult i64 %27, %2
%29 = and i64 %2, 4294967295
%30 = select i1 %28, i64 %27, i64 %29
%31 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %7, i64 0, i32 0
store i64 %30, i64* %31
%32 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %0, i64 0, i32 1
%33 = load i32, i32* %32
%34 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %7, i64 0, i32 6
store i32 %33, i32* %34
%35 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %7, i64 0, i32 4
%36 = bitcast i64* %35 to i8*
%37 = load i32, i32* @FTS_NOINSTR
%38 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %7, i64 0, i32 3
store i32 %37, i32* %38
%39 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %7, i64 0, i32 1
%40 = bitcast i32** %39 to i8*
br label %41
41: ; preds = %3, %24, %20
%42 = phi %struct.TYPE_6__* [ %7, %24 ], [ null, %20 ], [ null, %3 ]
ret %struct.TYPE_6__* %42
}