#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 */
struct FuncDef {
  int dummy;
};

/* Variables and functions */
float compute_func(int /*<<< orphan*/, struct FuncDef *);
int /*<<< orphan*/ fabs(int);
double fabsf(float);
float sin(double);
float sinc(float cutoff, float x, int N, struct FuncDef *window_func) {
  float xx = x * cutoff;
  if (fabsf(x) < 1e-6)
    return cutoff;
  else if (fabsf(x) > .5 * N)
    return 0;
  return cutoff * sin(3.14159263 * xx) / (3.14159263 * xx) *
         compute_func(fabs(2. * x / N), window_func);
}


x86 assembly (clang, -O0):
<sinc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
mov    %edi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <fabsf@plt>
movaps %xmm0,%xmm1
movsd  0xe83(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1196 <sinc+0x56>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    126a <sinc+0x12a>
movss  -0xc(%rbp),%xmm0
call   1030 <fabsf@plt>
cvtsi2sdl -0x10(%rbp),%xmm2
movsd  0xe5b(%rip),%xmm1
mulsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
jbe    11c8 <sinc+0x88>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    126a <sinc+0x12a>
jmp    11cd <sinc+0x8d>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe30(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1060 <sin@plt>
movaps %xmm0,%xmm1
movss  -0x2c(%rbp),%xmm0
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x1c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xe06(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xde0(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <fabs@plt>
mov    %eax,%edi
mov    -0x18(%rbp),%rsi
call   1050 <compute_func@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sinc>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movss  %xmm0,0x10(%rsp)
movss  %xmm1,0xc(%rsp)
movapd %xmm1,%xmm0
call   1030 <fabsf@plt>
movsd  0xe98(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1179 <sinc+0x39>
movss  0x10(%rsp),%xmm0
jmp    1216 <sinc+0xd6>
movss  0xc(%rsp),%xmm0
call   1030 <fabsf@plt>
movapd %xmm0,%xmm1
cvtsi2sd %ebp,%xmm3
movsd  0xe74(%rip),%xmm2
mulsd  %xmm3,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm1
ja     1216 <sinc+0xd6>
movss  0x10(%rsp),%xmm0
mulss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xe56(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  %xmm3,0x20(%rsp)
call   1060 <sin@plt>
mulss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  %xmm0,%xmm0
divsd  0x20(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <fabs@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1050 <compute_func@plt>
cvtss2sd %xmm0,%xmm0
mulsd  0x10(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.FuncDef = type { i32 }
define float @sinc(float %0, float %1, i32 %2, %struct.FuncDef* %3) {
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca i32
%9 = alloca %struct.FuncDef*
%10 = alloca float
store float %0, float* %6
store float %1, float* %7
store i32 %2, i32* %8
store %struct.FuncDef* %3, %struct.FuncDef** %9
%11 = load float, float* %7
%12 = load float, float* %6
%13 = fmul float %11, %12
store float %13, float* %10
%14 = load float, float* %7
%15 = call double @fabsf(float %14)
%16 = fcmp olt double %15, 0x3EB0C6F7A0B5ED8D
br i1 %16, label %17, label %19
17: ; preds = %4
%18 = load float, float* %6
store float %18, float* %5
br label %53
19: ; preds = %4
%20 = load float, float* %7
%21 = call double @fabsf(float %20)
%22 = load i32, i32* %8
%23 = sitofp i32 %22 to double
%24 = fmul double 5.000000e-01, %23
%25 = fcmp ogt double %21, %24
br i1 %25, label %26, label %27
26: ; preds = %19
store float 0.000000e+00, float* %5
br label %53
27: ; preds = %19
br label %28
28: ; preds = %27
%29 = load float, float* %6
%30 = load float, float* %10
%31 = fpext float %30 to double
%32 = fmul double 0x400921FB5119A314, %31
%33 = call float @sin(double %32)
%34 = fmul float %29, %33
%35 = fpext float %34 to double
%36 = load float, float* %10
%37 = fpext float %36 to double
%38 = fmul double 0x400921FB5119A314, %37
%39 = fdiv double %35, %38
%40 = load float, float* %7
%41 = fpext float %40 to double
%42 = fmul double 2.000000e+00, %41
%43 = load i32, i32* %8
%44 = sitofp i32 %43 to double
%45 = fdiv double %42, %44
%46 = fptosi double %45 to i32
%47 = call i32 @fabs(i32 %46)
%48 = load %struct.FuncDef*, %struct.FuncDef** %9
%49 = call float @compute_func(i32 %47, %struct.FuncDef* %48)
%50 = fpext float %49 to double
%51 = fmul double %39, %50
%52 = fptrunc double %51 to float
store float %52, float* %5
br label %53
53: ; preds = %28, %26, %17
%54 = load float, float* %5
ret float %54
}

LLVM IR (-O2):
%struct.FuncDef = type { i32 }
define float @sinc(float %0, float %1, i32 %2, %struct.FuncDef* %3) {
%5 = fmul float %0, %1
%6 = tail call double @fabsf(float %1)
%7 = fcmp olt double %6, 0x3EB0C6F7A0B5ED8D
br i1 %7, label %29, label %8
8: ; preds = %4
%9 = tail call double @fabsf(float %1)
%10 = sitofp i32 %2 to double
%11 = fmul double %10, 5.000000e-01
%12 = fcmp ogt double %9, %11
br i1 %12, label %29, label %13
13: ; preds = %8
%14 = fpext float %5 to double
%15 = fmul double %14, 0x400921FB5119A314
%16 = tail call float @sin(double %15)
%17 = fmul float %16, %0
%18 = fpext float %17 to double
%19 = fdiv double %18, %15
%20 = fpext float %1 to double
%21 = fmul double %20, 2.000000e+00
%22 = fdiv double %21, %10
%23 = fptosi double %22 to i32
%24 = tail call i32 @fabs(i32 %23)
%25 = tail call float @compute_func(i32 %24, %struct.FuncDef* %3)
%26 = fpext float %25 to double
%27 = fmul double %19, %26
%28 = fptrunc double %27 to float
br label %29
29: ; preds = %8, %4, %13
%30 = phi float [ %28, %13 ], [ %0, %4 ], [ 0.000000e+00, %8 ]
ret float %30
}