// File: /workspace/github_c_makefile_star2_O1/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 0xa075c
testq %rax, %rax
je 0x19094
movq %rax, %rbx
movl $0x0, (%r14)
movq %rax, %rdi
callq 0xa0e78
testl %eax, %eax
movq %rbx, 0x8(%rsp)
je 0x19099
movq 0x8(%rbx), %rax
movq 0x20(%rax), %r13
testq %r13, %r13
je 0x190a5
leaq 0x8b986(%rip), %rbp     # 0xa42b7
xorl %r12d, %r12d
xorl %r15d, %r15d
movq %r14, 0x10(%rsp)
movq %r12, 0x20(%rsp)
incl (%r14)
movl $0x1407278, %edi        # imm = 0x1407278
leaq 0x8b8ea(%rip), %rsi     # 0xa423a
movl $0x14, %edx
callq 0x390f5
movq %rax, %r12
movl $0x1, (%rax)
movq $0x0, 0x1407270(%rax)
movq 0x8(%rax), %rbx
movq %r13, %rdi
leaq 0x93138(%rip), %rsi     # 0xabab4
callq 0xa0b21
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3a404
movq %rax, 0x8(%r12)
movq 0x1b0(%r12), %rbx
movq %r13, %rdi
leaq 0x9025b(%rip), %rsi     # 0xa8bfe
callq 0xa0b21
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3a404
movq %rax, 0x1b0(%r12)
movq 0x1407118(%r12), %rbx
movq %r13, %rdi
leaq 0x932aa(%rip), %rsi     # 0xabc77
callq 0xa0b21
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3a404
movq %rax, 0x1407118(%r12)
movq %r13, %rdi
leaq 0x89db7(%rip), %rsi     # 0xa27a6
callq 0xa0b21
movq %rax, %rdi
movl $0x0, %eax
testq %rdi, %rdi
je 0x18a06
callq 0x4200
movl %eax, 0x1407120(%r12)
movq %r13, %rdi
leaq 0x8b833(%rip), %rsi     # 0xa424b
callq 0xa0b21
testq %rax, %rax
je 0x18a26
movb (%rax), %al
jmp 0x18a28
movb $0x20, %al
movb %al, 0x1a8(%r12)
movq %r13, %rdi
leaq 0x8b81b(%rip), %rsi     # 0xa4255
callq 0xa0b21
testq %rax, %rax
je 0x18a56
movq 0x1407108(%r12), %rdi
movq %rax, %rsi
callq 0x3a404
jmp 0x18a58
xorl %eax, %eax
movq %rax, 0x1407108(%r12)
movq %r13, %rdi
leaq 0x8b7f3(%rip), %rsi     # 0xa425d
callq 0xa0b21
testq %rax, %rax
je 0x18a86
movq 0x1407110(%r12), %rdi
movq %rax, %rsi
callq 0x3a404
jmp 0x18a88
xorl %eax, %eax
movq %rax, 0x1407110(%r12)
movl $0xffffffff, 0x1407138(%r12) # imm = 0xFFFFFFFF
movq %r13, %rdi
leaq 0x89d96(%rip), %rsi     # 0xa283c
callq 0xa0b21
testq %rax, %rax
je 0x18aba
movq %rax, %rdi
callq 0x4130
jmp 0x18abe
xorpd %xmm0, %xmm0
movsd %xmm0, 0x1407130(%r12)
movq %r13, %rdi
leaq 0x8b795(%rip), %rsi     # 0xa4267
callq 0xa0b21
movq %rax, %rbx
movq %rax, %rdi
leaq 0x8ae68(%rip), %rsi     # 0xa394c
callq 0x3a318
testl %eax, %eax
movq %r15, 0x28(%rsp)
je 0x18bc7
movq %rbx, %rdi
leaq 0x8ae43(%rip), %rsi     # 0xa3943
callq 0x3a318
testl %eax, %eax
je 0x18bd5
movq %rbx, %rdi
leaq 0x8ae3a(%rip), %rsi     # 0xa3951
callq 0x3a318
testl %eax, %eax
je 0x18be3
movq %rbx, %rdi
leaq 0x8ae2e(%rip), %rsi     # 0xa395c
callq 0x3a318
testl %eax, %eax
je 0x18bf1
movq %rbx, %rdi
leaq 0x95fbb(%rip), %rsi     # 0xaeb00
callq 0x3a318
testl %eax, %eax
jne 0x18c54
movl $0x3, 0x140713c(%r12)
movq %r13, %rdi
leaq 0x8b723(%rip), %rsi     # 0xa428b
callq 0xa0db3
movq %rax, %rbx
movq %rax, %rdi
callq 0xa0d0f
movl %eax, 0x1407268(%r12)
movq 0x20(%rbx), %rbx
testq %rbx, %rbx
je 0x18c54
leaq 0x1407218(%r12), %r15
movq (%r15), %r14
movq %rbx, %rdi
leaq 0x8dcd5(%rip), %rsi     # 0xa6877
callq 0xa0b21
movq %r14, %rdi
movq %rax, %rsi
callq 0x3a404
movq %rax, (%r15)
movq 0x28(%rbx), %rbx
addq $0x8, %r15
testq %rbx, %rbx
jne 0x18b95
jmp 0x18c54
movl $0x0, 0x140713c(%r12)
jmp 0x18c54
movl $0x1, 0x140713c(%r12)
jmp 0x18c54
movl $0x2, 0x140713c(%r12)
jmp 0x18c54
movl $0x4, 0x140713c(%r12)
movq %r13, %rdi
leaq 0x8b669(%rip), %rsi     # 0xa4270
callq 0xa0b21
testq %rax, %rax
je 0x18c1b
movq %rax, %rdi
callq 0x4200
jmp 0x18c1d
xorl %eax, %eax
movl %eax, 0x10(%r12)
movq %r13, %rdi
leaq 0x8b64f(%rip), %rsi     # 0xa427b
callq 0xa0b21
testq %rax, %rax
je 0x18c48
movq %rax, %rdi
callq 0x4200
movl %eax, 0x1407128(%r12)
jmp 0x18c54
movl $0xffffffff, 0x1407128(%r12) # imm = 0xFFFFFFFF
movq 0x8(%r12), %rsi
leaq 0x8b633(%rip), %rdi     # 0xa4293
xorl %eax, %eax
callq 0x4030
movq %r13, %rdi
leaq 0x8b636(%rip), %rsi     # 0xa42a7
callq 0xa0b21
cmpl $0x4, 0x140713c(%r12)
leaq 0x8b63b(%rip), %r15     # 0xa42c1
je 0x18d9f
movq %rax, %rdi
leaq 0x89ecf(%rip), %rsi     # 0xa2b65
callq 0x3a318
testl %eax, %eax
je 0x18cc2
movl $0x0, 0x10(%r12)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x1407128(%r12)
movl %eax, 0x1407138(%r12)
jmp 0x18d9f
movq %r13, %rdi
leaq 0x92b52(%rip), %rsi     # 0xab81e
callq 0xa0db3
movq %rax, %rbx
movq %rax, %rdi
callq 0xa0d0f
movl %eax, 0x10(%r12)
cmpl $0x33, %eax
jge 0x190e8
movq 0x20(%rbx), %rbx
testq %rbx, %rbx
je 0x18d4b
xorl %r15d, %r15d
movq 0x18(%r12,%r15,2), %r14
movq %rbx, %rdi
leaq 0x8db72(%rip), %rsi     # 0xa6877
callq 0xa0b21
movq %r14, %rdi
movq %rax, %rsi
callq 0x3a404
movq %rax, 0x18(%r12,%r15,2)
movq %rbx, %rdi
leaq 0x89a82(%rip), %rsi     # 0xa27a6
callq 0xa0b21
testq %rax, %rax
je 0x18d3e
movq %rax, %rdi
callq 0x4200
movl %eax, 0x1407140(%r12,%r15)
movq 0x28(%rbx), %rbx
addq $0x4, %r15
testq %rbx, %rbx
jne 0x18cf6
leaq 0x1407140(%r12), %rdi
movl 0x10(%r12), %esi
callq 0x37504
cltq
xorps %xmm0, %xmm0
cvtsi2sdl 0x1407140(%r12,%rax,4), %xmm0
cvtsi2sdl 0x1407120(%r12), %xmm1
divsd %xmm1, %xmm0
movsd 0x8979e(%rip), %xmm1    # 0xa2520
subsd %xmm0, %xmm1
mulsd 0x8a012(%rip), %xmm1    # 0xa2da0
movsd %xmm1, 0x1407208(%r12)
leaq 0x8b522(%rip), %r15     # 0xa42c1
movq %r13, 0x18(%rsp)
movq %r13, %rdi
leaq 0x8b4fe(%rip), %rsi     # 0xa42ac
callq 0xa0db3
movq %rax, %rbx
movq %rax, %rdi
callq 0xa0d0f
movl %eax, 0x1b8(%r12)
cmpl $0x61a9, %eax           # imm = 0x61A9
jge 0x190c4
movq %rbx, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0xa0d23
movl %eax, 0x1bc(%r12)
movl $0x0, 0x1c0(%r12)
movq 0x20(%rbx), %r14
testq %r14, %r14
je 0x19046
leaq 0x30f08(%r12), %rax
movq %rax, 0x30(%rsp)
xorl %r13d, %r13d
xorl %ebx, %ebx
movq %r14, %rdi
movq %rbp, %rsi
callq 0xa0b21
testq %rax, %rax
je 0x18e31
movq %rax, %rdi
movq %r15, %rsi
callq 0x3a318
testl %eax, %eax
je 0x18e42
movl $0x0, 0x1c4(%r12,%r13,4)
jmp 0x19036
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 0x8b722(%rip), %rsi     # 0xa4592
callq 0xa0b21
testq %rax, %rax
je 0x18ef8
movq %rax, %rdi
leaq 0xb8c7c(%rip), %rsi     # 0xd1b00
movl $0x4, %edx
callq 0x3a2c5
movl %eax, (%r15)
cmpl $0x3, %eax
jne 0x18ea5
cmpl $0x0, 0x10(%r12)
jne 0x18ea5
movl $0x4, (%r15)
movl (%r15), %eax
cmpq $0x4, %rax
ja 0x19026
leaq 0x8a65b(%rip), %rcx     # 0xa3514
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r14, %rdi
callq 0xa0d0f
movl %eax, 0x18(%r15)
cmpl $0x65, %eax
jge 0x190cf
cmpl $0x1, (%r15)
movl 0x1c0(%r12), %ecx
jne 0x18fa8
addl %eax, %ecx
movl %ecx, 0x1c0(%r12)
jmp 0x18fc3
movl $0x0, (%r15)
jmp 0x19026
movq %r14, %rdi
leaq 0x8b3b8(%rip), %rsi     # 0xa42c6
callq 0xa0b21
movsd 0x895f5(%rip), %xmm0    # 0xa2510
testq %rax, %rax
je 0x18f28
movq %rax, %rdi
callq 0x4130
movsd %xmm0, 0x8(%r15)
movq %r14, %rdi
leaq 0x89f5a(%rip), %rsi     # 0xa2e92
callq 0xa0b21
movsd 0x895d3(%rip), %xmm0    # 0xa2518
testq %rax, %rax
je 0x18f52
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 0x19026
movl %ebx, 0x1407128(%r12)
movl %eax, 0x1407138(%r12)
jmp 0x19026
movq %r14, %rdi
leaq 0x8b332(%rip), %rsi     # 0xa42c6
callq 0xa0b21
testq %rax, %rax
je 0x18fee
movq %rax, %rdi
callq 0x4200
jmp 0x18ff3
leal 0x1(%rcx), %eax
movl %eax, 0x1c0(%r12)
movl %ebx, 0x1407128(%r12)
movl %ecx, 0x1407138(%r12)
movq 0x20(%r14), %rbp
testq %rbp, %rbp
je 0x19026
addq $0x20, %r15
movq (%r15), %rdi
movq 0x8(%rbp), %rsi
callq 0x3a404
movq %rax, (%r15)
movq 0x28(%rbp), %rbp
addq $0x8, %r15
testq %rbp, %rbp
jne 0x18fd0
jmp 0x19026
movl $0x80000001, %eax       # imm = 0x80000001
movl %eax, 0x8(%r15)
movq %r14, %rdi
leaq 0x89e91(%rip), %rsi     # 0xa2e92
callq 0xa0b21
testq %rax, %rax
je 0x19015
movq %rax, %rdi
callq 0x4200
jmp 0x1901a
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, 0x10(%r15)
incl 0x1c0(%r12)
incl %ebx
leaq 0x8b288(%rip), %rbp     # 0xa42b7
leaq 0x8b28b(%rip), %r15     # 0xa42c1
incq %r13
movq 0x28(%r14), %r14
testq %r14, %r14
jne 0x18e12
cmpl $0x3, 0x140713c(%r12)
movq 0x20(%rsp), %rax
jne 0x19062
movq $0x0, 0x1407210(%r12)
movq 0x10(%rsp), %r14
cmpl $0x1, (%r14)
movq 0x28(%rsp), %r15
cmoveq %r12, %r15
testq %rax, %rax
movq 0x18(%rsp), %r13
je 0x19085
movq %r12, 0x1407270(%rax)
movq 0x28(%r13), %r13
testq %r13, %r13
jne 0x1893c
jmp 0x190a8
xorl %r15d, %r15d
jmp 0x190b2
leaq 0x8b6cd(%rip), %rdi     # 0xa476d
callq 0x4090
xorl %r15d, %r15d
movq 0x8(%rsp), %rdi
callq 0xa0e5a
movq %r15, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x8aeec(%rip), %rdi     # 0xa3fb7
movl %eax, %esi
jmp 0x190da
incl %ebx
leaq 0x8a82d(%rip), %rdi     # 0xa3905
movl %ebx, %esi
xorl %eax, %eax
callq 0x4030
xorl %edi, %edi
callq 0x40c0
leaq 0x8ae03(%rip), %rdi     # 0xa3ef2
jmp 0x190cb