// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/savenet.c
// Function: save_graph_hugin
void save_graph_hugin(bayesiangraphptr mygraph, char *file_name)
{
 /*!Last Changed 11.02.2001*/
 FILE *myfile;
 int i, j, k;
 myfile = fopen(file_name, "w");
	if (!myfile)
		 return;
 for (i = 0; i < mygraph->nodecount; i++)
  {
   fprintf(myfile, "node %s\n", mygraph->nodes[i].name);
   fprintf(myfile, "{ label = \"%s\";\n", mygraph->nodes[i].name);
   fprintf(myfile, "position = (%d %d);\n", mygraph->nodes[i].xpos, mygraph->nodes[i].ypos);
   fprintf(myfile, "states = (");
   for (j = 0; j < mygraph->nodes[i].value_count; j++)
     fprintf(myfile, "\"%s\" ", mygraph->nodes[i].values[j]);
   fprintf(myfile, ");\n}\n\n");
  }
 for (i = 0; i < mygraph->nodecount; i++)
  {
   fprintf(myfile, "potential (%s", mygraph->nodes[i].name);
   if (mygraph->nodes[i].parents > 0)
     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{ data = \n");
   for (j = 0; j < mygraph->nodes[i].table_count; j++)
    {
     fprintf(myfile, "( ");
     for (k = 0; k < mygraph->nodes[i].value_count; k++)
       fprintf(myfile, "%4.f ", mygraph->nodes[i].table[j][k]);
     fprintf(myfile, ")\n");
    }
   fprintf(myfile, ";\n}\n\n");
  }
 fclose(myfile);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rax
movq %rdi, %rbx
leaq 0x21600(%rip), %rsi     # 0xa88a1
movq %rax, %rdi
callq 0x40f0
testq %rax, %rax
je 0x87555
movq %rax, %r14
cmpl $0x0, 0x10(%rbx)
jle 0x8739b
leaq 0x26ebe(%rip), %r15     # 0xae184
xorl %r13d, %r13d
movq 0x8(%rbx), %rax
leaq (,%r13,8), %rcx
leaq (%rcx,%rcx,8), %rbp
movq (%rax,%rbp), %rdx
movq %r14, %rdi
leaq 0x26e63(%rip), %rsi     # 0xae14a
xorl %eax, %eax
callq 0x42e0
movq 0x8(%rbx), %rax
movq (%rax,%rbp), %rdx
movq %r14, %rdi
leaq 0x26e53(%rip), %rsi     # 0xae153
xorl %eax, %eax
callq 0x42e0
movq 0x8(%rbx), %rax
movl 0x40(%rax,%rbp), %edx
movl 0x44(%rax,%rbp), %ecx
movq %r14, %rdi
leaq 0x26e47(%rip), %rsi     # 0xae164
xorl %eax, %eax
callq 0x42e0
movl $0xa, %esi
movl $0x1, %edx
leaq 0x26e44(%rip), %rdi     # 0xae179
movq %r14, %rcx
callq 0x42c0
movq 0x8(%rbx), %rax
cmpl $0x0, 0x10(%rax,%rbp)
jle 0x87372
xorl %r12d, %r12d
movq 0x8(%rax,%rbp), %rax
movq (%rax,%r12,8), %rdx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x42e0
incq %r12
movq 0x8(%rbx), %rax
movslq 0x10(%rax,%rbp), %rcx
cmpq %rcx, %r12
jl 0x8734b
movl $0x6, %esi
movl $0x1, %edx
leaq 0x26e07(%rip), %rdi     # 0xae18a
movq %r14, %rcx
callq 0x42c0
incq %r13
movslq 0x10(%rbx), %rax
cmpq %rax, %r13
jl 0x872c9
cmpl $0x0, 0x10(%rbx)
jle 0x8753f
leaq 0x26e06(%rip), %r15     # 0xae1b2
xorl %r13d, %r13d
movq 0x8(%rbx), %rax
leaq (,%r13,8), %rcx
leaq (%rcx,%rcx,8), %rbp
movq (%rax,%rbp), %rdx
movq %r14, %rdi
leaq 0x26dc4(%rip), %rsi     # 0xae191
xorl %eax, %eax
callq 0x42e0
movq 0x8(%rbx), %rax
cmpl $0x0, 0x20(%rax,%rbp)
jle 0x873f8
movl $0x2, %esi
movl $0x1, %edx
leaq 0x26daf(%rip), %rdi     # 0xae19f
movq %r14, %rcx
callq 0x42c0
movq 0x8(%rbx), %rax
leaq (,%r13,8), %rcx
addq %r13, %rcx
movq %rcx, 0x8(%rsp)
cmpl $0x0, 0x20(%rax,%rcx,8)
jle 0x87456
xorl %r12d, %r12d
movq %rbx, %rdi
movl %r13d, %esi
movl %r12d, %edx
callq 0x4d140
movq 0x8(%rbx), %rcx
cltq
leaq (%rax,%rax,8), %rax
movq (%rcx,%rax,8), %rdx
movq %r14, %rdi
leaq 0x26977(%rip), %rsi     # 0xaddb3
xorl %eax, %eax
callq 0x42e0
incl %r12d
movq 0x8(%rbx), %rax
movq 0x8(%rsp), %rcx
cmpl 0x20(%rax,%rcx,8), %r12d
jl 0x87416
movq %r13, 0x10(%rsp)
movl $0xc, %esi
movl $0x1, %edx
leaq 0x26d36(%rip), %rdi     # 0xae1a2
movq %r14, %rcx
callq 0x42c0
movq 0x8(%rbx), %rax
movq 0x8(%rsp), %r13
cmpq $0x0, 0x28(%rax,%r13,8)
jle 0x87511
xorl %r12d, %r12d
movl $0x2, %esi
movl $0x1, %edx
leaq 0x26d12(%rip), %rdi     # 0xae1af
movq %r14, %rcx
callq 0x42c0
movq 0x8(%rbx), %rax
cmpl $0x0, 0x10(%rax,%r13,8)
jle 0x874e1
xorl %r13d, %r13d
movq 0x38(%rax,%rbp), %rax
movq (%rax,%r12,8), %rax
movsd (%rax,%r13,8), %xmm0
movq %r14, %rdi
movq %r15, %rsi
movb $0x1, %al
callq 0x42e0
incq %r13
movq 0x8(%rbx), %rax
movslq 0x10(%rax,%rbp), %rcx
cmpq %rcx, %r13
jl 0x874b4
movl $0x2, %esi
movl $0x1, %edx
leaq 0x268b6(%rip), %rdi     # 0xadda8
movq %r14, %rcx
callq 0x42c0
incq %r12
movq 0x8(%rbx), %rax
movq 0x8(%rsp), %r13
cmpq %r12, 0x28(%rax,%r13,8)
jg 0x8748c
movl $0x5, %esi
movl $0x1, %edx
leaq 0x26c69(%rip), %rdi     # 0xae18b
movq %r14, %rcx
callq 0x42c0
movq 0x10(%rsp), %r13
incq %r13
movslq 0x10(%rbx), %rax
cmpq %rax, %r13
jl 0x873af
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x42a0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq