#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*/ del_arg(int, char **, int);
scalar_t__ strcmp(char *, char *);
int find_arg(int argc, char *argv[], char *arg) {
  int i;
  for (i = 0; i < argc; ++i) {
    if (!argv[i])
      continue;
    if (0 == strcmp(argv[i], arg)) {
      del_arg(argc, argv, i);
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<find_arg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11af <find_arg+0x8f>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    115e <find_arg+0x3e>
jmp    11a1 <find_arg+0x81>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    119c <find_arg+0x7c>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <del_arg@plt>
movl   $0x1,-0x4(%rbp)
jmp    11b6 <find_arg+0x96>
jmp    11a1 <find_arg+0x81>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <find_arg+0x1a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_arg>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    1173 <find_arg+0x53>
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%r12d
xor    %ebx,%ebx
jmp    1149 <find_arg+0x29>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %rbx,%r12
je     1173 <find_arg+0x53>
mov    (%r15,%rbx,8),%rdi
test   %rdi,%rdi
je     1140 <find_arg+0x20>
mov    %r14,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    1140 <find_arg+0x20>
mov    %r12d,%edi
mov    %r15,%rsi
mov    %ebx,%edx
call   1040 <del_arg@plt>
mov    $0x1,%eax
jmp    1175 <find_arg+0x55>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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