// File: Sleepwalking[P]world-octave/dio.cpp
// Function: (anonymous namespace)::GetF0CandidateAndStabilityMap(double*, int, double, int, double*, int, double (*) [2], int, double, double, double**, double**)
void GetF0CandidateAndStabilityMap(double *boundary_f0_list,
    int number_of_bands, double actual_fs, int y_length,
    double *time_axis, int f0_length, fft_complex *y_spectrum,
    int fft_size, double f0_floor, double f0_ceil,
    double **f0_candidate_map, double **f0_stability_map) {
  double * f0_candidates = new double[f0_length];
  double * f0_deviations = new double[f0_length];

  // Calculation of the acoustics events (zero-crossing)
  for (int i = 0; i < number_of_bands; ++i) {
    CalculateRawEvent(boundary_f0_list[i], actual_fs, y_spectrum,
        y_length, fft_size, f0_floor, f0_ceil, time_axis, f0_length,
        f0_deviations, f0_candidates);
    for (int j = 0; j < f0_length; ++j) {
      // A way to avoid zero division
      f0_stability_map[i][j] = f0_deviations[j] /
        (f0_candidates[j] + world::kMySafeGuardMinimum);
      f0_candidate_map[i][j] = f0_candidates[j];
    }
  }

  delete[] f0_candidates;
  delete[] f0_deviations;
}

// 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)
movsd %xmm0, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq %r9, -0x38(%rbp)
movsd %xmm1, -0x40(%rbp)
movsd %xmm2, -0x48(%rbp)
movslq -0x2c(%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 -0x2c(%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)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x3066
movq -0x8(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd -0x18(%rbp), %xmm1
movq -0x38(%rbp), %rdi
movl -0x1c(%rbp), %esi
movl 0x10(%rbp), %edx
movsd -0x40(%rbp), %xmm2
movsd -0x48(%rbp), %xmm3
movq -0x28(%rbp), %rcx
movl -0x2c(%rbp), %r8d
movq -0x58(%rbp), %r9
movq -0x50(%rbp), %rax
movq %rax, (%rsp)
callq 0x35b0
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x3056
movq -0x58(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x50(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd 0x1909d(%rip), %xmm1    # 0x1c0a8
addsd (%rax,%rcx,8), %xmm1
divsd %xmm1, %xmm0
movq 0x20(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x60(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0x50(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq 0x18(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x60(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x2fe6
jmp 0x3058
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x2f94
movq -0x50(%rbp), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, %rax
je 0x307d
movq -0x68(%rbp), %rdi
callq 0x1110
movq -0x58(%rbp), %rax
movq %rax, -0x70(%rbp)
cmpq $0x0, %rax
je 0x3094
movq -0x70(%rbp), %rdi
callq 0x1110
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)