// File: /workspace/github_cpp_makefile_star2_O3/fei3189[P]PLSI/./plsi.hpp
// Function: PLSI::_train(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&, int, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&)
void _train(const vector<string> &docs, int z_k, const vector<string> &w_stop) {
        float eps = 0.01;
        float last = 0, current = -1000;
        int iter_num = 0;
        vector<float> p_zwd(z_k, 0);

        _preprocess(docs, z_k, w_stop);
        clock_t t = clock();
        while (fabs(current - last) > eps) {
            ++iter_num;
            vector<vector<float> > p_wz_current = p_wz;
            vector<vector<float> > p_dz_current = p_dz;
            vector<float> p_z_current = p_z;
            for (int i = 0; i < c_doc; ++i)
                for (int k = 0; k < z_k; ++k)
                    p_dz[i][k] = 0;
            for (int i = 0; i < c_word; ++i)
                for (int k = 0; k < z_k; ++k)
                    p_wz[i][k] = 0;
            for (int k = 0; k < z_k; ++k)
                p_z[k] = 0;
            for (int i = 0; i < c_doc; ++i) {
                for (int _j = 0; _j < n_wd[i].size(); ++_j) {
                    Index adj = n_wd[i][_j];
                    int j = adj.idx;
                    int v = adj.value;
                    float sum_zwd = 0;
                    for (int k = 0; k < z_k; ++k) {
                        float tmp = p_wz_current[j][k] * p_dz_current[i][k] * p_z_current[k];
                        p_zwd[k] = tmp;
                        sum_zwd += tmp;
                    }
                    for (int k = 0; k < z_k; ++k)
                        p_zwd[k] /= sum_zwd;
                    for (int k = 0; k < z_k; ++k) {
                        p_wz[j][k] += v * p_zwd[k];
                        p_dz[i][k] += v * p_zwd[k];
                        p_z[k] += v * p_zwd[k];
                    }
                }
            }

            float sum_z = 0;
            for (int k = 0; k < z_k; ++k) {
                float sum_w = 0, sum_d = 0;
                for (int i = 0; i < c_word; ++i)
                    sum_w += p_wz[i][k];
                for (int i = 0; i < c_word; ++i)
                    p_wz[i][k] /= sum_w;
                
                for (int i = 0; i < c_doc; ++i)
                    sum_d += p_dz[i][k];
                for (int i = 0; i < c_doc; ++i)
                    p_dz[i][k] /= sum_d;
                sum_z += p_z[k];
            }
            for (int k = 0; k < z_k; ++k)
                p_z[k] /= _all_words;

            last = current;
            current = _likelihood();
        }
        cout << "Train finished. " << endl;
        cout << "Likelihood = " << current << endl;
        cout << "eps = " << eps << ", iteration times = " << iter_num << endl;
        cout << "Time spent " << 1.0 * (clock() - t) / CLOCKS_PER_SEC << "s" << endl;
        cout << "Number of topics = " << z_k << endl;
        cout << endl;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rcx, %r14
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r12
movslq %edx, %r13
leaq 0xb0(%rsp), %rdx
movl $0x0, (%rdx)
leaq 0x80(%rsp), %rdi
leaq 0x98(%rsp), %rcx
movq %r13, %rsi
callq 0x32f0
movq %r12, %rdi
movq %r15, %rsi
movl %r13d, %edx
movq %r14, %rcx
callq 0x347a
callq 0x2120
movq %rax, 0x48(%rsp)
leaq 0x18(%r12), %rax
movq %rax, 0x30(%rsp)
leaq 0x30(%r12), %rax
movq %rax, 0x28(%rsp)
movl %ebx, %r13d
leaq (,%r13,4), %rax
movq %rax, 0x20(%rsp)
xorl %ebp, %ebp
movss 0x33d8(%rip), %xmm0     # 0x6004
movss %xmm0, 0xc(%rsp)
leaq 0xb0(%rsp), %r15
movq %r12, (%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x37e2
leaq 0x98(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x37e2
leaq 0x68(%rsp), %rdi
movq 0x28(%rsp), %rsi
callq 0x387c
movl 0x64(%r12), %ecx
movq %rcx, 0x18(%rsp)
testl %ecx, %ecx
jle 0x2cb1
movq 0x30(%rsp), %rax
movq (%rax), %r14
movq 0x18(%rsp), %rax
leaq (,%rax,8), %rax
leaq (%rax,%rax,2), %r15
xorl %r12d, %r12d
testl %ebx, %ebx
jle 0x2ca8
movq (%r14,%r12), %rdi
xorl %esi, %esi
movq 0x20(%rsp), %rdx
callq 0x2100
addq $0x18, %r12
cmpq %r12, %r15
jne 0x2c94
movq (%rsp), %rax
movl 0x60(%rax), %ecx
movq %rcx, 0x38(%rsp)
testl %ecx, %ecx
jle 0x2cf9
movq (%rsp), %rax
movq (%rax), %r14
movq 0x38(%rsp), %rax
leaq (,%rax,8), %rax
leaq (%rax,%rax,2), %r15
xorl %r12d, %r12d
testl %ebx, %ebx
jle 0x2cf0
movq (%r14,%r12), %rdi
xorl %esi, %esi
movq 0x20(%rsp), %rdx
callq 0x2100
addq $0x18, %r12
cmpq %r12, %r15
jne 0x2cdc
movq %rbp, 0x50(%rsp)
testl %ebx, %ebx
jle 0x2d16
movq 0x28(%rsp), %rax
movq (%rax), %rdi
xorl %esi, %esi
movq 0x20(%rsp), %rdx
callq 0x2100
movq 0x18(%rsp), %r10
testl %r10d, %r10d
jle 0x2eb1
movq (%rsp), %rax
movq 0x48(%rax), %rax
movq %rax, 0x58(%rsp)
xorl %eax, %eax
movq %rax, 0x40(%rsp)
leaq (%rax,%rax,2), %rax
movq 0x58(%rsp), %rcx
movq (%rcx,%rax,8), %rdx
movq 0x8(%rcx,%rax,8), %rsi
subq %rdx, %rsi
je 0x2e9b
sarq $0x3, %rsi
movq 0xb0(%rsp), %rdi
movq 0x40(%rsp), %rax
leaq (,%rax,8), %rax
leaq (%rax,%rax,2), %rcx
movq 0x98(%rsp), %r9
addq %rcx, %r9
movq 0x68(%rsp), %r10
movq 0x80(%rsp), %r11
movq (%rsp), %rax
movq (%rax), %r8
movq %r8, 0x60(%rsp)
movq 0x30(%rax), %r12
addq 0x18(%rax), %rcx
movq %rcx, 0x10(%rsp)
cmpq $0x1, %rsi
adcq $0x0, %rsi
xorl %r15d, %r15d
testl %ebx, %ebx
jle 0x2e8f
movl %ebx, %ecx
movslq (%rdx,%r15,8), %rax
movl 0x4(%rdx,%r15,8), %ebp
leaq (%rax,%rax,2), %rax
movq (%rdi,%rax,8), %r14
movq (%r9), %r8
xorps %xmm0, %xmm0
xorl %ebx, %ebx
movss (%r8,%rbx,4), %xmm1
mulss (%r14,%rbx,4), %xmm1
mulss (%r10,%rbx,4), %xmm1
movss %xmm1, (%r11,%rbx,4)
addss %xmm1, %xmm0
incq %rbx
cmpq %rbx, %r13
jne 0x2dcf
movl %ecx, %ebx
testl %ecx, %ecx
jle 0x2e8f
movss 0x3203(%rip), %xmm1     # 0x6008
divss %xmm0, %xmm1
xorl %r8d, %r8d
movss (%r11,%r8,4), %xmm0
mulss %xmm1, %xmm0
movss %xmm0, (%r11,%r8,4)
incq %r8
cmpq %r8, %r13
jne 0x2e0c
testl %ebx, %ebx
jle 0x2e8f
xorps %xmm0, %xmm0
cvtsi2ss %ebp, %xmm0
movq 0x60(%rsp), %rcx
movq (%rcx,%rax,8), %rax
movq 0x10(%rsp), %rcx
movq (%rcx), %rbp
xorl %r14d, %r14d
movss (%r11,%r14,4), %xmm1
mulss %xmm0, %xmm1
addss (%rax,%r14,4), %xmm1
movss %xmm1, (%rax,%r14,4)
movss (%r11,%r14,4), %xmm1
mulss %xmm0, %xmm1
addss (%rbp,%r14,4), %xmm1
movss %xmm1, (%rbp,%r14,4)
movss (%r11,%r14,4), %xmm1
mulss %xmm0, %xmm1
addss (%r12,%r14,4), %xmm1
movss %xmm1, (%r12,%r14,4)
incq %r14
cmpq %r14, %r13
jne 0x2e43
incq %r15
cmpq %rsi, %r15
jne 0x2dac
movq 0x40(%rsp), %rax
incq %rax
movq 0x18(%rsp), %r10
cmpq %r10, %rax
jne 0x2d33
testl %ebx, %ebx
movq 0x50(%rsp), %rbp
movq (%rsp), %r12
leaq 0xb0(%rsp), %r15
jle 0x2fd6
movq (%r12), %rax
movq 0x18(%r12), %rcx
movq 0x38(%rsp), %r11
leaq (,%r11,8), %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (,%r10,8), %rsi
leaq (%rsi,%rsi,2), %rsi
xorl %edi, %edi
testl %r11d, %r11d
jle 0x2f41
xorps %xmm0, %xmm0
xorl %r8d, %r8d
movq (%rax,%r8), %r9
addss (%r9,%rdi,4), %xmm0
addq $0x18, %r8
cmpq %r8, %rdx
jne 0x2efd
testl %r11d, %r11d
jle 0x2f41
movss 0x30eb(%rip), %xmm1     # 0x6008
divss %xmm0, %xmm1
xorl %r8d, %r8d
movq (%rax,%r8), %r9
movss (%r9,%rdi,4), %xmm0
mulss %xmm1, %xmm0
movss %xmm0, (%r9,%rdi,4)
addq $0x18, %r8
cmpq %r8, %rdx
jne 0x2f24
testl %r10d, %r10d
jle 0x2f90
xorps %xmm0, %xmm0
xorl %r8d, %r8d
movq (%rcx,%r8), %r9
addss (%r9,%rdi,4), %xmm0
addq $0x18, %r8
cmpq %r8, %rsi
jne 0x2f4c
testl %r10d, %r10d
jle 0x2f90
movss 0x309c(%rip), %xmm1     # 0x6008
divss %xmm0, %xmm1
xorl %r8d, %r8d
movq (%rcx,%r8), %r9
movss (%r9,%rdi,4), %xmm0
mulss %xmm1, %xmm0
movss %xmm0, (%r9,%rdi,4)
addq $0x18, %r8
cmpq %r8, %rsi
jne 0x2f73
incq %rdi
cmpq %r13, %rdi
jne 0x2ef2
testl %ebx, %ebx
jle 0x2fd6
xorps %xmm1, %xmm1
cvtsi2ssl 0xd0(%r12), %xmm1
movq 0x30(%r12), %rax
movss 0x304e(%rip), %xmm0     # 0x6008
divss %xmm1, %xmm0
xorl %ecx, %ecx
movss (%rax,%rcx,4), %xmm1
mulss %xmm0, %xmm1
movss %xmm1, (%rax,%rcx,4)
incq %rcx
cmpq %rcx, %r13
jne 0x2fc0
movq %r12, %rdi
callq 0x38fc
movss %xmm0, 0x10(%rsp)
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x2ffb
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x21e0
incl %ebp
leaq 0x98(%rsp), %rdi
callq 0x3a1a
movq %r15, %rdi
callq 0x3a1a
movss 0x10(%rsp), %xmm1
movaps %xmm1, %xmm0
subss 0xc(%rsp), %xmm0
andps 0x2ff8(%rip), %xmm0     # 0x6020
ucomiss 0x2fdd(%rip), %xmm0     # 0x600c
movss %xmm1, 0xc(%rsp)
ja 0x2c3e
movq 0x5f8e(%rip), %r14      # 0x8fd0
leaq 0x308f(%rip), %rsi      # 0x60d8
movl $0x10, %edx
movq %r14, %rdi
callq 0x2210
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq 0x5f5c(%rip), %rdi      # 0x8fd0
callq 0x2030
movq %rax, %rdi
callq 0x2130
movq 0x5f48(%rip), %rdi      # 0x8fd0
leaq 0x305a(%rip), %rsi      # 0x60e9
movl $0xd, %edx
callq 0x2210
xorps %xmm0, %xmm0
cvtss2sd 0x10(%rsp), %xmm0
movq 0x5f27(%rip), %rdi      # 0x8fd0
callq 0x2280
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movq 0x5ef1(%rip), %rdi      # 0x8fd0
leaq 0x3011(%rip), %rsi      # 0x60f7
movl $0x6, %edx
callq 0x2210
movq 0x5ed9(%rip), %rdi      # 0x8fd0
movsd 0x2f71(%rip), %xmm0     # 0x6070
callq 0x2280
movq %rax, %r14
leaq 0x2ff0(%rip), %rsi      # 0x60fe
movl $0x14, %edx
movq %rax, %rdi
callq 0x2210
movq %r14, %rdi
movl %ebp, %esi
callq 0x22c0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movq 0x5e7a(%rip), %rdi      # 0x8fd0
leaq 0x2fb6(%rip), %rsi      # 0x6113
movl $0xb, %edx
callq 0x2210
callq 0x2120
subq 0x48(%rsp), %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x2ef7(%rip), %xmm0     # 0x6078
movq 0x5e48(%rip), %rdi      # 0x8fd0
callq 0x2280
movq %rax, %r14
leaq 0x2f10(%rip), %rsi      # 0x60a7
movl $0x1, %edx
movq %rax, %rdi
callq 0x2210
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movq 0x5dfe(%rip), %rdi      # 0x8fd0
leaq 0x2f46(%rip), %rsi      # 0x611f
movl $0x13, %edx
callq 0x2210
movq 0x5de6(%rip), %r14      # 0x8fd0
movq %r14, %rdi
movl %ebx, %esi
callq 0x22c0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x21b0
movsbl %al, %esi
movq 0x5d94(%rip), %rdi      # 0x8fd0
callq 0x2030
movq %rax, %rdi
callq 0x2130
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x3266
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x21e0
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x32bc
jmp 0x32bc
movq %rax, %rbx
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x329b
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x21e0
jmp 0x329b
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x3a1a
jmp 0x32ad
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x3a1a
jmp 0x32bf
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x32dc
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x21e0
movq %rbx, %rdi
callq 0x22d0