// File: /workspace/github_cpp_makefile_star2_O2/UCBASiCS[P]SPRIGHT/src/backend.cpp
// Function: BackEnd::process()
void BackEnd::process()
{
    chrono->start("BackEnd");
    binProcessor = new BinProcessor(chrono, config, observationMatrix, frontEnd->getDelays());
    int binAbsoluteIndex;
    bool singletonFound = true;
    initialize();
    maxBinUsed =0;
    while(singletonFound)
    {
        singletonFound = false;
        for (int stage = 0; stage < config->getBinsNb(); stage++)
        {
            binAbsoluteIndex = config->getBinOffset(stage);

            for (int binRelativeIndex = 0; binRelativeIndex < config->getBinNumItems(stage); binRelativeIndex++)
            {
                // Copies the values of bin index and related variables in binProcessor object.
                binProcessor->adjustTo(binAbsoluteIndex, binRelativeIndex, stage);
                // only check for singletons in the updated bins
                if (
                    changed[binAbsoluteIndex]
                    && binProcessor->isSingleton()
                    && decodedFrequencies.count(binProcessor->getLocation()) == 0
                   )
                {
                    singletonFound = true;
                    decodedFrequencies[binProcessor->getLocation()] = binProcessor->getAmplitude();
                    peelFrom(binProcessor->getLocation(), binProcessor->getAmplitude(), binAbsoluteIndex);
                    changed[binAbsoluteIndex] = false;
                }

                // mark this bin as processed
                // remark: this state can be changed if a ball is peeled from this bin
                changed[binAbsoluteIndex] = false;

                if ((int) decodedFrequencies.size() == config->getSignalSparsityPeeling())
                {
                    goto stopPeeling;
                }

                binAbsoluteIndex++;
            }
        }
    }


    stopPeeling:
    for (auto it = decodedFrequencies.cbegin(); it != decodedFrequencies.cend(); ++it)
    {
        realFrequenciesIndices.push_back(it->first);
    }

    delete binProcessor;

    chrono->stop("BackEnd");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movq 0x8(%rdi), %r14
leaq 0x86f2(%rip), %rsi      # 0xc030
leaq 0x18(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x3fb6
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0x56f4
leaq 0x18(%rsp), %rdi
callq 0x30f0
movl $0xa0, %edi
callq 0x3260
movq %rax, %r14
movq 0x8(%rbx), %r15
movq 0x10(%rbx), %r12
movq 0x28(%rbx), %r13
movq 0x18(%rbx), %rsi
leaq 0x18(%rsp), %rdi
callq 0xb038
leaq 0x18(%rsp), %r8
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x47dc
movq %r14, 0x20(%rbx)
leaq 0x18(%rsp), %rdi
callq 0x41c6
movq %rbx, %rdi
callq 0x3be6
andl $0x0, 0x88(%rbx)
leaq 0x30(%rbx), %rax
movq %rax, 0x38(%rsp)
movl $0x0, 0x10(%rsp)
xorl %ebp, %ebp
movq 0x10(%rbx), %rdi
callq 0x67ca
cmpl %eax, %ebp
jge 0x3b09
movq 0x10(%rbx), %rdi
movl %ebp, %esi
callq 0x67ba
movl %eax, %r12d
movslq %eax, %r15
xorl %r13d, %r13d
movq 0x10(%rbx), %rdi
movl %ebp, %esi
callq 0x6730
cmpl %eax, %r13d
jge 0x3b20
movq 0x20(%rbx), %rdi
leal (%r12,%r13), %r14d
movl %r14d, %esi
movl %r13d, %edx
movl %ebp, %ecx
callq 0x4f16
movq 0x80(%rbx), %rax
cmpb $0x1, (%rax,%r15)
jne 0x3ae0
movq 0x20(%rbx), %rdi
callq 0x4f34
testb %al, %al
je 0x3ae0
movq 0x20(%rbx), %rdi
callq 0x4ffc
movl %eax, 0x18(%rsp)
movq 0x38(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x41fa
testq %rax, %rax
jne 0x3ae0
movq 0x20(%rbx), %rdi
callq 0x5000
movsd %xmm0, 0x10(%rsp)
movsd %xmm1, 0x40(%rsp)
movq 0x20(%rbx), %rdi
callq 0x4ffc
movl %eax, 0x18(%rsp)
movq 0x38(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x428a
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x40(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
movq 0x20(%rbx), %rdi
callq 0x4ffc
movl %eax, 0x10(%rsp)
movq 0x20(%rbx), %rdi
callq 0x5000
movq %rbx, %rdi
movl 0x10(%rsp), %esi
movl %r14d, %edx
callq 0x3c30
movq 0x80(%rbx), %rax
movb $0x0, (%rax,%r15)
movb $0x1, %al
movl %eax, 0x10(%rsp)
movq 0x80(%rbx), %rax
movb $0x0, (%rax,%r15)
movl 0x48(%rbx), %r14d
movq 0x10(%rbx), %rdi
callq 0x671c
cmpl %r14d, %eax
je 0x3b27
incq %r15
incl %r13d
jmp 0x39f6
xorl %ebp, %ebp
testb $0x1, 0x10(%rsp)
movl $0x0, 0x10(%rsp)
jne 0x39d1
jmp 0x3b27
incl %ebp
jmp 0x39d1
leaq 0x40(%rbx), %r12
leaq 0x68(%rbx), %r14
leaq 0x18(%rsp), %r15
movq (%r12), %r12
testq %r12, %r12
je 0x3b57
cvtsi2sdl 0x8(%r12), %xmm0
movsd %xmm0, 0x18(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x4598
jmp 0x3b34
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x3b66
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x8(%rbx), %rbx
leaq 0x84bf(%rip), %rsi      # 0xc030
leaq 0x18(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x3fb6
leaq 0x18(%rsp), %rsi
movq %rbx, %rdi
callq 0x5758
leaq 0x18(%rsp), %rdi
callq 0x30f0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3bcb
jmp 0x3bda
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x41c6
jmp 0x3bbc
movq %rax, %rbx
movl $0xa0, %esi
movq %r14, %rdi
callq 0x3270
jmp 0x3bdd
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x30f0
jmp 0x3bdd
movq %rax, %rbx
movq %rbx, %rdi
callq 0x3490
nop