// File: /workspace/github_c_makefile_star2_O2/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 $0xe8, %rsp
movq %rdx, 0x68(%rsp)
movq %rdi, %r12
leaq 0x367e4(%rip), %r14     # 0x9fa05
pushq $0x18
popq %rdi
pushq $0x3
popq %rdx
movq %r14, %rsi
callq 0x34f59
movq %rax, %rbx
movq (%r12), %r15
movq %r15, %rdi
callq 0x2c3cc
movl %eax, (%rbx)
movq (%r12), %rcx
movq %rcx, 0x8(%rbx)
movl %eax, %edi
movl %eax, %esi
callq 0x380d3
movq %rdx, %rbp
movq %rax, 0x70(%rsp)
movq %rdx, 0x78(%rsp)
movl (%rbx), %edi
pushq $0x1
popq %rsi
callq 0x380d3
movq %rax, 0x80(%rsp)
movq %rdx, %r13
movq %rbx, 0x60(%rsp)
movslq (%rbx), %rdi
shlq $0x3, %rdi
pushq $0xa
popq %rdx
movq %r14, %rsi
callq 0x34f59
movq %rax, %r12
xorl %r14d, %r14d
testq %r15, %r15
je 0x692bc
movq %r15, %rdi
callq 0x2add8
movq %rax, (%r12,%r14)
movq %r15, %rdi
callq 0x2b4a0
movq (%r13,%r14), %rax
movsd %xmm0, (%rax)
movq 0x10(%r15), %r15
addq $0x8, %r14
jmp 0x69290
movq %r13, 0x88(%rsp)
movq 0x68(%rsp), %rcx
movl 0x8(%rcx), %eax
leaq 0x90(%rsp), %r15
movl %eax, 0x4(%r15)
movsd 0x10(%rcx), %xmm0
movsd %xmm0, 0x18(%r15)
movsd 0x20(%rcx), %xmm0
movsd %xmm0, 0x10(%r15)
movl 0x18(%rcx), %eax
movl %eax, 0x8(%r15)
movq 0x60(%rsp), %rax
movl (%rax), %eax
xorl %r13d, %r13d
pushq $0xb
popq %r14
movslq %eax, %rcx
cmpq %rcx, %r13
jge 0x6934f
xorl %ebx, %ebx
movslq %eax, %rcx
cmpq %rcx, %rbx
jge 0x6934a
movq (%r12,%r13,8), %rax
movq (%r12,%rbx,8), %rdx
movq %r14, %rcx
movq %rsp, %rdi
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rax, %rdi
movq %rdx, %rsi
callq 0x8591e
movq (%rbp,%r13,8), %rax
movsd %xmm0, (%rax,%rbx,8)
incq %rbx
movq 0x60(%rsp), %rax
movl (%rax), %eax
jmp 0x6930d
incq %r13
jmp 0x69303
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
movq 0x88(%rsp), %r15
movq 0x80(%rsp), %r13
movq 0x68(%rsp), %rsi
cmpq %rcx, %rax
je 0x69388
movsd (%rsi), %xmm0
movq (%rbp,%rcx,8), %rdx
addsd (%rdx,%rcx,8), %xmm0
movsd %xmm0, (%rdx,%rcx,8)
incq %rcx
jmp 0x6936b
leaq 0x70(%rsp), %r14
movq %r14, %rdi
callq 0x3a9f7
movq %r14, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x39d59
movq 0x60(%rsp), %rbx
movslq (%rbx), %rdi
shlq $0x3, %rdi
leaq 0x3664f(%rip), %rsi     # 0x9fa05
pushq $0x19
popq %rdx
callq 0x34f59
movq %rax, 0x10(%rbx)
movl (%rbx), %ecx
movq 0x8(%r14), %rdx
xorl %esi, %esi
testl %ecx, %ecx
movl $0x0, %edi
cmovgl %ecx, %edi
cmpq %rsi, %rdi
je 0x693ec
movq (%rdx,%rsi,8), %r8
movsd (%r8), %xmm0
movsd %xmm0, (%rax,%rsi,8)
incq %rsi
jmp 0x693d4
xorl %ebx, %ebx
movslq %ecx, %rax
cmpq %rax, %rbx
jge 0x6940b
movq (%r12,%rbx,8), %rdi
callq 0x34ff7
incq %rbx
movq 0x60(%rsp), %rax
movl (%rax), %ecx
jmp 0x693ee
movq %r12, %rdi
callq 0x34ff7
movq 0x70(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0x3929f
movq %r13, %rdi
movq %r15, %rsi
callq 0x3929f
movq 0x60(%rsp), %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq