// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/savenet.c
// Function: save_graph_net
void save_graph_net(bayesiangraphptr mygraph, char *file_name)
{
 /*!Last Changed 06.02.2001*/
 FILE *myfile;
 int i, j, k, *list, *valuelist;
 myfile = fopen(file_name, "w");
	if (!myfile)
		 return;
 fprintf(myfile, "(network %s:probability)\n", mygraph->name);
 for (i = 0; i < mygraph->nodecount; i++)
  {
   fprintf(myfile, "(var %s (", mygraph->nodes[i].name);
   for (j = 0; j < mygraph->nodes[i].value_count; j++)
     fprintf(myfile, "%s ", mygraph->nodes[i].values[j]);
   fprintf(myfile, "))\n");
  }
 for (i = 0; i < mygraph->nodecount; i++)
  {
   fprintf(myfile, "parents %s ", mygraph->nodes[i].name);
   if (mygraph->nodes[i].parents == 0)/*No parents*/
    {
     fprintf(myfile, "(");
     for (j = 0; j < mygraph->nodes[i].value_count; j++)
       fprintf(myfile, "%.4f ", mygraph->nodes[i].table[0][j]);
     fprintf(myfile, ")\n");
    }
   else
    {
     list = find_parents(mygraph, i);/*Print parents*/
     fprintf(myfile, "(");
     for (j = 0; j < mygraph->nodes[i].parents; j++)
       fprintf(myfile, "%s ", mygraph->nodes[list[j]].name);
     fprintf(myfile, ")(\n");
     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; k++)
         fprintf(myfile, "%s ", mygraph->nodes[list[k]].values[valuelist[k]]);
       fprintf(myfile, ")");
       for (k = 0; k < mygraph->nodes[i].value_count; k++)
         fprintf(myfile, "%.4f ", mygraph->nodes[i].table[j][k]);
       fprintf(myfile, ")\n");
       safe_free(valuelist);
      }
     fprintf(myfile, ")\n");
     safe_free(list);
    }
  }
 fclose(myfile);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %rax
movq %rdi, %rbx
leaq 0x228a2(%rip), %rsi     # 0xab96d
movq %rax, %rdi
callq 0x40f0
testq %rax, %rax
je 0x89467
movq %rax, %r12
movq (%rbx), %rdx
leaq 0x27d32(%rip), %rsi     # 0xb0e1b
movq %rax, %rdi
xorl %eax, %eax
callq 0x42e0
cmpl $0x0, 0x10(%rbx)
jle 0x89451
leaq 0x27d47(%rip), %r13     # 0xb0e4b
xorl %ebp, %ebp
movq 0x8(%rbx), %rax
leaq (,%rbp,8), %rcx
leaq (%rcx,%rcx,8), %r15
movq (%rax,%r15), %rdx
movq %r12, %rdi
leaq 0x27d11(%rip), %rsi     # 0xb0e35
xorl %eax, %eax
callq 0x42e0
movq 0x8(%rbx), %rax
cmpl $0x0, 0x10(%rax,%r15)
jle 0x89161
xorl %r14d, %r14d
movq 0x8(%rax,%r15), %rax
movq (%rax,%r14,8), %rdx
movq %r12, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x42e0
incq %r14
movq 0x8(%rbx), %rax
movslq 0x10(%rax,%r15), %rcx
cmpq %rcx, %r14
jl 0x8913a
movl $0x3, %esi
movl $0x1, %edx
leaq 0x27ccd(%rip), %rdi     # 0xb0e3f
movq %r12, %rcx
callq 0x42c0
incq %rbp
movslq 0x10(%rbx), %rax
cmpq %rax, %rbp
jl 0x89106
testl %eax, %eax
jle 0x89451
leaq 0x27fdc(%rip), %r15     # 0xb1171
leaq 0x27caf(%rip), %rbp     # 0xb0e4b
xorl %r13d, %r13d
movq 0x8(%rbx), %rax
leaq (,%r13,8), %rcx
leaq (%rcx,%rcx,8), %r14
movq (%rax,%r14), %rdx
movq %r12, %rdi
leaq 0x27c86(%rip), %rsi     # 0xb0e43
xorl %eax, %eax
callq 0x42e0
movq 0x8(%rbx), %rax
movq %r14, 0x48(%rsp)
cmpl $0x0, 0x20(%rax,%r14)
je 0x893cc
movq %rbx, %rdi
movl %r13d, %esi
callq 0x4e548
movq %rax, %r15
movl $0x28, %edi
movq %r12, %rsi
callq 0x4150
movq 0x8(%rbx), %rax
movq %r13, 0x60(%rsp)
leaq (%r13,%r13,8), %r13
cmpl $0x0, 0x20(%rax,%r13,8)
jle 0x89237
xorl %r14d, %r14d
movslq (%r15,%r14,4), %rcx
leaq (%rcx,%rcx,8), %rcx
movq (%rax,%rcx,8), %rdx
movq %r12, %rdi
movq %rbp, %rsi
xorl %eax, %eax
callq 0x42e0
incq %r14
movq 0x8(%rbx), %rax
movslq 0x20(%rax,%r13,8), %rcx
cmpq %rcx, %r14
jl 0x8920d
movq %r15, 0x58(%rsp)
movl $0x3, %esi
movl $0x1, %edx
leaq 0x27c02(%rip), %rdi     # 0xb0e4f
movq %r12, %rcx
callq 0x42c0
movq 0x8(%rbx), %rax
cmpq $0x0, 0x28(%rax,%r13,8)
jle 0x8939b
xorl %r15d, %r15d
movq %r13, 0x50(%rsp)
movl $0x28, %edi
movq %r12, %rsi
callq 0x4150
movq 0x8(%rbx), %rsi
movq 0x48(%rsp), %r14
addq %r14, %rsi
movl $0x9, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r15, 0x70(%rsp)
movl %r15d, %edi
callq 0x4e4b2
movq %rax, %r13
movq 0x8(%rbx), %rax
cmpl $0x0, 0x20(%rax,%r14)
movq %rbp, %r15
movq 0x58(%rsp), %rbp
jle 0x892f2
xorl %r14d, %r14d
movslq (%rbp,%r14,4), %rcx
leaq (%rcx,%rcx,8), %rcx
movq 0x8(%rax,%rcx,8), %rax
movslq (%r13,%r14,4), %rcx
movq (%rax,%rcx,8), %rdx
movq %r12, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x42e0
incq %r14
movq 0x8(%rbx), %rax
movq 0x50(%rsp), %rcx
movslq 0x20(%rax,%rcx,8), %rcx
cmpq %rcx, %r14
jl 0x892b8
movq %r13, 0x68(%rsp)
movl $0x29, %edi
movq %r12, %rsi
callq 0x4150
movq 0x8(%rbx), %rax
movq 0x50(%rsp), %rcx
cmpl $0x0, 0x10(%rax,%rcx,8)
leaq 0x27e58(%rip), %rbp     # 0xb1171
movq 0x48(%rsp), %rdx
movq 0x70(%rsp), %r15
jle 0x8935a
xorl %r14d, %r14d
movq 0x38(%rax,%rdx), %rax
movq (%rax,%r15,8), %rax
movsd (%rax,%r14,8), %xmm0
movq %r12, %rdi
movq %rbp, %rsi
movb $0x1, %al
callq 0x42e0
movq 0x48(%rsp), %rdx
incq %r14
movq 0x8(%rbx), %rax
movslq 0x10(%rax,%rdx), %rcx
cmpq %rcx, %r14
jl 0x89328
movl $0x2, %esi
movl $0x1, %edx
leaq 0x27ad5(%rip), %rdi     # 0xb0e40
movq %r12, %rcx
callq 0x42c0
movq 0x68(%rsp), %rdi
callq 0x3a180
incq %r15
movq 0x8(%rbx), %rax
movq 0x50(%rsp), %r13
cmpq %r15, 0x28(%rax,%r13,8)
leaq 0x27ab6(%rip), %rbp     # 0xb0e4b
jg 0x8926d
movl $0x2, %esi
movl $0x1, %edx
leaq 0x27a94(%rip), %rdi     # 0xb0e40
movq %r12, %rcx
callq 0x42c0
movq 0x58(%rsp), %rdi
callq 0x3a180
leaq 0x27dac(%rip), %r15     # 0xb1171
movq 0x60(%rsp), %r13
jmp 0x89441
movl $0x28, %edi
movq %r12, %rsi
callq 0x4150
movq 0x8(%rbx), %rax
leaq (,%r13,8), %rcx
addq %r13, %rcx
cmpl $0x0, 0x10(%rax,%rcx,8)
movq 0x48(%rsp), %rdx
jle 0x89428
xorl %r14d, %r14d
movq 0x38(%rax,%rdx), %rax
movq (%rax), %rax
movsd (%rax,%r14,8), %xmm0
movq %r12, %rdi
movq %r15, %rsi
movb $0x1, %al
callq 0x42e0
movq 0x48(%rsp), %rdx
incq %r14
movq 0x8(%rbx), %rax
movslq 0x10(%rax,%rdx), %rcx
cmpq %rcx, %r14
jl 0x893f7
movl $0x2, %esi
movl $0x1, %edx
leaq 0x27a07(%rip), %rdi     # 0xb0e40
movq %r12, %rcx
callq 0x42c0
incq %r13
movslq 0x10(%rbx), %rax
cmpq %rax, %r13
jl 0x8919f
movq %r12, %rdi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x42a0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq