#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*/ strlen(char const *);
scalar_t__ strncmp(char const *const, char const *, int /*<<< orphan*/);
int contains(const char *const *list, const char *item) {
  int i = 0;
  for (; i < 256; i++) {
    if (list[i] == NULL || list[i][0] == '\0')
      return 0;
    if (strncmp(list[i], item, strlen(item)) == 0)
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<contains>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x100,-0x1c(%rbp)
jge    11d4 <contains+0xb4>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     116f <contains+0x4f>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    117b <contains+0x5b>
movl   $0x0,-0x4(%rbp)
jmp    11db <contains+0xbb>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11c1 <contains+0xa1>
movl   $0x1,-0x4(%rbp)
jmp    11db <contains+0xbb>
jmp    11c6 <contains+0xa6>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1137 <contains+0x17>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<contains>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r12
mov    %rdi,%r15
xor    %r14d,%r14d
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r15,%r13,8),%rbx
test   %rbx,%rbx
je     117d <contains+0x5d>
cmpb   $0x0,(%rbx)
je     117d <contains+0x5d>
mov    %r12,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1177 <contains+0x57>
add    $0x1,%r13
cmp    $0x100,%r13
jne    1140 <contains+0x20>
jmp    117d <contains+0x5d>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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