#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);
scalar_t__ ceil(double);
double fmin(double, double);
double ftrans(int);
double log(int /*<<< orphan*/);
int /*<<< orphan*/ sinh(double);
double sqrt(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 = sqrt(M_PI * d / (mu * n));
  if (alpha <= beta) {
    M = n;
    N = (int)ceil(alpha * n / beta);
  } else {
    M = (int)ceil(beta * n / alpha);
    N = n;
  }
  double x = log(sinh(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    $0x70,%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)
mov    0x2e35(%rip),%rax
movsd  (%rax),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
cvtsi2sdl -0x4(%rbp),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1080 <sqrt@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1212 <sinc_approx+0xb2>
mov    -0x4(%rbp),%eax
mov    %eax,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x20(%rbp),%xmm0
call   1040 <ceil@plt>
mov    %eax,-0x34(%rbp)
jmp    1233 <sinc_approx+0xd3>
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x18(%rbp),%xmm0
call   1040 <ceil@plt>
mov    %eax,-0x30(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x34(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <sinh@plt>
mov    %eax,%edi
call   1070 <log@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    12bd <sinc_approx+0x15d>
cvtsi2sdl -0x2c(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <ftrans@plt>
movsd  %xmm0,-0x68(%rbp)
mov    -0x2c(%rbp),%edi
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
call   1060 <S@plt>
movaps %xmm0,%xmm2
movsd  -0x68(%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    1261 <sinc_approx+0x101>
mov    -0x34(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jl     131f <sinc_approx+0x1bf>
cvtsi2sdl -0x2c(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <ftrans@plt>
movsd  %xmm0,-0x70(%rbp)
mov    -0x2c(%rbp),%edi
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
call   1060 <S@plt>
movaps %xmm0,%xmm2
movsd  -0x70(%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    12c3 <sinc_approx+0x163>
movsd  -0x58(%rbp),%xmm0
addsd  -0x60(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

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

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