#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*/ utf8stricmp(char *, char const *);
int array_index_utf8(char **strings, const char *str) {
  int i;
  if (!strings)
    return -1;
  for (i = 0; strings[i]; i++) {
    if (!utf8stricmp(strings[i], str))
      return i;
  }
  return -1;
}


x86 assembly (clang, -O0):
<array_index_utf8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1137 <array_index_utf8+0x27>
movl   $0xffffffff,-0x4(%rbp)
jmp    1194 <array_index_utf8+0x84>
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     118d <array_index_utf8+0x7d>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <utf8stricmp@plt>
cmp    $0x0,%eax
jne    117a <array_index_utf8+0x6a>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1194 <array_index_utf8+0x84>
jmp    117f <array_index_utf8+0x6f>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113e <array_index_utf8+0x2e>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<array_index_utf8>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0xffffffff,%r14d
test   %rdi,%rdi
je     115f <array_index_utf8+0x4f>
mov    %rdi,%rbp
mov    (%rdi),%rdi
test   %rdi,%rdi
je     115f <array_index_utf8+0x4f>
mov    %rsi,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rsi
call   1030 <utf8stricmp@plt>
test   %eax,%eax
je     115c <array_index_utf8+0x4c>
mov    0x8(%rbp,%rbx,8),%rdi
add    $0x1,%rbx
test   %rdi,%rdi
jne    1140 <array_index_utf8+0x30>
jmp    115f <array_index_utf8+0x4f>
mov    %ebx,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @array_index_utf8(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 -1, i32* %3
br label %34
10: ; preds = %2
store i32 0, i32* %6
br label %11
11: ; preds = %30, %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 %33
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 i32 @utf8stricmp(i8* %23, i8* %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %18
%28 = load i32, i32* %6
store i32 %28, i32* %3
br label %34
29: ; preds = %18
br label %30
30: ; preds = %29
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %11
33: ; preds = %11
store i32 -1, i32* %3
br label %34
34: ; preds = %33, %27, %9
%35 = load i32, i32* %3
ret i32 %35
}

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