// File: /workspace/github_c_makefile_star2_O2/olcaytaner[P]Isell/tests.c
// Function: assign_ranks_to_equal_size_observations
void assign_ranks_to_equal_size_observations(Obsptr* obs, int k, int N)
{
	int i, j, t, l, sum;
 Obs tmp, *obsarray;
 obsarray = safemalloc(k * sizeof(Obs), "assign_ranks_to_equal_size_observations", 3); 
	for (i = 0; i < N; i++)
	 {
			for (j = 0; j < k; j++)
				 for (t = j + 1; t < k; t++)
							if ((obs[t][i].observation < obs[j][i].observation && !get_parameter_o("accuracy")) || (obs[t][i].observation > obs[j][i].observation && get_parameter_o("accuracy")))
        {
         tmp = obs[t][i];
         obs[t][i] = obs[j][i];
         obs[j][i] = tmp;
        }
   j = 0;
   while (j < k)
    {
     t = j;
     while (j + 1 < k && obs[j][i].observation == obs[j + 1][i].observation)
       j++;
     if (j != t)
      {
       sum = 0;
       for (l = t + 1; l <= j + 1; l++)
         sum += l;
       for (l = t; l <= j; l++)
         obs[l][i].rij = (sum + 0.0) / (j - t + 1);
      }
     else
       obs[j][i].rij = j + 1;
     j++;
    }
   for (j = 0; j < k; j++)
     obsarray[obs[j][i].index] = obs[j][i];
   for (j = 0; j < k; j++)
     obs[j][i] = obsarray[j];
		}
 safe_free(obsarray);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %edx, %ebx
movl %esi, %ebp
movq %rdi, %r14
movslq %esi, %r15
movq %r15, %rdi
shlq $0x5, %rdi
leaq 0x185fe(%rip), %rsi     # 0xa1c50
pushq $0x3
popq %rdx
callq 0x34f59
xorl %r13d, %r13d
testl %r15d, %r15d
movl $0x0, %r12d
cmovgl %ebp, %r12d
movq %rax, 0x8(%rsp)
testl %ebx, %ebx
cmovlel %r13d, %ebx
movq %rbx, 0x28(%rsp)
leal -0x1(%r15), %eax
movl %eax, 0x14(%rsp)
leaq (,%r12,8), %rax
movq %rax, 0x38(%rsp)
movq %r15, 0x20(%rsp)
movq %r12, 0x30(%rsp)
cmpq 0x28(%rsp), %r13
je 0x898a8
xorl %r15d, %r15d
pushq $0x1
popq %rax
movq %rax, 0x18(%rsp)
cmpq %r12, %r15
je 0x89783
movq 0x18(%rsp), %r12
cmpl %ebp, %r12d
jge 0x89771
movq (%r14,%r12,8), %rax
movq %r13, %rbx
shlq $0x5, %rbx
movsd 0x8(%rax,%rbx), %xmm0
movq (%r14,%r15,8), %rax
movsd 0x8(%rax,%rbx), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x8970b
leaq 0x1233e(%rip), %rdi     # 0x9ba2c
callq 0x4cff1
testl %eax, %eax
je 0x89721
movq (%r14,%r12,8), %rax
movsd 0x8(%rax,%rbx), %xmm0
movq (%r14,%r15,8), %rax
movsd 0x8(%rax,%rbx), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x89769
leaq 0x12314(%rip), %rdi     # 0x9ba2c
callq 0x4cff1
testl %eax, %eax
je 0x89769
movq (%r14,%r12,8), %rax
movups (%rax,%rbx), %xmm0
movups 0x10(%rax,%rbx), %xmm1
movaps %xmm1, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movq (%r14,%r15,8), %rcx
movups (%rcx,%rbx), %xmm0
movups 0x10(%rcx,%rbx), %xmm1
movups %xmm0, (%rax,%rbx)
movups %xmm1, 0x10(%rax,%rbx)
movq (%r14,%r15,8), %rax
movapd 0x40(%rsp), %xmm0
movapd 0x50(%rsp), %xmm1
movupd %xmm1, 0x10(%rax,%rbx)
movupd %xmm0, (%rax,%rbx)
incq %r12
jmp 0x896bd
incq %r15
incq 0x18(%rsp)
movq 0x30(%rsp), %r12
jmp 0x896af
xorl %esi, %esi
movq %r13, %rax
shlq $0x5, %rax
movq 0x20(%rsp), %r15
cmpl %ebp, %esi
jge 0x8983e
movslq %esi, %rcx
leaq 0x1(%rcx), %rdi
movl %esi, %edx
cmpq %r15, %rdi
jge 0x897cc
movq -0x8(%r14,%rdi,8), %r8
movq (%r14,%rdi,8), %r9
movsd 0x8(%r8,%rax), %xmm0
incl %edx
incq %rdi
ucomisd 0x8(%r9,%rax), %xmm0
jne 0x897c7
jnp 0x897a2
leal -0x1(%rdx), %edi
jmp 0x897d4
movl 0x14(%rsp), %edx
movl %edx, %edi
movl %ebp, %edx
movl %edi, %r8d
subl %esi, %r8d
jne 0x897ee
cvtsi2sd %edx, %xmm0
movq (%r14,%rcx,8), %rcx
movsd %xmm0, 0x10(%rcx,%rax)
movl %edx, %esi
jmp 0x89791
leal 0x1(%rdi), %r9d
cmpl %r9d, %esi
cmovgl %esi, %r9d
movl %r9d, %r10d
subl %esi, %r10d
leal 0x1(%rsi), %r11d
notl %esi
addl %r9d, %esi
imull %r10d, %r11d
imulq %rsi, %r10
shrq %r10
addl %r10d, %r11d
cvtsi2sd %r11d, %xmm0
incl %r8d
cvtsi2sd %r8d, %xmm1
divsd %xmm1, %xmm0
movslq %edi, %rsi
cmpq %rsi, %rcx
jg 0x897ea
movq (%r14,%rcx,8), %rdi
movsd %xmm0, 0x10(%rdi,%rax)
incq %rcx
jmp 0x8982a
xorl %ecx, %ecx
cmpq %rcx, %r12
je 0x89872
movq (%r14,%rcx,8), %rdx
movslq 0x18(%rdx,%rax), %rsi
shlq $0x5, %rsi
movupd (%rdx,%rax), %xmm0
movupd 0x10(%rdx,%rax), %xmm1
movq 0x8(%rsp), %rdx
movupd %xmm1, 0x10(%rdx,%rsi)
movupd %xmm0, (%rdx,%rsi)
incq %rcx
jmp 0x89840
xorl %ecx, %ecx
cmpq %rcx, 0x38(%rsp)
je 0x898a0
movq (%r14,%rcx), %rdx
movq 0x8(%rsp), %rsi
movupd (%rsi,%rcx,4), %xmm0
movupd 0x10(%rsi,%rcx,4), %xmm1
movupd %xmm1, 0x10(%rdx,%rax)
movupd %xmm0, (%rdx,%rax)
addq $0x8, %rcx
jmp 0x89874
incq %r13
jmp 0x89699
movq 0x8(%rsp), %rdi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x34ff7