// File: /workspace/github_cpp_makefile_star2_O2/Pyboon[P]sage/isi_sage.cpp
// Function: IsiSage::InitAoD(Eigen::Matrix<std::complex<double>, 1, -1, 1, 1, -1>, int)
void IsiSage::InitAoD(const RowVectorXcd tau_data, const int iL){
    Util::log("init AOD");
    // X_l 
    MatrixXcd X(config.Rx, config.Tx);
    complex<double> cycle_data = 0;
    complex<double> temp = 0;
    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;
            temp = 0;
            for(int i_cyc = 0; i_cyc < config.cycle_num; ++i_cyc){
                double t = (i_cyc * config.Tcy + i_tx * config.Tt + i_rx * config.Tr) * config.T; 
                temp.real(cos(2*PI* result.doppler(iL) * t));
                temp.imag(sin(-2*PI* result.doppler(iL) * t));
                cycle_data += temp * tau_data(i_cyc * config.subchannel_num + i_tx * config.Rx + i_rx);
            }
            X(i_rx, i_tx) = cycle_data;
        }
    }
    // c_2_p
    MatrixX2cd C2 = getAntennaResponse(result.theta_rx(iL), result.phi_rx(iL), 2);
    VectorXcd c_2_1 = C2.col(0);
    VectorXcd c_2_2 = C2.col(1);
    Vector4cd f;
    Matrix2Xcd f_temp(2, config.Tx);
    f_temp.row(0) = c_2_1.adjoint() * X;
    f_temp.row(1) = c_2_2.adjoint() * X;
    double min_theta_tx = config.min_theta_tx;
    double max_theta_tx = config.max_theta_tx;
    double min_phi_tx = config.min_phi_tx;
    double max_phi_tx = config.max_phi_tx;
    double step = config.angle_step;
    int theta_size = (max_theta_tx - min_theta_tx)/step;
    int phi_size = (max_phi_tx - min_phi_tx)/step;
    MatrixXd aod_data(theta_size, phi_size);
    for(int i_theta = 0; i_theta < theta_size; ++i_theta){
        for(int i_phi = 0; i_phi < phi_size; ++i_phi){
            MatrixX2cd C1 = getAntennaResponse(i_theta * step + min_theta_tx, i_phi * step + min_phi_tx, 1);
            VectorXcd c_1_1_conj = C1.col(0).conjugate();
            VectorXcd c_1_2_conj = C1.col(1).conjugate();
            f(0) = f_temp.row(0) * c_1_1_conj;
            f(1) = f_temp.row(0) * c_1_2_conj;
            f(2) = f_temp.row(1) * c_1_1_conj;
            f(3) = f_temp.row(1) * c_1_2_conj;
            Matrix2cd part1 = C2.adjoint() * C2;
            Matrix2cd part2 = C1.adjoint() * C1;
            MatrixXcd D = kroneckerProduct(part1, part2);
            complex<double> z = f.adjoint() * D.inverse() * f;
            aod_data(i_theta, i_phi) = norm(z);
        }
    }
    int i,j;
    aod_data.maxCoeff(&i, &j);
    result.theta_tx(iL) = i * config.angle_step + min_theta_tx;
    result.phi_tx(iL) = j * config.angle_step + min_phi_tx;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movl %edx, %ebp
movq %rsi, 0x28(%rsp)
movq %rdi, %rbx
leaq 0x161a6(%rip), %rsi     # 0x1d7be
leaq 0x210(%rsp), %rdi
leaq 0xf0(%rsp), %rdx
callq 0x3b5e
leaq 0x210(%rsp), %rdi
callq 0x547e
leaq 0x210(%rsp), %rdi
callq 0x3100
leaq 0x8(%rbx), %rsi
leaq 0xc(%rbx), %rdx
leaq 0x138(%rsp), %rdi
movq %rsi, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
callq 0xabc2
leaq 0x1d0(%rbx), %r15
movslq %ebp, %rax
movq %rax, 0x30(%rsp)
xorpd %xmm0, %xmm0
leaq 0xb0(%rsp), %rax
movapd %xmm0, (%rax)
xorl %r13d, %r13d
movq 0x30(%rsp), %r12
movq 0x8(%rsp), %rax
movslq (%rax), %rax
cmpq %rax, %r13
jge 0x77d4
xorl %r14d, %r14d
movq 0x10(%rsp), %rax
movslq (%rax), %rax
cmpq %rax, %r14
jge 0x77cc
xorpd %xmm0, %xmm0
movapd %xmm0, 0xb0(%rsp)
movapd %xmm0, 0x40(%rsp)
xorl %ebp, %ebp
cmpl 0x10(%rbx), %ebp
jge 0x77a7
movl 0xbc(%rbx), %eax
imull %ebp, %eax
movl 0xb4(%rbx), %ecx
imull %r13d, %ecx
addl %eax, %ecx
movl 0xb8(%rbx), %eax
imull %r14d, %eax
addl %ecx, %eax
cvtsi2sd %eax, %xmm0
mulsd 0xa8(%rbx), %xmm0
movsd %xmm0, (%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x564e
movsd (%rax), %xmm0
mulsd 0x15ccf(%rip), %xmm0    # 0x1d3e8
mulsd (%rsp), %xmm0
callq 0x3470
movsd %xmm0, 0xb0(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x564e
movsd (%rax), %xmm1
mulsd 0x15cad(%rip), %xmm1    # 0x1d3f0
movsd (%rsp), %xmm0
mulsd %xmm1, %xmm0
callq 0x3080
movsd %xmm0, 0xb8(%rsp)
movl 0xa0(%rbx), %eax
imull %ebp, %eax
movl 0x8(%rbx), %ecx
imull %r13d, %ecx
addl %r14d, %eax
addl %ecx, %eax
movslq %eax, %rsi
movq 0x28(%rsp), %rdi
callq 0xab8c
leaq 0xb0(%rsp), %rdi
movq %rax, %rsi
callq 0xab66
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
movapd 0x40(%rsp), %xmm1
addpd %xmm0, %xmm1
movapd %xmm1, 0x40(%rsp)
incl %ebp
jmp 0x76c7
leaq 0x138(%rsp), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x54d6
movapd 0x40(%rsp), %xmm0
movupd %xmm0, (%rax)
incq %r14
jmp 0x76a1
incq %r13
jmp 0x768d
leaq 0x200(%rbx), %rdi
movq 0x30(%rsp), %r12
movq %r12, %rsi
callq 0x564e
movsd (%rax), %xmm0
movsd %xmm0, (%rsp)
leaq 0x210(%rbx), %rdi
movq %r12, %rsi
callq 0x564e
movsd (%rax), %xmm1
movq (%rbx), %rax
leaq 0x60(%rsp), %rdi
pushq $0x2
popq %rdx
movq %rbx, %rsi
movsd (%rsp), %xmm0
callq *0x20(%rax)
leaq 0xf0(%rsp), %rdi
leaq 0x60(%rsp), %rsi
xorl %edx, %edx
callq 0xc424
leaq 0x198(%rsp), %r15
leaq 0xf0(%rsp), %rsi
movq %r15, %rdi
callq 0xd570
leaq 0xf0(%rsp), %rdi
leaq 0x60(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0xc424
leaq 0x188(%rsp), %r14
leaq 0xf0(%rsp), %rsi
movq %r14, %rdi
callq 0xd570
xorpd %xmm0, %xmm0
movapd %xmm0, 0x120(%rsp)
movapd %xmm0, 0x110(%rsp)
movapd %xmm0, 0x100(%rsp)
movapd %xmm0, 0xf0(%rsp)
leaq 0x70(%rsp), %rsi
movl $0x2, (%rsi)
leaq 0x18(%rsp), %rdi
movq 0x8(%rsp), %rdx
callq 0xae6a
leaq 0x168(%rsp), %rsi
movq %r15, (%rsi)
leaq 0x1c0(%rsp), %rdi
leaq 0x138(%rsp), %rdx
callq 0xd81e
leaq 0x70(%rsp), %rdi
leaq 0x18(%rsp), %rsi
xorl %edx, %edx
callq 0xd77a
leaq 0x70(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
callq 0xd854
leaq 0x168(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x1c0(%rsp), %rdi
leaq 0x138(%rsp), %rdx
callq 0xd81e
leaq 0x70(%rsp), %rdi
leaq 0x18(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0xd77a
leaq 0x70(%rsp), %rdi
leaq 0x1c0(%rsp), %rbp
movq %rbp, %rsi
callq 0xd854
movsd 0xe0(%rbx), %xmm3
movsd 0xe8(%rbx), %xmm0
movsd 0xf0(%rbx), %xmm2
movsd 0xf8(%rbx), %xmm1
movsd 0x128(%rbx), %xmm4
movsd %xmm3, 0x50(%rsp)
subsd %xmm3, %xmm0
divsd %xmm4, %xmm0
cvttsd2si %xmm0, %eax
leaq 0x3c(%rsp), %rsi
movl %eax, (%rsi)
movsd %xmm2, 0x58(%rsp)
subsd %xmm2, %xmm1
movsd %xmm4, 0x10(%rsp)
divsd %xmm4, %xmm1
cvttsd2si %xmm1, %eax
leaq 0x38(%rsp), %rdx
movl %eax, (%rdx)
leaq 0x150(%rsp), %rdi
callq 0xabfa
xorl %r14d, %r14d
leaq 0x168(%rsp), %r13
leaq 0x1a8(%rsp), %r15
movslq 0x3c(%rsp), %rax
cmpq %rax, %r14
jge 0x7d25
cvtsi2sd %r14d, %xmm0
mulsd 0x10(%rsp), %xmm0
addsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
xorl %ecx, %ecx
movslq 0x38(%rsp), %rax
cmpq %rax, %rcx
jge 0x7d18
movq %r15, %r12
movq %rcx, (%rsp)
cvtsi2sd %ecx, %xmm1
mulsd 0x10(%rsp), %xmm1
addsd 0x58(%rsp), %xmm1
movq (%rbx), %rax
leaq 0xe0(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movsd 0x8(%rsp), %xmm0
pushq $0x1
popq %rdx
callq *0x20(%rax)
movq %rbp, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0xc424
movups 0x1c0(%rsp), %xmm0
movaps %xmm0, 0x70(%rsp)
leaq 0x1d8(%rsp), %rax
movupd (%rax), %xmm0
movupd 0x10(%rax), %xmm1
leaq 0x88(%rsp), %rax
movupd %xmm1, 0x10(%rax)
movupd %xmm0, (%rax)
leaq 0xd0(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0xe92c
movq %rbp, %rdi
leaq 0xe0(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0xc424
movups 0x1c0(%rsp), %xmm0
movaps %xmm0, 0x70(%rsp)
leaq 0x1d8(%rsp), %rax
movupd (%rax), %xmm0
movupd 0x10(%rax), %xmm1
leaq 0x88(%rsp), %rax
movupd %xmm1, 0x10(%rax)
movupd %xmm0, (%rax)
leaq 0xc0(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0xe92c
movq %rbp, %rdi
leaq 0x18(%rsp), %rsi
xorl %edx, %edx
callq 0xd77a
leaq 0x70(%rsp), %rdi
movq %rbp, %rsi
leaq 0xd0(%rsp), %rdx
callq 0xeafa
leaq 0x70(%rsp), %rdi
callq 0xae9e
movsd %xmm0, 0xf0(%rsp)
movsd %xmm1, 0xf8(%rsp)
movq %rbp, %rdi
leaq 0x18(%rsp), %rsi
xorl %edx, %edx
callq 0xd77a
leaq 0x70(%rsp), %rdi
movq %rbp, %rsi
leaq 0xc0(%rsp), %rdx
callq 0xeafa
leaq 0x70(%rsp), %rdi
callq 0xae9e
movsd %xmm0, 0x100(%rsp)
movsd %xmm1, 0x108(%rsp)
movq %rbp, %rdi
leaq 0x18(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0xd77a
leaq 0x70(%rsp), %rdi
movq %rbp, %rsi
leaq 0xd0(%rsp), %rdx
callq 0xeafa
leaq 0x70(%rsp), %rdi
callq 0xae9e
movsd %xmm0, 0x110(%rsp)
movsd %xmm1, 0x118(%rsp)
movq %rbp, %rdi
leaq 0x18(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0xd77a
leaq 0x70(%rsp), %rdi
movq %rbp, %rsi
leaq 0xc0(%rsp), %rdx
callq 0xeafa
leaq 0x70(%rsp), %rdi
callq 0xae9e
movsd %xmm0, 0x120(%rsp)
movsd %xmm1, 0x128(%rsp)
leaq 0x60(%rsp), %rdx
movq %rdx, 0x168(%rsp)
movq %rbp, %rdi
movq %r13, %rsi
callq 0xede8
leaq 0x70(%rsp), %rdi
movq %rbp, %rsi
callq 0xee1e
leaq 0xe0(%rsp), %rdx
movq %rdx, 0x1a8(%rsp)
movq %r13, %r15
movq %r13, %rdi
movq %r12, %rsi
callq 0xede8
movq %rbp, %rdi
movq %r15, %rsi
callq 0xee1e
leaq 0x70(%rsp), %rax
movq %rax, 0x168(%rsp)
movq %rbp, 0x170(%rsp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x116c6
leaq 0xf0(%rsp), %rax
movq %rax, 0x200(%rsp)
movq %r12, %rdi
callq 0xaec4
movq %r12, %r15
movq %rax, 0x130(%rsp)
leaq 0x230(%rsp), %rdi
leaq 0x200(%rsp), %rsi
leaq 0x130(%rsp), %rdx
callq 0x11adc
movq %r13, %rdi
leaq 0x230(%rsp), %rsi
leaq 0xf0(%rsp), %rdx
callq 0x11b10
movq %r13, %rdi
callq 0xaef2
movsd %xmm0, 0x40(%rsp)
movsd %xmm1, 0x28(%rsp)
leaq 0x150(%rsp), %rdi
movq %r14, %rsi
movq (%rsp), %r12
movq %r12, %rdx
callq 0xade2
movsd 0x28(%rsp), %xmm1
mulsd %xmm1, %xmm1
movsd 0x40(%rsp), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movq 0x1a8(%rsp), %rdi
callq 0x32c0
movq 0xc0(%rsp), %rdi
callq 0x32c0
movq 0xd0(%rsp), %rdi
callq 0x32c0
movq 0xe0(%rsp), %rdi
callq 0x32c0
incq %r12
movq %r12, %rcx
jmp 0x79e6
incq %r14
movq 0x30(%rsp), %r12
jmp 0x79bf
leaq 0x150(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x1c0(%rsp), %rdx
callq 0xae2c
movl 0x70(%rsp), %ebp
movsd 0x128(%rbx), %xmm0
movsd %xmm0, (%rsp)
leaq 0x1e0(%rbx), %rdi
movq %r12, %rsi
callq 0x564e
cvtsi2sd %ebp, %xmm0
mulsd (%rsp), %xmm0
addsd 0x50(%rsp), %xmm0
movsd %xmm0, (%rax)
movl 0x1c0(%rsp), %ebp
movsd 0x128(%rbx), %xmm0
movsd %xmm0, (%rsp)
addq $0x1f0, %rbx            # imm = 0x1F0
movq %rbx, %rdi
movq %r12, %rsi
callq 0x564e
cvtsi2sd %ebp, %xmm0
mulsd (%rsp), %xmm0
addsd 0x58(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x150(%rsp), %rdi
callq 0x32c0
movq 0x18(%rsp), %rdi
callq 0x32c0
movq 0x188(%rsp), %rdi
callq 0x32c0
movq 0x198(%rsp), %rdi
callq 0x32c0
movq 0x60(%rsp), %rdi
callq 0x32c0
movq 0x138(%rsp), %rdi
callq 0x32c0
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7e32
jmp 0x7e32
jmp 0x7e32
movq %rax, %rbx
jmp 0x7ec6
movq %rax, %rbx
leaq 0x210(%rsp), %rdi
callq 0x3100
jmp 0x7efe
movq %rax, %rbx
jmp 0x7efe
jmp 0x7e32
movq %rax, %rbx
jmp 0x7ebc
movq %rax, %rbx
jmp 0x7ed3
movq %rax, %rbx
jmp 0x7ee0
jmp 0x7e55
jmp 0x7eee
jmp 0x7e78
jmp 0x7e73
movq %rax, %rbx
jmp 0x7eaf
jmp 0x7eee
jmp 0x7e73
jmp 0x7e73
movq %rax, %rbx
jmp 0x7ea2
movq %rax, %rbx
jmp 0x7e95
jmp 0x7e73
jmp 0x7e73
jmp 0x7e73
movq %rax, %rbx
jmp 0x7e88
movq %rax, %rbx
movq 0x1a8(%rsp), %rdi
callq 0x32c0
movq 0xc0(%rsp), %rdi
callq 0x32c0
movq 0xd0(%rsp), %rdi
callq 0x32c0
movq 0xe0(%rsp), %rdi
callq 0x32c0
movq 0x150(%rsp), %rdi
callq 0x32c0
movq 0x18(%rsp), %rdi
callq 0x32c0
movq 0x188(%rsp), %rdi
callq 0x32c0
movq 0x198(%rsp), %rdi
callq 0x32c0
movq 0x60(%rsp), %rdi
callq 0x32c0
jmp 0x7ef1
jmp 0x7eee
movq %rax, %rbx
movq 0x138(%rsp), %rdi
callq 0x32c0
movq %rbx, %rdi
callq 0x3430