// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/instancelist.c
// Function: create_instancelist_from_rules
Instanceptr create_instancelist_from_rules(Decisionconditionptr rules, int count, Instanceptr* list)
{
 /*!Last Changed 09.04.2003*/
 int i, found, featureindex;
 double value, datavalue;
 char comparison;
 Instanceptr result = NULL, tmp = (*list), last = NULL, next, tmpbefore = NULL;
 while (tmp)
  {
   found = 0;
   for (i = 0; i < count; i++)
    {
     featureindex = rules[i].featureindex;
     value = rules[i].value;
     comparison = rules[i].comparison;
     switch (current_dataset->features[featureindex].type)
      {
       case INTEGER:datavalue = tmp->values[featureindex].intvalue;
                    if (comparison=='<' && datavalue>value)
                      found = 1;
                    if (comparison=='>' && datavalue<=value)
                      found = 1;
                    break;
       case    REAL:datavalue = tmp->values[featureindex].floatvalue;
                    if (comparison=='<' && datavalue>value)
                      found = 1;
                    if (comparison=='>' && datavalue<=value)
                      found = 1;
                    break;
       case  STRING:if (tmp->values[featureindex].stringindex != value)
                      found = 1;
                    break;
      }
     if (found)
       break;
    }
   next = tmp->next;
   if (!found)
    {
     if (last)
       last -> next = tmp;
     else
       result = tmp;
     last = tmp;
    }
   else
    {
     if (tmpbefore)
       tmpbefore -> next = tmp;
     else
       (*list) = tmp;
     tmpbefore = tmp;
    }
   tmp = next;
  }
 if (last)
   last -> next = NULL;
 if (!tmpbefore)
   (*list) = NULL;
 else
   tmpbefore -> next = NULL;   
 return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq (%rdx), %rbx
xorl %eax, %eax
testl %esi, %esi
cmovlel %eax, %esi
imulq $0x70, %rsi, %rcx
leaq 0xa069c(%rip), %rsi     # 0xcd870
movl $0x30f08, %r8d          # imm = 0x30F08
xorl %r9d, %r9d
movq %rbx, %r11
movq %rax, %r10
testq %r11, %r11
je 0x2d2b8
movq (%rsi), %rbx
addq %r8, %rbx
xorl %r14d, %r14d
cmpq %r14, %rcx
je 0x2d292
movslq (%rdi,%r14), %r15
movsd 0x8(%rdi,%r14), %xmm0
movb 0x4(%rdi,%r14), %bpl
imulq $0x340, %r15, %r12      # imm = 0x340
movl (%rbx,%r12), %r12d
cmpl $0x2, %r12d
je 0x2d248
cmpl $0x1, %r12d
je 0x2d235
testl %r12d, %r12d
jne 0x2d275
movq (%r11), %r12
cvtsi2sdl (%r12,%r15,8), %xmm1
jmp 0x2d251
movq (%r11), %r12
cvtsi2sdl (%r12,%r15,8), %xmm1
ucomisd %xmm1, %xmm0
jne 0x2d27e
jnp 0x2d275
jmp 0x2d27e
movq (%r11), %r12
movsd (%r12,%r15,8), %xmm1
cmpb $0x3c, %bpl
sete %r12b
ucomisd %xmm0, %xmm1
seta %r15b
andb %r12b, %r15b
cmpb $0x3e, %bpl
jne 0x2d270
ucomisd %xmm1, %xmm0
jae 0x2d27e
testb %r15b, %r15b
jne 0x2d27e
addq $0x70, %r14
jmp 0x2d1f5
movq 0x10(%r11), %rbx
leaq 0x10(%r9), %r14
testq %r9, %r9
cmoveq %rdx, %r14
movq %r11, %r9
jmp 0x2d2a5
movq 0x10(%r11), %rbx
testq %r10, %r10
je 0x2d2b0
addq $0x10, %r10
movq %r10, %r14
movq %r11, %r10
movq %r11, (%r14)
movq %rbx, %r11
jmp 0x2d1e3
movq %r11, %rax
jmp 0x2d1dd
testq %r10, %r10
je 0x2d2c2
andq $0x0, 0x10(%r10)
leaq 0x10(%r9), %rcx
testq %r9, %r9
cmoveq %rdx, %rcx
andq $0x0, (%rcx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq