// File: Sleepwalking[P]world-octave/common.cpp
// Function: (anonymous namespace)::SetParametersForLinearSmoothing(int, int, int, double, double*, double*, double*, double*)
void SetParametersForLinearSmoothing(int boundary, int fft_size, int fs,
    double width, double *power_spectrum, double *mirroring_spectrum,
    double *mirroring_segment, double *frequency_axis) {
  for (int i = 0; i < boundary; ++i)
    mirroring_spectrum[i] = power_spectrum[boundary - i];
  for (int i = boundary; i < fft_size / 2 + boundary; ++i)
    mirroring_spectrum[i] = power_spectrum[i - boundary];
  for (int i = fft_size / 2 + boundary; i <= fft_size / 2 + boundary * 2; ++i)
    mirroring_spectrum[i] =
      power_spectrum[fft_size / 2 - (i - (fft_size / 2 + boundary))];

  mirroring_segment[0] = mirroring_spectrum[0] * fs / fft_size;
  for (int i = 1; i < fft_size / 2 + boundary * 2 + 1; ++i)
    mirroring_segment[i] = mirroring_spectrum[i] * fs / fft_size +
    mirroring_segment[i - 1];

  for (int i = 0; i <= fft_size / 2; ++i)
    frequency_axis[i] = static_cast<double>(i) / fft_size *
    fs - width / 2.0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq 0x10(%rbp), %rax
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movsd %xmm0, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x18cb
movq -0x20(%rbp), %rax
movl -0x4(%rbp), %ecx
subl -0x34(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x34(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1899
movl -0x4(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x8(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x48(%rbp), %eax
addl -0x4(%rbp), %ecx
cmpl %ecx, %eax
jge 0x1918
movq -0x20(%rbp), %rax
movl -0x38(%rbp), %ecx
subl -0x4(%rbp), %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x18d1
movl -0x8(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
addl -0x4(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x8(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x4c(%rbp), %eax
movl -0x4(%rbp), %edx
shll %edx
addl %edx, %ecx
cmpl %ecx, %eax
jg 0x19a0
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
movl -0x8(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x3c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x8(%rbp), %eax
movl $0x2, %esi
cltd
idivl %esi
movl -0x5c(%rbp), %edx
movl %eax, %esi
movq -0x58(%rbp), %rax
addl -0x4(%rbp), %esi
subl %esi, %edx
subl %edx, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1929
movq -0x28(%rbp), %rax
movsd (%rax), %xmm0
cvtsi2sdl -0xc(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvtsi2sdl -0x8(%rbp), %xmm1
divsd %xmm1, %xmm0
movq -0x30(%rbp), %rax
movsd %xmm0, (%rax)
movl $0x1, -0x40(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x8(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x60(%rbp), %eax
movl -0x4(%rbp), %edx
shll %edx
addl %edx, %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x1a36
movq -0x28(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
cvtsi2sdl -0xc(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvtsi2sdl -0x8(%rbp), %xmm1
divsd %xmm1, %xmm0
movq -0x30(%rbp), %rax
movl -0x40(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
addsd (%rax,%rcx,8), %xmm0
movq -0x30(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x19c9
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x8(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x64(%rbp), %eax
cmpl %ecx, %eax
jg 0x1ab2
cvtsi2sdl -0x44(%rbp), %xmm0
cvtsi2sdl -0x8(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsi2sdl -0xc(%rbp), %xmm2
movsd -0x18(%rbp), %xmm1
movsd 0x1a591(%rip), %xmm3    # 0x1c008
divsd %xmm3, %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x10(%rbp), %rax
movslq -0x44(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x1a3d
popq %rbp
retq
nopw %cs:(%rax,%rax)