#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 is_namelist_member(unsigned long nu, char *name, char **name_list) {
  int rc = 0;
  unsigned long index = 0;
  while (index < nu) {
    if (strcmp(name, name_list[index]) == 0) {
      rc = 1;
      break;
    } else {
      index++;
    }
  }
  return rc;
}


x86 assembly (clang, -O0):
<is_namelist_member>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    117d <is_namelist_member+0x6d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    116c <is_namelist_member+0x5c>
movl   $0x1,-0x1c(%rbp)
jmp    117d <is_namelist_member+0x6d>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1133 <is_namelist_member+0x23>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

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

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

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