#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 *);
char *arg_parse(int counter, char **vector, char *token) {
  for (int i = 1; i < counter; i++)
    if (strcmp(vector[i], token) == 0)
      return (i + 1 < counter) ? vector[i + 1] : NULL;
  return NULL;
}


x86 assembly (clang, -O0):
<arg_parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a9 <arg_parse+0x99>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1196 <arg_parse+0x86>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cmp    -0xc(%rbp),%eax
jge    117e <arg_parse+0x6e>
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
jmp    1189 <arg_parse+0x79>
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
jmp    1189 <arg_parse+0x79>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11b1 <arg_parse+0xa1>
jmp    119b <arg_parse+0x8b>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    112a <arg_parse+0x1a>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arg_parse>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     1171 <arg_parse+0x61>
mov    %rdx,%r13
mov    %rsi,%r12
mov    %edi,%r15d
mov    %edi,%eax
mov    $0x1,%ebp
sub    %rax,%rbp
mov    $0x2,%ebx
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
mov    -0x8(%r12,%rbx,8),%rdi
mov    %r13,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1166 <arg_parse+0x56>
lea    (%rbx,%rbp,1),%rax
add    $0x1,%rax
add    $0x1,%rbx
cmp    $0x2,%rax
jne    1140 <arg_parse+0x30>
jmp    1174 <arg_parse+0x64>
cmp    %r15d,%ebx
jge    1171 <arg_parse+0x61>
mov    (%r12,%rbx,8),%r14
jmp    1174 <arg_parse+0x64>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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