#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*/ strcmp(char *, char *);
void get_double_from_args(char *option, double *value, int argc, char **argv) {
  int i = 0;
  while (i < argc) {
    if (!strcmp(argv[i], option)) {
      *value = atof(argv[++i]);
    }
    i++;
  }
}


x86 assembly (clang, -O0):
<get_double_from_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1197 <get_double_from_args+0x77>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1189 <get_double_from_args+0x69>
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x24(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <atof@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113e <get_double_from_args+0x1e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_double_from_args>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    1170 <get_double_from_args+0x50>
mov    %rcx,%r13
mov    %edx,%r12d
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebp,%ebp
jmp    1148 <get_double_from_args+0x28>
nop
add    $0x1,%ebp
cmp    %r12d,%ebp
jge    1170 <get_double_from_args+0x50>
movslq %ebp,%rbx
mov    0x0(%r13,%rbx,8),%rdi
mov    %r15,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1140 <get_double_from_args+0x20>
lea    0x1(%rbx),%ebp
mov    0x8(%r13,%rbx,8),%rdi
call   1030 <atof@plt>
movsd  %xmm0,(%r14)
jmp    1140 <get_double_from_args+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @get_double_from_args(i8* %0, double* %1, i32 %2, i8** %3) {
%5 = alloca i8*
%6 = alloca double*
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i32
store i8* %0, i8** %5
store double* %1, double** %6
store i32 %2, i32* %7
store i8** %3, i8*** %8
store i32 0, i32* %9
br label %10
10: ; preds = %32, %4
%11 = load i32, i32* %9
%12 = load i32, i32* %7
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %35
14: ; preds = %10
%15 = load i8**, i8*** %8
%16 = load i32, i32* %9
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = load i8*, i8** %5
%21 = call i32 @strcmp(i8* %19, i8* %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %32, label %23
23: ; preds = %14
%24 = load i8**, i8*** %8
%25 = load i32, i32* %9
%26 = add nsw i32 %25, 1
store i32 %26, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %24, i64 %27
%29 = load i8*, i8** %28
%30 = call double @atof(i8* %29)
%31 = load double*, double** %6
store double %30, double* %31
br label %32
32: ; preds = %23, %14
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 1
store i32 %34, i32* %9
br label %10
35: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @get_double_from_args(i8* nocapture %0, double* nocapture writeonly %1, i32 %2, i8** nocapture %3) {
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %23
6: ; preds = %4, %19
%7 = phi i32 [ %21, %19 ], [ 0, %4 ]
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8*, i8** %3, i64 %8
%10 = load i8*, i8** %9
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %10, i8* dereferenceable(1) %0)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %6
%14 = add nsw i32 %7, 1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %3, i64 %15
%17 = load i8*, i8** %16
%18 = tail call double @atof(i8* %17)
store double %18, double* %1
br label %19
19: ; preds = %13, %6
%20 = phi i32 [ %7, %6 ], [ %14, %13 ]
%21 = add nsw i32 %20, 1
%22 = icmp slt i32 %21, %2
br i1 %22, label %6, label %23
23: ; preds = %19, %4
ret void
}