#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 stat {
  int dummy;
};
struct TYPE_7__ {
  int fts_options;
  int /*<<< orphan*/ fts_path;
};
struct TYPE_6__ {
  int 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;
  scalar_t__ fts_name;
  struct stat *fts_statp;
};
typedef TYPE_1__ FTSENT;
typedef TYPE_2__ FTS;

/* Variables and functions */
scalar_t__ ALIGN(scalar_t__);
int /*<<< orphan*/ FTS_NOINSTR;
int FTS_NOSTAT;
TYPE_1__ *malloc(size_t);
int /*<<< orphan*/ memmove(scalar_t__, char *, int);
FTSENT *fts_alloc(FTS *sp, char *name, int namelen) {
  FTSENT *p;
  size_t len;
  len = sizeof(FTSENT) + namelen;
  if (!(sp->fts_options & (FTS_NOSTAT)))
    len += sizeof(struct stat) + 7;
  if ((p = malloc(len)) == NULL)
    return (NULL);
  memmove(p->fts_name, name, namelen + 1);
  if (!(sp->fts_options & (FTS_NOSTAT)))
    p->fts_statp = (struct stat *)ALIGN(p->fts_name + namelen + 2);
  p->fts_namelen = 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    %edx,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
add    $0x48,%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2e7c(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    1173 <fts_alloc+0x43>
mov    -0x30(%rbp),%rax
add    $0xb,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1197 <fts_alloc+0x67>
movq   $0x0,-0x8(%rbp)
jmp    1248 <fts_alloc+0x118>
mov    -0x28(%rbp),%rax
mov    0x38(%rax),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
add    $0x1,%edx
call   1050 <memmove@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2e1d(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    11e9 <fts_alloc+0xb9>
mov    -0x28(%rbp),%rax
mov    0x38(%rax),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
add    $0x2,%rdi
call   1030 <ALIGN@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,0x40(%rax)
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%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    0x2dc1(%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   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r12
mov    %rdi,%r15
movslq %edx,%rbp
mov    0x2e8a(%rip),%rax
mov    (%rax),%eax
and    (%rdi),%eax
lea    0x48(%rbp),%rdi
lea    0x53(%rbp),%rcx
test   %eax,%eax
cmove  %rcx,%rdi
call   1040 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11c3 <fts_alloc+0x93>
mov    0x38(%rbx),%r13
lea    0x1(%r14),%edx
mov    %r13,%rdi
mov    %r12,%rsi
call   1050 <memmove@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%eax
test   %eax,(%r15)
jne    11a2 <fts_alloc+0x72>
lea    0x2(,%r13,1),%rdi
add    %rbp,%rdi
call   1030 <ALIGN@plt>
mov    %rax,0x40(%rbx)
mov    %r14d,(%rbx)
mov    0x4(%r15),%eax
mov    %eax,0x30(%rbx)
xorps  %xmm0,%xmm0
movups %xmm0,0x20(%rbx)
mov    0x2e26(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rbx)
movups %xmm0,0x8(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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