// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/cn2.c
// Function: specialize_complex
void specialize_complex(Decisionruleptr current, Ruleset* newstar, Instanceptr* instances, int positive, int maxstar)
{
 int i, j, size, *featurecounts, *positivecounts, poscount, totalpositive;
 double split, prevvalue, value;
 Decisionruleptr candidate;
 Instanceptr covered = NULL, instancelist, tmp;
 remove_covered(instances, &covered, current);
 totalpositive = find_class_count(covered, positive);
 size = data_size(covered);
 for (i = 0; i < current_dataset->featurecount; i++)
   switch (current_dataset->features[i].type)
    { 
     case INTEGER:
     case    REAL:instancelist = sort_instances(covered, i, &size);
                  if (current_dataset->features[i].type == INTEGER)
                    prevvalue = instancelist[0].values[i].intvalue;
                  else
                    prevvalue = instancelist[0].values[i].floatvalue;
                  if (give_classno(&(instancelist[0])) == positive)
                    poscount = 1;
                  else
                    poscount = 0;
                  for (j = 1; j < size; j++)
                   {
                    if (current_dataset->features[i].type == INTEGER)
                      value = instancelist[j].values[i].intvalue;
                    else
                      value = instancelist[j].values[i].floatvalue;
                    if (value != prevvalue)
                     {
                      split = (value + prevvalue) / 2;
                      if (is_better_candidate(*newstar, maxstar, laplace_estimate(j - poscount, j)))
                       {
                        candidate = generate_candidate_for_newstar(current, i, '<', split, j - poscount, poscount);
                        add_candidate_to_newstar(candidate, newstar, maxstar);
                       }
                      if (is_better_candidate(*newstar, maxstar, laplace_estimate(size - j - totalpositive + poscount, size - j)))
                       {
                        candidate = generate_candidate_for_newstar(current, i, '>', split, size - j - totalpositive + poscount, totalpositive - poscount);
                        add_candidate_to_newstar(candidate, newstar, maxstar);
                       }
                      prevvalue = value;
                     }
                    if (give_classno(&(instancelist[j])) == positive)
                      poscount++;
                   }
                  safe_free(instancelist);
                  break;
     case  STRING:featurecounts = safecalloc(current_dataset->features[i].valuecount, sizeof(int), "find_best_condition", 94);
                  positivecounts = safecalloc(current_dataset->features[i].valuecount,sizeof(int), "find_best_condition", 95); 
                  tmp = covered;
                  while (tmp)
                   {
                    featurecounts[tmp->values[i].stringindex]++;
                    if (give_classno(tmp) == positive)
                      positivecounts[tmp->values[i].stringindex]++;
                    tmp = tmp->next;
                   }
                  for (j = 0; j < current_dataset->features[i].valuecount; j++)
                    if (featurecounts[j] != size && is_better_candidate(*newstar, maxstar, laplace_estimate(featurecounts[j] - positivecounts[j], featurecounts[j])))
                     {
                      candidate = generate_candidate_for_newstar(current, i, '=', j, featurecounts[j] - positivecounts[j], positivecounts[j]);
                      add_candidate_to_newstar(candidate, newstar, maxstar);
                     }
                  safe_free(featurecounts);
                  safe_free(positivecounts);
                  break;
    }
 merge_instancelist(instances, covered); 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq $0x0, -0x70(%rbp)
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rdx
leaq -0x70(%rbp), %rsi
callq 0xdb5b0
movq -0x70(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x18240
movl %eax, -0x48(%rbp)
movq -0x70(%rbp), %rdi
callq 0x449f0
movl %eax, -0x2c(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
leaq 0xf364d(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1bc(%rcx), %eax
jge 0x126e5
leaq 0xf3637(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
movl 0x30f08(%rax,%rcx), %eax
movl %eax, -0x84(%rbp)
testl %eax, %eax
je 0x1224c
jmp 0x1222a
movl -0x84(%rbp), %eax
subl $0x1, %eax
je 0x124dc
jmp 0x1223b
movl -0x84(%rbp), %eax
subl $0x2, %eax
jne 0x126d5
jmp 0x1224c
movq -0x70(%rbp), %rdi
movl -0x24(%rbp), %esi
leaq -0x2c(%rbp), %rdx
callq 0xdc050
movq %rax, -0x78(%rbp)
leaq 0xf35d9(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x24(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
cmpl $0x0, (%rax)
jne 0x1229a
movq -0x78(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
cvtsi2sdl (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x122af
movq -0x78(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x78(%rbp), %rdi
callq 0x43530
cmpl -0x1c(%rbp), %eax
jne 0x122c6
movl $0x1, -0x44(%rbp)
jmp 0x122cd
movl $0x0, -0x44(%rbp)
movl $0x1, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x124ce
leaq 0xf3559(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x24(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
cmpl $0x0, (%rax)
jne 0x12325
movq -0x78(%rbp), %rax
movslq -0x28(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
cvtsi2sdl (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x60(%rbp)
jmp 0x12345
movq -0x78(%rbp), %rax
movslq -0x28(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x60(%rbp), %xmm0
ucomisd -0x58(%rbp), %xmm0
jne 0x12358
jp 0x12358
jmp 0x1249c
movsd -0x60(%rbp), %xmm0
addsd -0x58(%rbp), %xmm0
movsd 0xd0936(%rip), %xmm1    # 0xe2ca0
divsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x90(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x88(%rbp)
movl -0x28(%rbp), %edi
subl -0x44(%rbp), %edi
movl -0x28(%rbp), %esi
callq 0xaee10
movq -0x90(%rbp), %rcx
movl -0x88(%rbp), %edi
movq 0x20(%rcx), %rdx
movq %rsp, %rax
movq %rdx, 0x20(%rax)
movups (%rcx), %xmm1
movups 0x10(%rcx), %xmm2
movups %xmm2, 0x10(%rax)
movups %xmm1, (%rax)
callq 0x11f40
cmpl $0x0, %eax
je 0x123f9
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %esi
movsd -0x50(%rbp), %xmm0
movl -0x28(%rbp), %ecx
subl -0x44(%rbp), %ecx
movl -0x44(%rbp), %r8d
movl $0x3c, %edx
callq 0x11fc0
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x20(%rbp), %edx
callq 0x12060
movq -0x10(%rbp), %rax
movq %rax, -0xa0(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x94(%rbp)
movl -0x2c(%rbp), %edi
subl -0x28(%rbp), %edi
subl -0x48(%rbp), %edi
addl -0x44(%rbp), %edi
movl -0x2c(%rbp), %esi
subl -0x28(%rbp), %esi
callq 0xaee10
movq -0xa0(%rbp), %rcx
movl -0x94(%rbp), %edi
movq 0x20(%rcx), %rdx
movq %rsp, %rax
movq %rdx, 0x20(%rax)
movups (%rcx), %xmm1
movups 0x10(%rcx), %xmm2
movups %xmm2, 0x10(%rax)
movups %xmm1, (%rax)
callq 0x11f40
cmpl $0x0, %eax
je 0x12492
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %esi
movsd -0x50(%rbp), %xmm0
movl -0x2c(%rbp), %ecx
subl -0x28(%rbp), %ecx
subl -0x48(%rbp), %ecx
addl -0x44(%rbp), %ecx
movl -0x48(%rbp), %r8d
subl -0x44(%rbp), %r8d
movl $0x3e, %edx
callq 0x11fc0
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x20(%rbp), %edx
callq 0x12060
movsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x78(%rbp), %rdi
movslq -0x28(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
callq 0x43530
cmpl -0x1c(%rbp), %eax
jne 0x124be
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x124c0
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x122d4
movq -0x78(%rbp), %rdi
callq 0x52e80
jmp 0x126d5
leaq 0xf335d(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x24(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
movslq 0x18(%rax), %rdi
movl $0x4, %esi
leaq 0xd07c1(%rip), %rdx     # 0xe2ccb
movl $0x5e, %ecx
callq 0x52f40
movq %rax, -0x38(%rbp)
leaq 0xf3321(%rip), %rax     # 0x105840
movq (%rax), %rax
addq $0x30f08, %rax          # imm = 0x30F08
movslq -0x24(%rbp), %rcx
imulq $0x340, %rcx, %rcx      # imm = 0x340
addq %rcx, %rax
movslq 0x18(%rax), %rdi
movl $0x4, %esi
leaq 0xd0785(%rip), %rdx     # 0xe2ccb
movl $0x5f, %ecx
callq 0x52f40
movq %rax, -0x40(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x80(%rbp)
cmpq $0x0, -0x80(%rbp)
je 0x125b7
movq -0x38(%rbp), %rax
movq -0x80(%rbp), %rcx
movq (%rcx), %rcx
movslq -0x24(%rbp), %rdx
movslq (%rcx,%rdx,8), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x80(%rbp), %rdi
callq 0x43530
cmpl -0x1c(%rbp), %eax
jne 0x125a9
movq -0x40(%rbp), %rax
movq -0x80(%rbp), %rcx
movq (%rcx), %rcx
movslq -0x24(%rbp), %rdx
movslq (%rcx,%rdx,8), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x80(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x80(%rbp)
jmp 0x1255c
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
leaq 0xf3278(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
addq $0x30f08, %rcx          # imm = 0x30F08
movslq -0x24(%rbp), %rdx
imulq $0x340, %rdx, %rdx      # imm = 0x340
addq %rdx, %rcx
cmpl 0x18(%rcx), %eax
jge 0x126c3
movq -0x38(%rbp), %rax
movslq -0x28(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x2c(%rbp), %eax
je 0x126b3
movq -0x10(%rbp), %rax
movq %rax, -0xb0(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0xa4(%rbp)
movq -0x38(%rbp), %rax
movslq -0x28(%rbp), %rcx
movl (%rax,%rcx,4), %edi
movq -0x40(%rbp), %rax
movslq -0x28(%rbp), %rcx
subl (%rax,%rcx,4), %edi
movq -0x38(%rbp), %rax
movslq -0x28(%rbp), %rcx
movl (%rax,%rcx,4), %esi
callq 0xaee10
movq -0xb0(%rbp), %rcx
movl -0xa4(%rbp), %edi
movq 0x20(%rcx), %rdx
movq %rsp, %rax
movq %rdx, 0x20(%rax)
movups (%rcx), %xmm1
movups 0x10(%rcx), %xmm2
movups %xmm2, 0x10(%rax)
movups %xmm1, (%rax)
callq 0x11f40
cmpl $0x0, %eax
je 0x126b3
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %esi
cvtsi2sdl -0x28(%rbp), %xmm0
movq -0x38(%rbp), %rax
movslq -0x28(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x40(%rbp), %rax
movslq -0x28(%rbp), %rdx
subl (%rax,%rdx,4), %ecx
movq -0x40(%rbp), %rax
movslq -0x28(%rbp), %rdx
movl (%rax,%rdx,4), %r8d
movl $0x3d, %edx
callq 0x11fc0
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x20(%rbp), %edx
callq 0x12060
jmp 0x126b5
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x125be
movq -0x38(%rbp), %rdi
callq 0x52e80
movq -0x40(%rbp), %rdi
callq 0x52e80
jmp 0x126d7
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x121e9
movq -0x18(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x44f40
addq $0xe0, %rsp
popq %rbp
retq
nopl (%rax,%rax)