// File: /workspace/github_c_makefile_star2_O1/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 $0x98, %rsp
movq %rsi, -0x98(%rbp)
movl %edi, -0x84(%rbp)
leaq -0x70(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x1266e(%rip), %rsi     # 0x1ac99
leaq 0x1266b(%rip), %rdx     # 0x1ac9d
leaq -0x80(%rbp), %rdi
callq 0x18fb2
leaq 0x18c4e(%rip), %rdi     # 0x21290
leaq -0x80(%rbp), %rsi
callq 0x1988c
movl $0x1, (%rax)
movq -0x80(%rbp), %rdi
cmpq %r14, %rdi
je 0x8666
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21d0
leaq -0x80(%rbp), %rdi
movq %r14, (%rdi)
leaq 0x1262a(%rip), %rsi     # 0x1ac9e
leaq 0x12627(%rip), %rdx     # 0x1aca2
callq 0x18fb2
leaq 0x18c09(%rip), %rdi     # 0x21290
leaq -0x80(%rbp), %rsi
callq 0x1988c
movl $0x1, (%rax)
movq -0x80(%rbp), %rdi
cmpq %r14, %rdi
je 0x86ab
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21d0
leaq -0x80(%rbp), %rdi
movq %r14, (%rdi)
leaq 0x125ea(%rip), %rsi     # 0x1aca3
leaq 0x125e7(%rip), %rdx     # 0x1aca7
callq 0x18fb2
leaq 0x18bc4(%rip), %rdi     # 0x21290
leaq -0x80(%rbp), %rsi
callq 0x1988c
movl $0x1, (%rax)
movq -0x80(%rbp), %rdi
cmpq %r14, %rdi
je 0x86f0
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21d0
leaq -0x80(%rbp), %rdi
movq %r14, (%rdi)
leaq 0x125aa(%rip), %rsi     # 0x1aca8
leaq 0x125a7(%rip), %rdx     # 0x1acac
callq 0x18fb2
leaq 0x18b7f(%rip), %rdi     # 0x21290
leaq -0x80(%rbp), %rsi
callq 0x1988c
movl $0x1, (%rax)
movq -0x80(%rbp), %rdi
cmpq %r14, %rdi
je 0x8735
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21d0
leaq -0x80(%rbp), %rdi
movq %r14, (%rdi)
leaq 0x1256a(%rip), %rsi     # 0x1acad
leaq 0x12567(%rip), %rdx     # 0x1acb1
callq 0x18fb2
leaq 0x18b3a(%rip), %rdi     # 0x21290
leaq -0x80(%rbp), %rsi
callq 0x1988c
movl $0x2, (%rax)
movq -0x80(%rbp), %rdi
cmpq %r14, %rdi
je 0x877a
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21d0
leaq -0x80(%rbp), %rdi
movq %r14, (%rdi)
leaq 0x1252a(%rip), %rsi     # 0x1acb2
leaq 0x12527(%rip), %rdx     # 0x1acb6
callq 0x18fb2
leaq 0x18af5(%rip), %rdi     # 0x21290
leaq -0x80(%rbp), %rsi
callq 0x1988c
movl $0x3, (%rax)
movq -0x80(%rbp), %rdi
cmpq %r14, %rdi
je 0x87bf
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21d0
leaq -0x80(%rbp), %rdi
movq %r14, (%rdi)
leaq 0x124ea(%rip), %rsi     # 0x1acb7
leaq 0x124e7(%rip), %rdx     # 0x1acbb
callq 0x18fb2
leaq 0x18ab0(%rip), %rdi     # 0x21290
leaq -0x80(%rbp), %rsi
callq 0x1988c
movl $0x4, (%rax)
movq -0x80(%rbp), %rdi
cmpq %r14, %rdi
je 0x8804
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21d0
leaq -0x80(%rbp), %rdi
movq %r14, (%rdi)
leaq 0x124aa(%rip), %rsi     # 0x1acbc
leaq 0x124a8(%rip), %rdx     # 0x1acc1
callq 0x18fb2
leaq 0x18a6b(%rip), %rdi     # 0x21290
leaq -0x80(%rbp), %rsi
callq 0x1988c
movl $0x5, (%rax)
movq -0x80(%rbp), %rdi
cmpq %r14, %rdi
je 0x8849
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21d0
leaq -0x80(%rbp), %rdi
movq %r14, (%rdi)
leaq 0x1246b(%rip), %rsi     # 0x1acc2
leaq 0x12468(%rip), %rdx     # 0x1acc6
callq 0x18fb2
leaq 0x18a26(%rip), %rdi     # 0x21290
leaq -0x80(%rbp), %rsi
callq 0x1988c
movl $0x6, (%rax)
movq -0x80(%rbp), %rdi
cmpq %r14, %rdi
je 0x888e
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21d0
leaq 0x12fd8(%rip), %rdi     # 0x1b86d
callq 0x2300
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movaps %xmm0, -0x50(%rbp)
movaps %xmm0, -0x60(%rbp)
movaps %xmm0, -0x70(%rbp)
movaps %xmm0, -0x80(%rbp)
cmpl $0x0, -0x84(%rbp)
jle 0x8958
leaq 0x12402(%rip), %rax     # 0x1acc7
movq %rax, -0x90(%rbp)
xorl %ebx, %ebx
leaq -0xb8(%rbp), %r13
movq -0x98(%rbp), %r12
movslq %ebx, %r15
movq (%r12,%r15,8), %r14
movq %r14, %rdi
leaq 0x123e7(%rip), %rsi     # 0x1acd4
callq 0x22a0
testl %eax, %eax
je 0x893c
movq %r13, %rdi
movq %r14, %rsi
leaq -0x29(%rbp), %rdx
callq 0x18660
leaq -0x80(%rbp), %rdi
movq %r13, %rsi
callq 0x7b5a
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x8933
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x21d0
movq -0x98(%rbp), %r12
jmp 0x894c
leal 0x1(%r15), %ebx
movq 0x8(%r12,%r15,8), %rax
movq %rax, -0x90(%rbp)
incl %ebx
cmpl -0x84(%rbp), %ebx
jl 0x88dc
jmp 0x8966
leaq 0x12368(%rip), %rax     # 0x1acc7
movq %rax, -0x90(%rbp)
leaq 0x12f12(%rip), %rdi     # 0x1b87f
callq 0x2300
leaq -0x80(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x7ed1
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x8997
movq -0x38(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x89ac
movq -0x50(%rbp), %rsi
subq %rdi, %rsi
callq 0x21d0
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8a01
jmp 0x89e2
jmp 0x89fc
jmp 0x89e2
jmp 0x89fc
jmp 0x89e2
jmp 0x89fc
jmp 0x89e2
jmp 0x89fc
jmp 0x89e2
jmp 0x89fc
jmp 0x89e2
jmp 0x89fc
jmp 0x89e2
jmp 0x89fc
jmp 0x89e2
jmp 0x89fc
movq %rax, %rbx
movq -0x80(%rbp), %rdi
cmpq %r14, %rdi
je 0x8a34
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21d0
jmp 0x8a34
movq %rax, %rbx
jmp 0x8a34
movq %rax, %rbx
jmp 0x8a2b
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x8a2b
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x21d0
leaq -0x80(%rbp), %rdi
callq 0x18708
movq %rbx, %rdi
callq 0x2380