#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 */
unsigned long long __make_mantissa(char const *);
double nan(const char *tagp) {
  union {
    double val;
    struct ieee_double {
      unsigned long long mantissa : 51;
      unsigned quiet : 1;
      unsigned exponent : 11;
      unsigned sign : 1;
    } bits;
  } tmp;
  tmp.bits.sign = 0u;
  tmp.bits.exponent = ~0u;
  tmp.bits.quiet = 1u;
  tmp.bits.mantissa = __make_mantissa(tagp);
  return tmp.val;
}


x86 assembly (clang, -O0):
<nan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movabs $0x7fffffffffffffff,%rax
ff ff 7f
and    -0x10(%rbp),%rax
or     $0x0,%rax
mov    %rax,-0x10(%rbp)
movabs $0x800fffffffffffff,%rax
ff 0f 80
and    -0x10(%rbp),%rax
movabs $0x7ff0000000000000,%rcx
or     %rcx,%rax
mov    %rax,-0x10(%rbp)
movabs $0xfff7ffffffffffff,%rax
ff f7 ff
and    -0x10(%rbp),%rax
movabs $0x8000000000000,%rcx
or     %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <__make_mantissa@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
movabs $0x7ffffffffffff,%rdx
and    %rdx,%rcx
movabs $0xfff8000000000000,%rdx
and    %rdx,%rax
or     %rcx,%rax
mov    %rax,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nan>:
push   %rax
call   1030 <__make_mantissa@plt>
movabs $0x7ffffffffffff,%rcx
and    %rax,%rcx
movabs $0x7ff8000000000000,%rax
or     %rcx,%rax
movq   %rax,%xmm0
pop    %rax
ret

LLVM IR (-O0):
%union.anon = type { double }
%struct.ieee_double = type { i64 }
define double @nan(i8* %0) {
%2 = alloca i8*
%3 = alloca %union.anon
store i8* %0, i8** %2
%4 = bitcast %union.anon* %3 to %struct.ieee_double*
%5 = bitcast %struct.ieee_double* %4 to i64*
%6 = load i64, i64* %5
%7 = and i64 %6, 9223372036854775807
%8 = or i64 %7, 0
store i64 %8, i64* %5
%9 = bitcast %union.anon* %3 to %struct.ieee_double*
%10 = bitcast %struct.ieee_double* %9 to i64*
%11 = load i64, i64* %10
%12 = and i64 %11, -9218868437227405313
%13 = or i64 %12, 9218868437227405312
store i64 %13, i64* %10
%14 = bitcast %union.anon* %3 to %struct.ieee_double*
%15 = bitcast %struct.ieee_double* %14 to i64*
%16 = load i64, i64* %15
%17 = and i64 %16, -2251799813685249
%18 = or i64 %17, 2251799813685248
store i64 %18, i64* %15
%19 = load i8*, i8** %2
%20 = call i64 @__make_mantissa(i8* %19)
%21 = bitcast %union.anon* %3 to %struct.ieee_double*
%22 = bitcast %struct.ieee_double* %21 to i64*
%23 = load i64, i64* %22
%24 = and i64 %20, 2251799813685247
%25 = and i64 %23, -2251799813685248
%26 = or i64 %25, %24
store i64 %26, i64* %22
%27 = bitcast %union.anon* %3 to double*
%28 = load double, double* %27
ret double %28
}

LLVM IR (-O2):
define double @nan(i8* %0) {
%2 = tail call i64 @__make_mantissa(i8* %0)
%3 = and i64 %2, 2251799813685247
%4 = or i64 %3, 9221120237041090560
%5 = bitcast i64 %4 to double
ret double %5
}