// File: /workspace/github_cpp_makefile_star2_O2/pgrouchy[P]NoiseWorld/mathNet.cpp
// Function: Population::savePop(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void Population::savePop(string myFilename) {
    ofstream myFile;
    int i;
    string treeString;
    list<Genome*>::iterator curGenome;
    list<Tree*>::iterator curTree;

    do {
        myFile.open(myFilename.c_str(), ios::out | ios::trunc);
        if (!myFile)
            sleep(0.1);
    } while (!myFile);

    // Population data
    myFile << "Timestep: " << this->gen << endl;
    myFile << "Isl: " << this->my_isl_id << endl;
    myFile << "MaxID: " << this->max_tree_id << endl;
    myFile << showpoint << setprecision(numeric_limits<double>::digits10 + 2) << "beta: " << this->beta << endl;

    // Agent & agent genome data
    for (curGenome = this->genomes.begin(); curGenome != this->genomes.end(); ++curGenome) {
        myFile << "Pop: " << (*curGenome)->pop_id << endl;
        if ((*curGenome)->is_alive) {
            myFile << "Alive: 1" << endl;
        } else {
            myFile << "Alive: 0" << endl;
        }
        myFile << "NumTrees: " << (*curGenome)->num_trees << endl;
        myFile << "Fit: " << (*curGenome)->fitness << endl;
        myFile << "Age: " << (*curGenome)->age << endl;
        myFile << "Grid: " << (*curGenome)->mainGridLocation[0] << "," << (*curGenome)->mainGridLocation[1] << endl;
        myFile << showpoint << setprecision(numeric_limits<double>::digits10 + 2) << "InitVals: " << (*curGenome)->initialVal[0];
        for (i = 1; i < (*curGenome)->num_trees; i++) {
            myFile << showpoint << setprecision(numeric_limits<double>::digits10 + 2) << "," << (*curGenome)->initialVal[i];
        }
        myFile << endl;
        myFile << showpoint << setprecision(numeric_limits<double>::digits10 + 2) << "Pos: " << (*curGenome)->myPosition[0] << "," << (*curGenome)->myPosition[1] << endl;

        // tree data
        for (curTree = (*curGenome)->trees.begin(); curTree != (*curGenome)->trees.end(); ++curTree) {
            myFile << "Tree: " << (*curTree)->tree_id->islandID << "," << (*curTree)->tree_id->myID << endl;
            treeString = (*curTree)->getTreeString();
            myFile << treeString;
        }
        myFile << endl;
    }

    myFile.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq %rsi, %r14
movq %rdi, (%rsp)
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x22f0
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
pushq $0x30
popq %rbp
movq (%r14), %rsi
movq %r15, %rdi
movl %ebp, %edx
callq 0x2040
movq 0x28(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x48(%rsp,%rax), %eax
testb $0x5, %al
je 0x5945
xorl %edi, %edi
callq 0x2130
movq 0x28(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x48(%rsp,%rax), %eax
testb $0x5, %al
jne 0x5913
leaq 0x4a61(%rip), %rsi      # 0xa3b1
leaq 0x28(%rsp), %rdi
callq 0x21d0
movq (%rsp), %rcx
movl 0x20(%rcx), %esi
movq %rax, %rdi
callq 0x2300
movq %rax, %rdi
callq 0x20c0
leaq 0x4a44(%rip), %rsi      # 0xa3bc
leaq 0x28(%rsp), %rdi
callq 0x21d0
movq (%rsp), %rcx
movl 0x24(%rcx), %esi
movq %rax, %rdi
callq 0x2300
movq %rax, %rdi
callq 0x20c0
leaq 0x4a22(%rip), %rsi      # 0xa3c2
leaq 0x28(%rsp), %rdi
callq 0x21d0
movq (%rsp), %rcx
movl 0x28(%rcx), %esi
movq %rax, %rdi
callq 0x2300
movq %rax, %rdi
callq 0x20c0
leaq 0x28(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rcx
orl $0x400, 0x40(%rsp,%rcx) # imm = 0x400
movq -0x18(%rax), %rax
movq $0x11, 0x30(%rsp,%rax)
leaq 0x49e1(%rip), %rsi      # 0xa3ca
callq 0x21d0
movq (%rsp), %rcx
movsd 0x48(%rcx), %xmm0
movq %rax, %rdi
callq 0x22d0
movq %rax, %rdi
callq 0x20c0
leaq 0x28(%rsp), %r15
leaq 0x47f6(%rip), %r12      # 0xa209
leaq 0x228(%rsp), %r13
leaq 0x8(%rsp), %rbp
movq (%rsp), %rbx
movq (%rbx), %rbx
cmpq (%rsp), %rbx
je 0x5cc8
movq %r15, %rdi
leaq 0x4996(%rip), %rsi      # 0xa3d1
callq 0x21d0
movq 0x10(%rbx), %rcx
movl 0x30(%rcx), %esi
movq %rax, %rdi
callq 0x2300
movq %rax, %rdi
callq 0x20c0
movq 0x10(%rbx), %rax
cmpb $0x0, 0x58(%rax)
leaq 0x497a(%rip), %rsi      # 0xa3e0
leaq 0x496a(%rip), %rax      # 0xa3d7
cmovneq %rax, %rsi
movq %r15, %rdi
callq 0x21d0
movq %rax, %rdi
callq 0x20c0
movq %r15, %rdi
leaq 0x495e(%rip), %rsi      # 0xa3e9
callq 0x21d0
movq 0x10(%rbx), %rcx
movl 0x34(%rcx), %esi
movq %rax, %rdi
callq 0x2300
movq %rax, %rdi
callq 0x20c0
movq %r15, %rdi
leaq 0x4943(%rip), %rsi      # 0xa3f4
callq 0x21d0
movq 0x10(%rbx), %rcx
movl 0x38(%rcx), %esi
movq %rax, %rdi
callq 0x2300
movq %rax, %rdi
callq 0x20c0
movq %r15, %rdi
leaq 0x4923(%rip), %rsi      # 0xa3fa
callq 0x21d0
movq 0x10(%rbx), %rcx
movsd 0x40(%rcx), %xmm0
movq %rax, %rdi
callq 0x22d0
movq %rax, %rdi
callq 0x20c0
movq %r15, %rdi
leaq 0x4901(%rip), %rsi      # 0xa400
callq 0x21d0
movq 0x10(%rbx), %rcx
movl 0x48(%rcx), %esi
movq %rax, %rdi
callq 0x2300
movq %rax, %rdi
movq %r12, %rsi
callq 0x21d0
movq 0x10(%rbx), %rcx
movl 0x4c(%rcx), %esi
movq %rax, %rdi
callq 0x2300
movq %rax, %rdi
callq 0x20c0
movq 0x28(%rsp), %rax
movq -0x18(%rax), %rcx
orl $0x400, 0x40(%rsp,%rcx) # imm = 0x400
movq -0x18(%rax), %rax
movq $0x11, 0x30(%rsp,%rax)
movq %r15, %rdi
leaq 0x48aa(%rip), %rsi      # 0xa407
callq 0x21d0
movq 0x10(%rbx), %rcx
movq 0x80(%rcx), %rcx
movsd (%rcx), %xmm0
movq %rax, %rdi
callq 0x22d0
pushq $0x1
popq %r14
movq 0x10(%rbx), %rax
movslq 0x34(%rax), %rax
cmpq %rax, %r14
jge 0x5bd1
movq 0x28(%rsp), %rax
movq -0x18(%rax), %rcx
orl $0x400, 0x40(%rsp,%rcx) # imm = 0x400
movq -0x18(%rax), %rax
movq $0x11, 0x30(%rsp,%rax)
movq %r15, %rdi
movq %r12, %rsi
callq 0x21d0
movq 0x10(%rbx), %rcx
movq 0x80(%rcx), %rcx
movsd (%rcx,%r14,8), %xmm0
movq %rax, %rdi
callq 0x22d0
incq %r14
jmp 0x5b7d
movq %r15, %rdi
callq 0x20c0
movq 0x28(%rsp), %rax
movq -0x18(%rax), %rcx
orl $0x400, 0x40(%rsp,%rcx) # imm = 0x400
movq -0x18(%rax), %rax
movq $0x11, 0x30(%rsp,%rax)
movq %r15, %rdi
leaq 0x4811(%rip), %rsi      # 0xa412
callq 0x21d0
movq 0x10(%rbx), %rcx
movsd 0x68(%rcx), %xmm0
movq %rax, %rdi
callq 0x22d0
movq %rax, %rdi
movq %r12, %rsi
callq 0x21d0
movq 0x10(%rbx), %rcx
movsd 0x70(%rcx), %xmm0
movq %rax, %rdi
callq 0x22d0
movq %rax, %rdi
callq 0x20c0
movq 0x10(%rbx), %r14
movq (%r14), %r14
cmpq 0x10(%rbx), %r14
je 0x5cbb
movq %r15, %rdi
leaq 0x47c6(%rip), %rsi      # 0xa418
callq 0x21d0
movq 0x10(%r14), %rcx
movq 0x10(%rcx), %rcx
movl (%rcx), %esi
movq %rax, %rdi
callq 0x2300
movq %rax, %rdi
movq %r12, %rsi
callq 0x21d0
movq 0x10(%r14), %rcx
movq 0x10(%rcx), %rcx
movl 0x4(%rcx), %esi
movq %rax, %rdi
callq 0x2300
movq %rax, %rdi
callq 0x20c0
movq 0x10(%r14), %rsi
movq %r13, %rdi
callq 0x5d22
movq %rbp, %rdi
movq %r13, %rsi
callq 0x2220
movq %r13, %rdi
callq 0x20b0
movq %r15, %rdi
movq %rbp, %rsi
callq 0x21a0
jmp 0x5c3f
movq %r15, %rdi
callq 0x20c0
jmp 0x5a24
leaq 0x28(%rsp), %rdi
callq 0x2270
leaq 0x8(%rsp), %rdi
callq 0x20b0
leaq 0x28(%rsp), %rdi
callq 0x2290
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5d02
jmp 0x5d02
jmp 0x5d02
jmp 0x5d02
jmp 0x5d02
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x20b0
leaq 0x28(%rsp), %rdi
callq 0x2290
movq %rbx, %rdi
callq 0x2310
nop