#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__ strchr(char *, int);
int find_short_arg(char **argv, int opt_short) {
  int i;
  for (i = 1; argv[i]; i++) {
    char *a = argv[i];
    if (*a == '-') {
      if (*(a + 1) == '-') {
        if (*(a + 2) == 0)
          return -1;
        continue;
      }
      if (strchr(a, opt_short))
        return i;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<find_short_arg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11c5 <find_short_arg+0xb5>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11b2 <find_short_arg+0xa2>
mov    -0x20(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2d,%eax
jne    118c <find_short_arg+0x7c>
mov    -0x20(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x0,%eax
jne    1187 <find_short_arg+0x77>
movl   $0xffffffff,-0x4(%rbp)
jmp    11cc <find_short_arg+0xbc>
jmp    11b7 <find_short_arg+0xa7>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     11ad <find_short_arg+0x9d>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11cc <find_short_arg+0xbc>
jmp    11b2 <find_short_arg+0xa2>
jmp    11b7 <find_short_arg+0xa7>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1126 <find_short_arg+0x16>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_short_arg>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x8(%rdi),%rdi
mov    $0xffffffff,%r14d
test   %rdi,%rdi
je     1173 <find_short_arg+0x63>
mov    %esi,%r15d
mov    $0x2,%ebp
jmp    115a <find_short_arg+0x4a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15d,%esi
call   1030 <strchr@plt>
test   %rax,%rax
jne    116d <find_short_arg+0x5d>
mov    (%rbx,%rbp,8),%rdi
add    $0x1,%rbp
test   %rdi,%rdi
je     1173 <find_short_arg+0x63>
cmpb   $0x2d,(%rdi)
jne    114d <find_short_arg+0x3d>
cmpb   $0x2d,0x1(%rdi)
jne    1140 <find_short_arg+0x30>
cmpb   $0x0,0x2(%rdi)
jne    114d <find_short_arg+0x3d>
jmp    1173 <find_short_arg+0x63>
add    $0xffffffff,%ebp
mov    %ebp,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @find_short_arg(i8** %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i8** %0, i8*** %4
store i32 %1, i32* %5
store i32 1, i32* %6
br label %8
8: ; preds = %48, %2
%9 = load i8**, i8*** %4
%10 = load i32, i32* %6
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8*, i8** %9, i64 %11
%13 = load i8*, i8** %12
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %51
15: ; preds = %8
%16 = load i8**, i8*** %4
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
store i8* %20, i8** %7
%21 = load i8*, i8** %7
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 45
br i1 %24, label %25, label %47
25: ; preds = %15
%26 = load i8*, i8** %7
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 45
br i1 %30, label %31, label %39
31: ; preds = %25
%32 = load i8*, i8** %7
%33 = getelementptr inbounds i8, i8* %32, i64 2
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %31
store i32 -1, i32* %3
br label %52
38: ; preds = %31
br label %48
39: ; preds = %25
%40 = load i8*, i8** %7
%41 = load i32, i32* %5
%42 = call i64 @strchr(i8* %40, i32 %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %39
%45 = load i32, i32* %6
store i32 %45, i32* %3
br label %52
46: ; preds = %39
br label %47
47: ; preds = %46, %15
br label %48
48: ; preds = %47, %38
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
br label %8
51: ; preds = %8
store i32 -1, i32* %3
br label %52
52: ; preds = %51, %44, %37
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
define i32 @find_short_arg(i8** nocapture %0, i32 %1) {
%3 = getelementptr inbounds i8*, i8** %0, i64 1
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %29, label %6
6: ; preds = %2, %22
%7 = phi i64 [ %23, %22 ], [ 1, %2 ]
%8 = phi i8* [ %25, %22 ], [ %4, %2 ]
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 45
br i1 %10, label %11, label %22
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %8, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 45
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = getelementptr inbounds i8, i8* %8, i64 2
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %29, label %22
19: ; preds = %11
%20 = tail call i64 @strchr(i8* %8, i32 %1)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %6, %19, %15
%23 = add nuw i64 %7, 1
%24 = getelementptr inbounds i8*, i8** %0, i64 %23
%25 = load i8*, i8** %24
%26 = icmp eq i8* %25, null
br i1 %26, label %29, label %6
27: ; preds = %19
%28 = trunc i64 %7 to i32
br label %29
29: ; preds = %15, %22, %27, %2
%30 = phi i32 [ -1, %2 ], [ %28, %27 ], [ -1, %22 ], [ -1, %15 ]
ret i32 %30
}