#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 */
scalar_t__ strcmp(char *, char *);
int name_in(char *name, char **a, int max) {
  int result = 0, i;
  for (i = 0; i < max; i++) {
    result = (strcmp(name, a[i]) == 0);
    if (result)
      break;
  }
  return result;
}


x86 assembly (clang, -O0):
<name_in>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1183 <name_in+0x73>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1170 <name_in+0x60>
jmp    1183 <name_in+0x73>
jmp    1175 <name_in+0x65>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1131 <name_in+0x21>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<name_in>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    114a <name_in+0x3a>
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%r12d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rsi
mov    %r15,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     114e <name_in+0x3e>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <name_in+0x20>
xor    %eax,%eax
jmp    1153 <name_in+0x43>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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