// File: Sleepwalking[P]world-octave/d4c.cpp
// Function: (anonymous namespace)::GetSmoothedPowerSpectrum(double*, int, int, double, int, double, ForwardRealFFT*, double*)
void GetSmoothedPowerSpectrum(double *x, int x_length, int fs,
    double current_f0, int fft_size, double temporal_position,
    ForwardRealFFT *forward_real_fft, double *smoothed_power_spectrum) {
  for (int i = 0; i < fft_size; ++i) forward_real_fft->waveform[i] = 0.0;
  GetWindowedWaveform(x, x_length, fs, current_f0,
      temporal_position, world::kHanning, 4.0, forward_real_fft->waveform);

  fft_execute(forward_real_fft->forward_fft);
  for (int i = 0; i <= fft_size / 2; ++i) {
    smoothed_power_spectrum[i] =
      forward_real_fft->spectrum[i][0] * forward_real_fft->spectrum[i][0] +
      forward_real_fft->spectrum[i][1] * forward_real_fft->spectrum[i][1];
  }
  DCCorrection(smoothed_power_spectrum, current_f0, fs, fft_size,
      smoothed_power_spectrum);
  LinearSmoothing(smoothed_power_spectrum, current_f0, fs, fft_size,
      smoothed_power_spectrum);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movsd %xmm1, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0xaed8
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x3c(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xaeb1
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movsd -0x18(%rbp), %xmm0
movsd -0x28(%rbp), %xmm1
movq -0x30(%rbp), %rax
movq 0x8(%rax), %r8
movl $0x1, %ecx
movsd 0x111cf(%rip), %xmm2    # 0x1c0d0
callq 0xb9d0
movq -0x30(%rbp), %rsi
addq $0x18, %rsi
leaq -0x88(%rbp), %rdi
movl $0x48, %edx
callq 0x10b0
movq -0x48(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x40(%rax)
movups -0x88(%rbp), %xmm0
movups -0x78(%rbp), %xmm1
movups -0x68(%rbp), %xmm2
movups -0x58(%rbp), %xmm3
movups %xmm3, 0x30(%rax)
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0xd500
movl $0x0, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
movl %eax, -0x90(%rbp)
movl -0x1c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x90(%rbp), %eax
cmpl %ecx, %eax
jg 0xb018
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x8c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x8c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm2
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x8c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm1
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x8c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
mulsd 0x8(%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x38(%rbp), %rax
movslq -0x8c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0xaf5b
movq -0x38(%rbp), %rdi
movsd -0x18(%rbp), %xmm0
movl -0x10(%rbp), %esi
movl -0x1c(%rbp), %edx
movq -0x38(%rbp), %rcx
callq 0x1310
movq -0x38(%rbp), %rdi
movsd -0x18(%rbp), %xmm0
movl -0x10(%rbp), %esi
movl -0x1c(%rbp), %edx
movq -0x38(%rbp), %rcx
callq 0x14d0
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)