// File: Pyboon[P]sage/isi_sage.cpp
// Function: IsiSage::InitDoppler(Eigen::Matrix<std::complex<double>, 1, -1, 1, 1, -1>, int)
void IsiSage::InitDoppler(const RowVectorXcd tau_data, const int iL){
    Util::log("init doppler...");
    // go through doppler frequecy bound to find index with max value
    double min_doppler = -config.max_doppler;
    double max_doppler = config.max_doppler;
    double step = config.doppler_step; // step of doppler is 0.1 hz
    int doppler_size = (int)(max_doppler-min_doppler)/step + 1;
    VectorXd doppler_data(doppler_size);
    doppler_data.setZero(doppler_size);
    complex<double> cycle_data = 0;
    complex<double> temp = 0;
    for(double i_step = 0; i_step < doppler_size; ++i_step){
        for(int i_tx = 0; i_tx < config.Tx; ++i_tx){
            for(int i_rx = 0; i_rx < config.Rx; ++i_rx){
                cycle_data = 0;
                for(int i_cyc = 0; i_cyc < config.cycle_num; ++i_cyc){
                    double t = i_cyc * config.cycle_interval + (i_tx * config.Tt + i_rx * config.Tr) * config.T; 
                    temp.real(cos(2*PI*(min_doppler+i_step*step)*t));
                    temp.imag(-sin(2*PI*(min_doppler+i_step*step)*t));
                    cycle_data += temp * tau_data(i_cyc * config.subchannel_num + i_tx * config.Rx + i_rx);
                }
                doppler_data(i_step) +=norm(cycle_data);
            }
        }
    }
    int max_index = 0;
    doppler_data.maxCoeff(&max_index);
    result.doppler(iL) = min_doppler + max_index * config.doppler_step;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rsi, -0xf0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x9dd0
movq -0xe0(%rbp), %rdx
leaq 0x5616d(%rip), %rsi     # 0x6fb73
leaq -0x38(%rbp), %rdi
callq 0xb320
jmp 0x19a11
leaq -0x38(%rbp), %rdi
callq 0x13b80
jmp 0x19a1c
leaq -0x38(%rbp), %rdi
callq 0x9470
leaq -0x39(%rbp), %rdi
callq 0x9840
movq -0xe8(%rbp), %rax
movsd 0xd8(%rax), %xmm0
movaps 0x55e4c(%rip), %xmm1    # 0x6f890
pxor %xmm1, %xmm0
movlpd %xmm0, -0x58(%rbp)
movsd 0xd8(%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd 0x120(%rax), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x60(%rbp), %xmm0
movsd -0x58(%rbp), %xmm1
subsd %xmm1, %xmm0
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
movsd -0x68(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0x5459a(%rip), %xmm1    # 0x6e028
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x6c(%rbp)
leaq -0x80(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
leaq -0x6c(%rbp), %rsi
callq 0x20110
movq -0xf8(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
callq 0x20170
jmp 0x19abf
leaq -0x90(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x14330
jmp 0x19ad3
leaq -0xa0(%rbp), %rdi
xorps %xmm1, %xmm1
movaps %xmm1, %xmm0
callq 0x14330
jmp 0x19ae7
xorps %xmm0, %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd -0xa8(%rbp), %xmm1
cvtsi2sdl -0x6c(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x19df6
movl $0x0, -0xac(%rbp)
movq -0xe8(%rbp), %rcx
movl -0xac(%rbp), %eax
cmpl 0xc(%rcx), %eax
jge 0x19dd7
movl $0x0, -0xb0(%rbp)
movq -0xe8(%rbp), %rcx
movl -0xb0(%rbp), %eax
cmpl 0x8(%rcx), %eax
jge 0x19dc1
leaq -0x90(%rbp), %rdi
xorps %xmm0, %xmm0
callq 0x202e0
jmp 0x19b5a
movl $0x0, -0xb4(%rbp)
movq -0xe8(%rbp), %rcx
movl -0xb4(%rbp), %eax
cmpl 0x10(%rcx), %eax
jge 0x19d65
movq -0xe8(%rbp), %rax
cvtsi2sdl -0xb4(%rbp), %xmm0
movsd 0xc8(%rax), %xmm2
movl -0xac(%rbp), %ecx
movl 0xb4(%rax), %edx
imull %edx, %ecx
movl -0xb0(%rbp), %edx
movl 0xb8(%rax), %esi
imull %esi, %edx
addl %edx, %ecx
cvtsi2sd %ecx, %xmm1
movsd 0xa8(%rax), %xmm3
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xc0(%rbp)
movsd -0x58(%rbp), %xmm1
movsd -0xa8(%rbp), %xmm0
movsd -0x68(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x55c7d(%rip), %xmm1    # 0x6f870
mulsd %xmm1, %xmm0
movsd -0xc0(%rbp), %xmm1
mulsd %xmm1, %xmm0
callq 0x9e90
leaq -0xa0(%rbp), %rdi
callq 0x13d00
jmp 0x19c16
movsd -0x58(%rbp), %xmm1
movsd -0xa8(%rbp), %xmm0
movsd -0x68(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x55c38(%rip), %xmm1    # 0x6f870
mulsd %xmm1, %xmm0
movsd -0xc0(%rbp), %xmm1
mulsd %xmm1, %xmm0
callq 0x9180
movaps 0x55c3c(%rip), %xmm1    # 0x6f890
pxor %xmm1, %xmm0
leaq -0xa0(%rbp), %rdi
callq 0x13d20
jmp 0x19c66
movq -0xf0(%rbp), %rdi
movq -0xe8(%rbp), %rcx
movl -0xb4(%rbp), %eax
movl 0x8(%rcx), %edx
movl 0xa0(%rcx), %ecx
imull %ecx, %eax
movl -0xac(%rbp), %ecx
imull %edx, %ecx
addl %ecx, %eax
movl -0xb0(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x20350
movq %rax, -0x100(%rbp)
jmp 0x19caa
movq -0x100(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x20310
movsd %xmm1, -0x110(%rbp)
movsd %xmm0, -0x108(%rbp)
jmp 0x19ccf
movsd -0x110(%rbp), %xmm0
movsd -0x108(%rbp), %xmm1
movsd %xmm1, -0xd0(%rbp)
movsd %xmm0, -0xc8(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x203e0
jmp 0x19d04
jmp 0x19d06
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x19b64
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x19d3d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x9470
leaq -0x39(%rbp), %rdi
callq 0x9840
jmp 0x19e7c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0xfde0
jmp 0x19e7c
leaq -0x90(%rbp), %rdi
callq 0x20430
movsd %xmm0, -0x118(%rbp)
jmp 0x19d7b
cvttsd2si -0xa8(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x14140
movq %rax, -0x120(%rbp)
jmp 0x19d96
movq -0x120(%rbp), %rax
movsd -0x118(%rbp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movl -0xb0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb0(%rbp)
jmp 0x19b33
jmp 0x19dc3
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
jmp 0x19b13
jmp 0x19dd9
movsd 0x54247(%rip), %xmm0    # 0x6e028
addsd -0xa8(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
jmp 0x19af2
movl $0x0, -0xd4(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0xd4(%rbp), %rsi
callq 0x20260
jmp 0x19e12
movq -0xe8(%rbp), %rdi
movsd -0x58(%rbp), %xmm1
cvtsi2sdl -0xd4(%rbp), %xmm0
movsd 0x120(%rdi), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x130(%rbp)
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0x14(%rbp), %rsi
callq 0x14140
movq %rax, -0x128(%rbp)
jmp 0x19e57
movq -0x128(%rbp), %rax
movsd -0x130(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq -0x80(%rbp), %rdi
callq 0xfde0
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x9dc0
nopw %cs:(%rax,%rax)