// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/dataset.c
// Function: discretize_dataset
Datasetptr discretize_dataset(Datasetptr original, int valuecount, DISCRETIZATION_TYPE discretization)
{
 Instanceptr data, inst;
 Datasetptr tmp;
 int i, j;
 char name[READLINELENGTH], tmpcommand[READLINELENGTH];
 char value[2];
 char* dname;
 char* fname;
 double **discretization_scheme, current;
 FILE* datafile;
 value[1] = '\0';
 sprintf(name, "%s%d", original->name, valuecount);
 tmp = empty_dataset(name, name, original->file, ' ');
 tmp->traincount = original->traincount;
 tmp->classdefno = original->classdefno;
 tmp->featurecount = original->featurecount;
 discretization_scheme = safemalloc(original->featurecount * sizeof(double *), "discretize_dataset", 12);
 tmp->datacount = original->datacount;
 tmp->classno = original->classno;
 for (i = 0; i < original->classno; i++)
  {
   tmp->classcounts[i] = original->classcounts[i];
   tmp->classes[i] = strcopy(tmp->classes[i], original->classes[i]);
  }
 tmp->allfeatures = original->allfeatures;
 for (i = 0; i < original->featurecount; i++)
  {
   tmp->features[i].selected = original->features[i].selected;
   tmp->availability[i] = original->availability[i];
   switch (original->features[i].type)
    {
     case  INTEGER:
     case     REAL:tmp->features[i].valuecount = valuecount;
                   tmp->features[i].type = STRING;
                   for (j = 0; j < valuecount; j++)
                    {
                     value[0] = '0' + j;
                     tmp->features[i].strings[j] = strcopy(tmp->features[i].strings[j], value);
                    }
                   break;
     case CLASSDEF:tmp->features[i].type = original->features[i].type;
                   tmp->features[i].valuecount = original->features[i].valuecount;
                   for (j = 0; j < tmp->features[i].valuecount; j++)
                     tmp->features[i].strings[j] = strcopy(tmp->features[i].strings[j], original->features[i].strings[j]);
                   break;
    }
  }
 read_from_train_file(original, &data);
 for (i = 0; i < original->featurecount; i++)
   if (original->features[i].type != CLASSDEF) 
     switch (discretization)
      {
       case EQUALWIDTH:discretization_scheme[i] = discretization_equalwidth(original, i, valuecount);
                       break;
       case    ENTROPY:discretization_scheme[i] = discretization_entropy(original, i, valuecount, data);
                       break; 
      }   
 inst = data;
 while (inst != NULL)
  {
   for (i = 0; i < original->featurecount; i++)
    {
     switch (original->features[i].type)
      {
       case INTEGER:current = inst->values[i].intvalue;
                    break;
       case    REAL:current = inst->values[i].floatvalue;
                    break;
      }
     if (in_list(original->features[i].type, 2, INTEGER, REAL))
      {
       j = 0;
       while (j < valuecount - 1 && current > discretization_scheme[i][j])
         j++;
       inst->values[i].stringindex = j;
      }
    }
   inst = inst->next;
  }
 dname = dataset_directory_name(tmp);
 sprintf(tmpcommand, "mkdir %s", dname);
 safe_free(dname);
 system(tmpcommand);
 fname = dataset_file_name(tmp);
 datafile = fopen(fname, "w");
 if (!datafile)
   return NULL;
 print_instance_list(datafile, ' ', tmp, data);
 fclose(datafile);
 for (i = 0; i < original->featurecount; i++)
   if (original->features[i].type != CLASSDEF) 
     safe_free(discretization_scheme[i]);
 safe_free(discretization_scheme);
 return tmp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf42c0, %rsp          # imm = 0xF42C0
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movb $0x0, -0xf4281(%rbp)
leaq -0x7a160(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
movl -0x14(%rbp), %ecx
leaq 0xc8dd6(%rip), %rsi     # 0xe82fb
movb $0x0, %al
callq 0x4170
leaq -0x7a160(%rbp), %rdi
leaq -0x7a160(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x1b0(%rax), %rdx
movl $0x20, %ecx
callq 0x1e640
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl 0x1407124(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x1407124(%rax)
movq -0x10(%rbp), %rax
movl 0x1407128(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x1407128(%rax)
movq -0x10(%rbp), %rax
movl 0x1bc(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x1bc(%rax)
movq -0x10(%rbp), %rax
movslq 0x1bc(%rax), %rdi
shlq $0x3, %rdi
leaq 0xc3f73(%rip), %rsi     # 0xe3518
movl $0xc, %edx
callq 0x52d70
movq %rax, -0xf42a0(%rbp)
movq -0x10(%rbp), %rax
movl 0x1407120(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x1407120(%rax)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x10(%rax)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x1f643
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl 0x1407140(%rax,%rcx,4), %edx
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl %edx, 0x1407140(%rax,%rcx,4)
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq 0x18(%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq 0x18(%rax,%rcx,8), %rsi
callq 0x54ba0
movq %rax, %rdx
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq %rdx, 0x18(%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1f5df
movq -0x10(%rbp), %rax
movl 0x1b8(%rax), %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x1b8(%rax)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0x1f8c4
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movl 0x30f24(%rax,%rcx), %edx
movq -0x30(%rbp), %rax
movl %edx, 0x30f24(%rax,%rcx)
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl 0x1c4(%rax,%rcx,4), %edx
movq -0x30(%rbp), %rax
movl %edx, 0x1c4(%rax,%rcx,4)
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movl 0x30f08(%rax,%rcx), %eax
movl %eax, -0xf42b4(%rbp)
testl %eax, %eax
je 0x1f6ef
jmp 0x1f6ce
movl -0xf42b4(%rbp), %eax
subl $0x2, %eax
je 0x1f6ef
jmp 0x1f6db
movl -0xf42b4(%rbp), %eax
subl $0x3, %eax
je 0x1f7a7
jmp 0x1f8b4
movl -0x14(%rbp), %ecx
movq -0x30(%rbp), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x34(%rbp), %rdx
imulq $0x340, %rdx, %rdx      # imm = 0x340
addq %rdx, %rax
movl %ecx, 0x18(%rax)
movq -0x30(%rbp), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x34(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
movl $0x1, (%rax)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x1f7a2
movl -0x38(%rbp), %eax
addl $0x30, %eax
movb %al, -0xf4282(%rbp)
movq -0x30(%rbp), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x34(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
movq 0x20(%rax,%rcx,8), %rdi
leaq -0xf4282(%rbp), %rsi
callq 0x54ba0
movq %rax, %rdx
movq -0x30(%rbp), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x34(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
movq %rdx, 0x20(%rax,%rcx,8)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1f732
jmp 0x1f8b4
movq -0x10(%rbp), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x34(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
movl (%rax), %ecx
movq -0x30(%rbp), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x34(%rbp), %rdx
imulq $0x340, %rdx, %rdx      # imm = 0x340
addq %rdx, %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x34(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
movl 0x18(%rax), %ecx
movq -0x30(%rbp), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x34(%rbp), %rdx
imulq $0x340, %rdx, %rdx      # imm = 0x340
addq %rdx, %rax
movl %ecx, 0x18(%rax)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq -0x30(%rbp), %rcx
addq $0x30f08, %rcx          # imm = 0x30F08
movslq -0x34(%rbp), %rdx
imulq $0x340, %rdx, %rdx      # imm = 0x340
addq %rdx, %rcx
cmpl 0x18(%rcx), %eax
jge 0x1f8b2
movq -0x30(%rbp), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x34(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
movq 0x20(%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x34(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
movq 0x20(%rax,%rcx,8), %rsi
callq 0x54ba0
movq %rax, %rdx
movq -0x30(%rbp), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x34(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
movslq -0x38(%rbp), %rcx
movq %rdx, 0x20(%rax,%rcx,8)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1f818
jmp 0x1f8b4
jmp 0x1f8b6
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1f65e
movq -0x10(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x85c60
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0x1f97e
movq -0x10(%rbp), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x34(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
cmpl $0x3, (%rax)
je 0x1f96e
movl -0x18(%rbp), %eax
movl %eax, -0xf42b8(%rbp)
testl %eax, %eax
je 0x1f924
jmp 0x1f917
movl -0xf42b8(%rbp), %eax
subl $0x1, %eax
je 0x1f947
jmp 0x1f96c
movq -0x10(%rbp), %rdi
movl -0x34(%rbp), %esi
movl -0x14(%rbp), %edx
callq 0x1eb50
movq %rax, %rdx
movq -0xf42a0(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x1f96c
movq -0x10(%rbp), %rdi
movl -0x34(%rbp), %esi
movl -0x14(%rbp), %edx
movq -0x20(%rbp), %rcx
callq 0x1ef60
movq %rax, %rdx
movq -0xf42a0(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x1f96e
jmp 0x1f970
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1f8d8
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x1fac9
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0x1fab8
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movl 0x30f08(%rax,%rcx), %eax
movl %eax, -0xf42bc(%rbp)
testl %eax, %eax
je 0x1f9da
jmp 0x1f9cd
movl -0xf42bc(%rbp), %eax
subl $0x2, %eax
je 0x1f9f4
jmp 0x1fa0c
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x34(%rbp), %rcx
cvtsi2sdl (%rax,%rcx,8), %xmm0
movsd %xmm0, -0xf42a8(%rbp)
jmp 0x1fa0c
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x34(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0xf42a8(%rbp)
movq -0x10(%rbp), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x34(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
movl (%rax), %edi
movl $0x2, %ecx
xorl %edx, %edx
movl %ecx, %esi
movb $0x0, %al
callq 0x53e40
cmpl $0x0, %eax
je 0x1faa8
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %ecx
movl -0x14(%rbp), %edx
subl $0x1, %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0xf42bd(%rbp)
jge 0x1fa80
movsd -0xf42a8(%rbp), %xmm0
movq -0xf42a0(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
ucomisd (%rax,%rcx,8), %xmm0
seta %al
movb %al, -0xf42bd(%rbp)
movb -0xf42bd(%rbp), %al
testb $0x1, %al
jne 0x1fa8c
jmp 0x1fa97
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1fa42
movl -0x38(%rbp), %edx
movq -0x28(%rbp), %rax
movq (%rax), %rax
movslq -0x34(%rbp), %rcx
movl %edx, (%rax,%rcx,8)
jmp 0x1faaa
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1f998
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x1f986
movq -0x30(%rbp), %rdi
callq 0x1fbf0
movq %rax, -0xf4290(%rbp)
leaq -0xf4280(%rbp), %rdi
movq -0xf4290(%rbp), %rdx
leaq 0xc3a3d(%rip), %rsi     # 0xe352b
movb $0x0, %al
callq 0x4170
movq -0xf4290(%rbp), %rdi
callq 0x52e80
leaq -0xf4280(%rbp), %rdi
callq 0x40d0
movq -0x30(%rbp), %rdi
callq 0x1fc90
movq %rax, -0xf4298(%rbp)
movq -0xf4298(%rbp), %rdi
leaq 0xc8693(%rip), %rsi     # 0xe81be
callq 0x40c0
movq %rax, -0xf42b0(%rbp)
cmpq $0x0, -0xf42b0(%rbp)
jne 0x1fb4e
movq $0x0, -0x8(%rbp)
jmp 0x1fbdb
movq -0xf42b0(%rbp), %rdi
movq -0x30(%rbp), %rdx
movq -0x20(%rbp), %rcx
movl $0x20, %esi
callq 0x44c60
movq -0xf42b0(%rbp), %rdi
callq 0x4250
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0x1fbc7
movq -0x10(%rbp), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x34(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
cmpl $0x3, (%rax)
je 0x1fbba
movq -0xf42a0(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x52e80
jmp 0x1fbbc
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1fb7a
movq -0xf42a0(%rbp), %rdi
callq 0x52e80
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xf42c0, %rsp          # imm = 0xF42C0
popq %rbp
retq
nopl (%rax,%rax)