// File: /workspace/github_cpp_makefile_star2_O2/Sleepwalking[P]world-octave/cheaptrick.cpp
// Function: CheapTrick(double*, int, int, double*, double*, int, double**)
void CheapTrick(double *x, int x_length, int fs, double *time_axis, double *f0,
    int f0_length, double **spectrogram) {
  int fft_size = GetFFTSizeForCheapTrick(fs);
  double *spectral_envelope = new double[fft_size];

  ForwardRealFFT forward_real_fft = {0};
  InitializeForwardRealFFT(fft_size, &forward_real_fft);
  InverseRealFFT inverse_real_fft = {0};
  InitializeInverseRealFFT(fft_size, &inverse_real_fft);

  double current_f0;
  for (int i = 0; i < f0_length; ++i) {
    current_f0 = f0[i] <= world::kFloorF0 ? world::kDefaultF0 : f0[i];
    CheapTrickGeneralBody(x, x_length, fs, current_f0, fft_size,
        time_axis[i], &forward_real_fft, &inverse_real_fft, spectral_envelope);
    for (int j = 0; j <= fft_size / 2; ++j)
      spectrogram[i][j] = spectral_envelope[j];
  }

  DestroyForwardRealFFT(&forward_real_fft);
  DestroyInverseRealFFT(&inverse_real_fft);
  delete[] spectral_envelope;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
movl %r9d, %ebx
movq %r8, 0xe0(%rsp)
movq %rcx, 0xd8(%rsp)
movl %edx, %ebp
movl %esi, %r12d
movq %rdi, 0xf8(%rsp)
movl %edx, %edi
callq 0x4bec
movl %eax, 0x74(%rsp)
movslq %eax, %r15
leaq (,%r15,8), %rdi
movl %r15d, %eax
shlq $0x3, %rax
testl %r15d, %r15d
pushq $-0x1
popq %rcx
cmovsq %rcx, %rdi
cmovsq %rcx, %rax
movq %rax, 0xc8(%rsp)
callq 0x1030
movq %rax, 0x98(%rsp)
xorps %xmm0, %xmm0
leaq 0x100(%rsp), %rsi
movaps %xmm0, (%rsi)
movaps %xmm0, 0x10(%rsi)
movaps %xmm0, 0x20(%rsi)
movaps %xmm0, 0x30(%rsi)
movaps %xmm0, 0x40(%rsi)
movaps %xmm0, 0x50(%rsi)
movl %r15d, %edi
callq 0x17c6
leaq 0x160(%rsp), %rsi
xorps %xmm0, %xmm0
movaps %xmm0, (%rsi)
movaps %xmm0, 0x10(%rsi)
movaps %xmm0, 0x20(%rsi)
movaps %xmm0, 0x30(%rsi)
movaps %xmm0, 0x40(%rsi)
movaps %xmm0, 0x50(%rsi)
movl %ebp, 0x7c(%rsp)
cvtsi2sd %ebp, %xmm0
movsd 0x86b2(%rip), %xmm1     # 0xd3b0
movsd %xmm0, 0x60(%rsp)
mulsd %xmm0, %xmm1
movsd %xmm1, 0xc0(%rsp)
movl %r15d, %edi
callq 0x187f
decl %r12d
pushq $0x2
popq %rcx
movl %r15d, %eax
cltd
idivl %ecx
testl %eax, %eax
pushq $-0x1
popq %rcx
cmovnsl %eax, %ecx
incl %ecx
movslq %eax, %rsi
cvtsi2sd %r15d, %xmm1
xorl %eax, %eax
testl %ebx, %ebx
cmovlel %eax, %ebx
movq %rbx, 0xe8(%rsp)
movq %rcx, 0x68(%rsp)
leaq (,%rcx,8), %rax
movq %rax, 0xa0(%rsp)
leaq -0x8(,%r15,8), %rax
movq %rax, 0xa8(%rsp)
xorl %edi, %edi
movl %r12d, 0x78(%rsp)
movq %r15, 0xd0(%rsp)
movq %rsi, 0xb8(%rsp)
movsd %xmm1, 0xb0(%rsp)
cmpq 0xe8(%rsp), %rdi
je 0x5319
movq 0xe0(%rsp), %rax
movsd (%rax,%rdi,8), %xmm0
movapd %xmm0, %xmm2
cmpnlesd 0x85f5(%rip), %xmm2     # 0xd3a8
andpd %xmm2, %xmm0
movsd 0x8341(%rip), %xmm1     # 0xd100
andnpd %xmm1, %xmm2
orpd %xmm0, %xmm2
movq 0xd8(%rsp), %rax
movq %rdi, 0xf0(%rsp)
movsd (%rax,%rdi,8), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0xc0(%rsp), %xmm0
movapd %xmm2, 0x80(%rsp)
divsd %xmm2, %xmm0
movsd %xmm0, 0x58(%rsp)
callq 0x419e
movl %eax, %r15d
leal 0x1(,%r15,2), %r14d
movslq %r14d, %r13
leaq (,%r13,4), %rbx
shlq $0x3, %r13
testl %eax, %eax
pushq $-0x1
popq %rax
cmovsq %rax, %rbx
cmovsq %rax, %r13
movq %rbx, %rdi
callq 0x1030
movq %rax, %rbp
movq %rbx, %rdi
callq 0x1030
movq %rax, %rbx
movq %r13, %rdi
callq 0x1030
movq %rax, %r13
movslq %r15d, %rax
negl %r15d
movslq %r15d, %rcx
leaq (,%rax,4), %rdx
addq %rbp, %rdx
cmpq %rax, %rcx
jg 0x4e6c
movl %ecx, (%rdx,%rcx,4)
incq %rcx
jmp 0x4e5f
testl %r14d, %r14d
movl $0x0, %eax
cmovlel %eax, %r14d
xorl %r15d, %r15d
movsd 0x48(%rsp), %xmm0
mulsd 0x60(%rsp), %xmm0
cmpq %r15, %r14
je 0x4eb5
cvtsi2sdl (%rbp,%r15,4), %xmm1
addsd %xmm1, %xmm0
callq 0x419e
testl %eax, %eax
jg 0x4ea2
xorl %eax, %eax
movl %r12d, %ecx
cmpl %eax, %r12d
jl 0x4eac
movl %eax, %ecx
movl %ecx, (%rbx,%r15,4)
incq %r15
jmp 0x4e7b
movsd %xmm0, 0x50(%rsp)
callq 0x419e
cvtsi2sd %eax, %xmm0
movsd 0x50(%rsp), %xmm1
subsd %xmm0, %xmm1
movsd %xmm1, 0x50(%rsp)
xorpd %xmm0, %xmm0
xorl %r15d, %r15d
cmpq %r15, %r14
je 0x4f4d
movsd %xmm0, 0x48(%rsp)
cvtsi2sdl (%rbp,%r15,4), %xmm0
divsd 0x84bb(%rip), %xmm0     # 0xd3b0
addsd 0x50(%rsp), %xmm0
divsd 0x60(%rsp), %xmm0
mulsd 0x81c7(%rip), %xmm0     # 0xd0d0
mulsd 0x80(%rsp), %xmm0
callq 0x11b0
movsd 0x81a1(%rip), %xmm1     # 0xd0c0
mulsd %xmm1, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%r13,%r15,8)
mulsd %xmm0, %xmm0
movsd 0x48(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x48(%rsp)
movsd 0x48(%rsp), %xmm0
incq %r15
jmp 0x4edb
ucomisd 0x81a3(%rip), %xmm0     # 0xd0f8
jb 0x4f5d
sqrtsd %xmm0, %xmm0
jmp 0x4f62
callq 0x1090
xorl %eax, %eax
cmpq %rax, %r14
je 0x4f80
movsd (%r13,%rax,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%r13,%rax,8)
incq %rax
jmp 0x4f64
movq 0x108(%rsp), %r15
xorl %r12d, %r12d
cmpq %r12, %r14
je 0x4fcc
movslq (%rbx,%r12,4), %rax
movq 0xf8(%rsp), %rcx
movsd (%rcx,%rax,8), %xmm0
mulsd (%r13,%r12,8), %xmm0
movsd %xmm0, 0x48(%rsp)
callq 0x431e
mulsd 0x83fd(%rip), %xmm0     # 0xd3b8
addsd 0x48(%rsp), %xmm0
movsd %xmm0, (%r15,%r12,8)
incq %r12
jmp 0x4f8b
xorpd %xmm0, %xmm0
xorl %eax, %eax
xorpd %xmm1, %xmm1
movl 0x78(%rsp), %r12d
cmpq %rax, %r14
je 0x4ff2
addsd (%r15,%rax,8), %xmm0
addsd (%r13,%rax,8), %xmm1
incq %rax
jmp 0x4fdb
divsd %xmm1, %xmm0
xorl %eax, %eax
cmpq %rax, %r14
je 0x501d
movsd (%r15,%rax,8), %xmm1
movsd (%r13,%rax,8), %xmm2
mulsd %xmm0, %xmm2
subsd %xmm2, %xmm1
movsd %xmm1, (%r15,%rax,8)
incq %rax
jmp 0x4ff8
movq %rbp, %rdi
callq 0x1110
movq %rbx, %rdi
callq 0x1110
movq %r13, %rdi
callq 0x1110
movsd 0x58(%rsp), %xmm0
callq 0x419e
leal 0x1(,%rax,2), %eax
cltq
movq 0x108(%rsp), %rcx
movq 0xd0(%rsp), %r15
cmpq %r15, %rax
jge 0x5068
andq $0x0, (%rcx,%rax,8)
incq %rax
jmp 0x5059
pushq $0x9
popq %rcx
movq %rsp, %rdi
leaq 0x118(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x752b
movq 0x108(%rsp), %rcx
movq 0x110(%rsp), %rax
xorl %edx, %edx
movq 0xa0(%rsp), %rsi
cmpq %rdx, %rsi
je 0x50bf
movsd (%rax,%rdx,2), %xmm0
movsd 0x8(%rax,%rdx,2), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rcx,%rdx)
addq $0x8, %rdx
jmp 0x5098
movq %rcx, %rdi
movaps 0x80(%rsp), %xmm0
movl 0x7c(%rsp), %ebx
movl %ebx, %esi
movl 0x74(%rsp), %ebp
movl %ebp, %edx
callq 0x12f9
movq 0x108(%rsp), %rcx
movapd 0x80(%rsp), %xmm0
addsd %xmm0, %xmm0
divsd 0x7ff0(%rip), %xmm0     # 0xd0e8
movq %rcx, %rdi
movl %ebx, %esi
movl %ebp, %edx
callq 0x1412
movq 0xc8(%rsp), %r14
movq %r14, %rdi
callq 0x1030
movq %rax, %rbx
movq %r14, %rdi
callq 0x1030
movq %rax, %r13
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, (%rbx)
movq %rax, (%r13)
movapd 0x80(%rsp), %xmm0
mulsd 0x7f8c(%rip), %xmm0     # 0xd0d0
movsd %xmm0, 0x58(%rsp)
pushq $0x1
popq %r14
movq 0x98(%rsp), %rbp
movl 0x100(%rsp), %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
cltq
cmpq %rax, %r14
jg 0x51d4
cvtsi2sd %r14d, %xmm1
divsd 0x60(%rsp), %xmm1
movsd %xmm1, 0x48(%rsp)
movsd 0x58(%rsp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x50(%rsp)
callq 0x1060
divsd 0x50(%rsp), %xmm0
movsd %xmm0, (%rbx,%r14,8)
movsd 0x48(%rsp), %xmm0
mulsd 0x7e7e(%rip), %xmm0     # 0xd028
mulsd 0x80(%rsp), %xmm0
callq 0x11b0
mulsd 0x8200(%rip), %xmm0     # 0xd3c0
addsd 0x8200(%rip), %xmm0     # 0xd3c8
movsd %xmm0, (%r13,%r14,8)
incq %r14
jmp 0x5156
xorl %r14d, %r14d
movq 0x108(%rsp), %rax
cmpq %r14, 0x68(%rsp)
je 0x5204
movsd (%rax,%r14,8), %xmm0
callq 0x10a0
movq 0x108(%rsp), %rax
movsd %xmm0, (%rax,%r14,8)
incq %r14
jmp 0x51d7
movq 0xa8(%rsp), %rcx
addq %rax, %rcx
pushq $0x1
popq %rdx
movq 0xb8(%rsp), %rsi
cmpq %rsi, %rdx
jge 0x5231
movsd (%rax,%rdx,8), %xmm0
movsd %xmm0, (%rcx)
incq %rdx
addq $-0x8, %rcx
jmp 0x521a
pushq $0x9
popq %rcx
movq %rsp, %rdi
leaq 0x118(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x752b
movq 0x110(%rsp), %rax
movq 0x170(%rsp), %rcx
xorl %edx, %edx
movsd 0xb0(%rsp), %xmm1
movq 0xa0(%rsp), %rsi
cmpq %rdx, %rsi
je 0x5295
movsd (%rax,%rdx,2), %xmm0
mulsd (%rbx,%rdx), %xmm0
mulsd (%r13,%rdx), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rcx,%rdx,2)
andq $0x0, 0x8(%rcx,%rdx,2)
addq $0x8, %rdx
jmp 0x526a
pushq $0x9
popq %rcx
movq %rsp, %rdi
leaq 0x178(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x752b
xorl %r14d, %r14d
cmpq %r14, 0x68(%rsp)
je 0x52d4
movq 0x168(%rsp), %rax
movsd (%rax,%r14,8), %xmm0
callq 0x11a0
movsd %xmm0, (%rbp,%r14,8)
incq %r14
jmp 0x52ae
movq %rbx, %rdi
callq 0x1110
movq %r13, %rdi
callq 0x1110
xorl %eax, %eax
movq 0x200(%rsp), %rdx
movq 0xf0(%rsp), %rdi
cmpq %rax, 0x68(%rsp)
je 0x5311
movsd (%rbp,%rax,8), %xmm0
movq (%rdx,%rdi,8), %rcx
movsd %xmm0, (%rcx,%rax,8)
incq %rax
jmp 0x52f6
incq %rdi
jmp 0x4d8b
leaq 0x100(%rsp), %rdi
callq 0x1842
leaq 0x160(%rsp), %rdi
callq 0x18fb
movq 0x98(%rsp), %rdi
callq 0x1110
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop