// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/dataset.c
// Function: create_sequential_dataset
int create_sequential_dataset(char* datasetname, char* separator, int numfeatures, char* classes, char* directoryname, char* filename, char* discretefeatures)
{
 /*!Last Changed 09.05.2008*/
 Datasetptr tmp;
 int i, classcode, framecount, frameindex;
 char* fname, *st, myline[READLINELENGTH];
 FILE* infile;
 Intervalptr intervals;
 tmp = search_dataset(Datasets, datasetname);
 if (tmp)
  {
   printf(m1120);
   delete_dataset(datasetname);
  }
 tmp = empty_dataset(datasetname, directoryname, filename, separator[0]);
 tmp->datacount = 0;
 tmp->allfeatures = numfeatures;
 tmp->featurecount = tmp->allfeatures;
 tmp->storetype = STORE_SEQUENTIAL;
 for (i = 0; i < tmp->featurecount; i++)
   tmp->availability[i] = YES;
 tmp->classdefno = 0;
 for (i = 0; i < MAXCLASSES; i++)
   tmp->classcounts[i] = 0;
 stringlist(classes, ";", tmp->classes, &(tmp->classno));
 if (tmp->classno)
  {
   tmp->features[0].type = CLASSDEF;
   for (i = 0; i < tmp->classno; i++)
     tmp->features[0].strings[i] = strcopy(tmp->features[0].strings[i], tmp->classes[i]);
   tmp->features[0].valuecount = tmp->classno;
  }
 else
   tmp->features[0].type = REGDEF;
 tmp->features[0].selected = YES;
 intervals = create_intervals(discretefeatures);
 for (i = 1; i < numfeatures; i++)
  {
   tmp->features[i].selected = YES;
   if (is_in_interval(intervals, i))
     tmp->features[i].type = STRING;
   else
     tmp->features[i].type = INTEGER;
  }
 fname = dataset_file_name(tmp);
 infile = fopen(fname, "r");
 if (!infile)
  {
   printf(m1121, fname);
   free_dataset(tmp);
   safe_free(fname);
   free_intervals(intervals);
   return 0;
  }
 while (fgets(myline, READLINELENGTH, infile))
  {
   if (strlen(myline) <= 1)
     continue;
   tmp->datacount++;
   myline[strlen(myline) - 1] = '\0';
   st = strtok(myline, separator);
   classcode = listindex(st, tmp->classes, tmp->classno);
   if (classcode == -1)
    {
     printf(m1260, tmp->datacount, 0);
     free_dataset(tmp);
     safe_free(fname);
     free_intervals(intervals);
     return 0;
    }
   else
     tmp->classcounts[classcode]++;
   st = strtok(NULL, separator);
   framecount = atoi(st);
   frameindex = 0;
   i = 1;
   st = strtok(NULL, separator);
   while (st)
    {
     if (!is_in_interval(intervals, i) && !isinteger(st) && tmp->features[i].type != REAL)
       tmp->features[i].type = REAL;
     i++;
     if (i == numfeatures)
      {
       i = 1;
       frameindex++;
      }
     st = strtok(NULL, separator);
    }
   if (i != 1)
    {
     printf(m1404, frameindex);
     free_dataset(tmp);
     safe_free(fname);
     free_intervals(intervals);
     return 0;     
    }
   if (frameindex != framecount)
    {
     printf(m1403, tmp->datacount, framecount);
     free_dataset(tmp);
     safe_free(fname);
     free_intervals(intervals);
     return 0;
    }
  }
 fclose(infile);
 tmp->active = NO;
 add_dataset(tmp);
 printf(m1126);
 safe_free(fname);
 free_intervals(intervals);
 return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7a158, %rsp          # imm = 0x7A158
movq %r9, %rbx
movq %r8, %r13
movq %rcx, %r12
movl %edx, 0x8(%rsp)
movq %rsi, %r14
movq %rdi, %r15
leaq 0xb7156(%rip), %rax     # 0xcd878
movq (%rax), %rdi
movq %r15, %rsi
callq 0x13da6
testq %rax, %rax
je 0x16746
leaq 0x80f00(%rip), %rdi     # 0x97639
callq 0x4090
movq %r15, %rdi
callq 0x15cdf
movq 0x7a190(%rsp), %rbp
movsbl (%r14), %ecx
movq %r15, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x1434b
movq %rax, %rbx
andl $0x0, 0x1407120(%rax)
movl 0x8(%rsp), %eax
movl %eax, 0x1b8(%rbx)
movl %eax, 0x1bc(%rbx)
movl $0x2, 0x140713c(%rbx)
movslq %eax, %r13
xorl %eax, %eax
cmpq %r13, %rax
jge 0x1679e
movl $0x1, 0x1c4(%rbx,%rax,4)
incq %rax
jmp 0x16789
andl $0x0, 0x1407128(%rbx)
movl $0x501c50, %eax         # imm = 0x501C50
cmpq $0x501c82, %rax         # imm = 0x501C82
je 0x167bb
andl $0x0, (%rbx,%rax,4)
incq %rax
jmp 0x167aa
leaq 0x18(%rbx), %rdx
leaq 0x10(%rbx), %rcx
leaq 0x822a4(%rip), %rsi     # 0x98a6e
movq %r12, %rdi
movq %rdx, 0x28(%rsp)
callq 0x36077
movl 0x10(%rbx), %eax
testl %eax, %eax
je 0x1681d
movl $0x3, 0x30f08(%rbx)
xorl %r15d, %r15d
movslq %eax, %rcx
cmpq %rcx, %r15
jge 0x16815
movq 0x30f28(%rbx,%r15,8), %rdi
movq 0x18(%rbx,%r15,8), %rsi
callq 0x3604c
movq %rax, 0x30f28(%rbx,%r15,8)
incq %r15
movl 0x10(%rbx), %eax
jmp 0x167eb
movl %eax, 0x30f20(%rbx)
jmp 0x16827
movl $0x4, 0x30f08(%rbx)
leaq 0x30f08(%rbx), %rax
movq %rax, 0x18(%rsp)
movl $0x1, 0x30f24(%rbx)
movq %rbp, %rdi
callq 0x2d8d0
movq %rax, %r15
movq %rbx, %rbp
addq $0x31248, %rbp          # imm = 0x31248
pushq $0x1
popq %r12
cmpq %r13, %r12
jge 0x16883
movl $0x1, 0x1c(%rbp)
movq %r15, %rdi
movl %r12d, %esi
callq 0x2d8b6
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
movl %ecx, (%rbp)
incq %r12
addq $0x340, %rbp            # imm = 0x340
jmp 0x16856
movq %rbx, %rdi
callq 0x14f75
movq %rax, %r12
leaq 0x84fea(%rip), %rsi     # 0x9b87f
movq %rax, %rdi
callq 0x40f0
testq %rax, %rax
je 0x169d9
movq %rax, %r13
leaq 0x30(%rsp), %rbp
movq %r12, 0x10(%rsp)
movq %rax, 0x20(%rsp)
movq %rbp, %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %r13, %rdx
callq 0x4120
testq %rax, %rax
je 0x169ee
movq %rbp, %rdi
callq 0x4190
cmpq $0x2, %rax
jb 0x168b8
incl 0x1407120(%rbx)
movq %rbp, %rdi
callq 0x4190
movb $0x0, -0x1(%rax,%rbp)
movq %rbp, %rdi
movq %r14, %rsi
callq 0x4280
movl 0x10(%rbx), %edx
movq %rax, %rdi
movq 0x28(%rsp), %rsi
callq 0x35f17
cmpl $-0x1, %eax
je 0x16a22
cltq
incl 0x1407140(%rbx,%rax,4)
xorl %r13d, %r13d
xorl %edi, %edi
movq %r14, %rsi
callq 0x4280
movq %rax, %rdi
callq 0x4200
movl %eax, 0xc(%rsp)
pushq $0x1
popq %r12
xorl %edi, %edi
movq %r14, %rsi
callq 0x4280
testq %rax, %rax
je 0x169a2
movq %rax, %rbp
movq %r15, %rdi
movl %r12d, %esi
callq 0x2d8b6
testl %eax, %eax
jne 0x16989
movq %rbp, %rdi
callq 0x356ca
testl %eax, %eax
jne 0x16989
movslq %r12d, %rax
imulq $0x340, %rax, %rax      # imm = 0x340
movq 0x18(%rsp), %rcx
cmpl $0x2, (%rcx,%rax)
je 0x16989
addq 0x18(%rsp), %rax
movl $0x2, (%rax)
incl %r12d
xorl %eax, %eax
cmpl 0x8(%rsp), %r12d
sete %al
pushq $0x1
popq %rcx
cmovel %ecx, %r12d
addl %eax, %r13d
jmp 0x1693c
cmpl $0x1, %r12d
leaq 0x30(%rsp), %rbp
jne 0x16a66
movl 0xc(%rsp), %edx
cmpl %edx, %r13d
movq 0x10(%rsp), %r12
movq 0x20(%rsp), %r13
je 0x168b8
movl 0x1407120(%rbx), %esi
leaq 0x8064b(%rip), %rdi     # 0x97020
xorl %ebp, %ebp
jmp 0x16a33
leaq 0x80521(%rip), %rdi     # 0x96f01
xorl %ebp, %ebp
movq %r12, %rsi
xorl %eax, %eax
callq 0x4030
jmp 0x16a3a
movq %r13, %rdi
callq 0x42a0
andl $0x0, (%rbx)
movq %rbx, %rdi
callq 0x145cf
leaq 0x80c94(%rip), %rdi     # 0x9769c
callq 0x4090
movq %r12, %rdi
callq 0x34ff7
movq %r15, %rdi
callq 0x2d888
pushq $0x1
popq %rbp
jmp 0x16a52
movl 0x1407120(%rbx), %esi
leaq 0x8052d(%rip), %rdi     # 0x96f5c
xorl %ebp, %ebp
xorl %edx, %edx
xorl %eax, %eax
callq 0x4030
movq %rbx, %rdi
callq 0x12723
movq %r12, %rdi
callq 0x34ff7
movq %r15, %rdi
callq 0x2d888
movl %ebp, %eax
addq $0x7a158, %rsp          # imm = 0x7A158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x80587(%rip), %rdi     # 0x96ff4
xorl %ebp, %ebp
movl %r13d, %esi
xorl %eax, %eax
callq 0x4030
movq %rbx, %rdi
callq 0x12723
movq 0x10(%rsp), %rdi
jmp 0x16a45