#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 *);
scalar_t__ strcmp(char *, char *);
double readParamDouble(int argc, char *argv[], char *strID, double defaultVal) {
  double returnVal = defaultVal;
  short n;
  for (n = 0; n < argc; n++) {
    if (strcmp(argv[n], strID) == 0) {
      n++;
      if (n < argc) {
        returnVal = atof(argv[n]);
      }
      break;
    }
  }
  return returnVal;
}


x86 assembly (clang, -O0):
<readParamDouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movw   $0x0,-0x2a(%rbp)
movswl -0x2a(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11c0 <readParamDouble+0xa0>
mov    -0x10(%rbp),%rax
movswq -0x2a(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11aa <readParamDouble+0x8a>
mov    -0x2a(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x2a(%rbp)
movswl -0x2a(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a5 <readParamDouble+0x85>
mov    -0x10(%rbp),%rax
movswq -0x2a(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x28(%rbp)
jmp    11c0 <readParamDouble+0xa0>
jmp    11af <readParamDouble+0x8f>
mov    -0x2a(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x2a(%rbp)
jmp    1148 <readParamDouble+0x28>
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readParamDouble>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movsd  %xmm0,(%rsp)
test   %edi,%edi
jle    117e <readParamDouble+0x5e>
mov    %rdx,%r15
mov    %rsi,%r14
mov    %edi,%ebp
mov    $0x1,%bx
nopl   0x0(%rax)
lea    -0x1(%rbx),%eax
movswq %ax,%rax
mov    (%r14,%rax,8),%rdi
mov    %r15,%rsi
call   1040 <strcmp@plt>
movswl %bx,%ecx
test   %rax,%rax
je     1164 <readParamDouble+0x44>
lea    0x1(%rcx),%ebx
cmp    %ebp,%ecx
jl     1140 <readParamDouble+0x20>
jmp    117e <readParamDouble+0x5e>
cmp    %ebp,%ecx
jge    117e <readParamDouble+0x5e>
movslq %ecx,%rax
mov    (%r14,%rax,8),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <atof@plt>
movsd  (%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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