// File: 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:
subq $0x528, %rsp            # imm = 0x528
movq %rdi, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdi, 0x520(%rsp)
movq %rsi, 0x518(%rsp)
leaq 0x318(%rsp), %rdi
callq 0x13170
leaq 0x300(%rsp), %rdi
callq 0x1efa30
movq 0x48(%rsp), %rsi
leaq 0x2d8(%rsp), %rdi
callq 0x1e7280
jmp 0x1eddaf
leaq 0x300(%rsp), %rax
movq %rax, 0x2a0(%rsp)
leaq 0x2a8(%rsp), %rdi
movq %rdi, 0x38(%rsp)
leaq 0x2a0(%rsp), %rsi
callq 0x1ee640
movq 0x38(%rsp), %rsi
leaq 0x2d8(%rsp), %rdi
callq 0x1ee1b0
jmp 0x1edded
leaq 0x2a8(%rsp), %rdi
callq 0x1e7530
leaq 0x2d8(%rsp), %rdi
callq 0x1e7130
movq 0x40(%rsp), %rsi
leaq 0x318(%rsp), %rdi
movl $0x10, %edx
callq 0x1efa40
jmp 0x1ede20
leaq 0x300(%rsp), %rdi
callq 0x1efa80
movq %rax, %rsi
leaq 0x318(%rsp), %rdi
callq 0x13600
movq %rax, 0x30(%rsp)
jmp 0x1ede44
movq 0x30(%rsp), %rdi
movl $0xa, %esi
callq 0x13400
jmp 0x1ede55
movl $0x0, 0x29c(%rsp)
movslq 0x29c(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x300(%rsp), %rdi
callq 0x1efa80
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jae 0x1ee070
movslq 0x29c(%rsp), %rsi
leaq 0x300(%rsp), %rdi
callq 0x1efaa0
movq %rax, %rsi
leaq 0x278(%rsp), %rdi
callq 0x1e70b0
jmp 0x1edeb2
leaq 0x278(%rsp), %rax
movq %rax, 0x270(%rsp)
movq 0x270(%rsp), %rdi
callq 0x114710
movq %rax, 0x268(%rsp)
movq 0x270(%rsp), %rdi
callq 0x114ac0
movq %rax, 0x260(%rsp)
leaq 0x268(%rsp), %rdi
leaq 0x260(%rsp), %rsi
callq 0x11eff0
xorb $-0x1, %al
testb $0x1, %al
jne 0x1edf0c
jmp 0x1edfeb
leaq 0x268(%rsp), %rdi
callq 0x121390
movb (%rax), %al
movb %al, 0x25f(%rsp)
movsbl 0x25f(%rsp), %eax
cmpl $0x5c, %eax
jne 0x1edfbe
leaq 0x318(%rsp), %rdi
movl $0x2f, %esi
callq 0x13400
jmp 0x1edf47
jmp 0x1edfd7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d0(%rsp)
movl %eax, 0x2cc(%rsp)
jmp 0x1ee17d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d0(%rsp)
movl %eax, 0x2cc(%rsp)
leaq 0x2a8(%rsp), %rdi
callq 0x1e7530
leaq 0x2d8(%rsp), %rdi
callq 0x1e7130
jmp 0x1ee17d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d0(%rsp)
movl %eax, 0x2cc(%rsp)
leaq 0x278(%rsp), %rdi
callq 0x52f50
jmp 0x1ee17d
movsbl 0x25f(%rsp), %esi
leaq 0x318(%rsp), %rdi
callq 0x13400
jmp 0x1edfd5
jmp 0x1edfd7
jmp 0x1edfd9
leaq 0x268(%rsp), %rdi
callq 0x124b80
jmp 0x1edeec
leaq 0x318(%rsp), %rdi
movl $0xa, %esi
callq 0x13400
jmp 0x1edfff
movslq 0x29c(%rsp), %rsi
leaq 0x300(%rsp), %rdi
callq 0x1efaa0
movq %rax, %rdi
callq 0x13130
movq %rax, 0x20(%rsp)
jmp 0x1ee023
movq 0x20(%rsp), %rsi
leaq 0x318(%rsp), %rdi
callq 0x13600
movq %rax, 0x18(%rsp)
jmp 0x1ee03c
movq 0x18(%rsp), %rdi
movl $0xa, %esi
callq 0x13400
jmp 0x1ee04d
leaq 0x278(%rsp), %rdi
callq 0x52f50
movl 0x29c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x29c(%rsp)
jmp 0x1ede60
movl $0x0, 0x258(%rsp)
movslq 0x258(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x300(%rsp), %rdi
callq 0x1efa80
movq %rax, %rcx
movq 0x10(%rsp), %rax
cmpq %rcx, %rax
jae 0x1ee14c
leaq 0x50(%rsp), %rdi
callq 0x131f0
jmp 0x1ee0b2
movslq 0x258(%rsp), %rsi
leaq 0x300(%rsp), %rdi
callq 0x1efaa0
movq %rax, %rsi
leaq 0x50(%rsp), %rdi
movl $0x4, %edx
callq 0x1efac0
jmp 0x1ee0db
leaq 0x50(%rsp), %rdi
callq 0x132b0
movq %rax, 0x8(%rsp)
jmp 0x1ee0ec
movq 0x8(%rsp), %rsi
leaq 0x318(%rsp), %rdi
callq 0x13150
jmp 0x1ee100
leaq 0x50(%rsp), %rdi
callq 0x133d0
jmp 0x1ee10c
leaq 0x50(%rsp), %rdi
callq 0x13040
movl 0x258(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x258(%rsp)
jmp 0x1ee07b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d0(%rsp)
movl %eax, 0x2cc(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x13040
jmp 0x1ee17d
leaq 0x318(%rsp), %rdi
callq 0x13520
jmp 0x1ee15b
leaq 0x300(%rsp), %rdi
callq 0x1efb00
leaq 0x318(%rsp), %rdi
callq 0x13460
addq $0x528, %rsp            # imm = 0x528
retq
leaq 0x300(%rsp), %rdi
callq 0x1efb00
leaq 0x318(%rsp), %rdi
callq 0x13460
movq 0x2d0(%rsp), %rdi
callq 0x133f0
nopw %cs:(%rax,%rax)