// File: /workspace/github_c_makefile_star2_O0/jondurbin[P]dre2/src/dre2_parse.c
// Function: dre2_first_or_last_cost
struct dre2_fl_cost dre2_first_or_last_cost( struct dre2 *graph, int *minimal )
{
  int i, j, k;
  int f_n_count, f_c_count, f_frequency;
  int l_n_count, l_c_count, l_frequency;
  int next_count, *next_ptr;
  struct dre2_node *node;
  struct dre2_fl_cost cost;
  unsigned char *temp;
  int *tp, *original;

  f_n_count = graph->v[0].n_count;
  f_c_count = 0;
  f_frequency = 0;

  l_n_count = graph->v[graph->count - 1].p_count;
  l_c_count = 0;
  l_frequency = 0;

  for ( i = 0; i < graph->v[0].n_count; i++ )
  {
    if ( !minimal[graph->v[0].n[i]] && !( graph->options & DRE2_GREEDY ) && graph->count > 3 )
      f_n_count--;
  }
  for ( i = 0; i < graph->v[graph->count - 1].p_count; i++ )
  {
    if ( !minimal[graph->v[graph->count - 1].p[i]] && !( graph->options & DRE2_GREEDY ) && graph->count > 3 )
      l_n_count--;
  }

  // Get number of possible chars in the first reachable nodes.
  tp = ( int * )malloc( sizeof( int ) * RANGE );
  temp = ( unsigned char * )malloc( sizeof( unsigned char ) * RANGE );

  original = graph->starting_chars;
  for ( k = 0; k < 2; k++ )
  {
    graph->starting_chars = tp;
    for ( i = 0; i < RANGE; i++ )
    {
      tp[i] = false;
      temp[i] = '\0';
    }

    if ( k == 0 )
    {
      next_count = graph->v[0].n_count;
      next_ptr = graph->v[0].n;
    } else
    {
      next_count = graph->v[graph->count - 1].p_count;
      next_ptr = graph->v[graph->count - 1].p;
    }
    for ( i = 0; i < next_count; i++ )
    {
      if ( !minimal[next_ptr[i]] && !( graph->options & DRE2_GREEDY ) && graph->count > 3 )
        continue;
      dre2_set_chars( graph, next_ptr[i] );
      for ( j = 1; j < RANGE; j++ )
      {
        if ( tp[j] && !dre2_contains_char( temp, j ) )
        {
          if ( k == 0 )
          {
            f_c_count++;
            temp[f_c_count - 1] = j;
            f_frequency += dre2_frequency[j];
          } else
          {
            l_c_count++;
            temp[l_c_count - 1] = j;
            l_frequency += dre2_frequency[j];
          }
        } else
        {
        }
      }
    }
  }
  free( temp ); temp = NULL;
  free( tp ); tp = NULL;
  graph->starting_chars = original;

  cost.f_n_count = f_n_count;
  cost.f_c_count = f_c_count;
  cost.f_frequency = f_frequency;
  cost.l_n_count = l_n_count;
  cost.l_c_count = l_c_count;
  cost.l_frequency = l_frequency;

  return cost;
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x8(%rsp)
movq %rdi, 0x10(%rsp)
movq %rsi, 0x70(%rsp)
movq %rdx, 0x68(%rsp)
movq 0x70(%rsp), %rax
movq (%rax), %rax
movl 0x10(%rax), %eax
movl %eax, 0x58(%rsp)
movl $0x0, 0x54(%rsp)
movl $0x0, 0x50(%rsp)
movq 0x70(%rsp), %rax
movq (%rax), %rax
movq 0x70(%rsp), %rcx
movl 0x8(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
movl %eax, 0x4c(%rsp)
movl $0x0, 0x48(%rsp)
movl $0x0, 0x44(%rsp)
movl $0x0, 0x64(%rsp)
movl 0x64(%rsp), %eax
movq 0x70(%rsp), %rcx
movq (%rcx), %rcx
cmpl 0x10(%rcx), %eax
jge 0x4a9c
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
movq (%rcx), %rcx
movq 0x8(%rcx), %rcx
movslq 0x64(%rsp), %rdx
movslq (%rcx,%rdx,4), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x4a8d
movq 0x70(%rsp), %rax
movl 0x43c(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x4a8d
movq 0x70(%rsp), %rax
cmpl $0x3, 0x8(%rax)
jle 0x4a8d
movl 0x58(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x58(%rsp)
jmp 0x4a8f
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0x4a33
movl $0x0, 0x64(%rsp)
movl 0x64(%rsp), %eax
movq 0x70(%rsp), %rcx
movq (%rcx), %rcx
movq 0x70(%rsp), %rdx
movl 0x8(%rdx), %edx
subl $0x1, %edx
movslq %edx, %rdx
shlq $0x6, %rdx
addq %rdx, %rcx
cmpl 0x20(%rcx), %eax
jge 0x4b3a
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
movq (%rcx), %rcx
movq 0x70(%rsp), %rdx
movl 0x8(%rdx), %edx
subl $0x1, %edx
movslq %edx, %rdx
shlq $0x6, %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
movslq 0x64(%rsp), %rdx
movslq (%rcx,%rdx,4), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x4b28
movq 0x70(%rsp), %rax
movl 0x43c(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x4b28
movq 0x70(%rsp), %rax
cmpl $0x3, 0x8(%rax)
jle 0x4b28
movl 0x4c(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x4b2a
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0x4aa4
movl $0x400, %edi            # imm = 0x400
callq 0x2280
movq %rax, 0x20(%rsp)
movl $0x100, %edi            # imm = 0x100
callq 0x2280
movq %rax, 0x28(%rsp)
movq 0x70(%rsp), %rax
movq 0x418(%rax), %rax
movq %rax, 0x18(%rsp)
movl $0x0, 0x5c(%rsp)
cmpl $0x2, 0x5c(%rsp)
jge 0x4d9e
movq 0x20(%rsp), %rcx
movq 0x70(%rsp), %rax
movq %rcx, 0x418(%rax)
movl $0x0, 0x64(%rsp)
cmpl $0x100, 0x64(%rsp)      # imm = 0x100
jge 0x4bcb
movq 0x20(%rsp), %rax
movslq 0x64(%rsp), %rcx
movl $0x0, (%rax,%rcx,4)
movq 0x28(%rsp), %rax
movslq 0x64(%rsp), %rcx
movb $0x0, (%rax,%rcx)
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0x4b95
cmpl $0x0, 0x5c(%rsp)
jne 0x4bf4
movq 0x70(%rsp), %rax
movq (%rax), %rax
movl 0x10(%rax), %eax
movl %eax, 0x40(%rsp)
movq 0x70(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
jmp 0x4c3e
movq 0x70(%rsp), %rax
movq (%rax), %rax
movq 0x70(%rsp), %rcx
movl 0x8(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
movl %eax, 0x40(%rsp)
movq 0x70(%rsp), %rax
movq (%rax), %rax
movq 0x70(%rsp), %rcx
movl 0x8(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq %rax, 0x38(%rsp)
movl $0x0, 0x64(%rsp)
movl 0x64(%rsp), %eax
cmpl 0x40(%rsp), %eax
jge 0x4d8c
movq 0x68(%rsp), %rax
movq 0x38(%rsp), %rcx
movslq 0x64(%rsp), %rdx
movslq (%rcx,%rdx,4), %rcx
cmpl $0x0, (%rax,%rcx,4)
jne 0x4c90
movq 0x70(%rsp), %rax
movl 0x43c(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x4c90
movq 0x70(%rsp), %rax
cmpl $0x3, 0x8(%rax)
jle 0x4c90
jmp 0x4d7c
movq 0x70(%rsp), %rdi
movq 0x38(%rsp), %rax
movslq 0x64(%rsp), %rcx
movl (%rax,%rcx,4), %esi
callq 0x2240
movl $0x1, 0x60(%rsp)
cmpl $0x100, 0x60(%rsp)      # imm = 0x100
jge 0x4d7a
movq 0x20(%rsp), %rax
movslq 0x60(%rsp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x4d66
movq 0x28(%rsp), %rdi
movl 0x60(%rsp), %eax
movzbl %al, %esi
callq 0x2140
cmpl $0x0, %eax
jne 0x4d66
cmpl $0x0, 0x5c(%rsp)
jne 0x4d2a
movl 0x54(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x54(%rsp)
movl 0x60(%rsp), %eax
movb %al, %dl
movq 0x28(%rsp), %rax
movl 0x54(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movslq 0x60(%rsp), %rcx
movq 0xd2cb(%rip), %rax      # 0x11fe8
movl (%rax,%rcx,4), %eax
addl 0x50(%rsp), %eax
movl %eax, 0x50(%rsp)
jmp 0x4d64
movl 0x48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
movl 0x60(%rsp), %eax
movb %al, %dl
movq 0x28(%rsp), %rax
movl 0x48(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movslq 0x60(%rsp), %rcx
movq 0xd28f(%rip), %rax      # 0x11fe8
movl (%rax,%rcx,4), %eax
addl 0x44(%rsp), %eax
movl %eax, 0x44(%rsp)
jmp 0x4d68
jmp 0x4d68
jmp 0x4d6a
movl 0x60(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x60(%rsp)
jmp 0x4caf
jmp 0x4d7c
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0x4c46
jmp 0x4d8e
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x4b71
movq 0x28(%rsp), %rdi
callq 0x2070
movq $0x0, 0x28(%rsp)
movq 0x20(%rsp), %rdi
callq 0x2070
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rax
movq $0x0, 0x20(%rsp)
movq 0x18(%rsp), %rsi
movq 0x70(%rsp), %rdx
movq %rsi, 0x418(%rdx)
movl 0x58(%rsp), %edx
movl %edx, (%rcx)
movl 0x54(%rsp), %edx
movl %edx, 0x4(%rcx)
movl 0x50(%rsp), %edx
movl %edx, 0x8(%rcx)
movl 0x4c(%rsp), %edx
movl %edx, 0xc(%rcx)
movl 0x48(%rsp), %edx
movl %edx, 0x10(%rcx)
movl 0x44(%rsp), %edx
movl %edx, 0x14(%rcx)
addq $0x78, %rsp
retq
nopl (%rax)