#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
double atof(char *);
scalar_t__ isdigit(char);
int /*<<< orphan*/ safef(char *, int, char *, char *);
double evalToDouble(char *s) {
  if (isdigit(s[0]))
    return atof(s);
  else {
    char buf[64];
    safef(buf, sizeof(buf), "1.0%s", s);
    return atof(buf);
  }
}


x86 assembly (clang, -O0):
<evalToDouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1165 <evalToDouble+0x35>
mov    -0x10(%rbp),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    118c <evalToDouble+0x5c>
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x40,%esi
lea    0xe87(%rip),%rdx
call   1050 <safef@plt>
lea    -0x50(%rbp),%rdi
call   1040 <atof@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<evalToDouble>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1156 <evalToDouble+0x26>
mov    %rbx,%rdi
add    $0x48,%rsp
pop    %rbx
pop    %r14
jmp    1040 <atof@plt>
lea    0xea3(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x40,%esi
mov    %rbx,%rcx
call   1050 <safef@plt>
mov    %r14,%rdi
call   1040 <atof@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [6 x i8] c"1.0%s\00"
define double @evalToDouble(i8* %0) {
%2 = alloca double
%3 = alloca i8*
%4 = alloca [64 x i8]
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = call i64 @isdigit(i8 signext %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call double @atof(i8* %11)
store double %12, double* %2
br label %19
13: ; preds = %1
%14 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%15 = load i8*, i8** %3
%16 = call i32 @safef(i8* %14, i32 64, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%18 = call double @atof(i8* %17)
store double %18, double* %2
br label %19
19: ; preds = %13, %10
%20 = load double, double* %2
ret double %20
}

LLVM IR (-O2):
@.str = [6 x i8] c"1.0%s\00"
define double @evalToDouble(i8* %0) {
%2 = alloca [64 x i8]
%3 = load i8, i8* %0
%4 = tail call i64 @isdigit(i8 signext %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = tail call double @atof(i8* %0)
br label %12
8: ; preds = %1
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%10 = call i32 @safef(i8* %9, i32 64, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0)
%11 = call double @atof(i8* %9)
br label %12
12: ; preds = %8, %6
%13 = phi double [ %7, %6 ], [ %11, %8 ]
ret double %13
}