// File: /workspace/github_cpp_makefile_star2_O1/tcannon686[P]obj2webgl/main.cpp
// Function: main
int main(int argc, char *argv[])
{
    if(argc < 2)
    {
        cout << "Usage: " << argv[0] << " [OPTION]... [FILE].obj..." << endl;
        cout << usage;
        cout << "    " << argv[0] << " objs/Cube.obj" << endl;
        cout << "    " << argv[0] << " -o Cube.js objs/Cube.obj" << endl;
        cout << "    " << argv[0] << " -o shapes.js objs/*" << endl;
        return -1;
    }

    string outpath;
    /* Parse arguments. */
    int index;
    for(index = 1; index < argc; index ++)
    {
        string arg(argv[index]);
        if(arg.rfind("-o", 0) == 0)
        {
            auto split = arg.find("=", 0);
            if(split != string::npos)
                outpath = arg.substr(split + 1, arg.size() - split - 1);
            else
            {
                if(index + 1 < argc)
                {
                    outpath = argv[++ index];
                }
            }
        }
        else
            break;
    }

    ofstream outfile;
    if(outpath.size())
        outfile.open(outpath);

    ostream &out(outpath.size() ? outfile : cout);

    /* Write header. */
    out << "/*" << std::endl
        << " * This code was generated using the obj2webgl tool:" << std::endl
        << " * https://github.com/tcannon686/obj2webgl" << std::endl
        << " */" << std::endl << std::endl;

    /* Read the files. */
    for(int i = index; i < argc; i ++)
    {
        string path(argv[i]);
        /* Figure out a name for it. */
        auto base = path.rfind('/');
        if(base == string::npos)
            base = path.rfind('\\');
        if(base != string::npos)
            base ++;
        else
            base = 0;
        auto extension = path.find('.', base);
        if(extension == string::npos)
            extension = path.size();

        string name(path.substr(base, extension - base));

        /* Open the file. */
        ifstream input(path);
        ObjParser<ifstream> parser(input);
        parser.parse();
        parser.writeWebGlCode(out, name);
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x708, %rsp            # imm = 0x708
movq %rsi, %r13
movq %rdi, -0x38(%rbp)
cmpl $0x1, %edi
jg 0x3a83
movq 0x758d(%rip), %rbx      # 0xafd0
leaq 0x4963(%rip), %rsi      # 0x83ad
movl $0x7, %edx
movq %rbx, %rdi
callq 0x32a0
movq (%r13), %r14
testq %r14, %r14
je 0x3ec6
movq %r14, %rdi
callq 0x3100
movq 0x755d(%rip), %rdi      # 0xafd0
movq %r14, %rsi
movq %rax, %rdx
callq 0x32a0
jmp 0x3edd
leaq -0x48(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl $0x1, %r14d
leaq -0x328(%rbp), %r15
movq %r13, %r12
movslq %r14d, %rax
movq (%r13,%rax,8), %rsi
movq %r15, %rdi
leaq -0x730(%rbp), %r13
movq %r13, %rdx
callq 0x41e8
movl $0x2, %ecx
movq %r15, %rdi
leaq 0x4935(%rip), %rsi      # 0x8404
xorl %edx, %edx
callq 0x3310
movq %rax, %rbx
testq %rax, %rax
je 0x3b1a
movq -0x328(%rbp), %rdi
leaq -0x318(%rbp), %rax
cmpq %rax, %rdi
je 0x3b00
movq -0x318(%rbp), %rsi
incq %rsi
callq 0x3250
testq %rbx, %rbx
movq %r12, %r13
jne 0x3bcb
incl %r14d
cmpl -0x38(%rbp), %r14d
jl 0x3aa6
jmp 0x3bcb
movl $0x1, %ecx
movq %r15, %rdi
leaq 0x48de(%rip), %rsi      # 0x8407
xorl %edx, %edx
callq 0x3410
cmpq $-0x1, %rax
je 0x3b89
leaq 0x1(%rax), %rdx
notq %rax
addq -0x320(%rbp), %rax
movq %r13, %rdi
movq %r15, %rsi
movq %rax, %rcx
callq 0x3280
leaq -0x58(%rbp), %rdi
movq %r13, %rsi
callq 0x32d0
movq -0x730(%rbp), %rdi
leaq -0x720(%rbp), %rax
cmpq %rax, %rdi
je 0x3ade
movq -0x720(%rbp), %rsi
incq %rsi
callq 0x3250
jmp 0x3ade
leal 0x1(%r14), %r13d
cmpl -0x38(%rbp), %r13d
jge 0x3ade
movslq %r13d, %rax
movq (%r12,%rax,8), %r14
movq -0x50(%rbp), %rax
movq %rax, -0x30(%rbp)
movq %r14, %rdi
callq 0x3100
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
movq -0x30(%rbp), %rdx
movq %r14, %rcx
movq %rax, %r8
callq 0x3370
movl %r13d, %r14d
jmp 0x3ade
leaq -0x528(%rbp), %rdi
movq %rdi, -0x30(%rbp)
callq 0x33f0
cmpq $0x0, -0x50(%rbp)
je 0x3bf7
leaq -0x528(%rbp), %rdi
leaq -0x58(%rbp), %rsi
movl $0x10, %edx
callq 0x3110
cmpq $0x0, -0x50(%rbp)
jne 0x3c09
movq 0x73cb(%rip), %rax      # 0xafd0
movq %rax, -0x30(%rbp)
leaq 0x47f1(%rip), %rsi      # 0x8401
movl $0x2, %edx
movq -0x30(%rbp), %rdi
callq 0x32a0
movq -0x30(%rbp), %rcx
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x3220
movsbl %al, %esi
movq -0x30(%rbp), %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
movq %rax, %rbx
leaq 0x47b5(%rip), %rsi      # 0x8409
movl $0x34, %edx
movq %rax, %rdi
callq 0x32a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
movq %rax, %rbx
leaq 0x47ac(%rip), %rsi      # 0x843e
movl $0x2a, %edx
movq %rax, %rdi
callq 0x32a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
movq %rax, %rbx
leaq 0x4799(%rip), %rsi      # 0x8469
movl $0x3, %edx
movq %rax, %rdi
callq 0x32a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
movq -0x38(%rbp), %rax
subl %r14d, %eax
movq %rax, -0x38(%rbp)
jle 0x3e70
movslq %r14d, %rax
leaq (,%rax,8), %rax
addq %r13, %rax
movq %rax, -0x60(%rbp)
xorl %r13d, %r13d
leaq -0xa0(%rbp), %rbx
leaq -0x328(%rbp), %r12
leaq -0x730(%rbp), %r15
movq -0x60(%rbp), %rax
movq (%rax,%r13,8), %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0x41e8
movq %rbx, %rdi
movl $0x2f, %esi
movq $-0x1, %rdx
callq 0x3450
movq %rax, %r14
cmpq $-0x1, %rax
jne 0x3db0
movq %rbx, %rdi
movl $0x5c, %esi
movq $-0x1, %rdx
callq 0x3450
movq %rax, %r14
incq %r14
movq %rbx, %rdi
movl $0x2e, %esi
movq %r14, %rdx
callq 0x32e0
cmpq $-0x1, %rax
jne 0x3dd0
movq -0x98(%rbp), %rax
subq %r14, %rax
leaq -0x80(%rbp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %rax, %rcx
callq 0x3280
movq %r15, %rdi
movq %rbx, %rsi
movl $0x8, %edx
callq 0x33b0
movq %r12, %rdi
movq %r15, %rsi
callq 0x4226
movq %r12, %rdi
callq 0x47d2
movq %r12, %rdi
movq -0x30(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x4888
movq %r12, %rdi
callq 0x5734
movq %r15, %rdi
callq 0x3070
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x3e41
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x3250
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x3e63
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x3250
incq %r13
cmpl %r13d, -0x38(%rbp)
jne 0x3d69
movq 0x7151(%rip), %rax      # 0xafc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x520(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x528(%rbp,%rcx)
callq 0x31f0
leaq -0x430(%rbp), %rdi
callq 0x30c0
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x3ebf
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3250
xorl %eax, %eax
jmp 0x4107
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x33e0
leaq 0x44d1(%rip), %rsi      # 0x83b5
movl $0x1a, %edx
movq %rbx, %rdi
callq 0x32a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
movq 0x7321(%rip), %r14      # 0xb240
testq %r14, %r14
je 0x3f40
movq %r14, %rdi
callq 0x3100
movq 0x709d(%rip), %rdi      # 0xafd0
movq %r14, %rsi
movq %rax, %rdx
callq 0x32a0
jmp 0x3f57
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x33e0
movq 0x7072(%rip), %r14      # 0xafd0
leaq 0x446b(%rip), %rsi      # 0x83d0
movl $0x4, %edx
movq %r14, %rdi
callq 0x32a0
movq (%r13), %rbx
testq %rbx, %rbx
je 0x3f97
movq %rbx, %rdi
callq 0x3100
movq 0x7046(%rip), %rdi      # 0xafd0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x32a0
jmp 0x3faf
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x33e0
leaq 0x442a(%rip), %rsi      # 0x83e0
movl $0xe, %edx
movq %r14, %rdi
callq 0x32a0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3220
movsbl %al, %esi
movq %r14, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
leaq 0x43df(%rip), %rsi      # 0x83d0
movl $0x4, %edx
movq %r14, %rdi
callq 0x32a0
movq (%r13), %rbx
testq %rbx, %rbx
je 0x4023
movq %rbx, %rdi
callq 0x3100
movq 0x6fba(%rip), %rdi      # 0xafd0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x32a0
jmp 0x403b
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x33e0
leaq 0x4393(%rip), %rsi      # 0x83d5
movl $0x19, %edx
movq %r14, %rdi
callq 0x32a0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3220
movsbl %al, %esi
movq %r14, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
leaq 0x4353(%rip), %rsi      # 0x83d0
movl $0x4, %edx
movq %r14, %rdi
callq 0x32a0
movq (%r13), %rbx
testq %rbx, %rbx
je 0x40af
movq %rbx, %rdi
callq 0x3100
movq 0x6f2e(%rip), %rdi      # 0xafd0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x32a0
jmp 0x40c7
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x33e0
leaq 0x4321(%rip), %rsi      # 0x83ef
movl $0x14, %edx
movq %r14, %rdi
callq 0x32a0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3220
movsbl %al, %esi
movq %r14, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x708, %rsp            # imm = 0x708
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4160
jmp 0x415b
jmp 0x411f
movq %rax, %rbx
movq -0x328(%rbp), %rdi
leaq -0x318(%rbp), %rax
cmpq %rax, %rdi
je 0x41c7
movq -0x318(%rbp), %rsi
incq %rsi
callq 0x3250
jmp 0x41c7
jmp 0x4160
movq %rax, %rbx
jmp 0x4199
movq %rax, %rbx
jmp 0x4180
movq %rax, %rbx
jmp 0x4174
movq %rax, %rbx
jmp 0x41c7
movq %rax, %rbx
jmp 0x41bb
movq %rax, %rbx
leaq -0x328(%rbp), %rdi
callq 0x5734
leaq -0x730(%rbp), %rdi
callq 0x3070
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x4199
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x3250
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x41bb
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x3250
leaq -0x528(%rbp), %rdi
callq 0x3350
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x41e0
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3250
movq %rbx, %rdi
callq 0x3420