// File: epfml[P]Bi-Sent2Vec/src/fasttext.cc
// Function: fasttext::FastText::transgram(fasttext::Model&, float, std::vector<int, std::allocator<int>> const&)
void FastText::transgram(Model& model, real lr,
                        const std::vector<int32_t>& line) {
  if (line.size() <= 1) return;
  std::uniform_int_distribution<> uniform(1, args_->ws);
  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]);
  }
  for (int32_t w = 0; w < line1.size(); w++) {
    int32_t boundary = uniform(model.rng);
    std::vector<int32_t> word;
    word.push_back(line1[w]);
    for (int32_t c = -boundary; c <= boundary; c++) {
      if (c != 0 && w + c >= 0 && w + c < line1.size()) {
        model.update(word, line1[w + c], lr);
      }
    }
    for (int32_t i=0; i<line2.size(); ++i){
        model.update(word, line2[i], lr);
    }
  }
  for (int32_t w = 0; w < line2.size(); w++) {
    int32_t boundary = uniform(model.rng);
    std::vector<int32_t> word;
    word.push_back(line2[w]);
    for (int32_t c = -boundary; c <= boundary; c++) {
      if (c != 0 && w + c >= 0 && w + c < line2.size()) {
        model.update(word, line2[w + c], lr);
      }
    }
    for (int32_t i=0; i<line1.size(); ++i){
        model.update(word, line1[i], lr);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movss %xmm0, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x20(%rbp), %rdi
callq 0xed50
cmpq $0x1, %rax
ja 0x2ae2b
jmp 0x2b416
movq -0xf0(%rbp), %rdi
callq 0xe6e0
movl 0x98(%rax), %edx
leaq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0xef10
leaq -0x40(%rbp), %rdi
callq 0xe440
leaq -0x58(%rbp), %rdi
callq 0xe440
movl $0x0, -0x5c(%rbp)
movl $0x0, -0x60(%rbp)
movslq -0x60(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x20(%rbp), %rdi
callq 0xed50
movq %rax, %rcx
movq -0xf8(%rbp), %rax
cmpq %rcx, %rax
jae 0x2afda
movq -0x20(%rbp), %rdi
movslq -0x60(%rbp), %rsi
callq 0xe1d0
movq -0xf0(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x10c(%rbp)
addq $0x10, %rdi
callq 0x34050
movq %rax, -0x108(%rbp)
leaq -0x81(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x57b0
movq -0x100(%rbp), %rdx
leaq 0x188fa(%rip), %rsi     # 0x437d9
leaq -0x80(%rbp), %rdi
callq 0x7c10
jmp 0x2aeea
movq -0x108(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x8570
movl %eax, -0x110(%rbp)
jmp 0x2af02
leaq -0x80(%rbp), %rdi
callq 0x58d8
leaq -0x81(%rbp), %rdi
callq 0x5480
movl -0x110(%rbp), %ecx
movl -0x10c(%rbp), %eax
cmpl %ecx, %eax
jne 0x2af73
movl $0x1, -0x5c(%rbp)
jmp 0x2afcc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x2af62
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x58d8
leaq -0x81(%rbp), %rdi
callq 0x5480
jmp 0x2b41f
cmpl $0x0, -0x5c(%rbp)
jne 0x2afad
movq -0x20(%rbp), %rdi
movslq -0x60(%rbp), %rsi
callq 0xe1d0
movq %rax, %rsi
leaq -0x40(%rbp), %rdi
callq 0xe5d0
jmp 0x2af94
jmp 0x2afca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x2b41f
movq -0x20(%rbp), %rdi
movslq -0x60(%rbp), %rsi
callq 0xe1d0
movq %rax, %rsi
leaq -0x58(%rbp), %rdi
callq 0xe5d0
jmp 0x2afc8
jmp 0x2afca
jmp 0x2afcc
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x2ae6b
movl $0x0, -0x98(%rbp)
movslq -0x98(%rbp), %rax
movq %rax, -0x118(%rbp)
leaq -0x40(%rbp), %rdi
callq 0xed50
movq %rax, %rcx
movq -0x118(%rbp), %rax
cmpq %rcx, %rax
jae 0x2b1ef
movq -0x10(%rbp), %rsi
addq $0x110, %rsi            # imm = 0x110
leaq -0x28(%rbp), %rdi
callq 0xef40
movl %eax, -0x11c(%rbp)
jmp 0x2b02a
movl -0x11c(%rbp), %eax
movl %eax, -0x9c(%rbp)
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0xe440
movslq -0x98(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0xe240
movq -0x128(%rbp), %rdi
movq %rax, %rsi
callq 0xe5d0
jmp 0x2b06a
xorl %eax, %eax
subl -0x9c(%rbp), %eax
movl %eax, -0xbc(%rbp)
movl -0xbc(%rbp), %eax
cmpl -0x9c(%rbp), %eax
jg 0x2b155
cmpl $0x0, -0xbc(%rbp)
je 0x2b13f
movl -0x98(%rbp), %eax
addl -0xbc(%rbp), %eax
cmpl $0x0, %eax
jl 0x2b13f
movl -0x98(%rbp), %eax
addl -0xbc(%rbp), %eax
cltq
movq %rax, -0x130(%rbp)
leaq -0x40(%rbp), %rdi
callq 0xed50
movq %rax, %rcx
movq -0x130(%rbp), %rax
cmpq %rcx, %rax
jae 0x2b13f
movq -0x10(%rbp), %rax
movq %rax, -0x138(%rbp)
movl -0x98(%rbp), %eax
movl -0xbc(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
leaq -0x40(%rbp), %rdi
callq 0xe240
movq -0x138(%rbp), %rdi
movl (%rax), %edx
movss -0x14(%rbp), %xmm0
leaq -0xb8(%rbp), %rsi
callq 0x22990
jmp 0x2b11a
jmp 0x2b13f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0xe530
jmp 0x2b41f
jmp 0x2b141
movl -0xbc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xbc(%rbp)
jmp 0x2b078
movl $0x0, -0xc0(%rbp)
movslq -0xc0(%rbp), %rax
movq %rax, -0x140(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xed50
movq %rax, %rcx
movq -0x140(%rbp), %rax
cmpq %rcx, %rax
jae 0x2b1cf
movq -0x10(%rbp), %rax
movq %rax, -0x148(%rbp)
movslq -0xc0(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0xe240
movq -0x148(%rbp), %rdi
movl (%rax), %edx
movss -0x14(%rbp), %xmm0
leaq -0xb8(%rbp), %rsi
callq 0x22990
jmp 0x2b1bc
jmp 0x2b1be
movl -0xc0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc0(%rbp)
jmp 0x2b15f
leaq -0xb8(%rbp), %rdi
callq 0xe530
movl -0x98(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x98(%rbp)
jmp 0x2afe4
movl $0x0, -0xc4(%rbp)
movslq -0xc4(%rbp), %rax
movq %rax, -0x150(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xed50
movq %rax, %rcx
movq -0x150(%rbp), %rax
cmpq %rcx, %rax
jae 0x2b404
movq -0x10(%rbp), %rsi
addq $0x110, %rsi            # imm = 0x110
leaq -0x28(%rbp), %rdi
callq 0xef40
movl %eax, -0x154(%rbp)
jmp 0x2b23f
movl -0x154(%rbp), %eax
movl %eax, -0xc8(%rbp)
leaq -0xe0(%rbp), %rdi
movq %rdi, -0x160(%rbp)
callq 0xe440
movslq -0xc4(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0xe240
movq -0x160(%rbp), %rdi
movq %rax, %rsi
callq 0xe5d0
jmp 0x2b27f
xorl %eax, %eax
subl -0xc8(%rbp), %eax
movl %eax, -0xe4(%rbp)
movl -0xe4(%rbp), %eax
cmpl -0xc8(%rbp), %eax
jg 0x2b36a
cmpl $0x0, -0xe4(%rbp)
je 0x2b354
movl -0xc4(%rbp), %eax
addl -0xe4(%rbp), %eax
cmpl $0x0, %eax
jl 0x2b354
movl -0xc4(%rbp), %eax
addl -0xe4(%rbp), %eax
cltq
movq %rax, -0x168(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xed50
movq %rax, %rcx
movq -0x168(%rbp), %rax
cmpq %rcx, %rax
jae 0x2b354
movq -0x10(%rbp), %rax
movq %rax, -0x170(%rbp)
movl -0xc4(%rbp), %eax
movl -0xe4(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
leaq -0x58(%rbp), %rdi
callq 0xe240
movq -0x170(%rbp), %rdi
movl (%rax), %edx
movss -0x14(%rbp), %xmm0
leaq -0xe0(%rbp), %rsi
callq 0x22990
jmp 0x2b32f
jmp 0x2b354
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0xe530
jmp 0x2b41f
jmp 0x2b356
movl -0xe4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe4(%rbp)
jmp 0x2b28d
movl $0x0, -0xe8(%rbp)
movslq -0xe8(%rbp), %rax
movq %rax, -0x178(%rbp)
leaq -0x40(%rbp), %rdi
callq 0xed50
movq %rax, %rcx
movq -0x178(%rbp), %rax
cmpq %rcx, %rax
jae 0x2b3e4
movq -0x10(%rbp), %rax
movq %rax, -0x180(%rbp)
movslq -0xe8(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0xe240
movq -0x180(%rbp), %rdi
movl (%rax), %edx
movss -0x14(%rbp), %xmm0
leaq -0xe0(%rbp), %rsi
callq 0x22990
jmp 0x2b3d1
jmp 0x2b3d3
movl -0xe8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe8(%rbp)
jmp 0x2b374
leaq -0xe0(%rbp), %rdi
callq 0xe530
movl -0xc4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
jmp 0x2b1f9
leaq -0x58(%rbp), %rdi
callq 0xe530
leaq -0x40(%rbp), %rdi
callq 0xe530
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
leaq -0x58(%rbp), %rdi
callq 0xe530
leaq -0x40(%rbp), %rdi
callq 0xe530
movq -0x90(%rbp), %rdi
callq 0x57a0
nopl (%rax)