#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 */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int PATH_MAX;
int /*<<< orphan*/ basename(char *);
int /*<<< orphan*/ ffindex_insert_file(int /*<<< orphan*/ *,
                                       int /*<<< orphan*/ *, size_t *,
                                       int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ ffnchomp(char *, int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ strlen(char *);
int ffindex_insert_list_file(FILE *data_file, FILE *index_file,
                             size_t *start_offset, FILE *list_file) {
  size_t offset = *start_offset;
  char path[PATH_MAX];
  while (fgets(path, PATH_MAX, list_file) != NULL)
    ffindex_insert_file(data_file, index_file, &offset,
                        ffnchomp(path, strlen(path)), basename(path));
  *start_offset = offset;
  return 0;
}


x86 assembly (clang, -O0):
<ffindex_insert_list_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e76(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rdi
mov    0x2e46(%rip),%rax
mov    (%rax),%esi
mov    -0x20(%rbp),%rdx
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     120b <ffindex_insert_list_file+0xbb>
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
call   1040 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
call   1030 <ffnchomp@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,-0x44(%rbp)
call   1060 <basename@plt>
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x44(%rbp),%ecx
mov    %eax,%r8d
lea    -0x28(%rbp),%rdx
call   1070 <ffindex_insert_file@plt>
jmp    119f <ffindex_insert_list_file+0x4f>
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ffindex_insert_list_file>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r13
mov    %rsi,%r15
mov    %rdi,%r12
mov    %rsp,-0x38(%rbp)
mov    %rdx,-0x40(%rbp)
mov    (%rdx),%r14
mov    %r14,-0x30(%rbp)
mov    0x2e70(%rip),%rcx
mov    (%rcx),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    (%rcx),%esi
mov    %rbx,%rdi
mov    %r13,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11ff <ffindex_insert_list_file+0xaf>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <ffnchomp@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1060 <basename@plt>
mov    %r12,%rdi
mov    %r15,%rsi
lea    -0x30(%rbp),%rdx
mov    %r14d,%ecx
mov    %eax,%r8d
call   1070 <ffindex_insert_file@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
mov    %r13,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    11b0 <ffindex_insert_list_file+0x60>
mov    -0x30(%rbp),%r14
mov    -0x40(%rbp),%rax
mov    %r14,(%rax)
mov    -0x38(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
define i32 @ffindex_insert_list_file(i32* %0, i32* %1, i64* %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i64*
%8 = alloca i32*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i64
store i32* %0, i32** %5
store i32* %1, i32** %6
store i64* %2, i64** %7
store i32* %3, i32** %8
%12 = load i64*, i64** %7
%13 = load i64, i64* %12
store i64 %13, i64* %9
%14 = load i32, i32* @PATH_MAX
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %10
%17 = alloca i8, i64 %15
store i64 %15, i64* %11
br label %18
18: ; preds = %23, %4
%19 = load i32, i32* @PATH_MAX
%20 = load i32*, i32** %8
%21 = call i32* @fgets(i8* %17, i32 %19, i32* %20)
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %30
23: ; preds = %18
%24 = load i32*, i32** %5
%25 = load i32*, i32** %6
%26 = call i32 @strlen(i8* %17)
%27 = call i32 @ffnchomp(i8* %17, i32 %26)
%28 = call i32 @basename(i8* %17)
%29 = call i32 @ffindex_insert_file(i32* %24, i32* %25, i64* %9, i32 %27, i32 %28)
br label %18
30: ; preds = %18
%31 = load i64, i64* %9
%32 = load i64*, i64** %7
store i64 %31, i64* %32
%33 = load i8*, i8** %10
ret i32 0
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
define i32 @ffindex_insert_list_file(i32* %0, i32* %1, i64* nocapture %2, i32* nocapture %3) {
%5 = alloca i64
%6 = bitcast i64* %5 to i8*
%7 = load i64, i64* %2
store i64 %7, i64* %5
%8 = load i32, i32* @PATH_MAX
%9 = zext i32 %8 to i64
%10 = tail call i8* @llvm.stacksave()
%11 = alloca i8, i64 %9
%12 = load i32, i32* @PATH_MAX
%13 = call i32* @fgets(i8* %11, i32 %12, i32* %3)
%14 = icmp eq i32* %13, null
br i1 %14, label %25, label %15
15: ; preds = %4, %15
%16 = call i32 @strlen(i8* %11)
%17 = call i32 @ffnchomp(i8* %11, i32 %16)
%18 = call i32 @basename(i8* %11)
%19 = call i32 @ffindex_insert_file(i32* %0, i32* %1, i64* %5, i32 %17, i32 %18)
%20 = load i32, i32* @PATH_MAX
%21 = call i32* @fgets(i8* %11, i32 %20, i32* %3)
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %15
23: ; preds = %15
%24 = load i64, i64* %5
br label %25
25: ; preds = %23, %4
%26 = phi i64 [ %24, %23 ], [ %7, %4 ]
store i64 %26, i64* %2
ret i32 0
}