// File: /workspace/github_cpp_makefile_star2_O1/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 $0x1d8, %rsp            # imm = 0x1D8
movl %r9d, %ebx
movq %r8, 0xf8(%rsp)
movq %rcx, 0xf0(%rsp)
movl %esi, %r12d
movq %rdi, %r15
movl %edx, 0x98(%rsp)
cvtsi2sd %edx, %xmm1
movsd 0x9efa(%rip), %xmm0     # 0xf0a8
movsd %xmm1, 0x68(%rsp)
mulsd %xmm1, %xmm0
divsd 0xa1b8(%rip), %xmm0     # 0xf378
addsd 0x9e48(%rip), %xmm0     # 0xf010
callq 0x10a0
divsd 0x9e33(%rip), %xmm0     # 0xf008
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
addsd 0x9e2b(%rip), %xmm0     # 0xf010
callq 0x10c0
cvttsd2si %xmm0, %eax
movq %rax, 0x58(%rsp)
movslq %eax, %r14
leaq (,%r14,8), %rdi
testl %r14d, %r14d
movq $-0x1, %rax
cmovsq %rax, %rdi
movq %rdi, 0xe8(%rsp)
callq 0x1030
movq %rax, %rbp
xorpd %xmm0, %xmm0
leaq 0x110(%rsp), %rsi
movapd %xmm0, 0x50(%rsi)
movapd %xmm0, 0x40(%rsi)
movapd %xmm0, 0x30(%rsi)
movapd %xmm0, 0x20(%rsi)
movapd %xmm0, 0x10(%rsi)
movapd %xmm0, (%rsi)
movl %r14d, %edi
callq 0x1817
leaq 0x170(%rsp), %rsi
xorpd %xmm0, %xmm0
movapd %xmm0, 0x50(%rsi)
movapd %xmm0, 0x40(%rsi)
movapd %xmm0, 0x30(%rsi)
movapd %xmm0, 0x20(%rsi)
movapd %xmm0, 0x10(%rsi)
movapd %xmm0, (%rsi)
movl %r14d, %edi
callq 0x18da
testl %ebx, %ebx
jle 0x5a21
movsd 0xa0f2(%rip), %xmm0     # 0xf380
mulsd 0x68(%rsp), %xmm0
movsd %xmm0, 0xd8(%rsp)
decl %r12d
movq 0x58(%rsp), %rcx
leal -0x2(%rcx), %eax
movl %eax, 0x90(%rsp)
movl %ecx, %eax
shrl $0x1f, %eax
addl %ecx, %eax
sarl %eax
leal 0x1(%rax), %r13d
cmpl $0x3, %eax
movl $0x2, %esi
cmovgel %eax, %esi
movq %rsi, 0xd0(%rsp)
movl %ecx, %eax
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movsd %xmm0, 0xb8(%rsp)
movl %ebx, %ecx
movq %rcx, 0xc8(%rsp)
leaq -0x8(,%rax,8), %rax
movq %rax, 0xb0(%rsp)
xorl %esi, %esi
movl %r12d, 0x94(%rsp)
movq %r15, 0xc0(%rsp)
movq %rbp, 0xe0(%rsp)
movq %r13, 0x70(%rsp)
movq 0xf8(%rsp), %rax
movsd (%rax,%rsi,8), %xmm0
movapd %xmm0, %xmm2
cmpnlesd 0xa044(%rip), %xmm2     # 0xf378
andpd %xmm2, %xmm0
movsd 0x9d90(%rip), %xmm1     # 0xf0d0
andnpd %xmm1, %xmm2
orpd %xmm0, %xmm2
movq 0xf0(%rsp), %rax
movq %rsi, 0x108(%rsp)
movsd (%rax,%rsi,8), %xmm0
movsd %xmm0, 0x50(%rsp)
movsd 0xd8(%rsp), %xmm0
movapd %xmm2, 0xa0(%rsp)
divsd %xmm2, %xmm0
movsd %xmm0, 0x100(%rsp)
callq 0x45c3
movl %eax, %r13d
leal (,%r13,2), %r15d
leal 0x1(,%r13,2), %eax
movl %eax, 0x9c(%rsp)
movslq %eax, %rbx
leaq (,%rbx,4), %r14
shlq $0x3, %rbx
testl %r13d, %r13d
movq $-0x1, %rax
cmovsq %rax, %r14
cmovsq %rax, %rbx
movq %r14, %rdi
callq 0x1030
movq %rax, %rbp
movq %r14, %rdi
callq 0x1030
movq %rax, %r14
movq %rbx, %rdi
callq 0x1030
movq %rax, %rbx
movl %r15d, 0x60(%rsp)
movl %r15d, %eax
movq %rax, 0x80(%rsp)
movq %r13, 0x88(%rsp)
testl %r13d, %r13d
movsd 0x68(%rsp), %xmm2
js 0x549b
movq 0x88(%rsp), %rdx
movl %edx, %eax
negl %eax
movl %edx, %esi
movq 0x80(%rsp), %rcx
incq %rcx
shlq $0x2, %rsi
movslq %edx, %rdx
shlq $0x2, %rdx
subq %rdx, %rsi
movq %rbp, %rdx
addq %rsi, %rdx
xorl %esi, %esi
leal (%rax,%rsi), %edi
movl %edi, (%rdx,%rsi,4)
incq %rsi
cmpl %esi, %ecx
jne 0x5439
movl 0x60(%rsp), %eax
testl %eax, %eax
movl $0x0, %r15d
cmovgl %eax, %r15d
incq %r15
xorl %r13d, %r13d
xorps %xmm1, %xmm1
cvtsi2sdl (%rbp,%r13,4), %xmm1
movsd 0x50(%rsp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x45c3
testl %eax, %eax
jg 0x547f
xorl %eax, %eax
movl %r12d, %ecx
cmpl %eax, %r12d
jl 0x5489
movl %eax, %ecx
movl %ecx, (%r14,%r13,4)
incq %r13
cmpq %r13, %r15
movsd 0x68(%rsp), %xmm2
jne 0x545c
movsd 0x50(%rsp), %xmm0
mulsd %xmm2, %xmm0
movsd %xmm0, 0x50(%rsp)
callq 0x45c3
cmpl $0x0, 0x88(%rsp)
js 0x555c
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movl 0x60(%rsp), %eax
testl %eax, %eax
movl $0x0, %r15d
cmovgl %eax, %r15d
movsd 0x50(%rsp), %xmm1
subsd %xmm0, %xmm1
orl $0x1, %r15d
xorpd %xmm2, %xmm2
xorl %r13d, %r13d
movsd %xmm1, 0x50(%rsp)
movsd %xmm2, 0x78(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl (%rbp,%r13,4), %xmm0
divsd 0x9e78(%rip), %xmm0     # 0xf380
addsd %xmm1, %xmm0
divsd 0x68(%rsp), %xmm0
mulsd 0x9b7e(%rip), %xmm0     # 0xf098
mulsd 0xa0(%rsp), %xmm0
callq 0x11b0
movsd 0x78(%rsp), %xmm2
movsd 0x50(%rsp), %xmm1
movsd 0x9b4c(%rip), %xmm3     # 0xf088
mulsd %xmm3, %xmm0
addsd %xmm3, %xmm0
movsd %xmm0, (%rbx,%r13,8)
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm2
incq %r13
cmpq %r13, %r15
jne 0x54f0
jmp 0x5560
xorpd %xmm2, %xmm2
ucomisd 0x9b50(%rip), %xmm2     # 0xf0b8
jb 0x5573
xorps %xmm0, %xmm0
sqrtsd %xmm2, %xmm0
jmp 0x557c
movapd %xmm2, %xmm0
callq 0x1090
cmpl $0x0, 0x88(%rsp)
js 0x55af
movl 0x60(%rsp), %ecx
testl %ecx, %ecx
movl $0x0, %eax
cmovgl %ecx, %eax
orl $0x1, %eax
xorl %ecx, %ecx
movsd (%rbx,%rcx,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rbx,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x5599
movq 0x118(%rsp), %r15
movsd 0x9dc9(%rip), %xmm0     # 0xf388
cmpl $0x0, 0x60(%rsp)
js 0x5656
movq %rbp, 0x78(%rsp)
movq 0x80(%rsp), %rax
leaq 0x1(%rax), %r13
xorl %r12d, %r12d
movq 0xc0(%rsp), %rbp
movslq (%r14,%r12,4), %rax
movsd (%rbp,%rax,8), %xmm0
mulsd (%rbx,%r12,8), %xmm0
movsd %xmm0, 0x50(%rsp)
callq 0x476c
mulsd 0x9d87(%rip), %xmm0     # 0xf390
addsd 0x50(%rsp), %xmm0
movsd %xmm0, (%r15,%r12,8)
incq %r12
cmpq %r12, %r13
jne 0x55e6
movq 0x80(%rsp), %rcx
incq %rcx
xorpd %xmm1, %xmm1
xorl %eax, %eax
xorpd %xmm0, %xmm0
addsd (%r15,%rax,8), %xmm0
addsd (%rbx,%rax,8), %xmm1
incq %rax
cmpq %rax, %rcx
jne 0x5632
divsd %xmm1, %xmm0
movl 0x94(%rsp), %r12d
movq 0x78(%rsp), %rbp
cmpl $0x0, 0x60(%rsp)
js 0x5687
movl 0x9c(%rsp), %eax
xorl %ecx, %ecx
movsd (%r15,%rcx,8), %xmm1
movsd (%rbx,%rcx,8), %xmm2
mulsd %xmm0, %xmm2
subsd %xmm2, %xmm1
movsd %xmm1, (%r15,%rcx,8)
incq %rcx
cmpq %rcx, %rax
jne 0x5666
movq %rbp, %rdi
callq 0x1110
movq %r14, %rdi
callq 0x1110
movq %rbx, %rdi
callq 0x1110
movsd 0x100(%rsp), %xmm0
callq 0x45c3
leal 0x1(,%rax,2), %ecx
cmpl 0x58(%rsp), %ecx
jge 0x56e6
addl %eax, %eax
movq 0x118(%rsp), %rcx
cltq
leaq (%rcx,%rax,8), %rdi
addq $0x8, %rdi
movl 0x90(%rsp), %ecx
subl %eax, %ecx
leaq 0x8(,%rcx,8), %rdx
xorl %esi, %esi
callq 0x1080
movl $0x9, %ecx
movq %rsp, %rdi
leaq 0x128(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x7f1a
movq 0x118(%rsp), %rcx
cmpl $-0x1, 0x58(%rsp)
movq 0xe0(%rsp), %rbp
movq 0x70(%rsp), %rsi
jl 0x574e
movq 0x120(%rsp), %rax
addq $0x8, %rax
xorl %edx, %edx
movsd -0x8(%rax), %xmm0
movsd (%rax), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rcx,%rdx,8)
incq %rdx
addq $0x10, %rax
cmpq %rdx, %rsi
jne 0x5728
movq %rcx, %rdi
movaps 0xa0(%rsp), %xmm0
movl 0x98(%rsp), %ebx
movl %ebx, %esi
movq 0x58(%rsp), %r14
movl %r14d, %edx
callq 0x12f9
movq 0x118(%rsp), %rcx
movapd 0xa0(%rsp), %xmm0
addsd %xmm0, %xmm0
divsd 0x991c(%rip), %xmm0     # 0xf0a8
movq %rcx, %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x1426
movq 0xe8(%rsp), %r14
movq %r14, %rdi
callq 0x1030
movq %rax, %rbx
movq %r14, %rdi
callq 0x1030
movq %rax, %r14
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, (%rbx)
movq %rax, (%r14)
cmpl $0x2, 0x110(%rsp)
movsd 0x68(%rsp), %xmm1
jl 0x588e
movapd 0xa0(%rsp), %xmm0
mulsd 0x98ac(%rip), %xmm0     # 0xf098
movsd %xmm0, 0x60(%rsp)
movl $0x1, %r15d
xorps %xmm2, %xmm2
cvtsi2sd %r15d, %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, 0x50(%rsp)
movsd 0x60(%rsp), %xmm0
mulsd %xmm2, %xmm0
movsd %xmm0, 0x78(%rsp)
callq 0x1060
divsd 0x78(%rsp), %xmm0
movsd %xmm0, (%rbx,%r15,8)
movsd 0x50(%rsp), %xmm0
mulsd 0x97ef(%rip), %xmm0     # 0xf028
mulsd 0xa0(%rsp), %xmm0
callq 0x11b0
movsd 0x9b49(%rip), %xmm2     # 0xf398
movsd 0x68(%rsp), %xmm1
mulsd %xmm2, %xmm0
movsd 0x9b3f(%rip), %xmm2     # 0xf3a0
addsd %xmm2, %xmm0
movsd %xmm0, (%r14,%r15,8)
leaq 0x1(%r15), %rax
movl 0x110(%rsp), %ecx
movl %ecx, %edx
shrl $0x1f, %edx
addl %ecx, %edx
sarl %edx
movslq %edx, %rcx
cmpq %rcx, %r15
movq %rax, %r15
jl 0x57f8
cmpl $-0x1, 0x58(%rsp)
movq 0x70(%rsp), %r13
jl 0x58c6
xorl %r15d, %r15d
movq 0x118(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
callq 0x10a0
movq 0x118(%rsp), %rax
movsd %xmm0, (%rax,%r15,8)
incq %r15
cmpq %r15, %r13
jne 0x589d
cmpl $0x4, 0x58(%rsp)
movq 0xd0(%rsp), %rsi
jl 0x5902
movq 0x118(%rsp), %rax
movq 0xb0(%rsp), %rcx
addq %rax, %rcx
movl $0x1, %edx
movsd (%rax,%rdx,8), %xmm0
movsd %xmm0, (%rcx)
incq %rdx
addq $-0x8, %rcx
cmpq %rdx, %rsi
jne 0x58ed
movl $0x9, %ecx
movq %rsp, %rdi
leaq 0x128(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x7f1a
cmpl $-0x1, 0x58(%rsp)
jge 0x5943
movl $0x9, %ecx
movq %rsp, %rdi
leaq 0x188(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x7f1a
movq 0x70(%rsp), %r13
jmp 0x59d0
movq 0x120(%rsp), %rax
movq 0x180(%rsp), %rcx
xorl %edx, %edx
movq 0x70(%rsp), %rsi
movsd 0xb8(%rsp), %xmm1
movsd (%rax,%rdx,2), %xmm0
mulsd (%rbx,%rdx), %xmm0
mulsd (%r14,%rdx), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rcx,%rdx,2)
movq $0x0, 0x8(%rcx,%rdx,2)
addq $0x8, %rdx
decq %rsi
jne 0x5963
movl $0x9, %ecx
movq %rsp, %rdi
leaq 0x188(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x7f1a
xorl %r15d, %r15d
movq 0x70(%rsp), %r13
movq 0x178(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
callq 0x11a0
movsd %xmm0, (%rbp,%r15,8)
incq %r15
cmpq %r15, %r13
jne 0x59ae
movq %rbx, %rdi
callq 0x1110
movq %r14, %rdi
callq 0x1110
cmpl $-0x1, 0x58(%rsp)
movq 0x108(%rsp), %rsi
jl 0x5a10
movq 0x210(%rsp), %rax
movq (%rax,%rsi,8), %rax
xorl %ecx, %ecx
movsd (%rbp,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
incq %rcx
cmpq %rcx, %r13
jne 0x59fd
incq %rsi
cmpq 0xc8(%rsp), %rsi
jne 0x531a
leaq 0x110(%rsp), %rdi
callq 0x189b
leaq 0x170(%rsp), %rdi
callq 0x195e
movq %rbp, %rdi
callq 0x1110
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)