#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*/ cdoAbort(char *, char const *, int);
double strtod(char const *, char **);
double parameter2double(const char *string) {
  char *endptr = NULL;
  double fval = strtod(string, &endptr);
  if (*endptr != 0)
    cdoAbort("Float parameter >%s< contains invalid character at position %d!",
             string, (int)(endptr - string + 1));
  return (fval);
}


x86 assembly (clang, -O0):
<parameter2double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1177 <parameter2double+0x57>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,%edx
lea    0xe8e(%rip),%rdi
call   1040 <cdoAbort@plt>
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parameter2double>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movq   $0x0,(%rsp)
mov    %rsp,%rsi
call   1030 <strtod@plt>
mov    (%rsp),%rdx
cmpb   $0x0,(%rdx)
je     1161 <parameter2double+0x41>
sub    %ebx,%edx
add    $0x1,%edx
lea    0xeb3(%rip),%rdi
mov    %rbx,%rsi
movsd  %xmm0,0x8(%rsp)
call   1040 <cdoAbort@plt>
movsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [64 x i8] c"Float parameter >%s< contains invalid character at position %d!\00"
define double @parameter2double(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca double
store i8* %0, i8** %2
store i8* null, i8** %3
%5 = load i8*, i8** %2
%6 = call double @strtod(i8* %5, i8** %3)
store double %6, double* %4
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %1
%12 = load i8*, i8** %2
%13 = load i8*, i8** %3
%14 = load i8*, i8** %2
%15 = ptrtoint i8* %13 to i64
%16 = ptrtoint i8* %14 to i64
%17 = sub i64 %15, %16
%18 = add nsw i64 %17, 1
%19 = trunc i64 %18 to i32
%20 = call i32 @cdoAbort(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i8* %12, i32 %19)
br label %21
21: ; preds = %11, %1
%22 = load double, double* %4
ret double %22
}

LLVM IR (-O2):
@.str = [64 x i8] c"Float parameter >%s< contains invalid character at position %d!\00"
define double @parameter2double(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%4 = call double @strtod(i8* %0, i8** %2)
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %1
%9 = ptrtoint i8* %5 to i64
%10 = ptrtoint i8* %0 to i64
%11 = sub i64 %9, %10
%12 = trunc i64 %11 to i32
%13 = add i32 %12, 1
%14 = tail call i32 @cdoAbort(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %13)
br label %15
15: ; preds = %8, %1
ret double %4
}