#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;
double strtod(char const *, char **);
double dtoa_strtod(const char *s, int *error) {
  char *endp;
  double d;
  errno = 0;
  d = strtod(s, &endp);
  if (endp != NULL && (*endp == '\0'))
    *error = (errno != 0);
  else
    *error = (1 == 1);
  return d;
}


x86 assembly (clang, -O0):
<dtoa_strtod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2eb9(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1179 <dtoa_strtod+0x69>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1179 <dtoa_strtod+0x69>
mov    0x2e7e(%rip),%rax
cmpq   $0x0,(%rax)
setne  %al
and    $0x1,%al
movzbl %al,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1183 <dtoa_strtod+0x73>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
movsd  -0x20(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dtoa_strtod>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    0x2ec2(%rip),%r14
movq   $0x0,(%r14)
mov    %rsp,%rsi
call   1030 <strtod@plt>
mov    (%rsp),%rcx
mov    $0x1,%eax
test   %rcx,%rcx
je     1149 <dtoa_strtod+0x39>
cmpb   $0x0,(%rcx)
jne    1149 <dtoa_strtod+0x39>
xor    %eax,%eax
cmpq   $0x0,(%r14)
setne  %al
mov    %eax,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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