#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 __builtin_inf();
double fabs(long double);
scalar_t__ isinf(double);
scalar_t__ sign(double);
long double ulp(long double);
scalar_t__ xisnan(double);
double countULP(long double x, long double y) {
  double fx = x;
  double fy = y;
  if (xisnan(fx) && xisnan(fy))
    return 0;
  if (xisnan(fx) || xisnan(fy))
    return 10000;
  if (isinf(fx)) {
    if (sign(fx) == sign(fy) && fabs(fy) > 1e+300)
      return 0;
    return 10001;
  }
  if (fx == __builtin_inf() && fy == __builtin_inf())
    return 0;
  if (fx == (-__builtin_inf()) && fy == (-__builtin_inf()))
    return 0;
  if (fy == 0) {
    if (fx == 0)
      return 0;
    return 10002;
  }
  if (!xisnan(fx) && !xisnan(fy) && !isinf(fx) && !isinf(fy)) {
    return fabs((x - y) / ulp(y));
  }
  return 10003;
}


x86 assembly (clang, -O0):
<countULP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
fldt   0x20(%rbp)
fldt   0x10(%rbp)
fstpt  -0x20(%rbp)
fstpt  -0x30(%rbp)
fldt   -0x20(%rbp)
fstpl  -0x38(%rbp)
fldt   -0x30(%rbp)
fstpl  -0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <xisnan@plt>
cmp    $0x0,%rax
je     11af <countULP+0x5f>
movsd  -0x40(%rbp),%xmm0
call   1030 <xisnan@plt>
cmp    $0x0,%rax
je     11af <countULP+0x5f>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    13cd <countULP+0x27d>
movsd  -0x38(%rbp),%xmm0
call   1030 <xisnan@plt>
cmp    $0x0,%rax
jne    11d7 <countULP+0x87>
movsd  -0x40(%rbp),%xmm0
call   1030 <xisnan@plt>
cmp    $0x0,%rax
je     11e9 <countULP+0x99>
movsd  0xe51(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    13cd <countULP+0x27d>
movsd  -0x38(%rbp),%xmm0
call   1070 <isinf@plt>
cmp    $0x0,%rax
je     1263 <countULP+0x113>
movsd  -0x38(%rbp),%xmm0
call   1060 <sign@plt>
mov    %rax,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1060 <sign@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
cmp    %rcx,%rax
jne    1251 <countULP+0x101>
fldl   -0x40(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <fabs@plt>
movsd  0xde6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1251 <countULP+0x101>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    13cd <countULP+0x27d>
movsd  0xdcf(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    13cd <countULP+0x27d>
movsd  -0x38(%rbp),%xmm0
movsd  0xd90(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    12aa <countULP+0x15a>
jp     12aa <countULP+0x15a>
movsd  -0x40(%rbp),%xmm0
movsd  0xd73(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    12aa <countULP+0x15a>
jp     12aa <countULP+0x15a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    13cd <countULP+0x27d>
movsd  -0x38(%rbp),%xmm0
movsd  0xd51(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    12f1 <countULP+0x1a1>
jp     12f1 <countULP+0x1a1>
movsd  -0x40(%rbp),%xmm0
movsd  0xd34(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    12f1 <countULP+0x1a1>
jp     12f1 <countULP+0x1a1>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    13cd <countULP+0x27d>
movsd  -0x40(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1340 <countULP+0x1f0>
jp     1340 <countULP+0x1f0>
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    132e <countULP+0x1de>
jp     132e <countULP+0x1de>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    13cd <countULP+0x27d>
movsd  0xce2(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    13cd <countULP+0x27d>
movsd  -0x38(%rbp),%xmm0
call   1030 <xisnan@plt>
cmp    $0x0,%rax
jne    13c0 <countULP+0x270>
movsd  -0x40(%rbp),%xmm0
call   1030 <xisnan@plt>
cmp    $0x0,%rax
jne    13c0 <countULP+0x270>
movsd  -0x38(%rbp),%xmm0
call   1070 <isinf@plt>
cmp    $0x0,%rax
jne    13c0 <countULP+0x270>
movsd  -0x40(%rbp),%xmm0
call   1070 <isinf@plt>
cmp    $0x0,%rax
jne    13c0 <countULP+0x270>
fldt   -0x20(%rbp)
fldt   -0x30(%rbp)
fsubr  %st,%st(1)
fxch   %st(1)
fstpt  -0x5c(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1050 <ulp@plt>
fldt   -0x5c(%rbp)
fdivp  %st,%st(1)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <fabs@plt>
movsd  %xmm0,-0x8(%rbp)
jmp    13cd <countULP+0x27d>
movsd  0xc48(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<countULP>:
push   %rbx
sub    $0x60,%rsp
fldt   0x80(%rsp)
fldt   0x70(%rsp)
fld    %st(0)
fstpt  0x48(%rsp)
fstpl  0x40(%rsp)
movsd  0x40(%rsp),%xmm0
fld    %st(0)
fstpt  0x54(%rsp)
fstpl  0x38(%rsp)
movsd  0x38(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
movapd %xmm0,0x20(%rsp)
call   1030 <xisnan@plt>
test   %rax,%rax
je     11ae <countULP+0x5e>
movsd  0x10(%rsp),%xmm0
call   1030 <xisnan@plt>
xorpd  %xmm2,%xmm2
test   %rax,%rax
jne    12c2 <countULP+0x172>
movapd 0x20(%rsp),%xmm0
call   1030 <xisnan@plt>
movsd  0xe3f(%rip),%xmm2
test   %rax,%rax
jne    12c2 <countULP+0x172>
movsd  0x10(%rsp),%xmm0
call   1030 <xisnan@plt>
movsd  0xe23(%rip),%xmm2
test   %rax,%rax
jne    12c2 <countULP+0x172>
movapd 0x20(%rsp),%xmm0
call   1070 <isinf@plt>
test   %rax,%rax
je     1247 <countULP+0xf7>
movaps 0x20(%rsp),%xmm0
call   1060 <sign@plt>
mov    %rax,%rbx
movsd  0x10(%rsp),%xmm0
call   1060 <sign@plt>
cmp    %rax,%rbx
jne    123d <countULP+0xed>
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x30(%rsp)
fldl   0x30(%rsp)
fstpt  (%rsp)
call   1040 <fabs@plt>
xorpd  %xmm2,%xmm2
ucomisd 0xdd1(%rip),%xmm0
ja     12c2 <countULP+0x172>
movsd  0xdcb(%rip),%xmm2
jmp    12c2 <countULP+0x172>
movapd 0x20(%rsp),%xmm1
ucomisd 0xdc3(%rip),%xmm1
xorpd  %xmm2,%xmm2
jb     126b <countULP+0x11b>
movsd  0x10(%rsp),%xmm0
ucomisd 0xdaf(%rip),%xmm0
jae    12c2 <countULP+0x172>
movsd  0xdad(%rip),%xmm0
ucomisd %xmm1,%xmm0
movsd  0x10(%rsp),%xmm1
jb     1285 <countULP+0x135>
ucomisd %xmm1,%xmm0
jae    12c2 <countULP+0x172>
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    12aa <countULP+0x15a>
jp     12aa <countULP+0x15a>
movapd 0x20(%rsp),%xmm2
cmpeqsd %xmm0,%xmm2
movsd  0xd8c(%rip),%xmm0
andnpd %xmm0,%xmm2
jmp    12c2 <countULP+0x172>
movapd 0x20(%rsp),%xmm0
call   1030 <xisnan@plt>
movsd  0xd6b(%rip),%xmm2
test   %rax,%rax
je     12cc <countULP+0x17c>
movapd %xmm2,%xmm0
add    $0x60,%rsp
pop    %rbx
ret
movsd  0x10(%rsp),%xmm0
call   1030 <xisnan@plt>
test   %rax,%rax
jne    12eb <countULP+0x19b>
movaps 0x20(%rsp),%xmm0
call   1070 <isinf@plt>
test   %rax,%rax
je     12f5 <countULP+0x1a5>
movsd  0xd35(%rip),%xmm0
jmp    12c6 <countULP+0x176>
movsd  0x10(%rsp),%xmm0
call   1070 <isinf@plt>
test   %rax,%rax
movsd  0xd1d(%rip),%xmm2
jne    12c2 <countULP+0x172>
fldt   0x54(%rsp)
fldt   0x48(%rsp)
fsub   %st(1),%st
fstpt  0x10(%rsp)
fstpt  (%rsp)
call   1050 <ulp@plt>
fldt   0x10(%rsp)
fdivp  %st,%st(1)
fstpt  (%rsp)
call   1040 <fabs@plt>
jmp    12c6 <countULP+0x176>

LLVM IR (-O0):
define double @countULP(x86_fp80 %0, x86_fp80 %1) {
%3 = alloca double
%4 = alloca x86_fp80
%5 = alloca x86_fp80
%6 = alloca double
%7 = alloca double
store x86_fp80 %0, x86_fp80* %4
store x86_fp80 %1, x86_fp80* %5
%8 = load x86_fp80, x86_fp80* %4
%9 = fptrunc x86_fp80 %8 to double
store double %9, double* %6
%10 = load x86_fp80, x86_fp80* %5
%11 = fptrunc x86_fp80 %10 to double
store double %11, double* %7
%12 = load double, double* %6
%13 = call i64 @xisnan(double %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load double, double* %7
%17 = call i64 @xisnan(double %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
store double 0.000000e+00, double* %3
br label %93
20: ; preds = %15, %2
%21 = load double, double* %6
%22 = call i64 @xisnan(double %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %20
%25 = load double, double* %7
%26 = call i64 @xisnan(double %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %24, %20
store double 1.000000e+04, double* %3
br label %93
29: ; preds = %24
%30 = load double, double* %6
%31 = call i64 @isinf(double %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %46
33: ; preds = %29
%34 = load double, double* %6
%35 = call i64 @sign(double %34)
%36 = load double, double* %7
%37 = call i64 @sign(double %36)
%38 = icmp eq i64 %35, %37
br i1 %38, label %39, label %45
39: ; preds = %33
%40 = load double, double* %7
%41 = fpext double %40 to x86_fp80
%42 = call double @fabs(x86_fp80 %41)
%43 = fcmp ogt double %42, 1.000000e+300
br i1 %43, label %44, label %45
44: ; preds = %39
store double 0.000000e+00, double* %3
br label %93
45: ; preds = %39, %33
store double 1.000100e+04, double* %3
br label %93
46: ; preds = %29
%47 = load double, double* %6
%48 = fcmp oeq double %47, 0x7FF0000000000000
br i1 %48, label %49, label %53
49: ; preds = %46
%50 = load double, double* %7
%51 = fcmp oeq double %50, 0x7FF0000000000000
br i1 %51, label %52, label %53
52: ; preds = %49
store double 0.000000e+00, double* %3
br label %93
53: ; preds = %49, %46
%54 = load double, double* %6
%55 = fcmp oeq double %54, 0xFFF0000000000000
br i1 %55, label %56, label %60
56: ; preds = %53
%57 = load double, double* %7
%58 = fcmp oeq double %57, 0xFFF0000000000000
br i1 %58, label %59, label %60
59: ; preds = %56
store double 0.000000e+00, double* %3
br label %93
60: ; preds = %56, %53
%61 = load double, double* %7
%62 = fcmp oeq double %61, 0.000000e+00
br i1 %62, label %63, label %68
63: ; preds = %60
%64 = load double, double* %6
%65 = fcmp oeq double %64, 0.000000e+00
br i1 %65, label %66, label %67
66: ; preds = %63
store double 0.000000e+00, double* %3
br label %93
67: ; preds = %63
store double 1.000200e+04, double* %3
br label %93
68: ; preds = %60
%69 = load double, double* %6
%70 = call i64 @xisnan(double %69)
%71 = icmp ne i64 %70, 0
br i1 %71, label %92, label %72
72: ; preds = %68
%73 = load double, double* %7
%74 = call i64 @xisnan(double %73)
%75 = icmp ne i64 %74, 0
br i1 %75, label %92, label %76
76: ; preds = %72
%77 = load double, double* %6
%78 = call i64 @isinf(double %77)
%79 = icmp ne i64 %78, 0
br i1 %79, label %92, label %80
80: ; preds = %76
%81 = load double, double* %7
%82 = call i64 @isinf(double %81)
%83 = icmp ne i64 %82, 0
br i1 %83, label %92, label %84
84: ; preds = %80
%85 = load x86_fp80, x86_fp80* %4
%86 = load x86_fp80, x86_fp80* %5
%87 = fsub x86_fp80 %85, %86
%88 = load x86_fp80, x86_fp80* %5
%89 = call x86_fp80 @ulp(x86_fp80 %88)
%90 = fdiv x86_fp80 %87, %89
%91 = call double @fabs(x86_fp80 %90)
store double %91, double* %3
br label %93
92: ; preds = %80, %76, %72, %68
store double 1.000300e+04, double* %3
br label %93
93: ; preds = %92, %84, %67, %66, %59, %52, %45, %44, %28, %19
%94 = load double, double* %3
ret double %94
}

LLVM IR (-O2):
define double @countULP(x86_fp80 %0, x86_fp80 %1) {
%3 = fptrunc x86_fp80 %0 to double
%4 = fptrunc x86_fp80 %1 to double
%5 = tail call i64 @xisnan(double %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = tail call i64 @xisnan(double %4)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %58
10: ; preds = %7, %2
%11 = tail call i64 @xisnan(double %3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %58
13: ; preds = %10
%14 = tail call i64 @xisnan(double %4)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %58
16: ; preds = %13
%17 = tail call i64 @isinf(double %3)
%18 = icmp eq i64 %17, 0
br i1 %18, label %28, label %19
19: ; preds = %16
%20 = tail call i64 @sign(double %3)
%21 = tail call i64 @sign(double %4)
%22 = icmp eq i64 %20, %21
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = fpext double %4 to x86_fp80
%25 = tail call double @fabs(x86_fp80 %24)
%26 = fcmp ogt double %25, 1.000000e+300
br i1 %26, label %58, label %27
27: ; preds = %23, %19
br label %58
28: ; preds = %16
%29 = fcmp oeq double %3, 0x7FF0000000000000
%30 = fcmp oeq double %4, 0x7FF0000000000000
%31 = and i1 %29, %30
br i1 %31, label %58, label %32
32: ; preds = %28
%33 = fcmp oeq double %3, 0xFFF0000000000000
%34 = fcmp oeq double %4, 0xFFF0000000000000
%35 = and i1 %33, %34
br i1 %35, label %58, label %36
36: ; preds = %32
%37 = fcmp oeq double %4, 0.000000e+00
br i1 %37, label %38, label %41
38: ; preds = %36
%39 = fcmp oeq double %3, 0.000000e+00
%40 = select i1 %39, double 0.000000e+00, double 1.000200e+04
br label %58
41: ; preds = %36
%42 = tail call i64 @xisnan(double %3)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %58
44: ; preds = %41
%45 = tail call i64 @xisnan(double %4)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %58
47: ; preds = %44
%48 = tail call i64 @isinf(double %3)
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %58
50: ; preds = %47
%51 = tail call i64 @isinf(double %4)
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %58
53: ; preds = %50
%54 = fsub x86_fp80 %0, %1
%55 = tail call x86_fp80 @ulp(x86_fp80 %1)
%56 = fdiv x86_fp80 %54, %55
%57 = tail call double @fabs(x86_fp80 %56)
br label %58
58: ; preds = %41, %44, %47, %50, %38, %32, %28, %23, %10, %13, %7, %53, %27
%59 = phi double [ 1.000100e+04, %27 ], [ %57, %53 ], [ 0.000000e+00, %7 ], [ 1.000000e+04, %13 ], [ 1.000000e+04, %10 ], [ 0.000000e+00, %23 ], [ 0.000000e+00, %28 ], [ 0.000000e+00, %32 ], [ %40, %38 ], [ 1.000300e+04, %50 ], [ 1.000300e+04, %47 ], [ 1.000300e+04, %44 ], [ 1.000300e+04, %41 ]
ret double %59
}