// File: Pyboon[P]sage/isi_sage.cpp
// Function: IsiSage::InitTau(Eigen::Matrix<std::complex<double>, -1, -1, 0, -1, -1>, int)
RowVectorXcd IsiSage::InitTau(const complex_mat data, const int iL){
    Util::log("init tau...");
    // go through all CIR find tau index with max power 
    int min_tau = 1;
    int max_tau = config.sample_codes;
    int step = config.delay_step;
    int tau_size = (max_tau-min_tau)/step + 1;
    VectorXd tau_power_sum(tau_size);
    tau_power_sum.setZero(tau_size);
    for(int i_tau = 0; i_tau < tau_size; ++i_tau){
        tau_power_sum(i_tau) = data.row(i_tau*step).norm();
    }
    // get index of max tau_power_sum
    int max_index = 0;
    tau_power_sum.maxCoeff(&max_index);
    result.tau(iL) = min_tau + max_index * step;
    //return tau_power
    return data.row(max_index);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdx, -0x120(%rbp)
movq %rdi, -0x118(%rbp)
movq %rdi, %rax
movq %rax, -0x110(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x108(%rbp)
leaq -0x41(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x9dd0
movq -0x100(%rbp), %rdx
leaq 0x563ac(%rip), %rsi     # 0x6fb67
leaq -0x40(%rbp), %rdi
callq 0xb320
jmp 0x197c6
leaq -0x40(%rbp), %rdi
callq 0x13b80
jmp 0x197d1
leaq -0x40(%rbp), %rdi
callq 0x9470
leaq -0x41(%rbp), %rdi
callq 0x9840
movq -0x108(%rbp), %rax
movl $0x1, -0x58(%rbp)
movl 0x1c(%rax), %ecx
movl %ecx, -0x5c(%rbp)
movl 0x130(%rax), %eax
movl %eax, -0x60(%rbp)
movl -0x5c(%rbp), %eax
movl -0x58(%rbp), %ecx
subl %ecx, %eax
movl -0x60(%rbp), %ecx
cltd
idivl %ecx
incl %eax
movl %eax, -0x64(%rbp)
leaq -0x78(%rbp), %rdi
movq %rdi, -0x128(%rbp)
leaq -0x64(%rbp), %rsi
callq 0x20110
movq -0x128(%rbp), %rdi
movslq -0x64(%rbp), %rsi
callq 0x20170
jmp 0x19839
movl $0x0, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0x19902
movq -0x120(%rbp), %rsi
movl -0x7c(%rbp), %eax
movl -0x60(%rbp), %ecx
imull %ecx, %eax
movslq %eax, %rdx
leaq -0xb8(%rbp), %rdi
callq 0x201b0
jmp 0x1986d
leaq -0xb8(%rbp), %rdi
callq 0x20200
movsd %xmm0, -0x130(%rbp)
jmp 0x19883
movslq -0x7c(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x14140
movq %rax, -0x138(%rbp)
jmp 0x19899
movq -0x138(%rbp), %rax
movsd -0x130(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x19840
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x198da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x9470
leaq -0x41(%rbp), %rdi
callq 0x9840
jmp 0x199ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0xfde0
jmp 0x199ae
movl $0x0, -0xbc(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0xbc(%rbp), %rsi
callq 0x20260
jmp 0x1991e
movq -0x108(%rbp), %rdi
movl -0x58(%rbp), %eax
movl -0xbc(%rbp), %ecx
movl -0x60(%rbp), %edx
imull %edx, %ecx
addl %ecx, %eax
movl %eax, -0x144(%rbp)
addq $0x1c0, %rdi            # imm = 0x1C0
movslq -0x1c(%rbp), %rsi
callq 0x14090
movq %rax, -0x140(%rbp)
jmp 0x19955
movq -0x120(%rbp), %rsi
movq -0x140(%rbp), %rax
movl -0x144(%rbp), %ecx
movl %ecx, (%rax)
movslq -0xbc(%rbp), %rdx
leaq -0xf8(%rbp), %rdi
callq 0x201b0
jmp 0x19980
movq -0x118(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x202a0
jmp 0x19995
leaq -0x78(%rbp), %rdi
callq 0xfde0
movq -0x110(%rbp), %rax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x9dc0
nopw (%rax,%rax)