#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 lookup_opt(int argc, const char *argv[]) {
  for (int i = 1; i <= argc - 1; i++) {
    if (strcmp(argv[i], "-b") == 0) {
      return 1;
    }
    if (strcmp(argv[i], "-o") == 0) {
      return 2;
    }
    if (strcmp(argv[i], "-h") == 0) {
      return 3;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<lookup_opt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     11d4 <lookup_opt+0xc4>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xeb6(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1165 <lookup_opt+0x55>
movl   $0x1,-0x4(%rbp)
jmp    11db <lookup_opt+0xcb>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe8b(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1193 <lookup_opt+0x83>
movl   $0x2,-0x4(%rbp)
jmp    11db <lookup_opt+0xcb>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe60(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11c1 <lookup_opt+0xb1>
movl   $0x3,-0x4(%rbp)
jmp    11db <lookup_opt+0xcb>
jmp    11c6 <lookup_opt+0xb6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1126 <lookup_opt+0x16>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lookup_opt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%eax
cmp    $0x2,%edi
jl     119f <lookup_opt+0x8f>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x1,%r14d
lea    0xec9(%rip),%r13
lea    0xec5(%rip),%r15
lea    0xec1(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rbx,%r14,8),%rdi
mov    %r13,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     118c <lookup_opt+0x7c>
mov    (%rbx,%r14,8),%rdi
mov    %r15,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1193 <lookup_opt+0x83>
mov    (%rbx,%r14,8),%rdi
mov    %r12,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     119a <lookup_opt+0x8a>
add    $0x1,%r14
cmp    %r14,%rbp
jne    1150 <lookup_opt+0x40>
mov    $0x1,%eax
jmp    119f <lookup_opt+0x8f>
mov    $0x2,%eax
jmp    119f <lookup_opt+0x8f>
mov    $0x3,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-b\00"
@.str.1 = [3 x i8] c"-o\00"
@.str.2 = [3 x i8] c"-h\00"
define i32 @lookup_opt(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %7
7: ; preds = %40, %2
%8 = load i32, i32* %6
%9 = load i32, i32* %4
%10 = sub nsw i32 %9, 1
%11 = icmp sle i32 %8, %10
br i1 %11, label %12, label %43
12: ; preds = %7
%13 = load i8**, i8*** %5
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %12
store i32 1, i32* %3
br label %44
21: ; preds = %12
%22 = load i8**, i8*** %5
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %21
store i32 2, i32* %3
br label %44
30: ; preds = %21
%31 = load i8**, i8*** %5
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %30
store i32 3, i32* %3
br label %44
39: ; preds = %30
br label %40
40: ; preds = %39
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 1
store i32 %42, i32* %6
br label %7
43: ; preds = %7
store i32 1, i32* %3
br label %44
44: ; preds = %43, %38, %29, %20
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@.str = [3 x i8] c"-b\00"
@.str.1 = [3 x i8] c"-o\00"
@.str.2 = [3 x i8] c"-h\00"
define i32 @lookup_opt(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %23
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %8
6: ; preds = %18
%7 = icmp eq i64 %22, %5
br i1 %7, label %23, label %8
8: ; preds = %4, %6
%9 = phi i64 [ 1, %4 ], [ %22, %6 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %23, label %14
14: ; preds = %8
%15 = load i8*, i8** %10
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %14
%19 = load i8*, i8** %10
%20 = tail call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
%22 = add nuw nsw i64 %9, 1
br i1 %21, label %23, label %6
23: ; preds = %6, %8, %14, %18, %2
%24 = phi i32 [ 1, %2 ], [ 3, %18 ], [ 2, %14 ], [ 1, %8 ], [ 1, %6 ]
ret i32 %24
}