#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(int /*<<< orphan*/, char const *);
int find_file_in_list(const char *file, int argc, char **argv) {
  int i = -1;
  while (argc-- > 0) {
    i++;
    if (strcmp(*(argv++), file) == 0) {
      return i;
    }
  }
  return i;
}


x86 assembly (clang, -O0):
<find_file_in_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0xffffffff,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
jle    117e <find_file_in_list+0x6e>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%rax
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1179 <find_file_in_list+0x69>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1184 <find_file_in_list+0x74>
jmp    112a <find_file_in_list+0x1a>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_file_in_list>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r15
mov    %rdi,%r14
xor    %r12d,%r12d
test   %esi,%esi
cmovs  %esi,%r12d
mov    %r12d,%ebp
not    %ebp
add    %esi,%ebp
sub    %esi,%r12d
mov    $0xffffffff,%ebx
cs nopw 0x0(%rax,%rax,1)
lea    (%r12,%rbx,1),%eax
cmp    $0xffffffff,%eax
je     1162 <find_file_in_list+0x52>
add    $0x1,%ebx
mov    (%r15),%edi
add    $0x8,%r15
mov    %r14,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    1140 <find_file_in_list+0x30>
jmp    1164 <find_file_in_list+0x54>
mov    %ebp,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @find_file_in_list(i8* %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
store i32 -1, i32* %8
br label %9
9: ; preds = %25, %3
%10 = load i32, i32* %6
%11 = add nsw i32 %10, -1
store i32 %11, i32* %6
%12 = icmp sgt i32 %10, 0
br i1 %12, label %13, label %26
13: ; preds = %9
%14 = load i32, i32* %8
%15 = add nsw i32 %14, 1
store i32 %15, i32* %8
%16 = load i8**, i8*** %7
%17 = getelementptr inbounds i8*, i8** %16, i32 1
store i8** %17, i8*** %7
%18 = load i8*, i8** %16
%19 = ptrtoint i8* %18 to i32
%20 = load i8*, i8** %5
%21 = call i64 @strcmp(i32 %19, i8* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %13
%24 = load i32, i32* %8
store i32 %24, i32* %4
br label %28
25: ; preds = %13
br label %9
26: ; preds = %9
%27 = load i32, i32* %8
store i32 %27, i32* %4
br label %28
28: ; preds = %26, %23
%29 = load i32, i32* %4
ret i32 %29
}

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