// File: /workspace/github_c_makefile_star2_O0/DVaronos[P]AnLogProject1/logistic.c
// Function: Training
Model* Training(Model* model,Input* input,Hash* H,JobSheduler* Sheduler){

  int   i,j,start=0,limit,msize=10,curr=0;
	double w,b;
	Job* job;
	TrainStruct** array=malloc(sizeof(TrainStruct*)*msize);
	while(start<input->size){ //Gia ola ta zevgaria tou input
		if(curr<msize){//Ean iparxei xwros ston array
			array[curr]=malloc(sizeof(TrainStruct)*Sheduler->num); //ftiakse mia lista apo TrainStruct
		}else{//Resize kata 10 thesis ton pinaka array
			msize+=10;
			array=realloc(array,msize*sizeof(TrainStruct*));
			array[curr]=malloc(sizeof(TrainStruct)*Sheduler->num);
		}
		for(i=0 ; i<Sheduler->num ; i++ ){	//Gia kathe thread ftiakse mia domh TrainStruct kai arxikopieise thn
			array[curr][i].w=malloc(model->array_size*sizeof(double));
			for(j=0 ; j<model->array_size ; j++){
				array[curr][i].w[j]=model->weight_array[j];
			}
			array[curr][i].b=model->b;
			array[curr][i].input=input;
			array[curr][i].start=start;
			start+=1000;
			if(start>=input->size) start=input->size;
			array[curr][i].end=start;
			start++;
			job=JobCreate(JobTraining,(void*)(array[curr]+i));	//Dimiourgise ena neo job
			JSAddWork(Sheduler,job);	//Dwse to job ston Sheduler
			if(start==((input->size)+1)) break;	//An elegthoun ola ta zevgaria vges ap thn for
		}
		JSWaitalltasks(Sheduler);	//Perimene na teleiosoun ta threads
		limit=i;
		if(start==((input->size)+1)) limit++;
		for(i=0 ; i<model->array_size ; i++){	//arxikopieise to w kai to b
			w=0;
			for(j=0 ; j<limit ; j++){
				w+=array[curr][j].w[i];
			}
			w=w/limit;
			model->weight_array[i]=w;
		}
		b=0;
		for(i=0 ; i<limit ; i++){
			b+=array[curr][i].b;
		}
		b=b/limit;
		model->b=b;
		curr++;
	}
	for(int r=0 ; r<msize ; r++){	//Apodesmefse to array
		if(r<curr){
			for(int t=0 ; t<Sheduler->num ; t++){
				if((r==(curr-1)) && (t==limit)) break;
				free(array[r][t].w);
			}
			free(array[r]);
		}

	}
	free(array);
	return model;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0xa, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movslq -0x34(%rbp), %rdi
shlq $0x3, %rdi
callq 0x1190
movq %rax, -0x58(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x2df2
movl -0x38(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x2adb
movq -0x20(%rbp), %rax
movslq 0xa8(%rax), %rdi
shlq $0x5, %rdi
callq 0x1190
movq %rax, %rdx
movq -0x58(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x2b1c
movl -0x34(%rbp), %eax
addl $0xa, %eax
movl %eax, -0x34(%rbp)
movq -0x58(%rbp), %rdi
movslq -0x34(%rbp), %rsi
shlq $0x3, %rsi
callq 0x11b0
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rax
movslq 0xa8(%rax), %rdi
shlq $0x5, %rdi
callq 0x1190
movq %rax, %rdx
movq -0x58(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0xa8(%rcx), %eax
jge 0x2cb5
movq -0x8(%rbp), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
callq 0x1190
movq %rax, %rcx
movq -0x58(%rbp), %rax
movslq -0x38(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movslq -0x24(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x2bb7
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x28(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x58(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movslq -0x28(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x2b6c
movq -0x8(%rbp), %rax
movsd 0x8(%rax), %xmm0
movq -0x58(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movsd %xmm0, 0x8(%rax)
movq -0x10(%rbp), %rcx
movq -0x58(%rbp), %rax
movslq -0x38(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movslq -0x24(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movq %rcx, 0x18(%rax)
movl -0x2c(%rbp), %ecx
movq -0x58(%rbp), %rax
movslq -0x38(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movslq -0x24(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movl -0x2c(%rbp), %eax
addl $0x3e8, %eax            # imm = 0x3E8
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jl 0x2c38
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %ecx
movq -0x58(%rbp), %rax
movslq -0x38(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movslq -0x24(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movq -0x58(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movslq -0x24(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rsi
leaq 0x224(%rip), %rdi       # 0x2ea0
callq 0x74e0
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x7870
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
movl 0x10(%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x2ca5
jmp 0x2cb5
jmp 0x2ca7
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2b23
movq -0x20(%rbp), %rdi
callq 0x78f0
movl -0x24(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
movl 0x10(%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x2cde
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jge 0x2d7b
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x2d45
movq -0x58(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x28(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movslq -0x24(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
addsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x2d04
movsd -0x40(%rbp), %xmm0
cvtsi2sdl -0x30(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
movq -0x8(%rbp), %rax
movq (%rax), %rax
movslq -0x24(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2ce5
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x2dc3
movq -0x58(%rbp), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
addsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2d8a
movsd -0x48(%rbp), %xmm0
cvtsi2sdl -0x30(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
movq -0x8(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x2a9e
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x2e86
movl -0x5c(%rbp), %eax
cmpl -0x38(%rbp), %eax
jge 0x2e76
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0xa8(%rcx), %eax
jge 0x2e65
movl -0x5c(%rbp), %eax
movl -0x38(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x2e3a
movl -0x60(%rbp), %eax
cmpl -0x30(%rbp), %eax
jne 0x2e3a
jmp 0x2e65
movq -0x58(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x60(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
callq 0x1030
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x2e14
movq -0x58(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1030
jmp 0x2e78
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x2df9
movq -0x58(%rbp), %rdi
callq 0x1030
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)