// File: 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
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movq %rsi, -0x198(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x190(%rbp)
movl -0x14(%rbp), %esi
leaq -0x78(%rbp), %rdi
movq %rdi, -0x188(%rbp)
callq 0x1fef0
movq -0x188(%rbp), %rdx
leaq 0x52642(%rip), %rsi     # 0x6fc6b
leaq -0x58(%rbp), %rdi
callq 0x1fea0
jmp 0x1d634
leaq 0x525a3(%rip), %rdx     # 0x6fbde
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x13b30
jmp 0x1d64a
leaq -0x38(%rbp), %rdi
callq 0x13b80
jmp 0x1d655
leaq -0x38(%rbp), %rdi
callq 0x9470
leaq -0x58(%rbp), %rdi
callq 0x9470
leaq -0x78(%rbp), %rdi
callq 0x9470
movq -0x190(%rbp), %rdi
addq $0x1e0, %rdi            # imm = 0x1E0
movslq -0x14(%rbp), %rsi
callq 0x14140
movq -0x190(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x1a0(%rbp)
addq $0x1f0, %rdi            # imm = 0x1F0
movslq -0x14(%rbp), %rsi
callq 0x14140
movsd -0x1a0(%rbp), %xmm0
movq -0x190(%rbp), %rsi
movsd (%rax), %xmm1
movq (%rsi), %rax
movq 0x20(%rax), %rax
leaq -0x98(%rbp), %rdi
movl $0x1, %edx
callq *%rax
movq -0x190(%rbp), %rax
movsd 0x100(%rax), %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd 0x108(%rax), %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd 0x110(%rax), %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd 0x118(%rax), %xmm0
movsd %xmm0, -0xb8(%rbp)
movsd 0x128(%rax), %xmm0
movsd %xmm0, -0xc0(%rbp)
movsd -0xa8(%rbp), %xmm0
movsd -0xa0(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd -0xc0(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0x508d7(%rip), %xmm1    # 0x6e028
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0xc4(%rbp)
movsd -0xb8(%rbp), %xmm0
movsd -0xb0(%rbp), %xmm2
subsd %xmm2, %xmm0
movsd -0xc0(%rbp), %xmm2
divsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0xc8(%rbp)
leaq -0xd8(%rbp), %rdi
leaq -0xc4(%rbp), %rsi
callq 0x20110
jmp 0x1d7a2
movl $0x0, -0xdc(%rbp)
movl -0xdc(%rbp), %eax
cmpl -0xc4(%rbp), %eax
jge 0x1da43
movq -0x190(%rbp), %rdi
cvtsi2sdl -0xdc(%rbp), %xmm0
movsd -0xc0(%rbp), %xmm2
movsd -0xa0(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x1b0(%rbp)
addq $0x210, %rdi            # imm = 0x210
movslq -0x14(%rbp), %rsi
callq 0x14140
movq %rax, -0x1a8(%rbp)
jmp 0x1d806
movsd -0x1b0(%rbp), %xmm0
movq -0x190(%rbp), %rsi
movq -0x1a8(%rbp), %rax
movsd (%rax), %xmm1
movq (%rsi), %rax
movq 0x20(%rax), %rax
leaq -0xf0(%rbp), %rdi
movl $0x2, %edx
callq *%rax
jmp 0x1d837
movq -0x198(%rbp), %rsi
leaq -0x100(%rbp), %rdi
callq 0x20010
jmp 0x1d84c
movq -0x190(%rbp), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0x14(%rbp), %rsi
callq 0x14140
movq %rax, -0x1b8(%rbp)
jmp 0x1d86c
movq -0x1b8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x1c0(%rbp)
leaq -0x110(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x21a90
jmp 0x1d894
leaq -0x120(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x21a90
jmp 0x1d8a9
movsd -0x1c0(%rbp), %xmm0
movq -0x190(%rbp), %rdi
movl -0x14(%rbp), %r8d
leaq -0x100(%rbp), %rsi
leaq -0x110(%rbp), %rdx
leaq -0x120(%rbp), %rcx
callq 0x1ead0
movsd %xmm0, -0x1c8(%rbp)
jmp 0x1d8e0
movslq -0xdc(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
callq 0x14140
movq %rax, -0x1d0(%rbp)
jmp 0x1d8fc
movq -0x1d0(%rbp), %rax
movsd -0x1c8(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq -0x120(%rbp), %rdi
callq 0x13f10
leaq -0x110(%rbp), %rdi
callq 0x13f10
leaq -0x100(%rbp), %rdi
callq 0x20040
leaq -0xf0(%rbp), %rdi
callq 0x13f10
movl -0xdc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xdc(%rbp)
jmp 0x1d7ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1d996
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1d98d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x9470
leaq -0x58(%rbp), %rdi
callq 0x9470
leaq -0x78(%rbp), %rdi
callq 0x9470
jmp 0x1ddc9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1ddbd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1ddb1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1da32
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1da26
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1da1a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x13f10
leaq -0x110(%rbp), %rdi
callq 0x13f10
leaq -0x100(%rbp), %rdi
callq 0x20040
leaq -0xf0(%rbp), %rdi
callq 0x13f10
jmp 0x1ddb1
movl $0x0, -0x124(%rbp)
leaq -0xd8(%rbp), %rdi
leaq -0x124(%rbp), %rsi
callq 0x20260
jmp 0x1da62
movq -0x190(%rbp), %rdi
cvtsi2sdl -0x124(%rbp), %xmm0
movsd 0x128(%rdi), %xmm2
movsd -0xa0(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x1e0(%rbp)
addq $0x200, %rdi            # imm = 0x200
movslq -0x14(%rbp), %rsi
callq 0x14140
movq %rax, -0x1d8(%rbp)
jmp 0x1daaa
movq -0x1d8(%rbp), %rax
movsd -0x1e0(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq -0x138(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x20110
jmp 0x1dad2
movl $0x0, -0x13c(%rbp)
movl $0x0, -0x13c(%rbp)
movl -0x13c(%rbp), %eax
cmpl -0xc8(%rbp), %eax
jge 0x1dd08
movq -0x190(%rbp), %rdi
addq $0x200, %rdi            # imm = 0x200
movslq -0x14(%rbp), %rsi
callq 0x14140
movq %rax, -0x1e8(%rbp)
jmp 0x1db18
movq -0x190(%rbp), %rsi
movq -0x1e8(%rbp), %rax
movsd (%rax), %xmm0
cvtsi2sdl -0x13c(%rbp), %xmm1
movsd -0xc0(%rbp), %xmm3
movsd -0xb0(%rbp), %xmm2
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
movq (%rsi), %rax
movq 0x20(%rax), %rax
leaq -0x150(%rbp), %rdi
movl $0x2, %edx
callq *%rax
jmp 0x1db61
movq -0x198(%rbp), %rsi
leaq -0x160(%rbp), %rdi
callq 0x20010
jmp 0x1db76
movq -0x190(%rbp), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0x14(%rbp), %rsi
callq 0x14140
movq %rax, -0x1f0(%rbp)
jmp 0x1db96
movq -0x1f0(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x1f8(%rbp)
leaq -0x170(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x21a90
jmp 0x1dbbe
leaq -0x180(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x21a90
jmp 0x1dbd3
movsd -0x1f8(%rbp), %xmm0
movq -0x190(%rbp), %rdi
movl -0x14(%rbp), %r8d
leaq -0x160(%rbp), %rsi
leaq -0x170(%rbp), %rdx
leaq -0x180(%rbp), %rcx
callq 0x1ead0
movsd %xmm0, -0x200(%rbp)
jmp 0x1dc0a
movslq -0x13c(%rbp), %rsi
leaq -0x138(%rbp), %rdi
callq 0x14140
movq %rax, -0x208(%rbp)
jmp 0x1dc26
movq -0x208(%rbp), %rax
movsd -0x200(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq -0x180(%rbp), %rdi
callq 0x13f10
leaq -0x170(%rbp), %rdi
callq 0x13f10
leaq -0x160(%rbp), %rdi
callq 0x20040
leaq -0x150(%rbp), %rdi
callq 0x13f10
movl -0x13c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x13c(%rbp)
jmp 0x1dae6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1dda5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1dcf7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1dceb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1dcdf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x13f10
leaq -0x170(%rbp), %rdi
callq 0x13f10
leaq -0x160(%rbp), %rdi
callq 0x20040
leaq -0x150(%rbp), %rdi
callq 0x13f10
jmp 0x1dda5
leaq -0x138(%rbp), %rdi
leaq -0x124(%rbp), %rsi
callq 0x20260
jmp 0x1dd1d
movq -0x190(%rbp), %rdi
cvtsi2sdl -0x124(%rbp), %xmm0
movsd 0x128(%rdi), %xmm2
movsd -0xb0(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x218(%rbp)
addq $0x210, %rdi            # imm = 0x210
movslq -0x14(%rbp), %rsi
callq 0x14140
movq %rax, -0x210(%rbp)
jmp 0x1dd65
movq -0x210(%rbp), %rax
movsd -0x218(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq -0x138(%rbp), %rdi
callq 0xfde0
leaq -0xd8(%rbp), %rdi
callq 0xfde0
leaq -0x98(%rbp), %rdi
callq 0x13f10
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
leaq -0x138(%rbp), %rdi
callq 0xfde0
leaq -0xd8(%rbp), %rdi
callq 0xfde0
leaq -0x98(%rbp), %rdi
callq 0x13f10
movq -0x80(%rbp), %rdi
callq 0x9dc0
nopw %cs:(%rax,%rax)