#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*/ Exit(char *, char);
int aaIndex(char s, char *alphabet, int d) {
  int i;
  for (i = 0; i < d; i++)
    if (s == alphabet[i])
      return (i);
  Exit((char *)"Looking for character %c in protein string.", s);
}


x86 assembly (clang, -O0):
<aaIndex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    116e <aaIndex+0x5e>
movsbl -0x5(%rbp),%eax
mov    -0x10(%rbp),%rcx
movslq -0x18(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    115b <aaIndex+0x4b>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    117e <aaIndex+0x6e>
jmp    1160 <aaIndex+0x50>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112c <aaIndex+0x1c>
lea    0xe8b(%rip),%rdi
movsbl -0x5(%rbp),%esi
call   1030 <Exit@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aaIndex>:
push   %rbx
test   %edx,%edx
jle    1131 <aaIndex+0x21>
mov    %edx,%ebx
mov    %edx,%ecx
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
cmp    %dil,(%rsi,%rax,1)
je     1145 <aaIndex+0x35>
add    $0x1,%rax
cmp    %rax,%rcx
jne    1120 <aaIndex+0x10>
jmp    1133 <aaIndex+0x23>
xor    %ebx,%ebx
movsbl %dil,%esi
lea    0xec2(%rip),%rdi
call   1030 <Exit@plt>
jmp    1147 <aaIndex+0x37>
mov    %eax,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Looking for character %c in protein string.\00"
define i32 @aaIndex(i8 signext %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8 %0, i8* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %26, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %7
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %29
13: ; preds = %9
%14 = load i8, i8* %5
%15 = sext i8 %14 to i32
%16 = load i8*, i8** %6
%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 = sext i8 %20 to i32
%22 = icmp eq i32 %15, %21
br i1 %22, label %23, label %25
23: ; preds = %13
%24 = load i32, i32* %8
store i32 %24, i32* %4
br label %32
25: ; preds = %13
br label %26
26: ; preds = %25
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
br label %9
29: ; preds = %9
%30 = load i8, i8* %5
%31 = call i32 @Exit(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8 signext %30)
br label %32
32: ; preds = %29, %23
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
@.str = [44 x i8] c"Looking for character %c in protein string.\00"
define i32 @aaIndex(i8 signext %0, i8* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %15
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %12
%8 = phi i64 [ 0, %5 ], [ %13, %12 ]
%9 = getelementptr inbounds i8, i8* %1, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, %0
br i1 %11, label %18, label %12
12: ; preds = %7
%13 = add nuw nsw i64 %8, 1
%14 = icmp eq i64 %13, %6
br i1 %14, label %15, label %7
15: ; preds = %12, %3
%16 = phi i32 [ 0, %3 ], [ %2, %12 ]
%17 = tail call i32 @Exit(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8 signext %0)
br label %20
18: ; preds = %7
%19 = trunc i64 %8 to i32
br label %20
20: ; preds = %18, %15
%21 = phi i32 [ %16, %15 ], [ %19, %18 ]
ret i32 %21
}