// File: /workspace/github_c_makefile_star2_O1/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 $0x48, %rsp
movq %r9, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %rcx, %rbx
movl %edx, %ebp
movq %rdi, %r12
leal -0x1(%rsi), %eax
movl %eax, 0x1c(%rsp)
movl %eax, %r15d
imull %esi, %r15d
movq %rsi, 0x20(%rsp)
movslq %esi, %r13
leaq (,%r13,4), %rdi
leaq 0x221fe(%rip), %r14     # 0xae6ff
movq %r14, %rsi
movl $0x7, %edx
callq 0x390f5
movq %rax, 0x8(%rsp)
movl $0x4, %esi
movq %r13, %rdi
movq %r14, %rdx
movl $0x8, %ecx
callq 0x39210
movq %rax, 0x28(%rsp)
movq %r12, %rdi
movl %r13d, %esi
movl 0x80(%rsp), %edx
movl %ebp, %ecx
callq 0x8bf42
cmpl $0x2, %r15d
movq %rax, 0x30(%rsp)
jl 0x8c619
shrl %r15d
movq %rax, %r14
movl $0x0, 0x4(%rsp)
xorl %r12d, %r12d
xorl %ebp, %ebp
cmpl $0x0, 0x10(%r14)
jne 0x8c60a
movl $0x10, %edi
leaq 0x22185(%rip), %rsi     # 0xae6ff
movl $0x24, %edx
movq %r12, 0x10(%rsp)
callq 0x390f5
movq %rax, %r12
movl (%r14), %eax
movl %eax, (%r12)
movl 0x4(%r14), %ecx
movl %ecx, 0x4(%r12)
addb $0x31, %al
movsbl %al, %ecx
movq %rbx, %rdi
leaq 0x17021(%rip), %r13     # 0xa35cc
movq %r13, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x41b0
movb 0x4(%r14), %al
addb $0x31, %al
movsbl %al, %ecx
movq %rbx, %rdi
movq %r13, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x41b0
movq %rbx, %rdi
movq %r13, %rsi
movq %rbx, %rdx
movl $0x2d, %ecx
xorl %eax, %eax
callq 0x41b0
movq 0x10(%rsp), %rcx
movq $0x0, 0x8(%r12)
movq %r12, %rax
testq %rcx, %rcx
je 0x8c603
movq %r12, 0x8(%rcx)
movq %rbp, %rax
incl 0x4(%rsp)
movq %rax, %rbp
addq $0x18, %r14
decq %r15
jne 0x8c563
jmp 0x8c623
xorl %ebp, %ebp
movl $0x0, 0x4(%rsp)
movq 0x30(%rsp), %rdi
callq 0x39194
movq %rbp, %rdi
movq 0x20(%rsp), %r14
movl %r14d, %esi
callq 0x8b857
movq 0x38(%rsp), %rcx
movl %eax, (%rcx)
movl %r14d, %ebx
testl %r14d, %r14d
movq 0x28(%rsp), %r10
jle 0x8c6fc
xorl %edx, %edx
xorl %r14d, %r14d
cmpl $0x0, (%r10,%r14,4)
je 0x8c66e
incq %r14
cmpq %rbx, %r14
jne 0x8c65a
jmp 0x8c6f0
testq %rbp, %rbp
je 0x8c686
movq %rbp, %rax
movl (%rax), %ecx
cmpq %rcx, %r14
je 0x8c661
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x8c676
testq %rbp, %rbp
movq %rdx, 0x10(%rsp)
je 0x8c6c9
xorl %r15d, %r15d
movq %rbp, %rax
movq 0x8(%rbp), %r13
cmpl %r14d, 0x4(%rbp)
jne 0x8c6bc
movq %r13, %r12
testq %r15, %r15
je 0x8c6af
movq %r13, 0x8(%r15)
movq %rax, %r12
movq %rbp, %rdi
callq 0x39194
movq %r12, %rax
jmp 0x8c6bf
movq %rbp, %r15
movq %r13, %rbp
testq %r13, %r13
jne 0x8c696
jmp 0x8c6cc
movq %rbp, %rax
leal 0x1(%r14), %ecx
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rsi
movl %ecx, (%rdx,%rsi,4)
movq %rsi, %rdx
movq 0x28(%rsp), %r10
movl $0x1, (%r10,%r14,4)
movq %rax, %rbp
incq %rdx
cmpq %rbx, %rdx
jne 0x8c657
xorl %ecx, %ecx
cmpl $0x2, 0x20(%rsp)
jl 0x8c745
movl 0x1c(%rsp), %eax
xorl %edx, %edx
movq 0x8(%rsp), %rsi
xorl %ecx, %ecx
movq 0x8(%rsp), %rdi
movl (%rdi,%rdx,4), %edi
incq %rdx
movl $0x1, %r8d
xorl %r9d, %r9d
cmpl (%rsi,%r8,4), %edi
setg %r9b
addl %r9d, %ecx
incq %r8
cmpq %r8, %rbx
jne 0x8c723
addq $0x4, %rsi
decq %rbx
cmpq %rax, %rdx
jne 0x8c712
xorl %eax, %eax
cmpl 0x4(%rsp), %ecx
sete %al
movq 0x40(%rsp), %rcx
movl %eax, (%rcx)
movq %r10, %rdi
callq 0x39194
movq 0x8(%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq