// File: /workspace/github_cpp_makefile_star2_O1/Sleepwalking[P]world-octave/common.cpp
// Function: LinearSmoothing(double*, double, int, int, double*)
void LinearSmoothing(double *input, double width, int fs, int fft_size,
    double *output) {
  int boundary = static_cast<int>(width * fft_size / fs) + 1;

  // These parameters are set by the other function.
  double *mirroring_spectrum = new double[fft_size / 2 + boundary * 2 + 1];
  double *mirroring_segment = new double[fft_size / 2 + boundary * 2 + 1];
  double *frequency_axis = new double[fft_size / 2 + 1];
  SetParametersForLinearSmoothing(boundary, fft_size, fs, width,
      input, mirroring_spectrum, mirroring_segment, frequency_axis);

  double *low_levels = new double[fft_size / 2 + 1];
  double *high_levels = new double[fft_size / 2 + 1];
  double origin_of_mirroring_axis =
    -(static_cast<double>(boundary) - 0.5) * fs / fft_size;
  double discrete_frequency_interval = static_cast<double>(fs) / fft_size;

  interp1Q(origin_of_mirroring_axis, discrete_frequency_interval,
      mirroring_segment, fft_size / 2 + boundary * 2 + 1, frequency_axis,
      fft_size / 2 + 1, low_levels);

  for (int i = 0; i <= fft_size / 2; ++i) frequency_axis[i] += width;

  interp1Q(origin_of_mirroring_axis, discrete_frequency_interval,
      mirroring_segment, fft_size / 2 + boundary * 2 + 1, frequency_axis,
      fft_size / 2 + 1, high_levels);

  for (int i = 0; i <= fft_size / 2; ++i)
    output[i] = (high_levels[i] - low_levels[i]) / width;

  delete[] mirroring_spectrum;
  delete[] mirroring_segment;
  delete[] frequency_axis;
  delete[] low_levels;
  delete[] high_levels;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, 0x50(%rsp)
movl %edx, %r13d
movq %rdi, %rbp
cvtsi2sd %edx, %xmm1
movsd %xmm1, 0x38(%rsp)
movsd %xmm0, 0x10(%rsp)
mulsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
movsd %xmm0, 0x8(%rsp)
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %edx
movq %rdx, 0x40(%rsp)
leal 0x1(%rdx), %eax
movq %rax, 0x20(%rsp)
movl %r13d, %r15d
shrl $0x1f, %r15d
addl %r13d, %r15d
sarl %r15d
leal (%r15,%rdx,2), %ecx
addl $0x2, %ecx
leal (%r15,%rdx,2), %eax
addl $0x3, %eax
movl %eax, 0x4(%rsp)
movslq %eax, %rbx
shlq $0x3, %rbx
movl %ecx, 0x1c(%rsp)
cmpl $-0x1, %ecx
movq $-0x1, %rax
cmovlq %rax, %rbx
movq %rbx, %rdi
callq 0x1030
movq %rax, %r14
movq %rbx, %rdi
callq 0x1030
movq %rax, %r12
movq %r15, 0x30(%rsp)
movslq %r15d, %rax
movl %r13d, (%rsp)
cmpl $-0x3, %r13d
leaq 0x8(,%rax,8), %rdi
movq $-0x1, %rax
cmovlq %rax, %rdi
movq %rdi, 0x48(%rsp)
callq 0x1030
movq 0x40(%rsp), %rdx
movq %rax, %r13
testl %edx, %edx
js 0x1516
movl 0x20(%rsp), %eax
movq %r14, %rcx
movsd (%rbp,%rax,8), %xmm0
movsd %xmm0, (%rcx)
addq $0x8, %rcx
decq %rax
jne 0x1503
leal 0x2(,%rdx,2), %ecx
movq 0x30(%rsp), %r15
movq 0x20(%rsp), %rax
leal (%rax,%r15), %ebx
cmpl $0x2, (%rsp)
jl 0x156f
movslq %ebx, %rax
movq %rdx, %r15
movslq %r15d, %rdx
movl %ecx, 0x18(%rsp)
leaq 0x2(%rdx), %rcx
cmpq %rax, %rcx
cmovgq %rcx, %rax
leaq (%r14,%rdx,8), %rdi
addq $0x8, %rdi
notq %rdx
addq %rax, %rdx
shlq $0x3, %rdx
movq %rbp, %rsi
callq 0x10b0
movl 0x18(%rsp), %ecx
movq %r15, %rdx
movq 0x30(%rsp), %r15
cmpl %edx, %ecx
movsd 0x8(%rsp), %xmm2
movsd 0x38(%rsp), %xmm3
movl 0x1c(%rsp), %edi
jle 0x15b0
movslq %ebx, %rax
cmpl %edi, %ebx
cmovlel %edi, %ebx
subl %edx, %ebx
subl %r15d, %ebx
leaq (%r14,%rax,8), %rax
xorl %ecx, %ecx
movl %r15d, %edx
movslq %edx, %rdx
movsd (%rbp,%rdx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
incq %rcx
decl %edx
cmpl %ecx, %ebx
jne 0x1599
movsd (%r14), %xmm0
mulsd %xmm2, %xmm0
divsd %xmm3, %xmm0
movsd %xmm0, (%r12)
testl %edi, %edi
jle 0x15f6
movl 0x4(%rsp), %eax
movsd (%r12), %xmm0
movl $0x1, %ecx
movsd (%r14,%rcx,8), %xmm1
mulsd %xmm2, %xmm1
divsd %xmm3, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, (%r12,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x15d6
incl %r15d
cmpl $-0x1, (%rsp)
jl 0x1634
movsd 0xda19(%rip), %xmm0     # 0xf020
mulsd 0x10(%rsp), %xmm0
movl %r15d, %eax
xorl %ecx, %ecx
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
divsd %xmm3, %xmm1
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%r13,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x1612
movq 0x48(%rsp), %rbx
movq %rbx, %rdi
callq 0x1030
movq %rax, %rbp
movq %rbx, %rdi
callq 0x1030
xorps %xmm0, %xmm0
cvtsi2sdl 0x20(%rsp), %xmm0
addsd 0xd9c3(%rip), %xmm0     # 0xf020
xorpd 0xda0b(%rip), %xmm0     # 0xf070
movq %rax, %rbx
movsd 0x8(%rsp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x38(%rsp), %xmm2
divsd %xmm2, %xmm0
divsd %xmm2, %xmm1
movapd %xmm0, 0x20(%rsp)
movsd %xmm1, 0x8(%rsp)
movq %r12, %rdi
movl 0x4(%rsp), %esi
movq %r13, %rdx
movl %r15d, %ecx
movq %rbp, %r8
callq 0x4607
cmpl $-0x1, (%rsp)
movsd 0x10(%rsp), %xmm1
jl 0x16cc
movl %r15d, %eax
xorl %edx, %edx
movsd (%r13,%rdx,8), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%r13,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x16b2
movapd 0x20(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
movq %r12, %rdi
movl 0x4(%rsp), %esi
movq %r13, %rdx
movl %r15d, %ecx
movq %rbx, %r8
callq 0x4607
movsd 0x10(%rsp), %xmm1
cmpl $-0x1, (%rsp)
movq 0x50(%rsp), %rdx
jl 0x171f
movl %r15d, %eax
xorl %ecx, %ecx
movsd (%rbx,%rcx,8), %xmm0
subsd (%rbp,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rdx,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x1703
movq %r14, %rdi
callq 0x1110
movq %r12, %rdi
callq 0x1110
movq %r13, %rdi
callq 0x1110
movq %rbp, %rdi
callq 0x1110
movq %rbx, %rdi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1110