// File: /workspace/github_cpp_makefile_star2_O1/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 0x48(%rsp), %r15
movq %r15, %rdi
callq 0x22e0
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq (%r14), %rsi
movq %r15, %rdi
movl $0x30, %edx
callq 0x2050
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x68(%rsp,%rax)
je 0x6a28
xorl %edi, %edi
callq 0x2130
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x68(%rsp,%rax)
jne 0x6a01
leaq 0x49c2(%rip), %rsi      # 0xb401
leaq 0x48(%rsp), %rdi
movl $0xa, %edx
callq 0x2210
movq (%rsp), %rax
movl 0x20(%rax), %esi
leaq 0x48(%rsp), %rdi
callq 0x22f0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
leaq 0x497c(%rip), %rsi      # 0xb40c
leaq 0x48(%rsp), %rdi
movl $0x5, %edx
callq 0x2210
movq (%rsp), %rax
movl 0x24(%rax), %esi
leaq 0x48(%rsp), %rdi
callq 0x22f0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
leaq 0x4931(%rip), %rsi      # 0xb412
leaq 0x48(%rsp), %rdi
movl $0x7, %edx
callq 0x2210
movq (%rsp), %rax
movl 0x28(%rax), %esi
leaq 0x48(%rsp), %rdi
callq 0x22f0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
leaq 0x48(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rcx
orl $0x400, 0x60(%rsp,%rcx) # imm = 0x400
movq -0x18(%rax), %rax
movq $0x11, 0x50(%rsp,%rax)
leaq 0x48c7(%rip), %rsi      # 0xb41a
movl $0x6, %edx
callq 0x2210
movq (%rsp), %rax
movsd 0x48(%rax), %xmm0
leaq 0x48(%rsp), %r14
movq %r14, %rdi
callq 0x22c0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
leaq 0x46b5(%rip), %r13      # 0xb259
leaq 0x28(%rsp), %rbp
movq (%rsp), %r15
movq (%r15), %r15
cmpq (%rsp), %r15
je 0x7029
movl $0x5, %edx
movq %r14, %rdi
leaq 0x4858(%rip), %rsi      # 0xb421
callq 0x2210
movq 0x10(%r15), %rax
movl 0x30(%rax), %esi
movq %r14, %rdi
callq 0x22f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
movq 0x10(%r15), %rax
cmpb $0x1, 0x58(%rax)
jne 0x6c27
movl $0x8, %edx
movq %r14, %rdi
leaq 0x4807(%rip), %rsi      # 0xb427
callq 0x2210
jmp 0x6c3b
movl $0x8, %edx
movq %r14, %rdi
leaq 0x47fa(%rip), %rsi      # 0xb430
callq 0x2210
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
movl $0xa, %edx
movq %r14, %rdi
leaq 0x47c6(%rip), %rsi      # 0xb439
callq 0x2210
movq 0x10(%r15), %rax
movl 0x34(%rax), %esi
movq %r14, %rdi
callq 0x22f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
movl $0x5, %edx
movq %r14, %rdi
leaq 0x4784(%rip), %rsi      # 0xb444
callq 0x2210
movq 0x10(%r15), %rax
movl 0x38(%rax), %esi
movq %r14, %rdi
callq 0x22f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
movl $0x5, %edx
movq %r14, %rdi
leaq 0x473d(%rip), %rsi      # 0xb44a
callq 0x2210
movq 0x10(%r15), %rax
movsd 0x40(%rax), %xmm0
movq %r14, %rdi
callq 0x22c0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
movl $0x6, %edx
movq %r14, %rdi
leaq 0x46f4(%rip), %rsi      # 0xb450
callq 0x2210
movq 0x10(%r15), %rax
movl 0x48(%rax), %esi
movq %r14, %rdi
callq 0x22f0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2210
movq 0x10(%r15), %rax
movl 0x4c(%rax), %esi
movq %rbx, %rdi
callq 0x22f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rcx
orl $0x400, 0x60(%rsp,%rcx) # imm = 0x400
movq -0x18(%rax), %rax
movq $0x11, 0x50(%rsp,%rax)
movl $0xa, %edx
movq %r14, %rdi
leaq 0x466e(%rip), %rsi      # 0xb457
callq 0x2210
movq 0x10(%r15), %rax
movq 0x80(%rax), %rax
movsd (%rax), %xmm0
movq %r14, %rdi
callq 0x22c0
movq 0x10(%r15), %rax
cmpl $0x2, 0x34(%rax)
jl 0x6e6a
movl $0x1, %ebx
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rcx
orl $0x400, 0x60(%rsp,%rcx) # imm = 0x400
movq -0x18(%rax), %rax
movq $0x11, 0x50(%rsp,%rax)
movl $0x1, %edx
movq %r14, %rdi
movq %r13, %rsi
callq 0x2210
movq 0x10(%r15), %rax
movq 0x80(%rax), %rax
movsd (%rax,%rbx,8), %xmm0
movq %r14, %rdi
callq 0x22c0
incq %rbx
movq 0x10(%r15), %rax
movslq 0x34(%rax), %rax
cmpq %rax, %rbx
jl 0x6e14
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rcx
orl $0x400, 0x60(%rsp,%rcx) # imm = 0x400
movq -0x18(%rax), %rax
movq $0x11, 0x50(%rsp,%rax)
movl $0x5, %edx
movq %r14, %rdi
leaq 0x45a2(%rip), %rsi      # 0xb462
callq 0x2210
movq 0x10(%r15), %rax
movsd 0x68(%rax), %xmm0
movq %r14, %rdi
callq 0x22c0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2210
movq 0x10(%r15), %rax
movsd 0x70(%rax), %xmm0
movq %rbx, %rdi
callq 0x22c0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
movq 0x10(%r15), %r12
movq (%r12), %r12
cmpq 0x10(%r15), %r12
je 0x6ffb
movl $0x6, %edx
movq %r14, %rdi
leaq 0x4523(%rip), %rsi      # 0xb468
callq 0x2210
movq 0x10(%r12), %rax
movq 0x10(%rax), %rax
movl (%rax), %esi
movq %r14, %rdi
callq 0x22f0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2210
movq 0x10(%r12), %rax
movq 0x10(%rax), %rax
movl 0x4(%rax), %esi
movq %rbx, %rdi
callq 0x22f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
movq 0x10(%r12), %rsi
movq %rbp, %rdi
callq 0x70ce
leaq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0x2230
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x6fe4
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rdi
callq 0x2210
jmp 0x6f28
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
jmp 0x6bad
leaq 0x48(%rsp), %rdi
callq 0x2260
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x704f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x6f82(%rip), %rax      # 0xdfd8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x50(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x48(%rsp,%rcx)
callq 0x2170
leaq 0x140(%rsp), %rdi
callq 0x2090
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x709d
jmp 0x709d
jmp 0x709d
jmp 0x709d
jmp 0x709d
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x70bc
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x48(%rsp), %rdi
callq 0x2280
movq %rbx, %rdi
callq 0x2300