// File: 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:
subq $0x448, %rsp            # imm = 0x448
movq %rsi, 0x190(%rsp)
movq %rdi, 0x440(%rsp)
movq %rsi, 0x438(%rsp)
movq 0x440(%rsp), %rax
movq %rax, 0x198(%rsp)
leaq 0x238(%rsp), %rdi
callq 0x3400
leaq 0x210(%rsp), %rdi
callq 0x3350
leaq 0x208(%rsp), %rdi
callq 0x7cb0
leaq 0x200(%rsp), %rdi
callq 0x7ce0
movq 0x190(%rsp), %rdi
callq 0x30e0
movq %rax, 0x180(%rsp)
movl $0x10, %edi
movl $0x20, %esi
callq 0x7f30
movl %eax, 0x18c(%rsp)
jmp 0xbad0
movl 0x18c(%rsp), %edx
movq 0x180(%rsp), %rsi
leaq 0x238(%rsp), %rdi
callq 0x3040
jmp 0xbaee
movq 0x238(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x238(%rsp,%rax), %rdi
callq 0x3110
movb %al, 0x17f(%rsp)
jmp 0xbb10
movb 0x17f(%rsp), %al
testb $0x1, %al
jne 0xbb1d
jmp 0xbb5b
xorl %edi, %edi
callq 0x31c0
jmp 0xbb26
jmp 0xbb5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1f8(%rsp)
movl %eax, 0x1f4(%rsp)
leaq 0x210(%rsp), %rdi
callq 0x3160
leaq 0x238(%rsp), %rdi
callq 0x33a0
jmp 0xc48f
jmp 0xbb5d
movq 0x238(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x238(%rsp,%rax), %rdi
callq 0x3110
movb %al, 0x17e(%rsp)
jmp 0xbb7f
movb 0x17e(%rsp), %al
testb $0x1, %al
jne 0xbaa3
jmp 0xbb90
leaq 0x975a(%rip), %rsi      # 0x152f1
leaq 0x238(%rsp), %rdi
callq 0x3280
movq %rax, 0x170(%rsp)
jmp 0xbbae
movq 0x170(%rsp), %rdi
movq 0x198(%rsp), %rax
movl 0x20(%rax), %esi
callq 0x3410
movq %rax, 0x168(%rsp)
jmp 0xbbd0
movq 0x168(%rsp), %rdi
movq 0xe3f1(%rip), %rsi      # 0x19fd0
callq 0x32c0
jmp 0xbbe6
leaq 0x970f(%rip), %rsi      # 0x152fc
leaq 0x238(%rsp), %rdi
callq 0x3280
movq %rax, 0x160(%rsp)
jmp 0xbc04
movq 0x160(%rsp), %rdi
movq 0x198(%rsp), %rax
movl 0x24(%rax), %esi
callq 0x3410
movq %rax, 0x158(%rsp)
jmp 0xbc26
movq 0x158(%rsp), %rdi
movq 0xe39b(%rip), %rsi      # 0x19fd0
callq 0x32c0
jmp 0xbc3c
leaq 0x96bf(%rip), %rsi      # 0x15302
leaq 0x238(%rsp), %rdi
callq 0x3280
movq %rax, 0x150(%rsp)
jmp 0xbc5a
movq 0x150(%rsp), %rdi
movq 0x198(%rsp), %rax
movl 0x28(%rax), %esi
callq 0x3410
movq %rax, 0x148(%rsp)
jmp 0xbc7c
movq 0x148(%rsp), %rdi
movq 0xe345(%rip), %rsi      # 0x19fd0
callq 0x32c0
jmp 0xbc92
leaq 0x70a7(%rip), %rsi      # 0x12d40
leaq 0x238(%rsp), %rdi
callq 0x30b0
movq %rax, 0x140(%rsp)
jmp 0xbcb0
movl $0x11, %edi
callq 0x12d60
movl %eax, 0x13c(%rsp)
jmp 0xbcc3
movq 0x140(%rsp), %rdi
movl 0x13c(%rsp), %eax
movl %eax, 0x1f0(%rsp)
movl 0x1f0(%rsp), %esi
callq 0x33d0
movq %rax, 0x130(%rsp)
jmp 0xbcef
movq 0x130(%rsp), %rdi
leaq 0x960c(%rip), %rsi      # 0x1530a
callq 0x3280
movq %rax, 0x128(%rsp)
jmp 0xbd0d
movq 0x128(%rsp), %rdi
movq 0x198(%rsp), %rax
movsd 0x48(%rax), %xmm0
callq 0x3490
movq %rax, 0x120(%rsp)
jmp 0xbd31
movq 0x120(%rsp), %rdi
movq 0xe290(%rip), %rsi      # 0x19fd0
callq 0x32c0
jmp 0xbd47
movq 0x198(%rsp), %rdi
callq 0x7e70
movq %rax, 0x1e8(%rsp)
movq 0x1e8(%rsp), %rax
movq %rax, 0x208(%rsp)
movq 0x198(%rsp), %rdi
callq 0x7ec0
movq %rax, 0x1e0(%rsp)
leaq 0x208(%rsp), %rdi
leaq 0x1e0(%rsp), %rsi
callq 0x7ea0
testb $0x1, %al
jne 0xbd9f
jmp 0xc45e
leaq 0x956b(%rip), %rsi      # 0x15311
leaq 0x238(%rsp), %rdi
callq 0x3280
movq %rax, 0x118(%rsp)
jmp 0xbdbd
leaq 0x208(%rsp), %rdi
callq 0x7ef0
movq 0x118(%rsp), %rdi
movq (%rax), %rax
movl 0x30(%rax), %esi
callq 0x3410
movq %rax, 0x110(%rsp)
jmp 0xbde7
movq 0x110(%rsp), %rdi
movq 0xe1da(%rip), %rsi      # 0x19fd0
callq 0x32c0
jmp 0xbdfd
leaq 0x208(%rsp), %rdi
callq 0x7ef0
movq (%rax), %rax
testb $0x1, 0x58(%rax)
je 0xbe49
leaq 0x94fd(%rip), %rsi      # 0x15317
leaq 0x238(%rsp), %rdi
callq 0x3280
movq %rax, 0x108(%rsp)
jmp 0xbe31
movq 0x108(%rsp), %rdi
movq 0xe190(%rip), %rsi      # 0x19fd0
callq 0x32c0
jmp 0xbe47
jmp 0xbe7f
leaq 0x94d0(%rip), %rsi      # 0x15320
leaq 0x238(%rsp), %rdi
callq 0x3280
movq %rax, 0x100(%rsp)
jmp 0xbe67
movq 0x100(%rsp), %rdi
movq 0xe15a(%rip), %rsi      # 0x19fd0
callq 0x32c0
jmp 0xbe7d
jmp 0xbe7f
leaq 0x94a3(%rip), %rsi      # 0x15329
leaq 0x238(%rsp), %rdi
callq 0x3280
movq %rax, 0xf8(%rsp)
jmp 0xbe9d
leaq 0x208(%rsp), %rdi
callq 0x7ef0
movq 0xf8(%rsp), %rdi
movq (%rax), %rax
movl 0x34(%rax), %esi
callq 0x3410
movq %rax, 0xf0(%rsp)
jmp 0xbec7
movq 0xf0(%rsp), %rdi
movq 0xe0fa(%rip), %rsi      # 0x19fd0
callq 0x32c0
jmp 0xbedd
leaq 0x9450(%rip), %rsi      # 0x15334
leaq 0x238(%rsp), %rdi
callq 0x3280
movq %rax, 0xe8(%rsp)
jmp 0xbefb
leaq 0x208(%rsp), %rdi
callq 0x7ef0
movq 0xe8(%rsp), %rdi
movq (%rax), %rax
movl 0x38(%rax), %esi
callq 0x3410
movq %rax, 0xe0(%rsp)
jmp 0xbf25
movq 0xe0(%rsp), %rdi
movq 0xe09c(%rip), %rsi      # 0x19fd0
callq 0x32c0
jmp 0xbf3b
leaq 0x93f8(%rip), %rsi      # 0x1533a
leaq 0x238(%rsp), %rdi
callq 0x3280
movq %rax, 0xd8(%rsp)
jmp 0xbf59
leaq 0x208(%rsp), %rdi
callq 0x7ef0
movq 0xd8(%rsp), %rdi
movq (%rax), %rax
movsd 0x40(%rax), %xmm0
callq 0x3490
movq %rax, 0xd0(%rsp)
jmp 0xbf85
movq 0xd0(%rsp), %rdi
movq 0xe03c(%rip), %rsi      # 0x19fd0
callq 0x32c0
jmp 0xbf9b
leaq 0x939e(%rip), %rsi      # 0x15340
leaq 0x238(%rsp), %rdi
callq 0x3280
movq %rax, 0xc8(%rsp)
jmp 0xbfb9
leaq 0x208(%rsp), %rdi
callq 0x7ef0
movq 0xc8(%rsp), %rdi
movq (%rax), %rax
movl 0x48(%rax), %esi
callq 0x3410
movq %rax, 0xc0(%rsp)
jmp 0xbfe3
movq 0xc0(%rsp), %rdi
leaq 0x916f(%rip), %rsi      # 0x15161
callq 0x3280
movq %rax, 0xb8(%rsp)
jmp 0xc001
leaq 0x208(%rsp), %rdi
callq 0x7ef0
movq 0xb8(%rsp), %rdi
movq (%rax), %rax
movl 0x4c(%rax), %esi
callq 0x3410
movq %rax, 0xb0(%rsp)
jmp 0xc02b
movq 0xb0(%rsp), %rdi
movq 0xdf96(%rip), %rsi      # 0x19fd0
callq 0x32c0
jmp 0xc041
leaq 0x6cf8(%rip), %rsi      # 0x12d40
leaq 0x238(%rsp), %rdi
callq 0x30b0
movq %rax, 0xa8(%rsp)
jmp 0xc05f
movl $0x11, %edi
callq 0x12d60
movl %eax, 0xa4(%rsp)
jmp 0xc072
movq 0xa8(%rsp), %rdi
movl 0xa4(%rsp), %eax
movl %eax, 0x1dc(%rsp)
movl 0x1dc(%rsp), %esi
callq 0x33d0
movq %rax, 0x98(%rsp)
jmp 0xc09e
movq 0x98(%rsp), %rdi
leaq 0x929a(%rip), %rsi      # 0x15347
callq 0x3280
movq %rax, 0x90(%rsp)
jmp 0xc0bc
leaq 0x208(%rsp), %rdi
callq 0x7ef0
movq 0x90(%rsp), %rdi
movq (%rax), %rax
movq 0x80(%rax), %rax
movsd (%rax), %xmm0
callq 0x3490
jmp 0xc0e6
movl $0x1, 0x234(%rsp)
movl 0x234(%rsp), %eax
movl %eax, 0x8c(%rsp)
leaq 0x208(%rsp), %rdi
callq 0x7ef0
movq %rax, %rcx
movl 0x8c(%rsp), %eax
movq (%rcx), %rcx
cmpl 0x34(%rcx), %eax
jge 0xc1d6
leaq 0x6c17(%rip), %rsi      # 0x12d40
leaq 0x238(%rsp), %rdi
callq 0x30b0
movq %rax, 0x80(%rsp)
jmp 0xc140
movl $0x11, %edi
callq 0x12d60
movl %eax, 0x7c(%rsp)
jmp 0xc150
movq 0x80(%rsp), %rdi
movl 0x7c(%rsp), %eax
movl %eax, 0x1d8(%rsp)
movl 0x1d8(%rsp), %esi
callq 0x33d0
movq %rax, 0x70(%rsp)
jmp 0xc176
movq 0x70(%rsp), %rdi
leaq 0x8fdf(%rip), %rsi      # 0x15161
callq 0x3280
movq %rax, 0x68(%rsp)
jmp 0xc18e
leaq 0x208(%rsp), %rdi
callq 0x7ef0
movq 0x68(%rsp), %rdi
movq (%rax), %rax
movq 0x80(%rax), %rax
movslq 0x234(%rsp), %rcx
movsd (%rax,%rcx,8), %xmm0
callq 0x3490
jmp 0xc1be
jmp 0xc1c0
movl 0x234(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x234(%rsp)
jmp 0xc0f1
movq 0xddf3(%rip), %rsi      # 0x19fd0
leaq 0x238(%rsp), %rdi
callq 0x32c0
jmp 0xc1ec
leaq 0x6b4d(%rip), %rsi      # 0x12d40
leaq 0x238(%rsp), %rdi
callq 0x30b0
movq %rax, 0x60(%rsp)
jmp 0xc207
movl $0x11, %edi
callq 0x12d60
movl %eax, 0x5c(%rsp)
jmp 0xc217
movq 0x60(%rsp), %rdi
movl 0x5c(%rsp), %eax
movl %eax, 0x1d4(%rsp)
movl 0x1d4(%rsp), %esi
callq 0x33d0
movq %rax, 0x50(%rsp)
jmp 0xc23a
movq 0x50(%rsp), %rdi
leaq 0x910c(%rip), %rsi      # 0x15352
callq 0x3280
movq %rax, 0x48(%rsp)
jmp 0xc252
leaq 0x208(%rsp), %rdi
callq 0x7ef0
movq 0x48(%rsp), %rdi
movq (%rax), %rax
movsd 0x68(%rax), %xmm0
callq 0x3490
movq %rax, 0x40(%rsp)
jmp 0xc278
movq 0x40(%rsp), %rdi
leaq 0x8edd(%rip), %rsi      # 0x15161
callq 0x3280
movq %rax, 0x38(%rsp)
jmp 0xc290
leaq 0x208(%rsp), %rdi
callq 0x7ef0
movq 0x38(%rsp), %rdi
movq (%rax), %rax
movsd 0x70(%rax), %xmm0
callq 0x3490
movq %rax, 0x30(%rsp)
jmp 0xc2b6
movq 0x30(%rsp), %rdi
movq 0xdd0e(%rip), %rsi      # 0x19fd0
callq 0x32c0
jmp 0xc2c9
leaq 0x208(%rsp), %rdi
callq 0x7ef0
movq (%rax), %rdi
callq 0x8810
movq %rax, 0x1c8(%rsp)
movq 0x1c8(%rsp), %rax
movq %rax, 0x200(%rsp)
leaq 0x208(%rsp), %rdi
callq 0x7ef0
movq (%rax), %rdi
callq 0x8860
movq %rax, 0x1c0(%rsp)
leaq 0x200(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
callq 0x8840
testb $0x1, %al
jne 0xc331
jmp 0xc434
leaq 0x9020(%rip), %rsi      # 0x15358
leaq 0x238(%rsp), %rdi
callq 0x3280
movq %rax, 0x28(%rsp)
jmp 0xc34c
leaq 0x200(%rsp), %rdi
callq 0x8890
movq 0x28(%rsp), %rdi
movq (%rax), %rax
movq 0x10(%rax), %rax
movl (%rax), %esi
callq 0x3410
movq %rax, 0x20(%rsp)
jmp 0xc373
movq 0x20(%rsp), %rdi
leaq 0x8de2(%rip), %rsi      # 0x15161
callq 0x3280
movq %rax, 0x18(%rsp)
jmp 0xc38b
leaq 0x200(%rsp), %rdi
callq 0x8890
movq 0x18(%rsp), %rdi
movq (%rax), %rax
movq 0x10(%rax), %rax
movl 0x4(%rax), %esi
callq 0x3410
movq %rax, 0x10(%rsp)
jmp 0xc3b3
movq 0x10(%rsp), %rdi
movq 0xdc11(%rip), %rsi      # 0x19fd0
callq 0x32c0
jmp 0xc3c6
leaq 0x200(%rsp), %rdi
callq 0x8890
movq (%rax), %rsi
leaq 0x1a0(%rsp), %rdi
callq 0xc4a0
jmp 0xc3e5
leaq 0x210(%rsp), %rdi
movq %rdi, 0x8(%rsp)
leaq 0x1a0(%rsp), %rsi
movq %rsi, (%rsp)
callq 0x3320
movq (%rsp), %rdi
callq 0x3160
movq 0x8(%rsp), %rsi
leaq 0x238(%rsp), %rdi
callq 0x3240
jmp 0xc420
jmp 0xc422
leaq 0x200(%rsp), %rdi
callq 0x88b0
jmp 0xc2f6
movq 0xdb95(%rip), %rsi      # 0x19fd0
leaq 0x238(%rsp), %rdi
callq 0x32c0
jmp 0xc44a
jmp 0xc44c
leaq 0x208(%rsp), %rdi
callq 0x7f10
jmp 0xbd6c
leaq 0x238(%rsp), %rdi
callq 0x3370
jmp 0xc46d
leaq 0x210(%rsp), %rdi
callq 0x3160
leaq 0x238(%rsp), %rdi
callq 0x33a0
addq $0x448, %rsp            # imm = 0x448
retq
movq 0x1f8(%rsp), %rdi
callq 0x3430
nopl (%rax)