#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 DBL_EPSILON;
double fabs(double);
double sin(double);
double sqrt(double const);
double sinc(double x) {
  const double taylor_0_bound = DBL_EPSILON;
  const double taylor_2_bound = sqrt(taylor_0_bound);
  const double taylor_n_bound = sqrt(taylor_2_bound);
  double abs_x = fabs(x);
  if (abs_x >= taylor_n_bound) {
    return sin(x) / x;
  } else {
    double result = 1;
    if (abs_x >= taylor_0_bound) {
      double x_squared = x * x;
      result -= x_squared / 6;
      if (abs_x >= taylor_2_bound) {
        result += (x_squared * x_squared) / 120;
      }
    }
    return result;
  }
}


x86 assembly (clang, -O0):
<sinc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    0x2eb4(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xe99(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     1199 <sinc+0x79>
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1223 <sinc+0x103>
movsd  0xe6f(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     1219 <sinc+0xf9>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm1
movsd  0xe46(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     1214 <sinc+0xf4>
movsd  -0x40(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  0xe1a(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1219 <sinc+0xf9>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sinc>:
sub    $0x28,%rsp
mov    0x2ebd(%rip),%rax
movsd  (%rax),%xmm1
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
movapd %xmm0,(%rsp)
movsd  %xmm1,0x20(%rsp)
jb     1165 <sinc+0x45>
sqrtsd %xmm1,%xmm3
ucomisd %xmm2,%xmm3
jae    117c <sinc+0x5c>
movapd %xmm3,%xmm0
movsd  %xmm3,0x18(%rsp)
call   1040 <sqrt@plt>
movsd  0x18(%rsp),%xmm3
jmp    1183 <sinc+0x63>
movapd %xmm1,%xmm0
call   1040 <sqrt@plt>
xorpd  %xmm2,%xmm2
movapd %xmm0,%xmm3
ucomisd %xmm2,%xmm3
jb     114e <sinc+0x2e>
xorps  %xmm0,%xmm0
sqrtsd %xmm3,%xmm0
movapd (%rsp),%xmm2
movapd 0xe70(%rip),%xmm1
andpd  %xmm2,%xmm1
ucomisd %xmm0,%xmm1
jae    11af <sinc+0x8f>
ucomisd 0x20(%rsp),%xmm1
jae    11c2 <sinc+0xa2>
movsd  0xe66(%rip),%xmm0
add    $0x28,%rsp
ret
movapd %xmm2,%xmm0
call   1030 <sin@plt>
divsd  (%rsp),%xmm0
add    $0x28,%rsp
ret
mulsd  %xmm2,%xmm2
movapd %xmm2,%xmm0
divsd  0xe46(%rip),%xmm0
addsd  0xe36(%rip),%xmm0
ucomisd %xmm3,%xmm1
jb     11f0 <sinc+0xd0>
mulsd  %xmm2,%xmm2
divsd  0xe34(%rip),%xmm2
addsd  %xmm2,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
@DBL_EPSILON = global double 0.000000e+00
define double @sinc(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %0, double* %3
%10 = load double, double* @DBL_EPSILON
store double %10, double* %4
%11 = load double, double* %4
%12 = call double @sqrt(double %11)
store double %12, double* %5
%13 = load double, double* %5
%14 = call double @sqrt(double %13)
store double %14, double* %6
%15 = load double, double* %3
%16 = call double @llvm.fabs.f64(double %15)
store double %16, double* %7
%17 = load double, double* %7
%18 = load double, double* %6
%19 = fcmp oge double %17, %18
br i1 %19, label %20, label %25
20: ; preds = %1
%21 = load double, double* %3
%22 = call double @sin(double %21)
%23 = load double, double* %3
%24 = fdiv double %22, %23
store double %24, double* %2
br label %50
25: ; preds = %1
store double 1.000000e+00, double* %8
%26 = load double, double* %7
%27 = load double, double* %4
%28 = fcmp oge double %26, %27
br i1 %28, label %29, label %48
29: ; preds = %25
%30 = load double, double* %3
%31 = load double, double* %3
%32 = fmul double %30, %31
store double %32, double* %9
%33 = load double, double* %9
%34 = fdiv double %33, 6.000000e+00
%35 = load double, double* %8
%36 = fsub double %35, %34
store double %36, double* %8
%37 = load double, double* %7
%38 = load double, double* %5
%39 = fcmp oge double %37, %38
br i1 %39, label %40, label %47
40: ; preds = %29
%41 = load double, double* %9
%42 = load double, double* %9
%43 = fmul double %41, %42
%44 = fdiv double %43, 1.200000e+02
%45 = load double, double* %8
%46 = fadd double %45, %44
store double %46, double* %8
br label %47
47: ; preds = %40, %29
br label %48
48: ; preds = %47, %25
%49 = load double, double* %8
store double %49, double* %2
br label %50
50: ; preds = %48, %20
%51 = load double, double* %2
ret double %51
}

LLVM IR (-O2):
@DBL_EPSILON = global double 0.000000e+00
define double @sinc(double %0) {
%2 = load double, double* @DBL_EPSILON
%3 = tail call double @sqrt(double %2)
%4 = tail call double @sqrt(double %3)
%5 = tail call double @llvm.fabs.f64(double %0)
%6 = fcmp ult double %5, %4
br i1 %6, label %10, label %7
7: ; preds = %1
%8 = tail call double @sin(double %0)
%9 = fdiv double %8, %0
br label %21
10: ; preds = %1
%11 = fcmp ult double %5, %2
br i1 %11, label %21, label %12
12: ; preds = %10
%13 = fmul double %0, %0
%14 = fdiv double %13, 6.000000e+00
%15 = fsub double 1.000000e+00, %14
%16 = fcmp ult double %5, %3
br i1 %16, label %21, label %17
17: ; preds = %12
%18 = fmul double %13, %13
%19 = fdiv double %18, 1.200000e+02
%20 = fadd double %15, %19
br label %21
21: ; preds = %10, %17, %12, %7
%22 = phi double [ %9, %7 ], [ 1.000000e+00, %10 ], [ %20, %17 ], [ %15, %12 ]
ret double %22
}