// File: /workspace/github_cpp_makefile_star2_O3/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 $0xf8, %rsp
movl %edx, %ebp
movq %rsi, 0x70(%rsp)
movq %rdi, %rbx
movl %edx, %r14d
negl %r14d
cmovsl %edx, %r14d
movl $0x1, %r15d
cmpl $0xa, %r14d
jb 0xc6c3
movl $0x4, %r15d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r14d, %ecx
cmpl $0x63, %ecx
jbe 0xc6ba
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xc6c0
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xc6c3
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r15d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xc687
addl $-0x3, %r15d
jmp 0xc6c3
addl $-0x2, %r15d
jmp 0xc6c3
decl %r15d
movl %ebp, %r12d
shrl $0x1f, %r12d
leal (%r15,%r12), %esi
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x28(%rsp), %r13
movq %r13, %rdi
movl $0x2d, %edx
callq 0x32f0
addq (%r13), %r12
movq %r12, %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0xf9e9
leaq 0x111b9(%rip), %rcx     # 0x1d8bb
movl $0x14, %r8d
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x32b0
leaq 0x58(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xc73b
movq %rdx, 0x48(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x58(%rsp)
jmp 0xc744
movupd (%rcx), %xmm0
movupd %xmm0, (%r14)
movq 0x8(%rax), %rdx
leaq 0x48(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x110c7(%rip), %rsi     # 0x1d82e
callq 0x34a0
leaq 0xa8(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xc79c
movq %rdx, 0x98(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xa8(%rsp)
jmp 0xc7a5
movupd (%rcx), %xmm0
movupd %xmm0, (%r15)
movq 0x8(%rax), %rdx
leaq 0x98(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
callq 0x60be
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0xc7e6
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x32a0
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0xc7fd
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x32a0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xc819
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32a0
testl %ebp, %ebp
js 0xcc84
movslq %ebp, %r12
cmpq %r12, 0x1e8(%rbx)
jle 0xcc84
cmpq %r12, 0x1f8(%rbx)
jle 0xcc84
movq (%rbx), %rax
movq 0x1e0(%rbx), %rcx
movsd (%rcx,%r12,8), %xmm0
movq 0x1f0(%rbx), %rcx
movsd (%rcx,%r12,8), %xmm1
leaq 0x48(%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, 0x8(%rsp)
subsd %xmm2, %xmm0
movsd %xmm1, 0x20(%rsp)
divsd %xmm1, %xmm0
movsd 0x10b51(%rip), %xmm1    # 0x1d3f0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %r15d
testl %r15d, %r15d
js 0xcca3
movsd 0x110(%rbx), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x118(%rbx), %xmm0
xorpd %xmm2, %xmm2
testq %r15, %r15
je 0xca26
movsd %xmm0, 0x68(%rsp)
leaq (,%r15,8), %rdi
callq 0x3360
cmpl $0x1, %r15d
je 0xc8f8
movl %eax, %ecx
andl $0xf, %ecx
jne 0xccc2
movq %rax, (%rsp)
testq %rax, %rax
je 0xcce1
xorl %r13d, %r13d
leaq 0xe8(%rsp), %rbp
leaq 0xd8(%rsp), %r14
cmpq %r12, 0x218(%rbx)
jle 0xcc84
movq 0x210(%rbx), %rax
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
mulsd 0x20(%rsp), %xmm0
addsd 0x8(%rsp), %xmm0
movsd (%rax,%r12,8), %xmm1
movq (%rbx), %rax
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
movl $0x2, %edx
callq *0x20(%rax)
leaq 0x88(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0xfc92
cmpq %r12, 0x1d8(%rbx)
jle 0xcc84
movq 0x1d0(%rbx), %rax
movsd (%rax,%r12,8), %xmm0
movsd %xmm0, 0x18(%rsp)
movq %rbp, %rdi
leaq 0x48(%rsp), %rsi
callq 0x1b5d6
movq %r14, %rdi
leaq 0x28(%rsp), %rsi
callq 0x1b5d6
movq %rbx, %rdi
leaq 0x88(%rsp), %rsi
movsd 0x18(%rsp), %xmm0
movq %rbp, %rdx
movq %r14, %rcx
callq 0xdc46
movq (%rsp), %rax
movsd %xmm0, (%rax,%r13,8)
movq 0xd8(%rsp), %rdi
callq 0x3310
movq 0xe8(%rsp), %rdi
callq 0x3310
movq 0x88(%rsp), %rdi
callq 0x3310
movq 0x28(%rsp), %rdi
callq 0x3310
incq %r13
cmpq %r13, %r15
jne 0xc918
cmpl $0x1, %r15d
jne 0xca2b
movq (%rsp), %r14
movsd 0x109d6(%rip), %xmm1    # 0x1d3f0
movsd 0x68(%rsp), %xmm0
xorpd %xmm2, %xmm2
jmp 0xca6b
xorl %r14d, %r14d
jmp 0xca6b
movq (%rsp), %r14
movsd (%r14), %xmm0
movl $0x1, %ecx
xorl %eax, %eax
movsd (%r14,%rcx,8), %xmm1
ucomisd %xmm0, %xmm1
cmovaq %rcx, %rax
maxsd %xmm0, %xmm1
incq %rcx
movapd %xmm1, %xmm0
cmpq %rcx, %r15
jne 0xca3b
cvtsi2sd %eax, %xmm2
movsd 0x1098b(%rip), %xmm1    # 0x1d3f0
movsd 0x68(%rsp), %xmm0
cmpq %r12, 0x208(%rbx)
jle 0xcc84
subsd 0x10(%rsp), %xmm0
divsd 0x20(%rsp), %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %r13d
mulsd 0x128(%rbx), %xmm2
movq 0x200(%rbx), %rax
addsd 0x8(%rsp), %xmm2
movsd %xmm2, (%rax,%r12,8)
testl %r13d, %r13d
js 0xcca3
xorpd %xmm0, %xmm0
testq %r13, %r13
je 0xcbfb
leaq (,%r13,8), %rdi
callq 0x3360
cmpl $0x1, %r13d
je 0xcadc
movl %eax, %ecx
andl $0xf, %ecx
jne 0xccc2
movq %r14, (%rsp)
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0xcd0f
xorl %ebp, %ebp
leaq 0xc8(%rsp), %r15
leaq 0xb8(%rsp), %r14
cmpq %r12, 0x208(%rbx)
jle 0xcc84
movq (%rbx), %rax
movq 0x200(%rbx), %rcx
movsd (%rcx,%r12,8), %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
mulsd 0x20(%rsp), %xmm1
addsd 0x10(%rsp), %xmm1
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
movl $0x2, %edx
callq *0x20(%rax)
leaq 0x78(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0xfc92
cmpq %r12, 0x1d8(%rbx)
jle 0xcc84
movq 0x1d0(%rbx), %rax
movsd (%rax,%r12,8), %xmm0
movsd %xmm0, 0x18(%rsp)
movq %r15, %rdi
leaq 0x48(%rsp), %rsi
callq 0x1b5d6
movq %r14, %rdi
leaq 0x28(%rsp), %rsi
callq 0x1b5d6
movq %rbx, %rdi
leaq 0x78(%rsp), %rsi
movsd 0x18(%rsp), %xmm0
movq %r15, %rdx
movq %r14, %rcx
callq 0xdc46
movq 0x8(%rsp), %rax
movsd %xmm0, (%rax,%rbp,8)
movq 0xb8(%rsp), %rdi
callq 0x3310
movq 0xc8(%rsp), %rdi
callq 0x3310
movq 0x78(%rsp), %rdi
callq 0x3310
movq 0x28(%rsp), %rdi
callq 0x3310
incq %rbp
cmpq %rbp, %r13
jne 0xcb00
cmpl $0x1, %r13d
jne 0xcbff
movq (%rsp), %r14
movq 0x8(%rsp), %rdi
xorpd %xmm0, %xmm0
jmp 0xcc37
xorl %edi, %edi
jmp 0xcc37
movq 0x8(%rsp), %rdi
movsd (%rdi), %xmm0
movl $0x1, %ecx
xorl %eax, %eax
movq (%rsp), %r14
movsd (%rdi,%rcx,8), %xmm1
ucomisd %xmm0, %xmm1
cmovaq %rcx, %rax
maxsd %xmm0, %xmm1
incq %rcx
movapd %xmm1, %xmm0
cmpq %rcx, %r13
jne 0xcc13
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
cmpq %r12, 0x218(%rbx)
jle 0xcc84
movq 0x210(%rbx), %rax
mulsd 0x128(%rbx), %xmm0
addsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax,%r12,8)
callq 0x3310
movq %r14, %rdi
callq 0x3310
movq 0x48(%rsp), %rdi
callq 0x3310
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1062b(%rip), %rdi     # 0x1d2b6
leaq 0xfdaa(%rip), %rsi      # 0x1ca3c
leaq 0x106bb(%rip), %rcx     # 0x1d354
movl $0x1a9, %edx            # imm = 0x1A9
callq 0x31b0
leaq 0x11825(%rip), %rdi     # 0x1e4cf
leaq 0xfb90(%rip), %rsi      # 0x1c841
leaq 0x118a1(%rip), %rcx     # 0x1e559
movl $0x138, %edx            # imm = 0x138
callq 0x31b0
leaq 0xfc32(%rip), %rdi      # 0x1c8fb
leaq 0xfce5(%rip), %rsi      # 0x1c9b5
leaq 0xfcfd(%rip), %rcx      # 0x1c9d4
movl $0xa1, %edx
callq 0x31b0
movl $0x8, %edi
callq 0x3130
movq 0x222ce(%rip), %rcx     # 0x2efc0
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x222d0(%rip), %rsi     # 0x2efd0
movq 0x222a1(%rip), %rdx     # 0x2efa8
movq %rax, %rdi
callq 0x3430
movl $0x8, %edi
callq 0x3130
movq 0x222a0(%rip), %rcx     # 0x2efc0
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x222a2(%rip), %rsi     # 0x2efd0
movq 0x22273(%rip), %rdx     # 0x2efa8
movq %rax, %rdi
callq 0x3430
jmp 0xcdfc
movq %rax, %rbx
jmp 0xce4d
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0xcd6f
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x32a0
jmp 0xcd6f
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0xcd8b
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x32a0
jmp 0xcd8b
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xce57
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32a0
jmp 0xce57
movq %rax, %rbx
jmp 0xcdf5
movq %rax, %rbx
jmp 0xcdeb
movq %rax, %rbx
jmp 0xcde1
movq %rax, %rbx
jmp 0xcdd4
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
callq 0x3310
movq 0xc8(%rsp), %rdi
callq 0x3310
movq 0x78(%rsp), %rdi
callq 0x3310
movq 0x28(%rsp), %rdi
callq 0x3310
movq 0x8(%rsp), %rdi
jmp 0xce3f
movq %rax, %rbx
jmp 0xce44
movq %rax, %rbx
jmp 0xce3a
movq %rax, %rbx
jmp 0xce2d
movq %rax, %rbx
jmp 0xce20
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
callq 0x3310
movq 0xe8(%rsp), %rdi
callq 0x3310
movq 0x88(%rsp), %rdi
callq 0x3310
movq 0x28(%rsp), %rdi
callq 0x3310
movq (%rsp), %rdi
callq 0x3310
movq 0x48(%rsp), %rdi
callq 0x3310
movq %rbx, %rdi
callq 0x3450
nop