#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__ isdigit(char);
double strtod(char const *, char **);
int str0_double(const char *str, double *val) {
  char ch;
  if (str == 0)
    return 0;
  ch = str[0];
  if (!(isdigit(ch) || ch == '-' || ch == '.' || ch == '+'))
    ch = 0;
  if (ch == '-') {
    ch = str[1];
    if (!(isdigit(ch) || ch == '.'))
      ch = 0;
  }
  if (ch) {
    char *end;
    *val = strtod(str, &end);
    return (*end == '\0');
  } else
    return 0;
}


x86 assembly (clang, -O0):
<str0_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1147 <str0_double+0x27>
movl   $0x0,-0x4(%rbp)
jmp    120e <str0_double+0xee>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    118e <str0_double+0x6e>
movsbl -0x19(%rbp),%eax
cmp    $0x2d,%eax
je     118e <str0_double+0x6e>
movsbl -0x19(%rbp),%eax
cmp    $0x2e,%eax
je     118e <str0_double+0x6e>
movsbl -0x19(%rbp),%eax
cmp    $0x2b,%eax
je     118e <str0_double+0x6e>
movb   $0x0,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x2d,%eax
jne    11ce <str0_double+0xae>
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%al
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    11c9 <str0_double+0xa9>
movsbl -0x19(%rbp),%eax
cmp    $0x2e,%eax
je     11c9 <str0_double+0xa9>
movb   $0x0,-0x19(%rbp)
jmp    11ce <str0_double+0xae>
cmpb   $0x0,-0x19(%rbp)
je     1207 <str0_double+0xe7>
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <strtod@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    120e <str0_double+0xee>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str0_double>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
je     11a2 <str0_double+0x82>
mov    %rsi,%r14
mov    %rdi,%r12
movsbl (%rdi),%ebx
mov    %ebx,%edi
call   1030 <isdigit@plt>
xor    %r15d,%r15d
test   %rax,%rax
mov    $0x0,%ebp
cmovne %ebx,%ebp
lea    -0x2d(%rbx),%eax
cmp    $0x2,%al
cmovb  %ebx,%ebp
cmp    $0x2b,%ebx
cmove  %ebx,%ebp
cmp    $0x2d,%bpl
jne    117a <str0_double+0x5a>
movsbl 0x1(%r12),%ebp
mov    %ebp,%edi
call   1030 <isdigit@plt>
cmp    $0x2e,%ebp
je     117a <str0_double+0x5a>
test   %rax,%rax
je     11a5 <str0_double+0x85>
test   %bpl,%bpl
je     11a5 <str0_double+0x85>
lea    0x8(%rsp),%rsi
mov    %r12,%rdi
call   1040 <strtod@plt>
movsd  %xmm0,(%r14)
mov    0x8(%rsp),%rax
xor    %r15d,%r15d
cmpb   $0x0,(%rax)
sete   %r15b
jmp    11a5 <str0_double+0x85>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @str0_double(i8* %0, double* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca double*
%6 = alloca i8
%7 = alloca i8*
store i8* %0, i8** %4
store double* %1, double** %5
%8 = load i8*, i8** %4
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 0, i32* %3
br label %61
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
store i8 %14, i8* %6
%15 = load i8, i8* %6
%16 = call i64 @isdigit(i8 signext %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %31, label %18
18: ; preds = %11
%19 = load i8, i8* %6
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 45
br i1 %21, label %31, label %22
22: ; preds = %18
%23 = load i8, i8* %6
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 46
br i1 %25, label %31, label %26
26: ; preds = %22
%27 = load i8, i8* %6
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 43
br i1 %29, label %31, label %30
30: ; preds = %26
store i8 0, i8* %6
br label %31
31: ; preds = %30, %26, %22, %18, %11
%32 = load i8, i8* %6
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 45
br i1 %34, label %35, label %48
35: ; preds = %31
%36 = load i8*, i8** %4
%37 = getelementptr inbounds i8, i8* %36, i64 1
%38 = load i8, i8* %37
store i8 %38, i8* %6
%39 = load i8, i8* %6
%40 = call i64 @isdigit(i8 signext %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %47, label %42
42: ; preds = %35
%43 = load i8, i8* %6
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 46
br i1 %45, label %47, label %46
46: ; preds = %42
store i8 0, i8* %6
br label %47
47: ; preds = %46, %42, %35
br label %48
48: ; preds = %47, %31
%49 = load i8, i8* %6
%50 = icmp ne i8 %49, 0
br i1 %50, label %51, label %60
51: ; preds = %48
%52 = load i8*, i8** %4
%53 = call double @strtod(i8* %52, i8** %7)
%54 = load double*, double** %5
store double %53, double* %54
%55 = load i8*, i8** %7
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 0
%59 = zext i1 %58 to i32
store i32 %59, i32* %3
br label %61
60: ; preds = %48
store i32 0, i32* %3
br label %61
61: ; preds = %60, %51, %10
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
define i32 @str0_double(i8* %0, double* nocapture writeonly %1) {
%3 = alloca i8*
%4 = icmp eq i8* %0, null
br i1 %4, label %33, label %5
5: ; preds = %2
%6 = load i8, i8* %0
%7 = tail call i64 @isdigit(i8 signext %6)
%8 = icmp ne i64 %7, 0
%9 = add i8 %6, -45
%10 = icmp ult i8 %9, 2
%11 = or i1 %10, %8
%12 = icmp eq i8 %6, 43
%13 = or i1 %12, %11
%14 = select i1 %13, i8 %6, i8 0
%15 = icmp eq i8 %14, 45
br i1 %15, label %16, label %23
16: ; preds = %5
%17 = getelementptr inbounds i8, i8* %0, i64 1
%18 = load i8, i8* %17
%19 = tail call i64 @isdigit(i8 signext %18)
%20 = icmp ne i64 %19, 0
%21 = icmp eq i8 %18, 46
%22 = or i1 %21, %20
br i1 %22, label %23, label %33
23: ; preds = %16, %5
%24 = phi i8 [ %14, %5 ], [ %18, %16 ]
%25 = icmp eq i8 %24, 0
br i1 %25, label %33, label %26
26: ; preds = %23
%27 = bitcast i8** %3 to i8*
%28 = call double @strtod(i8* %0, i8** %3)
store double %28, double* %1
%29 = load i8*, i8** %3
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 0
%32 = zext i1 %31 to i32
br label %33
33: ; preds = %16, %23, %2, %26
%34 = phi i32 [ %32, %26 ], [ 0, %2 ], [ 0, %23 ], [ 0, %16 ]
ret i32 %34
}