#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__ isinf(double);
scalar_t__ isnan(double);
double strtod(char *, char **);
int strToDouble(double *cislo, char *str) {
  char *endptr;
  errno = 0;
  *cislo = strtod(str, &endptr);
  if (isnan(*cislo) || isinf(*cislo) || endptr == str || *endptr != '\0' ||
      errno)
    return 0;
  else
    return 1;
}


x86 assembly (clang, -O0):
<strToDouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2e99(%rip),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <strtod@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
jne    11c0 <strToDouble+0x90>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
jne    11c0 <strToDouble+0x90>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
je     11c0 <strToDouble+0x90>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11c0 <strToDouble+0x90>
mov    0x2e2a(%rip),%rax
cmpq   $0x0,(%rax)
je     11cc <strToDouble+0x9c>
movl   $0x0,-0x4(%rbp)
jmp    11d3 <strToDouble+0xa3>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strToDouble>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2e9c(%rip),%r15
movq   $0x0,(%r15)
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <strtod@plt>
movsd  %xmm0,(%rbx)
call   1040 <isnan@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    118f <strToDouble+0x5f>
movsd  (%rbx),%xmm0
call   1050 <isinf@plt>
test   %rax,%rax
jne    118f <strToDouble+0x5f>
mov    (%rsp),%rax
cmp    %r14,%rax
je     118f <strToDouble+0x5f>
cmpb   $0x0,(%rax)
sete   %al
cmpq   $0x0,(%r15)
sete   %cl
and    %al,%cl
movzbl %cl,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@errno = global i64 0
define i32 @strToDouble(double* nocapture %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i64 0, i64* @errno
%5 = call double @strtod(i8* %1, i8** %3)
store double %5, double* %0
%6 = tail call i64 @isnan(double %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %22
8: ; preds = %2
%9 = load double, double* %0
%10 = tail call i64 @isinf(double %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = icmp eq i8* %13, %1
br i1 %14, label %22, label %15
15: ; preds = %12
%16 = load i8, i8* %13
%17 = icmp eq i8 %16, 0
%18 = load i64, i64* @errno
%19 = icmp eq i64 %18, 0
%20 = select i1 %17, i1 %19, i1 false
%21 = zext i1 %20 to i32
br label %22
22: ; preds = %15, %2, %8, %12
%23 = phi i32 [ 0, %12 ], [ 0, %8 ], [ 0, %2 ], [ %21, %15 ]
ret i32 %23
}