#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 */
long double NAN;
int /*<<< orphan*/ sprintf(char *, char *, char const *);
int /*<<< orphan*/ strlen(char const *);
long double strtold(char *, int /*<<< orphan*/ *);
long double __nanl(const char *tagp) {
  if (tagp[0] != '\0') {
    char buf[6 + strlen(tagp)];
    sprintf(buf, "NAN(%s)", tagp);
    return strtold(buf, NULL);
  }
  return NAN;
}


x86 assembly (clang, -O0):
<__nanl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11a7 <__nanl+0x77>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x6,%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdx
lea    0xe7a(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <strtold@plt>
fstpt  -0x10(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
jmp    11b3 <__nanl+0x83>
mov    0x2e4a(%rip),%rax
fldt   (%rax)
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__nanl>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmpb   $0x0,(%rdi)
je     117f <__nanl+0x4f>
mov    %rdi,%r14
call   1030 <strlen@plt>
mov    %rsp,%r15
add    $0x6,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1050 <sprintf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <strtold@plt>
mov    %r15,%rsp
jmp    1188 <__nanl+0x58>
mov    0x2e72(%rip),%rax
fldt   (%rax)
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"NAN(%s)\00"
@NAN = global x86_fp80 0xK00000000000000000000
define x86_fp80 @__nanl(i8* %0) {
%2 = alloca x86_fp80
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %22
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i32 @strlen(i8* %12)
%14 = add nsw i32 6, %13
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %4
%17 = alloca i8, i64 %15
store i64 %15, i64* %5
%18 = load i8*, i8** %3
%19 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = call x86_fp80 @strtold(i8* %17, i32* null)
store x86_fp80 %20, x86_fp80* %2
%21 = load i8*, i8** %4
br label %24
22: ; preds = %1
%23 = load x86_fp80, x86_fp80* @NAN
store x86_fp80 %23, x86_fp80* %2
br label %24
24: ; preds = %22, %11
%25 = load x86_fp80, x86_fp80* %2
ret x86_fp80 %25
}

LLVM IR (-O2):
@.str = [8 x i8] c"NAN(%s)\00"
@NAN = global x86_fp80 0xK00000000000000000000
define x86_fp80 @__nanl(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %12, label %4
4: ; preds = %1
%5 = tail call i32 @strlen(i8* %0)
%6 = add nsw i32 %5, 6
%7 = zext i32 %6 to i64
%8 = tail call i8* @llvm.stacksave()
%9 = alloca i8, i64 %7
%10 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %0)
%11 = call x86_fp80 @strtold(i8* nocapture %9, i32* null)
tail call void @llvm.stackrestore(i8* %8)
br label %14
12: ; preds = %1
%13 = load x86_fp80, x86_fp80* @NAN
br label %14
14: ; preds = %12, %4
%15 = phi x86_fp80 [ %11, %4 ], [ %13, %12 ]
ret x86_fp80 %15
}