// File: Sleepwalking[P]world-octave/synthesis.cpp
// Function: (anonymous namespace)::GetOneFrameSegment(double, int, double**, int, double**, int, double, double, int, ForwardRealFFT*, InverseRealFFT*, MinimumPhaseAnalysis*, double*)
void GetOneFrameSegment(double current_vuv, int noise_size,
    double **spectrogram, int fft_size, double **aperiodicity, int f0_length,
    double frame_period, double current_time, int fs,
    ForwardRealFFT *forward_real_fft, InverseRealFFT *inverse_real_fft,
    MinimumPhaseAnalysis *minimum_phase, double *response) {
  double *aperiodic_response = new double[fft_size];
  double *periodic_response = new double[fft_size];

  double *spectral_envelope = new double[fft_size];
  double *aperiodic_ratio = new double[fft_size];
  GetSpectralEnvelope(current_time, frame_period, f0_length, spectrogram,
      fft_size, spectral_envelope);
  GetAperiodicRatio(current_time, frame_period, f0_length, aperiodicity,
      fft_size, aperiodic_ratio);

  // Synthesis of the periodic response
  GetPeriodicResponse(fft_size, spectral_envelope, aperiodic_ratio,
    current_vuv, inverse_real_fft, minimum_phase, periodic_response);

  // Synthesis of the aperiodic response
  GetAperiodicResponse(noise_size, fft_size, spectral_envelope,
      aperiodic_ratio, current_vuv, forward_real_fft,
      inverse_real_fft, minimum_phase, aperiodic_response);

  double sqrt_noise_size = sqrt(static_cast<double>(noise_size));
  for (int i = 0; i < fft_size; ++i)
    response[i] =
      (periodic_response[i] * sqrt_noise_size + aperiodic_response[i]) /
      fft_size;

  delete[] spectral_envelope;
  delete[] aperiodic_ratio;
  delete[] periodic_response;
  delete[] aperiodic_response;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movsd %xmm0, -0x8(%rbp)
movl %edi, -0xc(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movsd %xmm1, -0x38(%rbp)
movsd %xmm2, -0x40(%rbp)
movl %r9d, -0x44(%rbp)
movslq -0x1c(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x1030
movq %rax, -0x50(%rbp)
movslq -0x1c(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x1030
movq %rax, -0x58(%rbp)
movslq -0x1c(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x1030
movq %rax, -0x60(%rbp)
movslq -0x1c(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x1030
movq %rax, -0x68(%rbp)
movsd -0x40(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movl -0x2c(%rbp), %edi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movq -0x60(%rbp), %rcx
callq 0x5d90
movsd -0x40(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movl -0x2c(%rbp), %edi
movq -0x28(%rbp), %rsi
movl -0x1c(%rbp), %edx
movq -0x68(%rbp), %rcx
callq 0x5f00
movl -0x1c(%rbp), %edi
movq -0x60(%rbp), %rsi
movq -0x68(%rbp), %rdx
movsd -0x8(%rbp), %xmm0
movq 0x18(%rbp), %rcx
movq 0x20(%rbp), %r8
movq -0x58(%rbp), %r9
callq 0x6090
movl -0xc(%rbp), %edi
movl -0x1c(%rbp), %esi
movq -0x60(%rbp), %rdx
movq -0x68(%rbp), %rcx
movsd -0x8(%rbp), %xmm0
movq 0x10(%rbp), %r8
movq 0x18(%rbp), %r9
movq 0x20(%rbp), %r10
movq -0x50(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x6290
cvtsi2sdl -0xc(%rbp), %xmm0
callq 0x1090
movsd %xmm0, -0x70(%rbp)
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x58b6
movq -0x58(%rbp), %rax
movslq -0x74(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd -0x70(%rbp), %xmm2
movq -0x50(%rbp), %rax
movslq -0x74(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
divsd %xmm1, %xmm0
movq 0x28(%rbp), %rax
movslq -0x74(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x5866
movq -0x60(%rbp), %rax
movq %rax, -0x80(%rbp)
cmpq $0x0, %rax
je 0x58cd
movq -0x80(%rbp), %rdi
callq 0x1110
movq -0x68(%rbp), %rax
movq %rax, -0x88(%rbp)
cmpq $0x0, %rax
je 0x58ea
movq -0x88(%rbp), %rdi
callq 0x1110
movq -0x58(%rbp), %rax
movq %rax, -0x90(%rbp)
cmpq $0x0, %rax
je 0x5907
movq -0x90(%rbp), %rdi
callq 0x1110
movq -0x50(%rbp), %rax
movq %rax, -0x98(%rbp)
cmpq $0x0, %rax
je 0x5924
movq -0x98(%rbp), %rdi
callq 0x1110
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax)