#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*/ isnan(float);
scalar_t__ issignaling(float);
int /*<<< orphan*/ puts(char const *);
scalar_t__ strcmp(char *, char *);
float strtof(char const *, char **);
int test_strtof(const char str[]) {
  char *endp;
  int result = 0;
  puts(str);
  float d = strtof(str, &endp);
  if (!isnan(d)) {
    puts("strto"
         "f"
         " did not return NAN");
    result = 1;
  }
  if (issignaling(d)) {
    puts("strto"
         "f"
         " returned a sNAN");
    result = 1;
  }
  if (strcmp(endp, "something") != 0) {
    puts("strto"
         "f"
         " set incorrect end pointer");
    result = 1;
  }
  return result;
}


x86 assembly (clang, -O0):
<test_strtof>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <puts@plt>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <strtof@plt>
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
call   1070 <isnan@plt>
cmp    $0x0,%eax
jne    11a4 <test_strtof+0x54>
lea    0xe68(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x14(%rbp)
movss  -0x18(%rbp),%xmm0
call   1060 <issignaling@plt>
cmp    $0x0,%rax
je     11cb <test_strtof+0x7b>
lea    0xe5b(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe5b(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11f8 <test_strtof+0xa8>
lea    0xe4f(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_strtof>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1030 <puts@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <strtof@plt>
movss  %xmm0,0x4(%rsp)
call   1070 <isnan@plt>
xor    %ebx,%ebx
test   %eax,%eax
jne    118c <test_strtof+0x3c>
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
movss  0x4(%rsp),%xmm0
call   1060 <issignaling@plt>
test   %rax,%rax
je     11ad <test_strtof+0x5d>
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    0x8(%rsp),%rdi
lea    0xe78(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11d4 <test_strtof+0x84>
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"strtof did not return NAN\00"
@.str.1 = [23 x i8] c"strtof returned a sNAN\00"
@.str.2 = [10 x i8] c"something\00"
@.str.3 = [33 x i8] c"strtof set incorrect end pointer\00"
define i32 @test_strtof(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca float
store i8* %0, i8** %2
store i32 0, i32* %4
%6 = load i8*, i8** %2
%7 = call i32 @puts(i8* %6)
%8 = load i8*, i8** %2
%9 = call float @strtof(i8* %8, i8** %3)
store float %9, float* %5
%10 = load float, float* %5
%11 = call i32 @isnan(float %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %1
%14 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %4
br label %15
15: ; preds = %13, %1
%16 = load float, float* %5
%17 = call i64 @issignaling(float %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @puts(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %4
br label %21
21: ; preds = %19, %15
%22 = load i8*, i8** %3
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @puts(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %4
br label %27
27: ; preds = %25, %21
%28 = load i32, i32* %4
ret i32 %28
}

LLVM IR (-O2):
@.str = [26 x i8] c"strtof did not return NAN\00"
@.str.1 = [23 x i8] c"strtof returned a sNAN\00"
@.str.2 = [10 x i8] c"something\00"
@.str.3 = [33 x i8] c"strtof set incorrect end pointer\00"
define i32 @test_strtof(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) %0)
%5 = call float @strtof(i8* %0, i8** %2)
%6 = tail call i32 @isnan(float %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %1
%11 = phi i32 [ 0, %1 ], [ 1, %8 ]
%12 = tail call i64 @issignaling(float %5)
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %10
%17 = phi i32 [ 1, %14 ], [ %11, %10 ]
%18 = load i8*, i8** %2
%19 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %16
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %21, %16
%24 = phi i32 [ 1, %21 ], [ %17, %16 ]
ret i32 %24
}