// File: Sleepwalking[P]world-octave/test.cpp
// Function: (anonymous namespace)::ParameterModification(int, char**, int, double*, int, double**)
void ParameterModification(int argc, char *argv[], int fs, double *f0,
    int f0_length, double **spectrogram) {
  int fft_size = GetFFTSizeForCheapTrick(fs);
  // F0 scaling
  if (argc >= 4) {
    double shift = atof(argv[3]);
    for (int i = 0; i < f0_length; ++i) f0[i] *= shift;
  }
  // Spectral stretching
  if (argc >= 5) {
    double ratio = atof(argv[4]);
    double *freq_axis1 = new double[fft_size];
    double *freq_axis2 = new double[fft_size];
    double *spectrum1 = new double[fft_size];
    double *spectrum2 = new double[fft_size];

    for (int i = 0; i <= fft_size / 2; ++i) {
      freq_axis1[i] = ratio * i / fft_size * fs;
      freq_axis2[i] = static_cast<double>(i) / fft_size * fs;
    }
    for (int i = 0; i < f0_length; ++i) {
      for (int j = 0; j <= fft_size / 2; ++j)
        spectrum1[j] = log(spectrogram[i][j]);
      interp1(freq_axis1, spectrum1, fft_size / 2 + 1, freq_axis2,
        fft_size / 2 + 1, spectrum2);
      for (int j = 0; j <= fft_size / 2; ++j)
        spectrogram[i][j] = exp(spectrum2[j]);
      if (ratio < 1.0) {
        for (int j = static_cast<int>(fft_size / 2.0 * ratio);
            j <= fft_size / 2; ++j)
          spectrogram[i][j] =
          spectrogram[i][static_cast<int>(fft_size / 2.0 * ratio) - 1];
      }
    }
    delete[] spectrum1;
    delete[] spectrum2;
    delete[] freq_axis1;
    delete[] freq_axis2;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movl -0x14(%rbp), %edi
callq 0x84a0
movl %eax, -0x34(%rbp)
cmpl $0x4, -0x4(%rbp)
jl 0x1b897
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x1100
movsd %xmm0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x1b895
movsd -0x40(%rbp), %xmm0
movq -0x20(%rbp), %rax
movslq -0x44(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x1b86b
jmp 0x1b897
cmpl $0x5, -0x4(%rbp)
jl 0x1bc1a
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x1100
movsd %xmm0, -0x50(%rbp)
movslq -0x34(%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)
movslq -0x34(%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, -0x60(%rbp)
movslq -0x34(%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, -0x68(%rbp)
movslq -0x34(%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, -0x70(%rbp)
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
movl %eax, -0x88(%rbp)
movl -0x34(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x88(%rbp), %eax
cmpl %ecx, %eax
jg 0x1b9da
movsd -0x50(%rbp), %xmm0
cvtsi2sdl -0x74(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvtsi2sdl -0x34(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsi2sdl -0x14(%rbp), %xmm1
mulsd %xmm1, %xmm0
movq -0x58(%rbp), %rax
movslq -0x74(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
cvtsi2sdl -0x74(%rbp), %xmm0
cvtsi2sdl -0x34(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsi2sdl -0x14(%rbp), %xmm1
mulsd %xmm1, %xmm0
movq -0x60(%rbp), %rax
movslq -0x74(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x1b95e
movl $0x0, -0x78(%rbp)
movl -0x78(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x1bba4
movl $0x0, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movl %eax, -0x8c(%rbp)
movl -0x34(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x8c(%rbp), %eax
cmpl %ecx, %eax
jg 0x1ba46
movq -0x30(%rbp), %rax
movslq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x7c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
callq 0x10a0
movq -0x68(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x1b9f4
movq -0x58(%rbp), %rdi
movq -0x68(%rbp), %rsi
movl -0x34(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
addl $0x1, %eax
movl %eax, -0x90(%rbp)
movq -0x60(%rbp), %rcx
movl -0x34(%rbp), %eax
movl $0x2, %r8d
cltd
idivl %r8d
movl -0x90(%rbp), %edx
movl %eax, %r8d
addl $0x1, %r8d
movq -0x70(%rbp), %r9
callq 0x68d0
movl $0x0, -0x80(%rbp)
movl -0x80(%rbp), %eax
movl %eax, -0x94(%rbp)
movl -0x34(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x94(%rbp), %eax
cmpl %ecx, %eax
jg 0x1bae2
movq -0x70(%rbp), %rax
movslq -0x80(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
callq 0x1190
movq -0x30(%rbp), %rax
movslq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x80(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x1ba90
movsd 0x526(%rip), %xmm0      # 0x1c010
ucomisd -0x50(%rbp), %xmm0
jbe 0x1bb94
cvtsi2sdl -0x34(%rbp), %xmm0
movsd 0x506(%rip), %xmm1      # 0x1c008
divsd %xmm1, %xmm0
mulsd -0x50(%rbp), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x84(%rbp)
movl -0x84(%rbp), %eax
movl %eax, -0x98(%rbp)
movl -0x34(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x98(%rbp), %eax
cmpl %ecx, %eax
jg 0x1bb92
movq -0x30(%rbp), %rax
movslq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cvtsi2sdl -0x34(%rbp), %xmm0
movsd 0x4b7(%rip), %xmm1      # 0x1c008
divsd %xmm1, %xmm0
mulsd -0x50(%rbp), %xmm0
cvttsd2si %xmm0, %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x30(%rbp), %rax
movslq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x84(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x1bb15
jmp 0x1bb94
jmp 0x1bb96
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x1b9e1
movq -0x68(%rbp), %rax
movq %rax, -0xa0(%rbp)
cmpq $0x0, %rax
je 0x1bbc1
movq -0xa0(%rbp), %rdi
callq 0x1110
movq -0x70(%rbp), %rax
movq %rax, -0xa8(%rbp)
cmpq $0x0, %rax
je 0x1bbde
movq -0xa8(%rbp), %rdi
callq 0x1110
movq -0x58(%rbp), %rax
movq %rax, -0xb0(%rbp)
cmpq $0x0, %rax
je 0x1bbfb
movq -0xb0(%rbp), %rdi
callq 0x1110
movq -0x60(%rbp), %rax
movq %rax, -0xb8(%rbp)
cmpq $0x0, %rax
je 0x1bc18
movq -0xb8(%rbp), %rdi
callq 0x1110
jmp 0x1bc1a
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)