#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 find_tok(int, char **, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
size_t strlen(char *);
char *find_argument(int argc, char **argv, char *to_find, int *found_list) {
  int i = find_tok(argc, argv, to_find);
  if (i == -1)
    return NULL;
  found_list[i] = 1;
  if (strlen(argv[i]) == strlen(to_find)) {
    if (i < argc - 1) {
      found_list[i + 1] = 1;
      return argv[i + 1];
    } else {
      fprintf(stderr,
              "Warning - token %s requested with an argument, but none was "
              "supplied.\n",
              to_find);
      return NULL;
    }
  } else {
    return &(argv[i][strlen(to_find)]);
  }
}


x86 assembly (clang, -O0):
<find_argument>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <find_tok@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    1171 <find_argument+0x41>
movq   $0x0,-0x8(%rbp)
jmp    123a <find_argument+0x10a>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
jne    1213 <find_argument+0xe3>
mov    -0x2c(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11ed <find_argument+0xbd>
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x8(%rbp)
jmp    123a <find_argument+0x10a>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xdff(%rip),%rsi
call   1040 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    123a <find_argument+0x10a>
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_argument>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%r12
mov    %edi,%r13d
call   1050 <find_tok@plt>
cmp    $0xffffffff,%eax
je     11c1 <find_argument+0x91>
mov    %eax,%ebp
movslq %eax,%r14
movl   $0x1,(%rbx,%r14,4)
mov    %rbx,0x8(%rsp)
mov    (%r12,%r14,8),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rax,0x10(%rsp)
mov    %r15,%rdi
call   1030 <strlen@plt>
cmp    %rax,0x10(%rsp)
jne    11a4 <find_argument+0x74>
mov    0x8(%rsp),%rax
add    $0xffffffff,%r13d
cmp    %r13d,%ebp
jge    11a9 <find_argument+0x79>
movl   $0x1,0x4(%rax,%r14,4)
mov    0x8(%r12,%r14,8),%rbx
jmp    11c3 <find_argument+0x93>
add    %rax,%rbx
jmp    11c3 <find_argument+0x93>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
lea    0xe47(%rip),%rsi
mov    %r15,%rdx
call   1040 <fprintf@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [71 x i8] c"Warning - token %s requested with an argument, but none was supplied.\0A\00"
define i8* @find_argument(i32 %0, i8** %1, i8* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32
store i32 %0, i32* %6
store i8** %1, i8*** %7
store i8* %2, i8** %8
store i32* %3, i32** %9
%11 = load i32, i32* %6
%12 = load i8**, i8*** %7
%13 = load i8*, i8** %8
%14 = call i32 @find_tok(i32 %11, i8** %12, i8* %13)
store i32 %14, i32* %10
%15 = load i32, i32* %10
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %18
17: ; preds = %4
store i8* null, i8** %5
br label %62
18: ; preds = %4
%19 = load i32*, i32** %9
%20 = load i32, i32* %10
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
store i32 1, i32* %22
%23 = load i8**, i8*** %7
%24 = load i32, i32* %10
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = call i64 @strlen(i8* %27)
%29 = load i8*, i8** %8
%30 = call i64 @strlen(i8* %29)
%31 = icmp eq i64 %28, %30
br i1 %31, label %32, label %53
32: ; preds = %18
%33 = load i32, i32* %10
%34 = load i32, i32* %6
%35 = sub nsw i32 %34, 1
%36 = icmp slt i32 %33, %35
br i1 %36, label %37, label %49
37: ; preds = %32
%38 = load i32*, i32** %9
%39 = load i32, i32* %10
%40 = add nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %38, i64 %41
store i32 1, i32* %42
%43 = load i8**, i8*** %7
%44 = load i32, i32* %10
%45 = add nsw i32 %44, 1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %43, i64 %46
%48 = load i8*, i8** %47
store i8* %48, i8** %5
br label %62
49: ; preds = %32
%50 = load i32, i32* @stderr
%51 = load i8*, i8** %8
%52 = call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0), i8* %51)
store i8* null, i8** %5
br label %62
53: ; preds = %18
%54 = load i8**, i8*** %7
%55 = load i32, i32* %10
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8*, i8** %54, i64 %56
%58 = load i8*, i8** %57
%59 = load i8*, i8** %8
%60 = call i64 @strlen(i8* %59)
%61 = getelementptr inbounds i8, i8* %58, i64 %60
store i8* %61, i8** %5
br label %62
62: ; preds = %53, %49, %37, %17
%63 = load i8*, i8** %5
ret i8* %63
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [71 x i8] c"Warning - token %s requested with an argument, but none was supplied.\0A\00"
define i8* @find_argument(i32 %0, i8** %1, i8* %2, i32* nocapture writeonly %3) {
%5 = tail call i32 @find_tok(i32 %0, i8** %1, i8* %2)
%6 = icmp eq i32 %5, -1
br i1 %6, label %29, label %7
7: ; preds = %4
%8 = sext i32 %5 to i64
%9 = getelementptr inbounds i32, i32* %3, i64 %8
store i32 1, i32* %9
%10 = getelementptr inbounds i8*, i8** %1, i64 %8
%11 = load i8*, i8** %10
%12 = tail call i64 @strlen(i8* dereferenceable(1) %11)
%13 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %27
15: ; preds = %7
%16 = add nsw i32 %0, -1
%17 = icmp slt i32 %5, %16
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = add nuw nsw i32 %5, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %3, i64 %20
store i32 1, i32* %21
%22 = getelementptr inbounds i8*, i8** %1, i64 %20
%23 = load i8*, i8** %22
br label %29
24: ; preds = %15
%25 = load i32, i32* @stderr
%26 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %29
27: ; preds = %7
%28 = getelementptr inbounds i8, i8* %11, i64 %13
br label %29
29: ; preds = %4, %27, %24, %18
%30 = phi i8* [ %23, %18 ], [ null, %24 ], [ %28, %27 ], [ null, %4 ]
ret i8* %30
}