// File: /workspace/github_cpp_makefile_star2_O3/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
movl 0x68(%rsp,%rax), %eax
testb $0x5, %al
je 0x6a4c
xorl %edi, %edi
callq 0x2130
movq 0x48(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x68(%rsp,%rax), %eax
testb $0x5, %al
jne 0x6a17
leaq 0x49ba(%rip), %rsi      # 0xb411
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 0x4974(%rip), %rsi      # 0xb41c
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 0x4929(%rip), %rsi      # 0xb422
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 0x48bf(%rip), %rsi      # 0xb42a
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 0x46ad(%rip), %r13      # 0xb269
leaq 0x28(%rsp), %rbp
movq (%rsp), %r12
movq (%r12), %r12
cmpq (%rsp), %r12
je 0x7040
movl $0x5, %edx
movq %r14, %rdi
leaq 0x484f(%rip), %rsi      # 0xb431
callq 0x2210
movq 0x10(%r12), %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(%r12), %rax
cmpb $0x0, 0x58(%rax)
leaq 0x480f(%rip), %rsi      # 0xb440
leaq 0x47ff(%rip), %rax      # 0xb437
cmovneq %rax, %rsi
movl $0x8, %edx
movq %r14, %rdi
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 0x47c8(%rip), %rsi      # 0xb449
callq 0x2210
movq 0x10(%r12), %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 0x4785(%rip), %rsi      # 0xb454
callq 0x2210
movq 0x10(%r12), %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      # 0xb45a
callq 0x2210
movq 0x10(%r12), %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 0x46f3(%rip), %rsi      # 0xb460
callq 0x2210
movq 0x10(%r12), %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(%r12), %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 0x466b(%rip), %rsi      # 0xb467
callq 0x2210
movq 0x10(%r12), %rax
movq 0x80(%rax), %rax
movsd (%rax), %xmm0
movq %r14, %rdi
callq 0x22c0
movq 0x10(%r12), %rax
cmpl $0x2, 0x34(%rax)
jl 0x6e81
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(%r12), %rax
movq 0x80(%rax), %rax
movsd (%rax,%rbx,8), %xmm0
movq %r14, %rdi
callq 0x22c0
incq %rbx
movq 0x10(%r12), %rax
movslq 0x34(%rax), %rax
cmpq %rax, %rbx
jl 0x6e29
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 0x459b(%rip), %rsi      # 0xb472
callq 0x2210
movq 0x10(%r12), %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(%r12), %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(%r12), %r15
movq (%r15), %r15
cmpq 0x10(%r12), %r15
je 0x7012
movl $0x6, %edx
movq %r14, %rdi
leaq 0x4519(%rip), %rsi      # 0xb478
callq 0x2210
movq 0x10(%r15), %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(%r15), %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(%r15), %rsi
movq %rbp, %rdi
callq 0x70ec
leaq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0x2230
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x6ffb
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rdi
callq 0x2210
jmp 0x6f42
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 0x6bc5
leaq 0x48(%rsp), %rdi
callq 0x2260
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x7066
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x6f6b(%rip), %rax      # 0xdfd8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x140(%rsp), %rbx
movq %rcx, -0xf8(%rbx)
movq -0x18(%rcx), %rcx
movq %rax, 0x48(%rsp,%rcx)
leaq 0x50(%rsp), %rdi
callq 0x2170
movq %rbx, %rdi
callq 0x2090
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x70ba
jmp 0x70ba
jmp 0x70ba
jmp 0x70ba
jmp 0x70ba
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x70d9
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x48(%rsp), %rdi
callq 0x2280
movq %rbx, %rdi
callq 0x2300
nop