// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/classification.c
// Function: train_logistic
void* train_logistic(Instanceptr* trdata, Instanceptr *cvdata, void* parameters)
{
 /*!Last Changed 17.04.2005*/
 double** w, **deltaw, *y, diff, eta;
 Instanceptr tmp;
 int i, j, k, cno;
 Logistic_parameterptr param;
 param = (Logistic_parameterptr) parameters;
 w = two_dimensional_initialize(current_dataset->classno, current_dataset->multifeaturecount, 0.01);
 deltaw = (double**) safemalloc_2d(sizeof(double *), sizeof(double), current_dataset->classno, current_dataset->multifeaturecount, "logistic", 7);
 y = safemalloc(current_dataset->classno * sizeof(double), "logistic", 6);
 eta = param->learning_rate;
 for (k = 0; k < param->perceptron_run; k++)
  {
   for (i = 0; i < current_dataset->classno; i++)
     for (j = 0; j < current_dataset->multifeaturecount; j++)
       deltaw[i][j] = 0.0;
   tmp = *trdata;
   while (tmp)
    {
     for (i = 0; i < current_dataset->classno; i++)
      {
       y[i] = w[i][0];
       for (j = 0; j < current_dataset->multifeaturecount - 1; j++)
         y[i] += w[i][j + 1] * real_feature(tmp, j);
      }
     softmax(y, current_dataset->classno);
     for (i = 0; i < current_dataset->classno; i++)
      {
       cno = give_classno(tmp);
       if (cno == i)
         diff = 1.0 - y[i];
       else
         diff = 0.0 - y[i];
       deltaw[i][0] += diff;
       for (j = 0; j < current_dataset->multifeaturecount - 1; j++)
         deltaw[i][j + 1] += diff * real_feature(tmp, j);
      }
     tmp = tmp->next;
    }
   for (i = 0; i < current_dataset->classno; i++)
     for (j = 0; j < current_dataset->multifeaturecount; j++)
       w[i][j] += eta * deltaw[i][j];
   eta *= param->etadecrease;
  }
 free_2d((void**)deltaw, current_dataset->classno);
 safe_free(y);
 return w;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %rbx
movq %rdi, 0x18(%rsp)
leaq 0xc9674(%rip), %r14     # 0xd5870
movq (%r14), %rax
movl 0x10(%rax), %edi
movl 0x1c0(%rax), %esi
movsd 0x99bb0(%rip), %xmm0    # 0xa5dc0
callq 0x55b0c
movq %rax, 0x8(%rsp)
movq (%r14), %rax
movl 0x10(%rax), %edx
movl 0x1c0(%rax), %ecx
leaq 0x99da8(%rip), %r15     # 0xa5fd5
movl $0x8, %edi
movl $0x8, %esi
movq %r15, %r8
movl $0x7, %r9d
callq 0x3a3ac
movq %rax, %r12
movq (%r14), %rax
movslq 0x10(%rax), %rdi
shlq $0x3, %rdi
movq %r15, %rsi
movl $0x6, %edx
callq 0x3a0e1
movq %rax, %r13
cmpl $0x0, (%rbx)
movq (%r14), %r14
jle 0xc4b4
movsd 0x8(%rbx), %xmm1
movl 0x10(%r14), %r15d
xorl %r9d, %r9d
movq %rbx, 0x10(%rsp)
movq %r12, 0x30(%rsp)
movq %r13, 0x40(%rsp)
movq %r9, 0x20(%rsp)
movsd %xmm1, 0x28(%rsp)
testl %r15d, %r15d
jle 0xc2d1
movl 0x1c0(%r14), %eax
movq %rax, (%rsp)
shlq $0x3, %rax
movq %rax, 0x38(%rsp)
movl %r15d, %ebp
xorl %ebx, %ebx
cmpl $0x0, (%rsp)
jle 0xc2c9
movq (%r12,%rbx,8), %rdi
xorl %esi, %esi
movq 0x38(%rsp), %rdx
callq 0x4050
incq %rbx
cmpq %rbx, %rbp
jne 0xc2b3
movq 0x18(%rsp), %rax
movq (%rax), %rbp
testq %rbp, %rbp
je 0xc446
movl 0x10(%r14), %esi
testl %esi, %esi
jle 0xc371
xorl %ebx, %ebx
movq 0x8(%rsp), %rcx
movq (%rcx,%rbx,8), %rax
movsd (%rax), %xmm0
movsd %xmm0, (%r13,%rbx,8)
cmpl $0x2, 0x1c0(%r14)
leaq 0xc955d(%rip), %r12     # 0xd5870
jl 0xc360
xorl %esi, %esi
movq (%rcx,%rbx,8), %rax
leaq 0x1(%rsi), %r15
movsd 0x8(%rax,%rsi,8), %xmm0
movsd %xmm0, (%rsp)
movq %rbp, %rdi
callq 0x2ed6a
mulsd (%rsp), %xmm0
addsd (%r13,%rbx,8), %xmm0
movsd %xmm0, (%r13,%rbx,8)
movq (%r12), %r14
movslq 0x1c0(%r14), %rax
decq %rax
movq %r15, %rsi
cmpq %rax, %r15
movq 0x8(%rsp), %rcx
jl 0xc317
incq %rbx
movslq 0x10(%r14), %rsi
cmpq %rsi, %rbx
jl 0xc2f5
movq 0x30(%rsp), %r12
movq %r13, %rdi
callq 0x55aa4
leaq 0xc94f0(%rip), %rax     # 0xd5870
movq (%rax), %r14
movl 0x10(%r14), %r15d
testl %r15d, %r15d
jle 0xc43d
xorl %ebx, %ebx
movq %rbp, %rdi
callq 0x2f33a
movl %eax, %eax
movsd 0x9917c(%rip), %xmm1    # 0xa5520
cmpq %rax, %rbx
je 0xc3ad
xorpd %xmm1, %xmm1
subsd (%r13,%rbx,8), %xmm1
movq (%r12,%rbx,8), %rax
movsd (%rax), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movq %r12, %r13
leaq 0xc94a2(%rip), %r12     # 0xd5870
movq (%r12), %r14
cmpl $0x2, 0x1c0(%r14)
jl 0xc425
xorl %r15d, %r15d
movsd %xmm1, (%rsp)
movq %rbp, %rdi
movl %r15d, %esi
callq 0x2ed6a
movsd (%rsp), %xmm1
movq (%r13,%rbx,8), %rax
mulsd %xmm1, %xmm0
addsd 0x8(%rax,%r15,8), %xmm0
movsd %xmm0, 0x8(%rax,%r15,8)
leaq 0x1(%r15), %rax
movq (%r12), %r14
movslq 0x1c0(%r14), %rcx
decq %rcx
movq %rax, %r15
cmpq %rcx, %rax
jl 0xc3e4
incq %rbx
movslq 0x10(%r14), %r15
cmpq %r15, %rbx
movq %r13, %r12
movq 0x40(%rsp), %r13
jl 0xc392
movq 0x10(%rbp), %rbp
jmp 0xc2d9
testl %r15d, %r15d
movq 0x10(%rsp), %rbx
movsd 0x28(%rsp), %xmm1
movq 0x20(%rsp), %r9
jle 0xc4a1
movl 0x1c0(%r14), %eax
movl %r15d, %ecx
xorl %edx, %edx
testl %eax, %eax
jle 0xc499
movq (%r12,%rdx,8), %rsi
movq 0x8(%rsp), %rdi
movq (%rdi,%rdx,8), %rdi
xorl %r8d, %r8d
movsd (%rsi,%r8,8), %xmm0
mulsd %xmm1, %xmm0
addsd (%rdi,%r8,8), %xmm0
movsd %xmm0, (%rdi,%r8,8)
incq %r8
cmpq %r8, %rax
jne 0xc47b
incq %rdx
cmpq %rcx, %rdx
jne 0xc467
mulsd 0x10(%rbx), %xmm1
incl %r9d
cmpl (%rbx), %r9d
jl 0xc28a
jmp 0xc4b8
movl 0x10(%r14), %r15d
movq %r12, %rdi
movl %r15d, %esi
callq 0x3a14b
movq %r13, %rdi
callq 0x3a180
movq 0x8(%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq