// File: /workspace/github_cpp_makefile_star2_O2/Pyboon[P]sage/isi_sage.cpp
// Function: IsiSage::UpdateAoD(Eigen::Matrix<std::complex<double>, 1, -1, 1, 1, -1>, int)
void IsiSage::UpdateAoD(RowVectorXcd tau_data, const int iL){
    Util::log("updating AoD of the " + to_string(iL) + "th path");
    MatrixX2cd C2 = getAntennaResponse(result.theta_rx(iL), result.phi_rx(iL), 2);
    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+1;
    int phi_size = (max_phi_tx - min_phi_tx)/step+1;
    VectorXd theta_data(theta_size);
    for(int i_theta = 0; i_theta < theta_size; ++i_theta){
        MatrixX2cd C1 = getAntennaResponse(i_theta * step + min_theta_tx, result.phi_tx(iL), 1);
        theta_data(i_theta) = ObjectiveFunction(tau_data, result.doppler(iL), C1, C2, iL);
    }
    int max_index = 0;
    theta_data.maxCoeff(&max_index);
    result.theta_tx(iL) = max_index * config.angle_step + min_theta_tx;

    VectorXd phi_data(phi_size);
    for(int i_phi = 0; i_phi < phi_size; ++i_phi){
        MatrixX2cd C1 = getAntennaResponse(result.theta_tx(iL), i_phi* step + min_phi_tx, 1);
        phi_data(i_phi) = ObjectiveFunction(tau_data, result.doppler(iL), C1, C2, iL);
    }
    phi_data.maxCoeff(&max_index);
    result.phi_tx(iL) = max_index * config.angle_step + min_phi_tx;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movl %edx, %ebp
movq %rsi, 0x58(%rsp)
movq %rdi, %rbx
leaq 0x98(%rsp), %r14
movq %r14, %rdi
movl %edx, %esi
callq 0xaa69
leaq 0x14182(%rip), %rsi     # 0x1d880
leaq 0x60(%rsp), %rdi
movq %r14, %rdx
callq 0xaa45
leaq 0x140cc(%rip), %rdx     # 0x1d7de
leaq 0x118(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x545f
leaq 0x118(%rsp), %rdi
callq 0x547e
leaq 0x118(%rsp), %rdi
callq 0x3100
leaq 0x60(%rsp), %rdi
callq 0x3100
leaq 0x98(%rsp), %rdi
callq 0x3100
leaq 0x200(%rbx), %rdi
movslq %ebp, %r15
movq %r15, %rsi
callq 0x564e
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x210(%rbx), %rdi
movq %r15, %rsi
callq 0x564e
movsd (%rax), %xmm1
movq (%rbx), %rax
leaq 0x60(%rsp), %rdi
pushq $0x2
popq %rdx
movq %rbx, %rsi
movsd 0x10(%rsp), %xmm0
callq *0x20(%rax)
movsd 0xe0(%rbx), %xmm2
movsd 0xe8(%rbx), %xmm0
movsd 0xf0(%rbx), %xmm3
movsd 0xf8(%rbx), %xmm1
movsd 0x128(%rbx), %xmm4
movsd %xmm2, 0x48(%rsp)
subsd %xmm2, %xmm0
divsd %xmm4, %xmm0
movsd 0x13bff(%rip), %xmm2    # 0x1d3d8
addsd %xmm2, %xmm0
cvttsd2si %xmm0, %eax
leaq 0x34(%rsp), %rsi
movl %eax, (%rsi)
movsd %xmm3, 0x38(%rsp)
subsd %xmm3, %xmm1
movsd %xmm4, 0x10(%rsp)
divsd %xmm4, %xmm1
addsd %xmm2, %xmm1
cvttsd2si %xmm1, %eax
movl %eax, 0x1c(%rsp)
leaq 0x98(%rsp), %rdi
callq 0xaade
leaq 0x1f0(%rbx), %rax
movq %rax, 0x40(%rsp)
leaq 0x1d0(%rbx), %rax
movq %rax, 0x50(%rsp)
xorl %r12d, %r12d
leaq 0x108(%rsp), %r13
leaq 0xf8(%rsp), %rbp
leaq 0xe8(%rsp), %r14
movslq 0x34(%rsp), %rax
cmpq %rax, %r12
jge 0x9933
movq 0x40(%rsp), %rdi
movq %r15, %rsi
callq 0x564e
cvtsi2sd %r12d, %xmm0
mulsd 0x10(%rsp), %xmm0
addsd 0x48(%rsp), %xmm0
movsd (%rax), %xmm1
movq (%rbx), %rax
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
pushq $0x1
popq %rdx
callq *0x20(%rax)
movq %r13, %rdi
movq 0x58(%rsp), %rsi
callq 0xb9b4
movq 0x50(%rsp), %rdi
movq %r15, %rsi
callq 0x564e
movsd (%rax), %xmm0
movsd %xmm0, (%rsp)
movq %rbp, %rdi
leaq 0x20(%rsp), %rsi
callq 0x1b0e6
movq %r14, %rdi
leaq 0x60(%rsp), %rsi
callq 0x1b0e6
movq %rbx, %rdi
movq %r13, %rsi
movsd (%rsp), %xmm0
movq %rbp, %rdx
movq %r14, %rcx
callq 0x9f64
movsd %xmm0, (%rsp)
leaq 0x98(%rsp), %rdi
movq %r12, %rsi
callq 0x564e
movsd (%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0xe8(%rsp), %rdi
callq 0x32c0
movq 0xf8(%rsp), %rdi
callq 0x32c0
movq 0x108(%rsp), %rdi
callq 0x32c0
movq 0x20(%rsp), %rdi
callq 0x32c0
incq %r12
jmp 0x9848
leaq 0xc(%rsp), %rsi
andl $0x0, (%rsi)
leaq 0x98(%rsp), %rdi
callq 0xab3e
movl 0xc(%rsp), %ebp
movsd 0x128(%rbx), %xmm0
movsd %xmm0, (%rsp)
leaq 0x1e0(%rbx), %rdi
movq %rdi, 0x80(%rsp)
movq %r15, %rsi
callq 0x564e
cvtsi2sd %ebp, %xmm0
mulsd (%rsp), %xmm0
addsd 0x48(%rsp), %xmm0
movsd %xmm0, (%rax)
leaq 0x20(%rsp), %rdi
leaq 0x1c(%rsp), %rsi
callq 0xaade
xorl %r12d, %r12d
leaq 0xd8(%rsp), %rbp
leaq 0xc8(%rsp), %r13
leaq 0xb8(%rsp), %r14
movslq 0x1c(%rsp), %rax
cmpq %rax, %r12
jge 0x9aa1
movq 0x80(%rsp), %rdi
movq %r15, %rsi
callq 0x564e
cvtsi2sd %r12d, %xmm1
movsd (%rax), %xmm0
mulsd 0x10(%rsp), %xmm1
addsd 0x38(%rsp), %xmm1
movq (%rbx), %rax
leaq 0x88(%rsp), %rdi
movq %rbx, %rsi
pushq $0x1
popq %rdx
callq *0x20(%rax)
movq %rbp, %rdi
movq 0x58(%rsp), %rsi
callq 0xb9b4
movq 0x50(%rsp), %rdi
movq %r15, %rsi
callq 0x564e
movsd (%rax), %xmm0
movsd %xmm0, (%rsp)
movq %r13, %rdi
leaq 0x88(%rsp), %rsi
callq 0x1b0e6
movq %r14, %rdi
leaq 0x60(%rsp), %rsi
callq 0x1b0e6
movq %rbx, %rdi
movq %rbp, %rsi
movsd (%rsp), %xmm0
movq %r13, %rdx
movq %r14, %rcx
callq 0x9f64
movsd %xmm0, (%rsp)
leaq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0x564e
movsd (%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0xb8(%rsp), %rdi
callq 0x32c0
movq 0xc8(%rsp), %rdi
callq 0x32c0
movq 0xd8(%rsp), %rdi
callq 0x32c0
movq 0x88(%rsp), %rdi
callq 0x32c0
incq %r12
jmp 0x99ad
leaq 0x20(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0xab3e
movl 0xc(%rsp), %ebp
movsd 0x128(%rbx), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x40(%rsp), %rdi
movq %r15, %rsi
callq 0x564e
cvtsi2sd %ebp, %xmm0
mulsd 0x10(%rsp), %xmm0
addsd 0x38(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x20(%rsp), %rdi
callq 0x32c0
movq 0x98(%rsp), %rdi
callq 0x32c0
movq 0x60(%rsp), %rdi
callq 0x32c0
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9bb1
movq %rax, %rbx
jmp 0x9bf7
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
callq 0x3100
jmp 0x9b38
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x3100
jmp 0x9b47
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x3100
jmp 0x9c01
jmp 0x9b73
jmp 0x9bb1
movq %rax, %rbx
jmp 0x9ba2
movq %rax, %rbx
jmp 0x9b88
jmp 0x9b73
movq %rax, %rbx
jmp 0x9bc6
movq %rax, %rbx
jmp 0x9b95
movq %rax, %rbx
jmp 0x9be0
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
callq 0x32c0
movq 0xc8(%rsp), %rdi
callq 0x32c0
movq 0xd8(%rsp), %rdi
callq 0x32c0
movq 0x88(%rsp), %rdi
jmp 0x9bdb
movq %rax, %rbx
jmp 0x9bd3
movq %rax, %rbx
jmp 0x9bea
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
callq 0x32c0
movq 0xf8(%rsp), %rdi
callq 0x32c0
movq 0x108(%rsp), %rdi
callq 0x32c0
movq 0x20(%rsp), %rdi
callq 0x32c0
movq 0x98(%rsp), %rdi
callq 0x32c0
movq 0x60(%rsp), %rdi
callq 0x32c0
movq %rbx, %rdi
callq 0x3430
nop