#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 */
char **realloc(char **, int);
int /*<<< orphan*/ strcmp(char *, char *);
void append_to_list_nodup(char ***list, int *n, char *entry) {
  for (int i = 0; i < *n; i++)
    if (!strcmp((*list)[i], entry))
      return;
  (*n)++;
  *list = realloc(*list, *n * sizeof **list);
  (*list)[*n - 1] = entry;
}


x86 assembly (clang, -O0):
<append_to_list_nodup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    1183 <append_to_list_nodup+0x63>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1170 <append_to_list_nodup+0x50>
jmp    11cc <append_to_list_nodup+0xac>
jmp    1175 <append_to_list_nodup+0x55>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113b <append_to_list_nodup+0x1b>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%esi
call   1040 <realloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<append_to_list_nodup>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rsi),%ebx
mov    (%rdi),%r13
test   %ebx,%ebx
jle    115a <append_to_list_nodup+0x3a>
xor    %ebp,%ebp
nop
mov    0x0(%r13,%rbp,8),%rdi
mov    %r12,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     117a <append_to_list_nodup+0x5a>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1140 <append_to_list_nodup+0x20>
lea    0x1(%rbx),%eax
mov    %eax,(%r14)
lea    0x8(,%rbx,8),%esi
mov    %r13,%rdi
call   1040 <realloc@plt>
mov    %rax,(%r15)
movslq (%r14),%rcx
mov    %r12,-0x8(%rax,%rcx,8)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @append_to_list_nodup(i8*** %0, i32* %1, i8* %2) {
%4 = alloca i8***
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
store i8*** %0, i8**** %4
store i32* %1, i32** %5
store i8* %2, i8** %6
store i32 0, i32* %7
br label %8
8: ; preds = %25, %3
%9 = load i32, i32* %7
%10 = load i32*, i32** %5
%11 = load i32, i32* %10
%12 = icmp slt i32 %9, %11
br i1 %12, label %13, label %28
13: ; preds = %8
%14 = load i8***, i8**** %4
%15 = load i8**, i8*** %14
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = load i8*, i8** %6
%21 = call i32 @strcmp(i8* %19, i8* %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %13
br label %49
24: ; preds = %13
br label %25
25: ; preds = %24
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %8
28: ; preds = %8
%29 = load i32*, i32** %5
%30 = load i32, i32* %29
%31 = add nsw i32 %30, 1
store i32 %31, i32* %29
%32 = load i8***, i8**** %4
%33 = load i8**, i8*** %32
%34 = load i32*, i32** %5
%35 = load i32, i32* %34
%36 = sext i32 %35 to i64
%37 = mul i64 %36, 8
%38 = trunc i64 %37 to i32
%39 = call i8** @realloc(i8** %33, i32 %38)
%40 = load i8***, i8**** %4
store i8** %39, i8*** %40
%41 = load i8*, i8** %6
%42 = load i8***, i8**** %4
%43 = load i8**, i8*** %42
%44 = load i32*, i32** %5
%45 = load i32, i32* %44
%46 = sub nsw i32 %45, 1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %43, i64 %47
store i8* %41, i8** %48
br label %49
49: ; preds = %28, %23
ret void
}

LLVM IR (-O2):
define void @append_to_list_nodup(i8*** nocapture %0, i32* nocapture %1, i8* %2) {
%4 = load i32, i32* %1
%5 = icmp sgt i32 %4, 0
%6 = load i8**, i8*** %0
br i1 %5, label %7, label %18
7: ; preds = %3
%8 = zext i32 %4 to i64
br label %11
9: ; preds = %11
%10 = icmp eq i64 %17, %8
br i1 %10, label %18, label %11
11: ; preds = %7, %9
%12 = phi i64 [ 0, %7 ], [ %17, %9 ]
%13 = getelementptr inbounds i8*, i8** %6, i64 %12
%14 = load i8*, i8** %13
%15 = tail call i32 @strcmp(i8* dereferenceable(1) %14, i8* dereferenceable(1) %2)
%16 = icmp eq i32 %15, 0
%17 = add nuw nsw i64 %12, 1
br i1 %16, label %26, label %9
18: ; preds = %9, %3
%19 = add nsw i32 %4, 1
store i32 %19, i32* %1
%20 = shl i32 %19, 3
%21 = tail call i8** @realloc(i8** %6, i32 %20)
store i8** %21, i8*** %0
%22 = load i32, i32* %1
%23 = add nsw i32 %22, -1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %21, i64 %24
store i8* %2, i8** %25
br label %26
26: ; preds = %11, %18
ret void
}