// File: /workspace/github_c_makefile_star2_O3/jondurbin[P]dre2/src/dre2_parse.c
// Function: dre2_character_class
int dre2_character_class( struct dre2_node *node, unsigned char *re, int s )
{
  int length = strlen(re);
  int i = s;
  int action;
  int k;

  if ( re[i] == ']' )
  {
    printf( "No content in charcter class.\n" );
    return false;
  } else if ( re[i] == '^' )
  {
    i++;
    action = false;
  } else
  {
    action = true;
  }

  for ( k = 0; k < RANGE; k++ )
    node->possible[k] = action == true ? false : true;
  node->possible[0] = false;

  unsigned char c;
  unsigned char last = '\0';
  while ( i < length )
  {
    c = re[i];
    if ( c == '\\' )
    {
      i++;
      if ( i == length )
      {
        printf( "Invalid character class.\n" );
        return false;
      }
      c = re[i];
      dre2_predefined_class( node, &c, action, true );
      last = '\0';
      i++;
      continue;
    } else if ( c == '-' )
    {
      i++;
      if ( i == length )
      {
        printf( "Invalid character class.\n" );
        return false;
      }
      c = re[i];
      if ( c == ']' )
      {
        node->possible['-'] = action;
        return i;
      } else
      {
        if ( !last || last > c )
        {
          printf( "Invalid range in character class.\n" );
          return false;
        }
        for ( k = last; k <= c; k++ )
          node->possible[k] = action;
      }
      i++;
      continue;
    } else if ( c == ']' )
    {
      return i;
    } else
    {
      node->possible[c] = action;
    }
    i++;
    last = c;
  }
  return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r12d
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x2120
movq %rax, %r15
movslq %r12d, %rax
movb (%r14,%rax), %al
cmpb $0x5d, %al
jne 0x2724
leaq 0x8a92(%rip), %rdi      # 0xb1ac
callq 0x20d0
jmp 0x293a
xorl %ebp, %ebp
xorl %r13d, %r13d
cmpb $0x5e, %al
setne %al
sete %r13b
movq 0x28(%rbx), %rcx
movd %r13d, %xmm0
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
xorl %edx, %edx
movdqu %xmm0, (%rcx,%rdx,4)
addq $0x4, %rdx
cmpq $0x100, %rdx            # imm = 0x100
jne 0x2742
addl %r12d, %r13d
movl $0x0, (%rcx)
cmpl %r15d, %r13d
jge 0x293a
movb %al, %bpl
movslq %r15d, %r12
xorl %ecx, %ecx
movdqa 0x899a(%rip), %xmm5     # 0xb110
movdqa 0x89a2(%rip), %xmm6     # 0xb120
movdqa 0x89aa(%rip), %xmm7     # 0xb130
pcmpeqd %xmm8, %xmm8
leaq 0x7(%rsp), %rsi
movzbl %cl, %edx
decb %cl
movslq %r13d, %r13
movl %edx, %r10d
shll $0x2, %r10d
movzbl (%r14,%r13), %eax
cmpl $0x2d, %eax
jne 0x28c7
leaq 0x1(%r13), %rax
cmpl %r15d, %eax
je 0x2950
movzbl (%r14,%rax), %edi
cmpq $0x5d, %rdi
je 0x295c
cmpb %dil, %cl
jae 0x2968
cmpb %dil, %dl
ja 0x28b8
movq 0x28(%rbx), %rax
subq %rdx, %rdi
movq %rdi, %xmm0
andq $-0x4, %rdi
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
addq $0x4, %rdi
addq %r10, %rax
addq $0xc, %rax
pxor %xmm7, %xmm0
xorl %r8d, %r8d
movq %r8, %xmm1
pshufd $0x44, %xmm1, %xmm1     # xmm1 = xmm1[0,1,0,1]
movdqa %xmm1, %xmm2
por %xmm6, %xmm2
pxor %xmm7, %xmm2
movdqa %xmm2, %xmm3
pcmpgtd %xmm0, %xmm3
pcmpeqd %xmm0, %xmm2
pshufd $0xf5, %xmm2, %xmm4     # xmm4 = xmm2[1,1,3,3]
pand %xmm3, %xmm4
pshufd $0xf5, %xmm3, %xmm2     # xmm2 = xmm3[1,1,3,3]
por %xmm4, %xmm2
movd %xmm2, %r9d
notl %r9d
testb $0x1, %r9b
je 0x2849
movl %ebp, -0xc(%rax,%r8,4)
pxor %xmm8, %xmm2
pextrw $0x4, %xmm2, %r9d
testb $0x1, %r9b
je 0x285f
movl %ebp, -0x8(%rax,%r8,4)
por %xmm5, %xmm1
pxor %xmm7, %xmm1
movdqa %xmm1, %xmm2
pcmpgtd %xmm0, %xmm2
pcmpeqd %xmm0, %xmm1
pshufd $0xf5, %xmm1, %xmm3     # xmm3 = xmm1[1,1,3,3]
pand %xmm2, %xmm3
pshufd $0xf5, %xmm2, %xmm1     # xmm1 = xmm2[1,1,3,3]
por %xmm3, %xmm1
pxor %xmm8, %xmm1
pextrw $0x0, %xmm1, %r9d
testb $0x1, %r9b
je 0x289b
movl %ebp, -0x4(%rax,%r8,4)
pextrw $0x4, %xmm1, %r9d
testb $0x1, %r9b
je 0x28ab
movl %ebp, (%rax,%r8,4)
addq $0x4, %r8
cmpq %r8, %rdi
jne 0x2802
addq $0x2, %r13
cmpq %r12, %r13
jl 0x279f
jmp 0x293a
cmpl $0x5d, %eax
je 0x294b
cmpl $0x5c, %eax
jne 0x291d
movslq %r13d, %rax
incq %rax
cmpl %r15d, %eax
je 0x2950
movb (%r14,%rax), %al
movb %al, 0x7(%rsp)
movq %rbx, %rdi
movl %ebp, %edx
movl $0x1, %ecx
callq 0x2270
leaq 0x7(%rsp), %rsi
pcmpeqd %xmm8, %xmm8
movdqa 0x882b(%rip), %xmm7     # 0xb130
movdqa 0x8813(%rip), %xmm6     # 0xb120
movdqa 0x87fb(%rip), %xmm5     # 0xb110
addl $0x2, %r13d
xorl %ecx, %ecx
jmp 0x292d
movb %al, 0x7(%rsp)
movq 0x28(%rbx), %rcx
movl %ebp, (%rcx,%rax,4)
incl %r13d
movl %eax, %ecx
xorl %eax, %eax
cmpl %r15d, %r13d
jl 0x2790
jmp 0x293c
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r13d, %eax
jmp 0x293c
leaq 0x883c(%rip), %rdi      # 0xb193
jmp 0x271a
movq 0x28(%rbx), %rcx
movl %ebp, 0xb4(%rcx)
jmp 0x293c
leaq 0x8802(%rip), %rdi      # 0xb171
jmp 0x271a