#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 */
double atof(char *);
scalar_t__ isdigit(char);
char tolower(char);
double fetch_float(char *str, char **new_str_ptr) {
  static char number[1024];
  int i;
  char *n;
  while (!isdigit(*str) && *str != '-')
    str++;
  for (n = number; isdigit(*str) || *str == '.' || tolower(*str) == 'e' ||
                   *str == '-' || *str == '+';
       str++, n++) {
    *n = *str;
  }
  *n = '\0';
  *new_str_ptr = str;
  return atof(number);
}


x86 assembly (clang, -O0):
<fetch_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x21(%rbp)
jne    116e <fetch_float+0x3e>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    117e <fetch_float+0x4e>
jmp    118f <fetch_float+0x5f>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1140 <fetch_float+0x10>
lea    0x2eba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x22(%rbp)
jne    120f <fetch_float+0xdf>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x2e,%ecx
mov    %al,-0x22(%rbp)
je     120f <fetch_float+0xdf>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1050 <tolower@plt>
movsbl %al,%ecx
mov    $0x1,%al
cmp    $0x65,%ecx
mov    %al,-0x22(%rbp)
je     120f <fetch_float+0xdf>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x2d,%ecx
mov    %al,-0x22(%rbp)
je     120f <fetch_float+0xdf>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
sete   %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
test   $0x1,%al
jne    121f <fetch_float+0xef>
jmp    1248 <fetch_float+0x118>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    119a <fetch_float+0x6a>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
lea    0x2def(%rip),%rdi
call   1040 <atof@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fetch_float>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
movsbl (%rdi),%edi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
call   1030 <isdigit@plt>
test   %rax,%rax
jne    116d <fetch_float+0x3d>
cmpb   $0x2d,(%r12)
je     116d <fetch_float+0x3d>
movsbl 0x1(%r12),%edi
add    $0x1,%r12
jmp    1150 <fetch_float+0x20>
xor    %ebx,%ebx
lea    0x2eda(%rip),%r15
jmp    118d <fetch_float+0x5d>
nopl   0x0(%rax,%rax,1)
movzbl (%r12,%rbx,1),%eax
mov    %al,(%rbx,%r15,1)
add    $0x1,%rbx
movsbl (%r12,%rbx,1),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1180 <fetch_float+0x50>
movzbl (%r12,%rbx,1),%eax
cmp    $0x2e,%al
je     1180 <fetch_float+0x50>
movsbl %al,%edi
call   1050 <tolower@plt>
cmp    $0x65,%al
je     1180 <fetch_float+0x50>
movzbl (%r12,%rbx,1),%eax
cmp    $0x2d,%al
je     1180 <fetch_float+0x50>
cmp    $0x2b,%al
je     1180 <fetch_float+0x50>
movb   $0x0,(%rbx,%r15,1)
add    %rbx,%r12
mov    %r12,(%r14)
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <atof@plt>

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

LLVM IR (-O2):
@fetch_float.number = internal global [1024 x i8] zeroinitializer
define double @fetch_float(i8* %0, i8** nocapture writeonly %1) {
%3 = load i8, i8* %0
%4 = tail call i64 @isdigit(i8 signext %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %2, %10
%7 = phi i8* [ %11, %10 ], [ %0, %2 ]
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 45
br i1 %9, label %15, label %10
10: ; preds = %6
%11 = getelementptr inbounds i8, i8* %7, i64 1
%12 = load i8, i8* %11
%13 = tail call i64 @isdigit(i8 signext %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %6, label %15
15: ; preds = %6, %10, %2
%16 = phi i8* [ %0, %2 ], [ %7, %6 ], [ %11, %10 ]
br label %17
17: ; preds = %15, %31
%18 = phi i8* [ %33, %31 ], [ %16, %15 ]
%19 = phi i8* [ %34, %31 ], [ getelementptr inbounds ([1024 x i8], [1024 x i8]* @fetch_float.number, i64 0, i64 0), %15 ]
%20 = load i8, i8* %18
%21 = tail call i64 @isdigit(i8 signext %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %31
23: ; preds = %17
%24 = load i8, i8* %18
%25 = icmp eq i8 %24, 46
br i1 %25, label %31, label %26
26: ; preds = %23
%27 = tail call signext i8 @tolower(i8 signext %24)
%28 = icmp eq i8 %27, 101
br i1 %28, label %31, label %29
29: ; preds = %26
%30 = load i8, i8* %18
switch i8 %30, label %35 [
i8 45, label %31
i8 43, label %31
]
31: ; preds = %29, %29, %17, %23, %26
%32 = load i8, i8* %18
store i8 %32, i8* %19
%33 = getelementptr inbounds i8, i8* %18, i64 1
%34 = getelementptr inbounds i8, i8* %19, i64 1
br label %17
35: ; preds = %29
store i8 0, i8* %19
store i8* %18, i8** %1
%36 = tail call double @atof(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @fetch_float.number, i64 0, i64 0))
ret double %36
}