#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__ strcasecmp(char *, char *);
int in_list(char **list, char *s) {
  int i;
  if (!list)
    return 0;
  for (i = 0; list[i]; i++)
    if (strcasecmp(list[i], s) == 0)
      return 1;
  return 0;
}


x86 assembly (clang, -O0):
<in_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1137 <in_list+0x27>
movl   $0x0,-0x4(%rbp)
jmp    1196 <in_list+0x86>
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     118f <in_list+0x7f>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    117c <in_list+0x6c>
movl   $0x1,-0x4(%rbp)
jmp    1196 <in_list+0x86>
jmp    1181 <in_list+0x71>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113e <in_list+0x2e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<in_list>:
push   %rbp
push   %r14
push   %rbx
xor    %r14d,%r14d
test   %rdi,%rdi
je     1152 <in_list+0x42>
mov    %rdi,%rbp
mov    (%rdi),%rdi
test   %rdi,%rdi
je     1152 <in_list+0x42>
mov    %rsi,%rbx
add    $0x8,%rbp
xchg   %ax,%ax
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     114c <in_list+0x3c>
mov    0x0(%rbp),%rdi
add    $0x8,%rbp
test   %rdi,%rdi
jne    1130 <in_list+0x20>
jmp    1152 <in_list+0x42>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @in_list(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
%7 = load i8**, i8*** %4
%8 = icmp ne i8** %7, null
br i1 %8, label %10, label %9
9: ; preds = %2
store i32 0, i32* %3
br label %33
10: ; preds = %2
store i32 0, i32* %6
br label %11
11: ; preds = %29, %10
%12 = load i8**, i8*** %4
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %12, i64 %14
%16 = load i8*, i8** %15
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %32
18: ; preds = %11
%19 = load i8**, i8*** %4
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = load i8*, i8** %5
%25 = call i64 @strcasecmp(i8* %23, i8* %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %18
store i32 1, i32* %3
br label %33
28: ; preds = %18
br label %29
29: ; preds = %28
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %11
32: ; preds = %11
store i32 0, i32* %3
br label %33
33: ; preds = %32, %27, %9
%34 = load i32, i32* %3
ret i32 %34
}

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