#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 */
typedef int uint64_t;

/* Variables and functions */
int get_dbits(double);
int filter_special(double fp, char *dest) {
  if (fp == 0.0) {
    dest[0] = '0';
    return 1;
  }
  uint64_t bits = get_dbits(fp);
  bool nan = (bits & 0x7FF0000000000000U) == 0x7FF0000000000000U;
  if (!nan) {
    return 0;
  }
  if (bits & 0x000FFFFFFFFFFFFFU) {
    dest[0] = 'n';
    dest[1] = 'a';
    dest[2] = 'n';
  } else {
    dest[0] = 'i';
    dest[1] = 'n';
    dest[2] = 'f';
  }
  return 3;
}


x86 assembly (clang, -O0):
<filter_special>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    114c <filter_special+0x3c>
jp     114c <filter_special+0x3c>
mov    -0x18(%rbp),%rax
movb   $0x30,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11ed <filter_special+0xdd>
movsd  -0x10(%rbp),%xmm0
call   1030 <get_dbits@plt>
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
movabs $0x7ff0000000000000,%rcx
and    %rcx,%rax
movabs $0x7ff0000000000000,%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    1198 <filter_special+0x88>
movl   $0x0,-0x4(%rbp)
jmp    11ed <filter_special+0xdd>
movslq -0x1c(%rbp),%rax
movabs $0xfffffffffffff,%rcx
and    %rcx,%rax
cmp    $0x0,%rax
je     11cf <filter_special+0xbf>
mov    -0x18(%rbp),%rax
movb   $0x6e,(%rax)
mov    -0x18(%rbp),%rax
movb   $0x61,0x1(%rax)
mov    -0x18(%rbp),%rax
movb   $0x6e,0x2(%rax)
jmp    11e6 <filter_special+0xd6>
mov    -0x18(%rbp),%rax
movb   $0x69,(%rax)
mov    -0x18(%rbp),%rax
movb   $0x6e,0x1(%rax)
mov    -0x18(%rbp),%rax
movb   $0x66,0x2(%rax)
movl   $0x3,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filter_special>:
push   %rbx
mov    %rdi,%rbx
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    112a <filter_special+0x1a>
jp     112a <filter_special+0x1a>
movb   $0x30,(%rbx)
mov    $0x1,%eax
pop    %rbx
ret
call   1030 <get_dbits@plt>
movslq %eax,%rcx
mov    %rcx,%rdx
not    %rdx
xor    %eax,%eax
movabs $0x7ff0000000000000,%rsi
test   %rsi,%rdx
jne    1168 <filter_special+0x58>
shl    $0xc,%rcx
je     115a <filter_special+0x4a>
movw   $0x616e,(%rbx)
movb   $0x6e,0x2(%rbx)
jmp    1163 <filter_special+0x53>
movw   $0x6e69,(%rbx)
movb   $0x66,0x2(%rbx)
mov    $0x3,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @filter_special(double %0, i8* %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store double %0, double* %4
store i8* %1, i8** %5
%8 = load double, double* %4
%9 = fcmp oeq double %8, 0.000000e+00
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = getelementptr inbounds i8, i8* %11, i64 0
store i8 48, i8* %12
store i32 1, i32* %3
br label %44
13: ; preds = %2
%14 = load double, double* %4
%15 = call i32 @get_dbits(double %14)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = and i64 %17, 9218868437227405312
%19 = icmp eq i64 %18, 9218868437227405312
%20 = zext i1 %19 to i32
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = icmp ne i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %13
store i32 0, i32* %3
br label %44
24: ; preds = %13
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = and i64 %26, 4503599627370495
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %24
%30 = load i8*, i8** %5
%31 = getelementptr inbounds i8, i8* %30, i64 0
store i8 110, i8* %31
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i64 1
store i8 97, i8* %33
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i64 2
store i8 110, i8* %35
br label %43
36: ; preds = %24
%37 = load i8*, i8** %5
%38 = getelementptr inbounds i8, i8* %37, i64 0
store i8 105, i8* %38
%39 = load i8*, i8** %5
%40 = getelementptr inbounds i8, i8* %39, i64 1
store i8 110, i8* %40
%41 = load i8*, i8** %5
%42 = getelementptr inbounds i8, i8* %41, i64 2
store i8 102, i8* %42
br label %43
43: ; preds = %36, %29
store i32 3, i32* %3
br label %44
44: ; preds = %43, %23, %10
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
define i32 @filter_special(double %0, i8* nocapture writeonly %1) {
%3 = fcmp oeq double %0, 0.000000e+00
br i1 %3, label %4, label %5
4: ; preds = %2
store i8 48, i8* %1
br label %19
5: ; preds = %2
%6 = tail call i32 @get_dbits(double %0)
%7 = sext i32 %6 to i64
%8 = and i64 %7, 9218868437227405312
%9 = icmp eq i64 %8, 9218868437227405312
br i1 %9, label %10, label %19
10: ; preds = %5
%11 = and i64 %7, 4503599627370495
%12 = icmp eq i64 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
store i8 110, i8* %1
%14 = getelementptr inbounds i8, i8* %1, i64 1
store i8 97, i8* %14
%15 = getelementptr inbounds i8, i8* %1, i64 2
store i8 110, i8* %15
br label %19
16: ; preds = %10
store i8 105, i8* %1
%17 = getelementptr inbounds i8, i8* %1, i64 1
store i8 110, i8* %17
%18 = getelementptr inbounds i8, i8* %1, i64 2
store i8 102, i8* %18
br label %19
19: ; preds = %5, %16, %13, %4
%20 = phi i32 [ 1, %4 ], [ 0, %5 ], [ 3, %16 ], [ 3, %13 ]
ret i32 %20
}