#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 */
double atod(char *);
double atodn(char *, char);
scalar_t__ s_tokcmpn(char *, char *, char);
int dblcmpn(char *val, char *s, char n) {
  double d1, d2;
  return s_tokcmpn(val, s, n) == 0 ? 0
         : s_tokcmpn(val, "NaN", 3) == 0 || s_tokcmpn("NaN", s, n) == 0
             ? 1
             : (d1 = atod(val), d2 = atodn(s, n),
                d1 < d2   ? -1
                : d1 > d2 ? 1
                          : 0);
}


x86 assembly (clang, -O0):
<dblcmpn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movsbl -0x11(%rbp),%edx
call   1040 <s_tokcmpn@plt>
cmp    $0x0,%rax
jne    116a <dblcmpn+0x3a>
xor    %eax,%eax
mov    %eax,-0x2c(%rbp)
jmp    121c <dblcmpn+0xec>
mov    -0x8(%rbp),%rdi
lea    0xe8b(%rip),%rsi
mov    $0x3,%edx
call   1040 <s_tokcmpn@plt>
cmp    $0x0,%rax
je     11a7 <dblcmpn+0x77>
mov    -0x10(%rbp),%rsi
lea    0xe6c(%rip),%rdi
movsbl -0x11(%rbp),%edx
call   1040 <s_tokcmpn@plt>
cmp    $0x0,%rax
jne    11b4 <dblcmpn+0x84>
mov    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1216 <dblcmpn+0xe6>
mov    -0x8(%rbp),%rdi
call   1030 <atod@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
movsbl -0x11(%rbp),%esi
call   1050 <atodn@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11f5 <dblcmpn+0xc5>
mov    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    1210 <dblcmpn+0xe0>
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
xor    %eax,%eax
mov    $0x1,%ecx
ucomisd %xmm1,%xmm0
cmova  %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dblcmpn>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <s_tokcmpn@plt>
test   %rax,%rax
je     11b7 <dblcmpn+0x87>
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1040 <s_tokcmpn@plt>
mov    $0x1,%r15d
test   %rax,%rax
je     11ba <dblcmpn+0x8a>
movsbl %bpl,%ebp
lea    0xe8d(%rip),%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1040 <s_tokcmpn@plt>
test   %rax,%rax
je     11ba <dblcmpn+0x8a>
mov    %rbx,%rdi
call   1030 <atod@plt>
movsd  %xmm0,(%rsp)
mov    %r14,%rdi
mov    %ebp,%esi
call   1050 <atodn@plt>
movsd  (%rsp),%xmm1
mov    $0xffffffff,%r15d
ucomisd %xmm1,%xmm0
ja     11ba <dblcmpn+0x8a>
xor    %r15d,%r15d
ucomisd %xmm0,%xmm1
seta   %r15b
jmp    11ba <dblcmpn+0x8a>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"NaN\00"
define i32 @dblcmpn(i8* %0, i8* %1, i8 signext %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8
%7 = alloca double
%8 = alloca double
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8 %2, i8* %6
%9 = load i8*, i8** %4
%10 = load i8*, i8** %5
%11 = load i8, i8* %6
%12 = call i64 @s_tokcmpn(i8* %9, i8* %10, i8 signext %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %3
br label %45
15: ; preds = %3
%16 = load i8*, i8** %4
%17 = call i64 @s_tokcmpn(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext 3)
%18 = icmp eq i64 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %15
%20 = load i8*, i8** %5
%21 = load i8, i8* %6
%22 = call i64 @s_tokcmpn(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %20, i8 signext %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %19, %15
br label %43
25: ; preds = %19
%26 = load i8*, i8** %4
%27 = call double @atod(i8* %26)
store double %27, double* %7
%28 = load i8*, i8** %5
%29 = load i8, i8* %6
%30 = call double @atodn(i8* %28, i8 signext %29)
store double %30, double* %8
%31 = load double, double* %7
%32 = load double, double* %8
%33 = fcmp olt double %31, %32
br i1 %33, label %34, label %35
34: ; preds = %25
br label %41
35: ; preds = %25
%36 = load double, double* %7
%37 = load double, double* %8
%38 = fcmp ogt double %36, %37
%39 = zext i1 %38 to i64
%40 = select i1 %38, i32 1, i32 0
br label %41
41: ; preds = %35, %34
%42 = phi i32 [ -1, %34 ], [ %40, %35 ]
br label %43
43: ; preds = %41, %24
%44 = phi i32 [ 1, %24 ], [ %42, %41 ]
br label %45
45: ; preds = %43, %14
%46 = phi i32 [ 0, %14 ], [ %44, %43 ]
ret i32 %46
}

LLVM IR (-O2):
@.str = [4 x i8] c"NaN\00"
define i32 @dblcmpn(i8* %0, i8* %1, i8 signext %2) {
%4 = tail call i64 @s_tokcmpn(i8* %0, i8* %1, i8 signext %2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %19, label %6
6: ; preds = %3
%7 = tail call i64 @s_tokcmpn(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext 3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %19, label %9
9: ; preds = %6
%10 = tail call i64 @s_tokcmpn(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %1, i8 signext %2)
%11 = icmp eq i64 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %9
%13 = tail call double @atod(i8* %0)
%14 = tail call double @atodn(i8* %1, i8 signext %2)
%15 = fcmp olt double %13, %14
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = fcmp ogt double %13, %14
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %9, %6, %12, %16, %3
%20 = phi i32 [ 0, %3 ], [ 1, %9 ], [ 1, %6 ], [ %18, %16 ], [ -1, %12 ]
ret i32 %20
}