#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*/ strcmp(char *, char *);
int FindHeader(char *token, char **headerNames, int nHeaders, int *index) {
  int i, match = 0, nMatches;
  *index = -1;
  nMatches = 0;
  for (i = 0; i < nHeaders; i++) {
    if (!strcmp(token, headerNames[i])) {
      nMatches++;
      match = i;
    }
  }
  if (nMatches != 1)
    return (1);
  *index = match;
  return (0);
}


x86 assembly (clang, -O0):
<FindHeader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movl   $0xffffffff,(%rax)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1192 <FindHeader+0x82>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    117f <FindHeader+0x6f>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    1184 <FindHeader+0x74>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1146 <FindHeader+0x36>
cmpl   $0x1,-0x34(%rbp)
je     11a8 <FindHeader+0x98>
movl   $0x1,-0x4(%rbp)
jmp    11b8 <FindHeader+0xa8>
mov    -0x30(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FindHeader>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0xffffffff,(%rcx)
mov    $0x1,%eax
test   %edx,%edx
jle    1176 <FindHeader+0x66>
mov    %rsi,%r12
mov    %rdi,%r13
mov    %rcx,(%rsp)
mov    %edx,%ebx
xor    %r14d,%r14d
xor    %r15d,%r15d
xor    %ebp,%ebp
xchg   %ax,%ax
mov    (%r12,%r14,8),%rsi
mov    %r13,%rdi
call   1030 <strcmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
cmove  %r14d,%ebp
sete   %cl
add    %ecx,%r15d
add    $0x1,%r14
cmp    %r14,%rbx
jne    1140 <FindHeader+0x30>
cmp    $0x1,%r15d
mov    $0x1,%eax
jne    1176 <FindHeader+0x66>
mov    (%rsp),%rax
mov    %ebp,(%rax)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @FindHeader(i8* nocapture %0, i8** nocapture %1, i32 %2, i32* nocapture writeonly %3) {
store i32 -1, i32* %3
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %25
6: ; preds = %4
%7 = zext i32 %2 to i64
br label %8
8: ; preds = %6, %8
%9 = phi i64 [ 0, %6 ], [ %20, %8 ]
%10 = phi i32 [ 0, %6 ], [ %19, %8 ]
%11 = phi i32 [ 0, %6 ], [ %17, %8 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 %9
%13 = load i8*, i8** %12
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(1) %13)
%15 = icmp eq i32 %14, 0
%16 = trunc i64 %9 to i32
%17 = select i1 %15, i32 %16, i32 %11
%18 = zext i1 %15 to i32
%19 = add nuw nsw i32 %10, %18
%20 = add nuw nsw i64 %9, 1
%21 = icmp eq i64 %20, %7
br i1 %21, label %22, label %8
22: ; preds = %8
%23 = icmp eq i32 %19, 1
br i1 %23, label %24, label %25
24: ; preds = %22
store i32 %17, i32* %3
br label %25
25: ; preds = %4, %22, %24
%26 = phi i32 [ 0, %24 ], [ 1, %22 ], [ 1, %4 ]
ret i32 %26
}