#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 floor(double);
double fmod(double, double);
double sin(double);
double sinc(double x) {
  double xm, val;
  xm = .0;
  if (x == 0.0)
    val = 1.0;
  else {
    val = sin(3.14159265358979323846 * xm) / (3.14159265358979323846 * x);
    xm = fmod(x, 2.0);
    if (x == floor(x))
      val = 0.0;
    else
      val = sin(3.14159265358979323846 * xm) / (3.14159265358979323846 * x);
  }
  return val;
}


x86 assembly (clang, -O0):
<sinc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    116f <sinc+0x3f>
jp     116f <sinc+0x3f>
movsd  0xeab(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1214 <sinc+0xe4>
movsd  0xe91(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1040 <sin@plt>
movsd  0xe7f(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe5c(%rip),%xmm1
call   1030 <fmod@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jne    11e7 <sinc+0xb7>
jp     11e7 <sinc+0xb7>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    120f <sinc+0xdf>
movsd  0xe19(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1040 <sin@plt>
movsd  0xe07(%rip),%xmm1
mulsd  -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1214 <sinc+0xe4>
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sinc>:
sub    $0x18,%rsp
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    114a <sinc+0x1a>
jp     114a <sinc+0x1a>
movsd  0xeb8(%rip),%xmm2
jmp    11ab <sinc+0x7b>
movsd  0xeb6(%rip),%xmm1
movsd  %xmm0,0x8(%rsp)
call   1030 <fmod@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <floor@plt>
xorpd  %xmm2,%xmm2
movsd  0x8(%rsp),%xmm1
ucomisd %xmm1,%xmm0
jne    1180 <sinc+0x50>
jnp    11ab <sinc+0x7b>
movsd  0xe88(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  %xmm2,%xmm0
call   1040 <sin@plt>
movapd %xmm0,%xmm2
divsd  0x8(%rsp),%xmm2
movapd %xmm2,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @sinc(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
store double %0, double* %2
store double 0.000000e+00, double* %3
%5 = load double, double* %2
%6 = fcmp oeq double %5, 0.000000e+00
br i1 %6, label %7, label %8
7: ; preds = %1
store double 1.000000e+00, double* %4
br label %30
8: ; preds = %1
%9 = load double, double* %3
%10 = fmul double 0x400921FB54442D18, %9
%11 = call double @sin(double %10)
%12 = load double, double* %2
%13 = fmul double 0x400921FB54442D18, %12
%14 = fdiv double %11, %13
store double %14, double* %4
%15 = load double, double* %2
%16 = call double @fmod(double %15, double 2.000000e+00)
store double %16, double* %3
%17 = load double, double* %2
%18 = load double, double* %2
%19 = call double @llvm.floor.f64(double %18)
%20 = fcmp oeq double %17, %19
br i1 %20, label %21, label %22
21: ; preds = %8
store double 0.000000e+00, double* %4
br label %29
22: ; preds = %8
%23 = load double, double* %3
%24 = fmul double 0x400921FB54442D18, %23
%25 = call double @sin(double %24)
%26 = load double, double* %2
%27 = fmul double 0x400921FB54442D18, %26
%28 = fdiv double %25, %27
store double %28, double* %4
br label %29
29: ; preds = %22, %21
br label %30
30: ; preds = %29, %7
%31 = load double, double* %4
ret double %31
}

LLVM IR (-O2):
define double @sinc(double %0) {
%2 = fcmp oeq double %0, 0.000000e+00
br i1 %2, label %12, label %3
3: ; preds = %1
%4 = tail call double @fmod(double %0, double 2.000000e+00)
%5 = tail call double @llvm.floor.f64(double %0)
%6 = fcmp oeq double %5, %0
br i1 %6, label %12, label %7
7: ; preds = %3
%8 = fmul double %0, 0x400921FB54442D18
%9 = fmul double %4, 0x400921FB54442D18
%10 = tail call double @sin(double %9)
%11 = fdiv double %10, %8
br label %12
12: ; preds = %3, %1, %7
%13 = phi double [ %11, %7 ], [ 1.000000e+00, %1 ], [ 0.000000e+00, %3 ]
ret double %13
}