#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);
scalar_t__ floor(double);
double fmin(double, double);
double ftrans(int);
double log(double);
double sinc_approx(int n, double d, double alpha, double beta, double t) {
  int k, M, N;
  double mu = fmin(alpha, beta);
  double h = log(4 * d * n / mu) / n;
  if (alpha <= beta) {
    M = n;
    N = n - (int)floor(log(beta / alpha) / h);
  } else {
    M = n - (int)floor(log(alpha / beta) / h);
    N = n;
  }
  double x = asinh(M_2_PI * log(t));
  double val1 = 0;
  double val2 = 0;
  for (k = -M; k < 0; k++) {
    val1 += ftrans(k * h) * S(k, h, x);
  }
  for (k = N; k >= 0; k--) {
    val2 += ftrans(k * h) * S(k, h, x);
  }
  return val1 + val2;
}


x86 assembly (clang, -O0):
<sinc_approx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm3
movsd  -0x20(%rbp),%xmm2
movaps %xmm2,%xmm4
movaps %xmm3,%xmm0
cmpunordsd %xmm0,%xmm0
movaps %xmm0,%xmm1
pand   %xmm4,%xmm1
minsd  %xmm3,%xmm2
pandn  %xmm2,%xmm0
por    %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe59(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x40(%rbp),%xmm0
call   1050 <log@plt>
cvtsi2sdl -0x4(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1216 <sinc_approx+0xc6>
mov    -0x4(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x64(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
call   1050 <log@plt>
divsd  -0x48(%rbp),%xmm0
call   1070 <floor@plt>
mov    %rax,%rcx
mov    -0x64(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x34(%rbp)
jmp    1246 <sinc_approx+0xf6>
mov    -0x4(%rbp),%eax
mov    %eax,-0x68(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
call   1050 <log@plt>
divsd  -0x48(%rbp),%xmm0
call   1070 <floor@plt>
mov    %rax,%rcx
mov    -0x68(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x30(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    0x2d8b(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1060 <asinh@plt>
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
xor    %eax,%eax
sub    -0x30(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    12ea <sinc_approx+0x19a>
cvtsi2sdl -0x2c(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <ftrans@plt>
movsd  %xmm0,-0x78(%rbp)
mov    -0x2c(%rbp),%edi
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
call   1040 <S@plt>
movaps %xmm0,%xmm2
movsd  -0x78(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    128e <sinc_approx+0x13e>
mov    -0x34(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jl     134c <sinc_approx+0x1fc>
cvtsi2sdl -0x2c(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <ftrans@plt>
movsd  %xmm0,-0x80(%rbp)
mov    -0x2c(%rbp),%edi
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
call   1040 <S@plt>
movaps %xmm0,%xmm2
movsd  -0x80(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
jmp    12f0 <sinc_approx+0x1a0>
movsd  -0x58(%rbp),%xmm0
addsd  -0x60(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sinc_approx>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
movsd  %xmm3,0x18(%rsp)
movapd %xmm2,0x20(%rsp)
movsd  %xmm1,0x8(%rsp)
mov    %edi,%ebx
movapd %xmm1,%xmm4
cmpunordsd %xmm1,%xmm4
movapd %xmm4,%xmm5
andpd  %xmm2,%xmm5
movapd %xmm2,%xmm3
minsd  %xmm1,%xmm3
andnpd %xmm3,%xmm4
orpd   %xmm5,%xmm4
mulsd  0xe6d(%rip),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %edi,%xmm1
movsd  %xmm1,0x10(%rsp)
mulsd  %xmm1,%xmm0
divsd  %xmm4,%xmm0
call   1050 <log@plt>
movapd 0x20(%rsp),%xmm1
movapd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
divsd  0x10(%rsp),%xmm2
movsd  %xmm2,0x10(%rsp)
ucomisd %xmm0,%xmm1
jae    11e9 <sinc_approx+0x99>
divsd  %xmm1,%xmm0
call   1050 <log@plt>
divsd  0x10(%rsp),%xmm0
call   1070 <floor@plt>
mov    %ebx,%ebp
sub    %eax,%ebx
jmp    1205 <sinc_approx+0xb5>
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1050 <log@plt>
divsd  0x10(%rsp),%xmm0
call   1070 <floor@plt>
mov    %ebx,%ebp
sub    %eax,%ebp
mov    0x2dcc(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1050 <log@plt>
mulsd  0x8(%rsp),%xmm0
call   1060 <asinh@plt>
movsd  %xmm0,0x20(%rsp)
xorpd  %xmm0,%xmm0
test   %ebx,%ebx
movsd  0x10(%rsp),%xmm2
jle    12a9 <sinc_approx+0x159>
neg    %ebx
xorpd  %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
movsd  %xmm0,0x18(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  %xmm2,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <ftrans@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
movsd  0x10(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1040 <S@plt>
movsd  0x10(%rsp),%xmm2
mulsd  0x8(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0x18(%rsp),%xmm0
inc    %ebx
jne    1250 <sinc_approx+0x100>
movsd  %xmm0,0x18(%rsp)
test   %ebp,%ebp
xorpd  %xmm1,%xmm1
js     131a <sinc_approx+0x1ca>
xorpd  %xmm1,%xmm1
nopl   0x0(%rax,%rax,1)
movsd  %xmm1,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  %xmm2,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <ftrans@plt>
movsd  %xmm0,0x30(%rsp)
mov    %ebp,%edi
movsd  0x10(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1040 <S@plt>
movsd  0x10(%rsp),%xmm2
mulsd  0x30(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm1
add    $0xffffffff,%ebp
jb     12c0 <sinc_approx+0x170>
movsd  0x18(%rsp),%xmm0
addsd  %xmm1,%xmm0
add    $0x38,%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, double %4) {
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
store i32 %0, i32* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
%19 = load double, double* %8
%20 = load double, double* %9
%21 = call double @llvm.minnum.f64(double %19, double %20)
store double %21, double* %14
%22 = load double, double* %7
%23 = fmul double 4.000000e+00, %22
%24 = load i32, i32* %6
%25 = sitofp i32 %24 to double
%26 = fmul double %23, %25
%27 = load double, double* %14
%28 = fdiv double %26, %27
%29 = call double @log(double %28)
%30 = load i32, i32* %6
%31 = sitofp i32 %30 to double
%32 = fdiv double %29, %31
store double %32, double* %15
%33 = load double, double* %8
%34 = load double, double* %9
%35 = fcmp ole double %33, %34
br i1 %35, label %36, label %48
36: ; preds = %5
%37 = load i32, i32* %6
store i32 %37, i32* %12
%38 = load i32, i32* %6
%39 = load double, double* %9
%40 = load double, double* %8
%41 = fdiv double %39, %40
%42 = call double @log(double %41)
%43 = load double, double* %15
%44 = fdiv double %42, %43
%45 = call i64 @floor(double %44)
%46 = trunc i64 %45 to i32
%47 = sub nsw i32 %38, %46
store i32 %47, i32* %13
br label %60
48: ; preds = %5
%49 = load i32, i32* %6
%50 = load double, double* %8
%51 = load double, double* %9
%52 = fdiv double %50, %51
%53 = call double @log(double %52)
%54 = load double, double* %15
%55 = fdiv double %53, %54
%56 = call i64 @floor(double %55)
%57 = trunc i64 %56 to i32
%58 = sub nsw i32 %49, %57
store i32 %58, i32* %12
%59 = load i32, i32* %6
store i32 %59, i32* %13
br label %60
60: ; preds = %48, %36
%61 = load double, double* @M_2_PI
%62 = load double, double* %10
%63 = call double @log(double %62)
%64 = fmul double %61, %63
%65 = call double @asinh(double %64)
store double %65, double* %16
store double 0.000000e+00, double* %17
store double 0.000000e+00, double* %18
%66 = load i32, i32* %12
%67 = sub nsw i32 0, %66
store i32 %67, i32* %11
br label %68
68: ; preds = %84, %60
%69 = load i32, i32* %11
%70 = icmp slt i32 %69, 0
br i1 %70, label %71, label %87
71: ; preds = %68
%72 = load i32, i32* %11
%73 = sitofp i32 %72 to double
%74 = load double, double* %15
%75 = fmul double %73, %74
%76 = fptosi double %75 to i32
%77 = call double @ftrans(i32 %76)
%78 = load i32, i32* %11
%79 = load double, double* %15
%80 = load double, double* %16
%81 = call double @S(i32 %78, double %79, double %80)
%82 = load double, double* %17
%83 = call double @llvm.fmuladd.f64(double %77, double %81, double %82)
store double %83, double* %17
br label %84
84: ; preds = %71
%85 = load i32, i32* %11
%86 = add nsw i32 %85, 1
store i32 %86, i32* %11
br label %68
87: ; preds = %68
%88 = load i32, i32* %13
store i32 %88, i32* %11
br label %89
89: ; preds = %105, %87
%90 = load i32, i32* %11
%91 = icmp sge i32 %90, 0
br i1 %91, label %92, label %108
92: ; preds = %89
%93 = load i32, i32* %11
%94 = sitofp i32 %93 to double
%95 = load double, double* %15
%96 = fmul double %94, %95
%97 = fptosi double %96 to i32
%98 = call double @ftrans(i32 %97)
%99 = load i32, i32* %11
%100 = load double, double* %15
%101 = load double, double* %16
%102 = call double @S(i32 %99, double %100, double %101)
%103 = load double, double* %18
%104 = call double @llvm.fmuladd.f64(double %98, double %102, double %103)
store double %104, double* %18
br label %105
105: ; preds = %92
%106 = load i32, i32* %11
%107 = add nsw i32 %106, -1
store i32 %107, i32* %11
br label %89
108: ; preds = %89
%109 = load double, double* %17
%110 = load double, double* %18
%111 = fadd double %109, %110
ret double %111
}

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