// File: /workspace/github_cpp_makefile_star2_O1/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
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 0xce81
movl $0x4, %r15d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r14d, %ecx
cmpl $0x63, %ecx
jbe 0xce78
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xce7e
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xce81
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r15d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xce45
addl $-0x3, %r15d
jmp 0xce81
addl $-0x2, %r15d
jmp 0xce81
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 0x10980(%rip), %rcx     # 0x1d840
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 0xcef9
movq %rdx, 0x58(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x68(%rsp)
jmp 0xcf02
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 0x10879(%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 0xcf5a
movq %rdx, 0xa8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xb8(%rsp)
jmp 0xcf63
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 0xcfa4
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x32b0
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0xcfbb
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x32b0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0xcfd7
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x32b0
testl %ebp, %ebp
js 0xd4c2
movslq %ebp, %r12
cmpq %r12, 0x208(%rbx)
jle 0xd4c2
cmpq %r12, 0x218(%rbx)
jle 0xd4c2
movq (%rbx), %rax
movq 0x200(%rbx), %rcx
movsd (%rcx,%r12,8), %xmm0
movq 0x210(%rbx), %rcx
movsd (%rcx,%r12,8), %xmm1
leaq 0x58(%rsp), %rdi
movq %rbx, %rsi
movl $0x2, %edx
callq *0x20(%rax)
movsd 0xe0(%rbx), %xmm2
movsd 0xe8(%rbx), %xmm0
movsd 0x128(%rbx), %xmm1
movsd %xmm2, 0x10(%rsp)
subsd %xmm2, %xmm0
movsd %xmm1, 0x30(%rsp)
divsd %xmm1, %xmm0
addsd 0x10373(%rip), %xmm0    # 0x1d3d0
cvttsd2si %xmm0, %ebp
testl %ebp, %ebp
js 0xd4e1
movsd 0xf0(%rbx), %xmm0
movsd %xmm0, 0x20(%rsp)
movsd 0xf8(%rbx), %xmm0
movsd %xmm0, 0x18(%rsp)
movl %ebp, %r14d
movq %r14, 0x80(%rsp)
je 0xd0e7
leaq (,%r14,8), %rdi
callq 0x3370
cmpl $0x1, %ebp
je 0xd0af
movl %eax, %ecx
andl $0xf, %ecx
jne 0xd500
movq %rax, 0x8(%rsp)
testq %rax, %rax
jne 0xd0f0
movl $0x8, %edi
callq 0x3130
movq 0x21ef6(%rip), %rcx     # 0x2efc0
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x21ef8(%rip), %rsi     # 0x2efd0
movq 0x21ec9(%rip), %rdx     # 0x2efa8
movq %rax, %rdi
callq 0x3440
movq $0x0, 0x8(%rsp)
movl %ebp, 0x4(%rsp)
testl %ebp, %ebp
je 0xd211
movl 0x4(%rsp), %eax
cmpl $0x2, %eax
movl $0x1, %r15d
cmovgel %eax, %r15d
xorl %r13d, %r13d
leaq 0xf8(%rsp), %rbp
leaq 0xe8(%rsp), %r14
cmpq %r12, 0x1f8(%rbx)
jle 0xd4c2
movq (%rbx), %rax
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
movq 0x1f0(%rbx), %rcx
mulsd 0x30(%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
movsd (%rcx,%r12,8), %xmm1
leaq 0x38(%rsp), %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq *0x20(%rax)
leaq 0x98(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0xfbc4
cmpq %r12, 0x1d8(%rbx)
jle 0xd4c2
movq 0x1d0(%rbx), %rax
movsd (%rax,%r12,8), %xmm0
movsd %xmm0, 0x28(%rsp)
movq %rbp, %rdi
leaq 0x38(%rsp), %rsi
callq 0x1bd16
movq %r14, %rdi
leaq 0x58(%rsp), %rsi
callq 0x1bd16
movq %rbx, %rdi
leaq 0x98(%rsp), %rsi
movsd 0x28(%rsp), %xmm0
movq %rbp, %rdx
movq %r14, %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, %r15
jne 0xd120
xorpd %xmm0, %xmm0
cmpl $0x2, 0x4(%rsp)
movq 0x8(%rsp), %rdx
jb 0xd258
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 0xd234
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
cmpq %r12, 0x1e8(%rbx)
jle 0xd4c2
movsd 0x18(%rsp), %xmm1
subsd 0x20(%rsp), %xmm1
divsd 0x30(%rsp), %xmm1
addsd 0x10151(%rip), %xmm1    # 0x1d3d0
cvttsd2si %xmm1, %ebp
mulsd 0x128(%rbx), %xmm0
movq 0x1e0(%rbx), %rax
addsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax,%r12,8)
testl %ebp, %ebp
js 0xd4e1
movl %ebp, %r14d
movq %r14, 0x18(%rsp)
je 0xd305
leaq (,%r14,8), %rdi
callq 0x3370
cmpl $0x1, %ebp
je 0xd2cd
movl %eax, %ecx
andl $0xf, %ecx
jne 0xd500
movq %rax, 0x10(%rsp)
testq %rax, %rax
jne 0xd30e
movl $0x8, %edi
callq 0x3130
movq 0x21cd8(%rip), %rcx     # 0x2efc0
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x21cda(%rip), %rsi     # 0x2efd0
movq 0x21cab(%rip), %rdx     # 0x2efa8
movq %rax, %rdi
callq 0x3440
movq $0x0, 0x10(%rsp)
movl %ebp, 0x4(%rsp)
testl %ebp, %ebp
je 0xd42c
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, 0x1e8(%rbx)
jle 0xd4c2
movq (%rbx), %rax
movq 0x1e0(%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 $0x1, %edx
callq *0x20(%rax)
leaq 0x88(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0xfbc4
cmpq %r12, 0x1d8(%rbx)
jle 0xd4c2
movq 0x1d0(%rbx), %rax
movsd (%rax,%r12,8), %xmm0
movsd %xmm0, 0x28(%rsp)
movq %r14, %rdi
leaq 0x38(%rsp), %rsi
callq 0x1bd16
movq %r15, %rdi
leaq 0x58(%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 0xd33d
xorpd %xmm0, %xmm0
cmpl $0x2, 0x4(%rsp)
movq 0x8(%rsp), %r14
movq 0x10(%rsp), %rdi
jb 0xd475
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 0xd451
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
cmpq %r12, 0x1f8(%rbx)
jle 0xd4c2
movq 0x1f0(%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 0xfdcd(%rip), %rdi      # 0x1d296
leaq 0xf54c(%rip), %rsi      # 0x1ca1c
leaq 0xfe5d(%rip), %rcx      # 0x1d334
movl $0x1a9, %edx            # imm = 0x1A9
callq 0x31b0
leaq 0x10f57(%rip), %rdi     # 0x1e43f
leaq 0xf332(%rip), %rsi      # 0x1c821
leaq 0x10fd3(%rip), %rcx     # 0x1e4c9
movl $0x138, %edx            # imm = 0x138
callq 0x31b0
leaq 0xf3d4(%rip), %rdi      # 0x1c8db
leaq 0xf487(%rip), %rsi      # 0x1c995
leaq 0xf49f(%rip), %rcx      # 0x1c9b4
movl $0xa1, %edx
callq 0x31b0
jmp 0xd5e1
movq %rax, %rbx
jmp 0xd633
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0xd551
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x32b0
jmp 0xd551
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0xd56d
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x32b0
jmp 0xd56d
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0xd63d
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x32b0
jmp 0xd63d
movq %rax, %rbx
jmp 0xd5da
movq %rax, %rbx
jmp 0xd5d0
movq %rax, %rbx
jmp 0xd5c3
movq %rax, %rbx
jmp 0xd5b6
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 0xd624
movq %rax, %rbx
jmp 0xd629
movq %rax, %rbx
jmp 0xd61f
movq %rax, %rbx
jmp 0xd612
movq %rax, %rbx
jmp 0xd605
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