// File: Sleepwalking[P]world-octave/common.cpp
// Function: DCCorrection(double*, double, int, int, double*)
void DCCorrection(double *input, double current_f0, int fs, int fft_size,
    double *output) {
  int upper_limit = 1 +
    static_cast<int>(1.2 * current_f0 * fft_size / fs);
  double *low_frequency_replica = new double[upper_limit];
  double *low_frequency_axis = new double[upper_limit];

  for (int i = 0; i < upper_limit; ++i)
    low_frequency_axis[i] = static_cast<double>(i) * fs / fft_size;

  int upper_limit_replica = 1 + static_cast<int>(current_f0 * fft_size / fs);
  interp1Q(current_f0 - low_frequency_axis[0],
      -static_cast<double>(fs) / fft_size, input, upper_limit + 1,
      low_frequency_axis, upper_limit_replica, low_frequency_replica);

  for (int i = 0; i < upper_limit_replica; ++i)
    output[i] = input[i] + low_frequency_replica[i];

  delete[] low_frequency_replica;
  delete[] low_frequency_axis;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movsd 0x1aced(%rip), %xmm0    # 0x1c020
mulsd -0x10(%rbp), %xmm0
cvtsi2sdl -0x18(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvtsi2sdl -0x14(%rbp), %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movslq -0x24(%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)
movslq -0x24(%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, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x13e4
cvtsi2sdl -0x3c(%rbp), %xmm0
cvtsi2sdl -0x14(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvtsi2sdl -0x18(%rbp), %xmm1
divsd %xmm1, %xmm0
movq -0x38(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x13ad
movsd -0x10(%rbp), %xmm0
cvtsi2sdl -0x18(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvtsi2sdl -0x14(%rbp), %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movsd -0x10(%rbp), %xmm0
movq -0x38(%rbp), %rax
subsd (%rax), %xmm0
cvtsi2sdl -0x14(%rbp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
cvtsi2sdl -0x18(%rbp), %xmm2
divsd %xmm2, %xmm1
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %esi
addl $0x1, %esi
movq -0x38(%rbp), %rdx
movl -0x40(%rbp), %ecx
movq -0x30(%rbp), %r8
callq 0x7390
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x40(%rbp), %eax
jge 0x1492
movq -0x8(%rbp), %rax
movslq -0x44(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x30(%rbp), %rax
movslq -0x44(%rbp), %rcx
addsd (%rax,%rcx,8), %xmm0
movq -0x20(%rbp), %rax
movslq -0x44(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x1458
movq -0x30(%rbp), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0x14a9
movq -0x50(%rbp), %rdi
callq 0x1110
movq -0x38(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
je 0x14c0
movq -0x58(%rbp), %rdi
callq 0x1110
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)