// File: /workspace/github_c_makefile_star2_O3/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), %r15
movq %r15, -0x10(%r15)
leaq 0x11731(%rip), %rsi     # 0x19c99
leaq 0x1172e(%rip), %rdx     # 0x19c9d
leaq -0x80(%rbp), %rdi
callq 0x17c98
leaq 0x17ce1(%rip), %rdi     # 0x20260
leaq -0x80(%rbp), %rsi
callq 0x184ee
movl $0x1, (%rax)
movq -0x80(%rbp), %rdi
cmpq %r15, %rdi
je 0x85a3
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21e0
leaq -0x80(%rbp), %rdi
movq %r15, (%rdi)
leaq 0x116ed(%rip), %rsi     # 0x19c9e
leaq 0x116ea(%rip), %rdx     # 0x19ca2
callq 0x17c98
leaq 0x17c9c(%rip), %rdi     # 0x20260
leaq -0x80(%rbp), %rsi
callq 0x184ee
movl $0x1, (%rax)
movq -0x80(%rbp), %rdi
cmpq %r15, %rdi
je 0x85e8
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21e0
leaq -0x80(%rbp), %rdi
movq %r15, (%rdi)
leaq 0x116ad(%rip), %rsi     # 0x19ca3
leaq 0x116aa(%rip), %rdx     # 0x19ca7
callq 0x17c98
leaq 0x17c57(%rip), %rdi     # 0x20260
leaq -0x80(%rbp), %rsi
callq 0x184ee
movl $0x1, (%rax)
movq -0x80(%rbp), %rdi
cmpq %r15, %rdi
je 0x862d
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21e0
leaq -0x80(%rbp), %rdi
movq %r15, (%rdi)
leaq 0x1166d(%rip), %rsi     # 0x19ca8
leaq 0x1166a(%rip), %rdx     # 0x19cac
callq 0x17c98
leaq 0x17c12(%rip), %rdi     # 0x20260
leaq -0x80(%rbp), %rsi
callq 0x184ee
movl $0x1, (%rax)
movq -0x80(%rbp), %rdi
cmpq %r15, %rdi
je 0x8672
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21e0
leaq -0x80(%rbp), %rdi
movq %r15, (%rdi)
leaq 0x1162d(%rip), %rsi     # 0x19cad
leaq 0x1162a(%rip), %rdx     # 0x19cb1
callq 0x17c98
leaq 0x17bcd(%rip), %rdi     # 0x20260
leaq -0x80(%rbp), %rsi
callq 0x184ee
movl $0x2, (%rax)
movq -0x80(%rbp), %rdi
cmpq %r15, %rdi
je 0x86b7
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21e0
leaq -0x80(%rbp), %rdi
movq %r15, (%rdi)
leaq 0x115ed(%rip), %rsi     # 0x19cb2
leaq 0x115ea(%rip), %rdx     # 0x19cb6
callq 0x17c98
leaq 0x17b88(%rip), %rdi     # 0x20260
leaq -0x80(%rbp), %rsi
callq 0x184ee
movl $0x3, (%rax)
movq -0x80(%rbp), %rdi
cmpq %r15, %rdi
je 0x86fc
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21e0
leaq -0x80(%rbp), %rdi
movq %r15, (%rdi)
leaq 0x115ad(%rip), %rsi     # 0x19cb7
leaq 0x115aa(%rip), %rdx     # 0x19cbb
callq 0x17c98
leaq 0x17b43(%rip), %rdi     # 0x20260
leaq -0x80(%rbp), %rsi
callq 0x184ee
movl $0x4, (%rax)
movq -0x80(%rbp), %rdi
cmpq %r15, %rdi
je 0x8741
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21e0
leaq -0x80(%rbp), %rdi
movq %r15, (%rdi)
leaq 0x1156d(%rip), %rsi     # 0x19cbc
leaq 0x1156b(%rip), %rdx     # 0x19cc1
callq 0x17c98
leaq 0x17afe(%rip), %rdi     # 0x20260
leaq -0x80(%rbp), %rsi
callq 0x184ee
movl $0x5, (%rax)
movq -0x80(%rbp), %rdi
cmpq %r15, %rdi
je 0x8786
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21e0
leaq -0x80(%rbp), %rdi
movq %r15, (%rdi)
leaq 0x1152e(%rip), %rsi     # 0x19cc2
leaq 0x1152b(%rip), %rdx     # 0x19cc6
callq 0x17c98
leaq 0x17ab9(%rip), %rdi     # 0x20260
leaq -0x80(%rbp), %rsi
callq 0x184ee
movl $0x6, (%rax)
movq -0x80(%rbp), %rdi
cmpq %r15, %rdi
je 0x87cb
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21e0
leaq 0x12094(%rip), %rdi     # 0x1a866
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 0x8895
leaq 0x114c5(%rip), %rax     # 0x19cc7
movq %rax, -0x90(%rbp)
xorl %ebx, %ebx
leaq -0xa8(%rbp), %r14
leaq -0xb8(%rbp), %r12
leaq -0x29(%rbp), %r13
leaq -0x80(%rbp), %r15
movslq %ebx, %rax
movq -0x98(%rbp), %rcx
movq (%rcx,%rax,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x8840
cmpb $0x6f, 0x1(%rsi)
jne 0x8840
cmpb $0x0, 0x2(%rsi)
je 0x887d
movq %r12, %rdi
movq %r13, %rdx
callq 0x1735a
movq %r15, %rdi
movq %r12, %rsi
callq 0x7a47
movq -0xb8(%rbp), %rdi
cmpq %r14, %rdi
je 0x8871
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x21e0
incl %ebx
cmpl -0x84(%rbp), %ebx
jl 0x8821
jmp 0x88a3
leal 0x1(%rax), %ebx
movq -0x98(%rbp), %rcx
movq 0x8(%rcx,%rax,8), %rax
movq %rax, -0x90(%rbp)
jmp 0x8871
leaq 0x1142b(%rip), %rax     # 0x19cc7
movq %rax, -0x90(%rbp)
leaq 0x11fce(%rip), %rdi     # 0x1a878
callq 0x2300
leaq -0x80(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x7dbe
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x88d4
movq -0x38(%rbp), %rsi
subq %rdi, %rsi
callq 0x21e0
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0x88e9
movq -0x50(%rbp), %rsi
subq %rdi, %rsi
callq 0x21e0
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x895e
jmp 0x891f
jmp 0x8939
jmp 0x891f
jmp 0x8939
jmp 0x891f
jmp 0x8939
jmp 0x891f
jmp 0x8939
jmp 0x891f
jmp 0x8939
jmp 0x891f
jmp 0x8939
jmp 0x891f
jmp 0x8939
jmp 0x891f
jmp 0x8939
movq %rax, %rbx
movq -0x80(%rbp), %rdi
cmpq %r15, %rdi
je 0x896a
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x21e0
jmp 0x896a
movq %rax, %rbx
jmp 0x896a
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
cmpq %r14, %rdi
je 0x8961
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x21e0
jmp 0x8961
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x17406
movq %rbx, %rdi
callq 0x2380