// File: /workspace/github_cpp_makefile_star2_O1/UCBASiCS[P]SPRIGHT/src/frontend.cpp
// Function: FrontEnd::process()
void FrontEnd::process()
{
    chrono->start("FrontEnd");
    
    int realSignalBitLength = config->getSignalBitLength(); //ceil(log2(config->getSignalLength()))

    for (int binAbsoluteIndex=0; binAbsoluteIndex<config->getBinsSum(); binAbsoluteIndex++)
        for (int delayNb = 0; delayNb < config->getDelaysNb(); delayNb++)
            observationMatrix[binAbsoluteIndex][delayNb] = 0;

    for (int c = 0; c < config->getBinsNb(); c++)
    {
        int binIndices = config->getSamplingPattern(c);

        int b = config->getBinNumIndices(c);
        int B = pow(2,b); // number of bins in stage

        for (int delayIndex = 0; delayIndex < config->getDelaysNb(); delayIndex++)
        {
            int currDelay = delays[delayIndex];

            std::vector<ffast_complex> binTimeDomain = std::vector<ffast_complex>(B);
            for (int bin_iter = 0; bin_iter < B; bin_iter++)
            {
                int mlInt = mapToInt(bin_iter, b, binIndices, realSignalBitLength);
                int signalIndex = currDelay ^ mlInt;

                binTimeDomain[bin_iter] = input->getSignalAtIndex(signalIndex);

                if (!countSamplesDone && config->needToCountSamples())
                    usedSamples.insert(signalIndex);
            }


            std::vector<ffast_complex> a = std::vector<ffast_complex>(binTimeDomain);
            std::vector<ffast_complex> b = std::vector<ffast_complex>(B);
            std::vector<ffast_complex> tmp = std::vector<ffast_complex>(B);
            int ii, jj, ss;
            for (ii = B>>1; ii > 0; ii>>=1) {
                for (jj = 0; jj < B; jj++) {
                    ss = jj/ii%2;
                    b[jj]=a[(ss?-ii:0)+jj];
                    b[jj]+= ((ffast_complex) (ss?-1:1)) * a[(ss?0:ii)+jj];
                }
                tmp = a; a = b; b = tmp;
            }
            std::vector<ffast_complex> binTransform = std::vector<ffast_complex>(a);

            for (int binLoc = 0; binLoc < B; binLoc++)
                observationMatrix[config->getBinOffset(c)+binLoc][delayIndex] = binTransform[binLoc];
        }     
    }






    for (int stage = 0; stage < config->getBinsNb(); stage++) {
        for (int r = 0; r < config->getBinNumItems(stage); r++) {
            for (int c = 0; c < config->getDelaysNb(); c++) {
                ffast_complex val = observationMatrix[r + config->getBinOffset(stage)][c];
                // double multiplier = pow(1.0*config->getSignalLength() / config->getBinNumItems(stage),.5);
                double multiplier = 1.0/config->getBinNumItems(stage) * pow(config->getSignalLength(), .5);
                // double multiplier = 1.0/config->getBinNumItems(stage);

                observationMatrix[r + config->getBinOffset(stage)][c] = val * multiplier;
            }
        }
    }

    countSamplesDone = true;

    chrono->stop("FrontEnd");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdi, %rbp
movq 0x8(%rdi), %r14
leaq 0x30(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x39a5(%rip), %rsi      # 0xff37
leaq 0x39a6(%rip), %rdx      # 0xff3f
leaq 0x20(%rsp), %rdi
callq 0x44c2
leaq 0x20(%rsp), %rsi
movq %r14, %rdi
callq 0x5a48
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0xc5c7
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3270
movq 0x10(%rbp), %rdi
callq 0x6d52
movl %eax, 0x14(%rsp)
movq 0x10(%rbp), %rdi
callq 0x6e18
testl %eax, %eax
jle 0xc636
xorl %ebx, %ebx
movq 0x10(%rbp), %rdi
callq 0x6e2a
testl %eax, %eax
xorpd %xmm0, %xmm0
jle 0xc623
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x50(%rbp), %rax
movq (%rax,%rbx,8), %rax
incq %r15
movupd %xmm0, (%rax,%r14)
movq 0x10(%rbp), %rdi
callq 0x6e2a
xorpd %xmm0, %xmm0
cltq
addq $0x10, %r14
cmpq %rax, %r15
jl 0xc5fa
incq %rbx
movq 0x10(%rbp), %rdi
callq 0x6e18
cltq
cmpq %rax, %rbx
jl 0xc5e3
movq 0x10(%rbp), %rdi
callq 0x6e1c
testl %eax, %eax
movq %rbp, 0x80(%rsp)
movl 0x14(%rsp), %ebx
jle 0xca09
leaq 0x80(%rbp), %rax
movq %rax, 0xa0(%rsp)
xorl %r15d, %r15d
movq 0x10(%rbp), %rdi
movl %r15d, %esi
callq 0x6d76
movl %eax, %r13d
movq 0x10(%rbp), %rdi
movl %r15d, 0x1c(%rsp)
movl %r15d, %esi
callq 0x6dce
movsd 0x2a5b(%rip), %xmm0     # 0xf0e8
movl %eax, %edi
callq 0x33c0
movsd %xmm0, (%rsp)
movq 0x10(%rbp), %rdi
callq 0x6e2a
testl %eax, %eax
jle 0xc9ef
cvttsd2si (%rsp), %eax
movl %eax, (%rsp)
movslq %eax, %r15
movl %r15d, %r12d
movl %r15d, %eax
sarl %eax
movl %eax, 0x18(%rsp)
movq %r12, 0xa8(%rsp)
shlq $0x4, %r12
xorl %r14d, %r14d
movq %r15, 0x78(%rsp)
movq 0x60(%rbp), %rax
movq %r14, 0x8(%rsp)
movl (%rax,%r14,4), %eax
movl %eax, 0x74(%rsp)
leaq 0x20(%rsp), %rdi
movq %r15, %rsi
leaq 0x40(%rsp), %rdx
callq 0x8dd0
cmpl $0x0, (%rsp)
movq 0xa0(%rsp), %r14
jle 0xc799
xorl %r15d, %r15d
testl %ebx, %ebx
jle 0xc73d
xorl %ecx, %ecx
xorl %esi, %esi
xorl %eax, %eax
movl $0x1, %edx
shll %cl, %edx
btl %ecx, %r13d
jae 0xc735
btl %eax, %r15d
leal 0x1(%rax), %eax
movl $0x0, %edi
cmovael %edi, %edx
addl %edx, %esi
incl %ecx
cmpl %ecx, %ebx
jne 0xc717
jmp 0xc73f
xorl %esi, %esi
xorl 0x74(%rsp), %esi
movl %esi, 0x40(%rsp)
movq 0x78(%rbp), %rdi
movq (%rdi), %rax
callq *0x28(%rax)
movq 0x20(%rsp), %rax
movq %r15, %rcx
shlq $0x4, %rcx
movsd %xmm0, (%rax,%rcx)
movsd %xmm1, 0x8(%rax,%rcx)
cmpb $0x0, 0x5c(%rbp)
jne 0xc788
movq 0x10(%rbp), %rdi
callq 0x6e5a
testb %al, %al
je 0xc788
movq %r14, %rdi
leaq 0x40(%rsp), %rsi
callq 0x8e48
incq %r15
cmpq 0xa8(%rsp), %r15
jne 0xc70d
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xccda
leaq 0x88(%rsp), %rdi
movq 0x78(%rsp), %r15
movq %r15, %rsi
leaq 0xb0(%rsp), %rbx
movq %rbx, %rdx
callq 0x8dd0
movq %rbx, %rdi
movq %r15, %rsi
leaq 0x58(%rsp), %rdx
callq 0x8dd0
cmpl $0x0, 0x18(%rsp)
jle 0xc8e9
movl 0x18(%rsp), %ebx
cmpl $0x0, (%rsp)
jle 0xc8a3
xorl %r15d, %r15d
xorl %r14d, %r14d
movl %r15d, %eax
xorl %edx, %edx
divl %ebx
andl $0x1, %eax
movl %eax, %ecx
negl %ecx
movl %ecx, %edx
andl %ebx, %edx
movq 0x40(%rsp), %rsi
movslq %edx, %rdx
shlq $0x4, %rdx
subq %rdx, %rsi
orl $0x1, %ecx
testl %eax, %eax
movq 0x88(%rsp), %rax
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movupd (%r14,%rsi), %xmm1
movl $0x0, %esi
cmovel %ebx, %esi
movupd %xmm1, (%rax,%r14)
shlq $0x4, %rsi
addq 0x40(%rsp), %rsi
addq %r14, %rsi
movsd %xmm0, 0x58(%rsp)
movq $0x0, 0x60(%rsp)
leaq 0x58(%rsp), %rdi
callq 0x5524
movsd 0x58(%rsp), %xmm0
movq 0x88(%rsp), %rax
addsd (%rax,%r14), %xmm0
movsd 0x60(%rsp), %xmm1
addsd 0x8(%rax,%r14), %xmm1
movsd %xmm0, (%rax,%r14)
movsd %xmm1, 0x8(%rax,%r14)
addq $0x10, %r14
incl %r15d
cmpq %r14, %r12
jne 0xc7f7
leaq 0xb0(%rsp), %r14
movq %r14, %rdi
leaq 0x40(%rsp), %rsi
callq 0xcd52
leaq 0x40(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0xcd52
leaq 0x88(%rsp), %rdi
movq %r14, %rsi
callq 0xcd52
movl %ebx, %eax
shrl %eax
cmpl $0x2, %ebx
movl %eax, %ebx
jae 0xc7e7
leaq 0x58(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0xccda
cmpl $0x0, (%rsp)
jle 0xc94b
xorl %ebx, %ebx
xorl %r14d, %r14d
movq 0x58(%rsp), %r15
movq 0x10(%rbp), %rdi
movq 0x50(%rbp), %rbp
movl 0x1c(%rsp), %esi
callq 0x6e0c
addl %r14d, %eax
cltq
movq (%rbp,%rax,8), %rax
movq 0x8(%rsp), %rcx
shlq $0x4, %rcx
movupd (%r15,%rbx), %xmm0
movupd %xmm0, (%rax,%rcx)
incl %r14d
addq $0x10, %rbx
cmpq %rbx, %r12
movq 0x80(%rsp), %rbp
jne 0xc903
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0xc962
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x3270
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
movl 0x14(%rsp), %ebx
je 0xc983
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3270
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
movq 0x78(%rsp), %r15
je 0xc9a5
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x3270
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0xc9bc
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3270
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xc9d3
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x3270
movq 0x8(%rsp), %r14
incq %r14
movq 0x10(%rbp), %rdi
callq 0x6e2a
cltq
cmpq %rax, %r14
jl 0xc6d5
movl 0x1c(%rsp), %r15d
incl %r15d
movq 0x10(%rbp), %rdi
callq 0x6e1c
cmpl %eax, %r15d
jl 0xc665
movq 0x10(%rbp), %rdi
callq 0x6e1c
testl %eax, %eax
jle 0xcb70
xorl %r14d, %r14d
movq 0x10(%rbp), %rdi
movl %r14d, %esi
callq 0x6d82
testl %eax, %eax
jle 0xcb5b
xorl %r15d, %r15d
movq 0x10(%rbp), %rdi
callq 0x6e2a
testl %eax, %eax
jle 0xcb43
movl $0x8, %ebx
xorl %r12d, %r12d
movq 0x10(%rbp), %rdi
movq 0x50(%rbp), %r13
movl %r14d, %esi
callq 0x6e0c
addl %r15d, %eax
cltq
movq (%r13,%rax,8), %rax
movsd -0x8(%rax,%rbx), %xmm0
movsd %xmm0, (%rsp)
movsd (%rax,%rbx), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x10(%rbp), %rdi
movl %r14d, %esi
callq 0x6d82
movq %rbp, %rcx
movl %eax, %ebp
movq 0x10(%rcx), %rdi
callq 0x6d62
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
ucomisd 0x326a(%rip), %xmm0     # 0xfd10
jb 0xcaae
sqrtsd %xmm0, %xmm0
jmp 0xcab3
callq 0x31c0
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
andpd 0x328e(%rip), %xmm0     # 0xfd50
movsd 0x261e(%rip), %xmm2     # 0xf0e8
divsd %xmm1, %xmm2
mulsd %xmm0, %xmm2
movsd (%rsp), %xmm0
mulsd %xmm2, %xmm0
movsd %xmm0, (%rsp)
movsd 0x8(%rsp), %xmm0
mulsd %xmm2, %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x80(%rsp), %rbp
movq 0x10(%rbp), %rdi
movq 0x50(%rbp), %r13
movl %r14d, %esi
callq 0x6e0c
addl %r15d, %eax
cltq
movq (%r13,%rax,8), %rax
movsd (%rsp), %xmm0
movsd %xmm0, -0x8(%rax,%rbx)
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rax,%rbx)
incq %r12
movq 0x10(%rbp), %rdi
callq 0x6e2a
cltq
addq $0x10, %rbx
cmpq %rax, %r12
jl 0xca4d
incl %r15d
movq 0x10(%rbp), %rdi
movl %r14d, %esi
callq 0x6d82
cmpl %eax, %r15d
jl 0xca34
incl %r14d
movq 0x10(%rbp), %rdi
callq 0x6e1c
cmpl %eax, %r14d
jl 0xca1d
movb $0x1, 0x5c(%rbp)
movq 0x8(%rbp), %rbx
leaq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %r14
movq %r14, (%rdi)
leaq 0x33ab(%rip), %rsi      # 0xff37
leaq 0x33ac(%rip), %rdx      # 0xff3f
callq 0x44c2
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x5ae4
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0xcbbc
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3270
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
jne 0xcbf3
jmp 0xcca8
jmp 0xcc10
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r15, %rdi
je 0xcca8
movq 0x30(%rsp), %rsi
incq %rsi
jmp 0xcca3
jmp 0xcc10
jmp 0xcc3d
movq %rax, %rbx
jmp 0xcc7a
jmp 0xcc36
movq %rax, %rbx
jmp 0xcc5d
movq %rax, %rbx
jmp 0xcca8
jmp 0xcc36
movq %rax, %rbx
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0xcc40
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x3270
jmp 0xcc40
movq %rax, %rbx
jmp 0xcc91
jmp 0xcc3d
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0xcc5d
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x3270
movq 0x88(%rsp), %rdi
testq %rdi, %rdi
je 0xcc7a
movq 0x98(%rsp), %rsi
subq %rdi, %rsi
callq 0x3270
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0xcc91
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3270
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0xcca8
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x3270
movq %rbx, %rdi
callq 0x3490