#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 has_option(char **options, char *option) {
  int i;
  for (i = 2; options[i]; i++)
    if (!strcmp(options[i], option))
      return i;
  return 0;
}


x86 assembly (clang, -O0):
<has_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x2,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1176 <has_option+0x66>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1163 <has_option+0x53>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    117d <has_option+0x6d>
jmp    1168 <has_option+0x58>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1127 <has_option+0x17>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<has_option>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbp
mov    0x10(%rdi),%rdi
xor    %r14d,%r14d
test   %rdi,%rdi
je     1152 <has_option+0x42>
mov    %rsi,%r15
mov    $0x3,%ebx
xchg   %ax,%ax
mov    %r15,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     114c <has_option+0x3c>
mov    0x0(%rbp,%rbx,8),%rdi
add    $0x1,%rbx
test   %rdi,%rdi
jne    1130 <has_option+0x20>
jmp    1152 <has_option+0x42>
add    $0xffffffff,%ebx
mov    %ebx,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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