#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;
scalar_t__ isinf(float);
scalar_t__ isnan(float);
float strtof(char const *, char **);
int /*<<< orphan*/ warn(char *, char const *, unsigned int);
float float_value(const char *value, const char *filename, unsigned linenum,
                  int *error) {
  char *endptr;
  float ret;
  errno = 0;
  ret = strtof(value, &endptr);
  if (errno == ERANGE) {
    warn("Value out of range %s:%d", filename, linenum);
    *error = -1;
  }
  if (endptr == value) {
    warn("Bad floating-point value at %s:%d", filename, linenum);
    *error = -1;
  }
  if (isnan(ret) || isinf(ret)) {
    warn("Value out of range %s:%d", filename, linenum);
    *error = -1;
  }
  return ret;
}


x86 assembly (clang, -O0):
<float_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    0x2e7a(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <strtof@plt>
movss  %xmm0,-0x2c(%rbp)
mov    0x2e5a(%rip),%rax
mov    (%rax),%rax
mov    0x2e60(%rip),%rcx
cmp    (%rcx),%rax
jne    11ae <float_value+0x6e>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe61(%rip),%rdi
call   1030 <warn@plt>
mov    -0x20(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x28(%rbp),%rax
cmp    -0x8(%rbp),%rax
jne    11d9 <float_value+0x99>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe4f(%rip),%rdi
call   1030 <warn@plt>
mov    -0x20(%rbp),%rax
movl   $0xffffffff,(%rax)
movss  -0x2c(%rbp),%xmm0
call   1050 <isnan@plt>
cmp    $0x0,%rax
jne    1201 <float_value+0xc1>
movss  -0x2c(%rbp),%xmm0
call   1060 <isinf@plt>
cmp    $0x0,%rax
je     121e <float_value+0xde>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xdf1(%rip),%rdi
call   1030 <warn@plt>
mov    -0x20(%rbp),%rax
movl   $0xffffffff,(%rax)
movss  -0x2c(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<float_value>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %edx,%r15d
mov    %rsi,%r12
mov    %rdi,%rbp
mov    0x2e79(%rip),%rbx
movq   $0x0,(%rbx)
lea    0x8(%rsp),%rsi
call   1040 <strtof@plt>
movss  %xmm0,0x4(%rsp)
mov    (%rbx),%rax
mov    0x2e68(%rip),%rcx
cmp    (%rcx),%rax
jne    119e <float_value+0x5e>
lea    0xe74(%rip),%rdi
mov    %r12,%rsi
mov    %r15d,%edx
call   1030 <warn@plt>
movl   $0xffffffff,(%r14)
cmp    %rbp,0x8(%rsp)
jne    11be <float_value+0x7e>
lea    0xe6d(%rip),%rdi
mov    %r12,%rsi
mov    %r15d,%edx
call   1030 <warn@plt>
movl   $0xffffffff,(%r14)
movss  0x4(%rsp),%xmm0
call   1050 <isnan@plt>
test   %rax,%rax
jne    11de <float_value+0x9e>
movss  0x4(%rsp),%xmm0
call   1060 <isinf@plt>
test   %rax,%rax
je     11f7 <float_value+0xb7>
lea    0xe1b(%rip),%rdi
mov    %r12,%rsi
mov    %r15d,%edx
call   1030 <warn@plt>
movl   $0xffffffff,(%r14)
movss  0x4(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i64 0
@ERANGE = global i64 0
@.str = [25 x i8] c"Value out of range %s:%d\00"
@.str.1 = [34 x i8] c"Bad floating-point value at %s:%d\00"
define float @float_value(i8* %0, i8* %1, i32 %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca float
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32* %3, i32** %8
store i64 0, i64* @errno
%11 = load i8*, i8** %5
%12 = call float @strtof(i8* %11, i8** %9)
store float %12, float* %10
%13 = load i64, i64* @errno
%14 = load i64, i64* @ERANGE
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %21
16: ; preds = %4
%17 = load i8*, i8** %6
%18 = load i32, i32* %7
%19 = call i32 @warn(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %17, i32 %18)
%20 = load i32*, i32** %8
store i32 -1, i32* %20
br label %21
21: ; preds = %16, %4
%22 = load i8*, i8** %9
%23 = load i8*, i8** %5
%24 = icmp eq i8* %22, %23
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = load i8*, i8** %6
%27 = load i32, i32* %7
%28 = call i32 @warn(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %26, i32 %27)
%29 = load i32*, i32** %8
store i32 -1, i32* %29
br label %30
30: ; preds = %25, %21
%31 = load float, float* %10
%32 = call i64 @isnan(float %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %30
%35 = load float, float* %10
%36 = call i64 @isinf(float %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %34, %30
%39 = load i8*, i8** %6
%40 = load i32, i32* %7
%41 = call i32 @warn(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %39, i32 %40)
%42 = load i32*, i32** %8
store i32 -1, i32* %42
br label %43
43: ; preds = %38, %34
%44 = load float, float* %10
ret float %44
}

LLVM IR (-O2):
@errno = global i64 0
@ERANGE = global i64 0
@.str = [25 x i8] c"Value out of range %s:%d\00"
@.str.1 = [34 x i8] c"Bad floating-point value at %s:%d\00"
define float @float_value(i8* %0, i8* %1, i32 %2, i32* nocapture writeonly %3) {
%5 = alloca i8*
%6 = bitcast i8** %5 to i8*
store i64 0, i64* @errno
%7 = call float @strtof(i8* %0, i8** %5)
%8 = load i64, i64* @errno
%9 = load i64, i64* @ERANGE
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %4
%12 = tail call i32 @warn(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %2)
store i32 -1, i32* %3
br label %13
13: ; preds = %11, %4
%14 = load i8*, i8** %5
%15 = icmp eq i8* %14, %0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @warn(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32 %2)
store i32 -1, i32* %3
br label %18
18: ; preds = %16, %13
%19 = tail call i64 @isnan(float %7)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = tail call i64 @isinf(float %7)
%23 = icmp eq i64 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %21, %18
%25 = tail call i32 @warn(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %2)
store i32 -1, i32* %3
br label %26
26: ; preds = %24, %21
ret float %7
}