// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/tre/lib/tre-parse.c
// Function: tre_parse_bracket_items
static reg_errcode_t
tre_parse_bracket_items(tre_parse_ctx_t *ctx, int negate,
			tre_ctype_t neg_classes[], int *num_neg_classes,
			tre_ast_node_t ***items, int *num_items,
			int *items_size)
{
  const tre_char_t *re = ctx->re;
  reg_errcode_t status = REG_OK;
  tre_ctype_t class = (tre_ctype_t)0;
  int i = *num_items;
  int max_i = *items_size;
  int skip;

  /* Build an array of the items in the bracket expression. */
  while (status == REG_OK)
    {
      skip = 0;
      if (re == ctx->re_end)
	{
	  status = REG_EBRACK;
	}
      else if (*re == CHAR_RBRACKET && re > ctx->re)
	{
	  DPRINT(("tre_parse_bracket:	done: '%.*" STRF "'\n", REST(re)));
	  re++;
	  break;
	}
      else
	{
	  tre_cint_t min = 0, max = 0;

	  class = (tre_ctype_t)0;
	  if (re + 2 < ctx->re_end
	      && *(re + 1) == CHAR_MINUS && *(re + 2) != CHAR_RBRACKET)
	    {
	      DPRINT(("tre_parse_bracket:  range: '%.*" STRF "'\n", REST(re)));
	      min = *re;
	      max = *(re + 2);
	      re += 3;
	      /* XXX - Should use collation order instead of encoding values
		 in character ranges. */
	      if (min > max)
		status = REG_ERANGE;
	    }
	  else if (re + 1 < ctx->re_end
		   && *re == CHAR_LBRACKET && *(re + 1) == CHAR_PERIOD)
	    status = REG_ECOLLATE;
	  else if (re + 1 < ctx->re_end
		   && *re == CHAR_LBRACKET && *(re + 1) == CHAR_EQUAL)
	    status = REG_ECOLLATE;
	  else if (re + 1 < ctx->re_end
		   && *re == CHAR_LBRACKET && *(re + 1) == CHAR_COLON)
	    {
	      char tmp_str[64];
	      const tre_char_t *endptr = re + 2;
	      int len;
	      DPRINT(("tre_parse_bracket:  class: '%.*" STRF "'\n", REST(re)));
	      while (endptr < ctx->re_end && *endptr != CHAR_COLON)
		endptr++;
	      if (endptr != ctx->re_end)
		{
		  len = MIN(endptr - re - 2, 63);
#ifdef TRE_WCHAR
		  {
		    tre_char_t tmp_wcs[64];
		    wcsncpy(tmp_wcs, re + 2, (size_t)len);
		    tmp_wcs[len] = L'\0';
#if defined HAVE_WCSRTOMBS
		    {
		      mbstate_t state;
		      const tre_char_t *src = tmp_wcs;
		      memset(&state, '\0', sizeof(state));
		      len = wcsrtombs(tmp_str, &src, sizeof(tmp_str), &state);
		    }
#elif defined HAVE_WCSTOMBS
		    len = wcstombs(tmp_str, tmp_wcs, 63);
#endif /* defined HAVE_WCSTOMBS */
		  }
#else /* !TRE_WCHAR */
		  strncpy(tmp_str, (const char*)re + 2, len);
#endif /* !TRE_WCHAR */
		  tmp_str[len] = '\0';
		  DPRINT(("  class name: %s\n", tmp_str));
		  class = tre_ctype(tmp_str);
		  if (!class)
		    status = REG_ECTYPE;
		  /* Optimize character classes for 8 bit character sets. */
		  if (status == REG_OK && TRE_MB_CUR_MAX == 1)
		    {
		      status = tre_expand_ctype(ctx->mem, class, items,
						&i, &max_i, ctx->cflags);
		      class = (tre_ctype_t)0;
		      skip = 1;
		    }
		  re = endptr + 2;
		}
	      else
		status = REG_ECTYPE;
	      min = 0;
	      max = TRE_CHAR_MAX;
	    }
	  else
	    {
	      DPRINT(("tre_parse_bracket:   char: '%.*" STRF "'\n", REST(re)));
	      if (*re == CHAR_MINUS && *(re + 1) != CHAR_RBRACKET
		  && ctx->re != re)
		/* Two ranges are not allowed to share and endpoint. */
		status = REG_ERANGE;
	      min = max = *re++;
	    }

	  if (status != REG_OK)
	    break;

	  if (class && negate)
	    if (*num_neg_classes >= MAX_NEG_CLASSES)
	      status = REG_ESPACE;
	    else
	      neg_classes[(*num_neg_classes)++] = class;
	  else if (!skip)
	    {
	      status = tre_new_item(ctx->mem, min, max, &i, &max_i, items);
	      if (status != REG_OK)
		break;
	      ((tre_literal_t*)((*items)[i-1])->obj)->u.class = class;
	    }

	  /* Add opposite-case counterpoints if REG_ICASE is present.
	     This is broken if there are more than two "same" characters. */
	  if (ctx->cflags & REG_ICASE && !class && status == REG_OK && !skip)
	    {
	      tre_cint_t cmin, ccurr;

	      DPRINT(("adding opposite-case counterpoints\n"));
	      while (min <= max)
		{
		  if (tre_islower(min))
		    {
		      cmin = ccurr = tre_toupper(min++);
		      while (tre_islower(min) && tre_toupper(min) == ccurr + 1
			     && min <= max)
			ccurr = tre_toupper(min++);
		      status = tre_new_item(ctx->mem, cmin, ccurr,
					    &i, &max_i, items);
		    }
		  else if (tre_isupper(min))
		    {
		      cmin = ccurr = tre_tolower(min++);
		      while (tre_isupper(min) && tre_tolower(min) == ccurr + 1
			     && min <= max)
			ccurr = tre_tolower(min++);
		      status = tre_new_item(ctx->mem, cmin, ccurr,
					    &i, &max_i, items);
		    }
		  else min++;
		  if (status != REG_OK)
		    break;
		}
	      if (status != REG_OK)
		break;
	    }
	}
    }
  *num_items = i;
  *items_size = max_i;
  ctx->re = re;
  return status;
}

// Assembly:
subq $0xc8, %rsp
movq 0xd0(%rsp), %rax
movq %rdi, 0xc0(%rsp)
movl %esi, 0xbc(%rsp)
movq %rdx, 0xb0(%rsp)
movq %rcx, 0xa8(%rsp)
movq %r8, 0xa0(%rsp)
movq %r9, 0x98(%rsp)
movq 0xc0(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x90(%rsp)
movl $0x0, 0x8c(%rsp)
movq $0x0, 0x80(%rsp)
movq 0x98(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x7c(%rsp)
movq 0xd0(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x78(%rsp)
cmpl $0x0, 0x8c(%rsp)
jne 0xc74eb
movl $0x0, 0x74(%rsp)
movq 0x90(%rsp), %rax
movq 0xc0(%rsp), %rcx
cmpq 0x28(%rcx), %rax
jne 0xc6db1
movl $0x7, 0x8c(%rsp)
jmp 0xc74e6
movq 0x90(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x5d, %eax
jne 0xc6df4
movq 0x90(%rsp), %rax
movq 0xc0(%rsp), %rcx
cmpq 0x18(%rcx), %rax
jbe 0xc6df4
jmp 0xc6dd9
jmp 0xc6ddb
movq 0x90(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x90(%rsp)
jmp 0xc74eb
movw $0x0, 0x72(%rsp)
movw $0x0, 0x70(%rsp)
movq $0x0, 0x80(%rsp)
movq 0x90(%rsp), %rax
addq $0x2, %rax
movq 0xc0(%rsp), %rcx
cmpq 0x28(%rcx), %rax
jae 0xc6ea1
movq 0x90(%rsp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x2d, %eax
jne 0xc6ea1
movq 0x90(%rsp), %rax
movzbl 0x2(%rax), %eax
cmpl $0x5d, %eax
je 0xc6ea1
jmp 0xc6e4c
jmp 0xc6e4e
movq 0x90(%rsp), %rax
movzbl (%rax), %eax
movw %ax, 0x72(%rsp)
movq 0x90(%rsp), %rax
movzbl 0x2(%rax), %eax
movw %ax, 0x70(%rsp)
movq 0x90(%rsp), %rax
addq $0x3, %rax
movq %rax, 0x90(%rsp)
movswl 0x72(%rsp), %eax
movswl 0x70(%rsp), %ecx
cmpl %ecx, %eax
jle 0xc6e9c
movl $0xb, 0x8c(%rsp)
jmp 0xc7181
movq 0x90(%rsp), %rax
addq $0x1, %rax
movq 0xc0(%rsp), %rcx
cmpq 0x28(%rcx), %rax
jae 0xc6eec
movq 0x90(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x5b, %eax
jne 0xc6eec
movq 0x90(%rsp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x2e, %eax
jne 0xc6eec
movl $0x3, 0x8c(%rsp)
jmp 0xc717f
movq 0x90(%rsp), %rax
addq $0x1, %rax
movq 0xc0(%rsp), %rcx
cmpq 0x28(%rcx), %rax
jae 0xc6f37
movq 0x90(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x5b, %eax
jne 0xc6f37
movq 0x90(%rsp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x3d, %eax
jne 0xc6f37
movl $0x3, 0x8c(%rsp)
jmp 0xc717d
movq 0x90(%rsp), %rax
addq $0x1, %rax
movq 0xc0(%rsp), %rcx
cmpq 0x28(%rcx), %rax
jae 0xc7111
movq 0x90(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x5b, %eax
jne 0xc7111
movq 0x90(%rsp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x3a, %eax
jne 0xc7111
movq 0x90(%rsp), %rax
addq $0x2, %rax
movq %rax, 0x28(%rsp)
jmp 0xc6f91
jmp 0xc6f93
movq 0x28(%rsp), %rcx
movq 0xc0(%rsp), %rdx
xorl %eax, %eax
cmpq 0x28(%rdx), %rcx
movb %al, 0x1f(%rsp)
jae 0xc6fbe
movq 0x28(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x3a, %eax
setne %al
movb %al, 0x1f(%rsp)
movb 0x1f(%rsp), %al
testb $0x1, %al
jne 0xc6fc8
jmp 0xc6fd8
movq 0x28(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x28(%rsp)
jmp 0xc6f93
movq 0x28(%rsp), %rax
movq 0xc0(%rsp), %rcx
cmpq 0x28(%rcx), %rax
je 0xc70f6
movq 0x28(%rsp), %rax
movq 0x90(%rsp), %rcx
subq %rcx, %rax
subq $0x2, %rax
cmpq $0x3f, %rax
jg 0xc7024
movq 0x28(%rsp), %rax
movq 0x90(%rsp), %rcx
subq %rcx, %rax
subq $0x2, %rax
movq %rax, 0x10(%rsp)
jmp 0xc7030
movl $0x3f, %eax
movq %rax, 0x10(%rsp)
jmp 0xc7030
movq 0x10(%rsp), %rax
movl %eax, 0x24(%rsp)
leaq 0x30(%rsp), %rdi
movq 0x90(%rsp), %rsi
addq $0x2, %rsi
movslq 0x24(%rsp), %rdx
callq 0xb2b0
movslq 0x24(%rsp), %rax
movb $0x0, 0x30(%rsp,%rax)
jmp 0xc7060
leaq 0x30(%rsp), %rdi
callq 0xc3750
movq %rax, 0x80(%rsp)
cmpq $0x0, 0x80(%rsp)
jne 0xc7088
movl $0x4, 0x8c(%rsp)
cmpl $0x0, 0x8c(%rsp)
jne 0xc70e3
movq 0xc0(%rsp), %rax
movq (%rax), %rdi
movq 0x80(%rsp), %rsi
movq 0xa0(%rsp), %rdx
movq 0xc0(%rsp), %rax
movl 0x44(%rax), %r9d
leaq 0x7c(%rsp), %rcx
leaq 0x78(%rsp), %r8
callq 0xc75c0
movl %eax, 0x8c(%rsp)
movq $0x0, 0x80(%rsp)
movl $0x1, 0x74(%rsp)
movq 0x28(%rsp), %rax
addq $0x2, %rax
movq %rax, 0x90(%rsp)
jmp 0xc7101
movl $0x4, 0x8c(%rsp)
movw $0x0, 0x72(%rsp)
movw $0xff, 0x70(%rsp)
jmp 0xc717b
jmp 0xc7113
jmp 0xc7115
movq 0x90(%rsp), %rax
movzbl (%rax), %eax
cmpl $0x2d, %eax
jne 0xc7157
movq 0x90(%rsp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x5d, %eax
je 0xc7157
movq 0xc0(%rsp), %rax
movq 0x18(%rax), %rax
cmpq 0x90(%rsp), %rax
je 0xc7157
movl $0xb, 0x8c(%rsp)
movq 0x90(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x90(%rsp)
movzbl (%rax), %eax
movw %ax, 0x70(%rsp)
movw %ax, 0x72(%rsp)
jmp 0xc717d
jmp 0xc717f
jmp 0xc7181
cmpl $0x0, 0x8c(%rsp)
je 0xc7190
jmp 0xc74eb
cmpq $0x0, 0x80(%rsp)
je 0xc71e9
cmpl $0x0, 0xbc(%rsp)
je 0xc71e9
movq 0xa8(%rsp), %rax
cmpl $0x40, (%rax)
jl 0xc71bf
movl $0xc, 0x8c(%rsp)
jmp 0xc71e7
movq 0x80(%rsp), %rdx
movq 0xb0(%rsp), %rax
movq 0xa8(%rsp), %rsi
movl (%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, (%rsi)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0xc725d
cmpl $0x0, 0x74(%rsp)
jne 0xc725b
movq 0xc0(%rsp), %rax
movq (%rax), %rdi
movswl 0x72(%rsp), %esi
movswl 0x70(%rsp), %edx
movq 0xa0(%rsp), %r9
leaq 0x7c(%rsp), %rcx
leaq 0x78(%rsp), %r8
callq 0xc7740
movl %eax, 0x8c(%rsp)
cmpl $0x0, 0x8c(%rsp)
je 0xc7232
jmp 0xc74eb
movq 0x80(%rsp), %rcx
movq 0xa0(%rsp), %rax
movq (%rax), %rax
movl 0x7c(%rsp), %edx
subl $0x1, %edx
movslq %edx, %rdx
movq (%rax,%rdx,8), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x18(%rax)
jmp 0xc725d
movq 0xc0(%rsp), %rax
movl 0x44(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xc74e2
cmpq $0x0, 0x80(%rsp)
jne 0xc74e2
cmpl $0x0, 0x8c(%rsp)
jne 0xc74e2
cmpl $0x0, 0x74(%rsp)
jne 0xc74e2
jmp 0xc729e
jmp 0xc72a0
jmp 0xc72a2
movswl 0x72(%rsp), %eax
movswl 0x70(%rsp), %ecx
cmpl %ecx, %eax
jg 0xc74d4
callq 0xb6b0
movq (%rax), %rax
movswl 0x72(%rsp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0xc73b5
movw 0x72(%rsp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, 0x72(%rsp)
movswl %ax, %edi
callq 0xbbb0
movw %ax, 0x20(%rsp)
movw %ax, 0x22(%rsp)
callq 0xb6b0
movq (%rax), %rax
movswl 0x72(%rsp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %ecx
andl $0x200, %ecx            # imm = 0x200
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, 0xf(%rsp)
je 0xc7350
movswl 0x72(%rsp), %edi
callq 0xbbb0
movswl %ax, %ecx
movswl 0x20(%rsp), %edx
addl $0x1, %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, 0xf(%rsp)
jne 0xc7350
movswl 0x72(%rsp), %eax
movswl 0x70(%rsp), %ecx
cmpl %ecx, %eax
setle %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0xc735a
jmp 0xc737d
movw 0x72(%rsp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, 0x72(%rsp)
movswl %ax, %edi
callq 0xbbb0
movw %ax, 0x20(%rsp)
jmp 0xc72f9
movq 0xc0(%rsp), %rax
movq (%rax), %rdi
movswl 0x22(%rsp), %esi
movswl 0x20(%rsp), %edx
movq 0xa0(%rsp), %r9
leaq 0x7c(%rsp), %rcx
leaq 0x78(%rsp), %r8
callq 0xc7740
movl %eax, 0x8c(%rsp)
jmp 0xc74c3
callq 0xb6b0
movq (%rax), %rax
movswl 0x72(%rsp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0xc74b3
movw 0x72(%rsp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, 0x72(%rsp)
movswl %ax, %edi
callq 0xb8c0
movw %ax, 0x20(%rsp)
movw %ax, 0x22(%rsp)
callq 0xb6b0
movq (%rax), %rax
movswl 0x72(%rsp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %ecx
andl $0x100, %ecx            # imm = 0x100
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, 0xe(%rsp)
je 0xc7451
movswl 0x72(%rsp), %edi
callq 0xb8c0
movswl %ax, %ecx
movswl 0x20(%rsp), %edx
addl $0x1, %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, 0xe(%rsp)
jne 0xc7451
movswl 0x72(%rsp), %eax
movswl 0x70(%rsp), %ecx
cmpl %ecx, %eax
setle %al
movb %al, 0xe(%rsp)
movb 0xe(%rsp), %al
testb $0x1, %al
jne 0xc745b
jmp 0xc747e
movw 0x72(%rsp), %ax
movw %ax, %cx
addw $0x1, %cx
movw %cx, 0x72(%rsp)
movswl %ax, %edi
callq 0xb8c0
movw %ax, 0x20(%rsp)
jmp 0xc73fa
movq 0xc0(%rsp), %rax
movq (%rax), %rdi
movswl 0x22(%rsp), %esi
movswl 0x20(%rsp), %edx
movq 0xa0(%rsp), %r9
leaq 0x7c(%rsp), %rcx
leaq 0x78(%rsp), %r8
callq 0xc7740
movl %eax, 0x8c(%rsp)
jmp 0xc74c1
movw 0x72(%rsp), %ax
addw $0x1, %ax
movw %ax, 0x72(%rsp)
jmp 0xc74c3
cmpl $0x0, 0x8c(%rsp)
je 0xc74cf
jmp 0xc74d4
jmp 0xc72a2
cmpl $0x0, 0x8c(%rsp)
je 0xc74e0
jmp 0xc74eb
jmp 0xc74e2
jmp 0xc74e4
jmp 0xc74e6
jmp 0xc6d75
movl 0x7c(%rsp), %ecx
movq 0x98(%rsp), %rax
movl %ecx, (%rax)
movl 0x78(%rsp), %ecx
movq 0xd0(%rsp), %rax
movl %ecx, (%rax)
movq 0x90(%rsp), %rcx
movq 0xc0(%rsp), %rax
movq %rcx, 0x18(%rax)
movl 0x8c(%rsp), %eax
addq $0xc8, %rsp
retq
nopw (%rax,%rax)