#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__ strlen(char *);
int strToDub(double *s, char str[]) {
  *s = 0;
  int k = 0;
  if (str[0] == '-')
    k = 1;
  for (int i = k; i < (int)strlen(str); i++) {
    if (str[i] >= '0' && str[i] <= '9') {
      *s = (*s) * 10 + (str[i] - '0');
    } else
      return 0;
  }
  if (k)
    (*s) *= -1;
  return 1;
}


x86 assembly (clang, -O0):
<strToDub>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1149 <strToDub+0x39>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jge    11ed <strToDub+0xdd>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jl     11ce <strToDub+0xbe>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
jg     11ce <strToDub+0xbe>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe4f(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11da <strToDub+0xca>
movl   $0x0,-0x4(%rbp)
jmp    1212 <strToDub+0x102>
jmp    11df <strToDub+0xcf>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114f <strToDub+0x3f>
cmpl   $0x0,-0x1c(%rbp)
je     120b <strToDub+0xfb>
mov    -0x10(%rbp),%rax
movsd  0xdfd(%rip),%xmm0
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strToDub>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
movq   $0x0,(%rdi)
mov    (%rsi),%r15b
xor    %ebp,%ebp
cmp    $0x2d,%r15b
sete   %bpl
mov    %rsi,%rdi
call   1030 <strlen@plt>
xorpd  %xmm0,%xmm0
movapd %xmm0,(%rsp)
cmp    %eax,%ebp
jge    11a1 <strToDub+0x91>
xor    %ebp,%ebp
cmp    $0x2d,%r15b
sete   %bpl
xorpd  %xmm0,%xmm0
movapd %xmm0,(%rsp)
nopl   0x0(%rax)
movzbl (%rbx,%rbp,1),%eax
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
ja     11c0 <strToDub+0xb0>
add    $0xffffffd0,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd (%rsp),%xmm1
mulsd  0xe7d(%rip),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,(%rsp)
movsd  %xmm1,(%r14)
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %eax,%ebp
jl     1160 <strToDub+0x50>
mov    $0x1,%eax
cmp    $0x2d,%r15b
jne    11c2 <strToDub+0xb2>
movapd (%rsp),%xmm0
xorpd  0xe57(%rip),%xmm0
movlpd %xmm0,(%r14)
jmp    11c2 <strToDub+0xb2>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @strToDub(double* %0, i8* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store double* %0, double** %4
store i8* %1, i8** %5
%8 = load double*, double** %4
store double 0.000000e+00, double* %8
store i32 0, i32* %6
%9 = load i8*, i8** %5
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 45
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 1, i32* %6
br label %15
15: ; preds = %14, %2
%16 = load i32, i32* %6
store i32 %16, i32* %7
br label %17
17: ; preds = %54, %15
%18 = load i32, i32* %7
%19 = load i8*, i8** %5
%20 = call i64 @strlen(i8* %19)
%21 = trunc i64 %20 to i32
%22 = icmp slt i32 %18, %21
br i1 %22, label %23, label %57
23: ; preds = %17
%24 = load i8*, i8** %5
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp sge i32 %29, 48
br i1 %30, label %31, label %52
31: ; preds = %23
%32 = load i8*, i8** %5
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp sle i32 %37, 57
br i1 %38, label %39, label %52
39: ; preds = %31
%40 = load double*, double** %4
%41 = load double, double* %40
%42 = load i8*, i8** %5
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = sub nsw i32 %47, 48
%49 = sitofp i32 %48 to double
%50 = call double @llvm.fmuladd.f64(double %41, double 1.000000e+01, double %49)
%51 = load double*, double** %4
store double %50, double* %51
br label %53
52: ; preds = %31, %23
store i32 0, i32* %3
br label %65
53: ; preds = %39
br label %54
54: ; preds = %53
%55 = load i32, i32* %7
%56 = add nsw i32 %55, 1
store i32 %56, i32* %7
br label %17
57: ; preds = %17
%58 = load i32, i32* %6
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %64
60: ; preds = %57
%61 = load double*, double** %4
%62 = load double, double* %61
%63 = fmul double %62, -1.000000e+00
store double %63, double* %61
br label %64
64: ; preds = %60, %57
store i32 1, i32* %3
br label %65
65: ; preds = %64, %52
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
define i32 @strToDub(double* nocapture %0, i8* nocapture %1) {
store double 0.000000e+00, double* %0
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 45
%5 = zext i1 %4 to i32
%6 = tail call i64 @strlen(i8* %1)
%7 = trunc i64 %6 to i32
%8 = icmp slt i32 %5, %7
br i1 %8, label %9, label %28
9: ; preds = %2
%10 = zext i1 %4 to i64
br label %11
11: ; preds = %9, %18
%12 = phi double [ 0.000000e+00, %9 ], [ %22, %18 ]
%13 = phi i64 [ %10, %9 ], [ %23, %18 ]
%14 = getelementptr inbounds i8, i8* %1, i64 %13
%15 = load i8, i8* %14
%16 = add i8 %15, -48
%17 = icmp ult i8 %16, 10
br i1 %17, label %18, label %32
18: ; preds = %11
%19 = zext i8 %15 to i32
%20 = add nsw i32 %19, -48
%21 = sitofp i32 %20 to double
%22 = tail call double @llvm.fmuladd.f64(double %12, double 1.000000e+01, double %21)
store double %22, double* %0
%23 = add nuw nsw i64 %13, 1
%24 = tail call i64 @strlen(i8* %1)
%25 = trunc i64 %24 to i32
%26 = trunc i64 %23 to i32
%27 = icmp slt i32 %26, %25
br i1 %27, label %11, label %28
28: ; preds = %18, %2
%29 = phi double [ 0.000000e+00, %2 ], [ %22, %18 ]
br i1 %4, label %30, label %32
30: ; preds = %28
%31 = fneg double %29
store double %31, double* %0
br label %32
32: ; preds = %11, %28, %30
%33 = phi i32 [ 1, %30 ], [ 1, %28 ], [ 0, %11 ]
ret i32 %33
}