// File: /workspace/github_c_makefile_star2_O2/FredTheDino[P]Fog/src/engine/unix_assets.cpp
// Function: main
int main(int nargs, char **vargs) {
    // Image file formats
    valid_endings[".psd"] = Asset::Type::TEXTURE;
    valid_endings[".png"] = Asset::Type::TEXTURE;
    valid_endings[".jpg"] = Asset::Type::TEXTURE;
    valid_endings[".bmp"] = Asset::Type::TEXTURE;
    // .sdf is for the font files, they are loaded
    // in the font pass only if there is a matching
    // .fnt file.

    // Fonts
    valid_endings[".fnt"] = Asset::Type::FONT;

    // Sprite
    valid_endings[".spr"] = Asset::Type::SPRITE;

    // Sound
    valid_endings[".wav"] = Asset::Type::SOUND;
    // TODO(ed): This might be nice to have
    // valid_endings[".ogg"] = Asset::Type::SOUND;

    // Shader
    valid_endings[".glsl"] = Asset::Type::SHADER;

    // Config files? Is this a good idea?
    valid_endings[".cfg"] = Asset::Type::CONFIG;

    printf("\n\t=== FINDING ===\n");

    // TODO(ed): Some form of compression on this data
    // would make it a lot less space savy
    AssetFile file = {};
    const char *out_path = "bin/data.fog";
    for (int i = 0; i < nargs; i++) {
        if (std::strcmp(vargs[i], "-o") == 0) {
            out_path = vargs[++i];
        } else {
            std::string path = vargs[i];
            process_asset(&file, &path);
        }
    }

    printf("\t=== WRITING ===\n");

    dump_asset_file(&file, out_path);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, %rbx
movl %edi, -0x30(%rbp)
leaq 0xc74e(%rip), %rsi      # 0x13c79
leaq -0x80(%rbp), %rdi
leaq -0xa8(%rbp), %rdx
callq 0x10d1e
leaq 0x12d5e(%rip), %rdi     # 0x1a2a0
leaq -0x80(%rbp), %rsi
callq 0x12242
movl $0x1, (%rax)
leaq -0x80(%rbp), %rdi
callq 0x2100
leaq 0xc71d(%rip), %rsi      # 0x13c7e
leaq -0x80(%rbp), %rdi
leaq -0xa8(%rbp), %rdx
callq 0x10d1e
leaq 0x12d28(%rip), %rdi     # 0x1a2a0
leaq -0x80(%rbp), %rsi
callq 0x12242
movl $0x1, (%rax)
leaq -0x80(%rbp), %rdi
callq 0x2100
leaq 0xc6ec(%rip), %rsi      # 0x13c83
leaq -0x80(%rbp), %rdi
leaq -0xa8(%rbp), %rdx
callq 0x10d1e
leaq 0x12cf2(%rip), %rdi     # 0x1a2a0
leaq -0x80(%rbp), %rsi
callq 0x12242
movl $0x1, (%rax)
leaq -0x80(%rbp), %rdi
callq 0x2100
leaq 0xc6bb(%rip), %rsi      # 0x13c88
leaq -0x80(%rbp), %rdi
leaq -0xa8(%rbp), %rdx
callq 0x10d1e
leaq 0x12cbc(%rip), %rdi     # 0x1a2a0
leaq -0x80(%rbp), %rsi
callq 0x12242
movl $0x1, (%rax)
leaq -0x80(%rbp), %rdi
callq 0x2100
leaq 0xc68a(%rip), %rsi      # 0x13c8d
leaq -0x80(%rbp), %rdi
leaq -0xa8(%rbp), %rdx
callq 0x10d1e
leaq 0x12c86(%rip), %rdi     # 0x1a2a0
leaq -0x80(%rbp), %rsi
callq 0x12242
movl $0x2, (%rax)
leaq -0x80(%rbp), %rdi
callq 0x2100
leaq 0xc659(%rip), %rsi      # 0x13c92
leaq -0x80(%rbp), %rdi
leaq -0xa8(%rbp), %rdx
callq 0x10d1e
leaq 0x12c50(%rip), %rdi     # 0x1a2a0
leaq -0x80(%rbp), %rsi
callq 0x12242
movl $0x3, (%rax)
leaq -0x80(%rbp), %rdi
callq 0x2100
leaq 0xc628(%rip), %rsi      # 0x13c97
leaq -0x80(%rbp), %rdi
leaq -0xa8(%rbp), %rdx
callq 0x10d1e
leaq 0x12c1a(%rip), %rdi     # 0x1a2a0
leaq -0x80(%rbp), %rsi
callq 0x12242
movl $0x4, (%rax)
leaq -0x80(%rbp), %rdi
callq 0x2100
leaq 0xc5f7(%rip), %rsi      # 0x13c9c
leaq -0x80(%rbp), %rdi
leaq -0xa8(%rbp), %rdx
callq 0x10d1e
leaq 0x12be4(%rip), %rdi     # 0x1a2a0
leaq -0x80(%rbp), %rsi
callq 0x12242
movl $0x5, (%rax)
leaq -0x80(%rbp), %rdi
callq 0x2100
leaq 0xc5c7(%rip), %rsi      # 0x13ca2
leaq -0x80(%rbp), %rdi
leaq -0xa8(%rbp), %rdx
callq 0x10d1e
leaq 0x12bae(%rip), %rdi     # 0x1a2a0
leaq -0x80(%rbp), %rsi
callq 0x12242
movl $0x6, (%rax)
leaq -0x80(%rbp), %r15
movq %r15, %rdi
callq 0x2100
leaq 0xd132(%rip), %rdi      # 0x14846
callq 0x2350
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%r15)
movaps %xmm0, 0x30(%r15)
movaps %xmm0, 0x20(%r15)
movaps %xmm0, 0x10(%r15)
movaps %xmm0, (%r15)
xorl %r14d, %r14d
leaq 0xc569(%rip), %rax      # 0x13ca7
movq %rax, -0x88(%rbp)
leaq -0xa8(%rbp), %r13
leaq -0x29(%rbp), %r12
cmpl -0x30(%rbp), %r14d
jge 0x77a2
movslq %r14d, %rax
movq (%rbx,%rax,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x776e
cmpb $0x6f, 0x1(%rsi)
jne 0x776e
cmpb $0x0, 0x2(%rsi)
je 0x7791
movq %r13, %rdi
movq %r12, %rdx
callq 0x10d1e
movq %r15, %rdi
movq %r13, %rsi
callq 0x6df1
movq %r13, %rdi
callq 0x2100
incl %r14d
jmp 0x7750
incl %r14d
movq 0x8(%rbx,%rax,8), %rax
movq %rax, -0x88(%rbp)
jmp 0x778c
leaq 0xd0af(%rip), %rdi      # 0x14858
callq 0x2350
leaq -0x80(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0x7076
leaq -0x80(%rbp), %rdi
callq 0x10f36
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7821
jmp 0x77fd
jmp 0x780b
jmp 0x77fd
jmp 0x780b
jmp 0x77fd
jmp 0x780b
jmp 0x77fd
jmp 0x780b
jmp 0x77fd
jmp 0x780b
jmp 0x77fd
jmp 0x780b
jmp 0x77fd
jmp 0x780b
jmp 0x77fd
jmp 0x780b
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x2100
jmp 0x782d
movq %rax, %rbx
jmp 0x782d
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x2100
jmp 0x7824
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x10f36
movq %rbx, %rdi
callq 0x23d0