// File: /workspace/github_cpp_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
movslq (%rdi), %rcx
pushq $0x2
popq %rbp
movl %ecx, %eax
cltd
idivl %ebp
cltq
leaq 0x1(%rax), %rdx
notq %rax
addq %rcx, %rax
cmpq %rcx, %rdx
jge 0x1a35
movq 0x8(%rbx), %rsi
movsd (%rsi,%rax,8), %xmm0
movsd %xmm0, (%rsi,%rdx,8)
incq %rdx
decq %rax
jmp 0x1a1a
leaq 0x20(%rbx), %rsi
pushq $0x9
popq %rcx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
callq 0x752b
movq 0x18(%rbx), %rsi
movsd 0x8(%rsi), %xmm0
xorps 0xb609(%rip), %xmm0     # 0xd060
movlps %xmm0, 0x8(%rsi)
movslq (%rbx), %rcx
movl %ecx, %eax
cltd
idivl %ebp
cltq
leaq 0x10(%rsi), %rdx
pushq $0x1
popq %rdi
movapd 0xb5fc(%rip), %xmm0     # 0xd070
cmpq %rax, %rdi
jge 0x1a8e
movupd (%rdx), %xmm1
mulpd %xmm0, %xmm1
movupd %xmm1, (%rdx)
incq %rdi
addq $0x10, %rdx
jmp 0x1a74
movq %rax, %rdx
shlq $0x4, %rdx
addq %rsi, %rdx
addq $0x10, %rdx
movsd -0x8(%rdx), %xmm0
xorpd 0xb5b7(%rip), %xmm0     # 0xd060
movlpd %xmm0, -0x8(%rdx)
incq %rax
xorpd %xmm0, %xmm0
cmpq %rcx, %rax
jge 0x1ac7
movupd %xmm0, (%rdx)
incq %rax
addq $0x10, %rdx
jmp 0x1ab5
leaq 0x68(%rbx), %rsi
pushq $0x9
popq %rcx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
callq 0x752b
xorl %r14d, %r14d
xorl %r15d, %r15d
movl (%rbx), %ecx
movl %ecx, %eax
cltd
idivl %ebp
cltq
cmpq %rax, %r15
jg 0x1b63
movq 0x10(%rbx), %rax
movsd (%rax,%r14), %xmm0
cvtsi2sd %ecx, %xmm1
divsd %xmm1, %xmm0
callq 0x11a0
movsd %xmm0, 0x50(%rsp)
movq 0x10(%rbx), %rax
movsd 0x8(%rax,%r14), %xmm0
cvtsi2sdl (%rbx), %xmm1
divsd %xmm1, %xmm0
callq 0x11b0
mulsd 0x50(%rsp), %xmm0
movq 0x10(%rbx), %rax
movsd %xmm0, (%rax,%r14)
movsd 0x8(%rax,%r14), %xmm0
cvtsi2sdl (%rbx), %xmm1
divsd %xmm1, %xmm0
callq 0x1060
mulsd 0x50(%rsp), %xmm0
movq 0x10(%rbx), %rax
movsd %xmm0, 0x8(%rax,%r14)
incq %r15
addq $0x10, %r14
jmp 0x1adf
addq $0x58, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq