#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(int);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ strcmp(char *, char *);
int find_chrom(char **list, int n, char *s) {
  int i;
  for (i = 0; i < n; i++)
    if (strcmp(list[i], s) == 0)
      return i;
  printf("\n We could not find chromosome %s \n", s);
  exit(1);
  return 0;
}


x86 assembly (clang, -O0):
<find_chrom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1191 <find_chrom+0x61>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    117e <find_chrom+0x4e>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret
jmp    1183 <find_chrom+0x53>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114a <find_chrom+0x1a>
mov    -0x18(%rbp),%rsi
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<find_chrom>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
test   %esi,%esi
jle    116a <find_chrom+0x3a>
mov    %rdi,%r15
mov    %esi,%r12d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1183 <find_chrom+0x53>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1150 <find_chrom+0x20>
lea    0xe8f(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [36 x i8] c"\0A We could not find chromosome %s \0A\00"
define i32 @find_chrom(i8** %0, i32 %1, i8* %2) {
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i8** %0, i8*** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
store i32 0, i32* %7
br label %8
8: ; preds = %24, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %5
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %27
12: ; preds = %8
%13 = load i8**, i8*** %4
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = load i8*, i8** %6
%19 = call i64 @strcmp(i8* %17, i8* %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %12
%22 = load i32, i32* %7
ret i32 %22
23: ; preds = %12
br label %24
24: ; preds = %23
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %8
27: ; preds = %8
%28 = load i8*, i8** %6
%29 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %28)
%30 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@.str = [36 x i8] c"\0A We could not find chromosome %s \0A\00"
define i32 @find_chrom(i8** nocapture %0, i32 %1, i8* %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %18
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %15
%8 = phi i64 [ 0, %5 ], [ %16, %15 ]
%9 = getelementptr inbounds i8*, i8** %0, i64 %8
%10 = load i8*, i8** %9
%11 = tail call i64 @strcmp(i8* %10, i8* %2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = trunc i64 %8 to i32
ret i32 %14
15: ; preds = %7
%16 = add nuw nsw i64 %8, 1
%17 = icmp eq i64 %16, %6
br i1 %17, label %18, label %7
18: ; preds = %15, %3
%19 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %2)
%20 = tail call i32 @exit(i32 1)
unreachable
}