#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*/ strlen(char *);
scalar_t__ strncmp(char *, char *, int /*<<< orphan*/);
int where_in_command_line(int argc, char *argv[], char *match) {
  int i;
  char *value_start;
  i = 1;
  while ((i <= argc) && (strncmp(argv[i], match, strlen(match)) != 0))
    i++;
  if (i == argc + 1)
    return -1;
  return i;
}


x86 assembly (clang, -O0):
<where_in_command_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0x29(%rbp)
jg     1185 <where_in_command_line+0x65>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1195 <where_in_command_line+0x75>
jmp    11a3 <where_in_command_line+0x83>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <where_in_command_line+0x1a>
mov    -0x1c(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jne    11c0 <where_in_command_line+0xa0>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c6 <where_in_command_line+0xa6>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<where_in_command_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0x1(%rdi),%r12d
test   %edi,%edi
jle    117c <where_in_command_line+0x5c>
mov    %rdx,%r15
mov    %rsi,%r14
mov    %r12d,%r13d
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbp,8),%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1181 <where_in_command_line+0x61>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1150 <where_in_command_line+0x30>
mov    %r12d,%ebp
jmp    1181 <where_in_command_line+0x61>
mov    $0x1,%ebp
cmp    %r12d,%ebp
mov    $0xffffffff,%eax
cmovne %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @where_in_command_line(i32 %0, i8** %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8* %2, i8** %7
store i32 1, i32* %8
br label %10
10: ; preds = %27, %3
%11 = load i32, i32* %8
%12 = load i32, i32* %5
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %25
14: ; preds = %10
%15 = load i8**, i8*** %6
%16 = load i32, i32* %8
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = load i8*, i8** %7
%21 = load i8*, i8** %7
%22 = call i32 @strlen(i8* %21)
%23 = call i64 @strncmp(i8* %19, i8* %20, i32 %22)
%24 = icmp ne i64 %23, 0
br label %25
25: ; preds = %14, %10
%26 = phi i1 [ false, %10 ], [ %24, %14 ]
br i1 %26, label %27, label %30
27: ; preds = %25
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
store i32 %29, i32* %8
br label %10
30: ; preds = %25
%31 = load i32, i32* %8
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
%34 = icmp eq i32 %31, %33
br i1 %34, label %35, label %36
35: ; preds = %30
store i32 -1, i32* %4
br label %38
36: ; preds = %30
%37 = load i32, i32* %8
store i32 %37, i32* %4
br label %38
38: ; preds = %36, %35
%39 = load i32, i32* %4
ret i32 %39
}

LLVM IR (-O2):
define i32 @where_in_command_line(i32 %0, i8** nocapture %1, i8* %2) {
%4 = icmp slt i32 %0, 1
%5 = add i32 %0, 1
br i1 %4, label %20, label %6
6: ; preds = %3
%7 = zext i32 %5 to i64
br label %8
8: ; preds = %6, %15
%9 = phi i64 [ 1, %6 ], [ %16, %15 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = tail call i32 @strlen(i8* %2)
%13 = tail call i64 @strncmp(i8* %11, i8* %2, i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %8
%16 = add nuw nsw i64 %9, 1
%17 = icmp eq i64 %16, %7
br i1 %17, label %20, label %8
18: ; preds = %8
%19 = trunc i64 %9 to i32
br label %20
20: ; preds = %15, %18, %3
%21 = phi i32 [ 1, %3 ], [ %19, %18 ], [ %5, %15 ]
%22 = icmp eq i32 %21, %5
%23 = select i1 %22, i32 -1, i32 %21
ret i32 %23
}