// File: /workspace/github_cpp_makefile_star2_O2/bobverity[P]MavericK/writeOut.cpp
// Function: printQmatrixError_pop(globals&, int)
void printQmatrixError_pop(globals &globals, int Kindex) {
    int K = globals.Kmin+Kindex;
    
    // open outputQmatrixError_pop filestream for this K
    string s = globals.outputQmatrixError_pop_filePath;
    s.erase(end(s)-4,end(s));
    s = s + "_K" + to_string((long long)K) + ".csv";
    globals.outputQmatrixError_pop_fileStream = safe_ofstream(s,globals.outputLog_on, globals.outputLog_fileStream);
    
    // write headers
    globals.outputQmatrixError_pop_fileStream << "given_population,individuals";
    for (int k=0; k<K; k++)
        globals.outputQmatrixError_pop_fileStream << ",deme" << k+1;
    globals.outputQmatrixError_pop_fileStream << "\n";
    
    // write results
    for (int i=0; i<int(globals.uniquePops.size()); i++) {
        
        // given population and number of individuals
        globals.outputQmatrixError_pop_fileStream << globals.uniquePops[i] << "," << globals.uniquePop_counts[i];
        
        // standard errors
        for (int k=0; k<K; k++) {
            char * buffer = new char[256];
            sprintf(buffer, "%.6f", my_round(globals.QmatrixError_pop[Kindex][i][k]*1e6)/1e6);
            string s = buffer;
            delete [] buffer;
            globals.outputQmatrixError_pop_fileStream << "," << s;
        }
        
        globals.outputQmatrixError_pop_fileStream << "\n";
        
    }
    
    globals.outputQmatrixError_pop_fileStream.flush();
    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2b8, %rsp            # imm = 0x2B8
movl %esi, %ebp
movl 0x2bc8(%rdi), %ebx
addl %esi, %ebx
movq %rdi, 0x8(%rsp)
leaq 0x3e0(%rdi), %rsi
leaq 0x38(%rsp), %r14
movq %r14, %rdi
callq 0x3430
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq (%rax,%rcx), %rdx
leaq (%rax,%rcx), %rsi
addq $-0x4, %rsi
movq %r14, %rdi
callq 0x30a0
leaq 0x3227(%rip), %rdx      # 0x2983e
leaq 0x98(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x110be
movslq %ebx, %rsi
leaq 0x78(%rsp), %rdi
callq 0x60a6
leaq 0x18(%rsp), %rdi
leaq 0x98(%rsp), %rsi
leaq 0x78(%rsp), %rdx
callq 0x601b
leaq 0xd19(%rip), %rdx       # 0x2736d
leaq 0xb8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0xcf2e
leaq 0x38(%rsp), %r14
leaq 0xb8(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x33f0
movq %r15, %rdi
callq 0x3170
leaq 0x18(%rsp), %rdi
callq 0x3170
leaq 0x78(%rsp), %rdi
callq 0x3170
leaq 0x98(%rsp), %rdi
callq 0x3170
leaq 0x58(%rsp), %rdi
movq %r14, %rsi
callq 0x3430
movq 0x8(%rsp), %r14
movzbl 0x2c3c(%r14), %edx
leaq 0x970(%r14), %rcx
leaq 0xb8(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x22438
addq $0x1570, %r14           # imm = 0x1570
leaq 0xb8(%rsp), %rsi
movq %r14, %rdi
callq 0x33d0
leaq 0xb8(%rsp), %rdi
callq 0x3460
leaq 0x58(%rsp), %rdi
callq 0x3170
leaq 0x334f(%rip), %rsi      # 0x29a5e
movq %r14, (%rsp)
movq %r14, %rdi
callq 0x3350
xorl %r14d, %r14d
testl %ebx, %ebx
cmovgl %ebx, %r14d
movl %r14d, %ebx
negl %ebx
pushq $0x1
popq %r12
leaq 0x32f1(%rip), %r15      # 0x29a25
leal (%rbx,%r12), %eax
cmpl $0x1, %eax
je 0x2675e
movq (%rsp), %rdi
movq %r15, %rsi
callq 0x3350
leal 0x1(%r12), %r13d
movq %rax, %rdi
movl %r12d, %esi
callq 0x3570
movl %r13d, %r12d
jmp 0x26734
leaq 0x1156(%rip), %rsi      # 0x278bb
movq (%rsp), %rdi
callq 0x3350
movslq %ebp, %rax
movl %r14d, %ebx
xorl %ecx, %ecx
imulq $0x18, %rax, %r15
leaq 0xb8(%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 0x268b5
movq %rcx, %rax
movq %rcx, 0x10(%rsp)
shlq $0x5, %rax
addq %rax, %rsi
movq (%rsp), %rdi
callq 0x3310
movq %rax, %rdi
leaq 0xa77(%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, %rbx
je 0x26898
movl $0x100, %edi            # imm = 0x100
callq 0x3030
movsd 0x2ec2(%rip), %xmm1     # 0x296d0
movq %rax, %r13
movq 0x8(%rsp), %rax
movq 0x2de8(%rax), %rax
movq (%rax,%r15), %rax
movq (%rax,%r12), %rax
movsd (%rax,%r14,8), %xmm0
mulsd %xmm1, %xmm0
callq 0x14cb8
movsd 0x2e94(%rip), %xmm1     # 0x296d0
cvtsi2sd %eax, %xmm0
divsd %xmm1, %xmm0
movq %r13, %rdi
leaq 0x31eb(%rip), %rsi      # 0x29a39
movb $0x1, %al
callq 0x3080
movq %rbp, %rdi
movq %r13, %rsi
leaq 0x18(%rsp), %rdx
callq 0x3130
movq %r13, %rdi
callq 0x3400
movq (%rsp), %rdi
leaq 0x9c8(%rip), %rsi       # 0x27240
callq 0x3350
movq %rax, %rdi
movq %rbp, %rsi
callq 0x3310
movq %rbp, %rdi
callq 0x3170
incq %r14
jmp 0x267f3
movq (%rsp), %rdi
leaq 0x1018(%rip), %rsi      # 0x278bb
callq 0x3350
movq 0x10(%rsp), %rcx
incq %rcx
jmp 0x26782
movq (%rsp), %rdi
callq 0x3230
leaq 0x38(%rsp), %rdi
callq 0x3170
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x3460
jmp 0x268ef
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
jmp 0x2693a
jmp 0x26941
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x3170
jmp 0x2690a
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x3170
jmp 0x26919
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
jmp 0x2693a
jmp 0x26941
jmp 0x26941
jmp 0x26941
jmp 0x26941
jmp 0x26941
jmp 0x26941
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x3170
jmp 0x26944
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x35a0