// File: /workspace/github_c_makefile_star2_O1/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 %rsi, %r15
movq %rdi, %r14
movl (%rdi), %esi
movq %rdx, 0x8(%rsp)
testq %rdx, %rdx
je 0x9320c
testl %esi, %esi
js 0x93208
movq %r8, %rbp
movq 0x8(%rsp), %rax
addq $-0x8, %rax
movq %rax, 0x20(%rsp)
movq %r15, 0x10(%rsp)
movq %r8, 0x18(%rsp)
movl (%r15), %eax
testl %eax, %eax
js 0x931f9
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movq %r15, %rbx
movl %r13d, %ecx
addq $0x40, %rbx
movl %eax, %r13d
cmpl %ecx, %r13d
jne 0x92f54
movl (%rbx), %r13d
addq $0x40, %rbx
testl %r13d, %r13d
jns 0x92f3e
jmp 0x931f9
movslq (%r14), %rax
movslq (%rbp,%rax,4), %r12
shlq $0x6, %r12
addq 0x20(%rsp), %r12
cmpq $0x0, 0x10(%r12)
leaq 0x40(%r12), %r12
jne 0x92f65
movq $0x0, 0x10(%r12)
movq 0x4(%r14), %xmm0
pshuflw $0xe8, %xmm0, %xmm0     # xmm0 = xmm0[0,2,2,3,4,5,6,7]
movd %xmm0, -0x38(%r12)
movl %r13d, %eax
movslq (%rbp,%rax,4), %rax
shlq $0x6, %rax
addq 0x8(%rsp), %rax
movq %rax, -0x30(%r12)
movl %r13d, -0x28(%r12)
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(%r12)
movl 0x30(%r14), %esi
testl %esi, %esi
js 0x93000
testb $0x4, %dl
jne 0x9324f
cmpl $0x0, -0x10(%rbx)
jns 0x9326e
movl %esi, -0x8(%r12)
orl $0x100, %eax            # imm = 0x100
movl %eax, -0x10(%r12)
jmp 0x93005
movq %rcx, -0x8(%r12)
movq 0x28(%r14), %rcx
movq %r12, %rax
testq %rcx, %rcx
je 0x93069
xorl %edi, %edi
cmpq $0x0, (%rcx,%rdi)
leaq 0x8(%rdi), %rdi
jne 0x93013
movabsq $0x7fffffff8, %rax      # imm = 0x7FFFFFFF8
andq %rax, %rdi
callq 0xb810
movq %rax, (%r12)
testq %rax, %rax
je 0x9323b
movq 0x28(%r14), %rax
movq (%rax), %rcx
xorl %eax, %eax
testq %rcx, %rcx
je 0x93061
movq (%r12), %rdx
movq %rcx, (%rdx,%rax,8)
movq 0x28(%r14), %rcx
movq 0x8(%rcx,%rax,8), %rcx
incq %rax
jmp 0x93046
shlq $0x3, %rax
addq (%r12), %rax
movq $0x0, (%rax)
movq 0x10(%r14), %rax
xorl %r15d, %r15d
movl $0x0, %ebp
testq %rax, %rax
je 0x93091
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
incl %ebp
cmpl $0x0, (%rax)
leaq 0x4(%rax), %rax
jns 0x93086
movq -0x30(%rbx), %rax
testq %rax, %rax
je 0x930ac
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
incl %r15d
cmpl $0x0, (%rax)
leaq 0x4(%rax), %rax
jns 0x930a0
movq -0x20(%r12), %rdi
testq %rdi, %rdi
je 0x930bb
callq 0xb790
movq $0x0, -0x20(%r12)
addl %ebp, %r15d
movq 0x18(%rsp), %rbp
je 0x93162
movl %r15d, %eax
leaq 0x4(,%rax,4), %rdi
callq 0xb810
movq %rax, -0x20(%r12)
testq %rax, %rax
je 0x9323b
movq 0x10(%r14), %rdx
xorl %ecx, %ecx
testq %rdx, %rdx
je 0x93111
movl (%rdx), %esi
testl %esi, %esi
js 0x93111
xorl %ecx, %ecx
movl %esi, (%rax,%rcx,4)
movl 0x4(%rdx,%rcx,4), %esi
incq %rcx
testl %esi, %esi
jns 0x93103
movq -0x30(%rbx), %rdx
testq %rdx, %rdx
je 0x93156
movl (%rdx), %r9d
testl %r9d, %r9d
js 0x93156
movl %ecx, %edi
xorl %r8d, %r8d
movl %ecx, %esi
testl %ecx, %ecx
je 0x9313e
xorl %r10d, %r10d
cmpl %r9d, (%rax,%r10,4)
je 0x93147
incq %r10
cmpq %r10, %rdi
jne 0x93130
movslq %esi, %r10
incl %esi
movl %r9d, (%rax,%r10,4)
movl 0x4(%rdx,%r8,4), %r9d
incq %r8
testl %r9d, %r9d
jns 0x93129
jmp 0x93158
movl %ecx, %esi
movslq %esi, %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movq 0x38(%r14), %r15
testq %r15, %r15
jne 0x93172
cmpq $0x0, -0x8(%rbx)
je 0x931df
cmpq $0x0, -0x18(%r12)
jne 0x93189
movl $0x24, %edi
callq 0xb810
movq %rax, -0x18(%r12)
movq -0x18(%r12), %rax
testq %rax, %rax
je 0x9323b
movq -0x8(%rbx), %rcx
xorl %edx, %edx
movl $0xffffffff, (%rax,%rdx,4) # imm = 0xFFFFFFFF
testq %r15, %r15
je 0x931b5
movl (%r15,%rdx,4), %esi
cmpl $-0x1, %esi
je 0x931b5
movl %esi, (%rax,%rdx,4)
testq %rcx, %rcx
je 0x931c5
movl (%rcx,%rdx,4), %esi
cmpl $-0x1, %esi
je 0x931c5
movl %esi, (%rax,%rdx,4)
incq %rdx
cmpq $0x9, %rdx
jne 0x9319d
movl (%rbx), %eax
testl %eax, %eax
movq 0x10(%rsp), %r15
jns 0x92f34
jmp 0x931f9
movq -0x18(%r12), %rdi
testq %rdi, %rdi
je 0x931ee
callq 0xb790
movq $0x0, -0x18(%r12)
jmp 0x931ce
cmpl $0x0, 0x40(%r14)
leaq 0x40(%r14), %r14
jns 0x92f20
xorl %eax, %eax
jmp 0x93240
xorl %eax, %eax
testl %esi, %esi
js 0x93240
leaq 0x40(%r15), %rdx
cmpl $0x0, (%r15)
js 0x9322e
movq %rdx, %rsi
movslq (%r14), %rdi
incl (%rcx,%rdi,4)
cmpl $0x0, (%rsi)
leaq 0x40(%rsi), %rsi
jns 0x9321f
cmpl $0x0, 0x40(%r14)
leaq 0x40(%r14), %r14
jns 0x93216
jmp 0x93240
movl $0xc, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x641b0(%rip), %rdi     # 0xf7406
leaq 0x63ea6(%rip), %rsi     # 0xf7103
leaq 0x641cf(%rip), %rcx     # 0xf7433
movl $0x65f, %edx            # imm = 0x65F
callq 0xb400
leaq 0x6422e(%rip), %rdi     # 0xf74a3
leaq 0x63e87(%rip), %rsi     # 0xf7103
leaq 0x641b0(%rip), %rcx     # 0xf7433
movl $0x660, %edx            # imm = 0x660
callq 0xb400
nopl (%rax)