// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/savenet.c
// Function: save_graph_bif
void save_graph_bif(bayesiangraphptr mygraph,char *file_name)
{
 /*!Last Changed 11.02.2001*/
 FILE *myfile;
 int i, j, k, *list, *valuelist;
 myfile = fopen(file_name, "w");
	if (!myfile)
		 return;
 fprintf(myfile, "network %s { }\n\n", mygraph->name);
 for (i = 0; i < mygraph->nodecount; i++)
  {
   fprintf(myfile, "variable %s {\n", mygraph->nodes[i].name);
   fprintf(myfile, "type discrete [%d] { ", mygraph->nodes[i].value_count);
   for (j = 0; j < mygraph->nodes[i].value_count - 1; j++)
     fprintf(myfile, "%s, ", mygraph->nodes[i].values[j]);
   fprintf(myfile, "%s };\n}\n\n", mygraph->nodes[i].values[j]);
  }
 for (i = 0; i < mygraph->nodecount; i++)
  {
   fprintf(myfile, "probability (%s", mygraph->nodes[i].name);
   if (mygraph->nodes[i].parents)
    {
     fprintf(myfile, " | ");
     for (j = 0; j < mygraph->nodes[i].parents; j++)
      {
       k = parent_index(mygraph, i, j);
       fprintf(myfile, "%s ", mygraph->nodes[k].name);
      }
    }
   fprintf(myfile, ") {\n");
   if (!mygraph->nodes[i].parents)
    {
     fprintf(myfile, "  table ");
     for (j = 0; j < mygraph->nodes[i].value_count - 1; j++)
       fprintf(myfile, " %4.f, ", mygraph->nodes[i].table[0][j]);
     fprintf(myfile, " %4.f;\n", mygraph->nodes[i].table[0][j]);
    }
   else
    {
     list = find_parents(mygraph, i);
     for (j = 0; j < mygraph->nodes[i].table_count; j++)
      {
       fprintf(myfile, "(");
       valuelist = table_list(mygraph->nodes[i], j);
       for (k = 0; k < mygraph->nodes[i].parents - 1; k++)
         fprintf(myfile, " %s,", mygraph->nodes[list[k]].values[valuelist[k]]);
       fprintf(myfile, "%s ) ", mygraph->nodes[list[k]].values[valuelist[k]]);
       for (k = 0; k < mygraph->nodes[i].value_count - 1; k++)
         fprintf(myfile, "%.4f, ", mygraph->nodes[i].table[j][k]);
       fprintf(myfile, "%.4f;\n", mygraph->nodes[i].table[j][k]);
       safe_free(valuelist);
      }
     safe_free(list);
    }
   fprintf(myfile, "}\n\n");
  }
 fclose(myfile); 
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, %rax
movq %rdi, %rbx
leaq 0x21b89(%rip), %rsi     # 0xab96d
movq %rax, %rdi
callq 0x40f0
testq %rax, %rax
je 0x8a268
movq %rax, %r15
movq (%rbx), %rdx
leaq 0x2744e(%rip), %rsi     # 0xb1250
movq %rax, %rdi
xorl %eax, %eax
callq 0x42e0
cmpl $0x0, 0x10(%rbx)
jle 0x8a24f
leaq 0x1d318(%rip), %r13     # 0xa7135
xorl %ebp, %ebp
movq %r15, 0x58(%rsp)
movq %rbx, 0x50(%rsp)
movq 0x8(%rbx), %rax
leaq (,%rbp,8), %rcx
leaq (%rcx,%rcx,8), %r12
movq (%rax,%r12), %rdx
movq %r15, %rdi
leaq 0x2741a(%rip), %rsi     # 0xb1261
xorl %eax, %eax
callq 0x42e0
movq 0x8(%rbx), %rax
movl 0x10(%rax,%r12), %edx
movq %r15, %rdi
leaq 0x2740f(%rip), %rsi     # 0xb1270
xorl %eax, %eax
callq 0x42e0
movq 0x8(%rbx), %rax
cmpl $0x2, 0x10(%rax,%r12)
jl 0x89ead
xorl %r14d, %r14d
movq 0x58(%rsp), %r15
movq 0x50(%rsp), %rbx
movq 0x8(%rax,%r12), %rax
movq (%rax,%r14,8), %rdx
movq %r15, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x42e0
incq %r14
movq 0x8(%rbx), %rax
movslq 0x10(%rax,%r12), %rcx
decq %rcx
cmpq %rcx, %r14
jl 0x89e81
jmp 0x89eba
xorl %r14d, %r14d
movq 0x58(%rsp), %r15
movq 0x50(%rsp), %rbx
leaq (,%rbp,8), %rcx
addq %rbp, %rcx
movq 0x8(%rax,%rcx,8), %rax
movq (%rax,%r14,8), %rdx
movq %r15, %rdi
leaq 0x273ae(%rip), %rsi     # 0xb1286
xorl %eax, %eax
callq 0x42e0
incq %rbp
movslq 0x10(%rbx), %rax
cmpq %rax, %rbp
jl 0x89e29
testl %eax, %eax
jle 0x8a24f
leaq 0x26f4d(%rip), %r13     # 0xb0e4b
xorl %ebp, %ebp
movq 0x8(%rbx), %rax
leaq (,%rbp,8), %rcx
leaq (%rcx,%rcx,8), %r14
movq (%rax,%r14), %rdx
movq %r15, %rdi
leaq 0x27372(%rip), %rsi     # 0xb1290
xorl %eax, %eax
callq 0x42e0
movq 0x8(%rbx), %rax
movq %r14, 0x60(%rsp)
cmpl $0x0, 0x20(%rax,%r14)
movq %rbp, %r12
je 0x89f99
movl $0x3, %esi
movl $0x1, %edx
leaq 0x27356(%rip), %rdi     # 0xb12a0
movq %r15, %rcx
callq 0x42c0
movq 0x8(%rbx), %rax
leaq (%r12,%r12,8), %r14
cmpl $0x0, 0x20(%rax,%r14,8)
jle 0x89f99
xorl %ebp, %ebp
movq %rbx, %rdi
movl %r12d, %esi
movl %ebp, %edx
callq 0x4e5b4
movq 0x8(%rbx), %rcx
cltq
leaq (%rax,%rax,8), %rax
movq (%rcx,%rax,8), %rdx
movq %r15, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x42e0
incl %ebp
movq 0x8(%rbx), %rax
cmpl 0x20(%rax,%r14,8), %ebp
jl 0x89f64
movl $0x4, %esi
movl $0x1, %edx
leaq 0x272fa(%rip), %rdi     # 0xb12a4
movq %r15, %rcx
callq 0x42c0
movq 0x8(%rbx), %rax
leaq (%r12,%r12,8), %r14
cmpl $0x0, 0x20(%rax,%r14,8)
movq %r12, %rbp
movq %r14, 0x70(%rsp)
je 0x8a193
movq %rbx, %rdi
movq %rbp, 0x80(%rsp)
movl %ebp, %esi
callq 0x4e548
movq %rax, 0x68(%rsp)
movq 0x8(%rbx), %rax
cmpq $0x0, 0x28(%rax,%r14,8)
movq 0x60(%rsp), %r12
jle 0x8a175
xorl %ebp, %ebp
movl $0x28, %edi
movq %r15, %rsi
callq 0x4150
movq 0x8(%rbx), %rsi
addq %r12, %rsi
movl $0x9, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movl %ebp, %edi
callq 0x4e4b2
movq 0x8(%rbx), %rsi
cmpl $0x2, 0x20(%rsi,%r12)
movq %rax, 0x78(%rsp)
jl 0x8a093
xorl %r14d, %r14d
movq 0x58(%rsp), %r15
movq 0x50(%rsp), %rbx
leaq 0x2727b(%rip), %r13     # 0xb12c2
movq 0x70(%rsp), %r12
movq 0x68(%rsp), %rdx
movslq (%rdx,%r14,4), %rcx
leaq (%rcx,%rcx,8), %rcx
movq 0x8(%rsi,%rcx,8), %rdx
movslq (%rax,%r14,4), %rcx
movq (%rdx,%rcx,8), %rdx
movq %r15, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x42e0
movq 0x78(%rsp), %rax
movq 0x68(%rsp), %rdx
incq %r14
movq 0x8(%rbx), %rsi
movslq 0x20(%rsi,%r12,8), %rcx
decq %rcx
cmpq %rcx, %r14
jl 0x8a051
jmp 0x8a0aa
xorl %r14d, %r14d
movq 0x58(%rsp), %r15
movq 0x50(%rsp), %rbx
movq 0x70(%rsp), %r12
movq 0x68(%rsp), %rdx
movslq (%rdx,%r14,4), %rcx
leaq (%rcx,%rcx,8), %rcx
movq 0x8(%rsi,%rcx,8), %rdx
movslq (%rax,%r14,4), %rcx
movq (%rdx,%rcx,8), %rdx
movq %r15, %rdi
leaq 0x271fe(%rip), %rsi     # 0xb12c7
xorl %eax, %eax
callq 0x42e0
movq 0x8(%rbx), %rax
cmpl $0x2, 0x10(%rax,%r12,8)
jl 0x8a127
xorl %r14d, %r14d
movq 0x58(%rsp), %r15
movq 0x50(%rsp), %rbx
leaq 0x271dd(%rip), %r13     # 0xb12cd
movq 0x60(%rsp), %r12
movq 0x38(%rax,%r12), %rax
movq (%rax,%rbp,8), %rax
movsd (%rax,%r14,8), %xmm0
movq %r15, %rdi
movq %r13, %rsi
movb $0x1, %al
callq 0x42e0
incq %r14
movq 0x8(%rbx), %rax
movslq 0x10(%rax,%r12), %rcx
decq %rcx
cmpq %rcx, %r14
jl 0x8a0f5
jmp 0x8a139
xorl %r14d, %r14d
movq 0x58(%rsp), %r15
movq 0x50(%rsp), %rbx
movq 0x60(%rsp), %r12
movq 0x38(%rax,%r12), %rax
movq (%rax,%rbp,8), %rax
movsd (%rax,%r14,8), %xmm0
movq %r15, %rdi
leaq 0x27182(%rip), %rsi     # 0xb12d4
movb $0x1, %al
callq 0x42e0
movq 0x78(%rsp), %rdi
callq 0x3a180
incq %rbp
movq 0x8(%rbx), %rax
cmpq %rbp, 0x28(%rax,%r12)
jg 0x89ffc
movq 0x68(%rsp), %rdi
callq 0x3a180
leaq 0x26cc5(%rip), %r13     # 0xb0e4b
movq 0x80(%rsp), %rbp
jmp 0x8a226
movl $0x8, %esi
movl $0x1, %edx
leaq 0x27105(%rip), %rdi     # 0xb12a9
movq %r15, %rcx
callq 0x42c0
movq 0x8(%rbx), %rax
cmpl $0x2, 0x10(%rax,%r14,8)
jl 0x8a1f8
xorl %r14d, %r14d
movq 0x60(%rsp), %r12
leaq 0x270eb(%rip), %r13     # 0xb12b2
movq 0x38(%rax,%r12), %rax
movq (%rax), %rax
movsd (%rax,%r14,8), %xmm0
movq %r15, %rdi
movq %r13, %rsi
movb $0x1, %al
callq 0x42e0
incq %r14
movq 0x8(%rbx), %rax
movslq 0x10(%rax,%r12), %rcx
decq %rcx
cmpq %rcx, %r14
jl 0x8a1c7
jmp 0x8a1fb
xorl %r14d, %r14d
movq 0x70(%rsp), %rcx
movq 0x38(%rax,%rcx,8), %rax
movq (%rax), %rax
movsd (%rax,%r14,8), %xmm0
movq %r15, %rdi
leaq 0x270a2(%rip), %rsi     # 0xb12ba
movb $0x1, %al
callq 0x42e0
leaq 0x26c25(%rip), %r13     # 0xb0e4b
movl $0x3, %esi
movl $0x1, %edx
leaq 0x26fee(%rip), %rdi     # 0xb1225
movq %r15, %rcx
callq 0x42c0
incq %rbp
movslq 0x10(%rbx), %rax
cmpq %rax, %rbp
jl 0x89f00
movq %r15, %rdi
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x42a0
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop