// File: UCBASiCS[P]SPRIGHT/src/experimentoutput.cpp
// Function: ExperimentOutput::isBinningFailure(std::set<int, std::less<int>, std::allocator<int>>) const
bool ExperimentOutput::isBinningFailure(std::set<int> missedLocations) const
{
    /*
        if at least one of the missed locations appear in a singleton bin, that is,
        it could have been peeled, declare NOT a bining failure. If all of the missed
        locations appear in multiton bins, than it is a binning failure.
    */
    for (int stage=0; stage<config->getBinsNb(); stage++)
    {
        // std::vector<int> binStatus(config->getOldBinSize(stage), 0);
        std::vector<int> binStatus(config->getBinNumItems(stage), 0);


        for (auto it = missedLocations.cbegin(); it != missedLocations.cend(); ++it)
        {
            // binStatus[*it % config->getOldBinSize(stage)]++;
            binStatus[*it % config->getBinNumItems(stage)]++;
        }

        for (unsigned int index=0; index<binStatus.size(); index++)
        {
            if (binStatus[index] == 1)
            {
                return false;
            }
        }
    }
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rsi, -0x78(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x70(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, -0x7c(%rbp)
movq 0x10(%rax), %rdi
callq 0xeb10
movl %eax, %ecx
movl -0x7c(%rbp), %eax
cmpl %ecx, %eax
jge 0x171da
movq -0x70(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0x1c(%rbp), %esi
callq 0xea50
cltq
movq %rax, -0x90(%rbp)
movl $0x0, -0x3c(%rbp)
leaq -0x3d(%rbp), %rdi
movq %rdi, -0x88(%rbp)
callq 0xfd50
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rcx
leaq -0x38(%rbp), %rdi
leaq -0x3c(%rbp), %rdx
callq 0x175c0
jmp 0x17093
leaq -0x3d(%rbp), %rdi
callq 0x70d0
movq -0x78(%rbp), %rdi
callq 0x156e0
movq %rax, -0x58(%rbp)
movq -0x78(%rbp), %rdi
callq 0x15740
movq %rax, -0x60(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x15710
testb $0x1, %al
jne 0x170cc
jmp 0x17159
leaq -0x58(%rbp), %rdi
callq 0x15770
movq %rax, %rcx
movq -0x70(%rbp), %rax
movl (%rcx), %ecx
movl %ecx, -0x98(%rbp)
movq 0x10(%rax), %rdi
movl -0x1c(%rbp), %esi
callq 0xea50
movl %eax, -0x94(%rbp)
jmp 0x170f8
movl -0x94(%rbp), %ecx
movl -0x98(%rbp), %eax
cltd
idivl %ecx
movslq %edx, %rsi
leaq -0x38(%rbp), %rdi
callq 0x5d60
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
leaq -0x58(%rbp), %rdi
callq 0x15790
jmp 0x170a9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x3d(%rbp), %rdi
callq 0x70d0
jmp 0x171ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x5ad0
jmp 0x171ec
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
movq %rax, -0xa0(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xa5e0
movq %rax, %rcx
movq -0xa0(%rbp), %rax
cmpq %rcx, %rax
jae 0x171af
movl -0x64(%rbp), %eax
movl %eax, %esi
leaq -0x38(%rbp), %rdi
callq 0x5d60
cmpl $0x1, (%rax)
jne 0x171a2
movb $0x0, -0x1(%rbp)
movl $0x1, -0x68(%rbp)
jmp 0x171b6
jmp 0x171a4
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x17160
movl $0x0, -0x68(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x5ad0
movl -0x68(%rbp), %eax
testl %eax, %eax
je 0x171ca
jmp 0x171c8
jmp 0x171de
jmp 0x171cc
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x17026
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xa0, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x4540
nopw %cs:(%rax,%rax)
nop