// File: /workspace/github_c_makefile_star2_O1/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, %r12
movq %rcx, %r15
movl %edx, 0x4(%rsp)
movq %rsi, %r14
movq %rdi, %r13
leaq 0xbac74(%rip), %rax     # 0xd2878
movq (%rax), %rbp
testq %rbp, %rbp
je 0x17c39
movq 0x8(%rbp), %rdi
movq %r13, %rsi
callq 0x4260
testl %eax, %eax
je 0x17c25
movq 0x1407270(%rbp), %rbp
jmp 0x17c07
leaq 0x8ca2b(%rip), %rdi     # 0xa4657
callq 0x4090
movq %r13, %rdi
callq 0x170a0
movsbl (%r14), %ecx
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x15559
movq %rax, %rbx
movl $0x0, 0x1407120(%rax)
movl 0x4(%rsp), %eax
movl %eax, 0x1b8(%rbx)
movl %eax, 0x1bc(%rbx)
movl $0x2, 0x140713c(%rbx)
testl %eax, %eax
jle 0x17c92
xorl %eax, %eax
movl $0x1, 0x1c4(%rbx,%rax,4)
incq %rax
movslq 0x1bc(%rbx), %rcx
cmpq %rcx, %rax
jl 0x17c78
movq 0x7a190(%rsp), %r12
movl $0x0, 0x1407128(%rbx)
leaq 0x1407140(%rbx), %rdi
movl $0xc8, %edx
xorl %esi, %esi
callq 0x4050
leaq 0x18(%rbx), %rdx
leaq 0x10(%rbx), %rcx
leaq 0x8ddb0(%rip), %rsi     # 0xa5a76
movq %r15, %rdi
movq %rdx, 0x28(%rsp)
callq 0x3a431
cmpl $0x0, 0x10(%rbx)
je 0x17d1b
movl $0x3, 0x30f08(%rbx)
movl 0x10(%rbx), %eax
testl %eax, %eax
jle 0x17d13
xorl %r15d, %r15d
movq 0x30f28(%rbx,%r15,8), %rdi
movq 0x18(%rbx,%r15,8), %rsi
callq 0x3a404
movq %rax, 0x30f28(%rbx,%r15,8)
incq %r15
movslq 0x10(%rbx), %rax
cmpq %rax, %r15
jl 0x17ced
movl %eax, 0x30f20(%rbx)
jmp 0x17d25
movl $0x4, 0x30f08(%rbx)
movl $0x1, 0x30f24(%rbx)
movq %r12, %rdi
callq 0x3115a
movq %rax, %r15
cmpl $0x2, 0x4(%rsp)
jl 0x17d7e
movl 0x4(%rsp), %r13d
leaq 0x31248(%rbx), %rbp
movl $0x1, %r12d
movl $0x1, 0x1c(%rbp)
movq %r15, %rdi
movl %r12d, %esi
callq 0x3113e
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
movl %ecx, (%rbp)
incq %r12
addq $0x340, %rbp            # imm = 0x340
cmpq %r12, %r13
jne 0x17d53
movq %rbx, %rdi
callq 0x16285
movq %rax, %r12
leaq 0x90aff(%rip), %rsi     # 0xa888f
movq %rax, %rdi
callq 0x40f0
testq %rax, %rax
je 0x17f5c
movq %rax, %r13
movq %r12, 0x8(%rsp)
leaq 0x30(%rsp), %r12
movq %r12, %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %rax, %rdx
callq 0x4120
testq %rax, %rax
je 0x17f0e
movq %rbx, %rax
addq $0x30f08, %rax          # imm = 0x30F08
movq %rax, 0x18(%rsp)
movq %r13, 0x20(%rsp)
movq %r12, %rdi
callq 0x4190
cmpq $0x1, %rax
jbe 0x17ef5
incl 0x1407120(%rbx)
movq %r12, %rdi
callq 0x4190
movb $0x0, -0x1(%rax,%r12)
movq %r12, %rdi
movq %r14, %rsi
callq 0x4280
movl 0x10(%rbx), %edx
movq %rax, %rdi
movq 0x28(%rsp), %rsi
callq 0x3a2c5
cmpl $-0x1, %eax
je 0x17f79
cltq
incl 0x1407140(%rbx,%rax,4)
xorl %r12d, %r12d
xorl %edi, %edi
movq %r14, %rsi
callq 0x4280
movq %rax, %rdi
callq 0x4200
movl %eax, 0x14(%rsp)
xorl %edi, %edi
movq %r14, %rsi
callq 0x4280
testq %rax, %rax
je 0x17ed9
movq %rax, %rbp
xorl %r12d, %r12d
movl $0x1, %r13d
movq %r15, %rdi
movl %r13d, %esi
callq 0x3113e
testl %eax, %eax
jne 0x17ea0
movq %rbp, %rdi
callq 0x3992c
testl %eax, %eax
jne 0x17ea0
movslq %r13d, %rax
imulq $0x340, %rax, %rax      # imm = 0x340
movq 0x18(%rsp), %rcx
cmpl $0x2, (%rcx,%rax)
je 0x17ea0
addq 0x18(%rsp), %rax
movl $0x2, (%rax)
incl %r13d
xorl %eax, %eax
cmpl 0x4(%rsp), %r13d
sete %al
movl $0x1, %ecx
cmovel %ecx, %r13d
addl %eax, %r12d
xorl %edi, %edi
movq %r14, %rsi
callq 0x4280
movq %rax, %rbp
testq %rax, %rax
jne 0x17e65
cmpl $0x1, %r13d
sete %al
movq 0x20(%rsp), %r13
jmp 0x17edb
movb $0x1, %al
testb %al, %al
je 0x17f8c
movl 0x14(%rsp), %edx
cmpl %edx, %r12d
leaq 0x30(%rsp), %r12
jne 0x17fa1
movq %r12, %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %r13, %rdx
callq 0x4120
testq %rax, %rax
jne 0x17dda
movq %r13, %rdi
callq 0x42a0
movl $0x0, (%rbx)
leaq 0xba955(%rip), %rcx     # 0xd2878
movq (%rcx), %rax
testq %rax, %rax
movq 0x8(%rsp), %r12
je 0x17f46
movq %rax, %rcx
movq 0x1407270(%rax), %rax
testq %rax, %rax
jne 0x17f30
addq $0x1407270, %rcx        # imm = 0x1407270
movq %rbx, (%rcx)
leaq 0x8c76a(%rip), %rdi     # 0xa46ba
callq 0x4090
movl $0x1, %ebp
jmp 0x17fc4
leaq 0x8bfba(%rip), %rdi     # 0xa3f1d
xorl %ebp, %ebp
movq %r12, %rsi
xorl %eax, %eax
callq 0x4030
movq %rbx, %rdi
callq 0x13765
jmp 0x17fc4
movl 0x1407120(%rbx), %esi
leaq 0x8bff2(%rip), %rdi     # 0xa3f78
xorl %ebp, %ebp
xorl %edx, %edx
jmp 0x17fb0
leaq 0x8c07f(%rip), %rdi     # 0xa4012
xorl %ebp, %ebp
movl %r12d, %esi
xorl %eax, %eax
callq 0x4030
jmp 0x17fb7
movl 0x1407120(%rbx), %esi
leaq 0x8c090(%rip), %rdi     # 0xa403e
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x4030
movq %rbx, %rdi
callq 0x13765
movq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x39194
movq %r15, %rdi
callq 0x31110
movl %ebp, %eax
addq $0x7a158, %rsp          # imm = 0x7A158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq