#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 */
int /*<<< orphan*/ isdigit(char);
int readDouble(char *to, char *from) {
  int i = 0, k = 0;
  if (from[0] == '-') {
    i++;
    k++;
    to[0] = from[0];
  }
  for (; i < 30; i++) {
    if (from[i] != '.' && !isdigit(from[i]))
      break;
    to[k] = from[i];
    k++;
  }
  to[k] = '\0';
  return k;
}


x86 assembly (clang, -O0):
<readDouble>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    115c <readDouble+0x4c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
jmp    1161 <readDouble+0x51>
cmpl   $0x1e,-0x14(%rbp)
jge    11cc <readDouble+0xbc>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
je     119f <readDouble+0x8f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    119f <readDouble+0x8f>
jmp    11cc <readDouble+0xbc>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1161 <readDouble+0x51>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readDouble>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
cmpb   $0x2d,(%rsi)
jne    112b <readDouble+0x1b>
movb   $0x2d,(%r14)
mov    $0x1,%ebx
jmp    1143 <readDouble+0x33>
xor    %ebx,%ebx
jmp    1143 <readDouble+0x33>
nop
movzbl (%r15,%rbx,1),%eax
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    $0x1e,%rbx
je     115d <readDouble+0x4d>
movzbl (%r15,%rbx,1),%ecx
mov    $0x2e,%al
cmp    $0x2e,%cl
je     1135 <readDouble+0x25>
movsbl %cl,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
jne    1130 <readDouble+0x20>
jmp    1162 <readDouble+0x52>
mov    $0x1e,%ebx
mov    %ebx,%eax
movb   $0x0,(%r14,%rax,1)
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @readDouble(i8* nocapture writeonly %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 45
br i1 %4, label %5, label %6
5: ; preds = %2
store i8 45, i8* %0
br label %6
6: ; preds = %5, %2
%7 = phi i64 [ 0, %2 ], [ 1, %5 ]
br label %8
8: ; preds = %6, %18
%9 = phi i64 [ %21, %18 ], [ %7, %6 ]
%10 = getelementptr inbounds i8, i8* %1, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 46
br i1 %12, label %18, label %13
13: ; preds = %8
%14 = tail call i32 @isdigit(i8 signext %11)
%15 = icmp eq i32 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %13
%17 = load i8, i8* %10
br label %18
18: ; preds = %16, %8
%19 = phi i8 [ %17, %16 ], [ 46, %8 ]
%20 = getelementptr inbounds i8, i8* %0, i64 %9
store i8 %19, i8* %20
%21 = add nuw nsw i64 %9, 1
%22 = icmp eq i64 %21, 30
br i1 %22, label %25, label %8
23: ; preds = %13
%24 = trunc i64 %9 to i32
br label %25
25: ; preds = %18, %23
%26 = phi i32 [ %24, %23 ], [ 30, %18 ]
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %0, i64 %27
store i8 0, i8* %28
ret i32 %26
}