// File: /workspace/github_cpp_makefile_star2_O2/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 $0x478, %rsp            # imm = 0x478
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x70(%rsp), %rdi
callq 0x11530
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
andq $0x0, 0x10(%rsp)
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x8b67e
leaq 0x50(%rsp), %rsi
andq $0x0, 0x8(%rsi)
movq %rsp, %rax
movq %rax, (%rsi)
leaq 0x86a(%rip), %rax       # 0x8dd6e
movq %rax, 0x18(%rsi)
leaq 0x8a3(%rip), %rax       # 0x8ddb2
movq %rax, 0x10(%rsi)
leaq 0x28(%rsp), %rdi
callq 0x8d736
leaq 0x50(%rsp), %rdi
callq 0x21f04
leaq 0x28(%rsp), %rdi
callq 0x8b62c
leaq 0x70(%rsp), %rdi
pushq $0x10
popq %rdx
movq %rbx, %rsi
callq 0x8dfca
movq 0x8(%rsp), %rax
subq (%rsp), %rax
pushq $0x28
popq %rcx
cqto
idivq %rcx
leaq 0x70(%rsp), %rdi
movq %rax, %rsi
callq 0x11250
pushq $0xa
popq %rsi
movq %rax, %rdi
callq 0x113d0
xorl %r8d, %r8d
leaq 0x270(%rsp), %rbx
leaq 0x70(%rsp), %r14
pushq $0x2f
popq %r12
movq (%rsp), %rsi
movq 0x8(%rsp), %rcx
movq %rcx, %rax
subq %rsi, %rax
cqto
pushq $0x28
popq %rdi
idivq %rdi
cmpq %r8, %rax
jbe 0x8d630
movq %r8, 0x20(%rsp)
imulq $0x28, %r8, %r15
addq %r15, %rsi
movq %rbx, %rdi
callq 0x8b610
movq 0x270(%rsp), %rbx
movq 0x278(%rsp), %rbp
xorl %r13d, %r13d
cmpq %r13, %rbp
je 0x8d5e5
movzbl (%rbx,%r13), %eax
cmpb $0x5c, %al
cmovel %r12d, %eax
movsbl %al, %esi
movq %r14, %rdi
callq 0x113d0
incq %r13
jmp 0x8d5c5
movq %r14, %rdi
pushq $0xa
popq %rbx
movl %ebx, %esi
callq 0x113d0
addq (%rsp), %r15
movq %r15, %rdi
callq 0x11450
movq %r14, %rdi
movq %rax, %rsi
callq 0x11250
movq %rax, %rdi
movl %ebx, %esi
callq 0x113d0
leaq 0x270(%rsp), %rbx
movq %rbx, %rdi
callq 0x209be
movq 0x20(%rsp), %r8
incq %r8
jmp 0x8d57e
leaq 0x280(%rsp), %rbx
xorl %r12d, %r12d
leaq 0x270(%rsp), %r14
pushq $0x4
popq %rbp
leaq 0x70(%rsp), %r15
xorl %r13d, %r13d
subq %rsi, %rcx
movq %rcx, %rax
cqto
pushq $0x28
popq %rcx
idivq %rcx
cmpq %r13, %rax
jbe 0x8d6a7
movq %r14, %rdi
callq 0x113a0
movq (%rsp), %rsi
addq %r12, %rsi
movq %r14, %rdi
movl %ebp, %edx
callq 0x8dfd2
movq %r15, %rdi
movq %rbx, %rsi
callq 0x110b0
movq %r14, %rdi
callq 0x110a0
movq %r14, %rdi
callq 0x110e0
incq %r13
movq (%rsp), %rsi
movq 0x8(%rsp), %rcx
addq $0x28, %r12
jmp 0x8d64e
leaq 0x70(%rsp), %rdi
callq 0x11480
movq %rsp, %rdi
callq 0x8dfda
leaq 0x70(%rsp), %rdi
callq 0x114b0
addq $0x478, %rsp            # imm = 0x478
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x21f04
leaq 0x28(%rsp), %rdi
callq 0x8b62c
jmp 0x8d71b
jmp 0x8d6f2
jmp 0x8d6f2
movq %rax, %rbx
jmp 0x8d71b
movq %rax, %rbx
leaq 0x270(%rsp), %rdi
callq 0x110e0
jmp 0x8d71b
jmp 0x8d70b
movq %rax, %rbx
leaq 0x270(%rsp), %rdi
callq 0x209be
movq %rsp, %rdi
callq 0x8dfda
leaq 0x70(%rsp), %rdi
callq 0x114b0
movq %rbx, %rdi
callq 0x11570
nop