#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*/ strncmp(char *, char *, int);
int getType(int pos, char **str, char source[][10]) {
  int i;
  for (i = 0; i < 3; i++) {
    if (!strncmp(str[pos], source[i], 3))
      return i;
  }
  return -1;
}


x86 assembly (clang, -O0):
<getType>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    1180 <getType+0x70>
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x1c(%rbp),%rax
imul   $0xa,%rax,%rax
add    %rax,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    116d <getType+0x5d>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1187 <getType+0x77>
jmp    1172 <getType+0x62>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112a <getType+0x1a>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getType>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
movslq %edi,%r15
mov    (%rsi,%r15,8),%rdi
mov    %rdx,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1167 <getType+0x57>
mov    (%r14,%r15,8),%rdi
lea    0xa(%rbx),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     116b <getType+0x5b>
mov    (%r14,%r15,8),%rdi
add    $0x14,%rbx
mov    %rbx,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
neg    %eax
sbb    %eax,%eax
or     $0x2,%eax
jmp    1170 <getType+0x60>
xor    %eax,%eax
jmp    1170 <getType+0x60>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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