// File: /workspace/github_c_makefile_star2_O3/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, %r14
callq 0xa36cc
testq %rax, %rax
je 0x19603
movq %rax, %rbx
movl $0x0, (%r14)
movq %rax, %rdi
callq 0xa3de1
testl %eax, %eax
movq %rbx, 0x8(%rsp)
je 0x19608
movq 0x8(%rbx), %rax
movq 0x20(%rax), %r13
testq %r13, %r13
je 0x19614
movl (%r14), %eax
leaq 0x8e45a(%rip), %rbp     # 0xa72f9
xorl %r12d, %r12d
xorl %r15d, %r15d
movq %r14, 0x10(%rsp)
movq %r12, 0x20(%rsp)
incl %eax
movl %eax, (%r14)
movl $0x1407278, %edi        # imm = 0x1407278
leaq 0x8e3bc(%rip), %rsi     # 0xa727c
movl $0x14, %edx
callq 0x3a0e1
movq %rax, %r12
movl $0x1, (%rax)
movq $0x0, 0x1407270(%rax)
movq 0x8(%rax), %rbx
movq %r13, %rdi
leaq 0x95c94(%rip), %rsi     # 0xaeb80
callq 0xa3a8c
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3b494
movq %rax, 0x8(%r12)
movq 0x1b0(%r12), %rbx
movq %r13, %rdi
leaq 0x92db7(%rip), %rsi     # 0xabcca
callq 0xa3a8c
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3b494
movq %rax, 0x1b0(%r12)
movq 0x1407118(%r12), %rbx
movq %r13, %rdi
leaq 0x95e06(%rip), %rsi     # 0xaed43
callq 0xa3a8c
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3b494
movq %rax, 0x1407118(%r12)
movq %r13, %rdi
leaq 0x8c847(%rip), %rsi     # 0xa57a6
callq 0xa3a8c
movq %rax, %rdi
movl $0x0, %eax
testq %rdi, %rdi
je 0x18f76
callq 0x4200
movl %eax, 0x1407120(%r12)
movq %r13, %rdi
leaq 0x8e305(%rip), %rsi     # 0xa728d
callq 0xa3a8c
testq %rax, %rax
je 0x18f96
movb (%rax), %al
jmp 0x18f98
movb $0x20, %al
movb %al, 0x1a8(%r12)
movq %r13, %rdi
leaq 0x8e2ed(%rip), %rsi     # 0xa7297
callq 0xa3a8c
testq %rax, %rax
je 0x18fc6
movq 0x1407108(%r12), %rdi
movq %rax, %rsi
callq 0x3b494
jmp 0x18fc8
xorl %eax, %eax
movq %rax, 0x1407108(%r12)
movq %r13, %rdi
leaq 0x8e2c5(%rip), %rsi     # 0xa729f
callq 0xa3a8c
testq %rax, %rax
je 0x18ff6
movq 0x1407110(%r12), %rdi
movq %rax, %rsi
callq 0x3b494
jmp 0x18ff8
xorl %eax, %eax
movq %rax, 0x1407110(%r12)
movl $0xffffffff, 0x1407138(%r12) # imm = 0xFFFFFFFF
movq %r13, %rdi
leaq 0x8c826(%rip), %rsi     # 0xa583c
callq 0xa3a8c
testq %rax, %rax
je 0x1902a
movq %rax, %rdi
callq 0x4130
jmp 0x1902e
xorpd %xmm0, %xmm0
movsd %xmm0, 0x1407130(%r12)
movq %r13, %rdi
leaq 0x8e267(%rip), %rsi     # 0xa72a9
callq 0xa3a8c
movq %rax, %rbx
movq %rax, %rdi
leaq 0x8d93c(%rip), %rsi     # 0xa6990
callq 0x3b3a8
testl %eax, %eax
movq %r15, 0x28(%rsp)
je 0x19137
movq %rbx, %rdi
leaq 0x8d917(%rip), %rsi     # 0xa6987
callq 0x3b3a8
testl %eax, %eax
je 0x19145
movq %rbx, %rdi
leaq 0x8d90e(%rip), %rsi     # 0xa6995
callq 0x3b3a8
testl %eax, %eax
je 0x19153
movq %rbx, %rdi
leaq 0x8d902(%rip), %rsi     # 0xa69a0
callq 0x3b3a8
testl %eax, %eax
je 0x19161
movq %rbx, %rdi
leaq 0x98ac3(%rip), %rsi     # 0xb1b78
callq 0x3b3a8
testl %eax, %eax
jne 0x191c4
movl $0x3, 0x140713c(%r12)
movq %r13, %rdi
leaq 0x8e1f5(%rip), %rsi     # 0xa72cd
callq 0xa3d1c
movq %rax, %rbx
movq %rax, %rdi
callq 0xa3c78
movl %eax, 0x1407268(%r12)
movq 0x20(%rbx), %rbx
testq %rbx, %rbx
je 0x191c4
leaq 0x1407218(%r12), %r15
movq (%r15), %r14
movq %rbx, %rdi
leaq 0x90793(%rip), %rsi     # 0xa98a5
callq 0xa3a8c
movq %r14, %rdi
movq %rax, %rsi
callq 0x3b494
movq %rax, (%r15)
movq 0x28(%rbx), %rbx
addq $0x8, %r15
testq %rbx, %rbx
jne 0x19105
jmp 0x191c4
movl $0x0, 0x140713c(%r12)
jmp 0x191c4
movl $0x1, 0x140713c(%r12)
jmp 0x191c4
movl $0x2, 0x140713c(%r12)
jmp 0x191c4
movl $0x4, 0x140713c(%r12)
movq %r13, %rdi
leaq 0x8e13b(%rip), %rsi     # 0xa72b2
callq 0xa3a8c
testq %rax, %rax
je 0x1918b
movq %rax, %rdi
callq 0x4200
jmp 0x1918d
xorl %eax, %eax
movl %eax, 0x10(%r12)
movq %r13, %rdi
leaq 0x8e121(%rip), %rsi     # 0xa72bd
callq 0xa3a8c
testq %rax, %rax
je 0x191b8
movq %rax, %rdi
callq 0x4200
movl %eax, 0x1407128(%r12)
jmp 0x191c4
movl $0xffffffff, 0x1407128(%r12) # imm = 0xFFFFFFFF
movq 0x8(%r12), %rsi
leaq 0x8e105(%rip), %rdi     # 0xa72d5
xorl %eax, %eax
callq 0x4030
movq %r13, %rdi
leaq 0x8e108(%rip), %rsi     # 0xa72e9
callq 0xa3a8c
cmpl $0x4, 0x140713c(%r12)
leaq 0x8e10d(%rip), %r15     # 0xa7303
je 0x19311
movq %rax, %rdi
leaq 0x8c95f(%rip), %rsi     # 0xa5b65
callq 0x3b3a8
testl %eax, %eax
je 0x19232
movl $0x0, 0x10(%r12)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x1407128(%r12)
movl %eax, 0x1407138(%r12)
jmp 0x19311
movq %r13, %rdi
leaq 0x956ae(%rip), %rsi     # 0xae8ea
callq 0xa3d1c
movq %rax, %rbx
movq %rax, %rdi
callq 0xa3c78
movl %eax, 0x10(%r12)
cmpl $0x33, %eax
jge 0x19657
movq 0x20(%rbx), %rbx
testq %rbx, %rbx
je 0x192c0
xorl %r15d, %r15d
movq 0x18(%r12,%r15,2), %r14
movq %rbx, %rdi
leaq 0x90630(%rip), %rsi     # 0xa98a5
callq 0xa3a8c
movq %r14, %rdi
movq %rax, %rsi
callq 0x3b494
movq %rax, 0x18(%r12,%r15,2)
movq %rbx, %rdi
leaq 0x8c512(%rip), %rsi     # 0xa57a6
callq 0xa3a8c
testq %rax, %rax
je 0x192ae
movq %rax, %rdi
callq 0x4200
movl %eax, 0x1407140(%r12,%r15)
movq 0x28(%rbx), %rbx
addq $0x4, %r15
testq %rbx, %rbx
jne 0x19266
movl 0x10(%r12), %eax
leaq 0x1407140(%r12), %rdi
movl %eax, %esi
callq 0x38002
cltq
xorps %xmm0, %xmm0
cvtsi2sdl 0x1407140(%r12,%rax,4), %xmm0
cvtsi2sdl 0x1407120(%r12), %xmm1
divsd %xmm1, %xmm0
movsd 0x8c22c(%rip), %xmm1    # 0xa5520
subsd %xmm0, %xmm1
mulsd 0x8caa0(%rip), %xmm1    # 0xa5da0
movsd %xmm1, 0x1407208(%r12)
leaq 0x8dff2(%rip), %r15     # 0xa7303
movq %r13, 0x18(%rsp)
movq %r13, %rdi
leaq 0x8dfce(%rip), %rsi     # 0xa72ee
callq 0xa3d1c
movq %rax, %rbx
movq %rax, %rdi
callq 0xa3c78
movl %eax, 0x1b8(%r12)
cmpl $0x61a9, %eax           # imm = 0x61A9
jge 0x19633
movq %rbx, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0xa3c8c
movl %eax, 0x1bc(%r12)
movl $0x0, 0x1c0(%r12)
movq 0x20(%rbx), %r14
testq %r14, %r14
je 0x195b3
leaq 0x30f08(%r12), %rax
movq %rax, 0x30(%rsp)
xorl %r13d, %r13d
xorl %ebx, %ebx
movq %r14, %rdi
movq %rbp, %rsi
callq 0xa3a8c
testq %rax, %rax
je 0x193a3
movq %rax, %rdi
movq %r15, %rsi
callq 0x3b3a8
testl %eax, %eax
je 0x193b4
movl $0x0, 0x1c4(%r12,%r13,4)
jmp 0x195a3
movl $0x1, %ecx
movl %ecx, 0x1c4(%r12,%r13,4)
movslq %ebx, %rax
imulq $0x340, %rax, %rax      # imm = 0x340
movq 0x30(%rsp), %rdx
leaq (%rdx,%rax), %r15
movl %ecx, 0x1c(%rdx,%rax)
movq %r14, %rdi
leaq 0x8e1f2(%rip), %rsi     # 0xa75d4
callq 0xa3a8c
testq %rax, %rax
je 0x194a8
movq %rax, %rdi
leaq 0xbb706(%rip), %rsi     # 0xd4b00
movl $0x4, %edx
callq 0x3b355
movl %eax, (%r15)
cmpl $0x4, %eax
ja 0x19593
movl %eax, %eax
leaq 0x8d13f(%rip), %rcx     # 0xa6558
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r14, %rdi
leaq 0x8dedc(%rip), %rsi     # 0xa7308
callq 0xa3a8c
movsd 0x8c0d7(%rip), %xmm0    # 0xa5510
testq %rax, %rax
je 0x19446
movq %rax, %rdi
callq 0x4130
movsd %xmm0, 0x8(%r15)
movq %r14, %rdi
leaq 0x8ca3c(%rip), %rsi     # 0xa5e92
callq 0xa3a8c
movsd 0x8c0b5(%rip), %xmm0    # 0xa5518
testq %rax, %rax
je 0x19470
movq %rax, %rdi
callq 0x4130
movsd %xmm0, 0x10(%r15)
movl 0x1c0(%r12), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x1c0(%r12)
cmpl $0x4, (%r15)
jne 0x19593
movl %ebx, 0x1407128(%r12)
movl %eax, 0x1407138(%r12)
jmp 0x19593
movl $0x0, (%r15)
jmp 0x19593
cmpl $0x0, 0x10(%r12)
je 0x1954f
movq %r14, %rdi
callq 0xa3c78
movl %eax, 0x18(%r15)
cmpl $0x65, %eax
jge 0x1963e
cmpl $0x1, (%r15)
movl 0x1c0(%r12), %ecx
je 0x194f8
movl %ebx, 0x1407128(%r12)
movl %ecx, 0x1407138(%r12)
movl $0x1, %eax
addl %eax, %ecx
movl %ecx, 0x1c0(%r12)
movq 0x20(%r14), %rbp
testq %rbp, %rbp
je 0x19593
addq $0x20, %r15
movq (%r15), %rdi
movq 0x8(%rbp), %rsi
callq 0x3b494
movq %rax, (%r15)
movq 0x28(%rbp), %rbp
addq $0x8, %r15
testq %rbp, %rbp
jne 0x19513
jmp 0x19593
movq %r14, %rdi
leaq 0x8ddcd(%rip), %rsi     # 0xa7308
callq 0xa3a8c
testq %rax, %rax
je 0x1955b
movq %rax, %rdi
callq 0x4200
jmp 0x19560
movl $0x4, (%r15)
jmp 0x19422
movl $0x80000001, %eax       # imm = 0x80000001
movl %eax, 0x8(%r15)
movq %r14, %rdi
leaq 0x8c924(%rip), %rsi     # 0xa5e92
callq 0xa3a8c
testq %rax, %rax
je 0x19582
movq %rax, %rdi
callq 0x4200
jmp 0x19587
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, 0x10(%r15)
incl 0x1c0(%r12)
incl %ebx
leaq 0x8dd5d(%rip), %rbp     # 0xa72f9
leaq 0x8dd60(%rip), %r15     # 0xa7303
incq %r13
movq 0x28(%r14), %r14
testq %r14, %r14
jne 0x19384
cmpl $0x3, 0x140713c(%r12)
movq 0x20(%rsp), %rcx
jne 0x195cf
movq $0x0, 0x1407210(%r12)
movq 0x10(%rsp), %r14
movl (%r14), %eax
cmpl $0x1, %eax
movq 0x28(%rsp), %r15
cmoveq %r12, %r15
testq %rcx, %rcx
movq 0x18(%rsp), %r13
je 0x195f4
movq %r12, 0x1407270(%rcx)
movq 0x28(%r13), %r13
testq %r13, %r13
jne 0x18eaa
jmp 0x19617
xorl %r15d, %r15d
jmp 0x19621
leaq 0x8e1a0(%rip), %rdi     # 0xa77af
callq 0x4090
xorl %r15d, %r15d
movq 0x8(%rsp), %rdi
callq 0xa3dc3
movq %r15, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8d9bf(%rip), %rdi     # 0xa6ff9
movl %eax, %esi
jmp 0x19649
incl %ebx
leaq 0x8d302(%rip), %rdi     # 0xa6949
movl %ebx, %esi
xorl %eax, %eax
callq 0x4030
xorl %edi, %edi
callq 0x40c0
leaq 0x8d8d8(%rip), %rdi     # 0xa6f36
jmp 0x1963a