// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/tre/lib/regexec.c
// Function: tre_fill_pmatch
void
tre_fill_pmatch(size_t nmatch, regmatch_t pmatch[], int cflags,
		const tre_tnfa_t *tnfa, int *tags, int match_eo)
{
  tre_submatch_data_t *submatch_data;
  unsigned int i, j;
  int *parents;

  i = 0;
  if (match_eo >= 0 && !(cflags & REG_NOSUB))
    {
      /* Construct submatch offsets from the tags. */
      DPRINT(("end tag = t%d = %d\n", tnfa->end_tag, match_eo));
      submatch_data = tnfa->submatch_data;
      while (i < tnfa->num_submatches && i < nmatch)
	{
	  if (submatch_data[i].so_tag == tnfa->end_tag)
	    pmatch[i].rm_so = match_eo;
	  else
	    pmatch[i].rm_so = tags[submatch_data[i].so_tag];

	  if (submatch_data[i].eo_tag == tnfa->end_tag)
	    pmatch[i].rm_eo = match_eo;
	  else
	    pmatch[i].rm_eo = tags[submatch_data[i].eo_tag];

	  /* If either of the endpoints were not used, this submatch
	     was not part of the match. */
	  if (pmatch[i].rm_so == -1 || pmatch[i].rm_eo == -1)
	    pmatch[i].rm_so = pmatch[i].rm_eo = -1;

	  DPRINT(("pmatch[%d] = {t%d = %d, t%d = %d}\n", i,
		  submatch_data[i].so_tag, pmatch[i].rm_so,
		  submatch_data[i].eo_tag, pmatch[i].rm_eo));
	  i++;
	}
      /* Reset all submatches that are not within all of their parent
	 submatches. */
      i = 0;
      while (i < tnfa->num_submatches && i < nmatch)
	{
	  if (pmatch[i].rm_eo == -1)
	    assert(pmatch[i].rm_so == -1);
	  assert(pmatch[i].rm_so <= pmatch[i].rm_eo);

	  parents = submatch_data[i].parents;
	  if (parents != NULL)
	    for (j = 0; parents[j] >= 0; j++)
	      {
		DPRINT(("pmatch[%d] parent %d\n", i, parents[j]));
		if (pmatch[i].rm_so < pmatch[parents[j]].rm_so
		    || pmatch[i].rm_eo > pmatch[parents[j]].rm_eo)
		  pmatch[i].rm_so = pmatch[i].rm_eo = -1;
	      }
	  i++;
	}
    }

  while (i < nmatch)
    {
      pmatch[i].rm_so = -1;
      pmatch[i].rm_eo = -1;
      i++;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testl %r9d, %r9d
sets %al
andl $0x8, %edx
shrl $0x3, %edx
xorl %r10d, %r10d
orb %al, %dl
jne 0x8f608
movl 0x34(%rcx), %eax
testq %rax, %rax
setne %dl
testq %rdi, %rdi
setne %r11b
andb %dl, %r11b
cmpb $0x1, %r11b
jne 0x8f608
movq 0x20(%rcx), %rdx
movl 0x50(%rcx), %ecx
leaq -0x1(%rdi), %r10
leal -0x1(%rax), %ebx
cmpq %rbx, %r10
cmovbq %r10, %rbx
leaq 0x8(,%rbx,8), %r10
xorl %ebx, %ebx
movslq (%rdx,%rbx,2), %r14
movl %r9d, %ebp
cmpl %ecx, %r14d
je 0x8f542
movl (%r8,%r14,4), %ebp
movl %ebp, (%rsi,%rbx)
movslq 0x4(%rdx,%rbx,2), %r15
movl %r9d, %r14d
cmpl %ecx, %r15d
je 0x8f556
movl (%r8,%r15,4), %r14d
movl %r14d, 0x4(%rsi,%rbx)
cmpl $-0x1, %ebp
je 0x8f566
cmpl $-0x1, %r14d
jne 0x8f56e
movq $-0x1, (%rsi,%rbx)
addq $0x8, %rbx
cmpq %rbx, %r10
jne 0x8f532
xorl %r10d, %r10d
testb %r11b, %r11b
je 0x8f608
cmpq %rdi, %rax
cmovaeq %rdi, %rax
xorl %r10d, %r10d
movl (%rsi,%r10,8), %r8d
movl 0x4(%rsi,%r10,8), %ecx
cmpl $-0x1, %ecx
setne %r9b
cmpl $-0x1, %r8d
sete %r11b
orb %r9b, %r11b
je 0x8f64e
cmpl %ecx, %r8d
jg 0x8f62f
movq %r10, %r9
shlq $0x4, %r9
movq 0x8(%rdx,%r9), %r9
testq %r9, %r9
je 0x8f600
movl (%r9), %ebx
testl %ebx, %ebx
js 0x8f600
movl $0x1, %r11d
movl %ebx, %ebx
cmpl (%rsi,%rbx,8), %r8d
jl 0x8f5df
cmpl 0x4(%rsi,%rbx,8), %ecx
jle 0x8f5f2
movq $-0x1, (%rsi,%r10,8)
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movl %r11d, %ebx
movl (%r9,%rbx,4), %ebx
incl %r11d
testl %ebx, %ebx
jns 0x8f5d1
incq %r10
cmpq %rax, %r10
jb 0x8f58d
movl %r10d, %eax
cmpq %rdi, %rax
jae 0x8f624
leal 0x1(%rax), %ecx
movq $-0x1, (%rsi,%rax,8)
movl %ecx, %eax
incl %ecx
cmpq %rdi, %rax
jb 0x8f613
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x67958(%rip), %rdi     # 0xf6f8e
leaq 0x678e2(%rip), %rsi     # 0xf6f1f
leaq 0x678fa(%rip), %rcx     # 0xf6f3e
movl $0x61, %edx
callq 0xb400
leaq 0x678b4(%rip), %rdi     # 0xf6f09
leaq 0x678c3(%rip), %rsi     # 0xf6f1f
leaq 0x678db(%rip), %rcx     # 0xf6f3e
movl $0x60, %edx
callq 0xb400