#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(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, char *, int, double const);
double sin(double const);
void gen_windowed_sines(int freq_count, const double *freqs, double max,
                        float *output, int output_len) {
  int k, freq;
  double amplitude, phase;
  amplitude = max / freq_count;
  for (k = 0; k < output_len; k++)
    output[k] = 0.0;
  for (freq = 0; freq < freq_count; freq++) {
    phase = 0.9 * 3.14159265358979323846264338 / freq_count;
    if (freqs[freq] <= 0.0 || freqs[freq] >= 0.5) {
      printf(
          "\n%s : Error : freq [%d] == %g is out of range. Should be < 0.5.\n",
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/bit-trade-one/SoundModuleAP/refs/heads/"
          "SoundModuleAP/lib-src/libsamplerate/tests/util.c",
          freq, freqs[freq]);
      exit(1);
    };
    for (k = 0; k < output_len; k++)
      output[k] +=
          amplitude *
          sin(freqs[freq] * (2 * k) * 3.14159265358979323846264338 + phase);
  };
  for (k = 0; k < output_len; k++)
    output[k] *= 0.5 - 0.5 * cos((2 * k) * 3.14159265358979323846264338 /
                                 (output_len - 1));
  return;
}


x86 assembly (clang, -O0):
<gen_windowed_sines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movsd  -0x18(%rbp),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    119f <gen_windowed_sines+0x5f>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1175 <gen_windowed_sines+0x35>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12c7 <gen_windowed_sines+0x187>
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xe59(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
xorps  %xmm0,%xmm0
ucomisd (%rax,%rcx,8),%xmm0
jae    11fd <gen_windowed_sines+0xbd>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xe15(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     122a <gen_windowed_sines+0xea>
mov    -0x2c(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe0c(%rip),%rdi
lea    0xe46(%rip),%rsi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12b4 <gen_windowed_sines+0x174>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x40(%rbp),%xmm1
movsd  0xda1(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1231 <gen_windowed_sines+0xf1>
jmp    12b9 <gen_windowed_sines+0x179>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11a6 <gen_windowed_sines+0x66>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    134e <gen_windowed_sines+0x20e>
mov    -0x28(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xd24(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  0xcee(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xcea(%rip),%xmm0
addsd  %xmm0,%xmm1
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    12ce <gen_windowed_sines+0x18e>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_windowed_sines>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %ecx,%r14d
mov    %rdx,%rbx
movapd %xmm0,%xmm2
mov    %rsi,%r15
mov    %edi,%r12d
mov    %ecx,%ebp
test   %ecx,%ecx
jle    1190 <gen_windowed_sines+0x40>
lea    0x0(,%rbp,4),%rdx
mov    %rbx,%rdi
xor    %esi,%esi
movsd  %xmm2,(%rsp)
call   1040 <memset@plt>
movsd  (%rsp),%xmm2
mov    %rbp,0x8(%rsp)
test   %r12d,%r12d
jle    12d9 <gen_windowed_sines+0x189>
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
divsd  %xmm0,%xmm2
movsd  0xe4e(%rip),%xmm1
divsd  %xmm0,%xmm1
mov    %r12d,%eax
mov    %rax,0x20(%rsp)
mov    0x8(%rsp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,0x18(%rsp)
xor    %ebp,%ebp
movsd  0xe3a(%rip),%xmm4
movsd  %xmm2,(%rsp)
movsd  %xmm1,0x10(%rsp)
jmp    11ff <gen_windowed_sines+0xaf>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbp
cmp    0x20(%rsp),%rbp
je     12d9 <gen_windowed_sines+0x189>
movsd  (%r15,%rbp,8),%xmm0
xorpd  %xmm3,%xmm3
ucomisd %xmm0,%xmm3
jae    135e <gen_windowed_sines+0x20e>
ucomisd 0xded(%rip),%xmm0
jae    135e <gen_windowed_sines+0x20e>
test   %r14d,%r14d
jle    11f0 <gen_windowed_sines+0xa0>
mulsd  0xdf2(%rip),%xmm0
mulsd  %xmm4,%xmm0
addsd  %xmm1,%xmm0
call   1050 <sin@plt>
movsd  0xdcd(%rip),%xmm4
movsd  (%rsp),%xmm2
movss  (%rbx),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0x10(%rsp),%xmm1
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rbx)
cmp    $0x1,%r14d
je     11f0 <gen_windowed_sines+0xa0>
mov    $0x2,%r12d
mov    0x18(%rsp),%r13
nopw   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
mulsd  (%r15,%rbp,8),%xmm0
mulsd  %xmm4,%xmm0
addsd  %xmm1,%xmm0
call   1050 <sin@plt>
movsd  0xd6d(%rip),%xmm4
movsd  (%rsp),%xmm2
movss  (%rbx,%r12,2),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0x10(%rsp),%xmm1
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rbx,%r12,2)
add    $0x2,%r12
add    $0xffffffffffffffff,%r13
jne    1280 <gen_windowed_sines+0x130>
jmp    11f0 <gen_windowed_sines+0xa0>
test   %r14d,%r14d
mov    0x8(%rsp),%r15
jle    134f <gen_windowed_sines+0x1ff>
add    $0xffffffff,%r14d
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
movsd  %xmm0,(%rsp)
add    %r15,%r15
xor    %ebp,%ebp
nopl   0x0(%rax)
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0xd01(%rip),%xmm0
divsd  (%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1060 <cos@plt>
mulsd  0xcf3(%rip),%xmm0
addsd  0xcdb(%rip),%xmm0
movss  (%rbx,%rbp,2),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,(%rbx,%rbp,2)
add    $0x2,%rbp
cmp    %rbp,%r15
jne    1300 <gen_windowed_sines+0x1b0>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcc3(%rip),%rdi
lea    0xcfd(%rip),%rsi
mov    %ebp,%edx
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [65 x i8] c"\0A%s : Error : freq [%d] == %g is out of range. Should be < 0.5.\0A\00"
@.str.1 = [178 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bit-trade-one/SoundModuleAP/refs/heads/SoundModuleAP/lib-src/libsamplerate/tests/util.c\00"
define void @gen_windowed_sines(i32 %0, double* %1, double %2, float* %3, i32 %4) {
%6 = alloca i32
%7 = alloca double*
%8 = alloca double
%9 = alloca float*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca double
store i32 %0, i32* %6
store double* %1, double** %7
store double %2, double* %8
store float* %3, float** %9
store i32 %4, i32* %10
%15 = load double, double* %8
%16 = load i32, i32* %6
%17 = sitofp i32 %16 to double
%18 = fdiv double %15, %17
store double %18, double* %13
store i32 0, i32* %11
br label %19
19: ; preds = %28, %5
%20 = load i32, i32* %11
%21 = load i32, i32* %10
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %31
23: ; preds = %19
%24 = load float*, float** %9
%25 = load i32, i32* %11
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds float, float* %24, i64 %26
store float 0.000000e+00, float* %27
br label %28
28: ; preds = %23
%29 = load i32, i32* %11
%30 = add nsw i32 %29, 1
store i32 %30, i32* %11
br label %19
31: ; preds = %19
store i32 0, i32* %12
br label %32
32: ; preds = %93, %31
%33 = load i32, i32* %12
%34 = load i32, i32* %6
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %96
36: ; preds = %32
%37 = load i32, i32* %6
%38 = sitofp i32 %37 to double
%39 = fdiv double 0x40069E9565708EFC, %38
store double %39, double* %14
%40 = load double*, double** %7
%41 = load i32, i32* %12
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %40, i64 %42
%44 = load double, double* %43
%45 = fcmp ole double %44, 0.000000e+00
br i1 %45, label %53, label %46
46: ; preds = %36
%47 = load double*, double** %7
%48 = load i32, i32* %12
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %47, i64 %49
%51 = load double, double* %50
%52 = fcmp oge double %51, 5.000000e-01
br i1 %52, label %53, label %62
53: ; preds = %46, %36
%54 = load i32, i32* %12
%55 = load double*, double** %7
%56 = load i32, i32* %12
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds double, double* %55, i64 %57
%59 = load double, double* %58
%60 = call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.1, i64 0, i64 0), i32 %54, double %59)
%61 = call i32 @exit(i32 1)
unreachable
62: ; preds = %46
store i32 0, i32* %11
br label %63
63: ; preds = %89, %62
%64 = load i32, i32* %11
%65 = load i32, i32* %10
%66 = icmp slt i32 %64, %65
br i1 %66, label %67, label %92
67: ; preds = %63
%68 = load double, double* %13
%69 = load double*, double** %7
%70 = load i32, i32* %12
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds double, double* %69, i64 %71
%73 = load double, double* %72
%74 = load i32, i32* %11
%75 = mul nsw i32 2, %74
%76 = sitofp i32 %75 to double
%77 = fmul double %73, %76
%78 = load double, double* %14
%79 = call double @llvm.fmuladd.f64(double %77, double 0x400921FB54442D18, double %78)
%80 = call double @sin(double %79)
%81 = load float*, float** %9
%82 = load i32, i32* %11
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds float, float* %81, i64 %83
%85 = load float, float* %84
%86 = fpext float %85 to double
%87 = call double @llvm.fmuladd.f64(double %68, double %80, double %86)
%88 = fptrunc double %87 to float
store float %88, float* %84
br label %89
89: ; preds = %67
%90 = load i32, i32* %11
%91 = add nsw i32 %90, 1
store i32 %91, i32* %11
br label %63
92: ; preds = %63
br label %93
93: ; preds = %92
%94 = load i32, i32* %12
%95 = add nsw i32 %94, 1
store i32 %95, i32* %12
br label %32
96: ; preds = %32
store i32 0, i32* %11
br label %97
97: ; preds = %121, %96
%98 = load i32, i32* %11
%99 = load i32, i32* %10
%100 = icmp slt i32 %98, %99
br i1 %100, label %101, label %124
101: ; preds = %97
%102 = load i32, i32* %11
%103 = mul nsw i32 2, %102
%104 = sitofp i32 %103 to double
%105 = fmul double %104, 0x400921FB54442D18
%106 = load i32, i32* %10
%107 = sub nsw i32 %106, 1
%108 = sitofp i32 %107 to double
%109 = fdiv double %105, %108
%110 = fptosi double %109 to i32
%111 = call double @cos(i32 %110)
%112 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %111, double 5.000000e-01)
%113 = load float*, float** %9
%114 = load i32, i32* %11
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds float, float* %113, i64 %115
%117 = load float, float* %116
%118 = fpext float %117 to double
%119 = fmul double %118, %112
%120 = fptrunc double %119 to float
store float %120, float* %116
br label %121
121: ; preds = %101
%122 = load i32, i32* %11
%123 = add nsw i32 %122, 1
store i32 %123, i32* %11
br label %97
124: ; preds = %97
ret void
}

LLVM IR (-O2):
@.str = [65 x i8] c"\0A%s : Error : freq [%d] == %g is out of range. Should be < 0.5.\0A\00"
@.str.1 = [178 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bit-trade-one/SoundModuleAP/refs/heads/SoundModuleAP/lib-src/libsamplerate/tests/util.c\00"
define void @gen_windowed_sines(i32 %0, double* nocapture %1, double %2, float* nocapture %3, i32 %4) {
%6 = sitofp i32 %0 to double
%7 = fdiv double %2, %6
%8 = icmp sgt i32 %4, 0
br i1 %8, label %9, label %13
9: ; preds = %5
%10 = bitcast float* %3 to i8*
%11 = zext i32 %4 to i64
%12 = shl nuw nsw i64 %11, 2
br label %13
13: ; preds = %9, %5
%14 = icmp sgt i32 %0, 0
br i1 %14, label %15, label %20
15: ; preds = %13
%16 = fdiv double 0x40069E9565708EFC, %6
%17 = zext i32 %0 to i64
%18 = zext i32 %4 to i64
%19 = icmp eq i32 %4, 1
br label %25
20: ; preds = %61, %13
br i1 %8, label %21, label %81
21: ; preds = %20
%22 = add nsw i32 %4, -1
%23 = sitofp i32 %22 to double
%24 = zext i32 %4 to i64
br label %64
25: ; preds = %15, %61
%26 = phi i64 [ 0, %15 ], [ %62, %61 ]
%27 = getelementptr inbounds double, double* %1, i64 %26
%28 = load double, double* %27
%29 = fcmp ugt double %28, 0.000000e+00
%30 = fcmp ult double %28, 5.000000e-01
%31 = and i1 %29, %30
br i1 %31, label %32, label %41
32: ; preds = %25
br i1 %8, label %33, label %61
33: ; preds = %32
%34 = fmul double %28, 0.000000e+00
%35 = tail call double @llvm.fmuladd.f64(double %34, double 0x400921FB54442D18, double %16)
%36 = tail call double @sin(double %35)
%37 = load float, float* %3
%38 = fpext float %37 to double
%39 = tail call double @llvm.fmuladd.f64(double %7, double %36, double %38)
%40 = fptrunc double %39 to float
store float %40, float* %3
br i1 %19, label %61, label %45
41: ; preds = %25
%42 = trunc i64 %26 to i32
%43 = tail call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.1, i64 0, i64 0), i32 %42, double %28)
%44 = tail call i32 @exit(i32 1)
unreachable
45: ; preds = %33, %45
%46 = phi i64 [ %59, %45 ], [ 1, %33 ]
%47 = load double, double* %27
%48 = trunc i64 %46 to i32
%49 = shl i32 %48, 1
%50 = sitofp i32 %49 to double
%51 = fmul double %47, %50
%52 = tail call double @llvm.fmuladd.f64(double %51, double 0x400921FB54442D18, double %16)
%53 = tail call double @sin(double %52)
%54 = getelementptr inbounds float, float* %3, i64 %46
%55 = load float, float* %54
%56 = fpext float %55 to double
%57 = tail call double @llvm.fmuladd.f64(double %7, double %53, double %56)
%58 = fptrunc double %57 to float
store float %58, float* %54
%59 = add nuw nsw i64 %46, 1
%60 = icmp eq i64 %59, %18
br i1 %60, label %61, label %45
61: ; preds = %45, %33, %32
%62 = add nuw nsw i64 %26, 1
%63 = icmp eq i64 %62, %17
br i1 %63, label %20, label %25
64: ; preds = %21, %64
%65 = phi i64 [ 0, %21 ], [ %79, %64 ]
%66 = trunc i64 %65 to i32
%67 = shl i32 %66, 1
%68 = sitofp i32 %67 to double
%69 = fmul double %68, 0x400921FB54442D18
%70 = fdiv double %69, %23
%71 = fptosi double %70 to i32
%72 = tail call double @cos(i32 %71)
%73 = tail call double @llvm.fmuladd.f64(double %72, double -5.000000e-01, double 5.000000e-01)
%74 = getelementptr inbounds float, float* %3, i64 %65
%75 = load float, float* %74
%76 = fpext float %75 to double
%77 = fmul double %73, %76
%78 = fptrunc double %77 to float
store float %78, float* %74
%79 = add nuw nsw i64 %65, 1
%80 = icmp eq i64 %79, %24
br i1 %80, label %81, label %64
81: ; preds = %64, %20
ret void
}