#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*/ stricmp(char const *, char *, int);
int strnicmp_array(const char *src, char **array, int num, int bytes) {
  while (--num >= 0)
    if (!stricmp(src, array[num], bytes))
      return num;
  return -1;
}


x86 assembly (clang, -O0):
<strnicmp_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jl     1169 <strnicmp_array+0x59>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x20(%rbp),%edx
call   1030 <stricmp@plt>
cmp    $0x0,%eax
jne    1164 <strnicmp_array+0x54>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1170 <strnicmp_array+0x60>
jmp    1126 <strnicmp_array+0x16>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strnicmp_array>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
mov    %edx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %ebx,%ebx
jle    114f <strnicmp_array+0x3f>
add    $0xffffffffffffffff,%rbx
mov    %ebx,%eax
mov    (%r15,%rax,8),%rsi
mov    %rbp,%rdi
mov    %r14d,%edx
call   1030 <stricmp@plt>
test   %eax,%eax
jne    1130 <strnicmp_array+0x20>
jmp    1154 <strnicmp_array+0x44>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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