#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 */
scalar_t__ errno;
int /*<<< orphan*/ prerror(char *, char const *);
double strtod(char const *, int /*<<< orphan*/ *);
int parse_double(const char *str, double *value, const char *param) {
  double v;
  errno = 0;
  v = strtod(str, NULL);
  if (errno)
    goto error;
  *value = v;
  return 0;
error:
  if (param) {
    prerror("%s value parsing error. Format: 0.00123\n", param);
  }
  return -1;
}


x86 assembly (clang, -O0):
<parse_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    0x2ea5(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <strtod@plt>
movsd  %xmm0,-0x28(%rbp)
mov    0x2e85(%rip),%rax
cmpq   $0x0,(%rax)
je     116a <parse_double+0x4a>
jmp    1183 <parse_double+0x63>
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11a5 <parse_double+0x85>
cmpq   $0x0,-0x20(%rbp)
je     119e <parse_double+0x7e>
mov    -0x20(%rbp),%rsi
lea    0xe67(%rip),%rdi
call   1040 <prerror@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_double>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    0x2eab(%rip),%r12
movq   $0x0,(%r12)
xor    %ebx,%ebx
xor    %esi,%esi
call   1030 <strtod@plt>
cmpq   $0x0,(%r12)
je     1168 <parse_double+0x48>
mov    $0xffffffff,%ebx
test   %r14,%r14
je     116d <parse_double+0x4d>
lea    0xea2(%rip),%rdi
mov    %r14,%rsi
call   1040 <prerror@plt>
jmp    116d <parse_double+0x4d>
movsd  %xmm0,(%r15)
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@errno = global i64 0
@.str = [41 x i8] c"%s value parsing error. Format: 0.00123\0A\00"
define i32 @parse_double(i8* %0, double* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca double*
%7 = alloca i8*
%8 = alloca double
store i8* %0, i8** %5
store double* %1, double** %6
store i8* %2, i8** %7
store i64 0, i64* @errno
%9 = load i8*, i8** %5
%10 = call double @strtod(i8* %9, i32* null)
store double %10, double* %8
%11 = load i64, i64* @errno
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %3
br label %17
14: ; preds = %3
%15 = load double, double* %8
%16 = load double*, double** %6
store double %15, double* %16
store i32 0, i32* %4
br label %24
17: ; preds = %13
%18 = load i8*, i8** %7
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i8*, i8** %7
%22 = call i32 @prerror(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %20, %17
store i32 -1, i32* %4
br label %24
24: ; preds = %23, %14
%25 = load i32, i32* %4
ret i32 %25
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [41 x i8] c"%s value parsing error. Format: 0.00123\0A\00"
define i32 @parse_double(i8* nocapture %0, double* nocapture writeonly %1, i8* %2) {
store i64 0, i64* @errno
%4 = tail call double @strtod(i8* nocapture %0, i32* null)
%5 = load i64, i64* @errno
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %3
store double %4, double* %1
br label %12
8: ; preds = %3
%9 = icmp eq i8* %2, null
br i1 %9, label %12, label %10
10: ; preds = %8
%11 = tail call i32 @prerror(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %12
12: ; preds = %8, %10, %7
%13 = phi i32 [ 0, %7 ], [ -1, %10 ], [ -1, %8 ]
ret i32 %13
}