// File: ctSkennerton[P]fxtract/util/msutil.c
// Function: findbit_0
int
findbit_0(uint8_t const*vec, int len)
{
    int off = 15 & (intptr_t)vec;
    uint8_t const *bp = vec - off;  // Back up to a 16b boundary.
    __m128i ones = {-1, -1};
    uint16_t m = BYTEDIFF(bp, ones);
    len += off;
        // Mask off trailing bits (tiny vec)
    if (len < 16) m &= ~(-1 << len);  
        // First time through, mask off leading (off) bits
    for (m &= -1 << off; !m && len >= 16; m = BYTEDIFF(bp, ones))
        bp += 16, len -= 16, _mm_prefetch(bp+512, _MM_HINT_NTA);
        // Mask off trailing bits (tail of vec)
    if (len < 16) m &= ~(-1 << len);  
    return m ? (off = bsrl(m), 8*(off+bp-vec) + bsrl(bp[off] ^ 0xFF)) : -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x68(%rbp)
movl %esi, -0x6c(%rbp)
movl -0x68(%rbp), %eax
andl $0xf, %eax
movl %eax, -0x70(%rbp)
movq -0x68(%rbp), %rax
movslq -0x70(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x78(%rbp)
pcmpeqd %xmm0, %xmm0
movaps %xmm0, -0x90(%rbp)
movq -0x78(%rbp), %rax
movaps (%rax), %xmm1
movaps -0x90(%rbp), %xmm0
movaps %xmm1, -0x10(%rbp)
movaps %xmm0, -0x20(%rbp)
movaps -0x10(%rbp), %xmm0
movaps -0x20(%rbp), %xmm1
pcmpeqb %xmm1, %xmm0
movdqa %xmm0, -0x50(%rbp)
movdqa -0x50(%rbp), %xmm0
pmovmskb %xmm0, %eax
xorl $0xffff, %eax           # imm = 0xFFFF
movw %ax, -0x92(%rbp)
movl -0x70(%rbp), %eax
addl -0x6c(%rbp), %eax
movl %eax, -0x6c(%rbp)
cmpl $0x10, -0x6c(%rbp)
jge 0x81af
movl -0x6c(%rbp), %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
shll %cl, %eax
movl %eax, %ecx
xorl $-0x1, %ecx
movzwl -0x92(%rbp), %eax
andl %ecx, %eax
movw %ax, -0x92(%rbp)
movl -0x70(%rbp), %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
shll %cl, %eax
movl %eax, %ecx
movzwl -0x92(%rbp), %eax
andl %ecx, %eax
movw %ax, -0x92(%rbp)
xorl %eax, %eax
cmpw $0x0, -0x92(%rbp)
movb %al, -0x93(%rbp)
jne 0x81ea
cmpl $0x10, -0x6c(%rbp)
setge %al
movb %al, -0x93(%rbp)
movb -0x93(%rbp), %al
testb $0x1, %al
jne 0x81f6
jmp 0x8259
movq -0x78(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x78(%rbp)
movl -0x6c(%rbp), %eax
subl $0x10, %eax
movl %eax, -0x6c(%rbp)
movq -0x78(%rbp), %rax
addq $0x200, %rax            # imm = 0x200
prefetchnta (%rax)
movq -0x78(%rbp), %rax
movaps (%rax), %xmm1
movaps -0x90(%rbp), %xmm0
movaps %xmm1, -0x30(%rbp)
movaps %xmm0, -0x40(%rbp)
movaps -0x30(%rbp), %xmm0
movaps -0x40(%rbp), %xmm1
pcmpeqb %xmm1, %xmm0
movdqa %xmm0, -0x60(%rbp)
movdqa -0x60(%rbp), %xmm0
pmovmskb %xmm0, %eax
xorl $0xffff, %eax           # imm = 0xFFFF
movw %ax, -0x92(%rbp)
jmp 0x81cb
cmpl $0x10, -0x6c(%rbp)
jge 0x827e
movl -0x6c(%rbp), %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
shll %cl, %eax
movl %eax, %ecx
xorl $-0x1, %ecx
movzwl -0x92(%rbp), %eax
andl %ecx, %eax
movw %ax, -0x92(%rbp)
movzwl -0x92(%rbp), %eax
cmpl $0x0, %eax
je 0x82e7
movzwl -0x92(%rbp), %edi
callq 0x8310
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %ecx
movq -0x78(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq -0x68(%rbp), %rcx
subq %rcx, %rax
shlq $0x3, %rax
movq %rax, -0xa8(%rbp)
movq -0x78(%rbp), %rax
movslq -0x70(%rbp), %rcx
movzbl (%rax,%rcx), %edi
xorl $0xff, %edi
callq 0x8310
movl %eax, %ecx
movq -0xa8(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0xa0(%rbp)
jmp 0x82f7
movq $-0x1, %rax
movq %rax, -0xa0(%rbp)
jmp 0x82f7
movq -0xa0(%rbp), %rax
addq $0xb0, %rsp
popq %rbp
retq
nopw (%rax,%rax)