// File: /workspace/github_cpp_makefile_star2_O3/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, %r13d
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x90(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x15b05(%rip), %rsi     # 0x1d7c3
leaq 0x15b0d(%rip), %rdx     # 0x1d7d2
leaq 0x80(%rsp), %r15
movq %r15, %rdi
callq 0x43cc
movq %r15, %rdi
callq 0x60be
movq 0x80(%rsp), %rdi
cmpq %r12, %rdi
je 0x7cfa
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x32a0
movsd 0xd8(%rbx), %xmm0
movapd %xmm0, 0x30(%rsp)
addsd %xmm0, %xmm0
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
movsd 0x120(%rbx), %xmm1
movsd %xmm1, 0x50(%rsp)
divsd %xmm1, %xmm0
addsd 0x156c2(%rip), %xmm0    # 0x1d3f0
cvttsd2si %xmm0, %ebp
testl %ebp, %ebp
js 0x8097
movl %r13d, 0x1c(%rsp)
je 0x7d8d
movl %ebp, %eax
movq %rax, %r13
leaq (,%rax,8), %rdi
callq 0x3360
movq %rax, %r12
cmpl $0x1, %ebp
je 0x7d67
movl %r12d, %eax
andl $0xf, %eax
jne 0x80b6
testq %r12, %r12
je 0x80d5
movq %r13, %rsi
movl %esi, %r15d
andl $0x7ffffffe, %r15d      # imm = 0x7FFFFFFE
cmpl $0x1, %ebp
jne 0x7da0
movq $0x0, 0x8(%rsp)
jmp 0x7dc4
movq $0x0, 0x8(%rsp)
xorl %r15d, %r15d
xorl %r12d, %r12d
xorl %esi, %esi
jmp 0x7dc4
leaq -0x8(,%r15,8), %rdx
andq $-0x10, %rdx
addq $0x10, %rdx
movq %r12, %rdi
xorl %esi, %esi
callq 0x3160
movq %r13, %rsi
movb $0x1, %al
movq %rax, 0x8(%rsp)
movapd 0x30(%rsp), %xmm0
xorpd 0x1567e(%rip), %xmm0    # 0x1d450
movapd %xmm0, 0x30(%rsp)
cmpl %esi, %r15d
movq %rsi, 0x20(%rsp)
je 0x7e09
leaq (,%rsi,8), %rdx
movabsq $0x3fffffff0, %rdi      # imm = 0x3FFFFFFF0
andq %rdx, %rdi
addq %r12, %rdi
andl $0x8, %edx
xorl %esi, %esi
callq 0x3160
movq 0x20(%rsp), %rsi
movq %r12, 0x28(%rsp)
testl %ebp, %ebp
je 0x7fd5
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
movsd %xmm0, 0x58(%rsp)
movl 0xc(%rbx), %eax
xorpd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x40(%rsp), %r12
testl %eax, %eax
jle 0x7fb1
movsd 0x10(%rsp), %xmm0
movapd %xmm0, %xmm1
mulsd 0x50(%rsp), %xmm1
addsd 0x30(%rsp), %xmm1
mulsd 0x155a5(%rip), %xmm1    # 0x1d400
movsd %xmm1, 0x68(%rsp)
cvttsd2si %xmm0, %rdx
movl 0x8(%rbx), %ecx
xorl %r13d, %r13d
movq %rdx, 0x60(%rsp)
testl %ecx, %ecx
jle 0x7fa5
movl 0x10(%rbx), %eax
xorl %r15d, %r15d
xorpd %xmm1, %xmm1
testl %eax, %eax
jle 0x7f5d
xorl %ebp, %ebp
movapd %xmm1, 0xa0(%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 0x68(%rsp), %xmm0
movsd %xmm0, 0x78(%rsp)
callq 0x3490
movsd %xmm0, 0x70(%rsp)
movsd 0x78(%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 0x8059
movslq %eax, %rsi
cmpq %rsi, 0x8(%r14)
jle 0x8059
xorpd 0x15530(%rip), %xmm0    # 0x1d450
shlq $0x4, %rsi
addq (%r14), %rsi
movsd 0x70(%rsp), %xmm1
movsd %xmm1, 0x40(%rsp)
movsd %xmm0, 0x48(%rsp)
movq %r12, %rdi
callq 0xff34
movapd 0xa0(%rsp), %xmm1
addpd 0x40(%rsp), %xmm1
incl %ebp
movl 0x10(%rbx), %eax
cmpl %eax, %ebp
jl 0x7e8d
movq 0x20(%rsp), %rsi
movq 0x60(%rsp), %rdx
cmpq %rdx, %rsi
jbe 0x8078
movapd %xmm1, %xmm0
mulpd %xmm1, %xmm0
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
mulsd %xmm1, %xmm1
addsd %xmm0, %xmm1
movq 0x28(%rsp), %rcx
addsd (%rcx,%rdx,8), %xmm1
movsd %xmm1, (%rcx,%rdx,8)
incl %r15d
movl 0x8(%rbx), %ecx
cmpl %ecx, %r15d
jl 0x7e7f
movl 0xc(%rbx), %eax
incl %r13d
cmpl %eax, %r13d
jl 0x7e71
movsd 0x10(%rsp), %xmm1
addsd 0x15431(%rip), %xmm1    # 0x1d3f0
movsd 0x58(%rsp), %xmm0
movsd %xmm1, 0x10(%rsp)
ucomisd %xmm1, %xmm0
ja 0x7e35
xorpd %xmm0, %xmm0
cmpb $0x0, 0x8(%rsp)
movl 0x1c(%rsp), %edx
movq 0x28(%rsp), %rdi
je 0x8018
movsd (%rdi), %xmm0
movl $0x1, %ecx
xorl %eax, %eax
movsd (%rdi,%rcx,8), %xmm1
ucomisd %xmm0, %xmm1
cmovaq %rcx, %rax
maxsd %xmm0, %xmm1
incq %rcx
movapd %xmm1, %xmm0
cmpq %rcx, %rsi
jne 0x7ff4
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
testl %edx, %edx
js 0x8078
movslq %edx, %rax
cmpq %rax, 0x1d8(%rbx)
jle 0x8078
movq 0x1d0(%rbx), %rcx
mulsd 0x120(%rbx), %xmm0
addsd 0x30(%rsp), %xmm0
movsd %xmm0, (%rcx,%rax,8)
callq 0x3310
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x15256(%rip), %rdi     # 0x1d2b6
leaq 0x149d5(%rip), %rsi     # 0x1ca3c
leaq 0x16ade(%rip), %rcx     # 0x1eb4c
movl $0xb4, %edx
callq 0x31b0
leaq 0x15237(%rip), %rdi     # 0x1d2b6
leaq 0x149b6(%rip), %rsi     # 0x1ca3c
leaq 0x152c7(%rip), %rcx     # 0x1d354
movl $0x1a9, %edx            # imm = 0x1A9
callq 0x31b0
leaq 0x16431(%rip), %rdi     # 0x1e4cf
leaq 0x1479c(%rip), %rsi     # 0x1c841
leaq 0x164ad(%rip), %rcx     # 0x1e559
movl $0x138, %edx            # imm = 0x138
callq 0x31b0
leaq 0x1483e(%rip), %rdi     # 0x1c8fb
leaq 0x148f1(%rip), %rsi     # 0x1c9b5
leaq 0x14909(%rip), %rcx     # 0x1c9d4
movl $0xa1, %edx
callq 0x31b0
movl $0x8, %edi
callq 0x3130
movq 0x26eda(%rip), %rcx     # 0x2efc0
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x26edc(%rip), %rsi     # 0x2efd0
movq 0x26ead(%rip), %rdx     # 0x2efa8
movq %rax, %rdi
callq 0x3430
movq %rax, %rbx
movq 0x80(%rsp), %rdi
cmpq %r12, %rdi
je 0x8123
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x32a0
movq %rbx, %rdi
callq 0x3450
nop