// File: /workspace/github_cpp_makefile_star2_O3/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 $0x38, %rsp
movq %rdi, %rbx
movq 0x8(%rdi), %r14
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xa4df(%rip), %rsi      # 0xe030
leaq 0xa4df(%rip), %rdx      # 0xe037
leaq 0x8(%rsp), %rdi
callq 0x4430
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x5940
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x3b86
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3270
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 0x8(%rsp), %rdi
callq 0xcb4c
leaq 0x8(%rsp), %r8
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x49e0
movq %r14, 0x20(%rbx)
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x3bde
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x3270
movq %rbx, %rdi
callq 0x3e72
movl $0x0, 0x88(%rbx)
leaq 0x30(%rbx), %rax
movq %rax, 0x28(%rsp)
movl $0x0, (%rsp)
xorl %ebp, %ebp
movq 0x10(%rbx), %rdi
callq 0x6ce2
cmpl %eax, %ebp
jge 0x3d4a
movq 0x10(%rbx), %rdi
movl %ebp, %esi
callq 0x6cd2
movl %eax, %r12d
movq 0x10(%rbx), %rdi
movl %ebp, %esi
callq 0x6c48
testl %eax, %eax
jle 0x3d43
movslq %r12d, %r14
xorl %r13d, %r13d
movq 0x20(%rbx), %rdi
leal (%r12,%r13), %r15d
movl %r15d, %esi
movl %r13d, %edx
movl %ebp, %ecx
callq 0x528a
movq 0x80(%rbx), %rax
cmpb $0x1, (%rax,%r14)
jne 0x3d0b
movq 0x20(%rbx), %rdi
callq 0x52a8
testb %al, %al
je 0x3d0b
movq 0x20(%rbx), %rdi
callq 0x5374
movl %eax, 0x8(%rsp)
movq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x44c6
testq %rax, %rax
jne 0x3d0b
movq 0x20(%rbx), %rdi
callq 0x5378
movsd %xmm0, (%rsp)
movsd %xmm1, 0x30(%rsp)
movq 0x20(%rbx), %rdi
callq 0x5374
movl %eax, 0x8(%rsp)
movq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x4522
movsd (%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x30(%rsp), %xmm0
movsd %xmm0, 0x8(%rax)
movq 0x20(%rbx), %rdi
callq 0x5374
movl %eax, (%rsp)
movq 0x20(%rbx), %rdi
callq 0x5378
movq %rbx, %rdi
movl (%rsp), %esi
movl %r15d, %edx
callq 0x3ec8
movq 0x80(%rbx), %rax
movb $0x0, (%rax,%r14)
movb $0x1, %al
movl %eax, (%rsp)
movq 0x80(%rbx), %rax
movb $0x0, (%rax,%r14)
movl 0x48(%rbx), %r15d
movq 0x10(%rbx), %rdi
callq 0x6c34
cmpl %r15d, %eax
je 0x3d5d
incq %r14
incl %r13d
movq 0x10(%rbx), %rdi
movl %ebp, %esi
callq 0x6c48
cmpl %eax, %r13d
jl 0x3c3a
incl %ebp
jmp 0x3c02
xorl %ebp, %ebp
testb $0x1, (%rsp)
movl $0x0, (%rsp)
jne 0x3c02
movq 0x40(%rbx), %r12
testq %r12, %r12
leaq 0x18(%rsp), %r13
je 0x3db0
leaq 0x68(%rbx), %r14
leaq 0x8(%rsp), %r15
xorps %xmm0, %xmm0
cvtsi2sdl 0x8(%r12), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x70(%rbx), %rsi
cmpq 0x78(%rbx), %rsi
je 0x3d9c
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x70(%rbx)
jmp 0x3da7
movq %r14, %rdi
movq %r15, %rdx
callq 0x47d4
movq (%r12), %r12
testq %r12, %r12
jne 0x3d74
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x3dbf
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x8(%rbx), %rbx
leaq 0x8(%rsp), %rdi
movq %r13, (%rdi)
leaq 0xa25e(%rip), %rsi      # 0xe030
leaq 0xa25e(%rip), %rdx      # 0xe037
callq 0x4430
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x59dc
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x3e02
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3270
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
jne 0x3e58
jmp 0x3e6a
jmp 0x3e67
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x3e41
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x3270
jmp 0x3e41
movq %rax, %rbx
movl $0xa0, %esi
movq %r14, %rdi
jmp 0x3e60
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x3e6a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3270
jmp 0x3e6a
movq %rax, %rbx
movq %rbx, %rdi
callq 0x3490