// File: /workspace/github_cpp_makefile_star2_O1/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, %rbp
movslq %edx, %r13
leaq 0xb0(%rsp), %rdx
movl $0x0, (%rdx)
leaq 0x80(%rsp), %rdi
leaq 0x98(%rsp), %rcx
movq %r13, %rsi
callq 0x32e4
movq %rbp, %rdi
movq %r15, %rsi
movl %r13d, %edx
movq %r14, %rcx
callq 0x3460
callq 0x2120
movq %rax, 0x48(%rsp)
leaq 0x18(%rbp), %rax
movq %rax, 0x38(%rsp)
leaq 0x30(%rbp), %rax
movq %rax, 0x30(%rsp)
movl %ebx, %r13d
leaq (,%r13,4), %rax
movq %rax, 0x28(%rsp)
xorl %r12d, %r12d
movss 0x33db(%rip), %xmm0     # 0x6004
movss %xmm0, 0x14(%rsp)
leaq 0xb0(%rsp), %r14
leaq 0x98(%rsp), %r15
movl %ebx, 0x4(%rsp)
movq %rbp, 0x20(%rsp)
movq %r14, %rdi
movq %rbp, %rsi
callq 0x37bc
movq %r15, %rdi
movq 0x38(%rsp), %rsi
callq 0x37bc
leaq 0x68(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x3856
movslq 0x64(%rbp), %rcx
movq %rcx, 0x8(%rsp)
testq %rcx, %rcx
jle 0x2cb8
movq 0x38(%rsp), %rax
movq (%rax), %r14
movq 0x8(%rsp), %rax
leaq (,%rax,8), %rax
leaq (%rax,%rax,2), %r15
xorl %ebx, %ebx
cmpl $0x0, 0x4(%rsp)
jle 0x2caf
movq (%r14,%rbx), %rdi
xorl %esi, %esi
movq 0x28(%rsp), %rdx
callq 0x2100
addq $0x18, %rbx
cmpq %rbx, %r15
jne 0x2c98
movslq 0x60(%rbp), %rax
testq %rax, %rax
movq %rax, 0x50(%rsp)
jle 0x2cf9
movq (%rbp), %r14
leaq (,%rax,8), %rax
leaq (%rax,%rax,2), %rbx
xorl %r15d, %r15d
cmpl $0x0, 0x4(%rsp)
jle 0x2cf0
movq (%r14,%r15), %rdi
xorl %esi, %esi
movq 0x28(%rsp), %rdx
callq 0x2100
addq $0x18, %r15
cmpq %r15, %rbx
jne 0x2cd9
movq %r12, 0x58(%rsp)
movl 0x4(%rsp), %ebx
testl %ebx, %ebx
jle 0x2d1a
movq 0x30(%rsp), %rax
movq (%rax), %rdi
xorl %esi, %esi
movq 0x28(%rsp), %rdx
callq 0x2100
cmpl $0x0, 0x8(%rsp)
jle 0x2e9c
movq 0x20(%rsp), %rax
movq 0x48(%rax), %rax
movq %rax, 0x60(%rsp)
xorl %eax, %eax
movq %rax, 0x40(%rsp)
leaq (%rax,%rax,2), %rax
movq 0x60(%rsp), %rcx
movq (%rcx,%rax,8), %rdx
movq 0x8(%rcx,%rax,8), %rsi
subq %rdx, %rsi
je 0x2e89
sarq $0x3, %rsi
movq 0xb0(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x40(%rsp), %rax
leaq (,%rax,8), %rax
leaq (%rax,%rax,2), %r8
movq 0x98(%rsp), %r9
addq %r8, %r9
movq 0x68(%rsp), %r10
movq 0x80(%rsp), %r11
movq 0x20(%rsp), %rax
movq (%rax), %r14
movq 0x30(%rax), %r12
addq 0x18(%rax), %r8
cmpq $0x1, %rsi
adcq $0x0, %rsi
xorl %r15d, %r15d
movslq (%rdx,%r15,8), %rax
movl 0x4(%rdx,%r15,8), %ebp
leaq (%rax,%rax,2), %rax
testl %ebx, %ebx
jle 0x2df0
movq 0x18(%rsp), %rcx
movq (%rcx,%rax,8), %rcx
movq (%r9), %rbx
xorps %xmm0, %xmm0
xorl %edi, %edi
movss (%rbx,%rdi,4), %xmm1
mulss (%rcx,%rdi,4), %xmm1
mulss (%r10,%rdi,4), %xmm1
movss %xmm1, (%r11,%rdi,4)
addss %xmm1, %xmm0
incq %rdi
cmpq %rdi, %r13
jne 0x2dcc
jmp 0x2df3
xorps %xmm0, %xmm0
movl 0x4(%rsp), %ebx
testl %ebx, %ebx
jle 0x2e21
movss 0x3205(%rip), %xmm1     # 0x6008
divss %xmm0, %xmm1
xorl %ecx, %ecx
movss (%r11,%rcx,4), %xmm0
mulss %xmm1, %xmm0
movss %xmm0, (%r11,%rcx,4)
incq %rcx
cmpq %rcx, %r13
jne 0x2e09
testl %ebx, %ebx
jle 0x2e7d
xorps %xmm0, %xmm0
cvtsi2ss %ebp, %xmm0
movq (%r14,%rax,8), %rax
movq (%r8), %rbp
xorl %ecx, %ecx
movss (%r11,%rcx,4), %xmm1
mulss %xmm0, %xmm1
addss (%rax,%rcx,4), %xmm1
movss %xmm1, (%rax,%rcx,4)
movss (%r11,%rcx,4), %xmm1
mulss %xmm0, %xmm1
addss (%rbp,%rcx,4), %xmm1
movss %xmm1, (%rbp,%rcx,4)
movss (%r11,%rcx,4), %xmm1
mulss %xmm0, %xmm1
addss (%r12,%rcx,4), %xmm1
movss %xmm1, (%r12,%rcx,4)
incq %rcx
cmpq %rcx, %r13
jne 0x2e35
incq %r15
cmpq %rsi, %r15
jne 0x2daa
movq 0x40(%rsp), %rax
incq %rax
cmpq 0x8(%rsp), %rax
jne 0x2d35
testl %ebx, %ebx
movq 0x58(%rsp), %r12
movq 0x20(%rsp), %rbp
leaq 0xb0(%rsp), %r14
leaq 0x98(%rsp), %r15
movq 0x50(%rsp), %r10
jle 0x2f97
movq (%rbp), %rax
movq 0x18(%rbp), %rcx
movl %r10d, %edx
movl 0x8(%rsp), %esi
shlq $0x3, %rdx
leaq (%rdx,%rdx,2), %rdx
shlq $0x3, %rsi
leaq (%rsi,%rsi,2), %rsi
xorl %edi, %edi
xorps %xmm0, %xmm0
testl %r10d, %r10d
jle 0x2f02
xorl %r8d, %r8d
movq (%rax,%r8), %r9
addss (%r9,%rdi,4), %xmm0
addq $0x18, %r8
cmpq %r8, %rdx
jne 0x2eef
testl %r10d, %r10d
jle 0x2f33
movss 0x30f9(%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 0x2f16
cmpl $0x0, 0x8(%rsp)
jle 0x2f55
xorps %xmm0, %xmm0
xorl %r8d, %r8d
movq (%rcx,%r8), %r9
addss (%r9,%rdi,4), %xmm0
addq $0x18, %r8
cmpq %r8, %rsi
jne 0x2f40
jmp 0x2f58
xorps %xmm0, %xmm0
cmpl $0x0, 0x8(%rsp)
jle 0x2f8b
movss 0x30a1(%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 0x2f6e
incq %rdi
cmpq %r13, %rdi
jne 0x2ee4
testl %ebx, %ebx
jle 0x2fce
xorps %xmm1, %xmm1
cvtsi2ssl 0xd0(%rbp), %xmm1
movq 0x30(%rbp), %rax
movss 0x3056(%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 0x2fb8
movq %rbp, %rdi
callq 0x38d6
movss %xmm0, 0x18(%rsp)
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x2ff3
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x21e0
incl %r12d
movq %r15, %rdi
callq 0x39f4
movq %r14, %rdi
callq 0x39f4
movss 0x18(%rsp), %xmm1
movaps %xmm1, %xmm0
subss 0x14(%rsp), %xmm0
andps 0x3004(%rip), %xmm0     # 0x6020
ucomiss 0x2fe9(%rip), %xmm0     # 0x600c
movss %xmm1, 0x14(%rsp)
ja 0x2c48
movq 0x5f9a(%rip), %r14      # 0x8fd0
leaq 0x309b(%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 0x5f68(%rip), %rdi      # 0x8fd0
callq 0x2030
movq %rax, %rdi
callq 0x2130
movq 0x5f54(%rip), %rdi      # 0x8fd0
leaq 0x3066(%rip), %rsi      # 0x60e9
movl $0xd, %edx
callq 0x2210
xorps %xmm0, %xmm0
cvtss2sd 0x18(%rsp), %xmm0
movq 0x5f33(%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 0x5efd(%rip), %rdi      # 0x8fd0
leaq 0x301d(%rip), %rsi      # 0x60f7
movl $0x6, %edx
callq 0x2210
movq 0x5ee5(%rip), %rdi      # 0x8fd0
movsd 0x2f7d(%rip), %xmm0     # 0x6070
callq 0x2280
movq %rax, %r14
leaq 0x2ffc(%rip), %rsi      # 0x60fe
movl $0x14, %edx
movq %rax, %rdi
callq 0x2210
movq %r14, %rdi
movl %r12d, %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 0x5e85(%rip), %rdi      # 0x8fd0
leaq 0x2fc1(%rip), %rsi      # 0x6113
movl $0xb, %edx
callq 0x2210
callq 0x2120
subq 0x48(%rsp), %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
mulsd 0x2f02(%rip), %xmm0     # 0x6078
movq 0x5e53(%rip), %rdi      # 0x8fd0
callq 0x2280
movq %rax, %r14
leaq 0x2f1b(%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 0x5e09(%rip), %rdi      # 0x8fd0
leaq 0x2f51(%rip), %rsi      # 0x611f
movl $0x13, %edx
callq 0x2210
movq 0x5df1(%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 0x5d9f(%rip), %rdi      # 0x8fd0
callq 0x2030
movq %rax, %rdi
callq 0x2130
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x325b
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 0x32b1
jmp 0x32b1
movq %rax, %rbx
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x3290
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x21e0
jmp 0x3290
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x39f4
jmp 0x32a2
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0x39f4
jmp 0x32b4
movq %rax, %rbx
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x32d1
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x21e0
movq %rbx, %rdi
callq 0x22d0