#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 */
int EINVAL;
scalar_t__ errno;
float strtof(char *, char **);
int ert_mapper_convert_to_float(char *string, float *value_rcv) {
  char *endptr = NULL;
  errno = 0;
  float value = strtof(string, &endptr);
  if (errno != 0) {
    return -EINVAL;
  }
  if (endptr != NULL && (*endptr) != '\0') {
    return -EINVAL;
  }
  *value_rcv = value;
  return 0;
}


x86 assembly (clang, -O0):
<ert_mapper_convert_to_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2eb1(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <strtof@plt>
movss  %xmm0,-0x24(%rbp)
mov    0x2e91(%rip),%rax
cmpq   $0x0,(%rax)
je     116c <ert_mapper_convert_to_float+0x5c>
xor    %eax,%eax
mov    0x2e76(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    11ae <ert_mapper_convert_to_float+0x9e>
cmpq   $0x0,-0x20(%rbp)
je     119a <ert_mapper_convert_to_float+0x8a>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     119a <ert_mapper_convert_to_float+0x8a>
xor    %eax,%eax
mov    0x2e48(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    11ae <ert_mapper_convert_to_float+0x9e>
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):
<ert_mapper_convert_to_float>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
movq   $0x0,(%rsp)
mov    0x2eba(%rip),%rbx
movq   $0x0,(%rbx)
mov    %rsp,%rsi
call   1030 <strtof@plt>
cmpq   $0x0,(%rbx)
je     1148 <ert_mapper_convert_to_float+0x38>
mov    0x2e96(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
jmp    115d <ert_mapper_convert_to_float+0x4d>
mov    (%rsp),%rax
test   %rax,%rax
je     1156 <ert_mapper_convert_to_float+0x46>
cmpb   $0x0,(%rax)
jne    113b <ert_mapper_convert_to_float+0x2b>
movss  %xmm0,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@errno = global i64 0
@EINVAL = global i32 0
define i32 @ert_mapper_convert_to_float(i8* %0, float* nocapture writeonly %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* null, i8** %3
store i64 0, i64* @errno
%5 = call float @strtof(i8* %0, i8** %3)
%6 = load i64, i64* @errno
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i32, i32* @EINVAL
%10 = sub nsw i32 0, %9
br label %21
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = icmp eq i8* %12, null
br i1 %13, label %20, label %14
14: ; preds = %11
%15 = load i8, i8* %12
%16 = icmp eq i8 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i32, i32* @EINVAL
%19 = sub nsw i32 0, %18
br label %21
20: ; preds = %14, %11
store float %5, float* %1
br label %21
21: ; preds = %20, %17, %8
%22 = phi i32 [ %10, %8 ], [ %19, %17 ], [ 0, %20 ]
ret i32 %22
}