#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*/ strcat(char *, char *);
int strlen(char *);
scalar_t__ word_in_list(char *, char *);
int add_word_to_list(char *word, char *word_list) {
  if (word_in_list(word, word_list) != 0)
    return 0;
  if (strlen(word_list) + strlen(word) + 3 >= (4096 * 4))
    return 1;
  strcat(word_list, ",");
  strcat(word_list, word);
  return 0;
}


x86 assembly (clang, -O0):
<add_word_to_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <word_in_list@plt>
cmp    $0x0,%rax
je     1163 <add_word_to_list+0x33>
movl   $0x0,-0x4(%rbp)
jmp    11bd <add_word_to_list+0x8d>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
add    $0x3,%eax
cmp    $0x4000,%eax
jl     1199 <add_word_to_list+0x69>
movl   $0x1,-0x4(%rbp)
jmp    11bd <add_word_to_list+0x8d>
mov    -0x18(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcat@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_word_to_list>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
call   1040 <word_in_list@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    1188 <add_word_to_list+0x58>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
add    %ebp,%ecx
mov    $0x1,%eax
cmp    $0x3ffc,%ecx
jg     1188 <add_word_to_list+0x58>
lea    0xe8d(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcat@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c",\00"
define i32 @add_word_to_list(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %4
%7 = load i8*, i8** %5
%8 = call i64 @word_in_list(i8* %6, i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 0, i32* %3
br label %26
11: ; preds = %2
%12 = load i8*, i8** %5
%13 = call i32 @strlen(i8* %12)
%14 = load i8*, i8** %4
%15 = call i32 @strlen(i8* %14)
%16 = add nsw i32 %13, %15
%17 = add nsw i32 %16, 3
%18 = icmp sge i32 %17, 16384
br i1 %18, label %19, label %20
19: ; preds = %11
store i32 1, i32* %3
br label %26
20: ; preds = %11
%21 = load i8*, i8** %5
%22 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%23 = load i8*, i8** %5
%24 = load i8*, i8** %4
%25 = call i32 @strcat(i8* %23, i8* %24)
store i32 0, i32* %3
br label %26
26: ; preds = %20, %19, %10
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [2 x i8] c",\00"
define i32 @add_word_to_list(i8* %0, i8* %1) {
%3 = tail call i64 @word_in_list(i8* %0, i8* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %13
5: ; preds = %2
%6 = tail call i32 @strlen(i8* %1)
%7 = tail call i32 @strlen(i8* %0)
%8 = add nsw i32 %7, %6
%9 = icmp sgt i32 %8, 16380
br i1 %9, label %13, label %10
10: ; preds = %5
%11 = tail call i32 @strcat(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @strcat(i8* %1, i8* %0)
br label %13
13: ; preds = %5, %2, %10
%14 = phi i32 [ 0, %10 ], [ 0, %2 ], [ 1, %5 ]
ret i32 %14
}