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


x86 assembly (clang, -O0):
<test_strtold>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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   1070 <strtold@plt>
fstpt  -0x30(%rbp)
fldt   -0x30(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1060 <isnan@plt>
cmp    $0x0,%eax
jne    11a5 <test_strtold+0x55>
lea    0xe67(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x14(%rbp)
fldt   -0x30(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1050 <issignaling@plt>
cmp    $0x0,%rax
je     11cf <test_strtold+0x7f>
lea    0xe58(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11fc <test_strtold+0xac>
lea    0xe4d(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_strtold>:
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
call   1030 <puts@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <strtold@plt>
fld    %st(0)
fstpt  0x24(%rsp)
fstpt  (%rsp)
call   1060 <isnan@plt>
xor    %ebx,%ebx
test   %eax,%eax
jne    118f <test_strtold+0x3f>
lea    0xe7b(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
fldt   0x24(%rsp)
fstpt  (%rsp)
call   1050 <issignaling@plt>
test   %rax,%rax
je     11b1 <test_strtold+0x61>
lea    0xe74(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    0x18(%rsp),%rdi
lea    0xe76(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11d8 <test_strtold+0x88>
lea    0xe6f(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"strtold did not return NAN\00"
@.str.1 = [24 x i8] c"strtold returned a sNAN\00"
@.str.2 = [10 x i8] c"something\00"
@.str.3 = [34 x i8] c"strtold set incorrect end pointer\00"
define i32 @test_strtold(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca x86_fp80
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 x86_fp80 @strtold(i8* %8, i8** %3)
store x86_fp80 %9, x86_fp80* %5
%10 = load x86_fp80, x86_fp80* %5
%11 = call i32 @isnan(x86_fp80 %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %1
%14 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %4
br label %15
15: ; preds = %13, %1
%16 = load x86_fp80, x86_fp80* %5
%17 = call i64 @issignaling(x86_fp80 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 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 ([34 x i8], [34 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 = [27 x i8] c"strtold did not return NAN\00"
@.str.1 = [24 x i8] c"strtold returned a sNAN\00"
@.str.2 = [10 x i8] c"something\00"
@.str.3 = [34 x i8] c"strtold set incorrect end pointer\00"
define i32 @test_strtold(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) %0)
%5 = call x86_fp80 @strtold(i8* %0, i8** %2)
%6 = tail call i32 @isnan(x86_fp80 %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 ([27 x i8], [27 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(x86_fp80 %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 ([24 x i8], [24 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 ([34 x i8], [34 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
}