// File: Sleepwalking[P]world-octave/d4c.cpp
// Function: (anonymous namespace)::D4CGeneralBody(double*, int, int, double, int, double, int, double*, int, ForwardRealFFT*, double*)
void D4CGeneralBody(double *x, int x_length, int fs, double current_f0,
    int fft_size, double temporal_position, int number_of_aperiodicities,
    double *window, int window_length, ForwardRealFFT *forward_real_fft,
    double *coarse_aperiodicity) {

  double *static_centroid = new double[fft_size / 2 + 1];
  double *smoothed_power_spectrum = new double[fft_size / 2 + 1];
  double *static_group_delay = new double[fft_size / 2 + 1];
  GetStaticCentroid(x, x_length, fs, current_f0, fft_size, temporal_position,
      forward_real_fft, static_centroid);
  GetSmoothedPowerSpectrum(x, x_length, fs, current_f0, fft_size,
      temporal_position, forward_real_fft, smoothed_power_spectrum);
  GetStaticGroupDelay(static_centroid, smoothed_power_spectrum,
    fs, current_f0, fft_size, static_group_delay);

  GetCoarseAperiodicity(static_group_delay, fs, current_f0, fft_size,
    number_of_aperiodicities, window, window_length, forward_real_fft,
    coarse_aperiodicity);

  // Revision of the result based on the F0
  for (int i = 0; i < number_of_aperiodicities; ++i)
    coarse_aperiodicity[i] = MyMin(0.0,
        coarse_aperiodicity[i] + (current_f0 - 100) / 50.0);
  delete[] static_centroid;
  delete[] smoothed_power_spectrum;
  delete[] static_group_delay;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movsd %xmm1, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq %r9, -0x38(%rbp)
movl -0x1c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
addl $0x1, %eax
cltq
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x1030
movq %rax, -0x40(%rbp)
movl -0x1c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
addl $0x1, %eax
cltq
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x1030
movq %rax, -0x48(%rbp)
movl -0x1c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
addl $0x1, %eax
cltq
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)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movsd -0x18(%rbp), %xmm0
movl -0x1c(%rbp), %ecx
movsd -0x28(%rbp), %xmm1
movq 0x18(%rbp), %r8
movq -0x40(%rbp), %r9
callq 0xace0
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movsd -0x18(%rbp), %xmm0
movl -0x1c(%rbp), %ecx
movsd -0x28(%rbp), %xmm1
movq 0x18(%rbp), %r8
movq -0x48(%rbp), %r9
callq 0xae80
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
movl -0x10(%rbp), %edx
movsd -0x18(%rbp), %xmm0
movl -0x1c(%rbp), %ecx
movq -0x50(%rbp), %r8
callq 0xb060
movq -0x50(%rbp), %rdi
movl -0x10(%rbp), %esi
movsd -0x18(%rbp), %xmm0
movl -0x1c(%rbp), %edx
movl -0x2c(%rbp), %ecx
movq -0x38(%rbp), %r8
movl 0x10(%rbp), %r9d
movq 0x18(%rbp), %r10
movq 0x20(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0xb1b0
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0xac85
movq 0x20(%rbp), %rax
movslq -0x54(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movsd -0x18(%rbp), %xmm0
movsd 0x117df(%rip), %xmm2    # 0x1c430
subsd %xmm2, %xmm0
movsd 0x11443(%rip), %xmm2    # 0x1c0a0
divsd %xmm2, %xmm0
addsd %xmm0, %xmm1
xorps %xmm0, %xmm0
callq 0xa4b0
movq 0x20(%rbp), %rax
movslq -0x54(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0xac2f
movq -0x40(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0xac9c
movq -0x60(%rbp), %rdi
callq 0x1110
movq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, %rax
je 0xacb3
movq -0x68(%rbp), %rdi
callq 0x1110
movq -0x50(%rbp), %rax
movq %rax, -0x70(%rbp)
cmpq $0x0, %rax
je 0xacca
movq -0x70(%rbp), %rdi
callq 0x1110
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)