// File: /workspace/github_cpp_makefile_star2_O3/Sleepwalking[P]world-octave/common.cpp
// Function: GetMinimumPhaseSpectrum(MinimumPhaseAnalysis*)
void GetMinimumPhaseSpectrum(MinimumPhaseAnalysis *minimum_phase) {
  // Mirroring
  for (int i = minimum_phase->fft_size / 2 + 1;
      i < minimum_phase->fft_size; ++i)
    minimum_phase->log_spectrum[i] =
    minimum_phase->log_spectrum[minimum_phase->fft_size - i];

  // This fft_plan carries out "forward" FFT.
  // To carriy out the Inverse FFT, the sign of imaginary part
  // is inverted after FFT.
  fft_execute(minimum_phase->inverse_fft);
  minimum_phase->cepstrum[0][1] *= -1.0;
  for (int i = 1; i < minimum_phase->fft_size / 2; ++i) {
    minimum_phase->cepstrum[i][0] *= 2.0;
    minimum_phase->cepstrum[i][1] *= -2.0;
  }
  minimum_phase->cepstrum[minimum_phase->fft_size / 2][1] *= -1.0;
  for (int i = minimum_phase->fft_size / 2 + 1;
      i < minimum_phase->fft_size; ++i) {
    minimum_phase->cepstrum[i][0] = 0.0;
    minimum_phase->cepstrum[i][1] = 0.0;
  }

  fft_execute(minimum_phase->forward_fft);

  // Since x is complex number, calculation of exp(x) is as following.
  // Note: This FFT library does not keep the aliasing.
  double tmp;
  for (int i = 0; i <= minimum_phase->fft_size / 2; ++i) {
    tmp = exp(minimum_phase->minimum_phase_spectrum[i][0] /
      minimum_phase->fft_size);
    minimum_phase->minimum_phase_spectrum[i][0] = tmp *
      cos(minimum_phase->minimum_phase_spectrum[i][1] /
      minimum_phase->fft_size);
    minimum_phase->minimum_phase_spectrum[i][1] = tmp *
      sin(minimum_phase->minimum_phase_spectrum[i][1] /
      minimum_phase->fft_size);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x50, %rsp
movq %rdi, %rbx
movslq (%rdi), %rsi
movl %esi, %edx
shrl $0x1f, %edx
addl %esi, %edx
sarl %edx
leal 0x1(%rdx), %ecx
cmpl %esi, %ecx
jge 0x1c48
movq 0x8(%rbx), %rax
movslq %ecx, %rcx
movslq %edx, %rdx
notq %rdx
addq %rsi, %rdx
movsd (%rax,%rdx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
incq %rcx
decq %rdx
jne 0x1c36
leaq 0x20(%rbx), %rsi
movl $0x9, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
callq 0x8792
movq 0x18(%rbx), %rax
movsd 0x8(%rax), %xmm0
xorpd 0xd423(%rip), %xmm0     # 0xf090
movlpd %xmm0, 0x8(%rax)
movl (%rbx), %edx
movl %edx, %ecx
shrl $0x1f, %ecx
addl %edx, %ecx
sarl %ecx
cmpl $0x4, %edx
jl 0x1cb5
cmpl $0x3, %ecx
movl $0x2, %esi
cmovgel %ecx, %esi
shlq $0x4, %rsi
movl $0x10, %edi
movapd 0xd412(%rip), %xmm0     # 0xf0b0
movupd (%rax,%rdi), %xmm1
mulpd %xmm0, %xmm1
movupd %xmm1, (%rax,%rdi)
addq $0x10, %rdi
cmpq %rdi, %rsi
jne 0x1c9e
movslq %ecx, %rsi
shlq $0x4, %rsi
movsd 0x8(%rax,%rsi), %xmm0
xorpd 0xd3c6(%rip), %xmm0     # 0xf090
movlpd %xmm0, 0x8(%rax,%rsi)
leal 0x1(%rcx), %edi
cmpl %edx, %edi
jge 0x1cf3
leaq (%rax,%rsi), %rdi
addq $0x10, %rdi
subl %ecx, %edx
addl $-0x2, %edx
shlq $0x4, %rdx
addq $0x10, %rdx
xorl %esi, %esi
callq 0x1080
leaq 0x68(%rbx), %rsi
movl $0x9, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
callq 0x8792
movl (%rbx), %eax
cmpl $-0x1, %eax
jl 0x1dad
movq 0x10(%rbx), %rcx
movq $-0x1, %r14
xorl %r15d, %r15d
movsd (%rcx,%r15), %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
callq 0x11a0
movsd %xmm0, 0x48(%rsp)
movq 0x10(%rbx), %rax
movsd 0x8(%rax,%r15), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl (%rbx), %xmm1
divsd %xmm1, %xmm0
callq 0x11b0
mulsd 0x48(%rsp), %xmm0
movq 0x10(%rbx), %rax
movsd %xmm0, (%rax,%r15)
movsd 0x8(%rax,%r15), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl (%rbx), %xmm1
divsd %xmm1, %xmm0
callq 0x1060
mulsd 0x48(%rsp), %xmm0
movq 0x10(%rbx), %rcx
movsd %xmm0, 0x8(%rcx,%r15)
movl (%rbx), %eax
movl %eax, %edx
shrl $0x1f, %edx
addl %eax, %edx
sarl %edx
movslq %edx, %rdx
incq %r14
addq $0x10, %r15
cmpq %rdx, %r14
jl 0x1d20
addq $0x50, %rsp
popq %rbx
popq %r14
popq %r15
retq