// File: /workspace/github_c_makefile_star2_O0/olcaytaner[P]Isell/softtree.c
// Function: gradient_descent_soft_tree_K_class
void gradient_descent_soft_tree_K_class(Decisionnodeptr rootnode, Decisionnodeptr node, Softregtree_parameterptr param, double eta)
{
 int i, j, k, t, r, *array, datasize;
 double sum, multiplier, delta, feature_value, *output, *previous_update_left, *previous_update_right, *previous_update;
 Instanceptr inst;
 Decisionnodeptr tmpnode;
 datasize = data_size(rootnode->instances);
 node->w = random_matrix(current_dataset->multifeaturecount, 1, -0.01, +0.01);
 node->left->w0s = random_array_double(current_dataset->classno, -0.01, +0.01);
 node->right->w0s = random_array_double(current_dataset->classno, -0.01, +0.01);
 previous_update = safecalloc(current_dataset->multifeaturecount, sizeof(double), "gradient_descent_soft_tree_K_class", 9);
 previous_update_left = safecalloc(current_dataset->classno, sizeof(double), "gradient_descent_soft_tree_K_class", 9);
 previous_update_right = safecalloc(current_dataset->classno, sizeof(double), "gradient_descent_soft_tree_K_class", 9);
 for (i = 0; i < param->epochs; i++)
  {
   array = random_array(datasize);
   for (j = 0; j < datasize; j++)
    {
     inst = data_x(rootnode->instances, array[j]);
     output = soft_tree_output_K_class(rootnode, inst);
     softmax(output, current_dataset->classno);
     r = give_classno(inst);
     multiplier = eta;
     tmpnode = node;
     while (tmpnode->parent)
      {
       multiplier *= tmpnode->weight;
       tmpnode = tmpnode->parent;
      }
     for (k = 0; k < current_dataset->classno; k++)
      {      
       node->left->w0s[k] += multiplier * (kronecker_delta(r, k) - output[k]) * node->left->weight + param->alpha * previous_update_left[k];
       previous_update_left[k] = multiplier * (kronecker_delta(r, k) - output[k]) * node->left->weight;
       node->right->w0s[k] += multiplier * (kronecker_delta(r, k) - output[k]) * node->right->weight + param->alpha * previous_update_right[k];
       previous_update_right[k] = multiplier * (kronecker_delta(r, k) - output[k]) * node->right->weight;
      }
     for (t = 0; t < current_dataset->multifeaturecount; t++)
      {
       if (t != 0)
         feature_value = real_feature(inst, t - 1);
       else
         feature_value = 1;
       sum = 0;
       for (k = 0; k < current_dataset->classno; k++)
        {
         delta = multiplier * (kronecker_delta(r, k) - output[k]) * feature_value * (node->left->outputs[k] - node->right->outputs[k]) * node->left->weight * node->right->weight;
         sum += delta;
        }
       node->w.values[t][0] += sum + param->alpha * previous_update[t];
       previous_update[t] = sum;
     }
    }
   safe_free(array);
   eta = eta * param->etadecrease;
  }
 safe_free(previous_update_left);
 safe_free(previous_update_right);
 safe_free(previous_update);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movsd %xmm0, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x449f0
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xb0(%rbp)
leaq 0x46882(%rip), %rax     # 0x105840
movq (%rax), %rax
movl 0x1c0(%rax), %edi
movl $0x1, %esi
movsd 0x23a84(%rip), %xmm0    # 0xe2a58
movsd 0x23044(%rip), %xmm1    # 0xe2020
callq 0x5a130
movq %rax, %rcx
movq -0xb0(%rbp), %rax
movq %rcx, -0xa8(%rbp)
movq %rdx, -0xa0(%rbp)
movq -0xa8(%rbp), %rcx
movq %rcx, 0x38(%rax)
movq -0xa0(%rbp), %rcx
movq %rcx, 0x40(%rax)
leaq 0x4682a(%rip), %rax     # 0x105840
movq (%rax), %rax
movl 0x10(%rax), %edi
movsd 0x23a34(%rip), %xmm0    # 0xe2a58
movsd 0x22ff4(%rip), %xmm1    # 0xe2020
callq 0x546c0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x50(%rax)
leaq 0x467fa(%rip), %rax     # 0x105840
movq (%rax), %rax
movl 0x10(%rax), %edi
movsd 0x23a04(%rip), %xmm0    # 0xe2a58
movsd 0x22fc4(%rip), %xmm1    # 0xe2020
callq 0x546c0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x50(%rax)
leaq 0x467c9(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x1c0(%rax), %rdi
movl $0x8, %esi
leaq 0x2e9e6(%rip), %rdx     # 0xeda73
movl $0x9, %ecx
callq 0x52f40
movq %rax, -0x88(%rbp)
leaq 0x4679b(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x10(%rax), %rdi
movl $0x8, %esi
leaq 0x2e9bb(%rip), %rdx     # 0xeda73
movl $0x9, %ecx
callq 0x52f40
movq %rax, -0x78(%rbp)
leaq 0x46773(%rip), %rax     # 0x105840
movq (%rax), %rax
movslq 0x10(%rax), %rdi
movl $0x8, %esi
leaq 0x2e993(%rip), %rdx     # 0xeda73
movl $0x9, %ecx
callq 0x52f40
movq %rax, -0x80(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0xbf531
movl -0x44(%rbp), %edi
callq 0x54600
movq %rax, -0x40(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0xbf507
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x40(%rbp), %rax
movslq -0x28(%rbp), %rcx
movl (%rax,%rcx,4), %esi
callq 0x46c40
movq %rax, -0x90(%rbp)
movq -0x8(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0xbebf0
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
leaq 0x466de(%rip), %rax     # 0x105840
movq (%rax), %rax
movl 0x10(%rax), %esi
callq 0x7ab00
movq -0x90(%rbp), %rdi
callq 0x43530
movl %eax, -0x34(%rbp)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0xbf1c9
movq -0x98(%rbp), %rax
movsd 0x78(%rax), %xmm0
mulsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movq -0x98(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x98(%rbp)
jmp 0xbf191
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
leaq 0x46666(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x10(%rcx), %eax
jge 0xbf383
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0xd0(%rbp)
movl -0x34(%rbp), %edi
movl -0x2c(%rbp), %esi
callq 0x532b0
movsd -0xd0(%rbp), %xmm0
cvtsi2sd %eax, %xmm1
movq -0x70(%rbp), %rax
movslq -0x2c(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm1
mulsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsd 0x78(%rax), %xmm2
movq -0x18(%rbp), %rax
movsd 0x18(%rax), %xmm1
movq -0x78(%rbp), %rax
movslq -0x2c(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x50(%rax), %rax
movslq -0x2c(%rbp), %rcx
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0xc8(%rbp)
movl -0x34(%rbp), %edi
movl -0x2c(%rbp), %esi
callq 0x532b0
movsd -0xc8(%rbp), %xmm0
cvtsi2sd %eax, %xmm1
movq -0x70(%rbp), %rax
movslq -0x2c(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm1
mulsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq (%rax), %rax
mulsd 0x78(%rax), %xmm0
movq -0x78(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0xc0(%rbp)
movl -0x34(%rbp), %edi
movl -0x2c(%rbp), %esi
callq 0x532b0
movsd -0xc0(%rbp), %xmm0
cvtsi2sd %eax, %xmm1
movq -0x70(%rbp), %rax
movslq -0x2c(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm1
mulsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movsd 0x78(%rax), %xmm2
movq -0x18(%rbp), %rax
movsd 0x18(%rax), %xmm1
movq -0x80(%rbp), %rax
movslq -0x2c(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x50(%rax), %rax
movslq -0x2c(%rbp), %rcx
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0xb8(%rbp)
movl -0x34(%rbp), %edi
movl -0x2c(%rbp), %esi
callq 0x532b0
movsd -0xb8(%rbp), %xmm0
cvtsi2sd %eax, %xmm1
movq -0x70(%rbp), %rax
movslq -0x2c(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm1
mulsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
mulsd 0x78(%rax), %xmm0
movq -0x80(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xbf1d0
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
leaq 0x464ac(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x1c0(%rcx), %eax
jge 0xbf4f7
cmpl $0x0, -0x30(%rbp)
je 0xbf3c2
movq -0x90(%rbp), %rdi
movl -0x30(%rbp), %esi
subl $0x1, %esi
callq 0x42c40
movsd %xmm0, -0x68(%rbp)
jmp 0xbf3cf
movsd 0x22c4e(%rip), %xmm0    # 0xe2018
movsd %xmm0, -0x68(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
leaq 0x46458(%rip), %rcx     # 0x105840
movq (%rcx), %rcx
cmpl 0x10(%rcx), %eax
jge 0xbf496
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0xd8(%rbp)
movl -0x34(%rbp), %edi
movl -0x2c(%rbp), %esi
callq 0x532b0
movsd -0xd8(%rbp), %xmm0
cvtsi2sd %eax, %xmm1
movq -0x70(%rbp), %rax
movslq -0x2c(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm1
mulsd %xmm1, %xmm0
mulsd -0x68(%rbp), %xmm0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x70(%rax), %rax
movslq -0x2c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x70(%rax), %rax
movslq -0x2c(%rbp), %rcx
subsd (%rax,%rcx,8), %xmm1
mulsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq (%rax), %rax
mulsd 0x78(%rax), %xmm0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
mulsd 0x78(%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x60(%rbp), %xmm0
addsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xbf3de
movsd -0x50(%rbp), %xmm1
movq -0x18(%rbp), %rax
movsd 0x18(%rax), %xmm0
movq -0x88(%rbp), %rax
movslq -0x30(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movslq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movsd -0x50(%rbp), %xmm0
movq -0x88(%rbp), %rax
movslq -0x30(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xbf38a
jmp 0xbf4f9
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xbf118
movq -0x40(%rbp), %rdi
callq 0x52e80
movsd -0x20(%rbp), %xmm0
movq -0x18(%rbp), %rax
mulsd 0x10(%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xbf0f5
movq -0x78(%rbp), %rdi
callq 0x52e80
movq -0x80(%rbp), %rdi
callq 0x52e80
movq -0x88(%rbp), %rdi
callq 0x52e80
addq $0xe0, %rsp
popq %rbp
retq
nopl (%rax,%rax)