#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 const *);
int search_array(char *arg, const char **list) {
  int i;
  for (i = 0; **(list + i) != '\n'; i++) {
    if (!strcmp(arg, *(list + i)))
      return i;
  }
  return -1;
}


x86 assembly (clang, -O0):
<search_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     117b <search_array+0x6b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1168 <search_array+0x58>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1182 <search_array+0x72>
jmp    116d <search_array+0x5d>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1127 <search_array+0x17>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search_array>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    (%rsi),%rsi
mov    $0xffffffff,%r14d
cmpb   $0xa,(%rsi)
je     114f <search_array+0x3f>
mov    %rdi,%r15
xor    %ebp,%ebp
nopl   (%rax)
mov    %r15,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     114c <search_array+0x3c>
mov    0x8(%rbx,%rbp,8),%rsi
add    $0x1,%rbp
cmpb   $0xa,(%rsi)
jne    1130 <search_array+0x20>
jmp    114f <search_array+0x3f>
mov    %ebp,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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