#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*/ clParseError(int, char **, int, char *);
scalar_t__ strcasecmp(char *, char const *);
int readOptionString(int argc, char **argv, int *i, const char *opt,
                     char **arg) {
  if ((*i) < argc) {
    if (strcasecmp(argv[(*i)], opt) == 0) {
      (*i) += 1;
      if (*i < argc) {
        (*arg) = argv[(*i)];
      } else {
        clParseError(argc, argv, (*i), "Option expects one argument.");
      }
      return 1;
    }
  } else {
    clParseError(argc, argv, (*i), "Error parsing command line.");
  }
  return 0;
}


x86 assembly (clang, -O0):
<readOptionString>:
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    %r8,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    11cb <readOptionString+0xab>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11c6 <readOptionString+0xa6>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jge    11a1 <readOptionString+0x81>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
jmp    11ba <readOptionString+0x9a>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xe4b(%rip),%rcx
call   1040 <clParseError@plt>
movl   $0x1,-0x4(%rbp)
jmp    11eb <readOptionString+0xcb>
jmp    11e4 <readOptionString+0xc4>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xe3e(%rip),%rcx
call   1040 <clParseError@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readOptionString>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
movslq (%rdx),%rbx
cmp    %edi,%ebx
jge    116a <readOptionString+0x4a>
mov    %r8,%r15
mov    %rdx,%r12
mov    (%r14,%rbx,8),%rdi
mov    %rcx,%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    117f <readOptionString+0x5f>
lea    0x1(%rbx),%edx
mov    %edx,(%r12)
cmp    %ebp,%edx
jge    1188 <readOptionString+0x68>
mov    0x8(%r14,%rbx,8),%rax
mov    %rax,(%r15)
mov    $0x1,%eax
jmp    117f <readOptionString+0x5f>
lea    0xeac(%rip),%rcx
mov    %ebp,%edi
mov    %r14,%rsi
mov    %ebx,%edx
call   1040 <clParseError@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe71(%rip),%rcx
mov    %ebp,%edi
mov    %r14,%rsi
call   1040 <clParseError@plt>
mov    $0x1,%eax
jmp    117f <readOptionString+0x5f>

LLVM IR (-O0):
@.str = [29 x i8] c"Option expects one argument.\00"
@.str.1 = [28 x i8] c"Error parsing command line.\00"
define i32 @readOptionString(i32 %0, i8** %1, i32* %2, i8* %3, i8** %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i8**
store i32 %0, i32* %7
store i8** %1, i8*** %8
store i32* %2, i32** %9
store i8* %3, i8** %10
store i8** %4, i8*** %11
%12 = load i32*, i32** %9
%13 = load i32, i32* %12
%14 = load i32, i32* %7
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %50
16: ; preds = %5
%17 = load i8**, i8*** %8
%18 = load i32*, i32** %9
%19 = load i32, i32* %18
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %17, i64 %20
%22 = load i8*, i8** %21
%23 = load i8*, i8** %10
%24 = call i64 @strcasecmp(i8* %22, i8* %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %49
26: ; preds = %16
%27 = load i32*, i32** %9
%28 = load i32, i32* %27
%29 = add nsw i32 %28, 1
store i32 %29, i32* %27
%30 = load i32*, i32** %9
%31 = load i32, i32* %30
%32 = load i32, i32* %7
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %42
34: ; preds = %26
%35 = load i8**, i8*** %8
%36 = load i32*, i32** %9
%37 = load i32, i32* %36
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %35, i64 %38
%40 = load i8*, i8** %39
%41 = load i8**, i8*** %11
store i8* %40, i8** %41
br label %48
42: ; preds = %26
%43 = load i32, i32* %7
%44 = load i8**, i8*** %8
%45 = load i32*, i32** %9
%46 = load i32, i32* %45
%47 = call i32 @clParseError(i32 %43, i8** %44, i32 %46, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %48
48: ; preds = %42, %34
store i32 1, i32* %6
br label %57
49: ; preds = %16
br label %56
50: ; preds = %5
%51 = load i32, i32* %7
%52 = load i8**, i8*** %8
%53 = load i32*, i32** %9
%54 = load i32, i32* %53
%55 = call i32 @clParseError(i32 %51, i8** %52, i32 %54, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %56
56: ; preds = %50, %49
store i32 0, i32* %6
br label %57
57: ; preds = %56, %48
%58 = load i32, i32* %6
ret i32 %58
}

LLVM IR (-O2):
@.str = [29 x i8] c"Option expects one argument.\00"
@.str.1 = [28 x i8] c"Error parsing command line.\00"
define i32 @readOptionString(i32 %0, i8** %1, i32* nocapture %2, i8* nocapture %3, i8** nocapture writeonly %4) {
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, %0
br i1 %7, label %8, label %23
8: ; preds = %5
%9 = sext i32 %6 to i64
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = tail call i64 @strcasecmp(i8* %11, i8* %3)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %25
14: ; preds = %8
%15 = add nsw i32 %6, 1
store i32 %15, i32* %2
%16 = icmp slt i32 %15, %0
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = sext i32 %15 to i64
%19 = getelementptr inbounds i8*, i8** %1, i64 %18
%20 = load i8*, i8** %19
store i8* %20, i8** %4
br label %25
21: ; preds = %14
%22 = tail call i32 @clParseError(i32 %0, i8** %1, i32 %15, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %25
23: ; preds = %5
%24 = tail call i32 @clParseError(i32 %0, i8** %1, i32 %6, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %23, %8, %17, %21
%26 = phi i32 [ 1, %21 ], [ 1, %17 ], [ 0, %8 ], [ 0, %23 ]
ret i32 %26
}