// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/instance.c
// Function: stratified_partition
int* stratified_partition(int *prior_class_information, int datasize, int classnumber, int* classcounts)
{
	/*!Last Changed 02.02.2004 added safemalloc*/
	/*!Last Changed 23.11.2003*/
 long i,j,tmp;
	int* classes, classno, **indexes, *positions, *result;
	if (classnumber > 0)
	 {
  	positions = (int*)safecalloc(classnumber,sizeof(int), "stratified_partition", 5);
  	classes = (int*)safecalloc(classnumber,sizeof(int), "stratified_partition", 6);
	  indexes = safemalloc(classnumber * sizeof(int *), "stratified_partition", 7);
			for (i = 0; i < classnumber; i++)
				 indexes[i] = safemalloc(classcounts[i] * sizeof(int), "stratified_partition", 9);
   result = (int *)safemalloc(datasize * sizeof(int), "stratified_partition", 10);
   for (i = 0; i < datasize;i++)
			 {
  		 classno = prior_class_information[i];
	  		indexes[classno][positions[classno]] = i;
     result[i] = classes[classno];
			  (classes[classno])++;
			  (positions[classno])++;
			 }
   for (i = 0; i < datasize; i++)
			 {
  		 classno = prior_class_information[i];
     j = myrand() % classcounts[classno];
		  	j = indexes[classno][j];
     tmp = result[i];
     result[i] = result[j];
     result[j] = tmp;
			 }
	  free_2d((void**)indexes, classnumber);
  	safe_free(positions);
  	safe_free(classes);
	 }
	else
		 result = random_array(datasize);
	return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
cmpl $0x0, -0x10(%rbp)
jle 0x43f57
movslq -0x10(%rbp), %rdi
movl $0x4, %esi
leaq 0xa18d8(%rip), %rdx     # 0xe5628
movl $0x5, %ecx
callq 0x52f40
movq %rax, -0x50(%rbp)
movslq -0x10(%rbp), %rdi
movl $0x4, %esi
leaq 0xa18ba(%rip), %rdx     # 0xe5628
movl $0x6, %ecx
callq 0x52f40
movq %rax, -0x38(%rbp)
movslq -0x10(%rbp), %rdi
shlq $0x3, %rdi
leaq 0xa189d(%rip), %rsi     # 0xe5628
movl $0x7, %edx
callq 0x52d70
movq %rax, -0x48(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movslq -0x10(%rbp), %rcx
cmpq %rcx, %rax
jge 0x43dec
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rax,%rcx,4), %rdi
shlq $0x2, %rdi
leaq 0xa1863(%rip), %rsi     # 0xe5628
movl $0x9, %edx
callq 0x52d70
movq %rax, %rdx
movq -0x48(%rbp), %rax
movq -0x20(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x43da1
movslq -0xc(%rbp), %rdi
shlq $0x2, %rdi
leaq 0xa182d(%rip), %rsi     # 0xe5628
movl $0xa, %edx
callq 0x52d70
movq %rax, -0x58(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movslq -0xc(%rbp), %rcx
cmpq %rcx, %rax
jge 0x43e96
movq -0x8(%rbp), %rax
movq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x3c(%rbp)
movq -0x20(%rbp), %rax
movl %eax, %edx
movq -0x48(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x50(%rbp), %rcx
movslq -0x3c(%rbp), %rsi
movslq (%rcx,%rsi,4), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x38(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x58(%rbp), %rax
movq -0x20(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x38(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x50(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x43e11
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movslq -0xc(%rbp), %rcx
cmpq %rcx, %rax
jge 0x43f37
movq -0x8(%rbp), %rax
movq -0x20(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x3c(%rbp)
movb $0x0, %al
callq 0x54550
movq -0x18(%rbp), %rcx
movslq -0x3c(%rbp), %rsi
cltd
idivl (%rcx,%rsi,4)
movslq %edx, %rax
movq %rax, -0x28(%rbp)
movq -0x48(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x28(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
movq %rax, -0x28(%rbp)
movq -0x58(%rbp), %rax
movq -0x20(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
movq %rax, -0x30(%rbp)
movq -0x58(%rbp), %rax
movq -0x28(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x58(%rbp), %rax
movq -0x20(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x30(%rbp), %rax
movl %eax, %edx
movq -0x58(%rbp), %rax
movq -0x28(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x43e9e
movq -0x48(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x52e20
movq -0x50(%rbp), %rdi
callq 0x52e80
movq -0x38(%rbp), %rdi
callq 0x52e80
jmp 0x43f63
movl -0xc(%rbp), %edi
callq 0x54600
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)