#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 cos(double);
double pow(double, double);
void gen_sinc(float *out, int count, double oversample, double treble,
              double cutoff) {
  int i;
  double maxh, rolloff, pow_a_n, to_angle;
  if (cutoff > 0.999)
    cutoff = 0.999;
  if (treble < -300.0)
    treble = -300.0;
  if (treble > 5.0)
    treble = 5.0;
  maxh = 4096.0;
  rolloff = pow(10.0, 1.0 / (maxh * 20.0) * treble / (1.0 - cutoff));
  pow_a_n = pow(rolloff, maxh - maxh * cutoff);
  to_angle = 3.1415926535897932384626433832795029 / 2 / maxh / oversample;
  for (i = 0; i < count; i++) {
    double angle, c, cos_nc_angle, cos_nc1_angle, cos_angle, d, b, a;
    angle = ((i - count) * 2 + 1) * to_angle;
    c = rolloff * cos((maxh - 1.0) * angle) - cos(maxh * angle);
    cos_nc_angle = cos(maxh * cutoff * angle);
    cos_nc1_angle = cos((maxh * cutoff - 1.0) * angle);
    cos_angle = cos(angle);
    c = c * pow_a_n - rolloff * cos_nc1_angle + cos_nc_angle;
    d = 1.0 + rolloff * (rolloff - cos_angle - cos_angle);
    b = 2.0 - cos_angle - cos_angle;
    a = 1.0 - cos_angle - cos_nc_angle + cos_nc1_angle;
    out[i] = (float)((a * d + c * b) / (b * d));
  }
}


x86 assembly (clang, -O0):
<gen_sinc>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xeb2(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1165 <gen_sinc+0x45>
movsd  0xea0(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe9b(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1185 <gen_sinc+0x65>
movsd  0xe88(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe7e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a9 <gen_sinc+0x89>
movsd  0xe6c(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe87(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe72(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  0xe5d(%rip),%xmm1
divsd  %xmm0,%xmm1
mulsd  -0x20(%rbp),%xmm1
movsd  0xe4c(%rip),%xmm0
subsd  -0x28(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe33(%rip),%xmm0
call   1040 <pow@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm3
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
call   1040 <pow@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  0xddc(%rip),%xmm0
divsd  -0x38(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1430 <gen_sinc+0x310>
mov    -0x2c(%rbp),%eax
sub    -0xc(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
movsd  0xd96(%rip),%xmm1
subsd  %xmm1,%xmm0
mulsd  -0x58(%rbp),%xmm0
call   1030 <cos@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
call   1030 <cos@plt>
movsd  -0xa0(%rbp),%xmm2
ff
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
call   1030 <cos@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd2b(%rip),%xmm1
addsd  %xmm1,%xmm0
mulsd  -0x58(%rbp),%xmm0
call   1030 <cos@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1030 <cos@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  -0x70(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
subsd  -0x78(%rbp),%xmm1
subsd  -0x78(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xc8c(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  0xc93(%rip),%xmm0
subsd  -0x78(%rbp),%xmm0
subsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  0xc61(%rip),%xmm0
subsd  -0x78(%rbp),%xmm0
subsd  -0x68(%rbp),%xmm0
addsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
movsd  -0x80(%rbp),%xmm2
movsd  -0x60(%rbp),%xmm1
mulsd  -0x88(%rbp),%xmm1
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x88(%rbp),%xmm1
ff
mulsd  -0x80(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1252 <gen_sinc+0x132>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_sinc>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x78,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %esi,%r15d
mov    %rdi,%r14
movsd  0xec1(%rip),%xmm3
movsd  0xec1(%rip),%xmm0
maxsd  %xmm1,%xmm0
movsd  0xebd(%rip),%xmm1
minsd  %xmm0,%xmm1
mulsd  0xeb9(%rip),%xmm1
minsd  %xmm2,%xmm3
movsd  %xmm3,0x10(%rsp)
movsd  0xeaf(%rip),%xmm0
subsd  %xmm3,%xmm0
divsd  %xmm0,%xmm1
movsd  0xea7(%rip),%xmm0
call   1040 <pow@plt>
movsd  0xea2(%rip),%xmm1
mulsd  0x10(%rsp),%xmm1
addsd  0xe9c(%rip),%xmm1
movapd %xmm0,0x20(%rsp)
call   1040 <pow@plt>
test   %r15d,%r15d
jle    1350 <gen_sinc+0x230>
movapd %xmm0,%xmm8
movsd  0xe83(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x40(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  0xe61(%rip),%xmm0
movsd  0xe69(%rip),%xmm1
movsd  %xmm0,0x10(%rsp)
addsd  %xmm0,%xmm1
movsd  %xmm1,0x38(%rsp)
movaps 0xe6a(%rip),%xmm0
xorps  0x20(%rsp),%xmm0
movaps %xmm0,0x60(%rsp)
mov    %r15d,%r12d
add    %r15d,%r15d
neg    %r15d
or     $0x1,%r15
add    %r12,%r12
xor    %ebx,%ebx
movsd  %xmm8,0x48(%rsp)
nopl   0x0(%rax)
lea    (%r15,%rbx,1),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x40(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mulsd  0xe11(%rip),%xmm0
call   1030 <cos@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xde0(%rip),%xmm0
call   1030 <cos@plt>
movsd  0x18(%rsp),%xmm1
mulsd  0x20(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
call   1030 <cos@plt>
movsd  %xmm0,0x58(%rsp)
movsd  0x38(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
call   1030 <cos@plt>
movsd  %xmm0,0x50(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <cos@plt>
movsd  0x48(%rsp),%xmm8
movsd  0x50(%rsp),%xmm5
movapd %xmm5,%xmm1
mulsd  0x60(%rsp),%xmm1
movsd  0x18(%rsp),%xmm3
mulsd  %xmm8,%xmm3
movapd 0x20(%rsp),%xmm4
movapd %xmm4,%xmm2
subsd  %xmm0,%xmm2
addsd  %xmm1,%xmm3
subsd  %xmm0,%xmm2
mulsd  %xmm4,%xmm2
movsd  0xd68(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  0x58(%rsp),%xmm7
addsd  %xmm7,%xmm3
movapd %xmm3,%xmm6
subsd  %xmm0,%xmm1
movsd  0xd12(%rip),%xmm4
movapd %xmm4,%xmm3
subsd  %xmm0,%xmm3
subsd  %xmm7,%xmm3
addsd  %xmm4,%xmm2
addsd  %xmm5,%xmm3
mulsd  %xmm1,%xmm6
mulsd  %xmm2,%xmm3
addsd  %xmm6,%xmm3
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm3
xorps  %xmm0,%xmm0
cvtsd2ss %xmm3,%xmm0
movss  %xmm0,(%r14,%rbx,2)
add    $0x2,%rbx
cmp    %rbx,%r12
jne    1220 <gen_sinc+0x100>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @gen_sinc(float* %0, i32 %1, double %2, double %3, double %4) {
%6 = alloca float*
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
store float* %0, float** %6
store i32 %1, i32* %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
%24 = load double, double* %10
%25 = fcmp ogt double %24, 0x3FEFF7CED916872B
br i1 %25, label %26, label %27
26: ; preds = %5
store double 0x3FEFF7CED916872B, double* %10
br label %27
27: ; preds = %26, %5
%28 = load double, double* %9
%29 = fcmp olt double %28, -3.000000e+02
br i1 %29, label %30, label %31
30: ; preds = %27
store double -3.000000e+02, double* %9
br label %31
31: ; preds = %30, %27
%32 = load double, double* %9
%33 = fcmp ogt double %32, 5.000000e+00
br i1 %33, label %34, label %35
34: ; preds = %31
store double 5.000000e+00, double* %9
br label %35
35: ; preds = %34, %31
store double 4.096000e+03, double* %12
%36 = load double, double* %12
%37 = fmul double %36, 2.000000e+01
%38 = fdiv double 1.000000e+00, %37
%39 = load double, double* %9
%40 = fmul double %38, %39
%41 = load double, double* %10
%42 = fsub double 1.000000e+00, %41
%43 = fdiv double %40, %42
%44 = call double @pow(double 1.000000e+01, double %43)
store double %44, double* %13
%45 = load double, double* %13
%46 = load double, double* %12
%47 = load double, double* %12
%48 = load double, double* %10
%49 = fneg double %47
%50 = call double @llvm.fmuladd.f64(double %49, double %48, double %46)
%51 = call double @pow(double %45, double %50)
store double %51, double* %14
%52 = load double, double* %12
%53 = fdiv double 0x3FF921FB54442D18, %52
%54 = load double, double* %8
%55 = fdiv double %53, %54
store double %55, double* %15
store i32 0, i32* %11
br label %56
56: ; preds = %136, %35
%57 = load i32, i32* %11
%58 = load i32, i32* %7
%59 = icmp slt i32 %57, %58
br i1 %59, label %60, label %139
60: ; preds = %56
%61 = load i32, i32* %11
%62 = load i32, i32* %7
%63 = sub nsw i32 %61, %62
%64 = mul nsw i32 %63, 2
%65 = add nsw i32 %64, 1
%66 = sitofp i32 %65 to double
%67 = load double, double* %15
%68 = fmul double %66, %67
store double %68, double* %16
%69 = load double, double* %13
%70 = load double, double* %12
%71 = fsub double %70, 1.000000e+00
%72 = load double, double* %16
%73 = fmul double %71, %72
%74 = call double @cos(double %73)
%75 = load double, double* %12
%76 = load double, double* %16
%77 = fmul double %75, %76
%78 = call double @cos(double %77)
%79 = fneg double %78
%80 = call double @llvm.fmuladd.f64(double %69, double %74, double %79)
store double %80, double* %17
%81 = load double, double* %12
%82 = load double, double* %10
%83 = fmul double %81, %82
%84 = load double, double* %16
%85 = fmul double %83, %84
%86 = call double @cos(double %85)
store double %86, double* %18
%87 = load double, double* %12
%88 = load double, double* %10
%89 = call double @llvm.fmuladd.f64(double %87, double %88, double -1.000000e+00)
%90 = load double, double* %16
%91 = fmul double %89, %90
%92 = call double @cos(double %91)
store double %92, double* %19
%93 = load double, double* %16
%94 = call double @cos(double %93)
store double %94, double* %20
%95 = load double, double* %17
%96 = load double, double* %14
%97 = load double, double* %13
%98 = load double, double* %19
%99 = fmul double %97, %98
%100 = fneg double %99
%101 = call double @llvm.fmuladd.f64(double %95, double %96, double %100)
%102 = load double, double* %18
%103 = fadd double %101, %102
store double %103, double* %17
%104 = load double, double* %13
%105 = load double, double* %13
%106 = load double, double* %20
%107 = fsub double %105, %106
%108 = load double, double* %20
%109 = fsub double %107, %108
%110 = call double @llvm.fmuladd.f64(double %104, double %109, double 1.000000e+00)
store double %110, double* %21
%111 = load double, double* %20
%112 = fsub double 2.000000e+00, %111
%113 = load double, double* %20
%114 = fsub double %112, %113
store double %114, double* %22
%115 = load double, double* %20
%116 = fsub double 1.000000e+00, %115
%117 = load double, double* %18
%118 = fsub double %116, %117
%119 = load double, double* %19
%120 = fadd double %118, %119
store double %120, double* %23
%121 = load double, double* %23
%122 = load double, double* %21
%123 = load double, double* %17
%124 = load double, double* %22
%125 = fmul double %123, %124
%126 = call double @llvm.fmuladd.f64(double %121, double %122, double %125)
%127 = load double, double* %22
%128 = load double, double* %21
%129 = fmul double %127, %128
%130 = fdiv double %126, %129
%131 = fptrunc double %130 to float
%132 = load float*, float** %6
%133 = load i32, i32* %11
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds float, float* %132, i64 %134
store float %131, float* %135
br label %136
136: ; preds = %60
%137 = load i32, i32* %11
%138 = add nsw i32 %137, 1
store i32 %138, i32* %11
br label %56
139: ; preds = %56
ret void
}

LLVM IR (-O2):
define void @gen_sinc(float* nocapture writeonly %0, i32 %1, double %2, double %3, double %4) {
%6 = fcmp ogt double %4, 0x3FEFF7CED916872B
%7 = select i1 %6, double 0x3FEFF7CED916872B, double %4
%8 = fcmp olt double %3, -3.000000e+02
%9 = select i1 %8, double -3.000000e+02, double %3
%10 = fcmp ogt double %9, 5.000000e+00
%11 = select i1 %10, double 5.000000e+00, double %9
%12 = fmul double %11, 0x3EE999999999999A
%13 = fsub double 1.000000e+00, %7
%14 = fdiv double %12, %13
%15 = tail call double @pow(double 1.000000e+01, double %14)
%16 = tail call double @llvm.fmuladd.f64(double %7, double -4.096000e+03, double 4.096000e+03)
%17 = tail call double @pow(double %15, double %16)
%18 = fdiv double 0x3F3921FB54442D18, %2
%19 = icmp sgt i32 %1, 0
br i1 %19, label %20, label %63
20: ; preds = %5
%21 = fmul double %7, 4.096000e+03
%22 = tail call double @llvm.fmuladd.f64(double %7, double 4.096000e+03, double -1.000000e+00)
%23 = fneg double %15
%24 = zext i32 %1 to i64
br label %25
25: ; preds = %20, %25
%26 = phi i64 [ 0, %20 ], [ %61, %25 ]
%27 = trunc i64 %26 to i32
%28 = sub nsw i32 %27, %1
%29 = shl nsw i32 %28, 1
%30 = or i32 %29, 1
%31 = sitofp i32 %30 to double
%32 = fmul double %18, %31
%33 = fmul double %32, 4.095000e+03
%34 = tail call double @cos(double %33)
%35 = fmul double %32, 4.096000e+03
%36 = tail call double @cos(double %35)
%37 = fneg double %36
%38 = tail call double @llvm.fmuladd.f64(double %15, double %34, double %37)
%39 = fmul double %21, %32
%40 = tail call double @cos(double %39)
%41 = fmul double %22, %32
%42 = tail call double @cos(double %41)
%43 = tail call double @cos(double %32)
%44 = fmul double %42, %23
%45 = tail call double @llvm.fmuladd.f64(double %38, double %17, double %44)
%46 = fadd double %40, %45
%47 = fsub double %15, %43
%48 = fsub double %47, %43
%49 = tail call double @llvm.fmuladd.f64(double %15, double %48, double 1.000000e+00)
%50 = fsub double 2.000000e+00, %43
%51 = fsub double %50, %43
%52 = fsub double 1.000000e+00, %43
%53 = fsub double %52, %40
%54 = fadd double %42, %53
%55 = fmul double %46, %51
%56 = tail call double @llvm.fmuladd.f64(double %54, double %49, double %55)
%57 = fmul double %51, %49
%58 = fdiv double %56, %57
%59 = fptrunc double %58 to float
%60 = getelementptr inbounds float, float* %0, i64 %26
store float %59, float* %60
%61 = add nuw nsw i64 %26, 1
%62 = icmp eq i64 %61, %24
br i1 %62, label %63, label %25
63: ; preds = %25, %5
ret void
}