// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/tre/lib/tre-compile.c
// Function: tre_make_trans
static reg_errcode_t
tre_make_trans(tre_pos_and_tags_t *p1, tre_pos_and_tags_t *p2,
	       tre_tnfa_transition_t *transitions,
	       int *counts, int *offs)
{
  tre_pos_and_tags_t *orig_p2 = p2;
  tre_tnfa_transition_t *trans;
  int i, j, k, l, dup, prev_p2_pos;

  if (transitions != NULL)
    while (p1->position >= 0)
      {
	p2 = orig_p2;
	prev_p2_pos = -1;
	while (p2->position >= 0)
	  {
	    /* Optimization: if this position was already handled, skip it. */
	    if (p2->position == prev_p2_pos)
	      {
		p2++;
		continue;
	      }
	    prev_p2_pos = p2->position;
	    /* Set `trans' to point to the next unused transition from
	       position `p1->position'. */
	    trans = transitions + offs[p1->position];
	    while (trans->state != NULL)
	      {
#if 0
		/* If we find a previous transition from `p1->position' to
		   `p2->position', it is overwritten.  This can happen only
		   if there are nested loops in the regexp, like in "((a)*)*".
		   In POSIX.2 repetition using the outer loop is always
		   preferred over using the inner loop.	 Therefore the
		   transition for the inner loop is useless and can be thrown
		   away. */
		/* XXX - The same position is used for all nodes in a bracket
		   expression, so this optimization cannot be used (it will
		   break bracket expressions) unless I figure out a way to
		   detect it here. */
		if (trans->state_id == p2->position)
		  {
		    DPRINT(("*"));
		    break;
		  }
#endif
		trans++;
	      }

	    if (trans->state == NULL)
	      (trans + 1)->state = NULL;
	    /* Use the character ranges, assertions, etc. from `p1' for
	       the transition from `p1' to `p2'. */
	    trans->code_min = (tre_cint_t) p1->code_min;
	    trans->code_max = (tre_cint_t) p1->code_max;
	    trans->state = transitions + offs[p2->position];
	    trans->state_id = p2->position;
	    trans->assertions = p1->assertions | p2->assertions
	      | (p1->class ? ASSERT_CHAR_CLASS : 0)
	      | (p1->neg_classes != NULL ? ASSERT_CHAR_CLASS_NEG : 0);
	    if (p1->backref >= 0)
	      {
		assert((trans->assertions & ASSERT_CHAR_CLASS) == 0);
		assert(p2->backref < 0);
		trans->u.backref = p1->backref;
		trans->assertions |= ASSERT_BACKREF;
	      }
	    else
	      trans->u.class = p1->class;
	    if (p1->neg_classes != NULL)
	      {
		for (i = 0; p1->neg_classes[i] != (tre_ctype_t)0; i++);
		trans->neg_classes =
		  xmalloc(sizeof(*trans->neg_classes) * (i + 1));
		if (trans->neg_classes == NULL)
		  return REG_ESPACE;
		for (i = 0; p1->neg_classes[i] != (tre_ctype_t)0; i++)
		  trans->neg_classes[i] = p1->neg_classes[i];
		trans->neg_classes[i] = (tre_ctype_t)0;
	      }
	    else
	      trans->neg_classes = NULL;

	    /* Find out how many tags this transition has. */
	    i = 0;
	    if (p1->tags != NULL)
	      while(p1->tags[i] >= 0)
		i++;
	    j = 0;
	    if (p2->tags != NULL)
	      while(p2->tags[j] >= 0)
		j++;

	    /* If we are overwriting a transition, free the old tag array. */
	    if (trans->tags != NULL)
	      xfree(trans->tags);
	    trans->tags = NULL;

	    /* If there were any tags, allocate an array and fill it. */
	    if (i + j > 0)
	      {
		trans->tags = xmalloc(sizeof(*trans->tags) * (i + j + 1));
		if (!trans->tags)
		  return REG_ESPACE;
		i = 0;
		if (p1->tags != NULL)
		  while(p1->tags[i] >= 0)
		    {
		      trans->tags[i] = p1->tags[i];
		      i++;
		    }
		l = i;
		j = 0;
		if (p2->tags != NULL)
		  while (p2->tags[j] >= 0)
		    {
		      /* Don't add duplicates. */
		      dup = 0;
		      for (k = 0; k < i; k++)
			if (trans->tags[k] == p2->tags[j])
			  {
			    dup = 1;
			    break;
			  }
		      if (!dup)
			trans->tags[l++] = p2->tags[j];
		      j++;
		    }
		trans->tags[l] = -1;
	      }

	    /* Set the parameter array.	 If both `p2' and `p1' have same
	       parameters, the values in `p2' override those in `p1'. */
	    if (p1->params || p2->params)
	      {
		if (!trans->params)
		  trans->params = xmalloc(sizeof(*trans->params)
					  * TRE_PARAM_LAST);
		if (!trans->params)
		  return REG_ESPACE;
		for (i = 0; i < TRE_PARAM_LAST; i++)
		  {
		    trans->params[i] = TRE_PARAM_UNSET;
		    if (p1->params && p1->params[i] != TRE_PARAM_UNSET)
		      trans->params[i] = p1->params[i];
		    if (p2->params && p2->params[i] != TRE_PARAM_UNSET)
		      trans->params[i] = p2->params[i];
		  }
	      }
	    else
	      {
		if (trans->params)
		  xfree(trans->params);
		trans->params = NULL;
	      }


#ifdef TRE_DEBUG
	    {
	      int *tags;

	      DPRINT(("	 %2d -> %2d on %3d", p1->position, p2->position,
		      p1->code_min));
	      if (p1->code_max != p1->code_min)
		DPRINT(("-%3d", p1->code_max));
	      tags = trans->tags;
	      if (tags)
		{
		  DPRINT((", tags ["));
		  while (*tags >= 0)
		    {
		      DPRINT(("%d", *tags));
		      tags++;
		      if (*tags >= 0)
			DPRINT((","));
		    }
		  DPRINT(("]"));
		}
	      if (trans->assertions)
		DPRINT((", assert %d", trans->assertions));
	      if (trans->assertions & ASSERT_BACKREF)
		DPRINT((", backref %d", trans->u.backref));
	      else if (trans->u.class)
		DPRINT((", class %ld", (GtWord)trans->u.class));
	      if (trans->neg_classes)
		DPRINT((", neg_classes %p", trans->neg_classes));
	      if (trans->params)
		{
		  DPRINT((", "));
		  tre_print_params(trans->params);
		}
	      DPRINT(("\n"));
	    }
#endif /* TRE_DEBUG */
	    p2++;
	  }
	p1++;
      }
  else
    /* Compute a maximum limit for the number of transitions leaving
       from each state. */
    while (p1->position >= 0)
      {
	p2 = orig_p2;
	while (p2->position >= 0)
	  {
	    counts[p1->position]++;
	    p2++;
	  }
	p1++;
      }
  return REG_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r14
testq %rdx, %rdx
je 0x73c68
leaq -0x8(%rdx), %rax
movq %rax, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movq %r8, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
cmpl $0x0, (%r14)
js 0x73c6e
movq %rsi, %rbx
pushq $-0x1
popq %rax
addq $0x40, %rbx
movslq -0x40(%rbx), %r15
testq %r15, %r15
js 0x73c47
cmpl %eax, %r15d
je 0x739eb
movslq (%r14), %rax
movslq (%r8,%rax,4), %r13
shlq $0x6, %r13
addq 0x20(%rsp), %r13
cmpq $0x0, 0x10(%r13)
leaq 0x40(%r13), %r13
jne 0x73a11
andq $0x0, 0x10(%r13)
movq 0x4(%r14), %xmm0
pshuflw $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,2,2,3,4,5,6,7]
movd %xmm0, -0x38(%r13)
movslq (%r8,%r15,4), %rax
shlq $0x6, %rax
addq %rdx, %rax
movq %rax, -0x30(%r13)
movl %r15d, -0x28(%r13)
movl -0x28(%rbx), %eax
orl 0x18(%r14), %eax
movq 0x20(%r14), %rcx
xorl %edx, %edx
testq %rcx, %rcx
setne %dl
shll $0x2, %edx
orl %eax, %edx
xorl %eax, %eax
cmpq $0x0, 0x28(%r14)
setne %al
shll $0x3, %eax
orl %edx, %eax
movl %eax, -0x10(%r13)
movl 0x30(%r14), %esi
testl %esi, %esi
js 0x73a9a
testb $0x4, %dl
jne 0x73c84
cmpl $0x0, -0x10(%rbx)
jns 0x73ca3
movl %esi, -0x8(%r13)
orl $0x100, %eax            # imm = 0x100
movl %eax, -0x10(%r13)
jmp 0x73a9e
movq %rcx, -0x8(%r13)
movq 0x28(%r14), %r12
movq %r13, %rcx
testq %r12, %r12
je 0x73af6
xorl %edi, %edi
cmpq $0x0, (%r12,%rdi)
leaq 0x8(%rdi), %rdi
jne 0x73aac
movabsq $0x7fffffff8, %rax      # imm = 0x7FFFFFFF8
andq %rax, %rdi
callq 0xbce8
movq %rax, (%r13)
testq %rax, %rax
je 0x73c72
xorl %eax, %eax
movq (%r12,%rax), %rdx
movq (%r13), %rcx
testq %rdx, %rdx
je 0x73af3
movq %rdx, (%rcx,%rax)
movq 0x28(%r14), %r12
addq $0x8, %rax
jmp 0x73ad8
addq %rax, %rcx
andq $0x0, (%rcx)
movq 0x10(%r14), %rax
xorl %r12d, %r12d
movl $0x0, %ebp
testq %rax, %rax
je 0x73b19
pushq $-0x1
popq %rbp
incl %ebp
cmpl $0x0, (%rax)
leaq 0x4(%rax), %rax
jns 0x73b0e
movq -0x30(%rbx), %rax
testq %rax, %rax
je 0x73b32
pushq $-0x1
popq %r12
incl %r12d
cmpl $0x0, (%rax)
leaq 0x4(%rax), %rax
jns 0x73b26
movq -0x20(%r13), %rdi
callq 0xb790
andq $0x0, -0x20(%r13)
addl %ebp, %r12d
je 0x73bbe
movl %r12d, %eax
leaq 0x4(,%rax,4), %rdi
callq 0xbce8
movq %rax, -0x20(%r13)
testq %rax, %rax
je 0x73c72
movq 0x10(%r14), %rdx
xorl %ecx, %ecx
testq %rdx, %rdx
je 0x73b7c
movl (%rdx,%rcx,4), %esi
testl %esi, %esi
js 0x73b7c
movl %esi, (%rax,%rcx,4)
incq %rcx
jmp 0x73b6d
movq -0x30(%rbx), %rdx
testq %rdx, %rdx
je 0x73bb7
movl %ecx, %esi
xorl %edi, %edi
movl (%rdx,%rdi,4), %r8d
testl %r8d, %r8d
js 0x73bb7
xorl %r9d, %r9d
cmpq %r9, %rsi
je 0x73ba9
leaq 0x1(%r9), %r10
cmpl %r8d, (%rax,%r9,4)
movq %r10, %r9
jne 0x73b95
jmp 0x73bb2
movslq %ecx, %r9
incl %ecx
movl %r8d, (%rax,%r9,4)
incq %rdi
jmp 0x73b89
movslq %ecx, %rcx
orl $-0x1, (%rax,%rcx,4)
movq 0x38(%r14), %r12
testq %r12, %r12
jne 0x73bce
cmpq $0x0, -0x8(%rbx)
je 0x73c22
movq -0x18(%r13), %rax
testq %rax, %rax
jne 0x73bec
pushq $0x24
popq %rdi
callq 0xbce8
movq %rax, -0x18(%r13)
testq %rax, %rax
je 0x73c72
movq -0x8(%rbx), %rcx
xorl %edx, %edx
cmpq $0x9, %rdx
je 0x73c30
orl $-0x1, (%rax,%rdx,4)
testq %r12, %r12
je 0x73c0d
movl (%r12,%rdx,4), %esi
cmpl $-0x1, %esi
je 0x73c0d
movl %esi, (%rax,%rdx,4)
testq %rcx, %rcx
je 0x73c1d
movl (%rcx,%rdx,4), %esi
cmpl $-0x1, %esi
je 0x73c1d
movl %esi, (%rax,%rdx,4)
incq %rdx
jmp 0x73bf2
movq -0x18(%r13), %rdi
callq 0xb790
andq $0x0, -0x18(%r13)
movl %r15d, %eax
movq 0x18(%rsp), %rsi
movq 0x10(%rsp), %r8
movq 0x8(%rsp), %rdx
jmp 0x739eb
addq $0x40, %r14
jmp 0x739db
movq %rsi, %rax
cmpl $0x0, (%rax)
js 0x73c64
movslq (%r14), %rdx
incl (%rcx,%rdx,4)
addq $0x40, %rax
jmp 0x73c53
addq $0x40, %r14
cmpl $0x0, (%r14)
jns 0x73c50
xorl %eax, %eax
jmp 0x73c75
pushq $0xc
popq %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6ca4b(%rip), %rdi     # 0xe06d6
leaq 0x6c741(%rip), %rsi     # 0xe03d3
leaq 0x6ca6a(%rip), %rcx     # 0xe0703
movl $0x65f, %edx            # imm = 0x65F
callq 0xb400
leaq 0x6cac9(%rip), %rdi     # 0xe0773
leaq 0x6c722(%rip), %rsi     # 0xe03d3
leaq 0x6ca4b(%rip), %rcx     # 0xe0703
movl $0x660, %edx            # imm = 0x660
callq 0xb400
nop