// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/dataset.c
// Function: dimension_reduced_dataset
Datasetptr dimension_reduced_dataset(Datasetptr d, int dimension, Instanceptr reduceddata, char* datasetname)
{
 /*dimension includes the class definition feature*/
 Datasetptr newdataset;
 int i;
 newdataset = empty_dataset(datasetname, datasetname, "dataset.txt", ' ');
 if (d->classdefno == -1)
   dimension--;
 newdataset->allfeatures = dimension;
 newdataset->featurecount = dimension;
 newdataset->multifeaturecount = dimension;
 for (i = 0; i < dimension; i++)
  {
   newdataset->availability[i] = YES;
   newdataset->features[i].selected = YES;
  }
 if (d->classdefno != -1)
   newdataset->classdefno = newdataset->newclassdefno = dimension - 1;
 else
   newdataset->classdefno = newdataset->newclassdefno = -1;
 newdataset->classno = d->classno;
 for (i = 0; i < d->classno; i++)
   newdataset->classes[i] = strcopy(newdataset->classes[i], d->classes[i]);
 if (d->classdefno == -1)
   dimension++;
 for (i = 0; i < dimension - 1; i++)
  {
   newdataset->features[i].type = REAL;
   newdataset->features[i].oldtype = REAL;
   find_bounds_of_feature(newdataset, reduceddata, i, &(newdataset->features[i].min.floatvalue), &(newdataset->features[i].max.floatvalue));
   newdataset->features[i].valuecount = 0;
  }
 if (d->classdefno != -1)
  {
   newdataset->features[dimension - 1].type = CLASSDEF; 
   newdataset->features[dimension - 1].oldtype = CLASSDEF; 
   newdataset->features[dimension - 1].valuecount = d->classno;
   for (i = 0; i < d->classno; i++)
     if (d->classdefno == d->newclassdefno)
       newdataset->features[dimension - 1].strings[i] = strcopy(newdataset->features[dimension - 1].strings[i], d->features[d->classdefno].strings[i]);
     else
       newdataset->features[dimension - 1].strings[i] = strcopy(newdataset->features[dimension - 1].strings[i], d->features[d->newclassdefno].strings[i]);
  }
 newdataset->traincount = d->traincount;
 newdataset->datacount = d->datacount;
 for (i = 0; i < d->classno; i++)
   newdataset->classcounts[i] = d->classcounts[i];
 return newdataset;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, 0x10(%rsp)
movl %esi, %r12d
movq %rdi, %rbx
leaq 0x826dc(%rip), %rdx     # 0x96848
pushq $0x20
popq %rax
movq %rcx, %rdi
movq %rcx, %rsi
movl %eax, %ecx
callq 0x1434b
xorl %ecx, %ecx
cmpl $-0x1, 0x1407128(%rbx)
movq %rax, %r14
sete %cl
subl %ecx, %r12d
movl %r12d, 0x1b8(%rax)
movl %r12d, 0x1bc(%rax)
movl %r12d, 0x1c0(%rax)
addq $0x1c4, %rax            # imm = 0x1C4
movq %r14, %rcx
addq $0x30f08, %rcx          # imm = 0x30F08
movq %rcx, 0x8(%rsp)
xorl %ecx, %ecx
testl %r12d, %r12d
movl $0x0, %edx
cmovgl %r12d, %edx
imulq $0xd0, %rdx, %rdx
pushq $0x1
popq %rsi
cmpq %rcx, %rdx
je 0x141ec
movl %esi, (%rax)
movl %esi, 0x30f24(%r14,%rcx,4)
addq $0xd0, %rcx
addq $0x4, %rax
jmp 0x141d0
movl 0x1407128(%rbx), %eax
leal -0x1(%r12), %ecx
cmpl $-0x1, %eax
cmovel %eax, %ecx
movl %ecx, 0x1407138(%r14)
movl %ecx, 0x1407128(%r14)
movl 0x10(%rbx), %eax
movl %eax, 0x10(%r14)
xorl %r15d, %r15d
cltq
cmpq %rax, %r15
jge 0x14238
movq 0x18(%r14,%r15,8), %rdi
movq 0x18(%rbx,%r15,8), %rsi
callq 0x3604c
movq %rax, 0x18(%r14,%r15,8)
incq %r15
movl 0x10(%rbx), %eax
jmp 0x14215
xorl %eax, %eax
cmpl $-0x1, 0x1407128(%rbx)
sete %al
addl %r12d, %eax
decl %eax
xorl %r12d, %r12d
testl %eax, %eax
movl $0x0, %r13d
movl %eax, 0x4(%rsp)
cmovgl %eax, %r13d
movabsq $0x200000002, %rbp      # imm = 0x200000002
movq 0x8(%rsp), %r15
cmpq %r12, %r13
je 0x1429c
movq %rbp, (%r15)
leaq 0x8(%r15), %rcx
leaq 0x10(%r15), %r8
movq %r14, %rdi
movq 0x10(%rsp), %rsi
movl %r12d, %edx
callq 0x101e4
andl $0x0, 0x18(%r15)
incq %r12
addq $0x340, %r15            # imm = 0x340
jmp 0x1426b
cmpl $-0x1, 0x1407128(%rbx)
je 0x1430c
movslq 0x4(%rsp), %rax
imulq $0x340, %rax, %rcx      # imm = 0x340
movq 0x8(%rsp), %rdx
leaq (%rdx,%rcx), %r15
movabsq $0x300000003, %rax      # imm = 0x300000003
movq %rax, (%rdx,%rcx)
movl 0x10(%rbx), %eax
movl %eax, 0x18(%rdx,%rcx)
leaq 0x30f28(%rbx), %r12
xorl %r13d, %r13d
cltq
cmpq %rax, %r13
jge 0x1430c
movslq 0x1407138(%rbx), %rax
movq 0x20(%r15,%r13,8), %rdi
imulq $0x340, %rax, %rax      # imm = 0x340
addq %r12, %rax
movq (%rax,%r13,8), %rsi
callq 0x3604c
movq %rax, 0x20(%r15,%r13,8)
incq %r13
movl 0x10(%rbx), %eax
jmp 0x142d9
movq 0x1407120(%rbx), %rax
movq %rax, 0x1407120(%r14)
xorl %eax, %eax
movslq 0x10(%rbx), %rcx
cmpq %rcx, %rax
jge 0x14339
movl 0x1407140(%rbx,%rax,4), %ecx
movl %ecx, 0x1407140(%r14,%rax,4)
incq %rax
jmp 0x1431c
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq