// File: /workspace/github_c_makefile_star2_O1/jondurbin[P]dre2/src/dre2_match.c
// Function: dre2_match
struct dre2_match_value dre2_match( struct dre2 *graph, unsigned char *input )
{
  int i, length;
  struct dre2_match_value result;
  int *r_temp, *reachable, *state;

  result.matched = false;

  // Make sure the string is even long enough before attempting matching.
  length = strlen( input );

  if ( length < graph->min_length )
    return result;

  if ( graph->options & DRE2_THREAD_SAFE )
  {
    r_temp = ( int * )malloc( sizeof( int ) * graph->count );
    reachable = ( int * )malloc( sizeof( int ) * graph->count );
    state = ( int * )calloc( graph->count, sizeof( int ) );
  } else
  {
    r_temp = graph->r_temp;
    reachable = graph->reachable;
    state = graph->state;
  }

  if ( graph->options & DRE2_FULL_MATCH )
  {
    result = dre2_full_match( graph, input, length, r_temp, reachable, state );
  } else
  {
    switch ( graph->match_method )
    {
      case DRE2_SN_SC_H:
        result = dre2_sn_sc_horspool( graph, input, length, r_temp, reachable, state );
        break;
      case DRE2_SN_SC:
        result = dre2_sn_sc( graph, input, length, r_temp, reachable, state );
        break;
      case DRE2_SN_MC_H:
        result = dre2_sn_mc_horspool( graph, input, length, r_temp, reachable, state );
        break;
      case DRE2_SN_MC:
        result = dre2_sn_mc( graph, input, length, r_temp, reachable, state );
        break;
      case DRE2_MN:
        result = dre2_mn( graph, input, length, r_temp, reachable, state );
        break;
    }
  }

  if ( result.matched && ( graph->options & DRE2_GREEDY ) && graph->has_loop )
    result = dre2_expanded_match( graph, input, length, r_temp, reachable, state, &result );

  if ( ( graph->options & DRE2_THREAD_SAFE ) || graph->count >= RANGE )
  {
    free( reachable ); reachable = NULL;
    free( r_temp ); r_temp = NULL;
    free( state ); state = NULL;
  }
  return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r15
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x2120
movq %rax, %rbp
cmpl %ebp, 0x40c(%rbx)
jle 0x6f58
xorl %r13d, %r13d
jmp 0x70ca
movl 0x43c(%rbx), %r13d
testb $0x10, %r13b
jne 0x6f81
movq 0x440(%rbx), %rax
movq %rax, 0x8(%rsp)
movq 0x448(%rbx), %r12
movq 0x450(%rbx), %rax
jmp 0x6fb2
movslq 0x8(%rbx), %r14
leaq (,%r14,4), %r12
movq %r12, %rdi
callq 0x22a0
movq %rax, 0x8(%rsp)
movq %r12, %rdi
callq 0x22a0
movq %rax, %r12
movl $0x4, %esi
movq %r14, %rdi
callq 0x2200
testb $0x2, %r13b
movq %r12, 0x18(%rsp)
movq %rax, 0x10(%rsp)
jne 0x6ffc
movl 0x424(%rbx), %edx
cmpq $0x4, %rdx
ja 0x7160
leaq 0x1123(%rip), %rcx      # 0x80fc
movslq (%rcx,%rdx,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %edx
movq 0x8(%rsp), %rcx
movq %r12, %r8
movq %rax, %r9
callq 0x20e0
jmp 0x7014
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %edx
movq 0x8(%rsp), %rcx
movq %r12, %r8
movq %rax, %r9
callq 0x2300
movq %rax, %r13
movq %rax, %r12
shrq $0x20, %r12
movq %rdx, %r14
shrq $0x20, %r14
testl %r13d, %r13d
je 0x7094
testb $0x1, 0x43c(%rbx)
je 0x7094
cmpl $0x0, 0x868(%rbx)
je 0x7094
movslq %edx, %rcx
addq %r15, %rcx
leaq 0x20(%rsp), %rdi
xorl %r12d, %r12d
movl $0x1, %r13d
movq %rbx, %rsi
movq %rdx, %r14
movq %rcx, %rdx
xorl %r8d, %r8d
movl $0x1, %r9d
pushq 0x10(%rsp)
pushq 0x20(%rsp)
pushq 0x18(%rsp)
pushq %rbp
callq 0x2290
movq %r14, %rdx
addq $0x20, %rsp
leaq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
movl %eax, %r14d
subl %r15d, %r14d
incl %r14d
testq %rax, %rax
cmovel %r12d, %r14d
testb $0x10, 0x43c(%rbx)
jne 0x70a6
cmpl $0x100, 0x8(%rbx)       # imm = 0x100
jl 0x70ca
movq 0x18(%rsp), %rdi
movq %rdx, %rbx
callq 0x2070
movq 0x8(%rsp), %rdi
callq 0x2070
movq 0x10(%rsp), %rdi
callq 0x2070
movq %rbx, %rdx
shlq $0x20, %r12
movl %r13d, %eax
orq %r12, %rax
shlq $0x20, %r14
movl %edx, %edx
orq %r14, %rdx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %edx
movq 0x8(%rsp), %rcx
movq %r12, %r8
movq %rax, %r9
callq 0x21a0
jmp 0x7014
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %edx
movq 0x8(%rsp), %rcx
movq %r12, %r8
movq %rax, %r9
callq 0x2250
jmp 0x7014
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %edx
movq 0x8(%rsp), %rcx
movq %r12, %r8
movq %rax, %r9
callq 0x2220
jmp 0x7014
movq %rbx, %rdi
movq %r15, %rsi
movl %ebp, %edx
movq 0x8(%rsp), %rcx
movq %r12, %r8
movq %rax, %r9
callq 0x2350
jmp 0x7014
xorl %r13d, %r13d
jmp 0x7025