double finv(x)
double x;
{
  if (x >= ((double)1.0e+19))
    return 0.0;
  if (x <= -((double)1.0e+19))
    return 0.0;
  if (x <= ((double)1.0e-19) && x >= 0)
    return ((double)1.0e+38);
  if (x >= -((double)1.0e-19) && x < 0)
    return -((double)1.0e+38);
  return 1.0 / x;
}


x86 assembly (clang, -O0):
<finv>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xeea(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     112d <finv+0x2d>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11cd <finv+0xcd>
movsd  0xed3(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     114d <finv+0x4d>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11cd <finv+0xcd>
movsd  0xebb(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1184 <finv+0x84>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1184 <finv+0x84>
movsd  0xeb6(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11cd <finv+0xcd>
movsd  -0x10(%rbp),%xmm0
movsd  0xe87(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11bb <finv+0xbb>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11bb <finv+0xbb>
movsd  0xe77(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11cd <finv+0xcd>
movsd  0xe5d(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<finv>:
ucomisd 0xef8(%rip),%xmm0
xorpd  %xmm1,%xmm1
jae    1166 <finv+0x66>
movsd  0xef2(%rip),%xmm2
ucomisd %xmm0,%xmm2
jae    1166 <finv+0x66>
movsd  0xeec(%rip),%xmm1
ucomisd %xmm0,%xmm1
jb     113d <finv+0x3d>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     113d <finv+0x3d>
movsd  0xedc(%rip),%xmm0
ret
ucomisd 0xedb(%rip),%xmm0
jb     115a <finv+0x5a>
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    115a <finv+0x5a>
movsd  0xecf(%rip),%xmm0
ret
movsd  0xece(%rip),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @finv(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp oge double %4, 1.000000e+19
br i1 %5, label %6, label %7
6: ; preds = %1
store double 0.000000e+00, double* %2
br label %28
7: ; preds = %1
%8 = load double, double* %3
%9 = fcmp ole double %8, -1.000000e+19
br i1 %9, label %10, label %11
10: ; preds = %7
store double 0.000000e+00, double* %2
br label %28
11: ; preds = %7
%12 = load double, double* %3
%13 = fcmp ole double %12, 0x3BFD83C94FB6D2AC
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = load double, double* %3
%16 = fcmp oge double %15, 0.000000e+00
br i1 %16, label %17, label %18
17: ; preds = %14
store double 0x47D2CED32A16A1B1, double* %2
br label %28
18: ; preds = %14, %11
%19 = load double, double* %3
%20 = fcmp oge double %19, 0xBBFD83C94FB6D2AC
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = load double, double* %3
%23 = fcmp olt double %22, 0.000000e+00
br i1 %23, label %24, label %25
24: ; preds = %21
store double 0xC7D2CED32A16A1B1, double* %2
br label %28
25: ; preds = %21, %18
%26 = load double, double* %3
%27 = fdiv double 1.000000e+00, %26
store double %27, double* %2
br label %28
28: ; preds = %25, %24, %17, %10, %6
%29 = load double, double* %2
ret double %29
}

LLVM IR (-O2):
define double @finv(double %0) {
%2 = fcmp ult double %0, 1.000000e+19
%3 = fcmp ugt double %0, -1.000000e+19
%4 = and i1 %2, %3
br i1 %4, label %5, label %15
5: ; preds = %1
%6 = fcmp ole double %0, 0x3BFD83C94FB6D2AC
%7 = fcmp oge double %0, 0.000000e+00
%8 = and i1 %6, %7
br i1 %8, label %15, label %9
9: ; preds = %5
%10 = fcmp oge double %0, 0xBBFD83C94FB6D2AC
%11 = fcmp olt double %0, 0.000000e+00
%12 = and i1 %10, %11
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = fdiv double 1.000000e+00, %0
br label %15
15: ; preds = %9, %5, %1, %13
%16 = phi double [ %14, %13 ], [ 0.000000e+00, %1 ], [ 0x47D2CED32A16A1B1, %5 ], [ 0xC7D2CED32A16A1B1, %9 ]
ret double %16
}