#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 *, char *);
int search(char name[][40], char specificName[]) {
  int i;
  int found = -1;
  for (i = 0; i < 100; i++) {
    if (strcmp(name[i], specificName) == 0) {
      found = i;
      break;
    }
  }
  return found;
}


x86 assembly (clang, -O0):
<search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    1178 <search+0x68>
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
imul   $0x28,%rax,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1165 <search+0x55>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1178 <search+0x68>
jmp    116a <search+0x5a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112e <search+0x1e>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %r15d,%r15d
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1144 <search+0x34>
add    $0x1,%r15
add    $0x28,%rbx
cmp    $0x64,%r15
jne    1120 <search+0x10>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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