#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 readOptionYesNo(int argc, char **argv, int *i, const char *opt, int *flag) {
  if ((*i) < argc) {
    if (strcasecmp(argv[*i], opt) == 0) {
      (*i) += 1;
      if ((*i) < argc) {
        if (strcasecmp(argv[(*i)], "YES") == 0) {
          (*flag) = 1;
          return 1;
        } else if (strcasecmp(argv[(*i)], "NO") == 0) {
          (*flag) = 0;
          return 1;
        } else {
          clParseError(argc, argv, (*i), "Option expects YES or NO.");
        }
      } else {
        clParseError(argc, argv, (*i), "Option expects YES or NO.");
      }
      return 1;
    }
  } else {
    clParseError(argc, argv, (*i), "Error parsing command line.");
  }
  return 0;
}


x86 assembly (clang, -O0):
<readOptionYesNo>:
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    1249 <readOptionYesNo+0x129>
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    1244 <readOptionYesNo+0x124>
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    121f <readOptionYesNo+0xff>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe64(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11c1 <readOptionYesNo+0xa1>
mov    -0x28(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1269 <readOptionYesNo+0x149>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe2d(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11fc <readOptionYesNo+0xdc>
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1269 <readOptionYesNo+0x149>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xdf7(%rip),%rcx
call   1040 <clParseError@plt>
jmp    121a <readOptionYesNo+0xfa>
jmp    1238 <readOptionYesNo+0x118>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xdd4(%rip),%rcx
call   1040 <clParseError@plt>
movl   $0x1,-0x4(%rbp)
jmp    1269 <readOptionYesNo+0x149>
jmp    1262 <readOptionYesNo+0x142>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xdc4(%rip),%rcx
call   1040 <clParseError@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readOptionYesNo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %edi,%r13d
movslq (%rdx),%rbx
cmp    %edi,%ebx
jge    11aa <readOptionYesNo+0x8a>
mov    %r8,%r14
mov    %rdx,%rbp
mov    (%r12,%rbx,8),%rdi
mov    %rcx,%rsi
call   1030 <strcasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    11c0 <readOptionYesNo+0xa0>
lea    0x1(%rbx),%r15d
mov    %r15d,0x0(%rbp)
cmp    %r13d,%r15d
jge    118e <readOptionYesNo+0x6e>
mov    0x8(%r12,%rbx,8),%rbx
lea    0xe93(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11cf <readOptionYesNo+0xaf>
lea    0xe83(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11dd <readOptionYesNo+0xbd>
lea    0xe72(%rip),%rcx
mov    %r13d,%edi
mov    %r12,%rsi
mov    %r15d,%edx
call   1040 <clParseError@plt>
mov    $0x1,%eax
jmp    11c0 <readOptionYesNo+0xa0>
lea    0xe70(%rip),%rcx
mov    %r13d,%edi
mov    %r12,%rsi
mov    %ebx,%edx
call   1040 <clParseError@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movl   $0x1,(%r14)
mov    $0x1,%eax
jmp    11c0 <readOptionYesNo+0xa0>
movl   $0x0,(%r14)
mov    $0x1,%eax
jmp    11c0 <readOptionYesNo+0xa0>

LLVM IR (-O0):
@.str = [4 x i8] c"YES\00"
@.str.1 = [3 x i8] c"NO\00"
@.str.2 = [26 x i8] c"Option expects YES or NO.\00"
@.str.3 = [28 x i8] c"Error parsing command line.\00"
define i32 @readOptionYesNo(i32 %0, i8** %1, i32* %2, i8* %3, i32* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i32*
store i32 %0, i32* %7
store i8** %1, i8*** %8
store i32* %2, i32** %9
store i8* %3, i8** %10
store i32* %4, i32** %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 %72
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 %71
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 %64
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 = call i64 @strcasecmp(i8* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %34
%44 = load i32*, i32** %11
store i32 1, i32* %44
store i32 1, i32* %6
br label %79
45: ; preds = %34
%46 = load i8**, i8*** %8
%47 = load i32*, i32** %9
%48 = load i32, i32* %47
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %46, i64 %49
%51 = load i8*, i8** %50
%52 = call i64 @strcasecmp(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %45
%55 = load i32*, i32** %11
store i32 0, i32* %55
store i32 1, i32* %6
br label %79
56: ; preds = %45
%57 = load i32, i32* %7
%58 = load i8**, i8*** %8
%59 = load i32*, i32** %9
%60 = load i32, i32* %59
%61 = call i32 @clParseError(i32 %57, i8** %58, i32 %60, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %62
62: ; preds = %56
br label %63
63: ; preds = %62
br label %70
64: ; preds = %26
%65 = load i32, i32* %7
%66 = load i8**, i8*** %8
%67 = load i32*, i32** %9
%68 = load i32, i32* %67
%69 = call i32 @clParseError(i32 %65, i8** %66, i32 %68, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %70
70: ; preds = %64, %63
store i32 1, i32* %6
br label %79
71: ; preds = %16
br label %78
72: ; preds = %5
%73 = load i32, i32* %7
%74 = load i8**, i8*** %8
%75 = load i32*, i32** %9
%76 = load i32, i32* %75
%77 = call i32 @clParseError(i32 %73, i8** %74, i32 %76, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %78
78: ; preds = %72, %71
store i32 0, i32* %6
br label %79
79: ; preds = %78, %70, %54, %43
%80 = load i32, i32* %6
ret i32 %80
}

LLVM IR (-O2):
@.str = [4 x i8] c"YES\00"
@.str.1 = [3 x i8] c"NO\00"
@.str.2 = [26 x i8] c"Option expects YES or NO.\00"
@.str.3 = [28 x i8] c"Error parsing command line.\00"
define i32 @readOptionYesNo(i32 %0, i8** %1, i32* nocapture %2, i8* nocapture %3, i32* nocapture writeonly %4) {
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, %0
br i1 %7, label %8, label %32
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 %34
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 %30
17: ; preds = %14
%18 = sext i32 %15 to i64
%19 = getelementptr inbounds i8*, i8** %1, i64 %18
%20 = load i8*, i8** %19
%21 = tail call i64 @strcasecmp(i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %17
store i32 1, i32* %4
br label %34
24: ; preds = %17
%25 = tail call i64 @strcasecmp(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 0, i32* %4
br label %34
28: ; preds = %24
%29 = tail call i32 @clParseError(i32 %0, i8** %1, i32 %15, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %34
30: ; preds = %14
%31 = tail call i32 @clParseError(i32 %0, i8** %1, i32 %15, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %34
32: ; preds = %5
%33 = tail call i32 @clParseError(i32 %0, i8** %1, i32 %6, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
br label %34
34: ; preds = %32, %8, %28, %30, %27, %23
%35 = phi i32 [ 1, %23 ], [ 1, %27 ], [ 1, %30 ], [ 1, %28 ], [ 0, %8 ], [ 0, %32 ]
ret i32 %35
}