#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__ atof(char *);
int /*<<< orphan*/ memcpy(char *, char *, unsigned int);
void parseFloatFromLine(float *inOutFloat, char *stringToParse,
                        unsigned int length) {
  unsigned int startIndex = 0;
  unsigned int endIndex = 0;
  while (endIndex < length && stringToParse[endIndex] != ' ' &&
         stringToParse[endIndex] != '\n' && stringToParse[endIndex] != '\0') {
    ++endIndex;
    continue;
  }
  {
    static char valueBuffer[64];
    unsigned int valueLength = endIndex - startIndex - 1;
    memcpy(valueBuffer, &stringToParse[startIndex], valueLength);
    valueBuffer[valueLength] = '\0';
    *inOutFloat = (float)atof(valueBuffer);
  }
}


x86 assembly (clang, -O0):
<parseFloatFromLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
xor    %eax,%eax
cmp    -0x14(%rbp),%ecx
mov    %al,-0x21(%rbp)
jae    1198 <parseFloatFromLine+0x78>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x21(%rbp)
je     1198 <parseFloatFromLine+0x78>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x21(%rbp)
je     1198 <parseFloatFromLine+0x78>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11a8 <parseFloatFromLine+0x88>
jmp    11b6 <parseFloatFromLine+0x96>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1141 <parseFloatFromLine+0x21>
mov    -0x1c(%rbp),%eax
sub    -0x18(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%eax
add    %rax,%rsi
mov    -0x20(%rbp),%edx
lea    0x2e6a(%rip),%rdi
call   1040 <memcpy@plt>
mov    -0x20(%rbp),%eax
mov    %eax,%ecx
lea    0x2e59(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e4e(%rip),%rdi
call   1030 <atof@plt>
cvtsi2ss %rax,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseFloatFromLine>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
test   %edx,%edx
je     115b <parseFloatFromLine+0x3b>
mov    %edx,%eax
xor    %ebx,%ebx
movabs $0x100000401,%rcx
jmp    1149 <parseFloatFromLine+0x29>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %rbx,%rax
je     115f <parseFloatFromLine+0x3f>
movzbl (%rsi,%rbx,1),%edx
cmp    $0x20,%rdx
ja     1140 <parseFloatFromLine+0x20>
bt     %rdx,%rcx
jae    1140 <parseFloatFromLine+0x20>
jmp    1161 <parseFloatFromLine+0x41>
xor    %ebx,%ebx
jmp    1161 <parseFloatFromLine+0x41>
mov    %eax,%ebx
add    $0xffffffff,%ebx
lea    0x2ed5(%rip),%r15
mov    %r15,%rdi
mov    %ebx,%edx
call   1040 <memcpy@plt>
movb   $0x0,(%rbx,%r15,1)
mov    %r15,%rdi
call   1030 <atof@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@parseFloatFromLine.valueBuffer = internal global [64 x i8] zeroinitializer
define void @parseFloatFromLine(float* nocapture writeonly %0, i8* %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %16, label %5
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %11
%8 = phi i64 [ 0, %5 ], [ %12, %11 ]
%9 = getelementptr inbounds i8, i8* %1, i64 %8
%10 = load i8, i8* %9
switch i8 %10, label %11 [
i8 32, label %14
i8 10, label %14
i8 0, label %14
]
11: ; preds = %7
%12 = add nuw nsw i64 %8, 1
%13 = icmp eq i64 %12, %6
br i1 %13, label %16, label %7
14: ; preds = %7, %7, %7
%15 = trunc i64 %8 to i32
br label %16
16: ; preds = %11, %14, %3
%17 = phi i32 [ 0, %3 ], [ %15, %14 ], [ %2, %11 ]
%18 = add i32 %17, -1
%19 = tail call i32 @memcpy(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @parseFloatFromLine.valueBuffer, i64 0, i64 0), i8* %1, i32 %18)
%20 = zext i32 %18 to i64
%21 = getelementptr inbounds [64 x i8], [64 x i8]* @parseFloatFromLine.valueBuffer, i64 0, i64 %20
store i8 0, i8* %21
%22 = tail call i64 @atof(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @parseFloatFromLine.valueBuffer, i64 0, i64 0))
%23 = sitofp i64 %22 to float
store float %23, float* %0
ret void
}