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


x86 assembly (clang, -O0):
<readOptionDouble>:
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    11e8 <readOptionDouble+0xb8>
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    11e3 <readOptionDouble+0xb3>
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    11be <readOptionDouble+0x8e>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <atof@plt>
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1208 <readOptionDouble+0xd8>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xe2e(%rip),%rcx
call   1050 <clParseError@plt>
movl   $0x0,-0x4(%rbp)
jmp    1208 <readOptionDouble+0xd8>
jmp    1201 <readOptionDouble+0xd1>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xe20(%rip),%rcx
call   1050 <clParseError@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readOptionDouble>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebp
movslq (%rdx),%rbx
cmp    %edi,%ebx
jge    1183 <readOptionDouble+0x53>
mov    %r8,%r14
mov    %rdx,%r13
mov    (%r15,%rbx,8),%rdi
mov    %rcx,%rsi
call   1030 <strcasecmp@plt>
xor    %r12d,%r12d
test   %rax,%rax
jne    1199 <readOptionDouble+0x69>
lea    0x1(%rbx),%edx
mov    %edx,0x0(%r13)
cmp    %ebp,%edx
jge    11ab <readOptionDouble+0x7b>
mov    0x8(%r15,%rbx,8),%rdi
call   1040 <atof@plt>
movsd  %xmm0,(%r14)
mov    $0x1,%r12d
jmp    1199 <readOptionDouble+0x69>
lea    0xe92(%rip),%rcx
mov    %ebp,%edi
mov    %r15,%rsi
mov    %ebx,%edx
call   1050 <clParseError@plt>
xor    %r12d,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe4e(%rip),%rcx
mov    %ebp,%edi
mov    %r15,%rsi
call   1050 <clParseError@plt>
jmp    1199 <readOptionDouble+0x69>

LLVM IR (-O0):
@.str = [28 x i8] c"Option expects one argument\00"
@.str.1 = [28 x i8] c"Error parsing command line.\00"
define i32 @readOptionDouble(i32 %0, i8** %1, i32* %2, i8* %3, double* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca double*
store i32 %0, i32* %7
store i8** %1, i8*** %8
store i32* %2, i32** %9
store i8* %3, i8** %10
store double* %4, double** %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 %51
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 %50
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 %43
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 double @atof(i8* %40)
%42 = load double*, double** %11
store double %41, double* %42
store i32 1, i32* %6
br label %58
43: ; preds = %26
%44 = load i32, i32* %7
%45 = load i8**, i8*** %8
%46 = load i32*, i32** %9
%47 = load i32, i32* %46
%48 = call i32 @clParseError(i32 %44, i8** %45, i32 %47, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %49
49: ; preds = %43
store i32 0, i32* %6
br label %58
50: ; preds = %16
br label %57
51: ; preds = %5
%52 = load i32, i32* %7
%53 = load i8**, i8*** %8
%54 = load i32*, i32** %9
%55 = load i32, i32* %54
%56 = call i32 @clParseError(i32 %52, i8** %53, i32 %55, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %57
57: ; preds = %51, %50
store i32 0, i32* %6
br label %58
58: ; preds = %57, %49, %34
%59 = load i32, i32* %6
ret i32 %59
}

LLVM IR (-O2):
@.str = [28 x i8] c"Option expects one argument\00"
@.str.1 = [28 x i8] c"Error parsing command line.\00"
define i32 @readOptionDouble(i32 %0, i8** %1, i32* nocapture %2, i8* nocapture %3, double* nocapture writeonly %4) {
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, %0
br i1 %7, label %8, label %24
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 %26
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 %22
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 double @atof(i8* %20)
store double %21, double* %4
br label %26
22: ; preds = %14
%23 = tail call i32 @clParseError(i32 %0, i8** %1, i32 %15, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %26
24: ; preds = %5
%25 = 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 %26
26: ; preds = %24, %8, %22, %17
%27 = phi i32 [ 1, %17 ], [ 0, %22 ], [ 0, %8 ], [ 0, %24 ]
ret i32 %27
}