// File: epfml[P]Bi-Sent2Vec/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_);
  if (args_->loss == loss_name::ns) {
    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::bisent2vec) {
    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 0x229b8
jmp 0x229d7
leaq 0x20b6c(%rip), %rdi     # 0x4352b
leaq 0x20a78(%rip), %rsi     # 0x4343e
movl $0xcc, %edx
leaq 0x20b65(%rip), %rcx     # 0x43537
callq 0x52d0
movq -0x30(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x88(%rcx), %eax
jge 0x229e8
jmp 0x22a07
leaq 0x20b92(%rip), %rdi     # 0x43581
leaq 0x20a48(%rip), %rsi     # 0x4343e
movl $0xcd, %edx
leaq 0x20b35(%rip), %rcx     # 0x43537
callq 0x52d0
movq -0x10(%rbp), %rdi
callq 0xed50
cmpq $0x0, %rax
jne 0x22a1b
jmp 0x22bc2
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq %rdi, %rdx
addq $0x50, %rdx
callq 0x22280
movq -0x30(%rbp), %rdi
addq $0x40, %rdi
callq 0xe6e0
cmpl $0x2, 0xbc(%rax)
jne 0x22a6c
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %esi
movss -0x18(%rbp), %xmm0
callq 0x21d20
movq -0x30(%rbp), %rax
addss 0x8c(%rax), %xmm0
movss %xmm0, 0x8c(%rax)
jmp 0x22ad0
movq -0x30(%rbp), %rdi
addq $0x40, %rdi
callq 0xe6e0
cmpl $0x1, 0xbc(%rax)
jne 0x22aa9
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %esi
movss -0x18(%rbp), %xmm0
callq 0x21e60
movq -0x30(%rbp), %rax
addss 0x8c(%rax), %xmm0
movss %xmm0, 0x8c(%rax)
jmp 0x22ace
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %esi
movss -0x18(%rbp), %xmm0
callq 0x22130
movq -0x30(%rbp), %rax
addss 0x8c(%rax), %xmm0
movss %xmm0, 0x8c(%rax)
jmp 0x22ad0
movq -0x30(%rbp), %rdi
movq 0x90(%rdi), %rax
addq $0x1, %rax
movq %rax, 0x90(%rdi)
addq $0x40, %rdi
callq 0xe6e0
cmpl $0x4, 0xc0(%rax)
jne 0x22b4d
movq -0x30(%rbp), %rax
addq $0x70, %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
callq 0xed50
movq -0x38(%rbp), %rdi
movq %rax, %xmm1
movaps 0x1fdd3(%rip), %xmm0    # 0x428f0
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movapd 0x1fdd7(%rip), %xmm0    # 0x42900
subpd %xmm0, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movsd 0x1fd78(%rip), %xmm0    # 0x428b8
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x20d80
movq -0x10(%rbp), %rdi
callq 0xf370
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0xf3e0
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0xf3a0
testb $0x1, %al
jne 0x22b7a
jmp 0x22bc2
movq -0x30(%rbp), %rdi
callq 0x235f0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, -0x48(%rbp)
addq $0x70, %rax
movq %rax, -0x40(%rbp)
leaq -0x20(%rbp), %rdi
callq 0xf410
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
movslq (%rax), %rdx
movss 0x1fd16(%rip), %xmm0    # 0x428c8
callq 0x1e1f0
leaq -0x20(%rbp), %rdi
callq 0xf430
jmp 0x22b5a
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)