// File: ddu1[P]polarizedtext/src/model.cc
// Function: fasttext::Model::update(std::vector<int, std::allocator<int>> const&, int, float)
void Model::update(const std::vector<int32_t>& input, int32_t target, real lr) {
  assert(target >= 0);
  assert(target < osz_);
  if (input.size() == 0) return;
  computeHidden(input, hidden_);

  // update negative sampling for both ns and polar
  if (args_->loss == loss_name::ns || args_->loss == loss_name::polar) {
    loss_ += negativeSampling(target, lr);
  } else if (args_->loss == loss_name::hs) {
    loss_ += hierarchicalSoftmax(target, lr);
  } else {
    loss_ += softmax(target, lr);
  }
  nexamples_ += 1;

  if (args_->model == model_name::sup) {
    grad_.mul(1.0 / input.size());
  }
  for (auto it = input.cbegin(); it != input.cend(); ++it) {
    wi_->addRow(grad_, *it, 1.0);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movss %xmm0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpl $0x0, -0x14(%rbp)
jl 0x14d58
jmp 0x14d77
leaq 0x14e5c(%rip), %rdi     # 0x29bbb
leaq 0x14d68(%rip), %rsi     # 0x29ace
movl $0xc4, %edx
leaq 0x14e55(%rip), %rcx     # 0x29bc7
callq 0x41d0
movq -0x30(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x80(%rcx), %eax
jge 0x14d88
jmp 0x14da7
leaq 0x14e82(%rip), %rdi     # 0x29c11
leaq 0x14d38(%rip), %rsi     # 0x29ace
movl $0xc5, %edx
leaq 0x14e25(%rip), %rcx     # 0x29bc7
callq 0x41d0
movq -0x10(%rbp), %rdi
callq 0xad50
cmpq $0x0, %rax
jne 0x14dbb
jmp 0x14f78
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq %rdi, %rdx
addq $0x30, %rdx
callq 0x146d0
movq -0x30(%rbp), %rdi
addq $0x20, %rdi
callq 0xa170
cmpl $0x2, 0x88(%rax)
je 0x14dfb
movq -0x30(%rbp), %rdi
addq $0x20, %rdi
callq 0xa170
cmpl $0x4, 0x88(%rax)
jne 0x14e22
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %esi
movss -0x18(%rbp), %xmm0
callq 0x141c0
movq -0x30(%rbp), %rax
addss 0x84(%rax), %xmm0
movss %xmm0, 0x84(%rax)
jmp 0x14e86
movq -0x30(%rbp), %rdi
addq $0x20, %rdi
callq 0xa170
cmpl $0x1, 0x88(%rax)
jne 0x14e5f
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %esi
movss -0x18(%rbp), %xmm0
callq 0x14300
movq -0x30(%rbp), %rax
addss 0x84(%rax), %xmm0
movss %xmm0, 0x84(%rax)
jmp 0x14e84
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %esi
movss -0x18(%rbp), %xmm0
callq 0x14580
movq -0x30(%rbp), %rax
addss 0x84(%rax), %xmm0
movss %xmm0, 0x84(%rax)
jmp 0x14e86
movq -0x30(%rbp), %rdi
movq 0x88(%rdi), %rax
addq $0x1, %rax
movq %rax, 0x88(%rdi)
addq $0x20, %rdi
callq 0xa170
cmpl $0x3, 0x8c(%rax)
jne 0x14f03
movq -0x30(%rbp), %rax
addq $0x68, %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
callq 0xad50
movq -0x38(%rbp), %rdi
movq %rax, %xmm1
movaps 0x1472d(%rip), %xmm0    # 0x29600
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movapd 0x14731(%rip), %xmm0    # 0x29610
subpd %xmm0, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movsd 0x146d2(%rip), %xmm0    # 0x295c8
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x13270
movq -0x10(%rbp), %rdi
callq 0x15b10
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x15b40
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x13840
testb $0x1, %al
jne 0x14f30
jmp 0x14f78
movq -0x30(%rbp), %rdi
callq 0x15820
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, -0x48(%rbp)
addq $0x68, %rax
movq %rax, -0x40(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x13880
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
movslq (%rax), %rdx
movss 0x149f0(%rip), %xmm0    # 0x29958
callq 0x12ba0
leaq -0x20(%rbp), %rdi
callq 0x138a0
jmp 0x14f10
addq $0x50, %rsp
popq %rbp
retq
nop