// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/statistics.c
// Function: multiple_comparison
int* multiple_comparison(char **files,int filecount,TEST_TYPE testtype, char* st, int* monotone, int* componentcount, CORRECTION_TYPE correctiontype)
{
 /*Last Changed 18.11.2004 added holm's correction*/
 /*Last Changed 25.02.2004 added monotonicity*/
 /*Last Changed 02.02.2004 added safemalloc Runs only with accuracy set to 0*/
 /*Last Changed 09.02.2003 !!!!  put "-" into st before calling !!!!!*/
 int i, j, *result, edgecount = 0, *inthelist, found, compcount = (filecount * (filecount - 1)) / 2;
 Linkptr edges = NULL, newedge, lastedge = NULL, tmp, tmpbefore, tmp1;
 Comparisonptr comparisons;
 char ch;
 result = (int *)safemalloc(filecount*sizeof(int), "multiple_comparison", 7);
 inthelist = (int *)safecalloc(filecount, sizeof(int), "multiple_comparison", 8);
 comparisons = all_pairwise_comparisons(files, filecount, correctiontype, testtype);
 for (i = 0; i < compcount; i++)
   if (!comparisons[i].accepted) /*If the test rejects*/
    {
     newedge = (Linkptr) safemalloc(sizeof(Link), "multiple_comparison", 36);
     newedge -> from = comparisons[i].alg1;
     newedge -> to = comparisons[i].alg2;
     ch = comparisons[i].alg1 + 1 + '0';
     sprintf(st,"%s%c",st,ch);
     ch = comparisons[i].alg2 + 1 + '0';
     sprintf(st,"%s%c",st,ch);
     sprintf(st,"%s%c",st,'-');
     newedge -> next = NULL;
     if (lastedge != NULL)
       lastedge -> next = newedge;
     else
       edges = newedge;
     lastedge = newedge;
     edgecount++;
    }
 safe_free(comparisons);
 *componentcount = connected_components(edges, filecount);
 for (j = 0; j < filecount; j++)
   for (i = 0; i < filecount; i++)
     if (!(inthelist[i]))
      {
       tmp = edges;
       while (tmp && tmp->from != i)
         tmp = tmp->next;
       if (!tmp)
        {
         tmp = edges;
         tmpbefore = NULL;
         while (tmp)
          {
           tmp1 = tmp->next;
           if (tmp->to != i)
             tmpbefore = tmp;
           else
            {
             if (tmpbefore)
               tmpbefore -> next = tmp1;
             else
               edges = tmp1; 
             safe_free(tmp);
            }
           tmp = tmp1;
          }
         result[j] = i+1;
         inthelist[i] = 1;
         break;
        }
      }
 found = 0;
 for (i = 0; i < filecount - 1; i++)
   for (j = i + 1; j < filecount; j++)
     if (result[i] > result[j])
       found++;
 if (found == edgecount)
   *monotone = 1;
 else
   *monotone = 0;
 safe_free(inthelist);
 return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r9, 0x38(%rsp)
movq %r8, 0x48(%rsp)
movq %rcx, 0x28(%rsp)
movl %edx, 0x8(%rsp)
movl %esi, %r14d
movq %rdi, %rbp
leal -0x1(%r14), %eax
movq %rax, 0x40(%rsp)
imull %esi, %eax
pushq $0x2
popq %rcx
cltd
idivl %ecx
movl %eax, %r13d
movslq %esi, %rbx
leaq (,%rbx,4), %rdi
leaq 0x2056e(%rip), %r12     # 0xa16ef
pushq $0x7
popq %rdx
movq %r12, %rsi
callq 0x34f59
movq %rax, %r15
pushq $0x4
popq %rsi
pushq $0x8
popq %rcx
movq %rbx, %rdi
movq %r12, %rdx
callq 0x35067
movq %rax, 0x30(%rsp)
movq %rbp, %rdi
movl %ebx, %esi
movl 0x90(%rsp), %edx
movl 0x8(%rsp), %ecx
callq 0x80c96
movq %rax, %r12
xorl %ecx, %ecx
testl %r13d, %r13d
cmovlel %ecx, %r13d
imulq $0x18, %r13, %rcx
xorl %ebp, %ebp
movq $0x0, 0x18(%rsp)
xorl %ebx, %ebx
movl $0x0, 0x14(%rsp)
movq %rax, 0x20(%rsp)
movq %rcx, 0x50(%rsp)
movq 0x28(%rsp), %r13
cmpq %rbp, %rcx
je 0x812a8
cmpl $0x0, 0x10(%r12,%rbp)
jne 0x8129f
pushq $0x10
popq %rdi
leaq 0x204e2(%rip), %rsi     # 0xa16ef
movq %rbx, 0x8(%rsp)
pushq $0x24
popq %rdx
callq 0x34f59
movq %rax, %rbx
movq (%r12,%rbp), %rax
movq %rax, (%rbx)
addb $0x31, %al
movsbl %al, %ecx
movq %r13, %rdi
leaq 0x1537d(%rip), %rsi     # 0x965b0
movq %r13, %rdx
xorl %eax, %eax
callq 0x41b0
movb 0x4(%r12,%rbp), %al
addb $0x31, %al
movsbl %al, %ecx
movq %r13, %rdi
leaq 0x1535f(%rip), %r12     # 0x965b0
movq %r12, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x41b0
movq %r13, %rdi
movq %r12, %rsi
movq %r13, %rdx
pushq $0x2d
popq %rcx
xorl %eax, %eax
callq 0x41b0
movq 0x8(%rsp), %rcx
andq $0x0, 0x8(%rbx)
movq %rbx, %rax
testq %rcx, %rcx
je 0x8128c
movq %rbx, 0x8(%rcx)
movq 0x18(%rsp), %rax
incl 0x14(%rsp)
movq %rax, 0x18(%rsp)
movq 0x20(%rsp), %r12
movq 0x50(%rsp), %rcx
addq $0x18, %rbp
jmp 0x811ee
movq %r12, %rdi
callq 0x34ff7
movq 0x18(%rsp), %rbp
movq %rbp, %rdi
movl %r14d, %esi
callq 0x80611
movq 0x38(%rsp), %rcx
movl %eax, (%rcx)
xorl %edx, %edx
testl %r14d, %r14d
movl $0x0, %eax
cmovgl %r14d, %eax
movq %rax, 0x28(%rsp)
movl %r14d, %esi
movq 0x30(%rsp), %r10
movq %rsi, 0x20(%rsp)
cmpq 0x28(%rsp), %rdx
je 0x8137f
xorl %r12d, %r12d
cmpq %rsi, %r12
je 0x81377
cmpl $0x0, (%r10,%r12,4)
je 0x81306
incq %r12
jmp 0x812f5
movq %rbp, %rax
testq %rax, %rax
je 0x8131b
movl (%rax), %ecx
cmpq %rcx, %r12
je 0x81301
movq 0x8(%rax), %rax
jmp 0x81309
movq %rbp, %rbx
xorl %r13d, %r13d
movq %r13, %rdi
testq %rbx, %rbx
je 0x81366
movq %rdi, %r13
movq %rbx, %rdi
movq 0x8(%rbx), %rbx
cmpl %r12d, 0x4(%rdi)
jne 0x81324
movq %rdx, 0x8(%rsp)
movq %rbp, %rax
movq %rbx, %rbp
testq %r13, %r13
je 0x81350
movq %rbx, 0x8(%r13)
movq %rax, %rbp
callq 0x34ff7
movq 0x30(%rsp), %r10
movq 0x8(%rsp), %rdx
movq 0x20(%rsp), %rsi
jmp 0x81321
leal 0x1(%r12), %eax
movl %eax, (%r15,%rdx,4)
movl $0x1, (%r10,%r12,4)
incq %rdx
jmp 0x812e7
xorl %eax, %eax
movq 0x40(%rsp), %r9
testl %r9d, %r9d
cmovlel %eax, %r9d
pushq $0x1
popq %rcx
xorl %edx, %edx
cmpq %r9, %rax
je 0x813be
movq %rcx, %rsi
cmpl %r14d, %esi
jge 0x813b6
movl (%r15,%rax,4), %edi
xorl %r8d, %r8d
cmpl (%r15,%rsi,4), %edi
setg %r8b
addl %r8d, %edx
incq %rsi
jmp 0x8139a
incq %rax
incq %rcx
jmp 0x81392
xorl %eax, %eax
cmpl 0x14(%rsp), %edx
sete %al
movq 0x48(%rsp), %rcx
movl %eax, (%rcx)
movq %r10, %rdi
callq 0x34ff7
movq %r15, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq