// File: epfml[P]Bi-Sent2Vec/src/fasttext.cc
// Function: fasttext::FastText::bisent2vec(fasttext::Model&, float, std::vector<int, std::allocator<int>> const&)
void FastText::bisent2vec(Model& model, real lr, const std::vector<int32_t>& line){
  if (line.size() <= 1) return;
  std::vector<int32_t> context;
  std::vector<int32_t> line1;
  std::vector<int32_t> line2;
  int32_t flag = 0;
  for (int32_t i=0; i<line.size(); ++i){
    if (line[i] == dict_->getId("<<split>>")){
      flag = 1;
      continue;
    }
    if (flag==0)
      line1.push_back(line[i]);
    else
      line2.push_back(line[i]);
  }
  std::uniform_real_distribution<> uniform(0, 1);
  for (int32_t i=0; i<line1.size(); ++i){
    if (uniform(model.rng) > dict_->getPDiscard(line1[i]) || dict_->getTokenCount(line1[i]) < args_->minCountLabel)
      continue;
    context = line1;
    context[i] = 0;
    dict_->addNgrams(context, args_->wordNgrams, args_->dropoutK, model.rng);
    model.update(context, line1[i], lr);
    context = line2;
    dict_->addNgrams(context, args_->wordNgrams, args_->dropoutK, model.rng);
    model.update(context, line1[i], lr);

  }
  for (int32_t i=0; i<line2.size(); ++i){
    if (uniform(model.rng) > dict_->getPDiscard(line2[i]) || dict_->getTokenCount(line2[i]) < args_->minCountLabel)
      continue;
    context = line2;
    context[i] = 0;
    dict_->addNgrams(context, args_->wordNgrams, args_->dropoutK, model.rng);
    model.update(context, line2[i], lr);
    context = line1;
    dict_->addNgrams(context, args_->wordNgrams, args_->dropoutK, model.rng);
    model.update(context, line2[i], lr);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movss %xmm0, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x20(%rbp), %rdi
callq 0xed50
cmpq $0x1, %rax
ja 0x2b6cb
jmp 0x2bdd1
leaq -0x38(%rbp), %rdi
callq 0xe440
leaq -0x50(%rbp), %rdi
callq 0xe440
leaq -0x68(%rbp), %rdi
callq 0xe440
movl $0x0, -0x6c(%rbp)
movl $0x0, -0x70(%rbp)
movslq -0x70(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x20(%rbp), %rdi
callq 0xed50
movq %rax, %rcx
movq -0xd0(%rbp), %rax
cmpq %rcx, %rax
jae 0x2b86f
movq -0x20(%rbp), %rdi
movslq -0x70(%rbp), %rsi
callq 0xe1d0
movq -0xc8(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0xe4(%rbp)
addq $0x10, %rdi
callq 0x34050
movq %rax, -0xe0(%rbp)
leaq -0x91(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x57b0
movq -0xd8(%rbp), %rdx
leaq 0x18071(%rip), %rsi     # 0x437d9
leaq -0x90(%rbp), %rdi
callq 0x7c10
jmp 0x2b776
movq -0xe0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x8570
movl %eax, -0xe8(%rbp)
jmp 0x2b791
leaq -0x90(%rbp), %rdi
callq 0x58d8
leaq -0x91(%rbp), %rdi
callq 0x5480
movl -0xe8(%rbp), %ecx
movl -0xe4(%rbp), %eax
cmpl %ecx, %eax
jne 0x2b808
movl $0x1, -0x6c(%rbp)
jmp 0x2b861
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x2b7f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x58d8
leaq -0x91(%rbp), %rdi
callq 0x5480
jmp 0x2bdda
cmpl $0x0, -0x6c(%rbp)
jne 0x2b842
movq -0x20(%rbp), %rdi
movslq -0x70(%rbp), %rsi
callq 0xe1d0
movq %rax, %rsi
leaq -0x50(%rbp), %rdi
callq 0xe5d0
jmp 0x2b829
jmp 0x2b85f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x2bdda
movq -0x20(%rbp), %rdi
movslq -0x70(%rbp), %rsi
callq 0xe1d0
movq %rax, %rsi
leaq -0x68(%rbp), %rdi
callq 0xe5d0
jmp 0x2b85d
jmp 0x2b85f
jmp 0x2b861
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x2b6f4
leaq -0xb8(%rbp), %rdi
xorps %xmm0, %xmm0
movsd 0x17037(%rip), %xmm1    # 0x428b8
callq 0xf070
jmp 0x2b888
movl $0x0, -0xbc(%rbp)
movslq -0xbc(%rbp), %rax
movq %rax, -0xf0(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xed50
movq %rax, %rcx
movq -0xf0(%rbp), %rax
cmpq %rcx, %rax
jae 0x2bb1f
movq -0x10(%rbp), %rsi
addq $0x110, %rsi            # imm = 0x110
leaq -0xb8(%rbp), %rdi
callq 0xf170
movsd %xmm0, -0xf8(%rbp)
jmp 0x2b8dd
movq -0xc8(%rbp), %rdi
addq $0x10, %rdi
callq 0x34050
movq %rax, -0x108(%rbp)
movslq -0xbc(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0xe240
movq -0x108(%rbp), %rdi
movl (%rax), %esi
callq 0x9000
movss %xmm0, -0xfc(%rbp)
jmp 0x2b91c
movsd -0xf8(%rbp), %xmm0
movss -0xfc(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
ja 0x2b996
movq -0xc8(%rbp), %rdi
addq $0x10, %rdi
callq 0x34050
movq %rax, -0x118(%rbp)
movslq -0xbc(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0xe240
movq -0x118(%rbp), %rdi
movl (%rax), %esi
callq 0x8f70
movq %rax, -0x110(%rbp)
jmp 0x2b974
movq -0xc8(%rbp), %rdi
callq 0xe6e0
movq %rax, %rcx
movq -0x110(%rbp), %rax
movslq 0xac(%rcx), %rcx
cmpq %rcx, %rax
jge 0x2b99b
jmp 0x2bb0b
leaq -0x38(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xf490
jmp 0x2b9aa
movslq -0xbc(%rbp), %rsi
leaq -0x38(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0xe240
movq -0xc8(%rbp), %rdi
movl $0x0, (%rax)
addq $0x10, %rdi
callq 0x34050
movq -0xc8(%rbp), %rdi
movq %rax, -0x130(%rbp)
callq 0xe6e0
movq -0xc8(%rbp), %rdi
movl 0xb4(%rax), %eax
movl %eax, -0x11c(%rbp)
callq 0xe6e0
movq -0x130(%rbp), %rdi
movq -0x128(%rbp), %rsi
movl -0x11c(%rbp), %edx
movl 0x9c(%rax), %ecx
movq -0x10(%rbp), %r8
addq $0x110, %r8             # imm = 0x110
callq 0xa490
jmp 0x2ba2e
movq -0x10(%rbp), %rax
movq %rax, -0x138(%rbp)
movslq -0xbc(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0xe240
movq -0x138(%rbp), %rdi
movl (%rax), %edx
movss -0x14(%rbp), %xmm0
leaq -0x38(%rbp), %rsi
callq 0x22990
jmp 0x2ba62
leaq -0x38(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0xf490
jmp 0x2ba71
movq -0xc8(%rbp), %rdi
addq $0x10, %rdi
callq 0x34050
movq -0xc8(%rbp), %rdi
movq %rax, -0x148(%rbp)
callq 0xe6e0
movq -0xc8(%rbp), %rdi
movl 0xb4(%rax), %eax
movl %eax, -0x13c(%rbp)
callq 0xe6e0
movq -0x148(%rbp), %rdi
movl -0x13c(%rbp), %edx
movl 0x9c(%rax), %ecx
movq -0x10(%rbp), %r8
addq $0x110, %r8             # imm = 0x110
leaq -0x38(%rbp), %rsi
callq 0xa490
jmp 0x2bad5
movq -0x10(%rbp), %rax
movq %rax, -0x150(%rbp)
movslq -0xbc(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0xe240
movq -0x150(%rbp), %rdi
movl (%rax), %edx
movss -0x14(%rbp), %xmm0
leaq -0x38(%rbp), %rsi
callq 0x22990
jmp 0x2bb09
jmp 0x2bb0b
movl -0xbc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xbc(%rbp)
jmp 0x2b892
movl $0x0, -0xc0(%rbp)
movslq -0xc0(%rbp), %rax
movq %rax, -0x158(%rbp)
leaq -0x68(%rbp), %rdi
callq 0xed50
movq %rax, %rcx
movq -0x158(%rbp), %rax
cmpq %rcx, %rax
jae 0x2bdb6
movq -0x10(%rbp), %rsi
addq $0x110, %rsi            # imm = 0x110
leaq -0xb8(%rbp), %rdi
callq 0xf170
movsd %xmm0, -0x160(%rbp)
jmp 0x2bb74
movq -0xc8(%rbp), %rdi
addq $0x10, %rdi
callq 0x34050
movq %rax, -0x170(%rbp)
movslq -0xc0(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0xe240
movq -0x170(%rbp), %rdi
movl (%rax), %esi
callq 0x9000
movss %xmm0, -0x164(%rbp)
jmp 0x2bbb3
movsd -0x160(%rbp), %xmm0
movss -0x164(%rbp), %xmm1
cvtss2sd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
ja 0x2bc2d
movq -0xc8(%rbp), %rdi
addq $0x10, %rdi
callq 0x34050
movq %rax, -0x180(%rbp)
movslq -0xc0(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0xe240
movq -0x180(%rbp), %rdi
movl (%rax), %esi
callq 0x8f70
movq %rax, -0x178(%rbp)
jmp 0x2bc0b
movq -0xc8(%rbp), %rdi
callq 0xe6e0
movq %rax, %rcx
movq -0x178(%rbp), %rax
movslq 0xac(%rcx), %rcx
cmpq %rcx, %rax
jge 0x2bc32
jmp 0x2bda2
leaq -0x38(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0xf490
jmp 0x2bc41
movslq -0xc0(%rbp), %rsi
leaq -0x38(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0xe240
movq -0xc8(%rbp), %rdi
movl $0x0, (%rax)
addq $0x10, %rdi
callq 0x34050
movq -0xc8(%rbp), %rdi
movq %rax, -0x198(%rbp)
callq 0xe6e0
movq -0xc8(%rbp), %rdi
movl 0xb4(%rax), %eax
movl %eax, -0x184(%rbp)
callq 0xe6e0
movq -0x198(%rbp), %rdi
movq -0x190(%rbp), %rsi
movl -0x184(%rbp), %edx
movl 0x9c(%rax), %ecx
movq -0x10(%rbp), %r8
addq $0x110, %r8             # imm = 0x110
callq 0xa490
jmp 0x2bcc5
movq -0x10(%rbp), %rax
movq %rax, -0x1a0(%rbp)
movslq -0xc0(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0xe240
movq -0x1a0(%rbp), %rdi
movl (%rax), %edx
movss -0x14(%rbp), %xmm0
leaq -0x38(%rbp), %rsi
callq 0x22990
jmp 0x2bcf9
leaq -0x38(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xf490
jmp 0x2bd08
movq -0xc8(%rbp), %rdi
addq $0x10, %rdi
callq 0x34050
movq -0xc8(%rbp), %rdi
movq %rax, -0x1b0(%rbp)
callq 0xe6e0
movq -0xc8(%rbp), %rdi
movl 0xb4(%rax), %eax
movl %eax, -0x1a4(%rbp)
callq 0xe6e0
movq -0x1b0(%rbp), %rdi
movl -0x1a4(%rbp), %edx
movl 0x9c(%rax), %ecx
movq -0x10(%rbp), %r8
addq $0x110, %r8             # imm = 0x110
leaq -0x38(%rbp), %rsi
callq 0xa490
jmp 0x2bd6c
movq -0x10(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movslq -0xc0(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0xe240
movq -0x1b8(%rbp), %rdi
movl (%rax), %edx
movss -0x14(%rbp), %xmm0
leaq -0x38(%rbp), %rsi
callq 0x22990
jmp 0x2bda0
jmp 0x2bda2
movl -0xc0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc0(%rbp)
jmp 0x2bb29
leaq -0x68(%rbp), %rdi
callq 0xe530
leaq -0x50(%rbp), %rdi
callq 0xe530
leaq -0x38(%rbp), %rdi
callq 0xe530
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
leaq -0x68(%rbp), %rdi
callq 0xe530
leaq -0x50(%rbp), %rdi
callq 0xe530
leaq -0x38(%rbp), %rdi
callq 0xe530
movq -0xa0(%rbp), %rdi
callq 0x57a0
nopw %cs:(%rax,%rax)