// File: epfml[P]Bi-Sent2Vec/src/model.cc
// Function: fasttext::Model::update(std::vector<int, std::allocator<int>> const&, int, float, float, int, int)
void Model::update(const std::vector<int32_t>& input, int32_t target, real lr, real boostNgrams, int32_t lowIdx, int32_t hiIdx) {
  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::sup || args_->model == model_name::bisent2vec) {
  //  grad_.mul(1.0 / input.size());
  //}
  for (auto it = input.cbegin(); it != input.cend(); ++it) {
    if (*it > lowIdx && *it < hiIdx) {
      wi_->addRow(grad_, *it, boostNgrams);
    } else {
      wi_->addRow(grad_, *it, 1.0);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movss %xmm0, -0x18(%rbp)
movss %xmm1, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpl $0x0, -0x14(%rbp)
jl 0x22c04
jmp 0x22c23
leaq 0x20920(%rip), %rdi     # 0x4352b
leaq 0x2082c(%rip), %rsi     # 0x4343e
movl $0xe2, %edx
leaq 0x20971(%rip), %rcx     # 0x4358f
callq 0x52d0
movq -0x40(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x88(%rcx), %eax
jge 0x22c34
jmp 0x22c53
leaq 0x20946(%rip), %rdi     # 0x43581
leaq 0x207fc(%rip), %rsi     # 0x4343e
movl $0xe3, %edx
leaq 0x20941(%rip), %rcx     # 0x4358f
callq 0x52d0
movq -0x10(%rbp), %rdi
callq 0xed50
cmpq $0x0, %rax
jne 0x22c67
jmp 0x22e0b
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq %rdi, %rdx
addq $0x50, %rdx
callq 0x22280
movq -0x40(%rbp), %rdi
addq $0x40, %rdi
callq 0xe6e0
cmpl $0x2, 0xbc(%rax)
jne 0x22cb8
movq -0x40(%rbp), %rdi
movl -0x14(%rbp), %esi
movss -0x18(%rbp), %xmm0
callq 0x21d20
movq -0x40(%rbp), %rax
addss 0x8c(%rax), %xmm0
movss %xmm0, 0x8c(%rax)
jmp 0x22d1c
movq -0x40(%rbp), %rdi
addq $0x40, %rdi
callq 0xe6e0
cmpl $0x1, 0xbc(%rax)
jne 0x22cf5
movq -0x40(%rbp), %rdi
movl -0x14(%rbp), %esi
movss -0x18(%rbp), %xmm0
callq 0x21e60
movq -0x40(%rbp), %rax
addss 0x8c(%rax), %xmm0
movss %xmm0, 0x8c(%rax)
jmp 0x22d1a
movq -0x40(%rbp), %rdi
movl -0x14(%rbp), %esi
movss -0x18(%rbp), %xmm0
callq 0x22130
movq -0x40(%rbp), %rax
addss 0x8c(%rax), %xmm0
movss %xmm0, 0x8c(%rax)
jmp 0x22d1c
movq -0x40(%rbp), %rax
movq 0x90(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x90(%rax)
movq -0x10(%rbp), %rdi
callq 0xf370
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0xf3e0
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0xf3a0
testb $0x1, %al
jne 0x22d62
jmp 0x22e0b
leaq -0x30(%rbp), %rdi
callq 0xf410
movl (%rax), %eax
cmpl -0x20(%rbp), %eax
jle 0x22dbe
leaq -0x30(%rbp), %rdi
callq 0xf410
movl (%rax), %eax
cmpl -0x24(%rbp), %eax
jge 0x22dbe
movq -0x40(%rbp), %rdi
callq 0x235f0
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, -0x50(%rbp)
addq $0x70, %rax
movq %rax, -0x48(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xf410
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movslq (%rax), %rdx
movss -0x1c(%rbp), %xmm0
callq 0x1e1f0
jmp 0x22dfb
movq -0x40(%rbp), %rdi
callq 0x235f0
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, -0x60(%rbp)
addq $0x70, %rax
movq %rax, -0x58(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xf410
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
movslq (%rax), %rdx
movss 0x1fad2(%rip), %xmm0    # 0x428c8
callq 0x1e1f0
jmp 0x22dfd
leaq -0x30(%rbp), %rdi
callq 0xf430
jmp 0x22d3f
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)