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


x86 assembly (clang, -O0):
<ldtoa_strtold>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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>
mov    %rax,-0x38(%rbp)
fildll -0x38(%rbp)
fstpt  -0x30(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     117e <ldtoa_strtold+0x6e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    117e <ldtoa_strtold+0x6e>
mov    0x2e79(%rip),%rax
cmpq   $0x0,(%rax)
setne  %al
and    $0x1,%al
movzbl %al,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1188 <ldtoa_strtold+0x78>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
fldt   -0x30(%rbp)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ldtoa_strtold>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    0x2ebf(%rip),%r14
movq   $0x0,(%r14)
lea    0x10(%rsp),%rsi
call   1030 <strtod@plt>
mov    0x10(%rsp),%rdx
mov    $0x1,%ecx
test   %rdx,%rdx
je     114f <ldtoa_strtold+0x3f>
cmpb   $0x0,(%rdx)
jne    114f <ldtoa_strtold+0x3f>
xor    %ecx,%ecx
cmpq   $0x0,(%r14)
setne  %cl
mov    %ecx,(%rbx)
mov    %rax,0x8(%rsp)
fildll 0x8(%rsp)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@errno = global i64 0
define x86_fp80 @ldtoa_strtold(i8* %0, i32* nocapture writeonly %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i64 0, i64* @errno
%5 = call i64 @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
%17 = sitofp i64 %5 to x86_fp80
ret x86_fp80 %17
}