// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/graphdata.c
// Function: create_data
void create_data(bayesiangraphptr mygraph, int data_count, char *f_name)
{
 /*!Last Changed 17.07.2008 Added find_bin function*/
	/*!Last Changed 02.02.2004 added safemalloc*/
 /*!Last Changed 09.02.2001*/
 FILE *myfile;
 BOOLEAN finished, found;
 int i, j, k, pos;
 double *probability;
 int parent[MAXPARENT];
 int *values;
 if ((myfile = fopen(f_name, "w")) == NULL)
  {
   printf(m1268, f_name);
   return;
  }
 probability = (double *)safemalloc(mygraph->nodecount * sizeof(double), "create_data", 11);
 values = (int *)safemalloc(mygraph->nodecount * sizeof(int), "create_data", 12);
 for (i = 0; i < data_count; i++)
  {
   /*Assign random probabilities to each Bayesian node*/
   for (j = 0; j < mygraph->nodecount; j++)
    {
     probability[j] = (double)(produce_random_value(0, 1));
     values[j] = -1;
    }
   finished = BOOLEAN_FALSE;
   while (!finished)
    {
     finished = BOOLEAN_TRUE;
     for (j = 0; j < mygraph->nodecount; j++)
       if (values[j] == -1)
        {
         found = BOOLEAN_TRUE;
         pos = mygraph->nodes[j].pointer;
         while (pos != -1)
          {
           if ((pos != -1) && (values[mygraph->dest[pos]] == -1))
             found = BOOLEAN_FALSE;
           pos = mygraph->arcs[pos].pointer;
          }
         if (found) /*Eger butun parentlarinin degerleri belirlenmisse*/
          {
           finished = BOOLEAN_FALSE;
           if (mygraph->nodes[j].pointer == -1)/*No parent*/
             values[j] = find_bin(mygraph->nodes[j].table[0], mygraph->nodes[j].value_count, probability[j]);
           else
            { /*Parenti varsa*/
             k = 0;
             pos = mygraph->nodes[j].pointer;
             while (pos != -1)
              {
               parent[k] = values[mygraph->dest[pos]];
               pos = mygraph->arcs[pos].pointer;
               k++;
              }
             k = table_pos(mygraph->nodes[j], parent);
             values[j] = find_bin(mygraph->nodes[j].table[k], mygraph->nodes[j].value_count, probability[j]);
            }
          }
        }
    }
   for (j = 0; j < mygraph->nodecount; j++)
     fprintf(myfile, "%s ", mygraph->nodes[j].values[values[j]]);
   fprintf(myfile, "\n");
  }
 safe_free(values);
 safe_free(probability);
 fclose(myfile);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %r14
leaq 0x77fee(%rip), %rsi     # 0x9b891
movq %rdx, %rdi
callq 0x40f0
movq %rax, 0x50(%rsp)
testq %rax, %rax
je 0x23a95
movslq 0x10(%r14), %rdi
shlq $0x3, %rdi
leaq 0x74878(%rip), %r12     # 0x98140
pushq $0xb
popq %rdx
movq %r12, %rsi
callq 0x34f59
movq %rax, %r15
movslq 0x10(%r14), %rdi
shlq $0x2, %rdi
pushq $0xc
popq %rdx
movq %r12, %rsi
callq 0x34f59
movq %rax, %r12
xorl %ebx, %ebx
testl %ebp, %ebp
cmovlel %ebx, %ebp
xorl %eax, %eax
movl %ebp, 0x58(%rsp)
cmpl %ebp, %eax
je 0x23a69
movl %eax, 0x5c(%rsp)
xorl %r13d, %r13d
movslq 0x10(%r14), %rcx
cmpq %rcx, %r13
jge 0x23931
xorps %xmm0, %xmm0
movsd 0x71c04(%rip), %xmm1    # 0x95520
callq 0x35cae
movsd %xmm0, (%r15,%r13,8)
orl $-0x1, (%r12,%r13,4)
incq %r13
jmp 0x23908
xorl %eax, %eax
testl %eax, %eax
jne 0x23a0f
xorl %r13d, %r13d
pushq $0x1
popq %rax
movslq %ecx, %rdx
cmpq %rdx, %r13
jge 0x23933
cmpl $-0x1, (%r12,%r13,4)
jne 0x23a03
movq 0x8(%r14), %rcx
imulq $0x48, %r13, %rbp
leaq (%rcx,%rbp), %rdx
addq $0x30, %rdx
pushq $0x1
popq %rsi
movslq (%rdx), %rdx
cmpq $-0x1, %rdx
je 0x2398a
movq 0x28(%r14), %rdi
movslq (%rdi,%rdx,4), %rdi
shlq $0x2, %rdx
cmpl $-0x1, (%r12,%rdi,4)
cmovel %ebx, %esi
addq 0x18(%r14), %rdx
jmp 0x23967
testl %esi, %esi
je 0x23a03
leaq (%rcx,%rbp), %rsi
movl 0x30(%rcx,%rbp), %edx
cmpl $-0x1, %edx
je 0x239e7
leaq 0x60(%rsp), %rax
cmpl $-0x1, %edx
je 0x239c3
movq 0x28(%r14), %rcx
movslq %edx, %rdx
movslq (%rcx,%rdx,4), %rcx
movl (%r12,%rcx,4), %ecx
movl %ecx, (%rax)
movq 0x18(%r14), %rcx
movl (%rcx,%rdx,4), %edx
addq $0x4, %rax
jmp 0x239a0
pushq $0x9
popq %rcx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x60(%rsp), %rdi
callq 0x472d4
movq 0x8(%r14), %rcx
cltq
shlq $0x3, %rax
addq 0x38(%rcx,%rbp), %rax
jmp 0x239eb
movq 0x38(%rsi), %rax
movq (%rax), %rdi
movl 0x10(%rcx,%rbp), %esi
movsd (%r15,%r13,8), %xmm0
callq 0x33688
movl %eax, (%r12,%r13,4)
xorl %eax, %eax
incq %r13
movl 0x10(%r14), %ecx
jmp 0x23941
pushq $0x2
popq %r13
xorl %ebp, %ebp
movslq %ecx, %rax
cmpq %rax, %rbp
jge 0x23a4d
movq 0x8(%r14), %rax
movq (%rax,%r13,4), %rax
movslq (%r12,%rbp,4), %rcx
movq (%rax,%rcx,8), %rdx
movq 0x50(%rsp), %rdi
leaq 0x7d376(%rip), %rsi     # 0xa0daf
xorl %eax, %eax
callq 0x42e0
incq %rbp
movl 0x10(%r14), %ecx
addq $0x12, %r13
jmp 0x23a15
pushq $0xa
popq %rdi
movq 0x50(%rsp), %rsi
callq 0x4150
movl 0x5c(%rsp), %eax
incl %eax
movl 0x58(%rsp), %ebp
jmp 0x238f9
movq %r12, %rdi
callq 0x34ff7
movq %r15, %rdi
callq 0x34ff7
movq 0x50(%rsp), %rdi
callq 0x42a0
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x74688(%rip), %rdi     # 0x98124
movq %r15, %rsi
xorl %eax, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4030