// File: /workspace/github_c_makefile_star2_O3/DVaronos[P]AnLogProject1/logistic.c
// Function: TestAndAdd
void TestAndAdd(Hash* H,Model* model,JobSheduler* Sheduler,Input** input,double threshold){
	Job* job;
	int i,sum,who=0,start=1,msize=10,curr=0;
	TestStruct** current=malloc(sizeof(TestStruct*)*msize);
	NList** nodes;
	MakeArrays(H,&sum,&nodes); //Ftiaxnw ena array me NList komvous gia kathe kamera pou den exei klika
	while(who<(sum-1)){ //Gia oles aftes is kameres
		if(curr<msize){	//Ean iparxei xoros sto array
	    current[curr]=malloc(sizeof(TestStruct)*Sheduler->num);
	  }else{//Allios resize to array kata 10
	    msize+=10;
	    current=realloc(current,msize*sizeof(TestStruct*));
	    current[curr]=malloc(sizeof(TestStruct)*Sheduler->num);
	  }
		for(i=0 ; i<Sheduler->num ; i++){	//Gia kathe thread ftiakse ena TestStruct kai arxikopieise to
			current[curr][i].who=who;
			current[curr][i].start=start;
			start+=1000;
			if(start>=(sum-1)) start=sum-1;
			current[curr][i].end=start;
			current[curr][i].model=model;
			current[curr][i].threshold=threshold;
			current[curr][i].input=*input;
			current[curr][i].hash=H;
			current[curr][i].Sheduler=Sheduler;
			current[curr][i].nodes=nodes;
			current[curr][i].sum=sum-1;
			job=JobCreate(TestData,(void*)(current[curr]+i)); //ftiakse ena job
			JSAddWork(Sheduler,job); //Dose to job sto Sheduler
			start++;
			if(start==sum){
				who++;
				if(who==sum-1) break;
				start=who+1;
			}
		}
		JSWaitalltasks(Sheduler); //perimene na teliosoun ta threads
		curr++;
	}
	for(int k=0 ; k<curr ; k++){
		free(current[k]);
	}
	free(current);
	free(nodes);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movsd %xmm0, -0x90(%rbp)
movq %rcx, -0x88(%rbp)
movq %rdx, -0x30(%rbp)
movq %rsi, -0x80(%rbp)
movq %rdi, %rbx
movl $0x50, %edi
callq 0x11a0
movq %rax, %r15
leaq -0x9c(%rbp), %r14
leaq -0x60(%rbp), %rdx
movq %rbx, -0x78(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2d22
movl (%r14), %eax
cmpl $0x2, %eax
jl 0x2d03
leal -0x1(%rax), %ecx
movl %ecx, -0x38(%rbp)
movq %rax, -0x70(%rbp)
addl $-0x2, %eax
movl %eax, -0x3c(%rbp)
xorl %r12d, %r12d
movl $0xa, -0x34(%rbp)
movl $0x1, %eax
movl $0x1, %r14d
xorl %edx, %edx
movq %rdx, -0x48(%rbp)
movl %eax, %ecx
movslq -0x34(%rbp), %rax
cmpq %rax, %r12
movq %rcx, -0x68(%rbp)
jl 0x2b90
leal 0xa(%rax), %ecx
movl %ecx, -0x34(%rbp)
leaq 0x50(,%rax,8), %rsi
movq %r15, %rdi
callq 0x11c0
movq %rax, %r15
movq -0x30(%rbp), %rax
movslq 0xa8(%rax), %rbx
movq %rbx, %rdi
shlq $0x6, %rdi
callq 0x11a0
movq %r15, -0x58(%rbp)
movq %r12, -0x50(%rbp)
movq %rax, (%r15,%r12,8)
testq %rbx, %rbx
jle 0x2cb9
movq -0x60(%rbp), %rax
movq %rax, -0x98(%rbp)
xorl %r12d, %r12d
xorl %ebx, %ebx
movq -0x30(%rbp), %rdi
movq -0x48(%rbp), %r13
movq -0x58(%rbp), %rdx
movq -0x50(%rbp), %r9
movq (%rdx,%r9,8), %rax
movl %r13d, 0x8(%rax,%r12)
movl %r14d, (%rax,%r12)
addl $0x3e8, %r14d           # imm = 0x3E8
movl -0x38(%rbp), %r8d
cmpl %r8d, %r14d
cmovgel %r8d, %r14d
movl %r14d, 0x4(%rax,%r12)
movq -0x80(%rbp), %rcx
movq %rcx, 0x18(%rax,%r12)
movq (%rdx,%r9,8), %rax
movsd -0x90(%rbp), %xmm0
movsd %xmm0, 0x10(%rax,%r12)
movq -0x88(%rbp), %rcx
movq (%rcx), %rcx
movq %rcx, 0x28(%rax,%r12)
movq (%rdx,%r9,8), %rax
movq -0x78(%rbp), %rcx
movq %rcx, 0x20(%rax,%r12)
movq (%rdx,%r9,8), %rax
movq %rdi, 0x38(%rax,%r12)
movq (%rdx,%r9,8), %rax
movq -0x98(%rbp), %rcx
movq %rcx, 0x30(%rax,%r12)
movq (%rdx,%r9,8), %rsi
movl %r8d, 0xc(%rsi,%r12)
addq %r12, %rsi
movq %rdi, %r15
leaq 0x17f(%rip), %rdi       # 0x2de6
callq 0x543c
movq %r15, %rdi
movq %rax, %rsi
callq 0x5654
incl %r14d
movq -0x70(%rbp), %rax
cmpl %eax, %r14d
jne 0x2c99
leal 0x1(%r13), %r15d
cmpl -0x3c(%rbp), %r13d
je 0x2cc2
addl $0x2, %r13d
movl %r13d, %r14d
movl %r15d, %r13d
jmp 0x2c9c
movl %r13d, %r15d
movq -0x30(%rbp), %rdi
incq %rbx
movslq 0xa8(%rdi), %rax
addq $0x40, %r12
cmpq %rax, %rbx
jl 0x2bd4
jmp 0x2cc9
movq -0x48(%rbp), %rax
movl %eax, %r15d
jmp 0x2cc5
movl %eax, %r14d
movq -0x30(%rbp), %rdi
callq 0x56a5
movq -0x50(%rbp), %r12
incq %r12
movq -0x68(%rbp), %rcx
leal 0x1(%rcx), %eax
movl %r15d, %edx
cmpl -0x38(%rbp), %r15d
movq -0x58(%rbp), %r15
jl 0x2b64
movl %ecx, %ebx
xorl %r14d, %r14d
movq (%r15,%r14,8), %rdi
callq 0x1030
incq %r14
cmpq %r14, %rbx
jne 0x2cf2
movq %r15, %rdi
callq 0x1030
movq -0x60(%rbp), %rdi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1030