// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0xa8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x1599e(%rip), %rsi     # 0x1d733
leaq 0x159a6(%rip), %rdx     # 0x1d742
leaq 0x98(%rsp), %r15
movq %r15, %rdi
callq 0x43da
movq %r15, %rdi
callq 0x60e8
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x7dd1
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x32b0
movsd 0xd8(%rbx), %xmm0
movapd %xmm0, 0x30(%rsp)
addsd %xmm0, %xmm0
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
movsd 0x120(%rbx), %xmm1
movsd %xmm1, 0x58(%rsp)
divsd %xmm1, %xmm0
addsd 0x155cb(%rip), %xmm0    # 0x1d3d0
cvttsd2si %xmm0, %ecx
testl %ecx, %ecx
js 0x8196
movl %ecx, %r13d
movl %ecx, 0xc(%rsp)
je 0x7e72
leaq (,%r13,8), %rdi
callq 0x3370
movl 0xc(%rsp), %ecx
movq %rax, %r12
cmpl $0x1, %ecx
je 0x7e3f
movl %r12d, %eax
andl $0xf, %eax
jne 0x81b5
testq %r12, %r12
jne 0x7e75
movl $0x8, %edi
callq 0x3130
movq 0x2716b(%rip), %rcx     # 0x2efc0
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x2716d(%rip), %rsi     # 0x2efd0
movq 0x2713e(%rip), %rdx     # 0x2efa8
movq %rax, %rdi
callq 0x3440
xorl %r12d, %r12d
movl %r13d, %r15d
andl $0x7ffffffe, %r15d      # imm = 0x7FFFFFFE
cmpl $0x2, %ecx
jb 0x7ea2
leaq -0x8(,%r15,8), %rdx
andq $-0x10, %rdx
addq $0x10, %rdx
movq %r12, %rdi
xorl %esi, %esi
callq 0x3160
movl 0xc(%rsp), %ecx
movl %ebp, 0x1c(%rsp)
movapd 0x30(%rsp), %xmm0
xorpd 0x1555c(%rip), %xmm0    # 0x1d410
movapd %xmm0, 0x30(%rsp)
cmpl %r13d, %r15d
je 0x7ee5
leaq (,%r13,8), %rdx
movabsq $0x3fffffff0, %rdi      # imm = 0x3FFFFFFF0
andq %rdx, %rdi
addq %r12, %rdi
andl $0x8, %edx
xorl %esi, %esi
callq 0x3160
movl 0xc(%rsp), %ecx
movq %r13, 0x20(%rsp)
movq %r12, 0x28(%rsp)
testl %ecx, %ecx
je 0x80cf
xorps %xmm0, %xmm0
cvtsi2sdl 0xc(%rsp), %xmm0
movsd %xmm0, 0x60(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x48(%rsp), %r12
cmpl $0x0, 0xc(%rbx)
jle 0x80ab
movsd 0x10(%rsp), %xmm0
movapd %xmm0, %xmm1
mulsd 0x58(%rsp), %xmm1
addsd 0x30(%rsp), %xmm1
mulsd 0x154a3(%rip), %xmm1    # 0x1d3e0
movsd %xmm1, 0x70(%rsp)
cvttsd2si %xmm0, %rcx
xorl %r13d, %r13d
movq %rcx, 0x68(%rsp)
cmpl $0x0, 0x8(%rbx)
jle 0x809e
xorl %r15d, %r15d
cmpl $0x0, 0x10(%rbx)
jle 0x805e
xorpd %xmm0, %xmm0
xorl %ebp, %ebp
xorpd %xmm1, %xmm1
movsd %xmm1, 0x80(%rsp)
movsd %xmm0, 0x88(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
movl 0xb4(%rbx), %eax
imull %r13d, %eax
movl 0xb8(%rbx), %ecx
imull %r15d, %ecx
addl %eax, %ecx
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
mulsd 0xa8(%rbx), %xmm1
mulsd 0xc8(%rbx), %xmm0
addsd %xmm1, %xmm0
mulsd 0x70(%rsp), %xmm0
movsd %xmm0, 0x90(%rsp)
callq 0x34a0
movsd %xmm0, 0x78(%rsp)
movsd 0x90(%rsp), %xmm0
callq 0x3090
movl 0xa0(%rbx), %eax
imull %ebp, %eax
movl 0x8(%rbx), %ecx
imull %r13d, %ecx
addl %r15d, %eax
addl %ecx, %eax
js 0x8158
movslq %eax, %rsi
cmpq %rsi, 0x8(%r14)
jle 0x8158
xorps 0x153fe(%rip), %xmm0    # 0x1d410
shlq $0x4, %rsi
addq (%r14), %rsi
movsd 0x78(%rsp), %xmm1
movsd %xmm1, 0x48(%rsp)
movsd %xmm0, 0x50(%rsp)
movq %r12, %rdi
callq 0xfe6c
movsd 0x88(%rsp), %xmm0
addsd 0x48(%rsp), %xmm0
movsd 0x80(%rsp), %xmm1
addsd 0x50(%rsp), %xmm1
incl %ebp
cmpl 0x10(%rbx), %ebp
jl 0x7f71
jmp 0x8066
xorpd %xmm1, %xmm1
xorpd %xmm0, %xmm0
movq 0x68(%rsp), %rcx
cmpq 0x20(%rsp), %rcx
jae 0x8177
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movq 0x28(%rsp), %rax
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
incl %r15d
cmpl 0x8(%rbx), %r15d
jl 0x7f5d
incl %r13d
cmpl 0xc(%rbx), %r13d
jl 0x7f50
movsd 0x10(%rsp), %xmm1
addsd 0x15317(%rip), %xmm1    # 0x1d3d0
movsd 0x60(%rsp), %xmm0
movsd %xmm1, 0x10(%rsp)
ucomisd %xmm1, %xmm0
ja 0x7f15
xorpd %xmm0, %xmm0
cmpl $0x2, 0xc(%rsp)
movl 0x1c(%rsp), %edx
movq 0x28(%rsp), %rdi
jb 0x8117
movsd (%rdi), %xmm0
movl $0x1, %ecx
xorl %eax, %eax
movq 0x20(%rsp), %rsi
movsd (%rdi,%rcx,8), %xmm1
ucomisd %xmm0, %xmm1
cmovaq %rcx, %rax
maxsd %xmm0, %xmm1
incq %rcx
movapd %xmm1, %xmm0
cmpq %rcx, %rsi
jne 0x80f3
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
testl %edx, %edx
js 0x8177
movslq %edx, %rax
cmpq %rax, 0x1d8(%rbx)
jle 0x8177
movq 0x1d0(%rbx), %rcx
mulsd 0x120(%rbx), %xmm0
addsd 0x30(%rsp), %xmm0
movsd %xmm0, (%rcx,%rax,8)
callq 0x3320
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x15137(%rip), %rdi     # 0x1d296
leaq 0x148b6(%rip), %rsi     # 0x1ca1c
leaq 0x1694f(%rip), %rcx     # 0x1eabc
movl $0xb4, %edx
callq 0x31b0
leaq 0x15118(%rip), %rdi     # 0x1d296
leaq 0x14897(%rip), %rsi     # 0x1ca1c
leaq 0x151a8(%rip), %rcx     # 0x1d334
movl $0x1a9, %edx            # imm = 0x1A9
callq 0x31b0
leaq 0x162a2(%rip), %rdi     # 0x1e43f
leaq 0x1467d(%rip), %rsi     # 0x1c821
leaq 0x1631e(%rip), %rcx     # 0x1e4c9
movl $0x138, %edx            # imm = 0x138
callq 0x31b0
leaq 0x1471f(%rip), %rdi     # 0x1c8db
leaq 0x147d2(%rip), %rsi     # 0x1c995
leaq 0x147ea(%rip), %rcx     # 0x1c9b4
movl $0xa1, %edx
callq 0x31b0
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r12, %rdi
je 0x81f4
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x32b0
movq %rbx, %rdi
callq 0x3460