#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 const *, char const *);
const char **header_find(const char **headers, unsigned count,
                         const char *key) {
  unsigned i;
  const char *header = NULL;
  for (i = 0; i < count; ++i) {
    header = *(headers + (i * 2));
    if (!strcmp(header, key))
      break;
  }
  return i < count ? headers + (i * 2) : NULL;
}


x86 assembly (clang, -O0):
<header_find>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1180 <header_find+0x70>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    116d <header_find+0x5d>
jmp    1180 <header_find+0x70>
jmp    1172 <header_find+0x62>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1132 <header_find+0x22>
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11a8 <header_find+0x98>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
mov    %ecx,%ecx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
jmp    11b3 <header_find+0xa3>
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
jmp    11b3 <header_find+0xa3>
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<header_find>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %ebx,%ebx
test   %esi,%esi
je     117c <header_find+0x6c>
mov    %rdx,%r12
mov    %esi,%r15d
mov    %rdi,%r14
mov    (%rdi),%rdi
mov    %rdx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1164 <header_find+0x54>
mov    %r15d,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbp,%rbx
je     1168 <header_find+0x58>
lea    (%rbx,%rbx,1),%eax
mov    (%r14,%rax,8),%rdi
mov    %r12,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
jne    1140 <header_find+0x30>
cmp    %rbp,%rbx
setb   %al
jmp    116e <header_find+0x5e>
mov    $0x1,%al
jmp    116e <header_find+0x5e>
setb   %al
mov    %r15d,%ebx
add    %ebx,%ebx
lea    (%r14,%rbx,8),%rcx
xor    %ebx,%ebx
test   %al,%al
cmovne %rcx,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i8** @header_find(i8** %0, i32 %1, i8* nocapture %2) {
%4 = icmp eq i32 %1, 0
br i1 %4, label %33, label %5
5: ; preds = %3
%6 = zext i32 %1 to i64
%7 = load i8*, i8** %0
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %7, i8* dereferenceable(1) %2)
%9 = icmp eq i32 %8, 0
br i1 %9, label %26, label %17
10: ; preds = %17
%11 = shl nuw i64 %19, 1
%12 = and i64 %11, 4294967294
%13 = getelementptr inbounds i8*, i8** %0, i64 %12
%14 = load i8*, i8** %13
%15 = tail call i32 @strcmp(i8* dereferenceable(1) %14, i8* dereferenceable(1) %2)
%16 = icmp eq i32 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %5, %10
%18 = phi i64 [ %19, %10 ], [ 0, %5 ]
%19 = add nuw nsw i64 %18, 1
%20 = icmp eq i64 %19, %6
br i1 %20, label %24, label %10
21: ; preds = %10
%22 = icmp ult i64 %19, %6
%23 = trunc i64 %19 to i32
br label %26
24: ; preds = %17
%25 = icmp ult i64 %19, %6
br label %26
26: ; preds = %24, %5, %21
%27 = phi i32 [ %23, %21 ], [ 0, %5 ], [ %1, %24 ]
%28 = phi i1 [ %22, %21 ], [ true, %5 ], [ %25, %24 ]
%29 = shl i32 %27, 1
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %0, i64 %30
%32 = select i1 %28, i8** %31, i8** null
br label %33
33: ; preds = %26, %3
%34 = phi i8** [ null, %3 ], [ %32, %26 ]
ret i8** %34
}