#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*/ free(char *);
char *split_and_get(char *, char, char **);
scalar_t__ strcasecmp(char *, char const *);
char *strdup(char const *);
int is_in_str_list(const char list[], char separator, const char needle[]) {
  char *list_copy = strdup(list);
  char *item = list_copy, *state = NULL;
  while ((item = split_and_get(item, separator, &state)) != NULL) {
    if (strcasecmp(item, needle) == 0) {
      break;
    }
  }
  free(list_copy);
  return (item != NULL);
}


x86 assembly (clang, -O0):
<is_in_str_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rdx
movsbl -0x9(%rbp),%esi
call   1050 <split_and_get@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     11b3 <is_in_str_list+0x73>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11ae <is_in_str_list+0x6e>
jmp    11b3 <is_in_str_list+0x73>
jmp    1173 <is_in_str_list+0x33>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x28(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_in_str_list>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r12
mov    %esi,%ebx
call   1060 <strdup@plt>
mov    %rax,%r14
movq   $0x0,0x8(%rsp)
movsbl %bl,%ebp
lea    0x8(%rsp),%r15
mov    %rax,%rbx
nopl   (%rax)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r15,%rdx
call   1050 <split_and_get@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1195 <is_in_str_list+0x55>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <strcasecmp@plt>
test   %rax,%rax
jne    1170 <is_in_str_list+0x30>
xor    %ebp,%ebp
test   %rbx,%rbx
setne  %bpl
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @is_in_str_list(i8* nocapture %0, i8 signext %1, i8* nocapture %2) {
%4 = alloca i8*
%5 = tail call i8* @strdup(i8* %0)
%6 = bitcast i8** %4 to i8*
store i8* null, i8** %4
br label %7
7: ; preds = %11, %3
%8 = phi i8* [ %5, %3 ], [ %9, %11 ]
%9 = call i8* @split_and_get(i8* %8, i8 signext %1, i8** %4)
%10 = icmp eq i8* %9, null
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = call i64 @strcasecmp(i8* %9, i8* %2)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %7
14: ; preds = %11, %7
%15 = xor i1 %10, true
%16 = call i32 @free(i8* %5)
%17 = zext i1 %15 to i32
ret i32 %17
}