#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 *, char *);
int find_dashdash(int argc, char **argv, int i) {
  while (i < argc) {
    if (strcmp("--", argv[i]) == 0)
      return i;
    ++i;
  }
  return -1;
}


x86 assembly (clang, -O0):
<find_dashdash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1169 <find_dashdash+0x59>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xebf(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    115b <find_dashdash+0x4b>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1170 <find_dashdash+0x60>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1122 <find_dashdash+0x12>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_dashdash>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xffffffff,%r14d
cmp    %edi,%edx
jge    1163 <find_dashdash+0x53>
mov    %edx,%r15d
movslq %edx,%rax
movslq %edi,%rbp
lea    (%rsi,%rax,8),%r13
sub    %rax,%rbp
xor    %ebx,%ebx
lea    0xec2(%rip),%r12
xchg   %ax,%ax
mov    0x0(%r13,%rbx,8),%rsi
mov    %r12,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     115d <find_dashdash+0x4d>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1140 <find_dashdash+0x30>
jmp    1163 <find_dashdash+0x53>
add    %ebx,%r15d
mov    %r15d,%r14d
mov    %r14d,%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"--\00"
define i32 @find_dashdash(i32 %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
br label %8
8: ; preds = %22, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %5
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %25
12: ; preds = %8
%13 = load i8**, i8*** %6
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %12
%21 = load i32, i32* %7
store i32 %21, i32* %4
br label %26
22: ; preds = %12
%23 = load i32, i32* %7
%24 = add nsw i32 %23, 1
store i32 %24, i32* %7
br label %8
25: ; preds = %8
store i32 -1, i32* %4
br label %26
26: ; preds = %25, %20
%27 = load i32, i32* %4
ret i32 %27
}

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