// File: 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
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 0x51e57(%rip), %rsi     # 0x6fc80
leaq -0x58(%rbp), %rdi
callq 0x1fea0
jmp 0x1de34
leaq 0x51da3(%rip), %rdx     # 0x6fbde
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x13b30
jmp 0x1de4a
leaq -0x38(%rbp), %rdi
callq 0x13b80
jmp 0x1de55
leaq -0x38(%rbp), %rdi
callq 0x9470
leaq -0x58(%rbp), %rdi
callq 0x9470
leaq -0x78(%rbp), %rdi
callq 0x9470
movq -0x190(%rbp), %rdi
addq $0x200, %rdi            # imm = 0x200
movslq -0x14(%rbp), %rsi
callq 0x14140
movq -0x190(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x1a0(%rbp)
addq $0x210, %rdi            # imm = 0x210
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 $0x2, %edx
callq *%rax
movq -0x190(%rbp), %rax
movsd 0xe0(%rax), %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd 0xe8(%rax), %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd 0xf0(%rax), %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd 0xf8(%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 0x500d7(%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 0x1dfa2
movl $0x0, -0xdc(%rbp)
movl -0xdc(%rbp), %eax
cmpl -0xc4(%rbp), %eax
jge 0x1e243
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 $0x1f0, %rdi            # imm = 0x1F0
movslq -0x14(%rbp), %rsi
callq 0x14140
movq %rax, -0x1a8(%rbp)
jmp 0x1e006
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 $0x1, %edx
callq *%rax
jmp 0x1e037
movq -0x198(%rbp), %rsi
leaq -0x100(%rbp), %rdi
callq 0x20010
jmp 0x1e04c
movq -0x190(%rbp), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0x14(%rbp), %rsi
callq 0x14140
movq %rax, -0x1b8(%rbp)
jmp 0x1e06c
movq -0x1b8(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x1c0(%rbp)
leaq -0x110(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x21a90
jmp 0x1e094
leaq -0x120(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x21a90
jmp 0x1e0a9
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 0x1e0e0
movslq -0xdc(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
callq 0x14140
movq %rax, -0x1d0(%rbp)
jmp 0x1e0fc
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 0x1dfac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1e196
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1e18d
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 0x1e5bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1e5b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1e5a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1e232
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1e226
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1e21a
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 0x1e5a7
movl $0x0, -0x124(%rbp)
leaq -0xd8(%rbp), %rdi
leaq -0x124(%rbp), %rsi
callq 0x20260
jmp 0x1e262
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 $0x1e0, %rdi            # imm = 0x1E0
movslq -0x14(%rbp), %rsi
callq 0x14140
movq %rax, -0x1d8(%rbp)
jmp 0x1e2aa
movq -0x1d8(%rbp), %rax
movsd -0x1e0(%rbp), %xmm0
movsd %xmm0, (%rax)
leaq -0x138(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x20110
jmp 0x1e2d2
movl $0x0, -0x13c(%rbp)
movl -0x13c(%rbp), %eax
cmpl -0xc8(%rbp), %eax
jge 0x1e4fe
movq -0x190(%rbp), %rdi
addq $0x1e0, %rdi            # imm = 0x1E0
movslq -0x14(%rbp), %rsi
callq 0x14140
movq %rax, -0x1e8(%rbp)
jmp 0x1e30e
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 $0x1, %edx
callq *%rax
jmp 0x1e357
movq -0x198(%rbp), %rsi
leaq -0x160(%rbp), %rdi
callq 0x20010
jmp 0x1e36c
movq -0x190(%rbp), %rdi
addq $0x1d0, %rdi            # imm = 0x1D0
movslq -0x14(%rbp), %rsi
callq 0x14140
movq %rax, -0x1f0(%rbp)
jmp 0x1e38c
movq -0x1f0(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x1f8(%rbp)
leaq -0x170(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x21a90
jmp 0x1e3b4
leaq -0x180(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x21a90
jmp 0x1e3c9
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 0x1e400
movslq -0x13c(%rbp), %rsi
leaq -0x138(%rbp), %rdi
callq 0x14140
movq %rax, -0x208(%rbp)
jmp 0x1e41c
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 0x1e2dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1e59b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1e4ed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1e4e1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x1e4d5
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 0x1e59b
leaq -0x138(%rbp), %rdi
leaq -0x124(%rbp), %rsi
callq 0x20260
jmp 0x1e513
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 $0x1f0, %rdi            # imm = 0x1F0
movslq -0x14(%rbp), %rsi
callq 0x14140
movq %rax, -0x210(%rbp)
jmp 0x1e55b
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
nopl (%rax,%rax)