// File: ctSkennerton[P]fxtract/util/./railgun7w.c
// Function: bloom12
static byte *
bloom12(byte *pbTarget, byte *pbPattern, uint cbTarget, uint cbPattern)
{
    uint ulHashPattern = *(uint*)pbPattern;  // First four bytes
    byte filter[1 << (HASHBITS - 3)] = {};
    uint i, h, skip;
    uint rharg = rollhash_arg(12);
    uint rhash = rollhash_init(pbPattern, 12);

    for (i = 0; i <= cbPattern - 12; i++) {
        h = foldu(rhash);
        filter[h >> 3] |= 1 << (h & 7);
        rhash = rollhash_step(rharg, rhash, pbPattern[i], pbPattern[i+12]);
    }

    rhash = rollhash_init(pbTarget + cbPattern - 12, 12);
    for (i = 0; i <= cbTarget - cbPattern; i += skip) {
        //uint h = hash12(pbTarget + i + cbPattern - 12);
        h = foldu(rhash);
        if (!(filter[h >> 3] & (1 << (h & 7))))
            skip = cbPattern - 11,
            rhash = rollhash_init(pbTarget + cbPattern + i + 1 - 12, 12);
        else if (*(uint*)&pbTarget[i] == ulHashPattern && !intdiff(pbTarget + i, pbPattern, cbPattern))
            return pbTarget + i;
        else skip = 1,
            rhash = rollhash_step(rharg, rhash, pbTarget[cbPattern + i + cbPattern - 12], pbTarget[cbPattern + i + cbPattern]);
    }

    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2050, %rsp           # imm = 0x2050
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x24(%rbp)
leaq -0x2030(%rbp), %rdi
xorl %esi, %esi
movl $0x2000, %edx           # imm = 0x2000
callq 0x3110
movl $0xc, %edi
callq 0x6d30
movl %eax, -0x2040(%rbp)
movq -0x18(%rbp), %rdi
movl $0xc, %esi
callq 0x6d70
movl %eax, -0x2044(%rbp)
movl $0x0, -0x2034(%rbp)
movl -0x2034(%rbp), %eax
movl -0x20(%rbp), %ecx
subl $0xc, %ecx
cmpl %ecx, %eax
ja 0x6b12
movl -0x2044(%rbp), %edi
callq 0x6d10
movl %eax, -0x2038(%rbp)
movl -0x2038(%rbp), %ecx
andl $0x7, %ecx
movl $0x1, %edx
shll %cl, %edx
movl -0x2038(%rbp), %eax
shrl $0x3, %eax
movl %eax, %eax
movzbl -0x2030(%rbp,%rax), %ecx
orl %edx, %ecx
movb %cl, -0x2030(%rbp,%rax)
movl -0x2040(%rbp), %edi
movl -0x2044(%rbp), %esi
movq -0x18(%rbp), %rax
movl -0x2034(%rbp), %ecx
movb (%rax,%rcx), %dl
movq -0x18(%rbp), %rax
movl -0x2034(%rbp), %ecx
addl $0xc, %ecx
movl %ecx, %ecx
movzbl %dl, %edx
movzbl (%rax,%rcx), %ecx
callq 0x6dc0
movl %eax, -0x2044(%rbp)
movl -0x2034(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2034(%rbp)
jmp 0x6a73
movq -0x10(%rbp), %rdi
movl -0x20(%rbp), %eax
addq %rax, %rdi
addq $-0xc, %rdi
movl $0xc, %esi
callq 0x6d70
movl %eax, -0x2044(%rbp)
movl $0x0, -0x2034(%rbp)
movl -0x2034(%rbp), %eax
movl -0x1c(%rbp), %ecx
subl -0x20(%rbp), %ecx
cmpl %ecx, %eax
ja 0x6c77
movl -0x2044(%rbp), %edi
callq 0x6d10
movl %eax, -0x2038(%rbp)
movl -0x2038(%rbp), %eax
shrl $0x3, %eax
movl %eax, %eax
movzbl -0x2030(%rbp,%rax), %eax
movl -0x2038(%rbp), %ecx
andl $0x7, %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
jne 0x6bc7
movl -0x20(%rbp), %eax
subl $0xb, %eax
movl %eax, -0x203c(%rbp)
movq -0x10(%rbp), %rdi
movl -0x20(%rbp), %eax
addq %rax, %rdi
movl -0x2034(%rbp), %eax
addq %rax, %rdi
addq $0x1, %rdi
addq $-0xc, %rdi
movl $0xc, %esi
callq 0x6d70
movl %eax, -0x2044(%rbp)
jmp 0x6c5e
movq -0x10(%rbp), %rax
movl -0x2034(%rbp), %ecx
movl (%rax,%rcx), %eax
cmpl -0x24(%rbp), %eax
jne 0x6c0a
movq -0x10(%rbp), %rdi
movl -0x2034(%rbp), %eax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
movl -0x20(%rbp), %edx
callq 0x6c90
cmpl $0x0, %eax
jne 0x6c0a
movq -0x10(%rbp), %rax
movl -0x2034(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x8(%rbp)
jmp 0x6c7f
movl $0x1, -0x203c(%rbp)
movl -0x2040(%rbp), %edi
movl -0x2044(%rbp), %esi
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
addl -0x2034(%rbp), %ecx
addl -0x20(%rbp), %ecx
subl $0xc, %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %dl
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
addl -0x2034(%rbp), %ecx
addl -0x20(%rbp), %ecx
movl %ecx, %ecx
movzbl %dl, %edx
movzbl (%rax,%rcx), %ecx
callq 0x6dc0
movl %eax, -0x2044(%rbp)
jmp 0x6c5e
jmp 0x6c60
movl -0x203c(%rbp), %eax
addl -0x2034(%rbp), %eax
movl %eax, -0x2034(%rbp)
jmp 0x6b3a
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x2050, %rsp           # imm = 0x2050
popq %rbp
retq
nopl (%rax)