// File: /workspace/github_cpp_makefile_star2_O3/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 $0x78, %rsp
movq %rcx, 0x50(%rsp)
movl %edx, %r13d
movq %rdi, %rbx
cvtsi2sd %edx, %xmm1
movapd %xmm1, 0x60(%rsp)
movsd %xmm0, 0x20(%rsp)
mulsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
movapd %xmm0, 0x40(%rsp)
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %ebp
leal 0x1(%rbp), %eax
movq %rax, 0x30(%rsp)
movl %edx, %r12d
shrl $0x1f, %r12d
addl %edx, %r12d
sarl %r12d
leal (%r12,%rbp,2), %ecx
addl $0x2, %ecx
leal (%r12,%rbp,2), %eax
addl $0x3, %eax
movl %eax, 0x1c(%rsp)
movslq %eax, %r15
shlq $0x3, %r15
movl %ecx, 0x2c(%rsp)
cmpl $-0x1, %ecx
movq $-0x1, %rax
cmovlq %rax, %r15
movq %r15, %rdi
callq 0x1030
movq %rax, %r14
movq %r15, %rdi
callq 0x1030
movq %rax, %r15
movq %r12, 0x10(%rsp)
movslq %r12d, %rax
movl %r13d, 0xc(%rsp)
cmpl $-0x3, %r13d
leaq 0x8(,%rax,8), %rdi
movq $-0x1, %rax
cmovlq %rax, %rdi
movq %rdi, 0x58(%rsp)
callq 0x1030
movq %rax, %r12
testl %ebp, %ebp
js 0x15bb
movl 0x30(%rsp), %eax
movq %r14, %rcx
movsd (%rbx,%rax,8), %xmm0
movsd %xmm0, (%rcx)
addq $0x8, %rcx
decq %rax
jne 0x15a9
leal 0x2(,%rbp,2), %edx
movq 0x10(%rsp), %rax
movq 0x30(%rsp), %rcx
leal (%rcx,%rax), %r13d
cmpl $0x2, 0xc(%rsp)
jl 0x160a
movslq %r13d, %rax
movl %edx, 0x28(%rsp)
movslq %ebp, %rdx
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 %rbx, %rsi
callq 0x10b0
movl 0x28(%rsp), %edx
cmpl %ebp, %edx
movapd 0x40(%rsp), %xmm12
movl 0x1c(%rsp), %esi
movapd 0x60(%rsp), %xmm13
movl 0x2c(%rsp), %edi
jle 0x1656
movslq %r13d, %rax
cmpl %edi, %r13d
cmovlel %edi, %r13d
subl %ebp, %r13d
movq 0x10(%rsp), %rdx
subl %edx, %r13d
leaq (%r14,%rax,8), %rax
xorl %ecx, %ecx
movslq %edx, %rdx
movsd (%rbx,%rdx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
incq %rcx
decl %edx
cmpl %ecx, %r13d
jne 0x163f
movsd (%r14), %xmm0
mulsd %xmm12, %xmm0
divsd %xmm13, %xmm0
movsd %xmm0, (%r15)
testl %edi, %edi
jle 0x169c
movl %esi, %eax
movsd (%r15), %xmm0
movl $0x1, %ecx
movsd (%r14,%rcx,8), %xmm1
mulsd %xmm12, %xmm1
divsd %xmm13, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, (%r15,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x167a
movq 0x10(%rsp), %r13
incl %r13d
cmpl $-0x1, 0xc(%rsp)
jl 0x17ad
movl %r13d, %ecx
movsd 0xd966(%rip), %xmm0     # 0xf020
mulsd 0x20(%rsp), %xmm0
leaq 0x1(%rcx), %rax
andq $-0x2, %rax
decq %rcx
movq %rcx, %xmm1
pshufd $0x44, %xmm1, %xmm1     # xmm1 = xmm1[0,1,0,1]
movapd %xmm12, %xmm2
unpcklpd %xmm12, %xmm2           # xmm2 = xmm2[0],xmm12[0]
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movapd %xmm13, %xmm3
unpcklpd %xmm13, %xmm3           # xmm3 = xmm3[0],xmm13[0]
movdqa 0xd96b(%rip), %xmm4     # 0xf060
xorl %ecx, %ecx
movdqa 0xd971(%rip), %xmm5     # 0xf070
pxor %xmm5, %xmm1
movdqa 0xd995(%rip), %xmm6     # 0xf0a0
pcmpeqd %xmm7, %xmm7
movdqa 0xd968(%rip), %xmm8     # 0xf080
movdqa %xmm4, %xmm9
pxor %xmm5, %xmm9
movdqa %xmm9, %xmm10
pcmpgtd %xmm1, %xmm10
pcmpeqd %xmm1, %xmm9
pshufd $0xf5, %xmm9, %xmm9     # xmm9 = xmm9[1,1,3,3]
pand %xmm10, %xmm9
pshufd $0xf5, %xmm10, %xmm10   # xmm10 = xmm10[1,1,3,3]
por %xmm9, %xmm10
movd %ecx, %xmm9
leal 0x1(%rcx), %edx
movd %edx, %xmm11
punpcklqdq %xmm11, %xmm9   # xmm9 = xmm9[0],xmm11[0]
por %xmm6, %xmm9
subpd %xmm6, %xmm9
divpd %xmm3, %xmm9
mulpd %xmm2, %xmm9
addpd %xmm0, %xmm9
movd %xmm10, %edx
notl %edx
testb $0x1, %dl
je 0x1784
movlpd %xmm9, (%r12,%rcx,8)
pxor %xmm7, %xmm10
pextrw $0x4, %xmm10, %edx
testb $0x1, %dl
je 0x179b
movhpd %xmm9, 0x8(%r12,%rcx,8)
addq $0x2, %rcx
paddq %xmm8, %xmm4
cmpq %rcx, %rax
jne 0x1718
movq %r13, 0x10(%rsp)
movq 0x58(%rsp), %r13
movq %r13, %rdi
callq 0x1030
movq %rax, %rbx
movq %r13, %rdi
callq 0x1030
xorps %xmm0, %xmm0
cvtsi2sdl 0x30(%rsp), %xmm0
addsd 0xd845(%rip), %xmm0     # 0xf020
xorpd 0xd8ad(%rip), %xmm0     # 0xf090
movq %rax, %rbp
movapd 0x40(%rsp), %xmm1
mulsd %xmm1, %xmm0
movapd 0x60(%rsp), %xmm2
divsd %xmm2, %xmm0
divsd %xmm2, %xmm1
movapd %xmm0, 0x30(%rsp)
movapd %xmm1, 0x40(%rsp)
movq %r15, %rdi
movl 0x1c(%rsp), %r13d
movl %r13d, %esi
movq %r12, %rdx
movq 0x10(%rsp), %rcx
movq %rbx, %r8
callq 0x4bd0
cmpl $-0x2, 0xc(%rsp)
jg 0x1850
movapd 0x30(%rsp), %xmm0
movapd 0x40(%rsp), %xmm1
movq %r15, %rdi
movl %r13d, %esi
movq %r12, %rdx
movq 0x10(%rsp), %rcx
movq %rbp, %r8
callq 0x4bd0
jmp 0x18c8
movapd 0x30(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
movq 0x10(%rsp), %r13
movq %r13, %rcx
movl %r13d, %r13d
xorl %eax, %eax
movsd 0x20(%rsp), %xmm2
movsd (%r12,%rax,8), %xmm3
addsd %xmm2, %xmm3
movsd %xmm3, (%r12,%rax,8)
incq %rax
cmpq %rax, %r13
jne 0x186e
movq %r15, %rdi
movl 0x1c(%rsp), %esi
movq %r12, %rdx
movq %rbp, %r8
callq 0x4bd0
movsd 0x20(%rsp), %xmm1
cmpl $-0x1, 0xc(%rsp)
movq 0x50(%rsp), %rcx
jl 0x18c8
xorl %eax, %eax
movsd (%rbp,%rax,8), %xmm0
subsd (%rbx,%rax,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rcx,%rax,8)
incq %rax
cmpq %rax, %r13
jne 0x18ac
movq %r14, %rdi
callq 0x1110
movq %r15, %rdi
callq 0x1110
movq %r12, %rdi
callq 0x1110
movq %rbx, %rdi
callq 0x1110
movq %rbp, %rdi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1110