#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 */
scalar_t__ strcmp(char const *, char *);
int nc_find(char **params, const char *key) {
  int i;
  char **p;
  for (i = 0, p = params; *p; p += 2, i++) {
    if (strcmp(key, *p) == 0)
      return i;
  }
  return -1;
}


x86 assembly (clang, -O0):
<nc_find>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpq   $0x0,(%rax)
je     1181 <nc_find+0x71>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    (%rax),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1162 <nc_find+0x52>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1188 <nc_find+0x78>
jmp    1167 <nc_find+0x57>
mov    -0x28(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112f <nc_find+0x1f>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nc_find>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    (%rdi),%rsi
mov    $0xffffffff,%r14d
test   %rsi,%rsi
je     1162 <nc_find+0x52>
mov    %rdi,%rbp
add    $0x10,%rbp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     115f <nc_find+0x4f>
add    $0x1,%ebx
mov    0x0(%rbp),%rsi
add    $0x10,%rbp
test   %rsi,%rsi
jne    1140 <nc_find+0x30>
jmp    1162 <nc_find+0x52>
mov    %ebx,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @nc_find(i8** nocapture %0, i8* %1) {
%3 = load i8*, i8** %0
%4 = icmp eq i8* %3, null
br i1 %4, label %16, label %5
5: ; preds = %2, %11
%6 = phi i8* [ %14, %11 ], [ %3, %2 ]
%7 = phi i8** [ %12, %11 ], [ %0, %2 ]
%8 = phi i32 [ %13, %11 ], [ 0, %2 ]
%9 = tail call i64 @strcmp(i8* %1, i8* %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %5
%12 = getelementptr inbounds i8*, i8** %7, i64 2
%13 = add nuw nsw i32 %8, 1
%14 = load i8*, i8** %12
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %5
16: ; preds = %5, %11, %2
%17 = phi i32 [ -1, %2 ], [ -1, %11 ], [ %8, %5 ]
ret i32 %17
}