// File: /workspace/github_cpp_makefile_star2_O3/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 0xaf306
leaq 0x38(%rsp), %rsi
movq $0x0, 0x8(%rsi)
leaq 0x10(%rsp), %rax
movq %rax, (%rsi)
leaq 0xaf4(%rip), %rax       # 0xb1faa
movq %rax, 0x18(%rsi)
leaq 0xb2d(%rip), %rax       # 0xb1fee
movq %rax, 0x10(%rsi)
leaq 0x58(%rsp), %rdi
callq 0xb1804
movq 0x48(%rsp), %rax
testq %rax, %rax
je 0xb14e8
leaq 0x38(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x58(%rsp), %rdi
callq 0xaf2ce
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, %rax # imm = 0xCCCCCCCCCCCCCCCD
imulq %rax, %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 0xb170c
leaq 0x90(%rsp), %rbx
xorl %edi, %edi
leaq 0x288(%rsp), %r14
leaq 0xf(%rsp), %r15
movq %rdi, 0x30(%rsp)
leaq (%rdi,%rdi,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 0x27370
movq 0x88(%rsp), %r13
testq %r13, %r13
je 0xb15eb
movq 0x80(%rsp), %rbp
xorl %ebx, %ebx
movb (%rbp,%rbx), %al
cmpb $0x5c, %al
jne 0xb15cf
movb $0x2f, 0xf(%rsp)
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x113c0
jmp 0xb15e3
movb %al, 0xf(%rsp)
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x113c0
incq %rbx
cmpq %rbx, %r13
jne 0xb15b0
movb $0xa, 0xf(%rsp)
movl $0x1, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x113c0
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 0xb1656
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x11360
movq 0x30(%rsp), %rdi
incq %rdi
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x3333333333333333, %rsi # imm = 0xCCCCCCCCCCCCCCCD
imulq %rsi, %rdx
cmpq %rdi, %rdx
ja 0xb156f
cmpq %rax, %rcx
je 0xb170c
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
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rcx, %rax
addq $0x28, %r12
cmpq %rbp, %rax
ja 0xb16ab
leaq 0x288(%rsp), %rdi
callq 0x11480
leaq 0x10(%rsp), %rdi
callq 0xb20c6
movq 0x6b886(%rip), %rax     # 0x11cfb0
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 0xb1797
movq %rax, %rbx
movq 0x48(%rsp), %rax
testq %rax, %rax
je 0xb178b
leaq 0x38(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
leaq 0x58(%rsp), %rdi
callq 0xaf2ce
jmp 0xb17e4
movq %rax, %rdi
callq 0x26e38
jmp 0xb17a3
jmp 0xb17a3
movq %rax, %rbx
jmp 0xb17e4
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x110d0
jmp 0xb17e4
jmp 0xb17bc
movq %rax, %rbx
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0xb17e4
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x11360
leaq 0x10(%rsp), %rdi
callq 0xb20c6
leaq 0x288(%rsp), %rdi
callq 0x114b0
movq %rbx, %rdi
callq 0x11580
nop