#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 */
int M_2_PI;
double S(int, double, double);
double asinh(int);
int expm1(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 * log(expm1(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  0xe8e(%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    0x2e36(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1060 <expm1@plt>
mov    %eax,%edi
call   1050 <log@plt>
mov    -0x44(%rbp),%edi
imul   %eax,%edi
call   1070 <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    1274 <sinc_approx+0x124>
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    11d6 <sinc_approx+0x86>
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  0xe9a(%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,0x8(%rsp)
mov    0x2e43(%rip),%rax
mov    (%rax),%ebp
movsd  0x20(%rsp),%xmm0
call   1060 <expm1@plt>
mov    %eax,%edi
call   1050 <log@plt>
imul   %eax,%ebp
mov    %ebp,%edi
call   1070 <asinh@plt>
movsd  %xmm0,0x20(%rsp)
xorpd  %xmm0,%xmm0
test   %ebx,%ebx
jle    125b <sinc_approx+0x10b>
mov    %ebx,%ebp
neg    %ebp
xorpd  %xmm0,%xmm0
nopl   (%rax)
movsd  %xmm0,0x18(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0x8(%rsp),%xmm0
call   1030 <ftrans@plt>
movsd  %xmm0,0x10(%rsp)
mov    %ebx,%edi
movsd  0x8(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1040 <S@plt>
mulsd  0x10(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0x8(%rsp),%xmm0
call   1030 <ftrans@plt>
movsd  %xmm0,0x10(%rsp)
mov    %ebp,%edi
movsd  0x8(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1040 <S@plt>
mulsd  0x10(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
lea    -0x1(%rbx),%eax
add    $0x1,%ebp
cmp    $0x1,%ebx
mov    %eax,%ebx
ja     11d0 <sinc_approx+0x80>
movsd  %xmm0,0x18(%rsp)
xorpd  %xmm0,%xmm0
mulsd  0x8(%rsp),%xmm0
call   1030 <ftrans@plt>
movsd  %xmm0,0x10(%rsp)
xor    %edi,%edi
movsd  0x8(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1040 <S@plt>
mulsd  0x10(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@M_2_PI = global i32 0
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 i32, i32* @M_2_PI
%26 = load double, double* %8
%27 = call i32 @expm1(double %26)
%28 = call i32 @log(i32 %27)
%29 = mul nsw i32 %25, %28
%30 = call double @asinh(i32 %29)
store double %30, double* %11
store double 0.000000e+00, double* %12
%31 = load i32, i32* %5
store i32 %31, i32* %9
br label %32
32: ; preds = %60, %4
%33 = load i32, i32* %9
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %63
35: ; preds = %32
%36 = load i32, i32* %9
%37 = sitofp i32 %36 to double
%38 = load double, double* %10
%39 = fmul double %37, %38
%40 = call double @ftrans(double %39)
%41 = load i32, i32* %9
%42 = load double, double* %10
%43 = load double, double* %11
%44 = call double @S(i32 %41, double %42, double %43)
%45 = load double, double* %12
%46 = call double @llvm.fmuladd.f64(double %40, double %44, double %45)
store double %46, double* %12
%47 = load i32, i32* %9
%48 = sub nsw i32 0, %47
%49 = sitofp i32 %48 to double
%50 = load double, double* %10
%51 = fmul double %49, %50
%52 = call double @ftrans(double %51)
%53 = load i32, i32* %9
%54 = sub nsw i32 0, %53
%55 = load double, double* %10
%56 = load double, double* %11
%57 = call double @S(i32 %54, double %55, double %56)
%58 = load double, double* %12
%59 = call double @llvm.fmuladd.f64(double %52, double %57, double %58)
store double %59, double* %12
br label %60
60: ; preds = %35
%61 = load i32, i32* %9
%62 = add nsw i32 %61, -1
store i32 %62, i32* %9
br label %32
63: ; preds = %32
%64 = load double, double* %10
%65 = fmul double 0.000000e+00, %64
%66 = call double @ftrans(double %65)
%67 = load double, double* %10
%68 = load double, double* %11
%69 = call double @S(i32 0, double %67, double %68)
%70 = load double, double* %12
%71 = call double @llvm.fmuladd.f64(double %66, double %69, double %70)
store double %71, double* %12
%72 = load double, double* %12
ret double %72
}

LLVM IR (-O2):
@M_2_PI = global i32 0
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 i32, i32* @M_2_PI
%14 = tail call i32 @expm1(double %3)
%15 = tail call i32 @log(i32 %14)
%16 = mul nsw i32 %15, %13
%17 = tail call double @asinh(i32 %16)
%18 = icmp sgt i32 %0, 0
br i1 %18, label %19, label %35
19: ; preds = %4, %19
%20 = phi double [ %32, %19 ], [ 0.000000e+00, %4 ]
%21 = phi i32 [ %33, %19 ], [ %0, %4 ]
%22 = sitofp i32 %21 to double
%23 = fmul double %12, %22
%24 = tail call double @ftrans(double %23)
%25 = tail call double @S(i32 %21, double %12, double %17)
%26 = tail call double @llvm.fmuladd.f64(double %24, double %25, double %20)
%27 = sub nsw i32 0, %21
%28 = sitofp i32 %27 to double
%29 = fmul double %12, %28
%30 = tail call double @ftrans(double %29)
%31 = tail call double @S(i32 %27, double %12, double %17)
%32 = tail call double @llvm.fmuladd.f64(double %30, double %31, double %26)
%33 = add nsw i32 %21, -1
%34 = icmp ugt i32 %21, 1
br i1 %34, label %19, label %35
35: ; preds = %19, %4
%36 = phi double [ 0.000000e+00, %4 ], [ %32, %19 ]
%37 = fmul double %12, 0.000000e+00
%38 = tail call double @ftrans(double %37)
%39 = tail call double @S(i32 0, double %12, double %17)
%40 = tail call double @llvm.fmuladd.f64(double %38, double %39, double %36)
ret double %40
}