#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*/ assert(double *);
double strtod(char const *, char **);
char *lace_parse_double(double *ret, const char *in) {
  double v;
  char *out = NULL;
  assert(ret);
  if (!in) {
    return NULL;
  }
  v = strtod(in, &out);
  if (out == in)
    out = NULL;
  if (out)
    *ret = (double)v;
  return out;
}


x86 assembly (clang, -O0):
<lace_parse_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <assert@plt>
cmpq   $0x0,-0x18(%rbp)
jne    1159 <lace_parse_double+0x39>
movq   $0x0,-0x8(%rbp)
jmp    11a1 <lace_parse_double+0x81>
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    1181 <lace_parse_double+0x61>
movq   $0x0,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1199 <lace_parse_double+0x79>
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lace_parse_double>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
movq   $0x0,(%rsp)
call   1040 <assert@plt>
test   %rbx,%rbx
je     1163 <lace_parse_double+0x43>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <strtod@plt>
mov    (%rsp),%rcx
xor    %eax,%eax
cmp    %rbx,%rcx
cmove  %rax,%rcx
test   %rcx,%rcx
je     1165 <lace_parse_double+0x45>
movsd  %xmm0,(%r14)
mov    %rcx,%rax
jmp    1165 <lace_parse_double+0x45>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @lace_parse_double(double* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca double*
%5 = alloca i8*
%6 = alloca double
%7 = alloca i8*
store double* %0, double** %4
store i8* %1, i8** %5
store i8* null, i8** %7
%8 = load double*, double** %4
%9 = call i32 @assert(double* %8)
%10 = load i8*, i8** %5
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %2
store i8* null, i8** %3
br label %28
13: ; preds = %2
%14 = load i8*, i8** %5
%15 = call double @strtod(i8* %14, i8** %7)
store double %15, double* %6
%16 = load i8*, i8** %7
%17 = load i8*, i8** %5
%18 = icmp eq i8* %16, %17
br i1 %18, label %19, label %20
19: ; preds = %13
store i8* null, i8** %7
br label %20
20: ; preds = %19, %13
%21 = load i8*, i8** %7
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load double, double* %6
%25 = load double*, double** %4
store double %24, double* %25
br label %26
26: ; preds = %23, %20
%27 = load i8*, i8** %7
store i8* %27, i8** %3
br label %28
28: ; preds = %26, %12
%29 = load i8*, i8** %3
ret i8* %29
}

LLVM IR (-O2):
define i8* @lace_parse_double(double* %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%5 = tail call i32 @assert(double* %0)
%6 = icmp eq i8* %1, null
br i1 %6, label %14, label %7
7: ; preds = %2
%8 = call double @strtod(i8* %1, i8** %3)
%9 = load i8*, i8** %3
%10 = icmp eq i8* %9, %1
%11 = select i1 %10, i8* null, i8* %9
%12 = icmp eq i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %7
store double %8, double* %0
br label %14
14: ; preds = %7, %13, %2
%15 = phi i8* [ null, %2 ], [ %11, %13 ], [ null, %7 ]
ret i8* %15
}