// File: UCBASiCS[P]SPRIGHT/src/frontend.cpp
// Function: FrontEnd::computeDelays()
void FrontEnd::computeDelays()
{
    delays.clear();

    if (config->isNoisy()) {
        if (config->needToUseMaximumLikelihoodDetection()) {
            if (config->isVerbose())
                std::cout << "ML delays" << std::endl;
            std::set<int> tempDelaysSet;
            while((int) tempDelaysSet.size() < config->getDelaysNb())
            {
                int tempDelay = ((int) floor(signalLength*((ffast_real) drand48()))) % signalLength;

                tempDelaysSet.insert(tempDelay);
            }
            delays.resize(config->getDelaysNb());
            std::copy(tempDelaysSet.begin(), tempDelaysSet.end(), delays.begin());
        }
        else {
            if (config->isVerbose())
                std::cout<< "FFAST chain delays" << std::endl;
            std::set<int> tempDelaysSet;
            while((int) tempDelaysSet.size() < config->getChainsNb())
            {
                int tempDelay = ((int) floor(signalLength*((ffast_real) drand48()))) % signalLength;

                tempDelaysSet.insert(tempDelay);
            }

            std::vector<int> tempDelaysArr;
            tempDelaysArr.clear();
            tempDelaysArr.resize(config->getDelaysNb());
            std::copy(tempDelaysSet.begin(), tempDelaysSet.end(), tempDelaysArr.begin());

            int r = 0;
            for (int i = 0; i < config->getChainsNb(); ++i) {
                r = tempDelaysArr[i];
                delays.push_back(r);
                for (int j = 0; j < config->getDelaysPerBunchNb()-1; j++)
                    delays.push_back(positiveMod(r^(1<<(config->getSignalBitLength() -1 - j)), signalLength));
            }
        }
    }
    else 
    {
        if (config->isVerbose())
            std::cout << "using standard delays" << std::endl;

        delays.push_back(0);
        for (int i =0; i < config->getSignalBitLength(); i++) {
            delays.push_back(1<<(config->getSignalBitLength() -1 - i));
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1d0, %rsp            # imm = 0x1D0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x120(%rbp)
addq $0x60, %rdi
callq 0xf930
movq -0x120(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xeb90
testb $0x1, %al
jne 0x1a8bc
jmp 0x1ae28
movq -0x120(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xe9c0
testb $0x1, %al
jne 0x1a8d5
jmp 0x1aa8c
movq -0x120(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xec10
testb $0x1, %al
jne 0x1a8eb
jmp 0x1a90d
movq 0x156d6(%rip), %rdi     # 0x2ffc8
leaq 0x6610(%rip), %rsi      # 0x20f09
callq 0x42b0
movq %rax, %rdi
movq 0x156a8(%rip), %rsi     # 0x2ffb0
callq 0x42f0
leaq -0x38(%rbp), %rdi
callq 0x5960
leaq -0x38(%rbp), %rdi
callq 0x5cd0
movq %rax, %rcx
movq -0x120(%rbp), %rax
movl %ecx, -0x128(%rbp)
movq 0x10(%rax), %rdi
callq 0xeb30
movl %eax, -0x124(%rbp)
jmp 0x1a940
movl -0x128(%rbp), %eax
movl -0x124(%rbp), %ecx
cmpl %ecx, %eax
jge 0x1a9e4
movq -0x120(%rbp), %rax
cvtsi2sdl 0x58(%rax), %xmm0
movsd %xmm0, -0x140(%rbp)
callq 0x4290
movaps %xmm0, %xmm1
movsd -0x140(%rbp), %xmm0
mulsd %xmm1, %xmm0
callq 0x4510
movq -0x120(%rbp), %rcx
cvttsd2si %xmm0, %eax
movl 0x58(%rcx), %ecx
cltd
idivl %ecx
movl %edx, -0x48(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x11fe0
movb %dl, -0x131(%rbp)
movq %rax, -0x130(%rbp)
jmp 0x1a9b1
movb -0x131(%rbp), %al
movq -0x130(%rbp), %rcx
movq %rcx, -0x58(%rbp)
movb %al, -0x50(%rbp)
jmp 0x1a916
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x5980
jmp 0x1af1b
movq -0x120(%rbp), %rax
movq %rax, %rcx
addq $0x60, %rcx
movq %rcx, -0x150(%rbp)
movq 0x10(%rax), %rdi
callq 0xeb30
movl %eax, -0x144(%rbp)
jmp 0x1aa0a
movq -0x150(%rbp), %rdi
movl -0x144(%rbp), %eax
movslq %eax, %rsi
callq 0x1bf30
jmp 0x1aa21
leaq -0x38(%rbp), %rdi
movq %rdi, -0x160(%rbp)
callq 0x1c030
movq -0x160(%rbp), %rdi
movq %rax, -0x60(%rbp)
callq 0x1c060
movq -0x120(%rbp), %rdi
movq %rax, -0x68(%rbp)
addq $0x60, %rdi
callq 0xa270
movq %rax, -0x70(%rbp)
movq -0x60(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x70(%rbp), %rdx
callq 0x1bfc0
movq %rax, -0x158(%rbp)
jmp 0x1aa73
movq -0x158(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x5980
jmp 0x1ae23
movq -0x120(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xec10
testb $0x1, %al
jne 0x1aaa2
jmp 0x1aac4
movq 0x1551f(%rip), %rdi     # 0x2ffc8
leaq 0x6463(%rip), %rsi      # 0x20f13
callq 0x42b0
movq %rax, %rdi
movq 0x154f1(%rip), %rsi     # 0x2ffb0
callq 0x42f0
leaq -0xa8(%rbp), %rdi
callq 0x5960
leaq -0xa8(%rbp), %rdi
callq 0x5cd0
movq %rax, %rcx
movq -0x120(%rbp), %rax
movl %ecx, -0x168(%rbp)
movq 0x10(%rax), %rdi
callq 0xeb50
movl %eax, -0x164(%rbp)
jmp 0x1aafd
movl -0x168(%rbp), %eax
movl -0x164(%rbp), %ecx
cmpl %ecx, %eax
jge 0x1aba7
movq -0x120(%rbp), %rax
cvtsi2sdl 0x58(%rax), %xmm0
movsd %xmm0, -0x180(%rbp)
callq 0x4290
movaps %xmm0, %xmm1
movsd -0x180(%rbp), %xmm0
mulsd %xmm1, %xmm0
callq 0x4510
movq -0x120(%rbp), %rcx
cvttsd2si %xmm0, %eax
movl 0x58(%rcx), %ecx
cltd
idivl %ecx
movl %edx, -0xac(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xac(%rbp), %rsi
callq 0x11fe0
movb %dl, -0x171(%rbp)
movq %rax, -0x170(%rbp)
jmp 0x1ab77
movb -0x171(%rbp), %al
movq -0x170(%rbp), %rcx
movq %rcx, -0xc0(%rbp)
movb %al, -0xb8(%rbp)
jmp 0x1aad0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1ae12
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0xf8f0
movq -0x190(%rbp), %rdi
callq 0xf930
movq -0x120(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xeb30
movl %eax, -0x184(%rbp)
jmp 0x1abde
movl -0x184(%rbp), %eax
movslq %eax, %rsi
leaq -0xd8(%rbp), %rdi
callq 0x1bf30
jmp 0x1abf5
leaq -0xa8(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
callq 0x1c030
movq -0x1a0(%rbp), %rdi
movq %rax, -0xe0(%rbp)
callq 0x1c060
movq %rax, -0xe8(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0xa270
movq %rax, -0xf0(%rbp)
movq -0xe0(%rbp), %rdi
movq -0xe8(%rbp), %rsi
movq -0xf0(%rbp), %rdx
callq 0x1bfc0
movq %rax, -0x198(%rbp)
jmp 0x1ac58
movq -0x198(%rbp), %rax
movq %rax, -0xf8(%rbp)
movl $0x0, -0xfc(%rbp)
movl $0x0, -0x100(%rbp)
movq -0x120(%rbp), %rax
movl -0x100(%rbp), %ecx
movl %ecx, -0x1a8(%rbp)
movq 0x10(%rax), %rdi
callq 0xeb50
movl %eax, -0x1a4(%rbp)
jmp 0x1ac9e
movl -0x1a8(%rbp), %eax
movl -0x1a4(%rbp), %ecx
cmpl %ecx, %eax
jge 0x1adf8
movslq -0x100(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
callq 0x5d60
movq -0x120(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0xfc(%rbp)
addq $0x60, %rdi
leaq -0xfc(%rbp), %rsi
callq 0xfa80
jmp 0x1ace6
movl $0x0, -0x104(%rbp)
movq -0x120(%rbp), %rax
movl -0x104(%rbp), %ecx
movl %ecx, -0x1b0(%rbp)
movq 0x10(%rax), %rdi
callq 0xeb70
movl %eax, -0x1ac(%rbp)
jmp 0x1ad14
movl -0x1b0(%rbp), %eax
movl -0x1ac(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x1ade2
movq -0x120(%rbp), %rax
movq %rax, %rcx
addq $0x60, %rcx
movq %rcx, -0x1c0(%rbp)
movl -0xfc(%rbp), %ecx
movl %ecx, -0x1b8(%rbp)
movq 0x10(%rax), %rdi
callq 0xe940
movl %eax, -0x1b4(%rbp)
jmp 0x1ad5d
movq -0x120(%rbp), %rax
movl -0x1b8(%rbp), %edi
movl -0x1b4(%rbp), %edx
movl -0x104(%rbp), %ecx
notl %ecx
addl %edx, %ecx
movb %cl, %dl
movb %dl, %cl
btcl %ecx, %edi
movl 0x58(%rax), %esi
callq 0x1c090
movl %eax, -0x1c4(%rbp)
jmp 0x1ad91
movq -0x1c0(%rbp), %rdi
movl -0x1c4(%rbp), %eax
movl %eax, -0x108(%rbp)
leaq -0x108(%rbp), %rsi
callq 0xfb50
jmp 0x1adb2
jmp 0x1adb4
movl -0x104(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x104(%rbp)
jmp 0x1acf0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x5ad0
jmp 0x1ae12
jmp 0x1ade4
movl -0x100(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x100(%rbp)
jmp 0x1ac7a
leaq -0xd8(%rbp), %rdi
callq 0x5ad0
leaq -0xa8(%rbp), %rdi
callq 0x5980
jmp 0x1ae23
leaq -0xa8(%rbp), %rdi
callq 0x5980
jmp 0x1af1b
jmp 0x1af12
movq -0x120(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xec10
testb $0x1, %al
jne 0x1ae3e
jmp 0x1ae60
movq 0x15183(%rip), %rdi     # 0x2ffc8
leaq 0x60da(%rip), %rsi      # 0x20f26
callq 0x42b0
movq %rax, %rdi
movq 0x15155(%rip), %rsi     # 0x2ffb0
callq 0x42f0
movq -0x120(%rbp), %rdi
addq $0x60, %rdi
movl $0x0, -0x10c(%rbp)
leaq -0x10c(%rbp), %rsi
callq 0xfb50
movl $0x0, -0x110(%rbp)
movq -0x120(%rbp), %rax
movl -0x110(%rbp), %ecx
movl %ecx, -0x1c8(%rbp)
movq 0x10(%rax), %rdi
callq 0xe940
movl %eax, %ecx
movl -0x1c8(%rbp), %eax
cmpl %ecx, %eax
jge 0x1af10
movq -0x120(%rbp), %rax
movq %rax, %rcx
addq $0x60, %rcx
movq %rcx, -0x1d0(%rbp)
movq 0x10(%rax), %rdi
callq 0xe940
movq -0x1d0(%rbp), %rdi
movl %eax, %ecx
subl $0x1, %ecx
subl -0x110(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x114(%rbp)
leaq -0x114(%rbp), %rsi
callq 0xfb50
movl -0x110(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x110(%rbp)
jmp 0x1ae8b
jmp 0x1af12
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x4540
nopw %cs:(%rax,%rax)