// File: /workspace/github_c_makefile_star2_O3/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, 0x40(%rsp)
movq %r8, 0x48(%rsp)
movq %rcx, 0x50(%rsp)
movl %edx, %ebp
movq %rdi, %r12
movl 0x90(%rsp), %ebx
leal -0x1(%rsi), %eax
movl %eax, 0x24(%rsp)
movl %eax, %r14d
imull %esi, %r14d
movq %rsi, 0x28(%rsp)
movslq %esi, %r13
leaq (,%r13,4), %rdi
leaq 0x22af7(%rip), %r15     # 0xb178f
movq %r15, %rsi
movl $0x7, %edx
callq 0x3a0e1
movq %rax, 0x30(%rsp)
movl $0x4, %esi
movq %r13, %rdi
movq %r15, %rdx
movl $0x8, %ecx
callq 0x3a1fc
movq %rax, 0x10(%rsp)
movq %r12, %rdi
movl %r13d, %esi
movl %ebx, %edx
movl %ebp, %ecx
callq 0x8e6f8
xorl %r12d, %r12d
cmpl $0x2, %r14d
movq %rax, 0x38(%rsp)
jl 0x8edb8
shrl %r14d
movq %rax, %rbx
movl $0x0, 0xc(%rsp)
xorl %eax, %eax
xorl %ebp, %ebp
movq 0x10(%rsp), %r13
movq 0x50(%rsp), %r15
cmpl $0x0, 0x10(%rbx)
jne 0x8eda9
movl $0x10, %edi
leaq 0x22a78(%rip), %rsi     # 0xb178f
movl $0x24, %edx
movq %rax, 0x18(%rsp)
callq 0x3a0e1
movq %rax, %r13
movq (%rbx), %rax
movq %rax, (%r13)
addb $0x31, %al
movsbl %al, %ecx
movq %r15, %rdi
leaq 0x178d1(%rip), %rsi     # 0xa6610
movq %r15, %rdx
xorl %eax, %eax
callq 0x41b0
movb 0x4(%rbx), %al
addb $0x31, %al
movsbl %al, %ecx
movq %r15, %rdi
leaq 0x178b5(%rip), %rsi     # 0xa6610
movq %r15, %rdx
xorl %eax, %eax
callq 0x41b0
movq %r15, %rdi
leaq 0x178a1(%rip), %rsi     # 0xa6610
movq %r15, %rdx
movl $0x2d, %ecx
xorl %eax, %eax
callq 0x41b0
movq 0x18(%rsp), %rcx
movq $0x0, 0x8(%r13)
movq %r13, %rax
testq %rcx, %rcx
je 0x8ed9a
movq %r13, 0x8(%rcx)
movq %rbp, %rax
incl 0xc(%rsp)
movq %rax, %rbp
movq %r13, %rax
movq 0x10(%rsp), %r13
addq $0x18, %rbx
decq %r14
jne 0x8ed01
jmp 0x8edc7
xorl %ebp, %ebp
movl $0x0, 0xc(%rsp)
movq 0x10(%rsp), %r13
movq 0x38(%rsp), %rdi
callq 0x3a180
movq %rbp, %rdi
movq 0x28(%rsp), %rbx
movl %ebx, %esi
callq 0x8dff3
movq 0x40(%rsp), %rcx
movl %eax, (%rcx)
testl %ebx, %ebx
movq 0x30(%rsp), %r14
jle 0x8eee3
movl %ebx, %ebx
xorl %edx, %edx
xorl %r12d, %r12d
cmpl $0x0, (%r13,%r12,4)
je 0x8ee10
incq %r12
cmpq %rbx, %r12
jne 0x8edfb
jmp 0x8ee94
movq %rbp, %rax
testq %rbp, %rbp
je 0x8ee7d
movl (%rax), %ecx
cmpq %rcx, %r12
je 0x8ee03
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x8ee18
testq %rbp, %rbp
je 0x8ee7d
movq %rdx, 0x18(%rsp)
xorl %r15d, %r15d
movq %rbp, %rax
movq 0x8(%rbp), %r13
cmpl %r12d, 0x4(%rbp)
jne 0x8ee5e
movq %r13, %r14
testq %r15, %r15
je 0x8ee51
movq %r13, 0x8(%r15)
movq %rax, %r14
movq %rbp, %rdi
callq 0x3a180
movq %r14, %rax
jmp 0x8ee61
movq %rbp, %r15
movq %r13, %rbp
testq %r13, %r13
jne 0x8ee38
movl %r12d, %ecx
movq 0x30(%rsp), %r14
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %rdx
jmp 0x8ee82
movl %r12d, %ecx
xorl %eax, %eax
incl %ecx
movl %ecx, (%r14,%rdx,4)
movl $0x1, (%r13,%r12,4)
movq %rax, %rbp
incq %rdx
cmpq %rbx, %rdx
jne 0x8edf8
xorl %r12d, %r12d
cmpl $0x1, 0x28(%rsp)
je 0x8eee3
movl 0x24(%rsp), %eax
xorl %ecx, %ecx
movq %r14, %rdx
xorl %r12d, %r12d
movl (%r14,%rcx,4), %esi
incq %rcx
movl $0x1, %edi
xorl %r8d, %r8d
cmpl (%rdx,%rdi,4), %esi
setg %r8b
addl %r8d, %r12d
incq %rdi
cmpq %rdi, %rbx
jne 0x8eec2
addq $0x4, %rdx
decq %rbx
cmpq %rax, %rcx
jne 0x8eeb6
xorl %eax, %eax
cmpl 0xc(%rsp), %r12d
sete %al
movq 0x48(%rsp), %rcx
movl %eax, (%rcx)
movq %r13, %rdi
callq 0x3a180
movq %r14, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq