// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/tre/lib/tre-filter.c
// Function: tre_filter_find
int
tre_filter_find(const unsigned char *str, size_t len, tre_filter_t *filter)
{
  unsigned short counts[256];
  unsigned int i;
  unsigned int window_len = filter->window_len;
  tre_filter_profile_t *profile = filter->profile;
  const unsigned char *str_orig = str;

  DPRINT(("tre_filter_find: %.*s\n", len, str));

  for (i = 0; i < elementsof(counts); i++)
    counts[i] = 0;

  i = 0;
  while (*str && i < window_len && i < len)
    {
      counts[*str]++;
      i++;
      str++;
      len--;
    }

  while (len > 0)
    {
      tre_filter_profile_t *p;
      counts[*str]++;
      counts[*(str - window_len)]--;

      p = profile;
      while (p->ch)
	{
	  if (counts[p->ch] < p->count)
	    break;
	  p++;
	}
      if (!p->ch)
	{
	  DPRINT(("Found possible match at %d\n",
		  str - str_orig));
	  return str - str_orig;
	}
      else
	{
	  DPRINT(("No match so far...\n"));
	}
      len--;
      str++;
    }
  DPRINT(("This string cannot match.\n"));
  return -1;
}

// Assembly:
subq $0x1d8, %rsp            # imm = 0x1D8
movq %rdi, 0x1c8(%rsp)
movq %rsi, 0x1c0(%rsp)
movq %rdx, 0x1b8(%rsp)
movq 0x1b8(%rsp), %rax
movl (%rax), %eax
movl %eax, -0x58(%rsp)
movq 0x1b8(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rsp)
movq 0x1c8(%rsp), %rax
movq %rax, -0x68(%rsp)
jmp 0x4bbecd
movl $0x0, -0x54(%rsp)
movl -0x54(%rsp), %eax
cmpq $0x100, %rax            # imm = 0x100
jae 0x4bbef9
movl -0x54(%rsp), %eax
movw $0x0, -0x50(%rsp,%rax,2)
movl -0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rsp)
jmp 0x4bbed5
movl $0x0, -0x54(%rsp)
movq 0x1c8(%rsp), %rax
movzbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x71(%rsp)
je 0x4bbf3a
movl -0x54(%rsp), %ecx
xorl %eax, %eax
cmpl -0x58(%rsp), %ecx
movb %al, -0x71(%rsp)
jae 0x4bbf3a
movl -0x54(%rsp), %eax
cmpq 0x1c0(%rsp), %rax
setb %al
movb %al, -0x71(%rsp)
movb -0x71(%rsp), %al
testb $0x1, %al
jne 0x4bbf44
jmp 0x4bbf95
movq 0x1c8(%rsp), %rax
movzbl (%rax), %eax
movw -0x50(%rsp,%rax,2), %cx
addw $0x1, %cx
movw %cx, -0x50(%rsp,%rax,2)
movl -0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rsp)
movq 0x1c8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1c8(%rsp)
movq 0x1c0(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x1c0(%rsp)
jmp 0x4bbf01
jmp 0x4bbf97
cmpq $0x0, 0x1c0(%rsp)
jbe 0x4bc07e
movq 0x1c8(%rsp), %rax
movzbl (%rax), %eax
movw -0x50(%rsp,%rax,2), %cx
addw $0x1, %cx
movw %cx, -0x50(%rsp,%rax,2)
movq 0x1c8(%rsp), %rax
movl -0x58(%rsp), %ecx
movl %ecx, %edx
xorl %ecx, %ecx
subq %rdx, %rcx
movzbl (%rax,%rcx), %eax
movw -0x50(%rsp,%rax,2), %cx
addw $-0x1, %cx
movw %cx, -0x50(%rsp,%rax,2)
movq -0x60(%rsp), %rax
movq %rax, -0x70(%rsp)
movq -0x70(%rsp), %rax
cmpb $0x0, (%rax)
je 0x4bc024
movq -0x70(%rsp), %rax
movzbl (%rax), %eax
movzwl -0x50(%rsp,%rax,2), %eax
movq -0x70(%rsp), %rcx
movzbl 0x1(%rcx), %ecx
cmpl %ecx, %eax
jge 0x4bc014
jmp 0x4bc024
movq -0x70(%rsp), %rax
addq $0x2, %rax
movq %rax, -0x70(%rsp)
jmp 0x4bbfee
movq -0x70(%rsp), %rax
cmpb $0x0, (%rax)
jne 0x4bc04b
jmp 0x4bc030
jmp 0x4bc032
movq 0x1c8(%rsp), %rax
movq -0x68(%rsp), %rcx
subq %rcx, %rax
movl %eax, 0x1d4(%rsp)
jmp 0x4bc08d
jmp 0x4bc04d
jmp 0x4bc04f
jmp 0x4bc051
movq 0x1c0(%rsp), %rax
addq $-0x1, %rax
movq %rax, 0x1c0(%rsp)
movq 0x1c8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x1c8(%rsp)
jmp 0x4bbf97
jmp 0x4bc080
jmp 0x4bc082
movl $0xffffffff, 0x1d4(%rsp) # imm = 0xFFFFFFFF
movl 0x1d4(%rsp), %eax
addq $0x1d8, %rsp            # imm = 0x1D8
retq
nopl (%rax)