// File: /workspace/github_c_makefile_star2_O1/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
cmpl $0x400, (%rdx)          # imm = 0x400
jl 0x2e02
cmpl $0x0, (%rbx)
jle 0x2de6
xorl %r15d, %r15d
xorl %r12d, %r12d
movq (%r14), %rax
movq (%rax,%r15), %rdi
testq %rdi, %rdi
je 0x2dd7
callq 0x2070
movq (%r14), %rax
movq $0x0, (%rax,%r15)
incq %r12
movslq (%rbx), %rax
addq $0x10, %r15
cmpq %rax, %r12
jl 0x2dbb
movq (%r14), %rdi
callq 0x2070
movq $0x0, (%r14)
movl $0x0, (%rbx)
xorl %eax, %eax
jmp 0x2f5b
movq %rdi, %r15
movq (%r14), %rax
movslq %esi, %rcx
shlq $0x4, %rcx
movslq 0x8(%rax,%rcx), %rdx
movq %rcx, 0x10(%rsp)
movq (%rax,%rcx), %rax
movq %rdx, (%rsp)
movslq -0x4(%rax,%rdx,4), %r13
movq (%rdi), %rdi
shlq $0x6, %r13
movl $0x1, %eax
cmpl $0x0, 0x38(%rdi,%r13)
jle 0x2f5b
movl %esi, 0x8(%rsp)
movq (%rsp), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0xc(%rsp)
movl %eax, %ebp
xorl %r12d, %r12d
movq %rbx, 0x30(%rsp)
movq %r15, 0x28(%rsp)
movq %r14, 0x20(%rsp)
movq %r13, 0x18(%rsp)
testq %r12, %r12
je 0x2f05
movslq (%rbx), %rsi
incq %rsi
movl %esi, (%rbx)
movq (%r14), %rdi
shlq $0x4, %rsi
callq 0x22d0
movq %r15, %rcx
movq %rax, %r15
movq %rax, (%r14)
movslq (%rbx), %rbx
movq %rbx, %r13
shlq $0x4, %r13
movl 0xc(%rsp), %eax
movl %eax, -0x8(%r15,%r13)
movslq 0x8(%rcx), %rdi
shlq $0x2, %rdi
callq 0x22a0
movq %rax, -0x10(%r15,%r13)
movq (%rsp), %rcx
testl %ecx, %ecx
jle 0x2ed2
movq 0x10(%rsp), %rcx
movq (%r15,%rcx), %rcx
xorl %edx, %edx
movl (%rcx,%rdx,4), %esi
movl %esi, (%rax,%rdx,4)
incq %rdx
cmpq %rdx, %rbp
jne 0x2ec4
movq 0x28(%rsp), %r15
movq (%r15), %rcx
movq 0x18(%rsp), %r13
movq 0x30(%rcx,%r13), %rcx
movl (%rcx,%r12,4), %ecx
movq (%rsp), %rdx
movl %ecx, (%rax,%rdx,4)
decl %ebx
movq %r15, %rdi
movl %ebx, %esi
movq 0x30(%rsp), %rbx
movq %rbx, %rdx
movq 0x20(%rsp), %r14
jmp 0x2f32
movq (%r14), %rcx
movq 0x10(%rsp), %r8
movslq 0x8(%rcx,%r8), %rdx
leal 0x1(%rdx), %esi
movl %esi, 0x8(%rcx,%r8)
movq 0x30(%rdi,%r13), %rax
movl (%rax), %eax
movq (%rcx,%r8), %rcx
movl %eax, (%rcx,%rdx,4)
movq %r15, %rdi
movl 0x8(%rsp), %esi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x22c0
testl %eax, %eax
je 0x2dfb
incq %r12
movq (%r15), %rdi
movslq 0x38(%rdi,%r13), %rcx
cmpq %rcx, %r12
jl 0x2e66
movl $0x1, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq