// File: /workspace/github_c_makefile_star2_O1/jondurbin[P]dre2/src/dre2_parse.c
// Function: dre2_strip_groups
void dre2_strip_groups( struct dre2 *graph, struct dre2 *new_graph, struct dre2_node **new_nodes, int *minimal, int **new_minimal, int *new_minimal_count, int **minimal_id )
{
  int i, j, k;
  struct dre2_node *nodes, *node;
  int node_count;
  int removed, offset;
  int *reachable, *visited, *temp_minimal;
  int *min_reachable, *min_visited;

  // Allocate some memory.
  reachable = ( int * )malloc( sizeof( int ) * graph->count );
  visited = ( int * )malloc( sizeof( int ) * graph->count );
  temp_minimal = ( int * )malloc( sizeof( int ) );
  min_reachable = ( int * )malloc( sizeof( int ) * graph->count );
  min_visited = ( int * )malloc( sizeof( int ) * graph->count );

  for ( i = 0; i < graph->count; i++ )
    ( *new_minimal )[i] = false;

  node_count = 0;
  *new_minimal_count = 0;
  for ( i = 0; i < graph->count; i++ )
  {
    // Initialize reachable nodes to all false.
    for ( j = 0; j < graph->count; j++ )
    {
      reachable[j] = false;
      visited[j] = false;
      min_reachable[j] = false;
      min_visited[j] = false;
    }
    dre2_reachable( graph, &reachable, &visited, i );
    dre2_min_reachable( graph, &min_reachable, &min_visited, i );

    if ( ( graph->v[i].c != DRE2_GROUP_OPEN && graph->v[i].c != DRE2_GROUP_CLOSE ) || ( i == 0 || i == graph->count - 1 ) )
    {
      // Add node to our min tree.
      dre2_add_node( new_nodes, &node_count, graph->v[i].c, &temp_minimal, true );

      ( *new_nodes )[node_count - 1].min_n_count = 0;
      ( *new_nodes )[node_count - 1].min_n = NULL;
      if ( minimal[i] )
      {
        ( *new_minimal )[node_count - 1] = true;
        *new_minimal_count = *new_minimal_count + 1;
        ( *minimal_id )[*new_minimal_count - 1] = node_count - 1;
      }
      graph->v[i].min_id = node_count - 1;
      if ( graph->v[i].c == DRE2_CHAR_CLASS )
      {
        for ( j = 0; j < RANGE; j++ )
          ( *new_nodes )[node_count - 1].possible[j] = graph->v[i].possible[j];
      }

      // Find the reachable nodes.
      for ( j = 0; j < graph->count; j++ )
      {
        if ( reachable[j] )
          dre2_add_neighbor( new_nodes, node_count - 1, j );
        if ( min_reachable[j] && minimal[j] )
        {
          ( *new_nodes )[node_count - 1].min_n_count++;
          if ( ( *new_nodes )[node_count - 1].min_n == NULL )
            ( *new_nodes )[node_count - 1].min_n = ( int * )malloc( sizeof( int ) * graph->count );
          ( *new_nodes )[node_count - 1].min_n[( *new_nodes )[node_count - 1].min_n_count - 1] = j;
        }
      }
    }
  }

  // Update the node IDs.
  for ( i = 0; i < node_count; i++ )
  {
    for ( j = 0; j < ( *new_nodes )[i].n_count; j++ )
      ( *new_nodes )[i].n[j] = graph->v[( *new_nodes )[i].n[j]].min_id;
  }

  for ( i = 0; i < *new_minimal_count; i++ )
  {
    for ( j = 0; j < ( *new_nodes )[( *minimal_id )[i]].min_n_count; j++ )
      ( *new_nodes )[( *minimal_id )[i]].min_n[j] = graph->v[( *new_nodes )[( *minimal_id )[i]].min_n[j]].min_id;
  }

  // Setup the minimized graph.
  new_graph->count = node_count;

  // Free the temp reachable nodes array.
  free( reachable );
  free( visited );
  free( temp_minimal );
  free( min_reachable );
  free( min_visited );

  // Set them all to null.
  reachable = NULL;
  visited = NULL;
  temp_minimal = NULL;
  min_reachable = NULL;
  min_visited = NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r9, %r14
movq %r8, 0x18(%rsp)
movq %rcx, 0x40(%rsp)
movq %rdx, %r13
movq %rsi, 0x50(%rsp)
movq %rdi, %r15
movslq 0x8(%rdi), %rbx
shlq $0x2, %rbx
movq %rbx, %rdi
callq 0x22a0
movq %rax, 0x38(%rsp)
movq %rax, 0x70(%rsp)
movq %rbx, %rdi
callq 0x22a0
movq %rax, 0x30(%rsp)
movq %rax, 0x68(%rsp)
movl $0x4, %edi
callq 0x22a0
movq %rax, 0x48(%rsp)
movq %rbx, %rdi
callq 0x22a0
movq %rax, 0x10(%rsp)
movq %rax, 0x60(%rsp)
movq %rbx, %rdi
callq 0x22a0
movq %rax, 0x28(%rsp)
movq %rax, 0x58(%rsp)
cmpl $0x0, 0x8(%r15)
jle 0x3f9f
movq 0x18(%rsp), %rax
movq (%rax), %rax
xorl %ecx, %ecx
movl $0x0, (%rax,%rcx,4)
incq %rcx
movslq 0x8(%r15), %rdx
cmpq %rdx, %rcx
jl 0x3f8c
xorl %eax, %eax
movl %eax, 0x4(%rsp)
movq %r14, 0x20(%rsp)
movl %eax, (%r14)
cmpl %eax, 0x8(%r15)
movq 0x38(%rsp), %rbx
jle 0x41bb
xorl %ebp, %ebp
cmpl $0x0, 0x8(%r15)
jle 0x4014
movl 0x8(%r15), %r14d
cmpl $0x2, %r14d
movl $0x1, %eax
cmovll %eax, %r14d
shlq $0x2, %r14
movq %rbx, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x2180
movq 0x30(%rsp), %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x2180
movq 0x10(%rsp), %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x2180
movq 0x28(%rsp), %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x2180
movq %r15, %rdi
leaq 0x70(%rsp), %rsi
leaq 0x68(%rsp), %rdx
movl %ebp, %ecx
callq 0x21c0
movq %r15, %rdi
leaq 0x60(%rsp), %rsi
leaq 0x58(%rsp), %rdx
movl %ebp, %ecx
callq 0x2060
movq (%r15), %rax
movq %rbp, %r12
shlq $0x6, %r12
movl (%rax,%r12), %edx
cmpl $-0x1, %edx
movq %rbp, 0x8(%rsp)
je 0x4066
cmpl $-0x2, %edx
setne %al
testq %rbp, %rbp
sete %cl
orb %al, %cl
je 0x406b
jmp 0x407c
testq %rbp, %rbp
je 0x407c
movl 0x8(%r15), %eax
decl %eax
cmpq %rax, 0x8(%rsp)
jne 0x41a6
movq %r13, %rdi
leaq 0x4(%rsp), %rsi
leaq 0x48(%rsp), %rcx
movl $0x1, %r8d
callq 0x20b0
movq (%r13), %rax
movslq 0x4(%rsp), %rbp
movq %rbp, %r14
shlq $0x6, %r14
movl $0x0, -0x8(%rax,%r14)
movq $0x0, -0x10(%rax,%r14)
movq 0x40(%rsp), %rax
movq 0x8(%rsp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x40f4
movq 0x18(%rsp), %rax
movq (%rax), %rax
movl $0x1, -0x4(%rax,%rbp,4)
movq 0x20(%rsp), %rdx
movslq (%rdx), %rax
leal 0x1(%rax), %ecx
movl %ecx, (%rdx)
leal -0x1(%rbp), %ecx
movq 0xb0(%rsp), %rdx
movq (%rdx), %rdx
movl %ecx, (%rdx,%rax,4)
decl %ebp
movq (%r15), %rax
movl %ebp, 0x24(%rax,%r12)
cmpl $-0x3, (%rax,%r12)
jne 0x4127
movq 0x28(%rax,%r12), %rax
movq (%r13), %rcx
movq -0x18(%rcx,%r14), %rcx
xorl %edx, %edx
movl (%rax,%rdx,4), %esi
movl %esi, (%rcx,%rdx,4)
incq %rdx
cmpq $0x100, %rdx            # imm = 0x100
jne 0x4115
cmpl $0x0, 0x8(%r15)
jle 0x41a6
xorl %r12d, %r12d
cmpl $0x0, (%rbx,%r12,4)
je 0x4145
movq %r13, %rdi
movl %ebp, %esi
movl %r12d, %edx
callq 0x21d0
movq 0x10(%rsp), %rax
cmpl $0x0, (%rax,%r12,4)
je 0x419a
movq 0x40(%rsp), %rax
cmpl $0x0, (%rax,%r12,4)
je 0x419a
movq (%r13), %rbx
incl -0x8(%rbx,%r14)
cmpq $0x0, -0x10(%rbx,%r14)
jne 0x4182
addq %r14, %rbx
movslq 0x8(%r15), %rdi
shlq $0x2, %rdi
callq 0x22a0
movq %rax, -0x10(%rbx)
movq (%r13), %rax
movq -0x10(%rax,%r14), %rcx
movslq -0x8(%rax,%r14), %rax
movl %r12d, -0x4(%rcx,%rax,4)
movq 0x38(%rsp), %rbx
incq %r12
movslq 0x8(%r15), %rax
cmpq %rax, %r12
jl 0x4131
movq 0x8(%rsp), %rbp
incq %rbp
movslq 0x8(%r15), %rax
cmpq %rax, %rbp
jl 0x3fbe
movslq 0x4(%rsp), %rax
testq %rax, %rax
movq 0x20(%rsp), %r11
jle 0x4210
movq (%r13), %rcx
xorl %edx, %edx
movq %rdx, %rsi
shlq $0x6, %rsi
cmpl $0x0, 0x10(%rcx,%rsi)
jle 0x4208
addq %rcx, %rsi
movq (%r15), %rdi
movq 0x8(%rsi), %r8
xorl %r9d, %r9d
movslq (%r8,%r9,4), %r10
shlq $0x6, %r10
movl 0x24(%rdi,%r10), %r10d
movl %r10d, (%r8,%r9,4)
incq %r9
movslq 0x10(%rsi), %r10
cmpq %r10, %r9
jl 0x41eb
incq %rdx
cmpq %rax, %rdx
jne 0x41d0
cmpl $0x0, (%r11)
jle 0x427c
movq (%r13), %rcx
movq 0xb0(%rsp), %rdx
movq (%rdx), %rdx
xorl %esi, %esi
movslq (%rdx,%rsi,4), %r8
movq %r8, %rdi
shlq $0x6, %rdi
cmpl $0x0, 0x38(%rcx,%rdi)
jle 0x4271
movq (%r15), %rdi
xorl %r9d, %r9d
shlq $0x6, %r8
movq 0x30(%rcx,%r8), %r8
movslq (%r8,%r9,4), %r10
shlq $0x6, %r10
movl 0x24(%rdi,%r10), %r10d
movl %r10d, (%r8,%r9,4)
incq %r9
movslq (%rdx,%rsi,4), %r8
movq %r8, %r10
shlq $0x6, %r10
movslq 0x38(%rcx,%r10), %r10
cmpq %r10, %r9
jl 0x423f
incq %rsi
movslq (%r11), %rdi
cmpq %rdi, %rsi
jl 0x4227
movq 0x50(%rsp), %rcx
movl %eax, 0x8(%rcx)
movq %rbx, %rdi
callq 0x2070
movq 0x30(%rsp), %rdi
callq 0x2070
movq 0x48(%rsp), %rdi
callq 0x2070
movq 0x10(%rsp), %rdi
callq 0x2070
movq 0x28(%rsp), %rdi
callq 0x2070
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq