// File: /workspace/github_c_makefile_star2_O3/jondurbin[P]dre2/src/dre2_parse.c
// Function: dre2_find_paths_recursive
int dre2_find_paths_recursive( struct dre2 *graph, int id, int *path_count, struct dre2_path **paths )
{
  int i, j;
  int size, last;
  struct dre2_path *path, *next_path;

  if ( *path_count >= 1024 )
  {
    for ( i = 0; i < *path_count; i++ )
    {
      if ( ( *paths )[i].nodes != NULL )
      {
        free( ( *paths )[i].nodes );
        ( *paths )[i].nodes = NULL;
      }
    }
    free( *paths );
    *paths = NULL;
    *path_count = 0;
    return false;
  }

  size = ( *paths )[id].count;
  last = ( *paths )[id].nodes[( *paths )[id].count - 1];

  for ( i = 0; i < graph->v[last].min_n_count; i++ )
  {
    path = &( *paths )[id];
    if ( i == 0 )
    {
      // For the first possible node, just add it to the current path.
      ( *paths )[id].count++;
      ( *paths )[id].nodes[( *paths )[id].count - 1] = graph->v[last].min_n[i];
      if ( dre2_find_paths_recursive( graph, id, path_count, paths ) == false )
        return false;
    } else
    {
      // For the other nodes, split the path.
      *path_count = *path_count + 1;
      *paths = ( struct dre2_path * )realloc( *paths, sizeof( struct dre2_path ) * *path_count );
      next_path = &( *paths )[*path_count - 1];
      next_path->count = size + 1;
      next_path->nodes = ( int * )malloc( sizeof( int ) * graph->count );

      // Copy the previous nodes and add the current one.
      for ( j = 0; j < size; j++ )
        next_path->nodes[j] = ( *paths )[id].nodes[j];
      next_path->nodes[size] = graph->v[last].min_n[i];
      if ( dre2_find_paths_recursive( graph, *path_count - 1, path_count, paths ) == false )
        return false;
    }
  }
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r14
movq %rdx, %rbx
movl (%rdx), %eax
cmpl $0x400, %eax            # imm = 0x400
jl 0x2da5
xorl %r15d, %r15d
xorl %r12d, %r12d
movq (%r14), %rcx
movq (%rcx,%r15), %rdi
testq %rdi, %rdi
je 0x2d7a
callq 0x2070
movq (%r14), %rax
movq $0x0, (%rax,%r15)
movl (%rbx), %eax
incq %r12
movslq %eax, %rcx
addq $0x10, %r15
cmpq %rcx, %r12
jl 0x2d5c
movq (%r14), %rdi
callq 0x2070
movq $0x0, (%r14)
movl $0x0, (%rbx)
xorl %eax, %eax
jmp 0x2ef6
movq %rdi, %r12
movq (%r14), %rax
movslq %esi, %rcx
shlq $0x4, %rcx
movslq 0x8(%rax,%rcx), %rdx
movq %rcx, 0x18(%rsp)
movq (%rax,%rcx), %rax
movq %rdx, 0x8(%rsp)
movslq -0x4(%rax,%rdx,4), %r13
movq (%rdi), %rdi
shlq $0x6, %r13
movl $0x1, %eax
cmpl $0x0, 0x38(%rdi,%r13)
jle 0x2ef6
movl %esi, 0x10(%rsp)
movq 0x8(%rsp), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0x14(%rsp)
movl %eax, %ebp
xorl %r15d, %r15d
movq %rbx, 0x30(%rsp)
movq %r12, 0x28(%rsp)
movq %r13, 0x20(%rsp)
testq %r15, %r15
je 0x2e9e
movslq (%rbx), %rsi
incq %rsi
movl %esi, (%rbx)
movq (%r14), %rdi
shlq $0x4, %rsi
callq 0x22d0
movq %r12, %rcx
movq %rax, %r12
movq %rax, (%r14)
movslq (%rbx), %rbx
movq %rbx, %r13
shlq $0x4, %r13
movl 0x14(%rsp), %eax
movl %eax, -0x8(%r12,%r13)
movslq 0x8(%rcx), %rdi
shlq $0x2, %rdi
callq 0x22a0
movq %rax, -0x10(%r12,%r13)
cmpl $0x0, 0x8(%rsp)
jle 0x2e71
movq 0x18(%rsp), %rcx
movq (%r12,%rcx), %rcx
xorl %edx, %edx
movl (%rcx,%rdx,4), %esi
movl %esi, (%rax,%rdx,4)
incq %rdx
cmpq %rdx, %rbp
jne 0x2e63
movq 0x28(%rsp), %r12
movq (%r12), %rcx
movq 0x20(%rsp), %r13
movq 0x30(%rcx,%r13), %rcx
movl (%rcx,%r15,4), %ecx
movq 0x8(%rsp), %rdx
movl %ecx, (%rax,%rdx,4)
decl %ebx
movq %r12, %rdi
movl %ebx, %esi
movq 0x30(%rsp), %rbx
jmp 0x2ec9
movq (%r14), %rcx
movq 0x18(%rsp), %r8
movslq 0x8(%rcx,%r8), %rdx
leaq 0x1(%rdx), %rsi
movl %esi, 0x8(%rcx,%r8)
movq 0x30(%rdi,%r13), %rax
movl (%rax), %eax
movq (%rcx,%r8), %rcx
movl %eax, (%rcx,%rdx,4)
movq %r12, %rdi
movl 0x10(%rsp), %esi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x22c0
testl %eax, %eax
je 0x2d9e
incq %r15
movq (%r12), %rdi
movslq 0x38(%rdi,%r13), %rcx
cmpq %rcx, %r15
jl 0x2e06
movl $0x1, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq