#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*/ strcmp(char *, char const *);
int stringv_append(char ***, size_t *, char const *);
int stringv_append_if_missing(char ***s, size_t *s_len, const char *elem) {
  size_t i;
  if ((!s) || (!s_len))
    return -1;
  for (i = 0; i < *s_len; i++)
    if (!strcmp((*s)[i], elem))
      return 0;
  return stringv_append(s, s_len, elem);
}


x86 assembly (clang, -O0):
<stringv_append_if_missing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     114a <stringv_append_if_missing+0x2a>
cmpq   $0x0,-0x18(%rbp)
jne    1156 <stringv_append_if_missing+0x36>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c6 <stringv_append_if_missing+0xa6>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%rax
jae    11b2 <stringv_append_if_missing+0x92>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    119c <stringv_append_if_missing+0x7c>
movl   $0x0,-0x4(%rbp)
jmp    11c6 <stringv_append_if_missing+0xa6>
jmp    11a1 <stringv_append_if_missing+0x81>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    115e <stringv_append_if_missing+0x3e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <stringv_append@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stringv_append_if_missing>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xffffffff,%eax
test   %rdi,%rdi
je     1198 <stringv_append_if_missing+0x78>
mov    %rsi,%r14
test   %rsi,%rsi
je     1198 <stringv_append_if_missing+0x78>
mov    %rdx,%r13
mov    %rdi,%r15
mov    (%r14),%rbx
test   %rbx,%rbx
je     117a <stringv_append_if_missing+0x5a>
mov    (%r15),%rbp
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp,%r12,8),%rdi
mov    %r13,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1196 <stringv_append_if_missing+0x76>
add    $0x1,%r12
cmp    %r12,%rbx
jne    1160 <stringv_append_if_missing+0x40>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <stringv_append@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @stringv_append_if_missing(i8*** %0, i64* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8***
%6 = alloca i64*
%7 = alloca i8*
%8 = alloca i64
store i8*** %0, i8**** %5
store i64* %1, i64** %6
store i8* %2, i8** %7
%9 = load i8***, i8**** %5
%10 = icmp ne i8*** %9, null
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load i64*, i64** %6
%13 = icmp ne i64* %12, null
br i1 %13, label %15, label %14
14: ; preds = %11, %3
store i32 -1, i32* %4
br label %40
15: ; preds = %11
store i64 0, i64* %8
br label %16
16: ; preds = %32, %15
%17 = load i64, i64* %8
%18 = load i64*, i64** %6
%19 = load i64, i64* %18
%20 = icmp ult i64 %17, %19
br i1 %20, label %21, label %35
21: ; preds = %16
%22 = load i8***, i8**** %5
%23 = load i8**, i8*** %22
%24 = load i64, i64* %8
%25 = getelementptr inbounds i8*, i8** %23, i64 %24
%26 = load i8*, i8** %25
%27 = load i8*, i8** %7
%28 = call i32 @strcmp(i8* %26, i8* %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %31, label %30
30: ; preds = %21
store i32 0, i32* %4
br label %40
31: ; preds = %21
br label %32
32: ; preds = %31
%33 = load i64, i64* %8
%34 = add i64 %33, 1
store i64 %34, i64* %8
br label %16
35: ; preds = %16
%36 = load i8***, i8**** %5
%37 = load i64*, i64** %6
%38 = load i8*, i8** %7
%39 = call i32 @stringv_append(i8*** %36, i64* %37, i8* %38)
store i32 %39, i32* %4
br label %40
40: ; preds = %35, %30, %14
%41 = load i32, i32* %4
ret i32 %41
}

LLVM IR (-O2):
define i32 @stringv_append_if_missing(i8*** %0, i64* %1, i8* %2) {
%4 = icmp ne i8*** %0, null
%5 = icmp ne i64* %1, null
%6 = and i1 %4, %5
br i1 %6, label %7, label %23
7: ; preds = %3
%8 = load i64, i64* %1
%9 = icmp eq i64 %8, 0
br i1 %9, label %21, label %10
10: ; preds = %7
%11 = load i8**, i8*** %0
br label %14
12: ; preds = %14
%13 = icmp eq i64 %20, %8
br i1 %13, label %21, label %14
14: ; preds = %10, %12
%15 = phi i64 [ 0, %10 ], [ %20, %12 ]
%16 = getelementptr inbounds i8*, i8** %11, i64 %15
%17 = load i8*, i8** %16
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(1) %2)
%19 = icmp eq i32 %18, 0
%20 = add nuw i64 %15, 1
br i1 %19, label %23, label %12
21: ; preds = %12, %7
%22 = tail call i32 @stringv_append(i8*** %0, i64* %1, i8* %2)
br label %23
23: ; preds = %14, %3, %21
%24 = phi i32 [ %22, %21 ], [ -1, %3 ], [ 0, %14 ]
ret i32 %24
}