// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/tre/lib/tre-compile.c
// Function: tre_set_union
static tre_pos_and_tags_t *
tre_set_union(tre_mem_t mem, tre_pos_and_tags_t *set1, tre_pos_and_tags_t *set2,
	      int *tags, int assertions, int *params)
{
  int s1, s2, i, j;
  tre_pos_and_tags_t *new_set;
  int *new_tags;
  int num_tags;

  for (num_tags = 0; tags != NULL && tags[num_tags] >= 0; num_tags++);
  for (s1 = 0; set1[s1].position >= 0; s1++);
  for (s2 = 0; set2[s2].position >= 0; s2++);
  new_set = tre_mem_calloc(mem, sizeof(*new_set) * (s1 + s2 + 1));
  if (!new_set )
    return NULL;

  for (s1 = 0; set1[s1].position >= 0; s1++)
    {
      new_set[s1].position = set1[s1].position;
      new_set[s1].code_min = set1[s1].code_min;
      new_set[s1].code_max = set1[s1].code_max;
      new_set[s1].assertions = set1[s1].assertions | assertions;
      new_set[s1].class = set1[s1].class;
      new_set[s1].neg_classes = set1[s1].neg_classes;
      new_set[s1].backref = set1[s1].backref;
      if (set1[s1].tags == NULL && tags == NULL)
	new_set[s1].tags = NULL;
      else
	{
	  for (i = 0; set1[s1].tags != NULL && set1[s1].tags[i] >= 0; i++);
	  new_tags = tre_mem_alloc(mem, (sizeof(*new_tags)
					 * (i + num_tags + 1)));
	  if (new_tags == NULL)
	    return NULL;
	  for (j = 0; j < i; j++)
	    new_tags[j] = set1[s1].tags[j];
	  for (i = 0; i < num_tags; i++)
	    new_tags[j + i] = tags[i];
	  new_tags[j + i] = -1;
	  new_set[s1].tags = new_tags;
	}
      if (set1[s1].params)
	new_set[s1].params = set1[s1].params;
      if (params)
	{
	  if (!new_set[s1].params)
	    new_set[s1].params = params;
	  else
	    {
	      new_set[s1].params = tre_mem_alloc(mem, sizeof(*params) *
						 TRE_PARAM_LAST);
	      if (!new_set[s1].params)
		return NULL;
	      for (i = 0; i < TRE_PARAM_LAST; i++)
		if (params[i] != TRE_PARAM_UNSET)
		  new_set[s1].params[i] = params[i];
	    }
	}
    }

  for (s2 = 0; set2[s2].position >= 0; s2++)
    {
      new_set[s1 + s2].position = set2[s2].position;
      new_set[s1 + s2].code_min = set2[s2].code_min;
      new_set[s1 + s2].code_max = set2[s2].code_max;
      /* XXX - why not | assertions here as well? */
      new_set[s1 + s2].assertions = set2[s2].assertions;
      new_set[s1 + s2].class = set2[s2].class;
      new_set[s1 + s2].neg_classes = set2[s2].neg_classes;
      new_set[s1 + s2].backref = set2[s2].backref;
      if (set2[s2].tags == NULL)
	new_set[s1 + s2].tags = NULL;
      else
	{
	  for (i = 0; set2[s2].tags[i] >= 0; i++);
	  new_tags = tre_mem_alloc(mem, sizeof(*new_tags) * (i + 1));
	  if (new_tags == NULL)
	    return NULL;
	  for (j = 0; j < i; j++)
	    new_tags[j] = set2[s2].tags[j];
	  new_tags[j] = -1;
	  new_set[s1 + s2].tags = new_tags;
	}
      if (set2[s2].params)
	new_set[s1 + s2].params = set2[s2].params;
      if (params)
	{
	  if (!new_set[s1 + s2].params)
	    new_set[s1 + s2].params = params;
	  else
	    {
	      new_set[s1 + s2].params = tre_mem_alloc(mem, sizeof(*params) *
						      TRE_PARAM_LAST);
	      if (!new_set[s1 + s2].params)
		return NULL;
	      for (i = 0; i < TRE_PARAM_LAST; i++)
		if (params[i] != TRE_PARAM_UNSET)
		  new_set[s1 + s2].params[i] = params[i];
	    }
	}
    }
  new_set[s1 + s2].position = -1;
  return new_set;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, %rbx
movl %r8d, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
movq %rsi, %rbp
movq %rdi, 0x8(%rsp)
testq %rcx, %rcx
movq %rcx, 0x28(%rsp)
je 0x9220c
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movq %rcx, %rax
incl %r14d
cmpl $0x0, (%rax)
leaq 0x4(%rax), %rax
jns 0x921fe
jmp 0x9220f
xorl %r14d, %r14d
movq $-0x40, %r8
cmpl $0x0, 0x40(%rbp,%r8)
leaq 0x40(%r8), %r8
jns 0x92216
movq 0x18(%rsp), %rax
addq $0x40, %r8
cmpl $0x0, (%rax)
leaq 0x40(%rax), %rax
jns 0x92227
movabsq $0x3fffffffc0, %rax     # imm = 0x3FFFFFFFC0
andq %rax, %r8
movq 0x8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x95072
movl $0x0, %ecx
movq %rcx, 0x10(%rsp)
movq %rax, (%rsp)
testq %rax, %rax
je 0x92598
movl (%rbp), %eax
testl %eax, %eax
movl $0x0, %r15d
js 0x92408
leal 0x1(%r14), %ecx
movq %rcx, 0x38(%rsp)
movl %r14d, %r12d
movq $0x0, 0x10(%rsp)
xorl %r15d, %r15d
movq (%rsp), %rsi
movq 0x28(%rsp), %rdi
movq %r15, 0x30(%rsp)
shlq $0x6, %r15
leaq (%r15,%rbp), %r8
movl %eax, (%rsi,%r15)
movq 0x4(%rbp,%r15), %rax
movq %rax, 0x4(%rsi,%r15)
movl 0x18(%rbp,%r15), %eax
orl 0x20(%rsp), %eax
movl %eax, 0x18(%rsi,%r15)
movups 0x20(%rbp,%r15), %xmm0
movups %xmm0, 0x20(%rsi,%r15)
movl 0x30(%rbp,%r15), %eax
movl %eax, 0x30(%rsi,%r15)
movq 0x10(%rbp,%r15), %rax
movq %rdi, %rcx
orq %rax, %rcx
jne 0x922f0
xorl %eax, %eax
jmp 0x92385
testq %rax, %rax
movq %r8, 0x40(%rsp)
je 0x9230e
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
incl %r13d
cmpl $0x0, (%rax)
leaq 0x4(%rax), %rax
jns 0x92300
jmp 0x92311
xorl %r13d, %r13d
movq 0x38(%rsp), %rax
leal (%rax,%r13), %r8d
shlq $0x2, %r8
movq 0x8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x95072
testq %rax, %rax
je 0x92598
movl %r13d, %ecx
testl %r13d, %r13d
movq 0x40(%rsp), %r8
je 0x92358
movq 0x10(%r8), %rdx
xorl %esi, %esi
movl (%rdx,%rsi,4), %edi
movl %edi, (%rax,%rsi,4)
incq %rsi
cmpq %rsi, %rcx
jne 0x9234a
testl %r14d, %r14d
movq 0x28(%rsp), %rdi
je 0x92376
leaq (%rax,%rcx,4), %rcx
xorl %edx, %edx
movl (%rdi,%rdx,4), %esi
movl %esi, (%rcx,%rdx,4)
incq %rdx
cmpq %rdx, %r12
jne 0x92368
addl %r14d, %r13d
movl $0xffffffff, (%rax,%r13,4) # imm = 0xFFFFFFFF
movq (%rsp), %rsi
addq %rsi, %r15
movq %rax, 0x10(%r15)
movq 0x38(%r8), %rax
testq %rax, %rax
je 0x92399
movq %rax, 0x38(%r15)
testq %rbx, %rbx
je 0x923ed
cmpq $0x0, 0x38(%r15)
je 0x923e9
movl $0x24, %r8d
movq 0x8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x95072
movq %rax, 0x38(%r15)
testq %rax, %rax
je 0x92598
xorl %ecx, %ecx
movq (%rsp), %rsi
movq 0x28(%rsp), %rdi
movl (%rbx,%rcx,4), %edx
cmpl $-0x1, %edx
je 0x923de
movl %edx, (%rax,%rcx,4)
incq %rcx
cmpq $0x9, %rcx
jne 0x923d3
jmp 0x923ed
movq %rbx, 0x38(%r15)
movq 0x30(%rsp), %r15
incq %r15
movq %r15, %rax
shlq $0x6, %rax
movl (%rbp,%rax), %eax
testl %eax, %eax
jns 0x9229d
movq 0x18(%rsp), %rsi
movl (%rsi), %eax
testl %eax, %eax
js 0x9257d
movq %r15, 0x30(%rsp)
movl %r15d, %ecx
shlq $0x6, %rcx
movq (%rsp), %r12
addq %rcx, %r12
movq $0x0, 0x10(%rsp)
xorl %r14d, %r14d
movq %r14, %r15
shlq $0x6, %r15
leaq (%rsi,%r15), %rdi
movl %eax, (%r12,%r15)
movq 0x4(%rsi,%r15), %rax
movq %rax, 0x4(%r12,%r15)
movl 0x18(%rsi,%r15), %eax
movl %eax, 0x18(%r12,%r15)
movups 0x20(%rsi,%r15), %xmm0
movups %xmm0, 0x20(%r12,%r15)
movl 0x30(%rsi,%r15), %eax
movl %eax, 0x30(%r12,%r15)
movq 0x10(%rsi,%r15), %rax
testq %rax, %rax
je 0x924e8
movq %rdi, 0x20(%rsp)
movl $0x1, %r13d
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %rcx, %rbp
decq %r13
cmpl $0x0, (%rax,%r8)
leaq 0x4(%r8), %r8
leaq 0x1(%rcx), %rcx
jns 0x92489
movabsq $0x3fffffffc, %rax      # imm = 0x3FFFFFFFC
andq %rax, %r8
movq 0x8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x95072
testq %rax, %rax
je 0x92598
testq %r13, %r13
je 0x924ec
movq 0x20(%rsp), %rdi
movq 0x10(%rdi), %rcx
xorl %edx, %edx
movl (%rcx,%rdx), %esi
movl %esi, (%rax,%rdx)
addq $0x4, %rdx
decq %rbp
jne 0x924d4
negq %r13
jmp 0x924f4
xorl %eax, %eax
jmp 0x92501
xorl %r13d, %r13d
movq 0x20(%rsp), %rdi
movl $0xffffffff, (%rax,%r13,4) # imm = 0xFFFFFFFF
movq 0x18(%rsp), %rsi
addq %r12, %r15
movq %rax, 0x10(%r15)
movq 0x38(%rdi), %rax
testq %rax, %rax
je 0x92515
movq %rax, 0x38(%r15)
testq %rbx, %rbx
je 0x92561
cmpq $0x0, 0x38(%r15)
je 0x9255d
movl $0x24, %r8d
movq 0x8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x95072
movq %rax, 0x38(%r15)
testq %rax, %rax
je 0x92598
xorl %ecx, %ecx
movq 0x18(%rsp), %rsi
movl (%rbx,%rcx,4), %edx
cmpl $-0x1, %edx
je 0x92552
movl %edx, (%rax,%rcx,4)
incq %rcx
cmpq $0x9, %rcx
jne 0x92547
jmp 0x92561
movq %rbx, 0x38(%r15)
incq %r14
movq %r14, %rax
shlq $0x6, %rax
movl (%rsi,%rax), %eax
testl %eax, %eax
jns 0x92436
movq 0x30(%rsp), %r15
jmp 0x92580
xorl %r14d, %r14d
addl %r15d, %r14d
shlq $0x6, %r14
movq (%rsp), %rax
movl $0xffffffff, (%rax,%r14) # imm = 0xFFFFFFFF
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq