// File: UCBASiCS[P]SPRIGHT/src/binprocessor.cpp
// Function: BinProcessor::computeLocation()
void BinProcessor::computeLocation()
{
    int tempLoc = 0;

    for(int q = 0; q < config->getSignalBitLength(); q++) {
        int runningSum = 0;
        for (int i = 0; i <config->getChainsNb(); i++) {
            ffast_complex Dp = observationMatrix[binAbsoluteIndex][(config->getSignalBitLength()+1)*i];
            ffast_complex Dpq = observationMatrix[binAbsoluteIndex][(config->getSignalBitLength()+1)*i+q+1];
            bool sgn1 = std::real(Dp) > 0;
            bool sgn2 = std::real(Dpq) > 0;
            bool sgn = sgn1 ^ sgn2;
            runningSum+= 2*sgn - 1;            
        }
        if (runningSum >=0)
            tempLoc += 1<<(config->getSignalBitLength() - 1- q);
    }
    location = tempLoc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movq -0x48(%rbp), %rax
movl -0x10(%rbp), %ecx
movl %ecx, -0x4c(%rbp)
movq 0x10(%rax), %rdi
callq 0xe940
movl %eax, %ecx
movl -0x4c(%rbp), %eax
cmpl %ecx, %eax
jge 0x9c63
movl $0x0, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movq -0x48(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, -0x50(%rbp)
movq 0x10(%rax), %rdi
callq 0xeb50
movl %eax, %ecx
movl -0x50(%rbp), %eax
cmpl %ecx, %eax
jge 0x9c2b
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rcx
movslq 0x58(%rax), %rdx
movq (%rcx,%rdx,8), %rcx
movq %rcx, -0x60(%rbp)
movq 0x10(%rax), %rdi
callq 0xe940
movq -0x60(%rbp), %rcx
movl %eax, %edx
movq -0x48(%rbp), %rax
addl $0x1, %edx
imull -0x18(%rbp), %edx
movslq %edx, %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
movq (%rcx), %rdx
movq %rdx, -0x28(%rbp)
movq 0x8(%rcx), %rcx
movq %rcx, -0x20(%rbp)
movq 0x18(%rax), %rcx
movslq 0x58(%rax), %rdx
movq (%rcx,%rdx,8), %rcx
movq %rcx, -0x58(%rbp)
movq 0x10(%rax), %rdi
callq 0xe940
movl %eax, %ecx
movq -0x58(%rbp), %rax
addl $0x1, %ecx
imull -0x18(%rbp), %ecx
addl -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x38(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
callq 0xa460
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
seta %al
andb $0x1, %al
movb %al, -0x39(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xa460
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
seta %al
andb $0x1, %al
movb %al, -0x3a(%rbp)
movb -0x39(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movb -0x3a(%rbp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
xorl %ecx, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, -0x3b(%rbp)
movb -0x3b(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
shll %eax
subl $0x1, %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x9b10
cmpl $0x0, -0x14(%rbp)
jl 0x9c53
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xe940
movl %eax, %ecx
subl $0x1, %ecx
subl -0x10(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
addl -0xc(%rbp), %eax
movl %eax, -0xc(%rbp)
jmp 0x9c55
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x9ae2
movq -0x48(%rbp), %rax
movl -0xc(%rbp), %ecx
movl %ecx, 0x38(%rax)
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)