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


x86 assembly (clang, -O0):
<do_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0xc(%rbp)
lea    0xe6a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <strtod@plt>
movsd  %xmm0,-0x18(%rbp)
fldl   -0x18(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1090 <isnan@plt>
cmp    $0x0,%eax
jne    11cd <do_test+0x4d>
lea    0xe54(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0xc(%rbp)
fldl   -0x18(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1080 <issignaling@plt>
cmp    $0x0,%rax
je     11f7 <do_test+0x77>
lea    0xe44(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe44(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1224 <do_test+0xa4>
lea    0xe38(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0xc(%rbp)
lea    0xdd5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <strtof@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1060 <isnanf@plt>
cmp    $0x0,%eax
jne    125f <do_test+0xdf>
lea    0xe1e(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0xc(%rbp)
flds   -0x1c(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1080 <issignaling@plt>
cmp    $0x0,%rax
je     1289 <do_test+0x109>
lea    0xe0e(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xdb2(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     12b6 <do_test+0x136>
lea    0xdf8(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0xc(%rbp)
lea    0xd43(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   10a0 <strtold@plt>
fstpt  -0x30(%rbp)
fldt   -0x30(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1090 <isnan@plt>
cmp    $0x0,%eax
jne    12f2 <do_test+0x172>
lea    0xddd(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0xc(%rbp)
fldt   -0x30(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1080 <issignaling@plt>
cmp    $0x0,%rax
je     131c <do_test+0x19c>
lea    0xdce(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xd1f(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1349 <do_test+0x1c9>
lea    0xdb9(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_test>:
push   %rbx
sub    $0x30,%rsp
lea    0xe74(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <strtod@plt>
movsd  %xmm0,0x28(%rsp)
fldl   0x28(%rsp)
fld    %st(0)
fstpt  0x18(%rsp)
fstpt  (%rsp)
call   1090 <isnan@plt>
xor    %ebx,%ebx
test   %eax,%eax
jne    11c5 <do_test+0x45>
lea    0xe5a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
fldt   0x18(%rsp)
fstpt  (%rsp)
call   1080 <issignaling@plt>
test   %rax,%rax
je     11e7 <do_test+0x67>
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    0x10(%rsp),%rdi
lea    0xe53(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     120e <do_test+0x8e>
lea    0xe4c(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
lea    0xdeb(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1050 <strtof@plt>
movss  %xmm0,0x18(%rsp)
call   1060 <isnanf@plt>
test   %eax,%eax
jne    123f <do_test+0xbf>
lea    0xe3c(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
movss  0x18(%rsp),%xmm0
movss  %xmm0,0x24(%rsp)
flds   0x24(%rsp)
fstpt  (%rsp)
call   1080 <issignaling@plt>
test   %rax,%rax
je     126d <do_test+0xed>
lea    0xe28(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    0x10(%rsp),%rdi
lea    0xdcd(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1294 <do_test+0x114>
lea    0xe18(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
lea    0xd65(%rip),%rdi
lea    0x10(%rsp),%rsi
call   10a0 <strtold@plt>
fld    %st(0)
fstpt  0x18(%rsp)
fstpt  (%rsp)
call   1090 <isnan@plt>
test   %eax,%eax
jne    12c8 <do_test+0x148>
lea    0xe05(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
fldt   0x18(%rsp)
fstpt  (%rsp)
call   1080 <issignaling@plt>
test   %rax,%rax
je     12ea <do_test+0x16a>
lea    0xdfe(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    0x10(%rsp),%rdi
lea    0xd50(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1311 <do_test+0x191>
lea    0xdef(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@do_test.str = internal constant [21 x i8] c"NaN(blabla)something\00"
@.str = [26 x i8] c"strtod did not return NAN\00"
@.str.1 = [23 x i8] c"strtod returned a sNAN\00"
@.str.2 = [10 x i8] c"something\00"
@.str.3 = [33 x i8] c"strtod set incorrect end pointer\00"
@.str.4 = [26 x i8] c"strtof did not return NAN\00"
@.str.5 = [23 x i8] c"strtof returned a sNAN\00"
@.str.6 = [33 x i8] c"strtof set incorrect end pointer\00"
@.str.7 = [27 x i8] c"strtold did not return NAN\00"
@.str.8 = [24 x i8] c"strtold returned a sNAN\00"
@.str.9 = [34 x i8] c"strtold set incorrect end pointer\00"
define i32 @do_test() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca double
%4 = alloca float
%5 = alloca x86_fp80
store i32 0, i32* %2
%6 = call double @strtod(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @do_test.str, i64 0, i64 0), i8** %1)
store double %6, double* %3
%7 = load double, double* %3
%8 = fpext double %7 to x86_fp80
%9 = call i32 @isnan(x86_fp80 %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %0
%12 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
br label %13
13: ; preds = %11, %0
%14 = load double, double* %3
%15 = fpext double %14 to x86_fp80
%16 = call i64 @issignaling(x86_fp80 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 @puts(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %2
br label %20
20: ; preds = %18, %13
%21 = load i8*, i8** %1
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 @puts(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %2
br label %26
26: ; preds = %24, %20
%27 = call float @strtof(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @do_test.str, i64 0, i64 0), i8** %1)
store float %27, float* %4
%28 = load float, float* %4
%29 = call i32 @isnanf(float %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %26
%32 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %2
br label %33
33: ; preds = %31, %26
%34 = load float, float* %4
%35 = fpext float %34 to x86_fp80
%36 = call i64 @issignaling(x86_fp80 %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %33
%39 = call i32 @puts(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %2
br label %40
40: ; preds = %38, %33
%41 = load i8*, i8** %1
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = call i32 @puts(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %2
br label %46
46: ; preds = %44, %40
%47 = call x86_fp80 @strtold(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @do_test.str, i64 0, i64 0), i8** %1)
store x86_fp80 %47, x86_fp80* %5
%48 = load x86_fp80, x86_fp80* %5
%49 = call i32 @isnan(x86_fp80 %48)
%50 = icmp ne i32 %49, 0
br i1 %50, label %53, label %51
51: ; preds = %46
%52 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %2
br label %53
53: ; preds = %51, %46
%54 = load x86_fp80, x86_fp80* %5
%55 = call i64 @issignaling(x86_fp80 %54)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %53
%58 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %2
br label %59
59: ; preds = %57, %53
%60 = load i8*, i8** %1
%61 = call i64 @strcmp(i8* %60, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%62 = icmp ne i64 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %59
%64 = call i32 @puts(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %2
br label %65
65: ; preds = %63, %59
%66 = load i32, i32* %2
ret i32 %66
}

LLVM IR (-O2):
@do_test.str = internal constant [21 x i8] c"NaN(blabla)something\00"
@.str = [26 x i8] c"strtod did not return NAN\00"
@.str.1 = [23 x i8] c"strtod returned a sNAN\00"
@.str.2 = [10 x i8] c"something\00"
@.str.3 = [33 x i8] c"strtod set incorrect end pointer\00"
@.str.4 = [26 x i8] c"strtof did not return NAN\00"
@.str.5 = [23 x i8] c"strtof returned a sNAN\00"
@.str.6 = [33 x i8] c"strtof set incorrect end pointer\00"
@.str.7 = [27 x i8] c"strtold did not return NAN\00"
@.str.8 = [24 x i8] c"strtold returned a sNAN\00"
@.str.9 = [34 x i8] c"strtold set incorrect end pointer\00"
define i32 @do_test() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
%3 = call double @strtod(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @do_test.str, i64 0, i64 0), i8** %1)
%4 = fpext double %3 to x86_fp80
%5 = tail call i32 @isnan(x86_fp80 %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
%10 = phi i32 [ 0, %0 ], [ 1, %7 ]
%11 = tail call i64 @issignaling(x86_fp80 %4)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %9
%16 = phi i32 [ 1, %13 ], [ %10, %9 ]
%17 = load i8*, i8** %1
%18 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %15
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %20, %15
%23 = phi i32 [ 1, %20 ], [ %16, %15 ]
%24 = call float @strtof(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @do_test.str, i64 0, i64 0), i8** %1)
%25 = tail call i32 @isnanf(float %24)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %29
29: ; preds = %27, %22
%30 = phi i32 [ %23, %22 ], [ 1, %27 ]
%31 = fpext float %24 to x86_fp80
%32 = tail call i64 @issignaling(x86_fp80 %31)
%33 = icmp eq i64 %32, 0
br i1 %33, label %36, label %34
34: ; preds = %29
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
br label %36
36: ; preds = %34, %29
%37 = phi i32 [ 1, %34 ], [ %30, %29 ]
%38 = load i8*, i8** %1
%39 = tail call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %43, label %41
41: ; preds = %36
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
br label %43
43: ; preds = %41, %36
%44 = phi i32 [ 1, %41 ], [ %37, %36 ]
%45 = call x86_fp80 @strtold(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @do_test.str, i64 0, i64 0), i8** %1)
%46 = tail call i32 @isnan(x86_fp80 %45)
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %43
%49 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
br label %50
50: ; preds = %48, %43
%51 = phi i32 [ %44, %43 ], [ 1, %48 ]
%52 = tail call i64 @issignaling(x86_fp80 %45)
%53 = icmp eq i64 %52, 0
br i1 %53, label %56, label %54
54: ; preds = %50
%55 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
br label %56
56: ; preds = %54, %50
%57 = phi i32 [ 1, %54 ], [ %51, %50 ]
%58 = load i8*, i8** %1
%59 = tail call i64 @strcmp(i8* %58, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%60 = icmp eq i64 %59, 0
br i1 %60, label %63, label %61
61: ; preds = %56
%62 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
br label %63
63: ; preds = %61, %56
%64 = phi i32 [ 1, %61 ], [ %57, %56 ]
ret i32 %64
}