// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/graphdata.c
// Function: parent_value_combinations
int **parent_value_combinations(bayesiangraphptr mygraph, int *parents, int parentcount, int total_combinations)
{
	/*!Last Changed 02.02.2004 added safemalloc*/
 int i, j;
 int repeat, value, num_values, current_value;
 int **combinations;
 combinations = (int **) safemalloc (total_combinations * sizeof(int *), "parent_value_combinations", 4);
 for (i = 0; i < total_combinations; i++)
   combinations[i] = (int *) safemalloc (parentcount * sizeof(int), "parent_value_combinations", 6);
 num_values = 1;
 for (i = 0; i < parentcount; i++)
  {
   current_value = mygraph->nodes[parents[i]].value_count;
   num_values = num_values * current_value;
   repeat = (int) total_combinations / num_values;
   value = 0;
   for (j = 0; j < total_combinations; j++)
    {
     if (repeat > 0)
      {
       combinations[j][i] = value;
       repeat = repeat - 1;
      }
     else
      {
       repeat = (int) total_combinations / num_values;
       value = (value + 1) % current_value;
       combinations[j][i] = value;
       repeat = repeat -1;
      }
    }
  }
 return combinations;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movslq -0x18(%rbp), %rdi
shlq $0x3, %rdi
leaq 0xad4c7(%rip), %rsi     # 0xe4d3c
movl $0x4, %edx
callq 0x52d70
movq %rax, -0x38(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x378c5
movslq -0x14(%rbp), %rdi
shlq $0x2, %rdi
leaq 0xad49b(%rip), %rsi     # 0xe4d3c
movl $0x6, %edx
callq 0x52d70
movq %rax, %rdx
movq -0x38(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x3788a
movl $0x1, -0x2c(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x379a4
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x10(%rbp), %rcx
movslq -0x1c(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %eax
imull -0x30(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x18(%rbp), %eax
cltd
idivl -0x2c(%rbp)
movl %eax, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x37994
cmpl $0x0, -0x24(%rbp)
jle 0x37951
movl -0x28(%rbp), %edx
movq -0x38(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x37987
movl -0x18(%rbp), %eax
cltd
idivl -0x2c(%rbp)
movl %eax, -0x24(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
cltd
idivl -0x30(%rbp)
movl %edx, -0x28(%rbp)
movl -0x28(%rbp), %edx
movq -0x38(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x24(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x37989
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x37922
jmp 0x37996
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x378d3
movq -0x38(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nop