// File: /workspace/github_c_makefile_star2_O1/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
subq $0x18, %rsp
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 0x272d
leaq 0x8a8b(%rip), %rdi      # 0xb1ac
callq 0x20d0
xorl %eax, %eax
jmp 0x2977
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 0x274b
addl %r12d, %r13d
movq 0x28(%rbx), %rcx
movl $0x0, (%rcx)
cmpl %r15d, %r13d
jge 0x296b
movb %al, %bpl
movslq %r15d, %r10
xorl %ecx, %ecx
movdqa 0x898d(%rip), %xmm5     # 0xb110
movdqa 0x8995(%rip), %xmm6     # 0xb120
movdqa 0x899d(%rip), %xmm7     # 0xb130
pcmpeqd %xmm8, %xmm8
leaq 0xf(%rsp), %rsi
movzbl %cl, %edx
decb %cl
movslq %r13d, %r13
movl %edx, %r11d
shll $0x2, %r11d
movzbl (%r14,%r13), %r12d
cmpl $0x2d, %r12d
jne 0x28db
leaq 0x1(%r13), %rax
cmpl %r15d, %eax
je 0x298b
movzbl (%r14,%rax), %r12d
cmpq $0x5d, %r12
je 0x299c
cmpb %r12b, %cl
jae 0x29ad
cmpb %r12b, %dl
ja 0x28c9
movq 0x28(%rbx), %rdi
movq %r12, %rax
subq %rdx, %rax
movq %rax, %xmm0
andq $-0x4, %rax
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
addq $0x4, %rax
addq %r11, %rdi
addq $0xc, %rdi
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 0x285a
movl %ebp, -0xc(%rdi,%r8,4)
pxor %xmm8, %xmm2
pextrw $0x4, %xmm2, %r9d
testb $0x1, %r9b
je 0x2870
movl %ebp, -0x8(%rdi,%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 0x28ac
movl %ebp, -0x4(%rdi,%r8,4)
pextrw $0x4, %xmm1, %r9d
testb $0x1, %r9b
je 0x28bc
movl %ebp, (%rdi,%r8,4)
addq $0x4, %r8
cmpq %r8, %rax
jne 0x2813
addq $0x2, %r13
cmpq %r10, %r13
jl 0x27ac
jmp 0x2970
cmpl $0x5d, %r12d
je 0x2986
cmpl $0x5c, %r12d
jne 0x294b
movb %r12b, 0xf(%rsp)
movslq %r13d, %rax
incq %rax
cmpl %r15d, %eax
je 0x2990
movb (%r14,%rax), %r12b
movb %r12b, 0xf(%rsp)
movq %rbx, %rdi
movl %ebp, %edx
movl $0x1, %ecx
movq %r10, 0x10(%rsp)
callq 0x2270
leaq 0xf(%rsp), %rsi
pcmpeqd %xmm8, %xmm8
movdqa 0x8802(%rip), %xmm7     # 0xb130
movdqa 0x87ea(%rip), %xmm6     # 0xb120
movdqa 0x87d2(%rip), %xmm5     # 0xb110
movq 0x10(%rsp), %r10
addl $0x2, %r13d
xorl %ecx, %ecx
jmp 0x295e
movb %r12b, 0xf(%rsp)
movq 0x28(%rbx), %rax
movl %ebp, (%rax,%r12,4)
incl %r13d
movl %r12d, %ecx
xorl %eax, %eax
cmpl %r15d, %r13d
jl 0x279d
jmp 0x2972
movb 0xf(%rsp), %r12b
xorl %eax, %eax
movb %r12b, 0xf(%rsp)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r13d, %eax
jmp 0x2972
movb %r12b, 0xf(%rsp)
leaq 0x87fc(%rip), %rdi      # 0xb193
jmp 0x2721
movb %r12b, 0xf(%rsp)
movq 0x28(%rbx), %rcx
movl %ebp, 0xb4(%rcx)
jmp 0x2977
movb %r12b, 0xf(%rsp)
leaq 0x87b8(%rip), %rdi      # 0xb171
jmp 0x2721