// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/tre/lib/tre-compile.c
// Function: tre_copy_ast
static reg_errcode_t
tre_copy_ast(tre_mem_t mem, tre_stack_t *stack, tre_ast_node_t *ast,
	     int flags, int *pos_add, tre_tag_direction_t *tag_directions,
	     tre_ast_node_t **copy, int *max_pos)
{
  reg_errcode_t status = REG_OK;
  int bottom = tre_stack_num_objects(stack);
  int num_copied = 0;
  int first_tag = 1;
  tre_ast_node_t **result = copy;
  tre_copyast_symbol_t symbol;

  STACK_PUSH(stack, voidptr, ast);
  STACK_PUSH(stack, int, COPY_RECURSE);

  while (status == REG_OK && tre_stack_num_objects(stack) > bottom)
    {
      tre_ast_node_t *node;
      if (status != REG_OK)
	break;

      symbol = (tre_copyast_symbol_t)tre_stack_pop_int(stack);
      switch (symbol)
	{
	case COPY_SET_RESULT_PTR:
	  result = tre_stack_pop_voidptr(stack);
	  break;
	case COPY_RECURSE:
	  node = tre_stack_pop_voidptr(stack);
	  switch (node->type)
	    {
	    case LITERAL:
	      {
		tre_literal_t *lit = node->obj;
		int pos = lit->position;
		int min = lit->code_min;
		int max = lit->code_max;
		if (!(IS_SPECIAL(lit)) || IS_BACKREF(lit))
		  {
		    /* XXX - e.g. [ab] has only one position but two
		       nodes, so we are creating holes in the state space
		       here.  Not fatal, just wastes memory. */
		    pos += *pos_add;
		    num_copied++;
		  }
		else if (IS_TAG(lit) && (flags & COPY_REMOVE_TAGS))
		  {
		    /* Change this tag to empty. */
		    min = EMPTY;
		    max = pos = -1;
		  }
		else if (IS_TAG(lit) && (flags & COPY_MAXIMIZE_FIRST_TAG)
			 && first_tag)
		  {
		    /* Maximize the first tag. */
		    tag_directions[max] = TRE_TAG_MAXIMIZE;
		    first_tag = 0;
		  }
		*result = tre_ast_new_literal(mem, min, max, pos);
		if (*result == NULL)
		  status = REG_ESPACE;

		if (pos > *max_pos)
		  *max_pos = pos;
		break;
	      }
	    case UNION:
	      {
		tre_union_t *uni = node->obj;
		tre_union_t *tmp;
		*result = tre_ast_new_union(mem, uni->left, uni->right);
		if (*result == NULL)
		  {
		    status = REG_ESPACE;
		    break;
		  }
		tmp = (*result)->obj;
		result = &tmp->left;
		STACK_PUSHX(stack, voidptr, uni->right);
		STACK_PUSHX(stack, int, COPY_RECURSE);
		STACK_PUSHX(stack, voidptr, &tmp->right);
		STACK_PUSHX(stack, int, COPY_SET_RESULT_PTR);
		STACK_PUSHX(stack, voidptr, uni->left);
		STACK_PUSHX(stack, int, COPY_RECURSE);
		break;
	      }
	    case CATENATION:
	      {
		tre_catenation_t *cat = node->obj;
		tre_catenation_t *tmp;
		*result = tre_ast_new_catenation(mem, cat->left, cat->right);
		if (*result == NULL)
		  {
		    status = REG_ESPACE;
		    break;
		  }
		tmp = (*result)->obj;
		tmp->left = NULL;
		tmp->right = NULL;
		result = &tmp->left;

		STACK_PUSHX(stack, voidptr, cat->right);
		STACK_PUSHX(stack, int, COPY_RECURSE);
		STACK_PUSHX(stack, voidptr, &tmp->right);
		STACK_PUSHX(stack, int, COPY_SET_RESULT_PTR);
		STACK_PUSHX(stack, voidptr, cat->left);
		STACK_PUSHX(stack, int, COPY_RECURSE);
		break;
	      }
	    case ITERATION:
	      {
		tre_iteration_t *iter = node->obj;
		STACK_PUSHX(stack, voidptr, iter->arg);
		STACK_PUSHX(stack, int, COPY_RECURSE);
		*result = tre_ast_new_iter(mem, iter->arg, iter->min,
					   iter->max, iter->minimal);
		if (*result == NULL)
		  {
		    status = REG_ESPACE;
		    break;
		  }
		iter = (*result)->obj;
		result = &iter->arg;
		break;
	      }
	    default:
	      assert(0);
	      break;
	    }
	  break;
	}
    }
  *pos_add += num_copied;
  return status;
}

// Assembly:
subq $0xa8, %rsp
movq 0xb8(%rsp), %rax
movq 0xb0(%rsp), %rax
movq %rdi, 0xa0(%rsp)
movq %rsi, 0x98(%rsp)
movq %rdx, 0x90(%rsp)
movl %ecx, 0x8c(%rsp)
movq %r8, 0x80(%rsp)
movq %r9, 0x78(%rsp)
movl $0x0, 0x74(%rsp)
movq 0x98(%rsp), %rdi
callq 0xc7920
movl %eax, 0x70(%rsp)
movl $0x0, 0x6c(%rsp)
movl $0x1, 0x68(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x98(%rsp), %rdi
movq 0x90(%rsp), %rsi
callq 0xc7aa0
movl %eax, 0x74(%rsp)
jmp 0xbde44
movq 0x98(%rsp), %rdi
xorl %esi, %esi
callq 0xc7930
movl %eax, 0x74(%rsp)
jmp 0xbde59
xorl %eax, %eax
cmpl $0x0, 0x74(%rsp)
movb %al, 0xf(%rsp)
jne 0xbde7e
movq 0x98(%rsp), %rdi
callq 0xc7920
cmpl 0x70(%rsp), %eax
setg %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0xbde8b
jmp 0xbe3cc
cmpl $0x0, 0x74(%rsp)
je 0xbde97
jmp 0xbe3cc
movq 0x98(%rsp), %rdi
callq 0xc7ad0
movl %eax, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
movl %eax, 0x8(%rsp)
testl %eax, %eax
je 0xbdedc
jmp 0xbdeb6
movl 0x8(%rsp), %eax
subl $0x1, %eax
jne 0xbe3c7
jmp 0xbdec5
movq 0x98(%rsp), %rdi
callq 0xc7b00
movq %rax, 0x60(%rsp)
jmp 0xbe3c7
movq 0x98(%rsp), %rdi
callq 0xc7b00
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
movl (%rax), %eax
movq %rax, (%rsp)
subq $0x3, %rax
ja 0xbe3a6
movq (%rsp), %rax
leaq 0xb728e(%rip), %rcx     # 0x17519c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
movl 0x10(%rax), %eax
movl %eax, 0x44(%rsp)
movq 0x48(%rsp), %rax
movq (%rax), %rax
movl %eax, 0x40(%rsp)
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movl %eax, 0x3c(%rsp)
movq 0x48(%rsp), %rax
cmpq $0x0, (%rax)
jge 0xbdf60
movq 0x48(%rsp), %rax
cmpq $-0x4, (%rax)
jne 0xbdf7f
movq 0x80(%rsp), %rax
movl (%rax), %eax
addl 0x44(%rsp), %eax
movl %eax, 0x44(%rsp)
movl 0x6c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x6c(%rsp)
jmp 0xbdff1
movq 0x48(%rsp), %rax
cmpq $-0x3, (%rax)
jne 0xbdfb3
movl 0x8c(%rsp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xbdfb3
movl $0xffffffff, 0x40(%rsp) # imm = 0xFFFFFFFF
movl $0xffffffff, 0x44(%rsp) # imm = 0xFFFFFFFF
movl $0xffffffff, 0x3c(%rsp) # imm = 0xFFFFFFFF
jmp 0xbdfef
movq 0x48(%rsp), %rax
cmpq $-0x3, (%rax)
jne 0xbdfed
movl 0x8c(%rsp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xbdfed
cmpl $0x0, 0x68(%rsp)
je 0xbdfed
movq 0x78(%rsp), %rax
movslq 0x3c(%rsp), %rcx
movl $0x1, (%rax,%rcx,4)
movl $0x0, 0x68(%rsp)
jmp 0xbdfef
jmp 0xbdff1
movq 0xa0(%rsp), %rdi
movl 0x40(%rsp), %esi
movl 0x3c(%rsp), %edx
movl 0x44(%rsp), %ecx
callq 0xfc1a0
movq %rax, %rcx
movq 0x60(%rsp), %rax
movq %rcx, (%rax)
movq 0x60(%rsp), %rax
cmpq $0x0, (%rax)
jne 0xbe028
movl $0xc, 0x74(%rsp)
movl 0x44(%rsp), %eax
movq 0xb8(%rsp), %rcx
cmpl (%rcx), %eax
jle 0xbe046
movl 0x44(%rsp), %ecx
movq 0xb8(%rsp), %rax
movl %ecx, (%rax)
jmp 0xbe3c5
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0xa0(%rsp), %rdi
movq 0x30(%rsp), %rax
movq (%rax), %rsi
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rdx
callq 0xfc2f0
movq %rax, %rcx
movq 0x60(%rsp), %rax
movq %rcx, (%rax)
movq 0x60(%rsp), %rax
cmpq $0x0, (%rax)
jne 0xbe09a
movl $0xc, 0x74(%rsp)
jmp 0xbe3c5
movq 0x60(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x98(%rsp), %rdi
movq 0x30(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0xc7aa0
movl %eax, 0x74(%rsp)
cmpl $0x0, 0x74(%rsp)
je 0xbe0db
jmp 0xbe3c5
movq 0x98(%rsp), %rdi
xorl %esi, %esi
callq 0xc7930
movl %eax, 0x74(%rsp)
cmpl $0x0, 0x74(%rsp)
je 0xbe0fa
jmp 0xbe3c5
movq 0x98(%rsp), %rdi
movq 0x28(%rsp), %rsi
addq $0x8, %rsi
callq 0xc7aa0
movl %eax, 0x74(%rsp)
cmpl $0x0, 0x74(%rsp)
je 0xbe120
jmp 0xbe3c5
movq 0x98(%rsp), %rdi
movl $0x1, %esi
callq 0xc7930
movl %eax, 0x74(%rsp)
cmpl $0x0, 0x74(%rsp)
je 0xbe142
jmp 0xbe3c5
movq 0x98(%rsp), %rdi
movq 0x30(%rsp), %rax
movq (%rax), %rsi
callq 0xc7aa0
movl %eax, 0x74(%rsp)
cmpl $0x0, 0x74(%rsp)
je 0xbe167
jmp 0xbe3c5
movq 0x98(%rsp), %rdi
xorl %esi, %esi
callq 0xc7930
movl %eax, 0x74(%rsp)
cmpl $0x0, 0x74(%rsp)
je 0xbe186
jmp 0xbe3c5
jmp 0xbe3c5
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0xa0(%rsp), %rdi
movq 0x20(%rsp), %rax
movq (%rax), %rsi
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rdx
callq 0xfc380
movq %rax, %rcx
movq 0x60(%rsp), %rax
movq %rcx, (%rax)
movq 0x60(%rsp), %rax
cmpq $0x0, (%rax)
jne 0xbe1da
movl $0xc, 0x74(%rsp)
jmp 0xbe3c5
movq 0x60(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq $0x0, (%rax)
movq 0x18(%rsp), %rax
movq $0x0, 0x8(%rax)
movq 0x18(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x98(%rsp), %rdi
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rsi
callq 0xc7aa0
movl %eax, 0x74(%rsp)
cmpl $0x0, 0x74(%rsp)
je 0xbe234
jmp 0xbe3c5
movq 0x98(%rsp), %rdi
xorl %esi, %esi
callq 0xc7930
movl %eax, 0x74(%rsp)
cmpl $0x0, 0x74(%rsp)
je 0xbe253
jmp 0xbe3c5
movq 0x98(%rsp), %rdi
movq 0x18(%rsp), %rsi
addq $0x8, %rsi
callq 0xc7aa0
movl %eax, 0x74(%rsp)
cmpl $0x0, 0x74(%rsp)
je 0xbe279
jmp 0xbe3c5
movq 0x98(%rsp), %rdi
movl $0x1, %esi
callq 0xc7930
movl %eax, 0x74(%rsp)
cmpl $0x0, 0x74(%rsp)
je 0xbe29b
jmp 0xbe3c5
movq 0x98(%rsp), %rdi
movq 0x20(%rsp), %rax
movq (%rax), %rsi
callq 0xc7aa0
movl %eax, 0x74(%rsp)
cmpl $0x0, 0x74(%rsp)
je 0xbe2c0
jmp 0xbe3c5
movq 0x98(%rsp), %rdi
xorl %esi, %esi
callq 0xc7930
movl %eax, 0x74(%rsp)
cmpl $0x0, 0x74(%rsp)
je 0xbe2df
jmp 0xbe3c5
jmp 0xbe3c5
movq 0x50(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x98(%rsp), %rdi
movq 0x10(%rsp), %rax
movq (%rax), %rsi
callq 0xc7aa0
movl %eax, 0x74(%rsp)
cmpl $0x0, 0x74(%rsp)
je 0xbe317
jmp 0xbe3c5
movq 0x98(%rsp), %rdi
xorl %esi, %esi
callq 0xc7930
movl %eax, 0x74(%rsp)
cmpl $0x0, 0x74(%rsp)
je 0xbe336
jmp 0xbe3c5
movq 0xa0(%rsp), %rdi
movq 0x10(%rsp), %rax
movq (%rax), %rsi
movq 0x10(%rsp), %rax
movl 0x8(%rax), %edx
movq 0x10(%rsp), %rax
movl 0xc(%rax), %ecx
movq 0x10(%rsp), %rax
movb 0x10(%rax), %al
andb $0x1, %al
movzbl %al, %r8d
callq 0xfc230
movq %rax, %rcx
movq 0x60(%rsp), %rax
movq %rcx, (%rax)
movq 0x60(%rsp), %rax
cmpq $0x0, (%rax)
jne 0xbe389
movl $0xc, 0x74(%rsp)
jmp 0xbe3c5
movq 0x60(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0x10(%rsp)
movq 0x10(%rsp), %rax
movq %rax, 0x60(%rsp)
jmp 0xbe3c5
leaq 0xb1b0e(%rip), %rdi     # 0x16febb
leaq 0xb6e57(%rip), %rsi     # 0x17520b
movl $0x30f, %edx            # imm = 0x30F
leaq 0xb6f5b(%rip), %rcx     # 0x17531b
callq 0xb3e0
jmp 0xbe3c7
jmp 0xbde59
movl 0x6c(%rsp), %ecx
movq 0x80(%rsp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movl 0x74(%rsp), %eax
addq $0xa8, %rsp
retq
nopl (%rax,%rax)