#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *const);
int /*<<< orphan*/ stderr;
scalar_t__ strtod(char const *const, char **);
float ExUtilGetFloat(const char *const v, int *const error) {
  char *end = NULL;
  const float f = (v != NULL) ? (float)strtod(v, &end) : 0.f;
  if (end == v && error != NULL && !*error) {
    *error = 1;
    fprintf(stderr, "Error! '%s' is not a floating point number.\n",
            (v != NULL) ? v : "(null)");
  }
  return f;
}


x86 assembly (clang, -O0):
<ExUtilGetFloat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     115f <ExUtilGetFloat+0x3f>
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <strtod@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    116c <ExUtilGetFloat+0x4c>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
jmp    116c <ExUtilGetFloat+0x4c>
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jne    11ed <ExUtilGetFloat+0xcd>
cmpq   $0x0,-0x10(%rbp)
je     11ed <ExUtilGetFloat+0xcd>
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jne    11ed <ExUtilGetFloat+0xcd>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    0x2e33(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11ca <ExUtilGetFloat+0xaa>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    11da <ExUtilGetFloat+0xba>
lea    0xe5c(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    11da <ExUtilGetFloat+0xba>
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%rdx
lea    0xe18(%rip),%rsi
call   1040 <fprintf@plt>
movss  -0x1c(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ExUtilGetFloat>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movq   $0x0,0x10(%rsp)
test   %rdi,%rdi
je     1159 <ExUtilGetFloat+0x39>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <strtod@plt>
cvtsi2ss %rax,%xmm0
mov    0x10(%rsp),%rax
test   %r14,%r14
jne    1163 <ExUtilGetFloat+0x43>
jmp    11a4 <ExUtilGetFloat+0x84>
xorps  %xmm0,%xmm0
xor    %eax,%eax
test   %r14,%r14
je     11a4 <ExUtilGetFloat+0x84>
cmp    %rbx,%rax
jne    11a4 <ExUtilGetFloat+0x84>
cmpl   $0x0,(%r14)
jne    11a4 <ExUtilGetFloat+0x84>
test   %rbx,%rbx
movl   $0x1,(%r14)
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
lea    0xea5(%rip),%rdx
cmovne %rbx,%rdx
lea    0xe6d(%rip),%rsi
movss  %xmm0,0xc(%rsp)
call   1040 <fprintf@plt>
movss  0xc(%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [45 x i8] c"Error! '%s' is not a floating point number.\0A\00"
@.str.1 = [7 x i8] c"(null)\00"
define float @ExUtilGetFloat(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca float
store i8* %0, i8** %3
store i32* %1, i32** %4
store i8* null, i8** %5
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i8*, i8** %3
%11 = call i64 @strtod(i8* %10, i8** %5)
%12 = sitofp i64 %11 to float
br label %14
13: ; preds = %2
br label %14
14: ; preds = %13, %9
%15 = phi float [ %12, %9 ], [ 0.000000e+00, %13 ]
store float %15, float* %6
%16 = load i8*, i8** %5
%17 = load i8*, i8** %3
%18 = icmp eq i8* %16, %17
br i1 %18, label %19, label %37
19: ; preds = %14
%20 = load i32*, i32** %4
%21 = icmp ne i32* %20, null
br i1 %21, label %22, label %37
22: ; preds = %19
%23 = load i32*, i32** %4
%24 = load i32, i32* %23
%25 = icmp ne i32 %24, 0
br i1 %25, label %37, label %26
26: ; preds = %22
%27 = load i32*, i32** %4
store i32 1, i32* %27
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %3
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %33
31: ; preds = %26
%32 = load i8*, i8** %3
br label %34
33: ; preds = %26
br label %34
34: ; preds = %33, %31
%35 = phi i8* [ %32, %31 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), %33 ]
%36 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %34, %22, %19, %14
%38 = load float, float* %6
ret float %38
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [45 x i8] c"Error! '%s' is not a floating point number.\0A\00"
@.str.1 = [7 x i8] c"(null)\00"
define float @ExUtilGetFloat(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%5 = icmp eq i8* %0, null
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = call i64 @strtod(i8* %0, i8** %3)
%8 = sitofp i64 %7 to float
%9 = load i8*, i8** %3
br label %10
10: ; preds = %2, %6
%11 = phi i8* [ %9, %6 ], [ null, %2 ]
%12 = phi float [ %8, %6 ], [ 0.000000e+00, %2 ]
%13 = icmp eq i8* %11, %0
%14 = icmp ne i32* %1, null
%15 = and i1 %14, %13
br i1 %15, label %16, label %23
16: ; preds = %10
%17 = load i32, i32* %1
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
store i32 1, i32* %1
%20 = load i32, i32* @stderr
%21 = select i1 %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %0
%22 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %19, %16, %10
ret float %12
}