// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/dataset.c
// Function: load_definitions
Datasetptr load_definitions(char *fname, int* datasetcount)
{
 /*!Last Changed 13.03.2007 added selected for features*/
 /*!Last Changed 06.01.2007 added store_time*/
 /*!Last Changed 02.04.2005 added sigma estimate*/
 /*!Last Changed 10.03.2004 extended to regression*/
 /*!Last Changed 02.02.2004 added safemalloc*/
 Xmldocumentptr doc;
 Xmlelementptr xmldataset, xmlclasses, xmlkernels, xmlattributes, xmlclass, xmlkernel, xmlattribute, xmlvalue;
 Datasetptr header = NULL, dataset = NULL;
 Datasetptr datasetbefore = NULL;
 int i, j, k, maxclass;
 char* st;
 doc = xml_document(fname);
 if (!doc)
   return NULL;
 *datasetcount = 0;
 if (xml_parse(doc))
  {
   xmldataset = doc->root->child;
   while (xmldataset)
    {
     (*datasetcount)++;
     dataset = (Datasetptr) safemalloc(sizeof(Dataset), "load_definitions", 20);
     dataset->active = YES;
     dataset->next = NULL;
     dataset->name = strcopy(dataset->name, xml_get_attribute_value(xmldataset, "name"));
     dataset->file = strcopy(dataset->file, xml_get_attribute_value(xmldataset, "filename"));
     dataset->directory = strcopy(dataset->directory, xml_get_attribute_value(xmldataset, "directory"));
     st = xml_get_attribute_value(xmldataset, "size");
     if (st)
       dataset->datacount = atoi(st);
     else
       dataset->datacount = 0;
     st = xml_get_attribute_value(xmldataset, "separator");
     if (st)
       dataset->separator = st[0];
     else
       dataset->separator = ' ';
     st = xml_get_attribute_value(xmldataset, "dsnname");
     if (st)
       dataset->dsnname = strcopy(dataset->dsnname, st);
     else
       dataset->dsnname = NULL;
     st = xml_get_attribute_value(xmldataset, "tablename");
     if (st)
       dataset->tablename = strcopy(dataset->tablename, st);
     else
       dataset->tablename = NULL;
     dataset->newclassdefno = -1;
     st = xml_get_attribute_value(xmldataset, "sigma");
     if (st)
       dataset->sigma = atof(st);
     else
       dataset->sigma = 0.0;
     st = xml_get_attribute_value(xmldataset, "filetype");
     if (strIcmp(st, "text") == 0)
       dataset->storetype = STORE_TEXT;
     else
       if (strIcmp(st, "database") == 0)
         dataset->storetype = STORE_DB;
       else
         if (strIcmp(st, "sequential") == 0)
           dataset->storetype = STORE_SEQUENTIAL;
         else
           if (strIcmp(st, "multilabel") == 0)
            {
             dataset->storetype = STORE_MULTILABEL;
             st = xml_get_attribute_value(xmldataset, "classcount");
             if (st)
               dataset->classno = atoi(st);
             else
               dataset->classno = 0;
             st = xml_get_attribute_value(xmldataset, "classlabelstart");
             if (st)
               dataset->classdefno = atoi(st);
             else
               dataset->classdefno = -1;
            }
           else
             if (strIcmp(st, "kernel") == 0)
              {
               dataset->storetype = STORE_KERNEL;
               xmlkernels = xml_get_child_with_name(xmldataset, "kernels");
               dataset->kernelcount = xml_number_of_children(xmlkernels);
               xmlkernel = xmlkernels->child;
               i = 0;
               while (xmlkernel)
                {
                 dataset->kernelfiles[i] = strcopy(dataset->kernelfiles[i], xml_get_attribute_value(xmlkernel, "value"));
                 xmlkernel = xmlkernel->sibling;
                 i++;
                }
              }
     printf(m1272, dataset->name);
     st = xml_get_attribute_value(xmldataset, "task");
     if (dataset->storetype != STORE_MULTILABEL)
      {
       if (strIcmp(st, "classification") == 0)
        {
         xmlclasses = xml_get_child_with_name(xmldataset, "classes");
         dataset->classno = xml_number_of_children(xmlclasses);
         if (dataset->classno > MAXCLASSES)
          {
           printf(m1419, dataset->classno);
           exit(0);
          }
         xmlclass = xmlclasses->child;
         i = 0;
         while (xmlclass)
          {
           dataset->classes[i] = strcopy(dataset->classes[i], xml_get_attribute_value(xmlclass, "value"));
           st = xml_get_attribute_value(xmlclass, "size");
           if (st)
             dataset->classcounts[i] = atoi(st);
           xmlclass = xmlclass->sibling;
           i++;
          }
         maxclass = find_max_in_list(dataset->classcounts, dataset->classno);
         dataset->baseerror = 100 * (1 - dataset->classcounts[maxclass] / (dataset->datacount + 0.0));
        }
       else
        {
         dataset->classno = 0;
         dataset->classdefno = -1;
         dataset->newclassdefno = -1;
        }
      }
     xmlattributes = xml_get_child_with_name(xmldataset, "attributes");
     dataset->allfeatures = xml_number_of_children(xmlattributes);
     if (dataset->allfeatures > MAXFEATURES)
      {
       printf(m1421, dataset->allfeatures);
       exit(0);
      }
     dataset->featurecount = xml_number_of_children_with_specific_attribute_value(xmlattributes, "available", "True");
     dataset->multifeaturecount = 0;
     xmlattribute = xmlattributes->child;
     i = 0;
     j = 0;
     while (xmlattribute)
      {
       st = xml_get_attribute_value(xmlattribute, "available");
       if (st && strIcmp(st, "True") == 0)
        {
         dataset->availability[i] = YES;
         dataset->features[j].selected = YES;
         st = xml_get_attribute_value(xmlattribute, "type");
         if (st)
          {
           dataset->features[j].type = listindex(st, featuretype, 4);
           if (dataset->features[j].type == CLASSDEF && dataset->classno == 0)
             dataset->features[j].type = REGDEF;
           switch (dataset->features[j].type)
            {
             case  INTEGER:st = xml_get_attribute_value(xmlattribute, "min");
                           if (st)
                             dataset->features[j].min.intvalue = atoi(st); 
                           else
                             dataset->features[j].min.intvalue = -INT_MAX;
                           st = xml_get_attribute_value(xmlattribute, "max");
                           if (st)
                             dataset->features[j].max.intvalue = atoi(st);
                           else
                             dataset->features[j].max.intvalue = +INT_MAX;
                           dataset->multifeaturecount++;
                           break;
             case   STRING:
             case CLASSDEF:dataset->features[j].valuecount = xml_number_of_children(xmlattribute);
                           if (dataset->features[j].valuecount > MAXVALUES)
                            {
                             printf(m1420, j + 1);
                             exit(0);
                            }
                           if (dataset->features[j].type == STRING)
                             dataset->multifeaturecount += dataset->features[j].valuecount;
                           else
                            {
                             dataset->multifeaturecount++;
                             dataset->classdefno = j;
                             dataset->newclassdefno = dataset->multifeaturecount - 1;
                            }
                           xmlvalue = xmlattribute->child;
                           k = 0;
                           while (xmlvalue)
                            {
                             dataset->features[j].strings[k] = strcopy(dataset->features[j].strings[k], xmlvalue->pcdata);
                             xmlvalue = xmlvalue->sibling;
                             k++;
                            }
                           break;
             case     REAL:
             case   REGDEF:st = xml_get_attribute_value(xmlattribute, "min");
                           if (st)
                             dataset->features[j].min.floatvalue = atof(st); 
                           else
                             dataset->features[j].min.floatvalue = -INT_MAX;
                           st = xml_get_attribute_value(xmlattribute, "max");
                           if (st)
                             dataset->features[j].max.floatvalue = atof(st);
                           else
                             dataset->features[j].max.floatvalue = +INT_MAX;
                           dataset->multifeaturecount++;
                           if (dataset->features[j].type == REGDEF)
                            {
                             dataset->classdefno = j;
                             dataset->newclassdefno = dataset->multifeaturecount - 1;
                            }
                           break;
            }
          }
         else
           dataset->features[j].type = INTEGER;
         j++;
        }
       else
         dataset->availability[i] = NO;
       xmlattribute = xmlattribute->sibling;
       i++;
      }
     if (dataset->storetype == STORE_KERNEL)
       dataset->kernel = NULL;
     if (*datasetcount == 1)
       header = dataset;
     if (datasetbefore)
       datasetbefore->next = dataset;
     datasetbefore = dataset;
     xmldataset = xmldataset->sibling;
    }
  }
 else
   printf(m1052);
 xml_free_document(doc);
 return header;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r13
callq 0x93f7c
testq %rax, %rax
je 0x179b2
movq %rax, %r15
andl $0x0, (%r13)
movq %rax, %rdi
callq 0x94657
testl %eax, %eax
je 0x179b7
movq 0x8(%r15), %rbx
addq $0x20, %rbx
xorl %r14d, %r14d
xorl %ebp, %ebp
movq %r15, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x179c6
movq %rbp, 0x28(%rsp)
movq %r14, 0x30(%rsp)
incl (%r13)
movl $0x1407278, %edi        # imm = 0x1407278
leaq 0x7ff41(%rip), %rsi     # 0x9721c
pushq $0x14
popq %rdx
callq 0x34f59
movq %rax, %rbp
movl $0x1, (%rax)
andq $0x0, 0x1407270(%rax)
movq %rbx, 0x8(%rsp)
movq 0x8(%rax), %r14
movq 0x8(%rsp), %rdi
leaq 0x8779b(%rip), %rsi     # 0x9eaa4
callq 0x94309
movq %r14, %rdi
movq %rax, %rsi
callq 0x3604c
movq %rax, 0x8(%rbp)
movq 0x1b0(%rbp), %r14
movq 0x8(%rsp), %rdi
leaq 0x848be(%rip), %rsi     # 0x9bbee
callq 0x94309
movq %r14, %rdi
movq %rax, %rsi
callq 0x3604c
movq %rax, 0x1b0(%rbp)
movq 0x1407118(%rbp), %r14
movq 0x8(%rsp), %rdi
leaq 0x8790d(%rip), %rsi     # 0x9ec67
callq 0x94309
movq %r14, %rdi
movq 0x8(%rsp), %rbx
movq %rax, %rsi
callq 0x3604c
movq %rax, 0x1407118(%rbp)
movq %rbx, %rdi
leaq 0x7e426(%rip), %rsi     # 0x957a6
callq 0x94309
testq %rax, %rax
je 0x17394
movq %rax, %rdi
callq 0x4200
jmp 0x17396
xorl %eax, %eax
movl %eax, 0x1407120(%rbp)
movq %rbx, %rdi
leaq 0x7fe87(%rip), %rsi     # 0x9722d
callq 0x94309
testq %rax, %rax
je 0x173b4
movb (%rax), %al
jmp 0x173b6
movb $0x20, %al
movb %al, 0x1a8(%rbp)
movq %rbx, %rdi
leaq 0x7fe71(%rip), %rsi     # 0x97237
callq 0x94309
testq %rax, %rax
je 0x173e1
movq 0x1407108(%rbp), %rdi
movq %rax, %rsi
callq 0x3604c
jmp 0x173e3
xorl %eax, %eax
movq %rax, 0x1407108(%rbp)
movq %rbx, %rdi
leaq 0x7fe4b(%rip), %rsi     # 0x9723f
callq 0x94309
testq %rax, %rax
je 0x1740f
movq 0x1407110(%rbp), %rdi
movq %rax, %rsi
callq 0x3604c
jmp 0x17411
xorl %eax, %eax
movq %rax, 0x1407110(%rbp)
orl $-0x1, 0x1407138(%rbp)
movq %rbx, %rdi
leaq 0x7e413(%rip), %rsi     # 0x9583c
callq 0x94309
testq %rax, %rax
je 0x1743d
movq %rax, %rdi
callq 0x4130
jmp 0x17441
xorpd %xmm0, %xmm0
movsd %xmm0, 0x1407130(%rbp)
movq %rbx, %rdi
leaq 0x7fdf6(%rip), %rsi     # 0x97249
callq 0x94309
movq %rax, %r14
movq %rax, %rdi
leaq 0x7f4cb(%rip), %rsi     # 0x96930
callq 0x35f65
testl %eax, %eax
je 0x1753b
movq %r14, %rdi
leaq 0x7f4ab(%rip), %rsi     # 0x96927
callq 0x35f65
testl %eax, %eax
je 0x17544
movq %r14, %rdi
leaq 0x7f4a2(%rip), %rsi     # 0x96935
callq 0x35f65
testl %eax, %eax
je 0x17550
movq %r14, %rdi
leaq 0x7f496(%rip), %rsi     # 0x96940
callq 0x35f65
testl %eax, %eax
je 0x1755c
movq %r14, %rdi
leaq 0x8a617(%rip), %rsi     # 0xa1ad8
callq 0x35f65
testl %eax, %eax
jne 0x175b9
movl $0x3, 0x140713c(%rbp)
movq 0x8(%rsp), %rdi
leaq 0x7fd89(%rip), %rsi     # 0x9726d
callq 0x94591
movq %rax, %r14
movq %rax, %rdi
callq 0x944ea
movl %eax, 0x1407268(%rbp)
addq $0x20, %r14
leaq 0x1407218(%rbp), %rbx
movq (%r14), %r14
testq %r14, %r14
je 0x175b9
movq (%rbx), %r12
movq %r14, %rdi
leaq 0x822f7(%rip), %rsi     # 0x99815
callq 0x94309
movq %r12, %rdi
movq %rax, %rsi
callq 0x3604c
movq %rax, (%rbx)
addq $0x28, %r14
addq $0x8, %rbx
jmp 0x17505
andl $0x0, 0x140713c(%rbp)
jmp 0x175b9
movl $0x1, 0x140713c(%rbp)
jmp 0x175b9
movl $0x2, 0x140713c(%rbp)
jmp 0x175b9
movl $0x4, 0x140713c(%rbp)
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
leaq 0x7fcdd(%rip), %rsi     # 0x97252
callq 0x94309
testq %rax, %rax
je 0x17589
movq %rax, %rdi
callq 0x4200
jmp 0x1758b
xorl %eax, %eax
movl %eax, 0x10(%rbp)
movq %rbx, %rdi
leaq 0x7fcc5(%rip), %rsi     # 0x9725d
callq 0x94309
testq %rax, %rax
je 0x175b2
movq %rax, %rdi
callq 0x4200
movl %eax, 0x1407128(%rbp)
jmp 0x175b9
orl $-0x1, 0x1407128(%rbp)
movq 0x8(%rbp), %rsi
leaq 0x7fcb1(%rip), %rdi     # 0x97275
xorl %eax, %eax
callq 0x4030
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
leaq 0x7fcaf(%rip), %rsi     # 0x97289
callq 0x94309
cmpl $0x4, 0x140713c(%rbp)
je 0x176ec
movq %rax, %rdi
leaq 0x7e56f(%rip), %rsi     # 0x95b65
callq 0x35f65
testl %eax, %eax
je 0x17616
andl $0x0, 0x10(%rbp)
orl $-0x1, 0x1407128(%rbp)
orl $-0x1, 0x1407138(%rbp)
jmp 0x176ec
movq %rbx, %rdi
leaq 0x871ee(%rip), %rsi     # 0x9e80e
callq 0x94591
movq %rax, %r14
movq %rax, %rdi
callq 0x944ea
movl %eax, 0x10(%rbp)
cmpl $0x33, %eax
jge 0x17a06
addq $0x20, %r14
leaq 0x1407140(%rbp), %rax
movq %rax, 0x10(%rsp)
xorl %ebx, %ebx
movq (%r14), %r14
testq %r14, %r14
je 0x176a7
movq 0x18(%rbp,%rbx,2), %r12
movq %r14, %rdi
leaq 0x821b0(%rip), %rsi     # 0x99815
callq 0x94309
movq %r12, %rdi
movq %rax, %rsi
callq 0x3604c
movq %rax, 0x18(%rbp,%rbx,2)
movq %r14, %rdi
leaq 0x7e122(%rip), %rsi     # 0x957a6
callq 0x94309
testq %rax, %rax
je 0x1769d
movq %rax, %rdi
callq 0x4200
movl %eax, 0x1407140(%rbp,%rbx)
addq $0x28, %r14
addq $0x4, %rbx
jmp 0x1764e
movl 0x10(%rbp), %esi
movq 0x10(%rsp), %rdi
callq 0x336b5
cltq
cvtsi2sdl 0x1407140(%rbp,%rax,4), %xmm0
cvtsi2sdl 0x1407120(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0x7de4d(%rip), %xmm1    # 0x95520
subsd %xmm0, %xmm1
mulsd 0x7e6c9(%rip), %xmm1    # 0x95da8
movsd %xmm1, 0x1407208(%rbp)
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
leaq 0x7fb98(%rip), %rsi     # 0x9728e
callq 0x94591
movq %rax, %r14
movq %rax, %rdi
callq 0x944ea
movl %eax, 0x1b8(%rbp)
cmpl $0x61a9, %eax           # imm = 0x61A9
jge 0x179ef
movq %r14, %rdi
leaq 0x7fb78(%rip), %rbx     # 0x97299
movq %rbx, %rsi
leaq 0x7fb78(%rip), %r15     # 0x972a3
movq %r15, %rdx
callq 0x94501
movl %eax, 0x1bc(%rbp)
andl $0x0, 0x1c0(%rbp)
addq $0x20, %r14
leaq 0x30f08(%rbp), %rax
movq %rax, 0x10(%rsp)
xorl %r13d, %r13d
xorl %r12d, %r12d
movq (%r14), %r14
testq %r14, %r14
je 0x1796a
movq %r14, %rdi
movq %rbx, %rsi
callq 0x94309
testq %rax, %rax
je 0x17781
movq %rax, %rdi
movq %r15, %rsi
callq 0x35f65
testl %eax, %eax
je 0x1778f
andl $0x0, 0x1c4(%rbp,%r13,4)
jmp 0x1795e
pushq $0x1
popq %rcx
movl %ecx, 0x1c4(%rbp,%r13,4)
movslq %r12d, %rax
imulq $0x340, %rax, %rax      # imm = 0x340
movq 0x10(%rsp), %rdx
leaq (%rdx,%rax), %r15
movl %ecx, 0x1c(%rdx,%rax)
movq %r14, %rdi
leaq 0x7fdb9(%rip), %rsi     # 0x97574
callq 0x94309
testq %rax, %rax
je 0x17878
movq %rax, %rdi
leaq 0xb532d(%rip), %rsi     # 0xccb00
pushq $0x4
popq %rdx
callq 0x35f17
movl %eax, (%r15)
cmpl $0x4, %eax
ja 0x1794d
movl %eax, %eax
leaq 0x7ece8(%rip), %rcx     # 0x964d8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r14, %rdi
leaq 0x7faa5(%rip), %rsi     # 0x972a8
callq 0x94309
movsd 0x7dd00(%rip), %xmm0    # 0x95510
testq %rax, %rax
je 0x1781d
movq %rax, %rdi
callq 0x4130
movsd %xmm0, 0x8(%r15)
movq %r14, %rdi
leaq 0x7e66d(%rip), %rsi     # 0x95e9a
callq 0x94309
movsd 0x7dcde(%rip), %xmm0    # 0x95518
testq %rax, %rax
je 0x17847
movq %rax, %rdi
callq 0x4130
movsd %xmm0, 0x10(%r15)
movl 0x1c0(%rbp), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x1c0(%rbp)
cmpl $0x4, (%r15)
jne 0x1794d
movl %r12d, 0x1407128(%rbp)
movl %eax, 0x1407138(%rbp)
jmp 0x1794d
andl $0x0, (%r15)
jmp 0x1794d
cmpl $0x0, 0x10(%rbp)
je 0x1790b
movq %r14, %rdi
callq 0x944ea
movl %eax, 0x18(%r15)
cmpl $0x65, %eax
jge 0x179e0
cmpl $0x1, (%r15)
movl 0x1c0(%rbp), %ecx
je 0x178bc
movl %r12d, 0x1407128(%rbp)
movl %ecx, 0x1407138(%rbp)
pushq $0x1
popq %rax
addl %eax, %ecx
movl %ecx, 0x1c0(%rbp)
leaq 0x20(%r14), %rbx
addq $0x20, %r15
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x1794d
movq (%r15), %rdi
movq 0x8(%rbx), %rsi
callq 0x3604c
movq %rax, (%r15)
addq $0x28, %rbx
addq $0x8, %r15
jmp 0x178cc
movq %r14, %rdi
leaq 0x7f9b1(%rip), %rsi     # 0x972a8
callq 0x94309
testq %rax, %rax
je 0x17917
movq %rax, %rdi
callq 0x4200
jmp 0x1791c
movl $0x4, (%r15)
jmp 0x177f9
movl $0x80000001, %eax       # imm = 0x80000001
movl %eax, 0x8(%r15)
movq %r14, %rdi
leaq 0x7e570(%rip), %rsi     # 0x95e9a
callq 0x94309
testq %rax, %rax
je 0x1793e
movq %rax, %rdi
callq 0x4200
jmp 0x17943
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, 0x10(%r15)
incl 0x1c0(%rbp)
incl %r12d
leaq 0x7f942(%rip), %rbx     # 0x97299
leaq 0x7f945(%rip), %r15     # 0x972a3
addq $0x28, %r14
incq %r13
jmp 0x17756
cmpl $0x3, 0x140713c(%rbp)
jne 0x1797b
andq $0x0, 0x1407210(%rbp)
movq 0x18(%rsp), %r13
cmpl $0x1, (%r13)
movq 0x30(%rsp), %r14
cmoveq %rbp, %r14
movq 0x28(%rsp), %rax
testq %rax, %rax
movq 0x20(%rsp), %r15
movq 0x8(%rsp), %rbx
je 0x179a9
movq %rbp, 0x1407270(%rax)
addq $0x28, %rbx
jmp 0x172b5
xorl %r14d, %r14d
jmp 0x179ce
leaq 0x7fd91(%rip), %rdi     # 0x9774f
callq 0x4090
xorl %r14d, %r14d
movq %r15, %rdi
callq 0x94639
movq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
incl %r12d
leaq 0x7eeff(%rip), %rdi     # 0x968e9
movl %r12d, %esi
jmp 0x179f8
leaq 0x7f5a3(%rip), %rdi     # 0x96f99
movl %eax, %esi
xorl %eax, %eax
callq 0x4030
xorl %edi, %edi
callq 0x40c0
leaq 0x7f4c9(%rip), %rdi     # 0x96ed6
jmp 0x179f6