// File: /workspace/github_cpp_makefile_star2_O2/Pyboon[P]sage/isi_sage.cpp
// Function: IsiSage::ObjectiveFunction(Eigen::Matrix<std::complex<double>, 1, -1, 1, 1, -1>, double, Eigen::Matrix<std::complex<double>, -1, 2, 0, -1, 2>, Eigen::Matrix<std::complex<double>, -1, 2, 0, -1, 2>, int)
double IsiSage::ObjectiveFunction(RowVectorXcd tau_data, double doppler, MatrixX2cd C1, MatrixX2cd C2, const int iL){
    // X 
    MatrixXcd X(config.Rx, config.Tx);
    complex<double> cycle_data = 0;
    complex<double> temp = 0;
    for(int i_tx = 0; i_tx < config.Tx; ++i_tx){
        for(int i_rx = 0; i_rx < config.Rx; ++i_rx){
            cycle_data = 0;
            temp = 0;
            for(int i_cyc = 0; i_cyc < config.cycle_num; ++i_cyc){
                double t = (i_cyc * config.Tcy + i_tx * config.Tt + i_rx * config.Tr) * config.T; 
                temp.real(cos(2*PI* doppler *t));
                temp.imag(-sin(2*PI* doppler *t));
                cycle_data += temp * tau_data(i_cyc * config.subchannel_num + i_tx * config.Rx + i_rx);
            }
            X(i_rx, i_tx) = cycle_data;
        }
    }
    // f 
    RowVectorXcd c_2_1_H = C2.col(0).adjoint();
    RowVectorXcd c_2_2_H = C2.col(1).adjoint();
    VectorXcd c_1_1_conj = C1.col(0).conjugate();
    VectorXcd c_1_2_conj = C1.col(1).conjugate();
    Vector4cd f;
    f(0) = c_2_1_H * X * c_1_1_conj;
    f(1) = c_2_1_H * X * c_1_2_conj;
    f(2) = c_2_2_H * X * c_1_1_conj;
    f(3) = c_2_2_H * X * c_1_2_conj;
    // D
    Matrix2cd part1 = C2.adjoint() * C2;
    Matrix2cd part2 = C1.adjoint() * C1;
    MatrixXcd D = kroneckerProduct(part1, part2);
    complex<double> z = f.adjoint() * D.inverse() * f;
    return sqrt(norm(z));

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1e8, %rsp            # imm = 0x1E8
movq %rcx, 0x120(%rsp)
movq %rdx, 0x118(%rsp)
movsd %xmm0, 0x8(%rsp)
movq %rsi, %r15
movq %rdi, %r12
leaq 0x8(%rdi), %rsi
leaq 0xc(%rdi), %rdx
leaq 0x68(%rsp), %rdi
movq %rsi, 0x130(%rsp)
movq %rdx, 0x128(%rsp)
callq 0xabc2
movsd 0x8(%rsp), %xmm0
mulsd 0x13427(%rip), %xmm0    # 0x1d3e8
movsd %xmm0, 0x8(%rsp)
xorpd %xmm0, %xmm0
leaq 0x100(%rsp), %r14
movapd %xmm0, (%r14)
xorl %ebp, %ebp
movq 0x128(%rsp), %rax
movslq (%rax), %rax
cmpq %rax, %rbp
jge 0xa109
xorl %ebx, %ebx
movq 0x130(%rsp), %rax
movslq (%rax), %rax
cmpq %rax, %rbx
jge 0xa101
xorpd %xmm0, %xmm0
movapd %xmm0, 0x100(%rsp)
movapd %xmm0, 0x50(%rsp)
xorl %r13d, %r13d
cmpl 0x10(%r12), %r13d
jge 0xa0df
movl 0xbc(%r12), %eax
imull %r13d, %eax
movl 0xb4(%r12), %ecx
imull %ebp, %ecx
addl %eax, %ecx
movl 0xb8(%r12), %eax
imull %ebx, %eax
addl %ecx, %eax
cvtsi2sd %eax, %xmm0
mulsd 0xa8(%r12), %xmm0
mulsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x138(%rsp)
callq 0x3470
movsd %xmm0, 0x100(%rsp)
movsd 0x138(%rsp), %xmm0
callq 0x3080
xorpd 0x133a4(%rip), %xmm0    # 0x1d430
movlpd %xmm0, 0x108(%rsp)
movl 0xa0(%r12), %eax
imull %r13d, %eax
movl 0x8(%r12), %ecx
imull %ebp, %ecx
addl %ebx, %eax
addl %ecx, %eax
movslq %eax, %rsi
movq %r15, %rdi
callq 0xafe6
movq %r14, %rdi
movq %rax, %rsi
callq 0xab66
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
movapd 0x50(%rsp), %xmm1
addpd %xmm0, %xmm1
movapd %xmm1, 0x50(%rsp)
incl %r13d
jmp 0xa01a
leaq 0x68(%rsp), %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x54d6
movapd 0x50(%rsp), %xmm0
movupd %xmm0, (%rax)
incq %rbx
jmp 0x9ff0
incq %rbp
jmp 0x9fda
leaq 0x10(%rsp), %rdi
movq 0x120(%rsp), %rbx
movq %rbx, %rsi
xorl %edx, %edx
callq 0xc424
movupd 0x10(%rsp), %xmm0
movupd 0x28(%rsp), %xmm1
movups 0x38(%rsp), %xmm2
leaq 0xc0(%rsp), %rsi
movapd %xmm0, (%rsi)
movupd %xmm1, 0x18(%rsi)
movups %xmm2, 0x28(%rsi)
leaq 0xb0(%rsp), %rdi
callq 0x19d30
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rdx
movq %rbx, %rsi
callq 0xc424
movq 0x118(%rsp), %r14
movupd 0x10(%rsp), %xmm0
movupd 0x28(%rsp), %xmm1
movups 0x38(%rsp), %xmm2
leaq 0xc0(%rsp), %rsi
movapd %xmm0, (%rsi)
movupd %xmm1, 0x18(%rsi)
movups %xmm2, 0x28(%rsi)
leaq 0xa0(%rsp), %rdi
callq 0x19d30
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xc424
movupd 0x10(%rsp), %xmm0
movupd 0x28(%rsp), %xmm1
movups 0x38(%rsp), %xmm2
leaq 0xc0(%rsp), %rsi
movapd %xmm0, (%rsi)
movupd %xmm1, 0x18(%rsi)
movups %xmm2, 0x28(%rsi)
leaq 0x90(%rsp), %rdi
callq 0xe92c
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rdx
movq %r14, %rsi
callq 0xc424
movupd 0x10(%rsp), %xmm0
movupd 0x28(%rsp), %xmm1
movups 0x38(%rsp), %xmm2
leaq 0xc0(%rsp), %r15
movapd %xmm0, (%r15)
movupd %xmm1, 0x18(%r15)
movups %xmm2, 0x28(%r15)
leaq 0x80(%rsp), %rdi
movq %r15, %rsi
callq 0xe92c
xorpd %xmm0, %xmm0
movapd %xmm0, 0xf0(%rsp)
movapd %xmm0, 0xe0(%rsp)
movapd %xmm0, 0xd0(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0xb166
leaq 0x190(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
leaq 0x10(%rsp), %rdi
leaq 0x90(%rsp), %rdx
callq 0x19fc4
leaq 0x10(%rsp), %rdi
callq 0xb18a
movsd %xmm0, 0xc0(%rsp)
movsd %xmm1, 0xc8(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0xb166
leaq 0x190(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
leaq 0x10(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x19fc4
leaq 0x10(%rsp), %rdi
callq 0xb18a
movsd %xmm0, 0xd0(%rsp)
movsd %xmm1, 0xd8(%rsp)
leaq 0xa0(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0xb166
leaq 0x190(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
leaq 0x10(%rsp), %rdi
leaq 0x90(%rsp), %rdx
callq 0x19fc4
leaq 0x10(%rsp), %rdi
callq 0xb18a
movsd %xmm0, 0xe0(%rsp)
movsd %xmm1, 0xe8(%rsp)
leaq 0xa0(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0xb166
leaq 0x190(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
leaq 0x10(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x19fc4
leaq 0x10(%rsp), %rdi
callq 0xb18a
movsd %xmm0, 0xf0(%rsp)
movsd %xmm1, 0xf8(%rsp)
leaq 0x158(%rsp), %rsi
movq %rbx, (%rsi)
leaq 0x190(%rsp), %rdi
movq %rbx, %rdx
callq 0xede8
leaq 0x10(%rsp), %rbx
leaq 0x190(%rsp), %rsi
movq %rbx, %rdi
callq 0xee1e
leaq 0x140(%rsp), %rsi
movq %r14, (%rsi)
leaq 0x158(%rsp), %rdi
movq %r14, %rdx
callq 0xede8
leaq 0x190(%rsp), %r14
leaq 0x158(%rsp), %rsi
movq %r14, %rdi
callq 0xee1e
leaq 0x158(%rsp), %rsi
movq %rbx, (%rsi)
movq %r14, 0x8(%rsi)
leaq 0x140(%rsp), %rdi
callq 0x116c6
movq %r15, 0x180(%rsp)
leaq 0x140(%rsp), %rdi
callq 0xaec4
leaq 0x178(%rsp), %rdx
movq %rax, (%rdx)
leaq 0x1d0(%rsp), %rdi
leaq 0x180(%rsp), %rsi
callq 0x11adc
leaq 0x158(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x11b10
leaq 0x158(%rsp), %rdi
callq 0xaef2
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
sqrtsd %xmm0, %xmm0
movsd %xmm0, 0x50(%rsp)
movq 0x140(%rsp), %rdi
callq 0x32c0
movq 0x80(%rsp), %rdi
callq 0x32c0
movq 0x90(%rsp), %rdi
callq 0x32c0
movq 0xa0(%rsp), %rdi
callq 0x32c0
movq 0xb0(%rsp), %rdi
callq 0x32c0
movq 0x68(%rsp), %rdi
callq 0x32c0
movsd 0x50(%rsp), %xmm0
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa4f8
jmp 0xa4f8
jmp 0xa4f8
movq %rax, %rbx
jmp 0xa508
movq %rax, %rbx
jmp 0xa515
movq %rax, %rbx
jmp 0xa522
jmp 0xa545
jmp 0xa4f8
jmp 0xa4f8
jmp 0xa4f8
movq %rax, %rbx
movq 0x80(%rsp), %rdi
callq 0x32c0
movq 0x90(%rsp), %rdi
callq 0x32c0
movq 0xa0(%rsp), %rdi
callq 0x32c0
movq 0xb0(%rsp), %rdi
callq 0x32c0
jmp 0xa548
movq %rax, %rbx
movq 0x140(%rsp), %rdi
callq 0x32c0
jmp 0xa4fb
jmp 0xa545
movq %rax, %rbx
movq 0x68(%rsp), %rdi
callq 0x32c0
movq %rbx, %rdi
callq 0x3430