// File: Sleepwalking[P]world-octave/synthesis.cpp
// Function: (anonymous namespace)::GetAperiodicResponse(int, int, double*, double*, double, ForwardRealFFT*, InverseRealFFT*, MinimumPhaseAnalysis*, double*)
void GetAperiodicResponse(int noise_size, int fft_size,
    double *spectrum, double *aperiodic_ratio, double current_vuv,
    ForwardRealFFT *forward_real_fft,
    InverseRealFFT *inverse_real_fft, MinimumPhaseAnalysis *minimum_phase,
    double *aperiodic_response) {
  GetNoiseSpectrum(noise_size, fft_size, forward_real_fft);

  if (current_vuv != 0.0) {
    for (int i = 0; i <= minimum_phase->fft_size / 2; ++i)
      minimum_phase->log_spectrum[i] =
        log(spectrum[i] * aperiodic_ratio[i]) / 2.0;
  } else {
    for (int i = 0; i <= minimum_phase->fft_size / 2; ++i)
      minimum_phase->log_spectrum[i] = log(spectrum[i]) / 2.0;
  }
  GetMinimumPhaseSpectrum(minimum_phase);

  for (int i = 0; i <= fft_size / 2; ++i) {
    inverse_real_fft->spectrum[i][0] =
      minimum_phase->minimum_phase_spectrum[i][0];
    inverse_real_fft->spectrum[i][1] =
      minimum_phase->minimum_phase_spectrum[i][1];

    inverse_real_fft->spectrum[i][0] =
      minimum_phase->minimum_phase_spectrum[i][0] *
      forward_real_fft->spectrum[i][0] -
      minimum_phase->minimum_phase_spectrum[i][1] *
      forward_real_fft->spectrum[i][1];
    inverse_real_fft->spectrum[i][1] =
      minimum_phase->minimum_phase_spectrum[i][0] *
      forward_real_fft->spectrum[i][1] +
      minimum_phase->minimum_phase_spectrum[i][1] *
      forward_real_fft->spectrum[i][0];
  }
  fft_execute(inverse_real_fft->inverse_fft);
  fftshift(inverse_real_fft->waveform, fft_size, aperiodic_response);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movsd %xmm0, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl -0x4(%rbp), %edi
movl -0x8(%rbp), %esi
movq -0x28(%rbp), %rdx
callq 0x65e0
movsd -0x20(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x62df
jp 0x62df
jmp 0x6352
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x8c(%rbp)
movq 0x10(%rbp), %rax
movl (%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x8c(%rbp), %eax
cmpl %ecx, %eax
jg 0x6350
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm0
callq 0x10a0
movsd 0x15cd8(%rip), %xmm1    # 0x1c008
divsd %xmm1, %xmm0
movq 0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x34(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x62e6
jmp 0x63b8
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0x90(%rbp)
movq 0x10(%rbp), %rax
movl (%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x90(%rbp), %eax
cmpl %ecx, %eax
jg 0x63b6
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
callq 0x10a0
movsd 0x15c72(%rip), %xmm1    # 0x1c008
divsd %xmm1, %xmm0
movq 0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x38(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x6359
jmp 0x63b8
movq 0x10(%rbp), %rdi
callq 0x1f90
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x94(%rbp)
movl -0x8(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x94(%rbp), %eax
cmpl %ecx, %eax
jg 0x656a
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm2
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm1
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
mulsd 0x8(%rax), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm2
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm1
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
mulsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x63c8
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
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movl -0x8(%rbp), %esi
movq 0x18(%rbp), %rdx
callq 0x6710
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)