// File: /workspace/github_cpp_makefile_star2_O1/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 0x1a9f
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 0x1a8d
leaq 0x20(%rbx), %rsi
movl $0x9, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
callq 0x7f1a
movq 0x18(%rbx), %rax
movsd 0x8(%rax), %xmm0
xorpd 0xd5ac(%rip), %xmm0     # 0xf070
movlpd %xmm0, 0x8(%rax)
movl (%rbx), %edx
movl %edx, %ecx
shrl $0x1f, %ecx
addl %edx, %ecx
sarl %ecx
cmpl $0x4, %edx
jl 0x1b1f
cmpl $0x3, %ecx
movl $0x2, %esi
cmovgel %ecx, %esi
shlq $0x4, %rsi
addq $-0x10, %rsi
xorl %edi, %edi
movsd 0xd56a(%rip), %xmm0     # 0xf060
movsd 0x10(%rax,%rdi), %xmm1
movsd 0x18(%rax,%rdi), %xmm2
addsd %xmm1, %xmm1
movsd %xmm1, 0x10(%rax,%rdi)
mulsd %xmm0, %xmm2
movsd %xmm2, 0x18(%rax,%rdi)
addq $0x10, %rdi
cmpq %rdi, %rsi
jne 0x1af6
movslq %ecx, %rsi
shlq $0x4, %rsi
movsd 0x8(%rax,%rsi), %xmm0
xorpd 0xd53c(%rip), %xmm0     # 0xf070
movlpd %xmm0, 0x8(%rax,%rsi)
leal 0x1(%rcx), %edi
cmpl %edx, %edi
jge 0x1b5d
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 0x7f1a
movl (%rbx), %eax
cmpl $-0x1, %eax
jl 0x1c17
movq $-0x1, %r14
xorl %r15d, %r15d
movq 0x10(%rbx), %rcx
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), %rax
movsd %xmm0, 0x8(%rax,%r15)
movl (%rbx), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
movslq %ecx, %rcx
incq %r14
addq $0x10, %r15
cmpq %rcx, %r14
jl 0x1b86
addq $0x50, %rsp
popq %rbx
popq %r14
popq %r15
retq