#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 M_2_PI;
double S(int, double, double);
double asinh(double);
double ftrans(double);
int log(int);
double sinc_approx(int N, double d, double mu, double t) {
  int k;
  double h = log(4 * d * N / mu) / N;
  double x = asinh(M_2_PI * asinh(t));
  double val = 0;
  for (k = N; k > 0; k--) {
    val += ftrans(k * h) * S(k, h, x);
    val += ftrans(-k * h) * S(-k, h, x);
  }
  val += ftrans(0 * h) * S(0, h, x);
  return val;
}


x86 assembly (clang, -O0):
<sinc_approx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  0xe9e(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <log@plt>
cltd
idivl  -0x4(%rbp)
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    0x2e46(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1060 <asinh@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1060 <asinh@plt>
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    1267 <sinc_approx+0x127>
cvtsi2sdl -0x24(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1030 <ftrans@plt>
movsd  %xmm0,-0x58(%rbp)
mov    -0x24(%rbp),%edi
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
call   1040 <S@plt>
movaps %xmm0,%xmm2
movsd  -0x58(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
xor    %eax,%eax
sub    -0x24(%rbp),%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1030 <ftrans@plt>
movsd  %xmm0,-0x50(%rbp)
xor    %edi,%edi
sub    -0x24(%rbp),%edi
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
call   1040 <S@plt>
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    11c9 <sinc_approx+0x89>
xorps  %xmm0,%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1030 <ftrans@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
xor    %edi,%edi
call   1040 <S@plt>
movaps %xmm0,%xmm2
movsd  -0x60(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sinc_approx>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
movsd  %xmm2,0x20(%rsp)
mov    %edi,%ebx
mulsd  0xeaa(%rip),%xmm0
xorps  %xmm2,%xmm2
cvtsi2sd %edi,%xmm2
mulsd  %xmm0,%xmm2
divsd  %xmm1,%xmm2
cvttsd2si %xmm2,%edi
call   1050 <log@plt>
cltd
idiv   %ebx
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    0x2e53(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
call   1060 <asinh@plt>
mulsd  0x8(%rsp),%xmm0
call   1060 <asinh@plt>
movsd  %xmm0,0x20(%rsp)
xorpd  %xmm0,%xmm0
test   %ebx,%ebx
jle    124b <sinc_approx+0x10b>
mov    %ebx,%ebp
neg    %ebp
xorpd  %xmm0,%xmm0
nop
movsd  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0x10(%rsp),%xmm0
call   1030 <ftrans@plt>
movsd  %xmm0,0x18(%rsp)
mov    %ebx,%edi
movsd  0x10(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1040 <S@plt>
mulsd  0x18(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0x10(%rsp),%xmm0
call   1030 <ftrans@plt>
movsd  %xmm0,0x18(%rsp)
mov    %ebp,%edi
movsd  0x10(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1040 <S@plt>
mulsd  0x18(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
lea    -0x1(%rbx),%eax
add    $0x1,%ebp
cmp    $0x1,%ebx
mov    %eax,%ebx
ja     11c0 <sinc_approx+0x80>
movsd  %xmm0,0x8(%rsp)
xorpd  %xmm0,%xmm0
mulsd  0x10(%rsp),%xmm0
call   1030 <ftrans@plt>
movsd  %xmm0,0x18(%rsp)
xor    %edi,%edi
movsd  0x10(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1040 <S@plt>
mulsd  0x18(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@M_2_PI = global double 0.000000e+00
define double @sinc_approx(i32 %0, double %1, double %2, double %3) {
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double
store i32 %0, i32* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%13 = load double, double* %6
%14 = fmul double 4.000000e+00, %13
%15 = load i32, i32* %5
%16 = sitofp i32 %15 to double
%17 = fmul double %14, %16
%18 = load double, double* %7
%19 = fdiv double %17, %18
%20 = fptosi double %19 to i32
%21 = call i32 @log(i32 %20)
%22 = load i32, i32* %5
%23 = sdiv i32 %21, %22
%24 = sitofp i32 %23 to double
store double %24, double* %10
%25 = load double, double* @M_2_PI
%26 = load double, double* %8
%27 = call double @asinh(double %26)
%28 = fmul double %25, %27
%29 = call double @asinh(double %28)
store double %29, double* %11
store double 0.000000e+00, double* %12
%30 = load i32, i32* %5
store i32 %30, i32* %9
br label %31
31: ; preds = %59, %4
%32 = load i32, i32* %9
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %62
34: ; preds = %31
%35 = load i32, i32* %9
%36 = sitofp i32 %35 to double
%37 = load double, double* %10
%38 = fmul double %36, %37
%39 = call double @ftrans(double %38)
%40 = load i32, i32* %9
%41 = load double, double* %10
%42 = load double, double* %11
%43 = call double @S(i32 %40, double %41, double %42)
%44 = load double, double* %12
%45 = call double @llvm.fmuladd.f64(double %39, double %43, double %44)
store double %45, double* %12
%46 = load i32, i32* %9
%47 = sub nsw i32 0, %46
%48 = sitofp i32 %47 to double
%49 = load double, double* %10
%50 = fmul double %48, %49
%51 = call double @ftrans(double %50)
%52 = load i32, i32* %9
%53 = sub nsw i32 0, %52
%54 = load double, double* %10
%55 = load double, double* %11
%56 = call double @S(i32 %53, double %54, double %55)
%57 = load double, double* %12
%58 = call double @llvm.fmuladd.f64(double %51, double %56, double %57)
store double %58, double* %12
br label %59
59: ; preds = %34
%60 = load i32, i32* %9
%61 = add nsw i32 %60, -1
store i32 %61, i32* %9
br label %31
62: ; preds = %31
%63 = load double, double* %10
%64 = fmul double 0.000000e+00, %63
%65 = call double @ftrans(double %64)
%66 = load double, double* %10
%67 = load double, double* %11
%68 = call double @S(i32 0, double %66, double %67)
%69 = load double, double* %12
%70 = call double @llvm.fmuladd.f64(double %65, double %68, double %69)
store double %70, double* %12
%71 = load double, double* %12
ret double %71
}

LLVM IR (-O2):
@M_2_PI = global double 0.000000e+00
define double @sinc_approx(i32 %0, double %1, double %2, double %3) {
%5 = fmul double %1, 4.000000e+00
%6 = sitofp i32 %0 to double
%7 = fmul double %5, %6
%8 = fdiv double %7, %2
%9 = fptosi double %8 to i32
%10 = tail call i32 @log(i32 %9)
%11 = sdiv i32 %10, %0
%12 = sitofp i32 %11 to double
%13 = load double, double* @M_2_PI
%14 = tail call double @asinh(double %3)
%15 = fmul double %13, %14
%16 = tail call double @asinh(double %15)
%17 = icmp sgt i32 %0, 0
br i1 %17, label %18, label %34
18: ; preds = %4, %18
%19 = phi double [ %31, %18 ], [ 0.000000e+00, %4 ]
%20 = phi i32 [ %32, %18 ], [ %0, %4 ]
%21 = sitofp i32 %20 to double
%22 = fmul double %12, %21
%23 = tail call double @ftrans(double %22)
%24 = tail call double @S(i32 %20, double %12, double %16)
%25 = tail call double @llvm.fmuladd.f64(double %23, double %24, double %19)
%26 = sub nsw i32 0, %20
%27 = sitofp i32 %26 to double
%28 = fmul double %12, %27
%29 = tail call double @ftrans(double %28)
%30 = tail call double @S(i32 %26, double %12, double %16)
%31 = tail call double @llvm.fmuladd.f64(double %29, double %30, double %25)
%32 = add nsw i32 %20, -1
%33 = icmp ugt i32 %20, 1
br i1 %33, label %18, label %34
34: ; preds = %18, %4
%35 = phi double [ 0.000000e+00, %4 ], [ %31, %18 ]
%36 = fmul double %12, 0.000000e+00
%37 = tail call double @ftrans(double %36)
%38 = tail call double @S(i32 0, double %12, double %16)
%39 = tail call double @llvm.fmuladd.f64(double %37, double %38, double %35)
ret double %39
}