#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__ ERANGE;
scalar_t__ errno;
float strtof(char *, char **);
int read_float(char *s, float *f, char **endp) {
  errno = 0;
  float t = strtof(s, endp);
  if (errno == ERANGE)
    return -1;
  if (*endp == s)
    return -2;
  *f = t;
  return 0;
}


x86 assembly (clang, -O0):
<read_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    0x2ead(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strtof@plt>
movss  %xmm0,-0x24(%rbp)
mov    0x2e8d(%rip),%rax
mov    (%rax),%rax
mov    0x2e93(%rip),%rcx
cmp    (%rcx),%rax
jne    116a <read_float+0x5a>
movl   $0xffffffff,-0x4(%rbp)
jmp    119b <read_float+0x8b>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
cmp    -0x10(%rbp),%rax
jne    1187 <read_float+0x77>
movl   $0xfffffffe,-0x4(%rbp)
jmp    119b <read_float+0x8b>
movss  -0x24(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_float>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2eb0(%rip),%r12
movq   $0x0,(%r12)
mov    %rdx,%rsi
call   1030 <strtof@plt>
mov    (%r12),%rcx
mov    0x2ea5(%rip),%rdx
mov    $0xffffffff,%eax
cmp    (%rdx),%rcx
je     1160 <read_float+0x50>
cmp    %rbx,(%r15)
je     115b <read_float+0x4b>
movss  %xmm0,(%r14)
xor    %eax,%eax
jmp    1160 <read_float+0x50>
mov    $0xfffffffe,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@errno = global i64 0
@ERANGE = global i64 0
define i32 @read_float(i8* %0, float* %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca float*
%7 = alloca i8**
%8 = alloca float
store i8* %0, i8** %5
store float* %1, float** %6
store i8** %2, i8*** %7
store i64 0, i64* @errno
%9 = load i8*, i8** %5
%10 = load i8**, i8*** %7
%11 = call float @strtof(i8* %9, i8** %10)
store float %11, float* %8
%12 = load i64, i64* @errno
%13 = load i64, i64* @ERANGE
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %16
15: ; preds = %3
store i32 -1, i32* %4
br label %25
16: ; preds = %3
%17 = load i8**, i8*** %7
%18 = load i8*, i8** %17
%19 = load i8*, i8** %5
%20 = icmp eq i8* %18, %19
br i1 %20, label %21, label %22
21: ; preds = %16
store i32 -2, i32* %4
br label %25
22: ; preds = %16
%23 = load float, float* %8
%24 = load float*, float** %6
store float %23, float* %24
store i32 0, i32* %4
br label %25
25: ; preds = %22, %21, %15
%26 = load i32, i32* %4
ret i32 %26
}

LLVM IR (-O2):
@errno = global i64 0
@ERANGE = global i64 0
define i32 @read_float(i8* %0, float* nocapture writeonly %1, i8** nocapture %2) {
store i64 0, i64* @errno
%4 = tail call float @strtof(i8* %0, i8** %2)
%5 = load i64, i64* @errno
%6 = load i64, i64* @ERANGE
%7 = icmp eq i64 %5, %6
br i1 %7, label %12, label %8
8: ; preds = %3
%9 = load i8*, i8** %2
%10 = icmp eq i8* %9, %0
br i1 %10, label %12, label %11
11: ; preds = %8
store float %4, float* %1
br label %12
12: ; preds = %8, %3, %11
%13 = phi i32 [ 0, %11 ], [ -1, %3 ], [ -2, %8 ]
ret i32 %13
}