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

/* Variables and functions */
int /*<<< orphan*/ _add_toc_line(char *, char *, int, int, int /*<<< orphan*/,
                                 int, int);
int /*<<< orphan*/ free(char *);
scalar_t__ is_empty(char *);
char *m_strdup(char const *);
int /*<<< orphan*/ printf(char *, int, char const *);
char *strpbrk(char const *, char *);
void _add_external_file(const char *buf, int line_number) {
  char *filename, *title;
  title = strpbrk(buf, "\t ");
  if (!title || is_empty(title)) {
    printf("Line %d has externalfile without title part (%s). "
           "Ignoring.\n",
           line_number, buf);
    return;
  }
  filename = m_strdup(buf);
  title = strpbrk(filename, "\t ");
  *title = 0;
  _add_toc_line(filename, title + 1, 1, line_number, 0, 1, 1);
  free(filename);
}


x86 assembly (clang, -O0):
<_add_external_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1070 <strpbrk@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11a1 <_add_external_file+0x41>
mov    -0x20(%rbp),%rdi
call   1060 <is_empty@plt>
cmp    $0x0,%rax
je     11b9 <_add_external_file+0x59>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%rdx
lea    0xe54(%rip),%rdi
call   1050 <printf@plt>
jmp    1211 <_add_external_file+0xb1>
mov    -0x8(%rbp),%rdi
call   1080 <m_strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe2f(%rip),%rsi
call   1070 <strpbrk@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
mov    -0xc(%rbp),%ecx
mov    $0x1,%r9d
xor    %r8d,%r8d
mov    %r9d,%edx
movl   $0x1,(%rsp)
call   1040 <_add_toc_line@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_add_external_file>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xe91(%rip),%rsi
call   1070 <strpbrk@plt>
test   %rax,%rax
je     1186 <_add_external_file+0x26>
mov    %rax,%rdi
call   1060 <is_empty@plt>
test   %rax,%rax
je     119d <_add_external_file+0x3d>
lea    0xe76(%rip),%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <printf@plt>
mov    %rbx,%rdi
call   1080 <m_strdup@plt>
mov    %rax,%rbx
lea    0xe51(%rip),%rsi
mov    %rax,%rdi
call   1070 <strpbrk@plt>
movb   $0x0,(%rax)
lea    0x1(%rax),%rsi
movl   $0x1,(%rsp)
mov    %rbx,%rdi
mov    $0x1,%edx
mov    %ebp,%ecx
xor    %r8d,%r8d
mov    $0x1,%r9d
call   1040 <_add_toc_line@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"\09 \00"
@.str.1 = [61 x i8] c"Line %d has externalfile without title part (%s). Ignoring.\0A\00"
define void @_add_external_file(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = call i8* @strpbrk(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i8*, i8** %6
%13 = call i64 @is_empty(i8* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %11, %2
%16 = load i32, i32* %4
%17 = load i8*, i8** %3
%18 = call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0), i32 %16, i8* %17)
br label %32
19: ; preds = %11
%20 = load i8*, i8** %3
%21 = call i8* @m_strdup(i8* %20)
store i8* %21, i8** %5
%22 = load i8*, i8** %5
%23 = call i8* @strpbrk(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %23, i8** %6
%24 = load i8*, i8** %6
store i8 0, i8* %24
%25 = load i8*, i8** %5
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i32, i32* %4
%29 = call i32 @_add_toc_line(i8* %25, i8* %27, i32 1, i32 %28, i32 0, i32 1, i32 1)
%30 = load i8*, i8** %5
%31 = call i32 @free(i8* %30)
br label %32
32: ; preds = %19, %15
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"\09 \00"
@.str.1 = [61 x i8] c"Line %d has externalfile without title part (%s). Ignoring.\0A\00"
define void @_add_external_file(i8* %0, i32 %1) {
%3 = tail call i8* @strpbrk(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i64 @is_empty(i8* %3)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5, %2
%9 = tail call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0), i32 %1, i8* %0)
br label %16
10: ; preds = %5
%11 = tail call i8* @m_strdup(i8* %0)
%12 = tail call i8* @strpbrk(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8 0, i8* %12
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = tail call i32 @_add_toc_line(i8* %11, i8* %13, i32 1, i32 %1, i32 0, i32 1, i32 1)
%15 = tail call i32 @free(i8* %11)
br label %16
16: ; preds = %10, %8
ret void
}