#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 */
size_t strlen(char const *);
scalar_t__ strncasecmp(char const *, char const *, size_t);
char *unquote(char const *, size_t *);
bool str_contains_n(size_t amount, const char **strings, const char *needle,
                    size_t needle_size) {
  if (*needle == '"') {
    needle++;
    needle_size -= 2;
    needle = unquote(needle, &needle_size);
  }
  for (size_t i = 0; i < amount; i++) {
    if (strlen(strings[i]) == needle_size &&
        strncasecmp(strings[i], needle, needle_size) == 0) {
      return true;
    }
  }
  return false;
}


x86 assembly (clang, -O0):
<str_contains_n>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    1181 <str_contains_n+0x51>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
sub    $0x2,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <unquote@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11f7 <str_contains_n+0xc7>
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
cmp    -0x28(%rbp),%rax
jne    11e1 <str_contains_n+0xb1>
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1050 <strncasecmp@plt>
cmp    $0x0,%rax
jne    11e1 <str_contains_n+0xb1>
movl   $0x1,-0x4(%rbp)
jmp    11fe <str_contains_n+0xce>
jmp    11e6 <str_contains_n+0xb6>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1189 <str_contains_n+0x59>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_contains_n>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x10(%rsp)
mov    %rdi,%r15
mov    %rcx,(%rsp)
cmpb   $0x22,(%rdx)
jne    1169 <str_contains_n+0x39>
add    $0x1,%rdx
add    $0xfffffffffffffffe,%rcx
mov    %rcx,(%rsp)
mov    %rsp,%rsi
mov    %rdx,%rdi
call   1040 <unquote@plt>
mov    %rax,%rdx
test   %r15,%r15
je     11d7 <str_contains_n+0xa7>
mov    %rdx,0x8(%rsp)
mov    (%rsp),%r13
mov    %r15,%r12
neg    %r12
mov    $0x1,%bpl
mov    $0x1,%r14d
jmp    11a9 <str_contains_n+0x79>
nopl   0x0(%rax,%rax,1)
cmp    %r15,%r14
setb   %bpl
lea    (%r12,%r14,1),%rax
add    $0x1,%rax
add    $0x1,%r14
cmp    $0x1,%rax
je     11d9 <str_contains_n+0xa9>
mov    0x10(%rsp),%rax
mov    -0x8(%rax,%r14,8),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %r13,%rax
jne    1190 <str_contains_n+0x60>
mov    %rbx,%rdi
mov    0x8(%rsp),%rsi
mov    %r13,%rdx
call   1050 <strncasecmp@plt>
test   %rax,%rax
jne    1190 <str_contains_n+0x60>
jmp    11d9 <str_contains_n+0xa9>
xor    %ebp,%ebp
movzbl %bpl,%eax
and    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @str_contains_n(i64 %0, i8** nocapture %1, i8* %2, i64 %3) {
%5 = alloca i64
store i64 %3, i64* %5
%6 = load i8, i8* %2
%7 = icmp eq i8 %6, 34
br i1 %7, label %8, label %12
8: ; preds = %4
%9 = getelementptr inbounds i8, i8* %2, i64 1
%10 = add i64 %3, -2
store i64 %10, i64* %5
%11 = call i8* @unquote(i8* %9, i64* %5)
br label %12
12: ; preds = %8, %4
%13 = phi i8* [ %11, %8 ], [ %2, %4 ]
%14 = icmp eq i64 %0, 0
br i1 %14, label %31, label %15
15: ; preds = %12
%16 = load i64, i64* %5
br label %17
17: ; preds = %15, %27
%18 = phi i1 [ true, %15 ], [ %29, %27 ]
%19 = phi i64 [ 0, %15 ], [ %28, %27 ]
%20 = getelementptr inbounds i8*, i8** %1, i64 %19
%21 = load i8*, i8** %20
%22 = call i64 @strlen(i8* dereferenceable(1) %21)
%23 = icmp eq i64 %22, %16
br i1 %23, label %24, label %27
24: ; preds = %17
%25 = call i64 @strncasecmp(i8* %21, i8* %13, i64 %16)
%26 = icmp eq i64 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %17, %24
%28 = add nuw i64 %19, 1
%29 = icmp ult i64 %28, %0
%30 = icmp eq i64 %28, %0
br i1 %30, label %31, label %17
31: ; preds = %27, %24, %12
%32 = phi i1 [ false, %12 ], [ %18, %24 ], [ %29, %27 ]
%33 = zext i1 %32 to i32
ret i32 %33
}