// File: /workspace/github_c_makefile_star2_O3/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, %ebx
movq %rdi, %r14
leaq 0x84da8(%rip), %rsi     # 0xab96d
movq %rdx, %rdi
callq 0x40f0
movq %rax, 0x50(%rsp)
testq %rax, %rax
je 0x26dd4
movslq 0x10(%r14), %rdi
shlq $0x3, %rdi
leaq 0x815d6(%rip), %r12     # 0xa81c0
movq %r12, %rsi
movl $0xb, %edx
callq 0x3a0e1
movq %rax, %r15
movslq 0x10(%r14), %rdi
shlq $0x2, %rdi
movq %r12, %rsi
movl $0xc, %edx
callq 0x3a0e1
movq %rax, %r12
testl %ebx, %ebx
jle 0x26da8
xorl %ebp, %ebp
xorl %eax, %eax
movl %ebx, 0x58(%rsp)
movl %eax, 0x5c(%rsp)
movl 0x10(%r14), %ecx
testl %ecx, %ecx
jle 0x26c5a
xorl %ebx, %ebx
xorps %xmm0, %xmm0
movsd 0x7e8e5(%rip), %xmm1    # 0xa5520
callq 0x3af6a
movsd %xmm0, (%r15,%rbx,8)
movl $0xffffffff, (%r12,%rbx,4) # imm = 0xFFFFFFFF
incq %rbx
movslq 0x10(%r14), %rcx
cmpq %rcx, %rbx
jl 0x26c30
testl %ecx, %ecx
jle 0x26d87
movl $0x1, %eax
xorl %ebx, %ebx
cmpl $-0x1, (%r12,%rbx,4)
jne 0x26d30
movq 0x8(%r14), %rdx
leaq (%rbx,%rbx,8), %r13
movl 0x30(%rdx,%r13,8), %ecx
cmpl $-0x1, %ecx
je 0x26d10
movq 0x18(%r14), %rsi
movq 0x28(%r14), %r8
movl $0x1, %edi
movl %ecx, %r9d
movslq %r9d, %r9
movslq (%r8,%r9,4), %r10
cmpl $-0x1, (%r12,%r10,4)
cmovel %ebp, %edi
movl (%rsi,%r9,4), %r9d
cmpl $-0x1, %r9d
jne 0x26c9a
testl %edi, %edi
je 0x26d30
leaq (%rdx,%r13,8), %rsi
cmpl $-0x1, %ecx
je 0x26d14
movq 0x18(%r14), %rax
movq 0x28(%r14), %rdx
leaq 0x60(%rsp), %rdi
movslq %ecx, %rcx
movslq (%rdx,%rcx,4), %r8
movl (%r12,%r8,4), %r8d
movl %r8d, (%rdi)
movl (%rax,%rcx,4), %ecx
addq $0x4, %rdi
cmpl $-0x1, %ecx
jne 0x26ccd
movl $0x9, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x60(%rsp), %rdi
callq 0x4e515
movq 0x8(%r14), %rcx
leaq (%rcx,%r13,8), %rsi
cltq
shlq $0x3, %rax
addq 0x38(%rsi), %rax
jmp 0x26d19
leaq (%rdx,%r13,8), %rsi
movq 0x38(%rdx,%r13,8), %rax
movq (%rax), %rdi
movl 0x10(%rsi), %esi
movsd (%r15,%rbx,8), %xmm0
callq 0x37fdb
movl %eax, (%r12,%rbx,4)
xorl %eax, %eax
incq %rbx
movslq 0x10(%r14), %rcx
cmpq %rcx, %rbx
jl 0x26c69
testl %eax, %eax
je 0x26c5a
testl %ecx, %ecx
jle 0x26d87
movl $0x2, %ebx
xorl %r13d, %r13d
movq 0x8(%r14), %rax
movq (%rax,%rbx,4), %rax
movslq (%r12,%r13,4), %rcx
movq (%rax,%rcx,8), %rdx
movq 0x50(%rsp), %rdi
leaq 0x8a0db(%rip), %rsi     # 0xb0e4b
xorl %eax, %eax
callq 0x42e0
incq %r13
movslq 0x10(%r14), %rax
addq $0x12, %rbx
cmpq %rax, %r13
jl 0x26d54
movl $0xa, %edi
movq 0x50(%rsp), %rsi
callq 0x4150
movl 0x5c(%rsp), %eax
incl %eax
movl 0x58(%rsp), %ebx
cmpl %ebx, %eax
jne 0x26c22
movq %r12, %rdi
callq 0x3a180
movq %r15, %rdi
callq 0x3a180
movq 0x50(%rsp), %rdi
callq 0x42a0
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x813c9(%rip), %rdi     # 0xa81a4
movq %r15, %rsi
xorl %eax, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4030