// File: /workspace/github_cpp_makefile_star2_O3/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, 0xe8(%rsp)
movq %rcx, 0xe0(%rsp)
movl %esi, %r13d
movq %rdi, %r12
movl %edx, 0x8c(%rsp)
cvtsi2sd %edx, %xmm1
movsd 0x99c6(%rip), %xmm0     # 0xf138
movsd %xmm1, 0x68(%rsp)
mulsd %xmm1, %xmm0
divsd 0x9c8c(%rip), %xmm0     # 0xf410
addsd 0x9884(%rip), %xmm0     # 0xf010
callq 0x10a0
divsd 0x986f(%rip), %xmm0     # 0xf008
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
addsd 0x9867(%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
movq $-0x1, %r15
cmovsq %rax, %rdi
callq 0x1030
movq %rax, %rbp
xorpd %xmm0, %xmm0
leaq 0x100(%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 0x19c0
leaq 0x160(%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 0x1a83
testl %ebx, %ebx
jle 0x6031
decl %r13d
movq 0x58(%rsp), %rdx
leal -0x2(%rdx), %eax
movl %eax, 0x84(%rsp)
movl %edx, %eax
shrl $0x1f, %eax
addl %edx, %eax
sarl %eax
leal 0x1(%rax), %esi
movl %edx, %ecx
leaq (,%rcx,8), %rdi
testl %edx, %edx
movsd 0x9b9d(%rip), %xmm0     # 0xf418
mulsd 0x68(%rsp), %xmm0
movsd %xmm0, 0xc8(%rsp)
cmovsq %r15, %rdi
movq %rdi, 0xd0(%rsp)
cmpl $0x3, %eax
movl $0x2, %edi
cmovgel %eax, %edi
movq %rdi, 0xb0(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
movsd %xmm0, 0xa8(%rsp)
movl %ebx, %eax
movq %rax, 0xc0(%rsp)
leaq -0x8(,%rcx,8), %rax
movq %rax, 0xa0(%rsp)
xorl %edx, %edx
movl %r13d, 0x88(%rsp)
movq %r12, 0xb8(%rsp)
movq %rbp, 0xd8(%rsp)
movq %rsi, 0x70(%rsp)
movq 0xe8(%rsp), %rax
movsd (%rax,%rdx,8), %xmm0
movapd %xmm0, %xmm2
cmpnlesd 0x9b04(%rip), %xmm2     # 0xf410
andpd %xmm2, %xmm0
movsd 0x9838(%rip), %xmm1     # 0xf150
andnpd %xmm1, %xmm2
orpd %xmm0, %xmm2
movq 0xe0(%rsp), %rax
movq %rdx, 0xf8(%rsp)
movsd (%rax,%rdx,8), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0xc8(%rsp), %xmm0
movapd %xmm2, 0x90(%rsp)
divsd %xmm2, %xmm0
movsd %xmm0, 0xf0(%rsp)
callq 0x4b8c
movl %eax, %r12d
leal (%r12,%r12), %r15d
leal 0x1(,%r12,2), %eax
movslq %eax, %rbx
leaq (,%rbx,4), %r14
shlq $0x3, %rbx
testl %r12d, %r12d
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, 0x64(%rsp)
movl %r15d, %eax
movq %rax, 0x78(%rsp)
movq %r12, 0x50(%rsp)
testl %r12d, %r12d
movsd 0x68(%rsp), %xmm4
js 0x5adb
movq 0x50(%rsp), %rsi
movl %esi, %eax
negl %eax
movl %esi, %edx
movq 0x78(%rsp), %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
addq $0x2, %rcx
shlq $0x2, %rdx
movslq %esi, %rsi
shlq $0x2, %rsi
subq %rsi, %rdx
addq %rbp, %rdx
addq $0x4, %rdx
xorl %esi, %esi
movdqa 0x9652(%rip), %xmm5     # 0xf060
movdqa 0x965a(%rip), %xmm6     # 0xf070
pcmpeqd %xmm7, %xmm7
movq %rsi, %xmm1
pshufd $0x44, %xmm1, %xmm1     # xmm1 = xmm1[0,1,0,1]
por %xmm5, %xmm1
movdqa %xmm0, %xmm2
pxor %xmm6, %xmm2
pxor %xmm6, %xmm1
movdqa %xmm1, %xmm3
pcmpgtd %xmm2, %xmm3
pcmpeqd %xmm2, %xmm1
pshufd $0xf5, %xmm1, %xmm2     # xmm2 = xmm1[1,1,3,3]
pand %xmm3, %xmm2
pshufd $0xf5, %xmm3, %xmm1     # xmm1 = xmm3[1,1,3,3]
por %xmm2, %xmm1
movd %xmm1, %edi
notl %edi
testb $0x1, %dil
je 0x5a66
leaq (%rax,%rsi), %rdi
movl %edi, -0x4(%rdx,%rsi,4)
pxor %xmm7, %xmm1
pextrw $0x4, %xmm1, %edi
testb $0x1, %dil
je 0x5a7d
leal (%rax,%rsi), %edi
incl %edi
movl %edi, (%rdx,%rsi,4)
addq $0x2, %rsi
cmpq %rsi, %rcx
jne 0x5a1a
movl 0x64(%rsp), %eax
testl %eax, %eax
movl $0x0, %r15d
cmovgl %eax, %r15d
incq %r15
xorl %r12d, %r12d
xorps %xmm1, %xmm1
cvtsi2sdl (%rbp,%r12,4), %xmm1
movsd 0x48(%rsp), %xmm0
mulsd %xmm4, %xmm0
addsd %xmm1, %xmm0
callq 0x4b8c
testl %eax, %eax
jg 0x5abf
xorl %eax, %eax
movl %r13d, %ecx
cmpl %eax, %r13d
jl 0x5ac9
movl %eax, %ecx
movl %ecx, (%r14,%r12,4)
incq %r12
cmpq %r12, %r15
movsd 0x68(%rsp), %xmm4
jne 0x5a9c
movsd 0x48(%rsp), %xmm0
mulsd %xmm4, %xmm0
movsd %xmm0, 0x48(%rsp)
callq 0x4b8c
cmpl $0x0, 0x50(%rsp)
js 0x5bcb
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movl 0x64(%rsp), %eax
testl %eax, %eax
movl $0x0, %r15d
cmovgl %eax, %r15d
movsd 0x48(%rsp), %xmm1
subsd %xmm0, %xmm1
orl $0x1, %r15d
xorpd %xmm2, %xmm2
xorl %r12d, %r12d
movsd %xmm1, 0x48(%rsp)
movsd %xmm2, 0x50(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdl (%rbp,%r12,4), %xmm0
divsd 0x98d3(%rip), %xmm0     # 0xf418
addsd %xmm1, %xmm0
divsd 0x68(%rsp), %xmm0
mulsd 0x95c9(%rip), %xmm0     # 0xf120
mulsd 0x90(%rsp), %xmm0
callq 0x11b0
movsd 0x50(%rsp), %xmm2
movsd 0x48(%rsp), %xmm1
movsd 0x9597(%rip), %xmm3     # 0xf110
mulsd %xmm3, %xmm0
addsd %xmm3, %xmm0
movsd %xmm0, (%rbx,%r12,8)
mulsd %xmm0, %xmm0
addsd %xmm0, %xmm2
incq %r12
cmpq %r12, %r15
jne 0x5b2d
ucomisd 0x95a9(%rip), %xmm2     # 0xf148
jb 0x5baa
xorps %xmm0, %xmm0
sqrtsd %xmm2, %xmm0
jmp 0x5bb3
movapd %xmm2, %xmm0
callq 0x1090
xorl %eax, %eax
movsd (%rbx,%rax,8), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, (%rbx,%rax,8)
incq %rax
cmpq %rax, %r15
jne 0x5bb5
cmpl $0x0, 0x64(%rsp)
movq 0x78(%rsp), %rax
js 0x5c8b
movq %rbp, 0x50(%rsp)
movq 0x108(%rsp), %r15
leaq 0x1(%rax), %r12
xorl %r13d, %r13d
movq 0xb8(%rsp), %rbp
movslq (%r14,%r13,4), %rax
movsd (%rbp,%rax,8), %xmm0
mulsd (%rbx,%r13,8), %xmm0
movsd %xmm0, 0x48(%rsp)
callq 0x4d40
mulsd 0x9806(%rip), %xmm0     # 0xf420
addsd 0x48(%rsp), %xmm0
movsd %xmm0, (%r15,%r13,8)
incq %r13
cmpq %r13, %r12
jne 0x5bf7
movq 0x78(%rsp), %rdx
leaq 0x1(%rdx), %rax
xorpd %xmm1, %xmm1
xorl %ecx, %ecx
xorpd %xmm0, %xmm0
addsd (%r15,%rcx,8), %xmm0
addsd (%rbx,%rcx,8), %xmm1
incq %rcx
cmpq %rcx, %rax
jne 0x5c41
divsd %xmm1, %xmm0
incq %rdx
xorl %eax, %eax
movl 0x88(%rsp), %r13d
movq 0x50(%rsp), %rbp
movsd (%r15,%rax,8), %xmm1
movsd (%rbx,%rax,8), %xmm2
mulsd %xmm0, %xmm2
subsd %xmm2, %xmm1
movsd %xmm1, (%r15,%rax,8)
incq %rax
cmpq %rax, %rdx
jne 0x5c6a
movq %rbp, %rdi
callq 0x1110
movq %r14, %rdi
callq 0x1110
movq %rbx, %rdi
callq 0x1110
movsd 0xf0(%rsp), %xmm0
callq 0x4b8c
leal 0x1(,%rax,2), %ecx
cmpl 0x58(%rsp), %ecx
jge 0x5cea
addl %eax, %eax
movq 0x108(%rsp), %rcx
cltq
leaq (%rcx,%rax,8), %rdi
addq $0x8, %rdi
movl 0x84(%rsp), %ecx
subl %eax, %ecx
leaq 0x8(,%rcx,8), %rdx
xorl %esi, %esi
callq 0x1080
movl $0x9, %ecx
movq %rsp, %rdi
leaq 0x118(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x8792
movq 0x108(%rsp), %rcx
cmpl $-0x1, 0x58(%rsp)
movq 0xd8(%rsp), %rbp
movq 0x70(%rsp), %rsi
jl 0x5d52
movq 0x110(%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 0x5d2c
movq %rcx, %rdi
movaps 0x90(%rsp), %xmm0
movl 0x8c(%rsp), %ebx
movl %ebx, %esi
movq 0x58(%rsp), %r14
movl %r14d, %edx
callq 0x12f9
movq 0x108(%rsp), %rcx
movapd 0x90(%rsp), %xmm0
addsd %xmm0, %xmm0
divsd 0x93a8(%rip), %xmm0     # 0xf138
movq %rcx, %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x14d5
movq 0xd0(%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, 0x100(%rsp)
movsd 0x68(%rsp), %xmm1
jl 0x5e92
movapd 0x90(%rsp), %xmm0
mulsd 0x9330(%rip), %xmm0     # 0xf120
movsd %xmm0, 0x78(%rsp)
movl $0x1, %r15d
xorps %xmm2, %xmm2
cvtsi2sd %r15d, %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, 0x48(%rsp)
movsd 0x78(%rsp), %xmm0
mulsd %xmm2, %xmm0
movsd %xmm0, 0x50(%rsp)
callq 0x1060
divsd 0x50(%rsp), %xmm0
movsd %xmm0, (%rbx,%r15,8)
movsd 0x48(%rsp), %xmm0
mulsd 0x91eb(%rip), %xmm0     # 0xf028
mulsd 0x90(%rsp), %xmm0
callq 0x11b0
movsd 0x95d5(%rip), %xmm2     # 0xf428
movsd 0x68(%rsp), %xmm1
mulsd %xmm2, %xmm0
movsd 0x95cb(%rip), %xmm2     # 0xf430
addsd %xmm2, %xmm0
movsd %xmm0, (%r14,%r15,8)
leaq 0x1(%r15), %rax
movl 0x100(%rsp), %ecx
movl %ecx, %edx
shrl $0x1f, %edx
addl %ecx, %edx
sarl %edx
movslq %edx, %rcx
cmpq %rcx, %r15
movq %rax, %r15
jl 0x5dfc
cmpl $-0x1, 0x58(%rsp)
jge 0x5ed3
movl $0x9, %ecx
movq %rsp, %rdi
leaq 0x118(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x8792
movl $0x9, %ecx
movq %rsp, %rdi
leaq 0x178(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x8792
movq 0x70(%rsp), %r12
jmp 0x5fdd
movq 0x108(%rsp), %rax
xorl %r15d, %r15d
movq 0x70(%rsp), %r12
movsd (%rax,%r15,8), %xmm0
callq 0x10a0
movq 0x108(%rsp), %rax
movsd %xmm0, (%rax,%r15,8)
incq %r15
cmpq %r15, %r12
jne 0x5ee3
cmpl $0x4, 0x58(%rsp)
movq 0xb0(%rsp), %rsi
jl 0x5f38
movq 0xa0(%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 0x5f23
movl $0x9, %ecx
movq %rsp, %rdi
leaq 0x118(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x8792
movq 0x110(%rsp), %rax
movq 0x170(%rsp), %rcx
xorl %edx, %edx
movq 0x70(%rsp), %rsi
movsd 0xa8(%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 0x5f70
movl $0x9, %ecx
movq %rsp, %rdi
leaq 0x178(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x8792
xorl %r15d, %r15d
movq 0x70(%rsp), %r12
movq 0x168(%rsp), %rax
movsd (%rax,%r15,8), %xmm0
callq 0x11a0
movsd %xmm0, (%rbp,%r15,8)
incq %r15
cmpq %r15, %r12
jne 0x5fbb
movq %rbx, %rdi
callq 0x1110
movq %r14, %rdi
callq 0x1110
cmpl $-0x1, 0x58(%rsp)
movq 0xf8(%rsp), %rdx
jl 0x6020
movq %r12, %rsi
movq 0x200(%rsp), %rax
movq (%rax,%rdx,8), %rax
xorl %ecx, %ecx
movsd (%rbp,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
incq %rcx
cmpq %rcx, %rsi
jne 0x600d
incq %rdx
cmpq 0xc0(%rsp), %rdx
jne 0x58f2
leaq 0x100(%rsp), %rdi
callq 0x1a44
leaq 0x160(%rsp), %rdi
callq 0x1b07
movq %rbp, %rdi
callq 0x1110
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)