#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*/ strcasecmp(char *, char *);
int has_arg(int argc, char **argv, char *test, char **value) {
  int i;
  *value = NULL;
  for (i = 0; i < argc; i++) {
    if (!strcasecmp(argv[i], test)) {
      *value = ((i + 1) < argc) ? argv[i + 1] : "";
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<has_arg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c6 <has_arg+0xb6>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    11b3 <has_arg+0xa3>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cmp    -0x8(%rbp),%eax
jge    118c <has_arg+0x7c>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
jmp    119c <has_arg+0x8c>
lea    0xe6d(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    119c <has_arg+0x8c>
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11cd <has_arg+0xbd>
jmp    11b8 <has_arg+0xa8>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1139 <has_arg+0x29>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<has_arg>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movq   $0x0,(%rcx)
xor    %r15d,%r15d
test   %edi,%edi
jle    1195 <has_arg+0x85>
mov    %rdx,%rbp
mov    %rsi,%r13
mov    %edi,%r12d
mov    %rcx,(%rsp)
mov    %edi,%r14d
neg    %r14
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    -0x8(%r13,%rbx,8),%rdi
mov    %rbp,%rsi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     1175 <has_arg+0x65>
lea    (%r14,%rbx,1),%rax
add    $0x1,%rax
add    $0x1,%rbx
cmp    $0x1,%rax
jne    1150 <has_arg+0x40>
jmp    1195 <has_arg+0x85>
cmp    %r12d,%ebx
mov    (%rsp),%rcx
jge    1185 <has_arg+0x75>
mov    0x0(%r13,%rbx,8),%rax
jmp    118c <has_arg+0x7c>
lea    0xe74(%rip),%rax
mov    %rax,(%rcx)
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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