// File: /workspace/github_cpp_makefile_star2_O3/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, -0x30(%rbp)
cmpl $0x1, %edi
jg 0x3a73
movq 0x759d(%rip), %rbx      # 0xafd0
leaq 0x4973(%rip), %rsi      # 0x83ad
movl $0x7, %edx
movq %rbx, %rdi
callq 0x32a0
movq (%r13), %r14
testq %r14, %r14
je 0x3eaf
movq %r14, %rdi
callq 0x3100
movq 0x756d(%rip), %rdi      # 0xafd0
movq %r14, %rsi
movq %rax, %rdx
callq 0x32a0
jmp 0x3ec6
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 0x41d2
movl $0x2, %ecx
movq %r15, %rdi
leaq 0x4945(%rip), %rsi      # 0x8404
xorl %edx, %edx
callq 0x3310
movq %rax, %rbx
testq %rax, %rax
je 0x3b0a
movq -0x328(%rbp), %rdi
leaq -0x318(%rbp), %rax
cmpq %rax, %rdi
je 0x3af0
movq -0x318(%rbp), %rsi
incq %rsi
callq 0x3250
testq %rbx, %rbx
movq %r12, %r13
jne 0x3bbb
incl %r14d
cmpl -0x30(%rbp), %r14d
jl 0x3a96
jmp 0x3bbb
movl $0x1, %ecx
movq %r15, %rdi
leaq 0x48ee(%rip), %rsi      # 0x8407
xorl %edx, %edx
callq 0x3410
cmpq $-0x1, %rax
je 0x3b79
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 0x3ace
movq -0x720(%rbp), %rsi
incq %rsi
callq 0x3250
jmp 0x3ace
leal 0x1(%r14), %r13d
cmpl -0x30(%rbp), %r13d
jge 0x3ace
movslq %r13d, %rax
movq (%r12,%rax,8), %r14
movq -0x50(%rbp), %rax
movq %rax, -0x38(%rbp)
movq %r14, %rdi
callq 0x3100
leaq -0x58(%rbp), %rdi
xorl %esi, %esi
movq -0x38(%rbp), %rdx
movq %r14, %rcx
movq %rax, %r8
callq 0x3370
movl %r13d, %r14d
jmp 0x3ace
leaq -0x528(%rbp), %rdi
callq 0x33f0
cmpq $0x0, -0x50(%rbp)
je 0x3bed
leaq -0x528(%rbp), %r15
leaq -0x58(%rbp), %rsi
movq %r15, %rdi
movl $0x10, %edx
callq 0x3110
cmpq $0x0, -0x50(%rbp)
jne 0x3bf4
movq 0x73dc(%rip), %r15      # 0xafd0
leaq 0x4806(%rip), %rsi      # 0x8401
movl $0x2, %edx
movq %r15, %rdi
callq 0x32a0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3220
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
movq %rax, %rbx
leaq 0x47d0(%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 0x47c7(%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 0x47b4(%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 %r15, -0x38(%rbp)
movq -0x30(%rbp), %rax
subl %r14d, %eax
movq %rax, -0x30(%rbp)
jle 0x3e59
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 0x41d2
movq %rbx, %rdi
movl $0x2f, %esi
movq $-0x1, %rdx
callq 0x3450
movq %rax, %r14
cmpq $-0x1, %rax
jne 0x3d99
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 0x3db9
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 0x4210
movq %r12, %rdi
callq 0x47bc
movq %r12, %rdi
movq -0x38(%rbp), %rsi
leaq -0x80(%rbp), %rdx
callq 0x4872
movq %r12, %rdi
callq 0x571e
movq %r15, %rdi
callq 0x3070
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x3e2a
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x3250
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x3e4c
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x3250
incq %r13
cmpl %r13d, -0x30(%rbp)
jne 0x3d52
movq 0x7168(%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 0x3ea8
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3250
xorl %eax, %eax
jmp 0x40f0
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x33e0
leaq 0x44e8(%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 0x7338(%rip), %r14      # 0xb240
testq %r14, %r14
je 0x3f29
movq %r14, %rdi
callq 0x3100
movq 0x70b4(%rip), %rdi      # 0xafd0
movq %r14, %rsi
movq %rax, %rdx
callq 0x32a0
jmp 0x3f40
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x33e0
movq 0x7089(%rip), %r14      # 0xafd0
leaq 0x4482(%rip), %rsi      # 0x83d0
movl $0x4, %edx
movq %r14, %rdi
callq 0x32a0
movq (%r13), %rbx
testq %rbx, %rbx
je 0x3f80
movq %rbx, %rdi
callq 0x3100
movq 0x705d(%rip), %rdi      # 0xafd0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x32a0
jmp 0x3f98
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x33e0
leaq 0x4441(%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 0x43f6(%rip), %rsi      # 0x83d0
movl $0x4, %edx
movq %r14, %rdi
callq 0x32a0
movq (%r13), %rbx
testq %rbx, %rbx
je 0x400c
movq %rbx, %rdi
callq 0x3100
movq 0x6fd1(%rip), %rdi      # 0xafd0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x32a0
jmp 0x4024
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x33e0
leaq 0x43aa(%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 0x436a(%rip), %rsi      # 0x83d0
movl $0x4, %edx
movq %r14, %rdi
callq 0x32a0
movq (%r13), %rbx
testq %rbx, %rbx
je 0x4098
movq %rbx, %rdi
callq 0x3100
movq 0x6f45(%rip), %rdi      # 0xafd0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x32a0
jmp 0x40b0
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x33e0
leaq 0x4338(%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 0x4149
jmp 0x4144
jmp 0x4108
movq %rax, %rbx
movq -0x328(%rbp), %rdi
leaq -0x318(%rbp), %rax
cmpq %rax, %rdi
je 0x41b0
movq -0x318(%rbp), %rsi
incq %rsi
callq 0x3250
jmp 0x41b0
jmp 0x4149
movq %rax, %rbx
jmp 0x4182
movq %rax, %rbx
jmp 0x4169
movq %rax, %rbx
jmp 0x415d
movq %rax, %rbx
jmp 0x41b0
movq %rax, %rbx
jmp 0x41a4
movq %rax, %rbx
leaq -0x328(%rbp), %rdi
callq 0x571e
leaq -0x730(%rbp), %rdi
callq 0x3070
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x4182
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x3250
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x41a4
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 0x41c9
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3250
movq %rbx, %rdi
callq 0x3420
nop