// File: /workspace/github_cpp_makefile_star2_O1/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 0x2bc8(%rdi), %eax
movl %esi, 0x10(%rsp)
addl %esi, %eax
movl %eax, 0x4(%rsp)
leaq 0x88(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x3e0(%rdi), %rsi
movq %rdi, 0x8(%rsp)
movq 0x3e8(%rdi), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %r14
movq %r14, %rdi
callq 0xbe10
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq -0x4(%rcx), %rdx
movq %rdx, 0x8(%r14)
movb $0x0, -0x4(%rax,%rcx)
movq (%r14), %rsi
leaq 0x68(%rsp), %r13
movq %r13, -0x10(%r13)
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %rdi
callq 0xbe10
leaq 0x3ccd(%rip), %rsi      # 0x3987e
leaq 0x58(%rsp), %rdi
callq 0x35e0
movslq 0x4(%rsp), %r15
movq %r15, %r14
negq %r14
cmovsq %r15, %r14
movl $0x1, %r12d
cmpq $0xa, %r14
jb 0x35c2a
movl $0x4, %r12d
movabsq $0x346dc5d63886594b, %rsi # imm = 0x346DC5D63886594B
movq %r14, %rcx
cmpq $0x63, %rcx
jbe 0x35c21
cmpq $0x3e7, %rcx            # imm = 0x3E7
jbe 0x35c27
cmpq $0x2710, %rcx           # imm = 0x2710
jb 0x35c2a
movq %rcx, %rax
mulq %rsi
shrq $0xb, %rdx
addl $0x4, %r12d
cmpq $0x1869f, %rcx          # imm = 0x1869F
movq %rdx, %rcx
ja 0x35be9
addl $-0x3, %r12d
jmp 0x35c2a
addl $-0x2, %r12d
jmp 0x35c2a
decl %r12d
shrq $0x3f, %r15
leal (%r15,%r12), %esi
leaq 0x48(%rsp), %rbp
movq %rbp, -0x10(%rbp)
leaq 0x38(%rsp), %rdi
movl $0x2d, %edx
callq 0x33a0
addq 0x38(%rsp), %r15
movq %r15, %rdi
movl %r12d, %esi
movq %r14, %rdx
callq 0x6dda
movq 0x58(%rsp), %rcx
movq 0x60(%rsp), %r8
movq 0x40(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
cmpq %r13, %rcx
je 0x35c7f
movq 0x68(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x35c9a
movl $0xf, %esi
cmpq %rbp, 0x38(%rsp)
je 0x35c95
movq 0x48(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x35cab
movq 0x38(%rsp), %rsi
leaq 0x58(%rsp), %rdi
callq 0x30e0
jmp 0x35cb9
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3370
leaq 0x28(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x35cdd
movq %rsi, 0x18(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x28(%rsp)
jmp 0x35ce5
movupd (%rcx), %xmm0
movupd %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x20(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x16dc(%rip), %rsi      # 0x373e5
leaq 0x18(%rsp), %rdi
callq 0x35e0
leaq 0xc8(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x35d43
movq %rdx, 0xb8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xc8(%rsp)
jmp 0x35d4b
movupd (%rcx), %xmm0
movupd %xmm0, (%rbx)
movq 0x8(%rax), %rdx
leaq 0xb8(%rsp), %r14
movq %rdx, 0x8(%r14)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x78(%rsp), %rdi
movq %r14, %rsi
callq 0x33e0
movq (%r14), %rdi
cmpq %rbx, %rdi
je 0x35d84
callq 0x3310
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
movq 0x8(%rsp), %r14
je 0x35d9c
callq 0x3310
movq 0x38(%rsp), %rdi
cmpq %rbp, %rdi
je 0x35dab
callq 0x3310
movq 0x58(%rsp), %rdi
cmpq %r13, %rdi
je 0x35dba
callq 0x3310
leaq 0xa8(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x78(%rsp), %rsi
movq 0x80(%rsp), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rdi
callq 0xbe10
movzbl 0x2c3c(%r14), %edx
leaq 0x970(%r14), %rcx
leaq 0xb8(%rsp), %r12
leaq 0x98(%rsp), %rsi
movq %r12, %rdi
callq 0x2f394
movq %r14, %r13
addq $0x1570, %r14           # imm = 0x1570
movq 0x1570(%r13), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
leaq 0xc0(%rsp), %r15
movq -0x8(%r15), %rax
addq -0x18(%rax), %r12
movq %r12, %rsi
callq 0x35d0
leaq 0x1578(%r13), %rdi
movq %r15, %rsi
callq 0x3340
movq 0xc150(%rip), %rax      # 0x41fa0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x1b0(%rsp), %r12
movq %rcx, -0xf8(%r12)
movq -0x18(%rcx), %rcx
movq %rax, 0xb8(%rsp,%rcx)
movq %r15, %rdi
callq 0x32b0
movq %r12, %rdi
callq 0x30f0
movq 0x98(%rsp), %rdi
cmpq %rbx, %rdi
je 0x35e95
callq 0x3310
leaq 0x3c02(%rip), %rsi      # 0x39a9e
movl $0x1c, %edx
movq %r14, %rdi
callq 0x3390
xorl %ebx, %ebx
movl 0x4(%rsp), %eax
testl %eax, %eax
cmovgl %eax, %ebx
negl %ebx
movl $0x1, %r12d
leaq 0x3ba2(%rip), %r15      # 0x39a65
leal (%rbx,%r12), %eax
cmpl $0x1, %eax
je 0x35ef1
movl $0x5, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x3390
leal 0x1(%r12), %ebp
movq %r14, %rdi
movl %r12d, %esi
callq 0x3550
movl %ebp, %r12d
jmp 0x35ec3
leaq 0x1a2a(%rip), %rsi      # 0x37922
movl $0x1, %edx
movq %r14, %rdi
callq 0x3390
movq 0x8(%rsp), %rcx
movq 0x2c88(%rcx), %rax
movq 0x2c90(%rcx), %rcx
subq %rax, %rcx
shrq $0x5, %rcx
testl %ecx, %ecx
jle 0x360c0
movslq 0x10(%rsp), %rcx
movl 0x4(%rsp), %ebx
xorl %r15d, %r15d
leaq (%rcx,%rcx,2), %r12
movq %r15, %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
movq %r14, %rdi
callq 0x3390
movq %rax, %rbp
movl $0x1, %edx
movq %rax, %rdi
leaq 0x132f(%rip), %rsi      # 0x37290
callq 0x3390
movq 0x8(%rsp), %rax
movq 0x2ca0(%rax), %rax
movl (%rax,%r15,4), %esi
movq %rbp, %rdi
callq 0x3550
movq %r15, 0x10(%rsp)
cmpl $0x0, 0x4(%rsp)
jle 0x3607e
movq 0x10(%rsp), %rax
leaq (%rax,%rax,2), %r13
xorl %r15d, %r15d
movl $0x100, %edi            # imm = 0x100
callq 0x3030
movsd 0x3764(%rip), %xmm1     # 0x39710
movq %rax, %rbp
movq 0x8(%rsp), %rax
movq 0x2de8(%rax), %rax
movq (%rax,%r12,8), %rax
movq (%rax,%r13,8), %rax
movsd (%rax,%r15,8), %xmm0
mulsd %xmm1, %xmm0
callq 0x1aa2c
movsd 0x3736(%rip), %xmm1     # 0x39710
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd %xmm1, %xmm0
movq %rbp, %rdi
leaq 0x3a8a(%rip), %rsi      # 0x39a79
movb $0x1, %al
callq 0x3080
leaq 0xc8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq %rbp, %rdi
callq 0x3140
movq %rbp, %rdx
addq %rax, %rdx
leaq 0xb8(%rsp), %rdi
movq %rbp, %rsi
callq 0x6e56
movq %rbp, %rdi
callq 0x33f0
movl $0x1, %edx
movq %r14, %rdi
leaq 0x1255(%rip), %rsi      # 0x37290
callq 0x3390
movq 0xb8(%rsp), %rsi
movq 0xc0(%rsp), %rdx
movq %r14, %rdi
callq 0x3390
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x36072
callq 0x3310
incq %r15
cmpq %r15, %rbx
jne 0x35f9a
movl $0x1, %edx
movq %r14, %rdi
leaq 0x1895(%rip), %rsi      # 0x37922
callq 0x3390
movq 0x10(%rsp), %r15
incq %r15
movq 0x8(%rsp), %rcx
movq 0x2c88(%rcx), %rax
movq 0x2c90(%rcx), %rcx
subq %rax, %rcx
shrq $0x5, %rcx
movslq %ecx, %rcx
cmpq %rcx, %r15
jl 0x35f37
movq %r14, %rdi
callq 0x31f0
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x360df
callq 0x3310
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq 0xb8(%rsp), %rdi
callq 0x3440
jmp 0x36106
movq %rax, %r14
movq 0x98(%rsp), %rdi
cmpq %rbx, %rdi
jne 0x3617b
jmp 0x36180
jmp 0x3615e
movq %rax, %r14
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x36132
callq 0x3310
jmp 0x36132
movq %rax, %r14
movq 0x38(%rsp), %rdi
cmpq %rbp, %rdi
je 0x36148
callq 0x3310
jmp 0x36148
jmp 0x36145
movq %rax, %r14
movq 0x58(%rsp), %rdi
cmpq %r13, %rdi
jne 0x3617b
jmp 0x36180
jmp 0x3615e
jmp 0x3615e
jmp 0x3615e
jmp 0x3615e
jmp 0x3615e
movq %rax, %r14
jmp 0x36180
movq %rax, %r14
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x36180
callq 0x3310
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x36197
callq 0x3310
movq %r14, %rdi
callq 0x3580