#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 */
char readChar();
float strtof(char *, char **);
float readFloat(void) {
  char buffer[10];
  unsigned int rx_length = 0, c;
  float data = 0.0;
  char cara = 0;
  char *pEnd;
  buffer[rx_length] = 0;
  while (cara != '$') {
    cara = readChar();
  }
  while (cara != '\n') {
    buffer[rx_length] = readChar();
    cara = buffer[rx_length];
    rx_length++;
  }
  data = strtof(buffer, &pEnd);
  return data;
}


x86 assembly (clang, -O0):
<readFloat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movb   $0x0,-0x19(%rbp)
mov    -0x10(%rbp),%eax
movb   $0x0,-0xa(%rbp,%rax,1)
movsbl -0x19(%rbp),%eax
cmp    $0x24,%eax
je     115f <readFloat+0x3f>
mov    $0x0,%al
call   1040 <readChar@plt>
mov    %al,-0x19(%rbp)
jmp    1143 <readFloat+0x23>
jmp    1164 <readFloat+0x44>
movsbl -0x19(%rbp),%eax
cmp    $0xa,%eax
je     1199 <readFloat+0x79>
mov    $0x0,%al
call   1040 <readChar@plt>
mov    %al,%cl
mov    -0x10(%rbp),%eax
mov    %cl,-0xa(%rbp,%rax,1)
mov    -0x10(%rbp),%eax
mov    -0xa(%rbp,%rax,1),%al
mov    %al,-0x19(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1164 <readFloat+0x44>
lea    -0xa(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <strtof@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readFloat>:
push   %rbx
sub    $0x20,%rsp
movb   $0x0,0xe(%rsp)
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <readChar@plt>
cmp    $0x24,%al
jne    1130 <readFloat+0x10>
xor    %ebx,%ebx
nopl   (%rax)
xor    %eax,%eax
call   1040 <readChar@plt>
mov    %ebx,%ecx
mov    %al,0xe(%rsp,%rcx,1)
add    $0x1,%ebx
cmp    $0xa,%al
jne    1140 <readFloat+0x20>
lea    0xe(%rsp),%rdi
lea    0x18(%rsp),%rsi
call   1030 <strtof@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define float @readFloat() {
%1 = alloca [10 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca i8
%6 = alloca i8*
store i32 0, i32* %2
store float 0.000000e+00, float* %4
store i8 0, i8* %5
%7 = load i32, i32* %2
%8 = zext i32 %7 to i64
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %8
store i8 0, i8* %9
br label %10
10: ; preds = %14, %0
%11 = load i8, i8* %5
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 36
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call signext i8 (...) @readChar()
store i8 %15, i8* %5
br label %10
16: ; preds = %10
br label %17
17: ; preds = %21, %16
%18 = load i8, i8* %5
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 10
br i1 %20, label %21, label %32
21: ; preds = %17
%22 = call signext i8 (...) @readChar()
%23 = load i32, i32* %2
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %24
store i8 %22, i8* %25
%26 = load i32, i32* %2
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %27
%29 = load i8, i8* %28
store i8 %29, i8* %5
%30 = load i32, i32* %2
%31 = add i32 %30, 1
store i32 %31, i32* %2
br label %17
32: ; preds = %17
%33 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%34 = call float @strtof(i8* %33, i8** %6)
store float %34, float* %4
%35 = load float, float* %4
ret float %35
}

LLVM IR (-O2):
define float @readFloat() {
%1 = alloca [10 x i8]
%2 = alloca i8*
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = bitcast i8** %2 to i8*
store i8 0, i8* %3
br label %5
5: ; preds = %0, %5
%6 = tail call signext i8 (...) @readChar()
%7 = icmp eq i8 %6, 36
br i1 %7, label %8, label %5
8: ; preds = %5, %8
%9 = phi i32 [ %13, %8 ], [ 0, %5 ]
%10 = tail call signext i8 (...) @readChar()
%11 = zext i32 %9 to i64
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %11
store i8 %10, i8* %12
%13 = add i32 %9, 1
%14 = icmp eq i8 %10, 10
br i1 %14, label %15, label %8
15: ; preds = %8
%16 = call float @strtof(i8* %3, i8** %2)
ret float %16
}