// File: /workspace/github_cpp_makefile_star2_O3/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 $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 0xcedb
movl $0x4, %r15d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r14d, %ecx
cmpl $0x63, %ecx
jbe 0xced2
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0xced8
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0xcedb
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r15d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0xce9f
addl $-0x3, %r15d
jmp 0xcedb
addl $-0x2, %r15d
jmp 0xcedb
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 0x109b6(%rip), %rcx     # 0x1d8d0
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 0xcf53
movq %rdx, 0x48(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x58(%rsp)
jmp 0xcf5c
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 0x108af(%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 0xcfb4
movq %rdx, 0x98(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xa8(%rsp)
jmp 0xcfbd
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 0xcffe
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x32a0
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0xd015
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x32a0
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xd031
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32a0
testl %ebp, %ebp
js 0xd49c
movslq %ebp, %r12
cmpq %r12, 0x208(%rbx)
jle 0xd49c
cmpq %r12, 0x218(%rbx)
jle 0xd49c
movq (%rbx), %rax
movq 0x200(%rbx), %rcx
movsd (%rcx,%r12,8), %xmm0
movq 0x210(%rbx), %rcx
movsd (%rcx,%r12,8), %xmm1
leaq 0x48(%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, 0x8(%rsp)
subsd %xmm2, %xmm0
movsd %xmm1, 0x20(%rsp)
divsd %xmm1, %xmm0
movsd 0x10339(%rip), %xmm1    # 0x1d3f0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %r14d
testl %r14d, %r14d
js 0xd4bb
movsd 0xf0(%rbx), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0xf8(%rbx), %xmm0
xorpd %xmm2, %xmm2
testq %r14, %r14
je 0xd23e
movsd %xmm0, 0x68(%rsp)
leaq (,%r14,8), %rdi
callq 0x3360
cmpl $0x1, %r14d
je 0xd110
movl %eax, %ecx
andl $0xf, %ecx
jne 0xd4da
movq %rax, (%rsp)
testq %rax, %rax
je 0xd4f9
xorl %r13d, %r13d
leaq 0xe8(%rsp), %rbp
leaq 0xd8(%rsp), %r15
cmpq %r12, 0x1f8(%rbx)
jle 0xd49c
movq (%rbx), %rax
xorps %xmm0, %xmm0
cvtsi2sd %r13d, %xmm0
movq 0x1f0(%rbx), %rcx
mulsd 0x20(%rsp), %xmm0
addsd 0x8(%rsp), %xmm0
movsd (%rcx,%r12,8), %xmm1
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq *0x20(%rax)
leaq 0x88(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0xfc92
cmpq %r12, 0x1d8(%rbx)
jle 0xd49c
movq 0x1d0(%rbx), %rax
movsd (%rax,%r12,8), %xmm0
movsd %xmm0, 0x18(%rsp)
movq %rbp, %rdi
leaq 0x28(%rsp), %rsi
callq 0x1b5d6
movq %r15, %rdi
leaq 0x48(%rsp), %rsi
callq 0x1b5d6
movq %rbx, %rdi
leaq 0x88(%rsp), %rsi
movsd 0x18(%rsp), %xmm0
movq %rbp, %rdx
movq %r15, %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, %r14
jne 0xd130
cmpl $0x1, %r14d
jne 0xd243
movq (%rsp), %r15
movsd 0x101be(%rip), %xmm1    # 0x1d3f0
movsd 0x68(%rsp), %xmm0
xorpd %xmm2, %xmm2
jmp 0xd283
xorl %r15d, %r15d
jmp 0xd283
movq (%rsp), %r15
movsd (%r15), %xmm0
movl $0x1, %ecx
xorl %eax, %eax
movsd (%r15,%rcx,8), %xmm1
ucomisd %xmm0, %xmm1
cmovaq %rcx, %rax
maxsd %xmm0, %xmm1
incq %rcx
movapd %xmm1, %xmm0
cmpq %rcx, %r14
jne 0xd253
cvtsi2sd %eax, %xmm2
movsd 0x10173(%rip), %xmm1    # 0x1d3f0
movsd 0x68(%rsp), %xmm0
cmpq %r12, 0x1e8(%rbx)
jle 0xd49c
subsd 0x10(%rsp), %xmm0
divsd 0x20(%rsp), %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %r13d
mulsd 0x128(%rbx), %xmm2
movq 0x1e0(%rbx), %rax
addsd 0x8(%rsp), %xmm2
movsd %xmm2, (%rax,%r12,8)
testl %r13d, %r13d
js 0xd4bb
xorpd %xmm0, %xmm0
testq %r13, %r13
je 0xd413
leaq (,%r13,8), %rdi
callq 0x3360
cmpl $0x1, %r13d
je 0xd2f4
movl %eax, %ecx
andl $0xf, %ecx
jne 0xd4da
movq %r15, (%rsp)
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0xd527
xorl %ebp, %ebp
leaq 0xc8(%rsp), %r15
leaq 0xb8(%rsp), %r14
cmpq %r12, 0x1e8(%rbx)
jle 0xd49c
movq (%rbx), %rax
movq 0x1e0(%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 $0x1, %edx
callq *0x20(%rax)
leaq 0x78(%rsp), %rdi
movq 0x70(%rsp), %rsi
callq 0xfc92
cmpq %r12, 0x1d8(%rbx)
jle 0xd49c
movq 0x1d0(%rbx), %rax
movsd (%rax,%r12,8), %xmm0
movsd %xmm0, 0x18(%rsp)
movq %r15, %rdi
leaq 0x28(%rsp), %rsi
callq 0x1b5d6
movq %r14, %rdi
leaq 0x48(%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 0xd318
cmpl $0x1, %r13d
jne 0xd417
movq (%rsp), %r15
movq 0x8(%rsp), %rdi
xorpd %xmm0, %xmm0
jmp 0xd44f
xorl %edi, %edi
jmp 0xd44f
movq 0x8(%rsp), %rdi
movsd (%rdi), %xmm0
movl $0x1, %ecx
xorl %eax, %eax
movq (%rsp), %r15
movsd (%rdi,%rcx,8), %xmm1
ucomisd %xmm0, %xmm1
cmovaq %rcx, %rax
maxsd %xmm0, %xmm1
incq %rcx
movapd %xmm1, %xmm0
cmpq %rcx, %r13
jne 0xd42b
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
cmpq %r12, 0x1f8(%rbx)
jle 0xd49c
movq 0x1f0(%rbx), %rax
mulsd 0x128(%rbx), %xmm0
addsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax,%r12,8)
callq 0x3310
movq %r15, %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 0xfe13(%rip), %rdi      # 0x1d2b6
leaq 0xf592(%rip), %rsi      # 0x1ca3c
leaq 0xfea3(%rip), %rcx      # 0x1d354
movl $0x1a9, %edx            # imm = 0x1A9
callq 0x31b0
leaq 0x1100d(%rip), %rdi     # 0x1e4cf
leaq 0xf378(%rip), %rsi      # 0x1c841
leaq 0x11089(%rip), %rcx     # 0x1e559
movl $0x138, %edx            # imm = 0x138
callq 0x31b0
leaq 0xf41a(%rip), %rdi      # 0x1c8fb
leaq 0xf4cd(%rip), %rsi      # 0x1c9b5
leaq 0xf4e5(%rip), %rcx      # 0x1c9d4
movl $0xa1, %edx
callq 0x31b0
movl $0x8, %edi
callq 0x3130
movq 0x21ab6(%rip), %rcx     # 0x2efc0
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x21ab8(%rip), %rsi     # 0x2efd0
movq 0x21a89(%rip), %rdx     # 0x2efa8
movq %rax, %rdi
callq 0x3430
movl $0x8, %edi
callq 0x3130
movq 0x21a88(%rip), %rcx     # 0x2efc0
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x21a8a(%rip), %rsi     # 0x2efd0
movq 0x21a5b(%rip), %rdx     # 0x2efa8
movq %rax, %rdi
callq 0x3430
jmp 0xd614
movq %rax, %rbx
jmp 0xd665
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0xd587
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x32a0
jmp 0xd587
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0xd5a3
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x32a0
jmp 0xd5a3
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xd66f
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x32a0
jmp 0xd66f
movq %rax, %rbx
jmp 0xd60d
movq %rax, %rbx
jmp 0xd603
movq %rax, %rbx
jmp 0xd5f9
movq %rax, %rbx
jmp 0xd5ec
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 0xd657
movq %rax, %rbx
jmp 0xd65c
movq %rax, %rbx
jmp 0xd652
movq %rax, %rbx
jmp 0xd645
movq %rax, %rbx
jmp 0xd638
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