// File: ttalvitie[P]traveling-santa/optimize.cpp
// Function: writeOutput(std::vector<Path, std::allocator<Path>> const&)
void writeOutput(const vector<Path>& srcPaths) {
    vector<Path> paths(srcPaths.begin(), srcPaths.end());
    double cost = 0.0;
    for(Path& path : paths) {
        path.finalize();
        cost += path.cost;
    }
    Z score = (Z)round(cost);
    stringstream fnamess;
    fnamess << "output_" << score;
    string fname = fnamess.str();
    cout << "Writing " << fname << "\n";
    ofstream fp;
    fp.exceptions(fp.failbit | fp.badbit | fp.eofbit);
    fp.open(fname);
    for(const Path& path : paths) {
        bool first = true;
        for(const Point& point : path.points) {
            if(point.child != -1) {
                if(first) {
                    first = false;
                } else {
                    fp << ';';
                }
                fp << point.child;
            }
        }
        if(!first) {
            fp << '\n';
        }
    }
    fp.close();
}

// Assembly:
subq $0x4a8, %rsp            # imm = 0x4A8
movq %rdi, 0x4a0(%rsp)
movq 0x4a0(%rsp), %rdi
callq 0x9690
movq %rax, 0x480(%rsp)
movq 0x4a0(%rsp), %rdi
callq 0x96c0
movq %rax, 0x478(%rsp)
leaq 0x477(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x96f0
movq 0x38(%rsp), %rcx
movq 0x480(%rsp), %rsi
movq 0x478(%rsp), %rdx
leaq 0x488(%rsp), %rdi
callq 0x9700
jmp 0x491f
leaq 0x477(%rsp), %rdi
callq 0x9790
xorps %xmm0, %xmm0
movsd %xmm0, 0x458(%rsp)
leaq 0x488(%rsp), %rax
movq %rax, 0x450(%rsp)
movq 0x450(%rsp), %rdi
callq 0x97a0
movq %rax, 0x448(%rsp)
movq 0x450(%rsp), %rdi
callq 0x97d0
movq %rax, 0x440(%rsp)
leaq 0x448(%rsp), %rdi
leaq 0x440(%rsp), %rsi
callq 0x9800
testb $0x1, %al
jne 0x4990
jmp 0x4a21
leaq 0x448(%rsp), %rdi
callq 0x9840
movq %rax, 0x438(%rsp)
movq 0x438(%rsp), %rdi
callq 0x9250
jmp 0x49b4
movq 0x438(%rsp), %rax
movsd 0x18(%rax), %xmm0
addsd 0x458(%rsp), %xmm0
movsd %xmm0, 0x458(%rsp)
leaq 0x448(%rsp), %rdi
callq 0x9850
jmp 0x4972
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x468(%rsp)
movl %eax, 0x464(%rsp)
leaq 0x477(%rsp), %rdi
callq 0x9790
jmp 0x4d56
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x468(%rsp)
movl %eax, 0x464(%rsp)
jmp 0x4d49
movsd 0x458(%rsp), %xmm0
callq 0x30a0
cvttsd2si %xmm0, %rax
movq %rax, 0x430(%rsp)
leaq 0x2a8(%rsp), %rdi
callq 0x3150
jmp 0x4a4b
leaq 0x2b8(%rsp), %rdi
leaq 0xa64b(%rip), %rsi      # 0xf0a5
callq 0x3270
movq %rax, 0x30(%rsp)
jmp 0x4a66
movq 0x30(%rsp), %rdi
movq 0x430(%rsp), %rsi
callq 0x3100
jmp 0x4a7a
leaq 0x288(%rsp), %rdi
leaq 0x2a8(%rsp), %rsi
callq 0x3260
jmp 0x4a91
movq 0xe540(%rip), %rdi      # 0x12fd8
leaq 0xa60e(%rip), %rsi      # 0xf0ad
callq 0x3270
movq %rax, 0x28(%rsp)
jmp 0x4aab
movq 0x28(%rsp), %rdi
leaq 0x288(%rsp), %rsi
callq 0x3240
movq %rax, 0x20(%rsp)
jmp 0x4ac4
movq 0x20(%rsp), %rdi
leaq 0xa644(%rip), %rsi      # 0xf114
callq 0x3270
jmp 0x4ad7
leaq 0x88(%rsp), %rdi
callq 0x33e0
jmp 0x4ae6
movq 0x88(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0x88(%rsp,%rax), %rax
movq %rax, 0x10(%rsp)
movl $0x4, %edi
movl $0x1, %esi
callq 0x8e70
movl %eax, 0x1c(%rsp)
jmp 0x4b14
movl 0x1c(%rsp), %edi
movl $0x2, %esi
callq 0x8e70
movl %eax, 0xc(%rsp)
jmp 0x4b28
movl 0xc(%rsp), %esi
movq 0x10(%rsp), %rdi
callq 0x3070
jmp 0x4b38
leaq 0x88(%rsp), %rdi
leaq 0x288(%rsp), %rsi
movl $0x10, %edx
callq 0x30c0
jmp 0x4b54
leaq 0x488(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x80(%rsp), %rdi
callq 0x97a0
movq %rax, 0x78(%rsp)
movq 0x80(%rsp), %rdi
callq 0x97d0
movq %rax, 0x70(%rsp)
leaq 0x78(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x9800
testb $0x1, %al
jne 0x4ba0
jmp 0x4ce4
leaq 0x78(%rsp), %rdi
callq 0x9840
movq %rax, 0x68(%rsp)
movb $0x1, 0x67(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rdi
callq 0x9870
movq %rax, 0x50(%rsp)
movq 0x58(%rsp), %rdi
callq 0x98a0
movq %rax, 0x48(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x98d0
testb $0x1, %al
jne 0x4bf4
jmp 0x4cb6
leaq 0x50(%rsp), %rdi
callq 0x9910
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
cmpl $-0x1, (%rax)
je 0x4ca5
testb $0x1, 0x67(%rsp)
je 0x4c77
movb $0x0, 0x67(%rsp)
jmp 0x4c8d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x468(%rsp)
movl %eax, 0x464(%rsp)
jmp 0x4d3c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x468(%rsp)
movl %eax, 0x464(%rsp)
jmp 0x4d2f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x468(%rsp)
movl %eax, 0x464(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x3370
jmp 0x4d2f
leaq 0x88(%rsp), %rdi
movl $0x3b, %esi
callq 0x32e0
jmp 0x4c8b
jmp 0x4c8d
movq 0x40(%rsp), %rax
movl (%rax), %esi
leaq 0x88(%rsp), %rdi
callq 0x3400
jmp 0x4ca3
jmp 0x4ca5
jmp 0x4ca7
leaq 0x50(%rsp), %rdi
callq 0x9920
jmp 0x4bdc
testb $0x1, 0x67(%rsp)
jne 0x4cd3
leaq 0x88(%rsp), %rdi
movl $0xa, %esi
callq 0x32e0
jmp 0x4cd1
jmp 0x4cd3
jmp 0x4cd5
leaq 0x78(%rsp), %rdi
callq 0x9850
jmp 0x4b88
leaq 0x88(%rsp), %rdi
callq 0x3350
jmp 0x4cf3
leaq 0x88(%rsp), %rdi
callq 0x3370
leaq 0x288(%rsp), %rdi
callq 0x3130
leaq 0x2a8(%rsp), %rdi
callq 0x3180
leaq 0x488(%rsp), %rdi
callq 0x95d0
addq $0x4a8, %rsp            # imm = 0x4A8
retq
leaq 0x288(%rsp), %rdi
callq 0x3130
leaq 0x2a8(%rsp), %rdi
callq 0x3180
leaq 0x488(%rsp), %rdi
callq 0x95d0
movq 0x468(%rsp), %rdi
callq 0x3410
nopw %cs:(%rax,%rax)