#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*/ strlen(char *);
scalar_t__ strncmp(char *, char *, int /*<<< orphan*/);
int get_tag_index(char tags[15][1024], char *tag) {
  int i = 0;
  while (i < 15) {
    if (strncmp(tags[i], tag, strlen(tag)) == 0) {
      return i;
    }
    i++;
  }
  return -1;
}


x86 assembly (clang, -O0):
<get_tag_index>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0xf,-0x1c(%rbp)
jge    1197 <get_tag_index+0x77>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0xa,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1189 <get_tag_index+0x69>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    119e <get_tag_index+0x7e>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1137 <get_tag_index+0x17>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_tag_index>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %r15d,%r15d
xchg   %ax,%ax
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1161 <get_tag_index+0x41>
add    $0x1,%r15
add    $0x400,%rbx
cmp    $0xf,%r15
jne    1130 <get_tag_index+0x10>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @get_tag_index([1024 x i8]* %0, i8* %1) {
br label %3
3: ; preds = %2, %9
%4 = phi i64 [ 0, %2 ], [ %10, %9 ]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %0, i64 %4, i64 0
%6 = tail call i32 @strlen(i8* %1)
%7 = tail call i64 @strncmp(i8* %5, i8* %1, i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = add nuw nsw i64 %4, 1
%11 = icmp eq i64 %10, 15
br i1 %11, label %14, label %3
12: ; preds = %3
%13 = trunc i64 %4 to i32
br label %14
14: ; preds = %9, %12
%15 = phi i32 [ %13, %12 ], [ -1, %9 ]
ret i32 %15
}