// File: /workspace/github_cpp_makefile_star2_O2/bobverity[P]MavericK/writeOut.cpp
// Function: printQmatrix_pop(globals&, int)
void printQmatrix_pop(globals &globals, int Kindex) {
    int K = globals.Kmin+Kindex;
    
    if (globals.outputQmatrix_structureFormat_on) {
        
        // open outputQmatrix_pop filestream for this K
        string s = globals.outputQmatrix_pop_filePath;
        s.erase(end(s)-4,end(s));
        s = s + "_K" + to_string((long long)K) + ".txt";
        globals.outputQmatrix_pop_fileStream = safe_ofstream(s,globals.outputLog_on, globals.outputLog_fileStream);
        
        // write headers
        /*
        globals.outputQmatrix_pop_fileStream << "Given    Inferred Clusters       Number of\n";
        globals.outputQmatrix_pop_fileStream << " Pop       1";
        for (int k=1; k<K; k++) {
            if ((k+1)<10)
                globals.outputQmatrix_pop_fileStream << " ";
            globals.outputQmatrix_pop_fileStream << "     " << k+1;
        }
        globals.outputQmatrix_pop_fileStream << "      Individuals\n\n";
        */
        
        // write results
        for (int i=0; i<int(globals.uniquePops.size()); i++) {
            
            // given pop
            if (globals.uniquePops[i].length()<3)
                globals.outputQmatrix_pop_fileStream << " ";
            if (globals.uniquePops[i].length()<2)
                globals.outputQmatrix_pop_fileStream << " ";
            globals.outputQmatrix_pop_fileStream << globals.uniquePops[i] << ":     ";
            
            // probabilities
            for (int k=0; k<K; k++) {
                char * buffer = new char[256];
                sprintf(buffer, "%.3f", my_round(globals.Qmatrix_pop[Kindex][i][k]*1000)/1000.0);
                string s = buffer;
                delete [] buffer;
                globals.outputQmatrix_pop_fileStream << s << " ";
            }
            
            // number of individuals in each population
            globals.outputQmatrix_pop_fileStream << "     ";
            if (globals.uniquePop_counts[i]<100)
                globals.outputQmatrix_pop_fileStream << " ";
            if (globals.uniquePop_counts[i]<10)
                globals.outputQmatrix_pop_fileStream << " ";
            globals.outputQmatrix_pop_fileStream << globals.uniquePop_counts[i];
            
            globals.outputQmatrix_pop_fileStream << "\n";
        }
        
    } // end of if outputQmatrix_structureFormat_on=true
        
    // open outputQmatrix_pop filestream for this K
    string s = globals.outputQmatrix_pop_filePath;
    s.erase(end(s)-4,end(s));
    s = s + "_K" + to_string((long long)K) + ".csv";
    globals.outputQmatrix_pop_fileStream = safe_ofstream(s,globals.outputLog_on, globals.outputLog_fileStream);
    
    // write headers
    globals.outputQmatrix_pop_fileStream << "given_population,members";
    for (int k=0; k<K; k++)
        globals.outputQmatrix_pop_fileStream << ",deme" << k+1;
    globals.outputQmatrix_pop_fileStream << "\n";
    
    // write results
    for (int i=0; i<int(globals.uniquePops.size()); i++) {
        
        // given population and number of individuals
        globals.outputQmatrix_pop_fileStream << globals.uniquePops[i] << "," << globals.uniquePop_counts[i];
        
        // probabilities
        for (int k=0; k<K; k++) {
            char * buffer = new char[256];
            sprintf(buffer, "%.3f", my_round(globals.Qmatrix_pop[Kindex][i][k]*1000)/1000.0);
            string s = buffer;
            delete [] buffer;
            globals.outputQmatrix_pop_fileStream << "," << s;
        }
        
        globals.outputQmatrix_pop_fileStream << "\n";
        
    }
    
    globals.outputQmatrix_pop_fileStream.flush();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2f8, %rsp            # imm = 0x2F8
movl %esi, %r15d
movslq %esi, %rax
movq %rax, 0x28(%rsp)
addl 0x2bc8(%rdi), %r15d
cmpb $0x1, 0x2c4d(%rdi)
movslq %r15d, %r12
movq %rdi, 0x8(%rsp)
jne 0x26213
leaq 0x380(%rdi), %rsi
leaq 0x50(%rsp), %rbx
movq %rbx, %rdi
callq 0x3430
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
leaq (%rax,%rcx), %rdx
leaq (%rax,%rcx), %rsi
addq $-0x4, %rsi
movq %rbx, %rdi
callq 0x30a0
leaq 0x393c(%rip), %rdx      # 0x2983e
leaq 0x98(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x110be
leaq 0x78(%rsp), %rdi
movq %r12, %rsi
callq 0x60a6
leaq 0x30(%rsp), %rdi
leaq 0x98(%rsp), %rsi
leaq 0x78(%rsp), %rdx
callq 0x601b
leaq 0x1337(%rip), %rdx      # 0x27276
leaq 0xf8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xcf2e
leaq 0x50(%rsp), %rbx
leaq 0xf8(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x33f0
movq %r14, %rdi
callq 0x3170
leaq 0x30(%rsp), %rdi
callq 0x3170
leaq 0x78(%rsp), %rdi
callq 0x3170
leaq 0x98(%rsp), %rdi
callq 0x3170
leaq 0xd8(%rsp), %rdi
movq %rbx, %rsi
callq 0x3430
movq 0x8(%rsp), %rbx
movzbl 0x2c3c(%rbx), %edx
leaq 0x970(%rbx), %rcx
leaq 0xf8(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x22438
movq %r12, 0x70(%rsp)
movl %r15d, 0x1c(%rsp)
leaq 0xf70(%rbx), %r15
leaq 0xf8(%rsp), %rsi
movq %r15, %rdi
callq 0x33d0
leaq 0xf8(%rsp), %r12
movq %r12, %rdi
callq 0x3460
leaq 0xd8(%rsp), %rdi
callq 0x3170
xorl %ebx, %ebx
movl 0x1c(%rsp), %eax
testl %eax, %eax
movl $0x0, %r14d
cmovgl %eax, %r14d
imulq $0x18, 0x28(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x8(%rsp), %rax
movq 0x2c88(%rax), %rsi
movq 0x2c90(%rax), %rax
subq %rsi, %rax
shrq $0x5, %rax
cltq
cmpq %rax, %rbx
jge 0x261fa
movq %rbx, 0x10(%rsp)
shlq $0x5, %rbx
cmpq $0x2, 0x8(%rsi,%rbx)
ja 0x26099
movq %r15, %rdi
leaq 0x39de(%rip), %rsi      # 0x29a43
callq 0x3350
movq 0x8(%rsp), %rax
movq 0x2c88(%rax), %rsi
cmpq $0x1, 0x8(%rsi,%rbx)
ja 0x26099
movq %r15, %rdi
leaq 0x39bb(%rip), %rsi      # 0x29a43
callq 0x3350
movq 0x8(%rsp), %rax
movq 0x2c88(%rax), %rsi
addq %rbx, %rsi
movq %r15, %rdi
callq 0x3310
movq %rax, %rdi
leaq 0x3990(%rip), %rsi      # 0x29a3e
callq 0x3350
imulq $0x18, 0x10(%rsp), %r13
xorl %ebx, %ebx
cmpq %rbx, %r14
je 0x26163
movl $0x100, %edi            # imm = 0x100
callq 0x3030
movsd 0x35f2(%rip), %xmm1     # 0x296c8
movq %rax, %rbp
movq 0x8(%rsp), %rax
movq 0x2dd0(%rax), %rax
movq 0x20(%rsp), %rcx
movq (%rax,%rcx), %rax
movq (%rax,%r13), %rax
movsd (%rax,%rbx,8), %xmm0
mulsd %xmm1, %xmm0
callq 0x14cb8
movsd 0x35c0(%rip), %xmm1     # 0x296c8
cvtsi2sd %eax, %xmm0
divsd %xmm1, %xmm0
movq %rbp, %rdi
leaq 0x3911(%rip), %rsi      # 0x29a2b
movb $0x1, %al
callq 0x3080
movq %r12, %rdi
movq %rbp, %rsi
leaq 0x30(%rsp), %rdx
callq 0x3130
movq %rbp, %rdi
callq 0x3400
movq %r15, %rdi
movq %r12, %rsi
callq 0x3310
movq %rax, %rdi
leaq 0x38f5(%rip), %rsi      # 0x29a43
callq 0x3350
movq %r12, %rdi
callq 0x3170
incq %rbx
jmp 0x260bb
movq %r15, %rdi
leaq 0x38d2(%rip), %rsi      # 0x29a3f
callq 0x3350
movq 0x8(%rsp), %rax
movq 0x2ca0(%rax), %rax
movq 0x10(%rsp), %rcx
movl (%rax,%rcx,4), %esi
cmpl $0x63, %esi
jg 0x261d6
movq %r15, %rdi
leaq 0x38ae(%rip), %rsi      # 0x29a43
callq 0x3350
movq 0x8(%rsp), %rax
movq 0x2ca0(%rax), %rax
movq 0x10(%rsp), %rcx
movl (%rax,%rcx,4), %esi
cmpl $0x9, %esi
jg 0x261d6
movq %r15, %rdi
leaq 0x3886(%rip), %rsi      # 0x29a43
callq 0x3350
movq 0x8(%rsp), %rax
movq 0x2ca0(%rax), %rax
movq 0x10(%rsp), %rcx
movl (%rax,%rcx,4), %esi
movq %r15, %rdi
callq 0x3570
movq %r15, %rdi
leaq 0x16d3(%rip), %rsi      # 0x278bb
callq 0x3350
movq 0x10(%rsp), %rbx
incq %rbx
jmp 0x26025
leaq 0x50(%rsp), %rdi
callq 0x3170
movq 0x8(%rsp), %rdi
movl 0x1c(%rsp), %r15d
movq 0x70(%rsp), %r12
leaq 0x380(%rdi), %rsi
leaq 0x50(%rsp), %rbx
movq %rbx, %rdi
callq 0x3430
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
leaq (%rax,%rcx), %rdx
leaq (%rax,%rcx), %rsi
addq $-0x4, %rsi
movq %rbx, %rdi
callq 0x30a0
leaq 0x35f5(%rip), %rdx      # 0x2983e
leaq 0x98(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x110be
leaq 0x78(%rsp), %rdi
movq %r12, %rsi
callq 0x60a6
leaq 0x30(%rsp), %rdi
leaq 0x98(%rsp), %rsi
leaq 0x78(%rsp), %rdx
callq 0x601b
leaq 0x10e7(%rip), %rdx      # 0x2736d
leaq 0xf8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xcf2e
leaq 0x50(%rsp), %rbx
leaq 0xf8(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x33f0
movq %r14, %rdi
callq 0x3170
leaq 0x30(%rsp), %rdi
callq 0x3170
leaq 0x78(%rsp), %rdi
callq 0x3170
leaq 0x98(%rsp), %rdi
callq 0x3170
leaq 0xb8(%rsp), %rdi
movq %rbx, %rsi
callq 0x3430
movq 0x8(%rsp), %rbx
movzbl 0x2c3c(%rbx), %edx
leaq 0x970(%rbx), %rcx
leaq 0xf8(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x22438
leaq 0xf70(%rbx), %r13
leaq 0xf8(%rsp), %rsi
movq %r13, %rdi
callq 0x33d0
leaq 0xf8(%rsp), %rdi
callq 0x3460
leaq 0xb8(%rsp), %rdi
callq 0x3170
leaq 0x36fc(%rip), %rsi      # 0x29a45
movq %r13, %rdi
callq 0x3350
xorl %ebp, %ebp
testl %r15d, %r15d
cmovgl %r15d, %ebp
movl %ebp, %r14d
negl %r14d
pushq $0x1
popq %r15
leaq 0x36ba(%rip), %rbx      # 0x29a25
leal (%r14,%r15), %eax
cmpl $0x1, %eax
je 0x26393
movq %r13, %rdi
movq %rbx, %rsi
callq 0x3350
leal 0x1(%r15), %r12d
movq %rax, %rdi
movl %r15d, %esi
callq 0x3570
movl %r12d, %r15d
jmp 0x2636b
leaq 0x1521(%rip), %rsi      # 0x278bb
movq %r13, %rdi
callq 0x3350
movl %ebp, %eax
movq %rax, 0x20(%rsp)
xorl %ecx, %ecx
imulq $0x18, 0x28(%rsp), %r15
leaq 0xf8(%rsp), %rbp
movq 0x8(%rsp), %rax
movq 0x2c88(%rax), %rsi
movq 0x2c90(%rax), %rax
subq %rsi, %rax
shrq $0x5, %rax
cltq
cmpq %rax, %rcx
jge 0x264eb
movq %rcx, %rax
movq %rcx, 0x10(%rsp)
shlq $0x5, %rax
addq %rax, %rsi
movq %r13, %rdi
callq 0x3310
movq %rax, %rdi
leaq 0xe41(%rip), %rsi       # 0x27240
callq 0x3350
movq 0x8(%rsp), %rcx
movq 0x2ca0(%rcx), %rcx
movq 0x10(%rsp), %rdx
movl (%rcx,%rdx,4), %esi
movq %rax, %rdi
callq 0x3570
imulq $0x18, 0x10(%rsp), %r12
xorl %r14d, %r14d
cmpq %r14, 0x20(%rsp)
je 0x264cf
movl $0x100, %edi            # imm = 0x100
callq 0x3030
movsd 0x3282(%rip), %xmm1     # 0x296c8
movq %rax, %rbx
movq 0x8(%rsp), %rax
movq 0x2dd0(%rax), %rax
movq (%rax,%r15), %rax
movq (%rax,%r12), %rax
movsd (%rax,%r14,8), %xmm0
mulsd %xmm1, %xmm0
callq 0x14cb8
movsd 0x3254(%rip), %xmm1     # 0x296c8
cvtsi2sd %eax, %xmm0
divsd %xmm1, %xmm0
movq %rbx, %rdi
leaq 0x35a5(%rip), %rsi      # 0x29a2b
movb $0x1, %al
callq 0x3080
movq %rbp, %rdi
movq %rbx, %rsi
leaq 0x30(%rsp), %rdx
callq 0x3130
movq %rbx, %rdi
callq 0x3400
movq %r13, %rdi
leaq 0xd91(%rip), %rsi       # 0x27240
callq 0x3350
movq %rax, %rdi
movq %rbp, %rsi
callq 0x3310
movq %rbp, %rdi
callq 0x3170
incq %r14
jmp 0x26429
movq %r13, %rdi
leaq 0x13e2(%rip), %rsi      # 0x278bb
callq 0x3350
movq 0x10(%rsp), %rcx
incq %rcx
jmp 0x263b9
movq %r13, %rdi
callq 0x3230
leaq 0x50(%rsp), %rdi
callq 0x3170
addq $0x2f8, %rsp            # imm = 0x2F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x3460
jmp 0x26524
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
jmp 0x265a5
jmp 0x265ac
jmp 0x2655b
jmp 0x2656a
jmp 0x26579
jmp 0x265ac
jmp 0x265ac
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x3460
jmp 0x2654f
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
jmp 0x265a5
jmp 0x265ac
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x3170
jmp 0x2656d
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x3170
jmp 0x2657c
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
jmp 0x265a5
jmp 0x265ac
jmp 0x265ac
jmp 0x265ac
jmp 0x265ac
jmp 0x265ac
jmp 0x265ac
jmp 0x265ac
jmp 0x265ac
jmp 0x2659a
jmp 0x265ac
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x3170
jmp 0x265af
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x35a0