#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_PI;
double S(int, double, double);
double asinh(double);
double ftrans(double);
double sqrt(double);
double sinc_approx(int N, double d, double mu, double t) {
  int k;
  double h = sqrt(M_PI * d / (mu * N));
  double x = 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)
mov    0x2e87(%rip),%rax
movsd  (%rax),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
cvtsi2sdl -0x4(%rbp),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%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    1241 <sinc_approx+0x101>
cvtsi2sdl -0x24(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1030 <ftrans@plt>
movsd  %xmm0,-0x50(%rbp)
mov    -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)
xor    %eax,%eax
sub    -0x24(%rbp),%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1030 <ftrans@plt>
movsd  %xmm0,-0x48(%rbp)
xor    %edi,%edi
sub    -0x24(%rbp),%edi
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
call   1040 <S@plt>
movaps %xmm0,%xmm2
movsd  -0x48(%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    11a3 <sinc_approx+0x63>
xorps  %xmm0,%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1030 <ftrans@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
xor    %edi,%edi
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)
movsd  -0x40(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sinc_approx>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    0x2e9b(%rip),%rax
mulsd  (%rax),%xmm0
movapd %xmm2,%xmm3
mov    %edi,%ebx
xorps  %xmm2,%xmm2
cvtsi2sd %edi,%xmm2
mulsd  %xmm1,%xmm2
divsd  %xmm2,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1176 <sinc_approx+0x36>
sqrtsd %xmm0,%xmm0
jmp    1187 <sinc_approx+0x47>
movsd  %xmm3,0x20(%rsp)
call   1050 <sqrt@plt>
movsd  0x20(%rsp),%xmm3
movsd  %xmm0,0x8(%rsp)
movapd %xmm3,%xmm0
call   1060 <asinh@plt>
movsd  %xmm0,0x20(%rsp)
test   %ebx,%ebx
movsd  0x8(%rsp),%xmm1
xorpd  %xmm0,%xmm0
movsd  %xmm1,0x8(%rsp)
jle    124f <sinc_approx+0x10f>
mov    %ebx,%ebp
neg    %ebp
xorpd  %xmm0,%xmm0
nopl   0x0(%rax)
movsd  %xmm0,0x18(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  %xmm1,%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>
movsd  0x8(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
lea    -0x1(%rbx),%eax
add    $0x1,%ebp
cmp    $0x1,%ebx
mov    %eax,%ebx
ja     11c0 <sinc_approx+0x80>
movsd  %xmm0,0x18(%rsp)
xorpd  %xmm0,%xmm0
mulsd  %xmm1,%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_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* @M_PI
%14 = load double, double* %6
%15 = fmul double %13, %14
%16 = load double, double* %7
%17 = load i32, i32* %5
%18 = sitofp i32 %17 to double
%19 = fmul double %16, %18
%20 = fdiv double %15, %19
%21 = call double @sqrt(double %20)
store double %21, double* %10
%22 = load double, double* %8
%23 = call double @asinh(double %22)
store double %23, double* %11
store double 0.000000e+00, double* %12
%24 = load i32, i32* %5
store i32 %24, i32* %9
br label %25
25: ; preds = %53, %4
%26 = load i32, i32* %9
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %56
28: ; preds = %25
%29 = load i32, i32* %9
%30 = sitofp i32 %29 to double
%31 = load double, double* %10
%32 = fmul double %30, %31
%33 = call double @ftrans(double %32)
%34 = load i32, i32* %9
%35 = load double, double* %10
%36 = load double, double* %11
%37 = call double @S(i32 %34, double %35, double %36)
%38 = load double, double* %12
%39 = call double @llvm.fmuladd.f64(double %33, double %37, double %38)
store double %39, double* %12
%40 = load i32, i32* %9
%41 = sub nsw i32 0, %40
%42 = sitofp i32 %41 to double
%43 = load double, double* %10
%44 = fmul double %42, %43
%45 = call double @ftrans(double %44)
%46 = load i32, i32* %9
%47 = sub nsw i32 0, %46
%48 = load double, double* %10
%49 = load double, double* %11
%50 = call double @S(i32 %47, double %48, double %49)
%51 = load double, double* %12
%52 = call double @llvm.fmuladd.f64(double %45, double %50, double %51)
store double %52, double* %12
br label %53
53: ; preds = %28
%54 = load i32, i32* %9
%55 = add nsw i32 %54, -1
store i32 %55, i32* %9
br label %25
56: ; preds = %25
%57 = load double, double* %10
%58 = fmul double 0.000000e+00, %57
%59 = call double @ftrans(double %58)
%60 = load double, double* %10
%61 = load double, double* %11
%62 = call double @S(i32 0, double %60, double %61)
%63 = load double, double* %12
%64 = call double @llvm.fmuladd.f64(double %59, double %62, double %63)
store double %64, double* %12
%65 = load double, double* %12
ret double %65
}

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