#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 *);
int strcasecmp(char const *, char const *);
int readOptionString(int argc, char **argv, int *i, char const *opt,
                     char **arg) {
  int tmp;
  {
    if (*i < argc) {
      tmp = strcasecmp((char const *)*(argv + *i), opt);
      if (tmp == 0) {
        (*i)++;
        if (*i < argc) {
          *arg = *(argv + *i);
        } else {
          clParseError(argc, argv, *i, (char *)"Option expects one argument.");
        }
        return (1);
      }
    } else {
      clParseError(argc, argv, *i, (char *)"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    11ce <readOptionString+0xae>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcasecmp@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    11c9 <readOptionString+0xa9>
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    11a4 <readOptionString+0x84>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
jmp    11bd <readOptionString+0x9d>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xe48(%rip),%rcx
call   1040 <clParseError@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ee <readOptionString+0xce>
jmp    11e7 <readOptionString+0xc7>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xe3b(%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    1168 <readOptionString+0x48>
mov    %r8,%r15
mov    %rdx,%r12
mov    (%r14,%rbx,8),%rdi
mov    %rcx,%rsi
call   1030 <strcasecmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
jne    117d <readOptionString+0x5d>
lea    0x1(%rbx),%edx
mov    %edx,(%r12)
cmp    %ebp,%edx
jge    1186 <readOptionString+0x66>
mov    0x8(%r14,%rbx,8),%rax
mov    %rax,(%r15)
mov    $0x1,%eax
jmp    117d <readOptionString+0x5d>
lea    0xeae(%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    0xe73(%rip),%rcx
mov    %ebp,%edi
mov    %r14,%rsi
call   1040 <clParseError@plt>
mov    $0x1,%eax
jmp    117d <readOptionString+0x5d>

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**
%12 = alloca i32
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
%13 = load i32*, i32** %9
%14 = load i32, i32* %13
%15 = load i32, i32* %7
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %52
17: ; preds = %5
%18 = load i8**, i8*** %8
%19 = load i32*, i32** %9
%20 = load i32, i32* %19
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %18, i64 %21
%23 = load i8*, i8** %22
%24 = load i8*, i8** %10
%25 = call i32 @strcasecmp(i8* %23, i8* %24)
store i32 %25, i32* %12
%26 = load i32, i32* %12
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %51
28: ; preds = %17
%29 = load i32*, i32** %9
%30 = load i32, i32* %29
%31 = add nsw i32 %30, 1
store i32 %31, i32* %29
%32 = load i32*, i32** %9
%33 = load i32, i32* %32
%34 = load i32, i32* %7
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %44
36: ; preds = %28
%37 = load i8**, i8*** %8
%38 = load i32*, i32** %9
%39 = load i32, i32* %38
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %37, i64 %40
%42 = load i8*, i8** %41
%43 = load i8**, i8*** %11
store i8* %42, i8** %43
br label %50
44: ; preds = %28
%45 = load i32, i32* %7
%46 = load i8**, i8*** %8
%47 = load i32*, i32** %9
%48 = load i32, i32* %47
%49 = call i32 @clParseError(i32 %45, i8** %46, i32 %48, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %50
50: ; preds = %44, %36
store i32 1, i32* %6
br label %59
51: ; preds = %17
br label %58
52: ; preds = %5
%53 = load i32, i32* %7
%54 = load i8**, i8*** %8
%55 = load i32*, i32** %9
%56 = load i32, i32* %55
%57 = call i32 @clParseError(i32 %53, i8** %54, i32 %56, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %58
58: ; preds = %52, %51
store i32 0, i32* %6
br label %59
59: ; preds = %58, %50
%60 = load i32, i32* %6
ret i32 %60
}

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 i32 @strcasecmp(i8* %11, i8* %3)
%13 = icmp eq i32 %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
}