// File: /workspace/github_c_makefile_star2_O1/olcaytaner[P]Isell/regression.c
// Function: train_gprocessreg
void* train_gprocessreg(Instanceptr* trdata, Instanceptr *cvdata, void* parameters)
{
 /*!Last Changed 15.01.2009*/
 int i, j;
 matrix kernel_matrix, t;
 Svm_nodeptr* nodelist;
 Svm_parameter param;
 Gprocess_parameterptr gp = (Gprocess_parameterptr) parameters;
 Model_gprocessregressionptr m = safemalloc(sizeof(Model_gprocessregression), "train_gprocessreg", 3);
 Instanceptr tmp = *trdata;
 m->size = data_size(*trdata);
 m->data = *trdata;
 kernel_matrix = matrix_alloc(m->size, m->size);
 t = matrix_alloc(m->size, 1);
 nodelist = safemalloc(m->size * sizeof(Svm_nodeptr), "train_gprocessreg", 10);
 i = 0;
 while (tmp)
  {
   nodelist[i] = instance_to_svmnode(tmp);
   t.values[i][0] = give_regressionvalue(tmp);
   tmp = tmp->next;
   i++;
  }
 param.kernel_type = gp->kernel_type;
 param.coef0 = gp->coef0;
 param.gamma = gp->gamma;
 param.degree = gp->degree;
 for (i = 0; i < m->size; i++)
   for (j = 0; j < m->size; j++)
     kernel_matrix.values[i][j] = k_function(nodelist[i], nodelist[j], param);
 for (i = 0; i < m->size; i++)
   kernel_matrix.values[i][i] += gp->sigma;
 matrix_inverse(&kernel_matrix);
 matrix_product(&kernel_matrix, t);
 m->weights = safemalloc(m->size * sizeof(double), "train_gprocessreg", 25);
 for (i = 0; i < m->size; i++)
   m->weights[i] = kernel_matrix.values[i][0];
 for (i = 0; i < m->size; i++)
   safe_free(nodelist[i]);
 safe_free(nodelist);
 matrix_free(kernel_matrix);
 matrix_free(t);
 return m;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdx, %r13
movq %rdi, %r14
leaq 0x3b59b(%rip), %r12     # 0xaca0d
movl $0x18, %edi
movq %r12, %rsi
movl $0x3, %edx
callq 0x390f5
movq %rax, %rbx
movq (%r14), %rbp
movq %rbp, %rdi
callq 0x2fa14
movl %eax, (%rbx)
movq (%r14), %rcx
movq %rcx, 0x8(%rbx)
movl %eax, %edi
movl %eax, %esi
callq 0x3c6e5
movq %rax, 0x60(%rsp)
movq %rdx, 0x68(%rsp)
movl (%rbx), %edi
movl $0x1, %esi
callq 0x3c6e5
movq %rax, 0x70(%rsp)
movq %rdx, %r15
movslq (%rbx), %rdi
shlq $0x3, %rdi
movq %r12, %rsi
movl $0xa, %edx
callq 0x390f5
movq %rax, %r12
testq %rbp, %rbp
je 0x7150a
xorl %r14d, %r14d
movq %rbp, %rdi
callq 0x2e3eb
movq %rax, (%r12,%r14)
movq %rbp, %rdi
callq 0x2eaee
movq (%r15,%r14), %rax
movsd %xmm0, (%rax)
movq 0x10(%rbp), %rbp
addq $0x8, %r14
testq %rbp, %rbp
jne 0x714e1
movq %r15, 0x78(%rsp)
movl 0x8(%r13), %eax
movl %eax, 0x84(%rsp)
movsd 0x10(%r13), %xmm0
movsd %xmm0, 0x98(%rsp)
movsd 0x20(%r13), %xmm0
movsd %xmm0, 0x90(%rsp)
movl 0x18(%r13), %eax
movl %eax, 0x88(%rsp)
movl (%rbx), %eax
testl %eax, %eax
movq 0x70(%rsp), %r15
jle 0x715ac
xorl %r14d, %r14d
leaq 0x80(%rsp), %rbp
cmpl $0x0, (%rbx)
jle 0x7159c
xorl %r15d, %r15d
movq (%r12,%r14,8), %rax
movq (%r12,%r15,8), %rdx
movl $0xb, %ecx
movq %rsp, %rdi
movq %rbp, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rax, %rdi
movq %rdx, %rsi
callq 0x912a1
movq 0x68(%rsp), %rax
movq (%rax,%r14,8), %rax
movsd %xmm0, (%rax,%r15,8)
incq %r15
movslq (%rbx), %rax
cmpq %rax, %r15
jl 0x71561
incq %r14
movslq (%rbx), %rax
cmpq %rax, %r14
jl 0x71559
movq 0x70(%rsp), %r15
testl %eax, %eax
jle 0x715d5
movq 0x68(%rsp), %rcx
movl %eax, %eax
xorl %edx, %edx
movsd (%r13), %xmm0
movq (%rcx,%rdx,8), %rsi
addsd (%rsi,%rdx,8), %xmm0
movsd %xmm0, (%rsi,%rdx,8)
incq %rdx
cmpq %rdx, %rax
jne 0x715b9
leaq 0x60(%rsp), %r13
movq %r13, %rdi
callq 0x3f648
movq %r13, %rdi
movq %r15, %rsi
movq 0x78(%rsp), %r13
movq %r13, %rdx
callq 0x3e83e
movslq (%rbx), %rdi
shlq $0x3, %rdi
leaq 0x3b40a(%rip), %rsi     # 0xaca0d
movl $0x19, %edx
callq 0x390f5
movq %rax, 0x10(%rbx)
movslq (%rbx), %rcx
testq %rcx, %rcx
jle 0x71635
movq 0x68(%rsp), %rdx
xorl %esi, %esi
movq (%rdx,%rsi,8), %rdi
movsd (%rdi), %xmm0
movsd %xmm0, (%rax,%rsi,8)
incq %rsi
cmpq %rsi, %rcx
jne 0x71620
cmpl $0x0, (%rbx)
jle 0x71651
xorl %r14d, %r14d
movq (%r12,%r14,8), %rdi
callq 0x39194
incq %r14
movslq (%rbx), %rax
cmpq %rax, %r14
jl 0x7163d
movq %r12, %rdi
callq 0x39194
movq 0x60(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0x3dbad
movq %r15, %rdi
movq %r13, %rsi
callq 0x3dbad
movq %rbx, %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq