// File: Sleepwalking[P]world-octave/test.cpp
// Function: (anonymous namespace)::F0Estimation(double*, int, int, int, double*, double*)
void F0Estimation(double *x, int x_length, int fs, int f0_length, double *f0,
    double *time_axis) {
  double *refined_f0 = new double[f0_length];

  DioOption option;
  InitializeDioOption(&option);  // Initialize the option
  // Modification of the option
  option.frame_period = FRAMEPERIOD;
  // Valuable option.speed represents the ratio for downsampling.
  // The signal is downsampled to fs / speed Hz.
  // If you want to obtain the accurate result, speed should be set to 1.
  option.speed = 1;
  // You should not set option.f0_floor to under world::kFloorF0.
  // If you want to analyze such low F0 speech, please change world::kFloorF0.
  // Processing speed may sacrify, provided that the FFT length changes.
  option.f0_floor = 71.0;
  // You can give a positive real number as the threshold.
  // Most strict value is 0, but almost all results are counted as unvoiced.
  // The value from 0.02 to 0.2 would be reasonable.
  option.allowed_range = 0.1;

  printf("\nAnalysis\n");
  DWORD elapsed_time = timeGetTime();
  Dio(x, x_length, fs, option, time_axis, f0);
  printf("DIO: %d [msec]\n", timeGetTime() - elapsed_time);

  // StoneMask is carried out to improve the estimation performance.
  elapsed_time = timeGetTime();
  StoneMask(x, x_length, fs, time_axis, f0, f0_length, refined_f0);
  printf("StoneMask: %d [msec]\n", timeGetTime() - elapsed_time);

  for (int i = 0; i < f0_length; ++i) f0[i] = refined_f0[i];

  delete[] refined_f0;
  return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movslq -0x14(%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, -0x30(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x29d0
movsd 0xace(%rip), %xmm0      # 0x1c088
movsd %xmm0, -0x48(%rbp)
movl $0x1, -0x40(%rbp)
movsd 0xac2(%rip), %xmm0      # 0x1c090
movsd %xmm0, -0x60(%rbp)
movsd 0xaa5(%rip), %xmm0      # 0x1c080
movsd %xmm0, -0x38(%rbp)
leaq 0xed3(%rip), %rdi       # 0x1c4ba
movb $0x0, %al
callq 0x1040
callq 0x1b030
movl %eax, -0x64(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0xa0(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movl $0x30, %edx
callq 0x10b0
movq -0xb0(%rbp), %rdi
movl -0xa4(%rbp), %esi
movl -0xa0(%rbp), %edx
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %r8
movups -0x98(%rbp), %xmm0
movups -0x88(%rbp), %xmm1
movups -0x78(%rbp), %xmm2
movq %rsp, %rax
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x2460
callq 0x1b030
movl %eax, %esi
subl -0x64(%rbp), %esi
leaq 0xe4c(%rip), %rdi       # 0x1c4c5
movb $0x0, %al
callq 0x1040
callq 0x1b030
movl %eax, -0x64(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %r8
movl -0x14(%rbp), %r9d
movq -0x30(%rbp), %rax
movq %rax, (%rsp)
callq 0x9290
callq 0x1b030
movl %eax, %esi
subl -0x64(%rbp), %esi
leaq 0xe19(%rip), %rdi       # 0x1c4d5
movb $0x0, %al
callq 0x1040
movl $0x0, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x1b709
movq -0x30(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x20(%rbp), %rax
movslq -0x9c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x9c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x9c(%rbp)
jmp 0x1b6cd
movq -0x30(%rbp), %rax
movq %rax, -0xb8(%rbp)
cmpq $0x0, %rax
je 0x1b726
movq -0xb8(%rbp), %rdi
callq 0x1110
addq $0xf0, %rsp
popq %rbp
retq
nop