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

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

// 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 0x146ad(%rip), %rsi     # 0x1d86b
leaq 0x60(%rsp), %rdi
movq %r14, %rdx
callq 0xaa45
leaq 0x1460c(%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 0x1e0(%rbx), %rdi
movslq %ebp, %r15
movq %r15, %rsi
callq 0x564e
movsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x1f0(%rbx), %rdi
movq %r15, %rsi
callq 0x564e
movsd (%rax), %xmm1
movq (%rbx), %rax
leaq 0x60(%rsp), %rdi
pushq $0x1
popq %rdx
movq %rbx, %rsi
movsd 0x10(%rsp), %xmm0
callq *0x20(%rax)
movsd 0x100(%rbx), %xmm2
movsd 0x108(%rbx), %xmm0
movsd 0x110(%rbx), %xmm3
movsd 0x118(%rbx), %xmm1
movsd 0x128(%rbx), %xmm4
movsd %xmm2, 0x48(%rsp)
subsd %xmm2, %xmm0
divsd %xmm4, %xmm0
movsd 0x1413f(%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 0x210(%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 0x93f3
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 $0x2
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 0x60(%rsp), %rsi
callq 0x1b0e6
movq %r14, %rdi
leaq 0x20(%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 0x9308
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 0x200(%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 0x9561
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 $0x2
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 0x60(%rsp), %rsi
callq 0x1b0e6
movq %r14, %rdi
leaq 0x88(%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 0x946d
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 0x9671
movq %rax, %rbx
jmp 0x96b7
movq %rax, %rbx
leaq 0x118(%rsp), %rdi
callq 0x3100
jmp 0x95f8
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x3100
jmp 0x9607
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x3100
jmp 0x96c1
jmp 0x9633
jmp 0x9671
movq %rax, %rbx
jmp 0x9662
movq %rax, %rbx
jmp 0x9648
jmp 0x9633
movq %rax, %rbx
jmp 0x9686
movq %rax, %rbx
jmp 0x9655
movq %rax, %rbx
jmp 0x96a0
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 0x969b
movq %rax, %rbx
jmp 0x9693
movq %rax, %rbx
jmp 0x96aa
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