// File: /workspace/github_cpp_makefile_star2_O1/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 $0x108, %rsp            # imm = 0x108
movl %edx, %ebp
movq %rsi, 0x78(%rsp)
movq %rdi, %rbx
movl %edx, %r14d
negl %r14d
cmovsl %edx, %r14d
movl $0x1, %r15d
cmpl $0xa, %r14d
jb 0xc641
movl $0x4, %r15d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r14d, %ecx
cmpl $0x63, %ecx
jbe 0xc638
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xc63e
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xc641
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r15d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xc605
addl $-0x3, %r15d
jmp 0xc641
addl $-0x2, %r15d
jmp 0xc641
decl %r15d
movl %ebp, %r12d
shrl $0x1f, %r12d
leal (%r15,%r12), %esi
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x38(%rsp), %r13
movq %r13, %rdi
movl $0x2d, %edx
callq 0x3300
addq (%r13), %r12
movq %r12, %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0xf91b
leaq 0x111ab(%rip), %rcx     # 0x1d82b
movl $0x14, %r8d
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x32c0
leaq 0x68(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xc6b9
movq %rdx, 0x58(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x68(%rsp)
jmp 0xc6c2
movupd (%rcx), %xmm0
movupd %xmm0, (%r14)
movq 0x8(%rax), %rdx
leaq 0x58(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x110b9(%rip), %rsi     # 0x1d79e
callq 0x34b0
leaq 0xb8(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xc71a
movq %rdx, 0xa8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xb8(%rsp)
jmp 0xc723
movupd (%rcx), %xmm0
movupd %xmm0, (%r15)
movq 0x8(%rax), %rdx
leaq 0xa8(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
callq 0x60e8
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0xc764
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x32b0
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0xc77b
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x32b0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0xc797
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x32b0
testl %ebp, %ebp
js 0xcc82
movslq %ebp, %r12
cmpq %r12, 0x1e8(%rbx)
jle 0xcc82
cmpq %r12, 0x1f8(%rbx)
jle 0xcc82
movq (%rbx), %rax
movq 0x1e0(%rbx), %rcx
movsd (%rcx,%r12,8), %xmm0
movq 0x1f0(%rbx), %rcx
movsd (%rcx,%r12,8), %xmm1
leaq 0x58(%rsp), %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq *0x20(%rax)
movsd 0x100(%rbx), %xmm2
movsd 0x108(%rbx), %xmm0
movsd 0x128(%rbx), %xmm1
movsd %xmm2, 0x10(%rsp)
subsd %xmm2, %xmm0
movsd %xmm1, 0x30(%rsp)
divsd %xmm1, %xmm0
addsd 0x10bb3(%rip), %xmm0    # 0x1d3d0
cvttsd2si %xmm0, %ebp
testl %ebp, %ebp
js 0xcca1
movsd 0x110(%rbx), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0x118(%rbx), %xmm0
movsd %xmm0, 0x18(%rsp)
movl %ebp, %r14d
movq %r14, 0x80(%rsp)
je 0xc8a7
leaq (,%r14,8), %rdi
callq 0x3370
cmpl $0x1, %ebp
je 0xc86f
movl %eax, %ecx
andl $0xf, %ecx
jne 0xccc0
movq %rax, 0x8(%rsp)
testq %rax, %rax
jne 0xc8b0
movl $0x8, %edi
callq 0x3130
movq 0x22736(%rip), %rcx     # 0x2efc0
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x22738(%rip), %rsi     # 0x2efd0
movq 0x22709(%rip), %rdx     # 0x2efa8
movq %rax, %rdi
callq 0x3440
movq $0x0, 0x8(%rsp)
movl %ebp, 0x4(%rsp)
testl %ebp, %ebp
je 0xc9d1
movl 0x4(%rsp), %eax
cmpl $0x2, %eax
movl $0x1, %r14d
cmovgel %eax, %r14d
xorl %r13d, %r13d
leaq 0xf8(%rsp), %rbp
leaq 0xe8(%rsp), %r15
cmpq %r12, 0x218(%rbx)
jle 0xcc82
movq 0x210(%rbx), %rax
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
mulsd 0x30(%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
movsd (%rax,%r12,8), %xmm1
movq (%rbx), %rax
leaq 0x38(%rsp), %rdi
movq %rbx, %rsi
movl $0x2, %edx
callq *0x20(%rax)
leaq 0x98(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0xfbc4
cmpq %r12, 0x1d8(%rbx)
jle 0xcc82
movq 0x1d0(%rbx), %rax
movsd (%rax,%r12,8), %xmm0
movsd %xmm0, 0x28(%rsp)
movq %rbp, %rdi
leaq 0x58(%rsp), %rsi
callq 0x1bd16
movq %r15, %rdi
leaq 0x38(%rsp), %rsi
callq 0x1bd16
movq %rbx, %rdi
leaq 0x98(%rsp), %rsi
movsd 0x28(%rsp), %xmm0
movq %rbp, %rdx
movq %r15, %rcx
callq 0xdc1a
movq 0x8(%rsp), %rax
movsd %xmm0, (%rax,%r13,8)
movq 0xe8(%rsp), %rdi
callq 0x3320
movq 0xf8(%rsp), %rdi
callq 0x3320
movq 0x98(%rsp), %rdi
callq 0x3320
movq 0x38(%rsp), %rdi
callq 0x3320
incq %r13
cmpq %r13, %r14
jne 0xc8e0
xorpd %xmm0, %xmm0
cmpl $0x2, 0x4(%rsp)
movq 0x8(%rsp), %rdx
jb 0xca18
movsd (%rdx), %xmm0
movl $0x1, %ecx
xorl %eax, %eax
movq 0x80(%rsp), %rsi
movsd (%rdx,%rcx,8), %xmm1
ucomisd %xmm0, %xmm1
cmovaq %rcx, %rax
maxsd %xmm0, %xmm1
incq %rcx
movapd %xmm1, %xmm0
cmpq %rcx, %rsi
jne 0xc9f4
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
cmpq %r12, 0x208(%rbx)
jle 0xcc82
movsd 0x18(%rsp), %xmm1
subsd 0x20(%rsp), %xmm1
divsd 0x30(%rsp), %xmm1
addsd 0x10991(%rip), %xmm1    # 0x1d3d0
cvttsd2si %xmm1, %ebp
mulsd 0x128(%rbx), %xmm0
movq 0x200(%rbx), %rax
addsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax,%r12,8)
testl %ebp, %ebp
js 0xcca1
movl %ebp, %r14d
movq %r14, 0x18(%rsp)
je 0xcac5
leaq (,%r14,8), %rdi
callq 0x3370
cmpl $0x1, %ebp
je 0xca8d
movl %eax, %ecx
andl $0xf, %ecx
jne 0xccc0
movq %rax, 0x10(%rsp)
testq %rax, %rax
jne 0xcace
movl $0x8, %edi
callq 0x3130
movq 0x22518(%rip), %rcx     # 0x2efc0
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x2251a(%rip), %rsi     # 0x2efd0
movq 0x224eb(%rip), %rdx     # 0x2efa8
movq %rax, %rdi
callq 0x3440
movq $0x0, 0x10(%rsp)
movl %ebp, 0x4(%rsp)
testl %ebp, %ebp
je 0xcbec
movl 0x4(%rsp), %eax
cmpl $0x2, %eax
movl $0x1, %r13d
cmovgel %eax, %r13d
xorl %ebp, %ebp
leaq 0xd8(%rsp), %r14
leaq 0xc8(%rsp), %r15
cmpq %r12, 0x208(%rbx)
jle 0xcc82
movq (%rbx), %rax
movq 0x200(%rbx), %rcx
movsd (%rcx,%r12,8), %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
mulsd 0x30(%rsp), %xmm1
addsd 0x20(%rsp), %xmm1
leaq 0x38(%rsp), %rdi
movq %rbx, %rsi
movl $0x2, %edx
callq *0x20(%rax)
leaq 0x88(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0xfbc4
cmpq %r12, 0x1d8(%rbx)
jle 0xcc82
movq 0x1d0(%rbx), %rax
movsd (%rax,%r12,8), %xmm0
movsd %xmm0, 0x28(%rsp)
movq %r14, %rdi
leaq 0x58(%rsp), %rsi
callq 0x1bd16
movq %r15, %rdi
leaq 0x38(%rsp), %rsi
callq 0x1bd16
movq %rbx, %rdi
leaq 0x88(%rsp), %rsi
movsd 0x28(%rsp), %xmm0
movq %r14, %rdx
movq %r15, %rcx
callq 0xdc1a
movq 0x10(%rsp), %rax
movsd %xmm0, (%rax,%rbp,8)
movq 0xc8(%rsp), %rdi
callq 0x3320
movq 0xd8(%rsp), %rdi
callq 0x3320
movq 0x88(%rsp), %rdi
callq 0x3320
movq 0x38(%rsp), %rdi
callq 0x3320
incq %rbp
cmpq %rbp, %r13
jne 0xcafd
xorpd %xmm0, %xmm0
cmpl $0x2, 0x4(%rsp)
movq 0x8(%rsp), %r14
movq 0x10(%rsp), %rdi
jb 0xcc35
movsd (%rdi), %xmm0
movl $0x1, %ecx
xorl %eax, %eax
movq 0x18(%rsp), %rdx
movsd (%rdi,%rcx,8), %xmm1
ucomisd %xmm0, %xmm1
cmovaq %rcx, %rax
maxsd %xmm0, %xmm1
incq %rcx
movapd %xmm1, %xmm0
cmpq %rcx, %rdx
jne 0xcc11
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
cmpq %r12, 0x218(%rbx)
jle 0xcc82
movq 0x210(%rbx), %rax
mulsd 0x128(%rbx), %xmm0
addsd 0x20(%rsp), %xmm0
movsd %xmm0, (%rax,%r12,8)
callq 0x3320
movq %r14, %rdi
callq 0x3320
movq 0x58(%rsp), %rdi
callq 0x3320
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1060d(%rip), %rdi     # 0x1d296
leaq 0xfd8c(%rip), %rsi      # 0x1ca1c
leaq 0x1069d(%rip), %rcx     # 0x1d334
movl $0x1a9, %edx            # imm = 0x1A9
callq 0x31b0
leaq 0x11797(%rip), %rdi     # 0x1e43f
leaq 0xfb72(%rip), %rsi      # 0x1c821
leaq 0x11813(%rip), %rcx     # 0x1e4c9
movl $0x138, %edx            # imm = 0x138
callq 0x31b0
leaq 0xfc14(%rip), %rdi      # 0x1c8db
leaq 0xfcc7(%rip), %rsi      # 0x1c995
leaq 0xfcdf(%rip), %rcx      # 0x1c9b4
movl $0xa1, %edx
callq 0x31b0
jmp 0xcda1
movq %rax, %rbx
jmp 0xcdf3
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0xcd11
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x32b0
jmp 0xcd11
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0xcd2d
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x32b0
jmp 0xcd2d
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0xcdfd
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x32b0
jmp 0xcdfd
movq %rax, %rbx
jmp 0xcd9a
movq %rax, %rbx
jmp 0xcd90
movq %rax, %rbx
jmp 0xcd83
movq %rax, %rbx
jmp 0xcd76
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
callq 0x3320
movq 0xd8(%rsp), %rdi
callq 0x3320
movq 0x88(%rsp), %rdi
callq 0x3320
movq 0x38(%rsp), %rdi
callq 0x3320
movq 0x10(%rsp), %rdi
jmp 0xcde4
movq %rax, %rbx
jmp 0xcde9
movq %rax, %rbx
jmp 0xcddf
movq %rax, %rbx
jmp 0xcdd2
movq %rax, %rbx
jmp 0xcdc5
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
callq 0x3320
movq 0xf8(%rsp), %rdi
callq 0x3320
movq 0x98(%rsp), %rdi
callq 0x3320
movq 0x38(%rsp), %rdi
callq 0x3320
movq 0x8(%rsp), %rdi
callq 0x3320
movq 0x58(%rsp), %rdi
callq 0x3320
movq %rbx, %rdi
callq 0x3460
nop