#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 errno;
float strtof(char *, char **);
int /*<<< orphan*/ xfree(float *);
float *xmalloc(int);
float *str2floatp(char *num) {
  float *rfloat;
  int p_errno;
  if (num != (char *)NULL) {
    rfloat = xmalloc(sizeof(float));
    if (rfloat != (float *)NULL) {
      p_errno = errno;
      errno = 0;
      *rfloat = strtof(num, (char **)NULL);
      if (errno == 0) {
        errno = p_errno;
        return rfloat;
      }
      xfree(rfloat);
      return (float *)NULL;
    }
  }
  return (float *)NULL;
}


x86 assembly (clang, -O0):
<str2floatp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11d2 <str2floatp+0xa2>
mov    $0x4,%edi
call   1050 <xmalloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11cd <str2floatp+0x9d>
mov    0x2e79(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e6d(%rip),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <strtof@plt>
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
mov    0x2e4b(%rip),%rax
cmpl   $0x0,(%rax)
jne    11b7 <str2floatp+0x87>
mov    -0x1c(%rbp),%ecx
mov    0x2e38(%rip),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11da <str2floatp+0xaa>
mov    -0x18(%rbp),%rdi
call   1030 <xfree@plt>
movq   $0x0,-0x8(%rbp)
jmp    11da <str2floatp+0xaa>
jmp    11d2 <str2floatp+0xa2>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str2floatp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     117e <str2floatp+0x4e>
mov    %rdi,%r14
mov    $0x4,%edi
call   1050 <xmalloc@plt>
test   %rax,%rax
je     117e <str2floatp+0x4e>
mov    %rax,%rbx
mov    0x2e88(%rip),%r15
mov    (%r15),%ebp
movl   $0x0,(%r15)
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <strtof@plt>
movss  %xmm0,(%rbx)
cmpl   $0x0,(%r15)
je     118e <str2floatp+0x5e>
mov    %rbx,%rdi
call   1030 <xfree@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebp,(%r15)
jmp    1180 <str2floatp+0x50>

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

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