#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*/ da_additem(int *, int *, void ***, void *);
int da_maybeadditem(int *cur, int *max, void ***array, void *item) {
  int idx;
  for (idx = 0; idx < *cur; idx++) {
    if ((*array)[idx] == item) {
      return 0;
    }
  }
  da_additem(cur, max, array, item);
  return 1;
}


x86 assembly (clang, -O0):
<da_maybeadditem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    1176 <da_maybeadditem+0x66>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
cmp    -0x28(%rbp),%rax
jne    1163 <da_maybeadditem+0x53>
movl   $0x0,-0x4(%rbp)
jmp    1192 <da_maybeadditem+0x82>
jmp    1168 <da_maybeadditem+0x58>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    112f <da_maybeadditem+0x1f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1030 <da_additem@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<da_maybeadditem>:
push   %rax
mov    (%rdi),%r8d
test   %r8d,%r8d
jle    113f <da_maybeadditem+0x2f>
mov    (%rdx),%r9
xor    %eax,%eax
xor    %r10d,%r10d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    %rcx,(%r9,%r10,8)
je     1149 <da_maybeadditem+0x39>
add    $0x1,%r10
cmp    %r10,%r8
jne    1130 <da_maybeadditem+0x20>
call   1030 <da_additem@plt>
mov    $0x1,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
define i32 @da_maybeadditem(i32* %0, i32* %1, i8*** %2, i8* %3) {
%5 = load i32, i32* %0
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %18
7: ; preds = %4
%8 = load i8**, i8*** %2
%9 = zext i32 %5 to i64
br label %12
10: ; preds = %12
%11 = icmp eq i64 %17, %9
br i1 %11, label %18, label %12
12: ; preds = %7, %10
%13 = phi i64 [ 0, %7 ], [ %17, %10 ]
%14 = getelementptr inbounds i8*, i8** %8, i64 %13
%15 = load i8*, i8** %14
%16 = icmp eq i8* %15, %3
%17 = add nuw nsw i64 %13, 1
br i1 %16, label %20, label %10
18: ; preds = %10, %4
%19 = tail call i32 @da_additem(i32* %0, i32* %1, i8*** %2, i8* %3)
br label %20
20: ; preds = %12, %18
%21 = phi i32 [ 1, %18 ], [ 0, %12 ]
ret i32 %21
}