// File: /workspace/github_cpp_makefile_star2_O2/FreeSlave[P]def2fgd/src/main.cpp
// Function: main
int main(int argc, char** argv)
{
    const char* format = "";
    const char* inputFileName = 0;
    const char* outputFileName = 0;
    FGDWriteOptions options;

    const char* package = "def2fgd";
    const char* localeDir = LOCALEDIR;

    generateLocale(package, localeDir);

    std::vector<const char*> positionalArgs;
    const char* programName = argv[0];
    for(int i=1; i<argc; ++i) {
        const char* arg = argv[i];
        if (strcmp(arg, "-format") == 0) {
            if (format[0]) {
                fputs(translate("-format option repetition\n").c_str(), stderr);
                return EXIT_FAILURE;
            }

            i++;
            if (i < argc) {
                format = argv[i];
            } else {
                fputs(translate("-format requires argument\n").c_str(), stderr);
                return EXIT_FAILURE;
            }
        } else if (strcmp(arg, "-bob") == 0) {
            if (options.bob) {
                printBobparms(options);
                return EXIT_FAILURE;
            }

            options.bobparms[0] = 180;
            options.bobparms[1] = 8;
            options.bobparms[2] = 0;
            options.bob = true;
        } else if (strcmp(arg, "-bobparms") == 0) {
            if (options.bob) {
                printBobparms(options);
                return EXIT_FAILURE;
            }

            i++;
            if (i < argc) {
                char* current = argv[i];
                options.bobparms[0] = static_cast<int>(strtol(current, &current, 10));
                options.bobparms[1] = static_cast<int>(strtol(current, &current, 10));
                options.bobparms[2] = static_cast<int>(strtol(current, NULL, 10));
                options.bob = true;
            } else {
                fputs(translate("-bobparms requires argument\n").c_str(), stderr);
                return EXIT_FAILURE;
            }
        } else if (strcmp(arg, "-offset-glob") == 0) {
            i++;
            if (i < argc) {
                options.offsetPatterns.push_back(argv[i]);
            } else {
                fputs(translate("-offset-glob requires argument\n").c_str(), stderr);
                return EXIT_FAILURE;
            }
        } else if (strcmp(arg, "-bob-glob") == 0) {
            i++;
            if (i < argc) {
                options.bobPatterns.push_back(argv[i]);
            } else {
                fputs(translate("-bob-glob requires argument\n").c_str(), stderr);
                return EXIT_FAILURE;
            }

        } else if (strcmp(arg, "-noauto-bob-glob") == 0) {
            options.useDefaultBobPatterns = false;
        } else if (strcmp(arg, "-noauto-offset-glob") == 0) {
            options.useDefaultOffsetPatterns = false;
        } else if (strcmp(arg, "-help") == 0 || strcmp(arg, "--help") == 0 || strcmp(arg, "-h") == 0) {
            printHelp(programName);
            return EXIT_SUCCESS;
        } else if (strcmp(arg, "-version") == 0 || strcmp(arg, "--version") == 0) {
            printVersion();
            return EXIT_SUCCESS;
        } else if (strcmp(arg, "--") == 0) {
            for (; ++i<argc;) {
                positionalArgs.push_back(argv[i]);
            }
        } else if (arg[0] == '-' && arg[1] != '\0') {
            fprintf(stderr, translate("Unknown parameter: %s\n").c_str(), arg);
            printHint(argv[0]);
            return EXIT_FAILURE;
        } else {
            positionalArgs.push_back(arg);
        }
    }

    if (positionalArgs.size() > 0) {
        inputFileName = positionalArgs[0];
        if (positionalArgs.size() > 1) {
            outputFileName = positionalArgs[1];
        }
    }

    if (inputFileName && strcmp(inputFileName, "-") == 0) {
        inputFileName = 0;
    }

    if (outputFileName && strcmp(outputFileName, "-") == 0) {
        outputFileName = 0;
    }

    if (format[0] == '\0') {
        if (inputFileName) {
            const char* extension = strrchr(inputFileName, '.');
            if (extension && strcmp(extension, ".ent") == 0){
                format = "ent";
            } else if (extension && strcmp(extension, ".def") == 0) {
                format = "def";
            } else {
                fputs(translate("Could not detect input format. Use -format option to explicitly set it.\n").c_str(), stderr);
                return EXIT_FAILURE;
            }
        } else {
            fputs(translate("No input file name nor format given.\n").c_str(), stderr);
            printHint(argv[0]);
            return EXIT_FAILURE;
        }
    }

    std::istream* inStream = &std::cin;
    std::ostream* outStream = &std::cout;

    std::ifstream inFile;
    std::ofstream outFile;

    if (inputFileName != 0) {
        inFile.open(inputFileName);
        if (!inFile) {
            fprintf(stderr, translate("Could not open file %s for reading: %s\n").c_str(), inputFileName, strerror(errno));
            return EXIT_FAILURE;
        }
        inStream = &inFile;
    }

    try
    {
        std::vector<Entity> entities;
        if (strcmp(format, "def") == 0) {
            entities = readDefFile(*inStream);
        } else if (strcmp(format, "ent") == 0) {
            entities = readEntFile(*inStream);
        } else {
            fprintf(stderr, translate("Unknown format '%s'\n").c_str(), format);
            return EXIT_FAILURE;
        }

        if (outputFileName) {
            outFile.open(outputFileName);
            if (!outFile) {
                fprintf(stderr, translate("Could not open file %s for writing: %s\n").c_str(), outputFileName, strerror(errno));
                return EXIT_FAILURE;
            }
            outStream = &outFile;
        }

        writefgd(*outStream, entities, options);
        outStream->flush();
    }
    catch(DefReadError& e)
    {
        if (inputFileName) {
            fprintf(stderr, translate("%s:%d:%d: error: %s\n").c_str(), inputFileName, e.line(), e.column(), e.what());
        } else {
            fprintf(stderr, translate("%d:%d: error: %s\n").c_str(), e.line(), e.column(), e.what());
        }

        return EXIT_FAILURE;
    }
    catch(std::exception& e)
    {
        fprintf(stderr, translate("Error: %s\n").c_str(), e.what());
        return EXIT_FAILURE;
    }
    return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4c8, %rsp            # imm = 0x4C8
movq %rsi, %r14
movw $0x100, 0x3c(%rsp)      # imm = 0x100
movb $0x1, 0x3e(%rsp)
andl $0x0, 0x38(%rsp)
movl %edi, %ebp
andq $0x0, 0x30(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rsp)
movups %xmm0, 0x50(%rsp)
movups %xmm0, 0x60(%rsp)
leaq 0x6376(%rip), %rdi      # 0xa5f8
leaq 0x6377(%rip), %rsi      # 0xa600
leaq 0x5f5e(%rip), %rbx      # 0xa1ee
movq %rbx, %rdx
callq 0x95ec
leaq 0x90(%rsp), %rax
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movq (%r14), %rax
movq %rax, 0xa8(%rsp)
movslq %ebp, %rax
movq %rax, 0xb8(%rsp)
leaq 0x8(%r14), %rax
movq %rax, 0xb0(%rsp)
pushq $0x1
popq %r12
cmpl %ebp, %r12d
jge 0x4592
movslq %r12d, %r15
movq (%r14,%r15,8), %r13
movq %r13, 0x2c8(%rsp)
movq %r13, %rdi
leaq 0x6314(%rip), %rsi      # 0xa607
callq 0x3360
testl %eax, %eax
je 0x4447
movq %r13, %rdi
leaq 0x633b(%rip), %rsi      # 0xa645
callq 0x3360
testl %eax, %eax
je 0x4468
movq %r13, %rdi
leaq 0x6329(%rip), %rsi      # 0xa64a
callq 0x3360
testl %eax, %eax
je 0x4489
movq %r13, %rdi
leaq 0x638e(%rip), %rsi      # 0xa6c6
callq 0x3360
testl %eax, %eax
je 0x4504
movq %r13, %rdi
leaq 0x6366(%rip), %rsi      # 0xa6b5
callq 0x3360
testl %eax, %eax
je 0x4523
movq %r13, %rdi
leaq 0x6348(%rip), %rsi      # 0xa6ae
callq 0x3360
testl %eax, %eax
je 0x4542
movq %r13, %rdi
leaq 0x6342(%rip), %rsi      # 0xa6bf
callq 0x3360
testl %eax, %eax
je 0x4549
movq %rbx, 0x28(%rsp)
movq %r13, %rdi
leaq 0x633b(%rip), %rsi      # 0xa6d4
callq 0x3360
testl %eax, %eax
je 0x466f
movq %r13, %rdi
leaq 0x6323(%rip), %rsi      # 0xa6d3
callq 0x3360
testl %eax, %eax
je 0x466f
movb (%r13), %bl
cmpb $0x2d, %bl
jne 0x43d8
cmpb $0x68, 0x1(%r13)
jne 0x43d8
cmpb $0x0, 0x2(%r13)
je 0x466f
movq %r13, %rdi
leaq 0x62f9(%rip), %rsi      # 0xa6db
callq 0x3360
testl %eax, %eax
je 0x488c
movq %r13, %rdi
leaq 0x62e1(%rip), %rsi      # 0xa6da
callq 0x3360
testl %eax, %eax
je 0x488c
cmpb $0x2d, %bl
movq 0x28(%rsp), %rbx
jne 0x442d
cmpb $0x2d, 0x1(%r13)
jne 0x4422
cmpb $0x0, 0x2(%r13)
je 0x4550
cmpb $0x0, 0x1(%r13)
jne 0x49c1
leaq 0x90(%rsp), %rdi
leaq 0x2c8(%rsp), %rsi
callq 0x4eb0
jmp 0x44fc
cmpb $0x0, (%rbx)
jne 0x4918
incl %r12d
cmpl %ebp, %r12d
jge 0x492e
movslq %r12d, %rax
movq (%r14,%rax,8), %rbx
jmp 0x44fc
cmpb $0x0, 0x3c(%rsp)
jne 0x45ca
movabsq $0x8000000b4, %rax      # imm = 0x8000000B4
movq %rax, 0x30(%rsp)
andl $0x0, 0x38(%rsp)
jmp 0x44f7
cmpb $0x1, 0x3c(%rsp)
je 0x45ca
incl %r12d
cmpl %ebp, %r12d
jge 0x495a
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
movq %rdi, 0xc0(%rsp)
leaq 0xc0(%rsp), %r15
movq %r15, %rsi
pushq $0xa
popq %r13
movl %r13d, %edx
callq 0x3370
movl %eax, 0x30(%rsp)
movq 0xc0(%rsp), %rdi
movq %r15, %rsi
movl %r13d, %edx
callq 0x3370
movl %eax, 0x34(%rsp)
movq 0xc0(%rsp), %rdi
xorl %esi, %esi
movl %r13d, %edx
callq 0x3370
movl %eax, 0x38(%rsp)
movb $0x1, 0x3c(%rsp)
incl %r12d
jmp 0x42d1
incl %r12d
cmpl %ebp, %r12d
jge 0x4970
movslq %r12d, %rax
leaq (%r14,%rax,8), %rsi
leaq 0x40(%rsp), %rdi
callq 0x4eb0
jmp 0x44fc
incl %r12d
cmpl %ebp, %r12d
jge 0x4986
movslq %r12d, %rax
leaq (%r14,%rax,8), %rsi
leaq 0x58(%rsp), %rdi
callq 0x4eb0
jmp 0x44fc
movb $0x0, 0x3d(%rsp)
jmp 0x44fc
movb $0x0, 0x3e(%rsp)
jmp 0x44fc
movq 0xb0(%rsp), %rax
leaq (%rax,%r15,8), %rsi
incq %r15
leaq 0x90(%rsp), %r12
cmpq 0xb8(%rsp), %r15
jge 0x4585
incq %r15
leaq 0x8(%rsi), %rbx
movq %r12, %rdi
callq 0x4eb0
movq %rbx, %rsi
jmp 0x4567
movl %r15d, %r12d
movq 0x28(%rsp), %rbx
jmp 0x44fc
movq 0x90(%rsp), %rax
movq 0x98(%rsp), %rcx
subq %rax, %rcx
je 0x45b6
movq (%rax), %r15
cmpq $0x9, %rcx
jb 0x45dc
movq 0x8(%rax), %r12
jmp 0x45df
cmpb $0x0, (%rbx)
je 0x4895
xorl %r12d, %r12d
xorl %r15d, %r15d
jmp 0x468a
leaq 0x30(%rsp), %rdi
callq 0x41ec
pushq $0x1
popq %rbx
jmp 0x4861
xorl %r12d, %r12d
testq %r15, %r15
je 0x45f7
cmpb $0x2d, (%r15)
jne 0x45fa
xorl %eax, %eax
cmpb $0x0, 0x1(%r15)
cmoveq %rax, %r15
jmp 0x45fa
xorl %r15d, %r15d
testq %r12, %r12
je 0x4614
cmpb $0x2d, (%r12)
jne 0x4617
xorl %eax, %eax
cmpb $0x0, 0x1(%r12)
cmoveq %rax, %r12
jmp 0x4617
xorl %r12d, %r12d
cmpb $0x0, (%rbx)
jne 0x468a
testq %r15, %r15
je 0x4895
pushq $0x2e
popq %rsi
movq %r15, %rdi
callq 0x32b0
testq %rax, %rax
je 0x4944
movq %rax, %rbx
leaq 0x60b8(%rip), %rsi      # 0xa6fb
movq %rax, %rdi
callq 0x3360
testl %eax, %eax
je 0x4683
leaq 0x60aa(%rip), %rsi      # 0xa700
movq %rbx, %rdi
callq 0x3360
testl %eax, %eax
jne 0x4944
leaq 0x6094(%rip), %rbx      # 0xa701
jmp 0x468a
xorl %ebx, %ebx
movq 0xa8(%rsp), %rdi
callq 0x4152
jmp 0x4861
leaq 0x6072(%rip), %rbx      # 0xa6fc
leaq 0xc0(%rsp), %rdi
callq 0x32d0
leaq 0x2c8(%rsp), %rdi
callq 0x3430
testq %r15, %r15
je 0x4727
leaq 0xc0(%rsp), %r14
pushq $0x8
popq %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x31a0
movq 0xc0(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xe0(%rsp,%rax)
je 0x472e
movq 0xa8e4(%rip), %rax      # 0xefc0
movq (%rax), %rbx
leaq 0x608e(%rip), %rsi      # 0xa774
leaq 0x8(%rsp), %rdi
callq 0x95ed
leaq 0x8(%rsp), %r14
movq (%r14), %r12
callq 0x3040
movl (%rax), %edi
callq 0x30c0
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x3380
movq %r14, %rdi
callq 0x3110
pushq $0x1
popq %rbx
jmp 0x4847
movq 0xa8a2(%rip), %r14      # 0xefd0
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
andq $0x0, 0x80(%rsp)
leaq 0x5fbb(%rip), %rsi      # 0xa701
movq %rbx, %rdi
callq 0x3360
testl %eax, %eax
je 0x4778
leaq 0x5fa3(%rip), %rsi      # 0xa6fc
movq %rbx, %rdi
callq 0x3360
testl %eax, %eax
jne 0x48d8
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x7262
jmp 0x4785
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x55fb
leaq 0x70(%rsp), %rdi
leaq 0x8(%rsp), %rbx
movq %rbx, %rsi
callq 0x5572
movq %rbx, %rdi
callq 0x4ece
testq %r12, %r12
je 0x481a
leaq 0x2c8(%rsp), %r14
pushq $0x10
popq %rdx
movq %r14, %rdi
movq %r12, %rsi
callq 0x3060
movq 0x2c8(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x2e8(%rsp,%rax)
je 0x4821
movq 0xa7e9(%rip), %rax      # 0xefc0
movq (%rax), %rbx
leaq 0x5fd0(%rip), %rsi      # 0xa7b1
leaq 0x8(%rsp), %rdi
callq 0x95ed
leaq 0x8(%rsp), %r14
movq (%r14), %r15
callq 0x3040
movl (%rax), %edi
callq 0x30c0
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x3380
movq %r14, %rdi
jmp 0x490b
movq 0xa797(%rip), %r14      # 0xefb8
leaq 0x70(%rsp), %rsi
leaq 0x30(%rsp), %rdx
movq %r14, %rdi
callq 0x361e
xorl %ebx, %ebx
movq %r14, %rdi
callq 0x31d0
leaq 0x70(%rsp), %rdi
callq 0x4ece
leaq 0x2c8(%rsp), %rdi
callq 0x33b0
leaq 0xc0(%rsp), %rdi
callq 0x3090
leaq 0x90(%rsp), %rdi
callq 0x5128
leaq 0x30(%rsp), %rdi
callq 0x4efa
movl %ebx, %eax
addq $0x4c8, %rsp            # imm = 0x4C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x418d
xorl %ebx, %ebx
jmp 0x4861
leaq 0x5eb2(%rip), %rsi      # 0xa74e
leaq 0xc0(%rsp), %rdi
callq 0x95ed
leaq 0xc0(%rsp), %rbx
movq (%rbx), %rdi
movq 0xa705(%rip), %rax      # 0xefc0
movq (%rax), %rsi
callq 0x32c0
movq %rbx, %rdi
callq 0x3110
movq (%r14), %rdi
callq 0x41a2
jmp 0x45d4
movq 0xa6e1(%rip), %rax      # 0xefc0
movq (%rax), %r14
leaq 0x5eb3(%rip), %rsi      # 0xa79c
leaq 0x8(%rsp), %rdi
callq 0x95ed
leaq 0x8(%rsp), %r15
movq (%r15), %rsi
movq %r14, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x3380
movq %r15, %rdi
callq 0x3110
pushq $0x1
popq %rbx
jmp 0x483d
leaq 0x5cf0(%rip), %rsi      # 0xa60f
leaq 0xc0(%rsp), %rdi
callq 0x95ed
jmp 0x499a
leaq 0x5cf5(%rip), %rsi      # 0xa62a
leaq 0xc0(%rsp), %rdi
callq 0x95ed
jmp 0x499a
leaq 0x5dba(%rip), %rsi      # 0xa705
leaq 0xc0(%rsp), %rdi
callq 0x95ed
jmp 0x499a
leaq 0x5cf3(%rip), %rsi      # 0xa654
leaq 0xc0(%rsp), %rdi
callq 0x95ed
jmp 0x499a
leaq 0x5cfa(%rip), %rsi      # 0xa671
leaq 0xc0(%rsp), %rdi
callq 0x95ed
jmp 0x499a
leaq 0x5d04(%rip), %rsi      # 0xa691
leaq 0xc0(%rsp), %rdi
callq 0x95ed
leaq 0xc0(%rsp), %rbx
movq (%rbx), %rdi
movq 0xa614(%rip), %rax      # 0xefc0
movq (%rax), %rsi
callq 0x32c0
movq %rbx, %rdi
callq 0x3110
jmp 0x45d4
movq 0xa5f8(%rip), %rax      # 0xefc0
movq (%rax), %rbx
leaq 0x5d12(%rip), %rsi      # 0xa6e4
leaq 0xc0(%rsp), %rdi
callq 0x95ed
leaq 0xc0(%rsp), %r15
movq (%r15), %rsi
movq 0x2c8(%rsp), %rdx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3380
movq %r15, %rdi
callq 0x3110
movq (%r14), %rdi
callq 0x41a2
jmp 0x45d4
jmp 0x4c0b
jmp 0x4c0b
jmp 0x4c0b
jmp 0x4c0b
jmp 0x4c0b
jmp 0x4c0b
jmp 0x4a81
jmp 0x4c0b
jmp 0x4c0b
jmp 0x4c0b
jmp 0x4a81
jmp 0x4a81
jmp 0x4a81
jmp 0x4a4d
jmp 0x4c0b
movq %rax, %rbx
leaq 0x2c8(%rsp), %rdi
callq 0x33b0
jmp 0x4a62
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x3090
jmp 0x4c0e
jmp 0x4c0b
movq %rax, %rbx
jmp 0x4c1b
movq %rdx, %r14
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x4ece
cmpl $0x2, %r14d
jne 0x4b05
movq %rbx, %rdi
callq 0x30e0
movq %rax, %r14
movq 0xa517(%rip), %rax      # 0xefc0
movq (%rax), %rbx
testq %r15, %r15
jne 0x4b68
leaq 0x5d2b(%rip), %rsi      # 0xa7e7
leaq 0x8(%rsp), %rdi
callq 0x95ed
movq 0x8(%rsp), %r15
movq %r14, %rdi
callq 0x55f0
movq %rax, %r12
movq %r14, %rdi
callq 0x55f6
movq %rax, %r13
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %r13, %rcx
movq %rax, %r8
xorl %eax, %eax
callq 0x3380
jmp 0x4bb6
cmpl $0x1, %r14d
jne 0x4a50
movq %rbx, %rdi
callq 0x30e0
movq %rax, %r14
movq 0xa49f(%rip), %rax      # 0xefc0
movq (%rax), %rbx
leaq 0x5cae(%rip), %rsi      # 0xa7d9
leaq 0x8(%rsp), %rdi
callq 0x95ed
leaq 0x8(%rsp), %r15
movq (%r15), %r12
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3380
movq %r15, %rdi
callq 0x3110
callq 0x3410
jmp 0x471f
leaq 0x5c75(%rip), %rsi      # 0xa7e4
leaq 0x8(%rsp), %rdi
callq 0x95ed
movq 0x8(%rsp), %r12
movq %r14, %rdi
callq 0x55f0
movq %rax, %r13
movq %r14, %rdi
callq 0x55f6
movq %rax, %rbp
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r13, %rcx
movq %rbp, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0x3380
leaq 0x8(%rsp), %rdi
callq 0x3110
callq 0x3410
jmp 0x471f
jmp 0x4a4d
jmp 0x4a4d
jmp 0x4bd6
movq %rax, %rbx
jmp 0x4bf7
jmp 0x4bea
movq %rax, %rbx
callq 0x3410
jmp 0x4a50
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3110
callq 0x3410
jmp 0x4a50
movq %rax, %rdi
callq 0x4eef
jmp 0x4c0b
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x5128
leaq 0x30(%rsp), %rdi
callq 0x4efa
movq %rbx, %rdi
callq 0x3460