#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__ fnmatch(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ *strchr(char *, char);
int find_application(char *argv[]) {
  int uses_kickstart = 0;
  for (int i = 0; argv[i]; i++) {
    char *a = argv[i];
    if (i == 0 && fnmatch("*kickstart", a, 0) == 0) {
      uses_kickstart = 1;
      continue;
    }
    if (uses_kickstart) {
      if (a[0] == '-' && strchr("ioelnNRBLTIwWSsKk", a[1]) != NULL) {
        if (a[2] == 0)
          i++;
      } else if (a[0] == '-' && strchr("HVXFfqctzZ", a[1]) != NULL) {
      } else {
        uses_kickstart = 0;
      }
    }
    if (!uses_kickstart) {
      if (argv[i] == NULL) {
        return 0;
      } else {
        return i;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<find_application>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1271 <find_application+0x151>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    118f <find_application+0x6f>
mov    -0x20(%rbp),%rsi
lea    0xe8e(%rip),%rdi
xor    %edx,%edx
call   1040 <fnmatch@plt>
cmp    $0x0,%rax
jne    118f <find_application+0x6f>
movl   $0x1,-0x14(%rbp)
jmp    1263 <find_application+0x143>
cmpl   $0x0,-0x14(%rbp)
je     122a <find_application+0x10a>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11e6 <find_application+0xc6>
mov    -0x20(%rbp),%rax
lea    0xe57(%rip),%rdi
movsbl 0x1(%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     11e6 <find_application+0xc6>
mov    -0x20(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x0,%eax
jne    11e1 <find_application+0xc1>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1225 <find_application+0x105>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1219 <find_application+0xf9>
mov    -0x20(%rbp),%rax
lea    0xe1c(%rip),%rdi
movsbl 0x1(%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     1219 <find_application+0xf9>
jmp    1220 <find_application+0x100>
movl   $0x0,-0x14(%rbp)
jmp    1225 <find_application+0x105>
jmp    122a <find_application+0x10a>
cmpl   $0x0,-0x14(%rbp)
jne    125e <find_application+0x13e>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    1253 <find_application+0x133>
movl   $0x0,-0x4(%rbp)
jmp    1278 <find_application+0x158>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1278 <find_application+0x158>
jmp    1263 <find_application+0x143>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113a <find_application+0x1a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_application>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    (%rdi),%rbx
test   %rbx,%rbx
je     11ea <find_application+0xca>
mov    %rdi,%r13
mov    $0x1,%bpl
xor    %r14d,%r14d
lea    0xec4(%rip),%r15
nopw   0x0(%rax,%rax,1)
test   %r14d,%r14d
jne    116e <find_application+0x4e>
xor    %r12d,%r12d
lea    0xea1(%rip),%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1040 <fnmatch@plt>
test   %rax,%rax
je     11bd <find_application+0x9d>
test   $0x1,%bpl
jne    11d9 <find_application+0xb9>
cmpb   $0x2d,(%rbx)
jne    11d9 <find_application+0xb9>
movsbl 0x1(%rbx),%esi
mov    %r15,%rdi
call   1030 <strchr@plt>
test   %rax,%rax
je     11a0 <find_application+0x80>
cmpb   $0x1,0x2(%rbx)
adc    $0x0,%r14d
jmp    11ba <find_application+0x9a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpb   $0x2d,(%rbx)
jne    11d9 <find_application+0xb9>
movsbl 0x1(%rbx),%esi
lea    0xe6d(%rip),%rdi
call   1030 <strchr@plt>
test   %rax,%rax
je     11d9 <find_application+0xb9>
mov    %r14d,%r12d
movslq %r12d,%rax
add    $0x1,%r12d
mov    0x8(%r13,%rax,8),%rbx
xor    %ebp,%ebp
mov    %r12d,%r14d
test   %rbx,%rbx
jne    1150 <find_application+0x30>
jmp    11ec <find_application+0xcc>
movslq %r14d,%rax
xor    %ebp,%ebp
cmpq   $0x0,0x0(%r13,%rax,8)
cmovne %r14d,%ebp
jmp    11ec <find_application+0xcc>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"*kickstart\00"
@.str.1 = [18 x i8] c"ioelnNRBLTIwWSsKk\00"
@.str.2 = [11 x i8] c"HVXFfqctzZ\00"
define i32 @find_application(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i8** %0, i8*** %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %82, %1
%8 = load i8**, i8*** %3
%9 = load i32, i32* %5
%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 %85
14: ; preds = %7
%15 = load i8**, i8*** %3
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
store i8* %19, i8** %6
%20 = load i32, i32* %5
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %14
%23 = load i8*, i8** %6
%24 = call i64 @fnmatch(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %23, i32 0)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 1, i32* %4
br label %82
27: ; preds = %22, %14
%28 = load i32, i32* %4
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %68
30: ; preds = %27
%31 = load i8*, i8** %6
%32 = getelementptr inbounds i8, i8* %31, i64 0
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 45
br i1 %35, label %36, label %52
36: ; preds = %30
%37 = load i8*, i8** %6
%38 = getelementptr inbounds i8, i8* %37, i64 1
%39 = load i8, i8* %38
%40 = call i32* @strchr(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8 signext %39)
%41 = icmp ne i32* %40, null
br i1 %41, label %42, label %52
42: ; preds = %36
%43 = load i8*, i8** %6
%44 = getelementptr inbounds i8, i8* %43, i64 2
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %42
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
store i32 %50, i32* %5
br label %51
51: ; preds = %48, %42
br label %67
52: ; preds = %36, %30
%53 = load i8*, i8** %6
%54 = getelementptr inbounds i8, i8* %53, i64 0
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 45
br i1 %57, label %58, label %65
58: ; preds = %52
%59 = load i8*, i8** %6
%60 = getelementptr inbounds i8, i8* %59, i64 1
%61 = load i8, i8* %60
%62 = call i32* @strchr(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8 signext %61)
%63 = icmp ne i32* %62, null
br i1 %63, label %64, label %65
64: ; preds = %58
br label %66
65: ; preds = %58, %52
store i32 0, i32* %4
br label %66
66: ; preds = %65, %64
br label %67
67: ; preds = %66, %51
br label %68
68: ; preds = %67, %27
%69 = load i32, i32* %4
%70 = icmp ne i32 %69, 0
br i1 %70, label %81, label %71
71: ; preds = %68
%72 = load i8**, i8*** %3
%73 = load i32, i32* %5
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8*, i8** %72, i64 %74
%76 = load i8*, i8** %75
%77 = icmp eq i8* %76, null
br i1 %77, label %78, label %79
78: ; preds = %71
store i32 0, i32* %2
br label %86
79: ; preds = %71
%80 = load i32, i32* %5
store i32 %80, i32* %2
br label %86
81: ; preds = %68
br label %82
82: ; preds = %81, %26
%83 = load i32, i32* %5
%84 = add nsw i32 %83, 1
store i32 %84, i32* %5
br label %7
85: ; preds = %7
store i32 0, i32* %2
br label %86
86: ; preds = %85, %79, %78
%87 = load i32, i32* %2
ret i32 %87
}

LLVM IR (-O2):
@.str = [11 x i8] c"*kickstart\00"
@.str.1 = [18 x i8] c"ioelnNRBLTIwWSsKk\00"
@.str.2 = [11 x i8] c"HVXFfqctzZ\00"
define i32 @find_application(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = icmp eq i8* %2, null
br i1 %3, label %47, label %4
4: ; preds = %1, %34
%5 = phi i8* [ %39, %34 ], [ %2, %1 ]
%6 = phi i32 [ %36, %34 ], [ 0, %1 ]
%7 = phi i1 [ false, %34 ], [ true, %1 ]
%8 = icmp eq i32 %6, 0
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = tail call i64 @fnmatch(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %5, i32 0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %34, label %12
12: ; preds = %9, %4
br i1 %7, label %41, label %13
13: ; preds = %12
%14 = load i8, i8* %5
%15 = icmp eq i8 %14, 45
br i1 %15, label %16, label %41
16: ; preds = %13
%17 = getelementptr inbounds i8, i8* %5, i64 1
%18 = load i8, i8* %17
%19 = tail call i32* @strchr(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8 signext %18)
%20 = icmp eq i32* %19, null
br i1 %20, label %27, label %21
21: ; preds = %16
%22 = getelementptr inbounds i8, i8* %5, i64 2
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
%25 = zext i1 %24 to i32
%26 = add nsw i32 %6, %25
br label %34
27: ; preds = %16
%28 = load i8, i8* %5
%29 = icmp eq i8 %28, 45
br i1 %29, label %30, label %41
30: ; preds = %27
%31 = load i8, i8* %17
%32 = tail call i32* @strchr(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8 signext %31)
%33 = icmp eq i32* %32, null
br i1 %33, label %41, label %34
34: ; preds = %9, %21, %30
%35 = phi i32 [ %26, %21 ], [ %6, %30 ], [ 0, %9 ]
%36 = add nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8*, i8** %0, i64 %37
%39 = load i8*, i8** %38
%40 = icmp eq i8* %39, null
br i1 %40, label %47, label %4
41: ; preds = %27, %30, %13, %12
%42 = sext i32 %6 to i64
%43 = getelementptr inbounds i8*, i8** %0, i64 %42
%44 = load i8*, i8** %43
%45 = icmp eq i8* %44, null
%46 = select i1 %45, i32 0, i32 %6
br label %47
47: ; preds = %34, %1, %41
%48 = phi i32 [ %46, %41 ], [ 0, %1 ], [ 0, %34 ]
ret i32 %48
}