// File: /workspace/github_cpp_makefile_star2_O1/Heptagon196[P]Gos/GosFileSystem.cpp
// Function: Gos::FileSystem::PackDirectory(std::filesystem::__cxx11::path, std::filesystem::__cxx11::path)
void Gos::FileSystem::PackDirectory(Path dir, Path saveTo) {
    std::ofstream fout;
    std::vector<Path> files;
    FileSystem::Iterate(dir, std::function([&files](Path path) {
        files.push_back(path);
    }));
    fout.open(saveTo);
    fout << files.size() << '\n';
    for (int i = 0; i < files.size(); i++) {
        std::string filename = files[i].string();
        for (auto ch : filename) {
            if (ch == '\\') {
                fout << '/';
            } else {
                fout << ch;
            }
        }
        fout << '\n';
        fout << std::filesystem::file_size(files[i]) << '\n';
    }
    for (int i = 0; i < files.size(); i++) {
        std::ifstream fin;
        fin.open(files[i], std::ios::binary);
        fout << fin.rdbuf();
        fin.close();
    }
    fout.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x488, %rsp            # imm = 0x488
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x288(%rsp), %rdi
callq 0x11540
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
leaq 0x58(%rsp), %rdi
movq %r14, %rsi
callq 0xb01c0
leaq 0x30(%rsp), %rsi
xorps %xmm0, %xmm0
movaps %xmm0, (%rsi)
movaps %xmm0, 0x10(%rsi)
leaq 0x10(%rsp), %rax
movq %rax, (%rsi)
leaq 0xaee(%rip), %rax       # 0xb2ed4
movq %rax, 0x18(%rsi)
leaq 0xb27(%rip), %rax       # 0xb2f18
movq %rax, 0x10(%rsi)
leaq 0x58(%rsp), %rdi
callq 0xb272e
movq 0x40(%rsp), %rax
testq %rax, %rax
je 0xb2418
leaq 0x30(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x58(%rsp), %rdi
callq 0xb0188
movq (%rbx), %rsi
leaq 0x288(%rsp), %rdi
movl $0x10, %edx
callq 0x11060
movq 0x18(%rsp), %rsi
subq 0x10(%rsp), %rsi
sarq $0x3, %rsi
movabsq $-0x3333333333333333, %r13 # imm = 0xCCCCCCCCCCCCCCCD
imulq %r13, %rsi
leaq 0x288(%rsp), %rdi
callq 0x11250
leaq 0x80(%rsp), %rsi
movb $0xa, (%rsi)
movl $0x1, %edx
movq %rax, %rdi
callq 0x113c0
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0xb25b6
leaq 0x90(%rsp), %rbx
xorl %edx, %edx
leaq 0x288(%rsp), %r14
leaq 0xf(%rsp), %r15
movq %rdx, 0x28(%rsp)
leaq (%rdx,%rdx,4), %r12
movq (%rax,%r12,8), %rsi
movq 0x8(%rax,%r12,8), %rdx
addq %rsi, %rdx
movq %rbx, 0x80(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x27dc8
movq 0x88(%rsp), %r13
testq %r13, %r13
je 0xb251b
movq 0x80(%rsp), %rbp
xorl %ebx, %ebx
movb (%rbp,%rbx), %al
cmpb $0x5c, %al
jne 0xb24ff
movb $0x2f, 0xf(%rsp)
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x113c0
jmp 0xb2513
movb %al, 0xf(%rsp)
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x113c0
incq %rbx
cmpq %rbx, %r13
jne 0xb24e0
movb $0xa, 0xf(%rsp)
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x113c0
movabsq $-0x3333333333333333, %r13 # imm = 0xCCCCCCCCCCCCCCCD
shlq $0x3, %r12
addq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0x11450
movq %r14, %rdi
movq %rax, %rsi
callq 0x11250
movb $0xa, 0xf(%rsp)
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x113c0
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rbx
cmpq %rbx, %rdi
je 0xb2590
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x11360
movq 0x28(%rsp), %rdx
incq %rdx
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
imulq %r13, %rcx
cmpq %rdx, %rcx
ja 0xb249f
movq 0x18(%rsp), %rax
cmpq 0x10(%rsp), %rax
je 0xb2636
leaq 0x90(%rsp), %rbx
xorl %r12d, %r12d
leaq 0x80(%rsp), %r14
leaq 0x288(%rsp), %r15
xorl %ebp, %ebp
movq %r14, %rdi
callq 0x113b0
movq 0x10(%rsp), %rax
movq (%rax,%r12), %rsi
movq %r14, %rdi
movl $0x4, %edx
callq 0x11200
movq %r15, %rdi
movq %rbx, %rsi
callq 0x110b0
movq %r14, %rdi
callq 0x110a0
movq %r14, %rdi
callq 0x110d0
incq %rbp
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
sarq $0x3, %rax
imulq %r13, %rax
addq $0x28, %r12
cmpq %rbp, %rax
ja 0xb25df
leaq 0x288(%rsp), %rdi
callq 0x11480
leaq 0x10(%rsp), %rdi
callq 0xb2ff0
movq 0x6b95c(%rip), %rax     # 0x11dfb0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x290(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x288(%rsp,%rcx)
callq 0x11300
leaq 0x380(%rsp), %rdi
callq 0x11120
addq $0x488, %rsp            # imm = 0x488
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xb26c1
movq %rax, %rbx
movq 0x40(%rsp), %rax
testq %rax, %rax
je 0xb26b5
leaq 0x30(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x58(%rsp), %rdi
callq 0xb0188
jmp 0xb270e
movq %rax, %rdi
callq 0x2789a
jmp 0xb26cd
jmp 0xb26cd
movq %rax, %rbx
jmp 0xb270e
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x110d0
jmp 0xb270e
jmp 0xb26e6
movq %rax, %rbx
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0xb270e
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x11360
leaq 0x10(%rsp), %rdi
callq 0xb2ff0
leaq 0x288(%rsp), %rdi
callq 0x114b0
movq %rbx, %rdi
callq 0x11580
nop