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


x86 assembly (clang, -O0):
<is_real>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2eb1(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <strtod@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    0x2e8e(%rip),%rax
cmpq   $0x0,(%rax)
jne    116a <is_real+0x5a>
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    1176 <is_real+0x66>
movl   $0x0,-0x4(%rbp)
jmp    119e <is_real+0x8e>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1192 <is_real+0x82>
movl   $0x0,-0x4(%rbp)
jmp    119e <is_real+0x8e>
jmp    1197 <is_real+0x87>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_real>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
mov    0x2eb1(%rip),%r15
movq   $0x0,(%r15)
lea    0x8(%rsp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,(%r14)
xor    %eax,%eax
cmpq   $0x0,(%r15)
jne    115f <is_real+0x4f>
mov    0x8(%rsp),%rcx
cmp    %rbx,%rcx
je     115f <is_real+0x4f>
xor    %eax,%eax
cmpb   $0x0,(%rcx)
sete   %al
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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