// File: /workspace/github_c_makefile_star2_O1/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, %r13d
movq %rdi, %r14
leaq 0x8242f(%rip), %rsi     # 0xa88a1
movq %rdx, %rdi
callq 0x40f0
testq %rax, %rax
je 0x26694
movq %rax, %rbx
movslq 0x10(%r14), %rdi
shlq $0x3, %rdi
leaq 0x7ecd3(%rip), %r12     # 0xa5168
movq %r12, %rsi
movl $0xb, %edx
callq 0x390f5
movq %rax, %r15
movslq 0x10(%r14), %rdi
shlq $0x2, %rdi
movq %r12, %rsi
movl $0xc, %edx
callq 0x390f5
movq %rax, %r12
testl %r13d, %r13d
jle 0x2666a
xorl %ebp, %ebp
xorl %eax, %eax
movq %rbx, 0x50(%rsp)
movl %r13d, 0x48(%rsp)
movq %r15, 0x58(%rsp)
movl %eax, 0x4c(%rsp)
cmpl $0x0, 0x10(%r14)
jle 0x26510
xorl %ebx, %ebx
xorps %xmm0, %xmm0
movsd 0x7c02f(%rip), %xmm1    # 0xa2520
callq 0x39f62
movsd %xmm0, (%r15,%rbx,8)
movl $0xffffffff, (%r12,%rbx,4) # imm = 0xFFFFFFFF
incq %rbx
movslq 0x10(%r14), %rax
cmpq %rax, %rbx
jl 0x264e6
cmpl $0x0, 0x10(%r14)
jle 0x265f4
movl $0x1, %eax
xorl %ebx, %ebx
cmpl $-0x1, (%r12,%rbx,4)
jne 0x265dc
movq 0x8(%r14), %rcx
leaq (%rbx,%rbx,8), %r13
movl 0x30(%rcx,%r13,8), %esi
cmpl $-0x1, %esi
je 0x26567
movq 0x18(%r14), %rdx
movq 0x28(%r14), %r8
movl $0x1, %edi
movslq %esi, %rsi
movslq (%r8,%rsi,4), %r9
cmpl $-0x1, (%r12,%r9,4)
cmovel %ebp, %edi
movl (%rdx,%rsi,4), %esi
cmpl $-0x1, %esi
jne 0x2654c
testl %edi, %edi
je 0x265dc
leaq (%rcx,%r13,8), %rsi
movl 0x30(%rsi), %eax
cmpl $-0x1, %eax
je 0x265bf
movq 0x18(%r14), %rcx
movq 0x28(%r14), %rdx
leaq 0x60(%rsp), %rdi
cltq
movslq (%rdx,%rax,4), %r8
movl (%r12,%r8,4), %r8d
movl %r8d, (%rdi)
movl (%rcx,%rax,4), %eax
addq $0x4, %rdi
cmpl $-0x1, %eax
jne 0x26580
movl $0x9, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x60(%rsp), %rdi
callq 0x4d0a1
movq 0x8(%r14), %rcx
cltq
shlq $0x3, %rax
addq 0x38(%rcx,%r13,8), %rax
jmp 0x265c3
movq 0x38(%rsi), %rax
movq (%rax), %rdi
movl 0x10(%rcx,%r13,8), %esi
movsd (%r15,%rbx,8), %xmm0
callq 0x374dd
movl %eax, (%r12,%rbx,4)
xorl %eax, %eax
incq %rbx
movslq 0x10(%r14), %rcx
cmpq %rcx, %rbx
jl 0x26522
testl %eax, %eax
je 0x26510
cmpl $0x0, 0x10(%r14)
movq 0x50(%rsp), %r8
leaq 0x877ae(%rip), %r15     # 0xaddb3
jle 0x26641
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 %r8, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x42e0
movq 0x50(%rsp), %r8
incq %r13
movslq 0x10(%r14), %rax
addq $0x12, %rbx
cmpq %rax, %r13
jl 0x2660f
movl $0xa, %edi
movq %r8, %rbx
movq %r8, %rsi
callq 0x4150
movl 0x4c(%rsp), %eax
incl %eax
movl 0x48(%rsp), %r13d
cmpl %r13d, %eax
movq 0x58(%rsp), %r15
jne 0x264d9
movq %r12, %rdi
callq 0x39194
movq %r15, %rdi
callq 0x39194
movq %rbx, %rdi
callq 0x42a0
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7eab1(%rip), %rdi     # 0xa514c
movq %r15, %rsi
xorl %eax, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4030