// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/jfbuild/tools/bin2c.cc
// Function: main
int main(int argc, const char * const argv[])
{
    bool showusage = false;
    string sourcefile;
    string symbol("bin2cdata");
    bool textmode = false;

    if (argc < 2) {
        showusage = true;
    } else {
        int    anonparam = 0;
        string opt;

        for (int i = 1; i < argc; ++i) {
            if (argv[i][0] == '-') {
                opt = string(argv[i]).substr(1);
                if (opt == "text") {
                    textmode = true;
                } else {
                    cerr << "error: unrecognised option -" << opt << endl;
                    showusage = true;
                }
            } else {
                opt = string(argv[i]);
                switch (anonparam) {
                    case 0:
                        sourcefile = opt;
                        break;
                    case 1:
                        symbol = opt;
                        break;
                    default:
                        cerr << "warning: too many parameters passed" << endl;
                        break;
                }
                anonparam++;
            }
        }
    }

    if (showusage) {
        usage();
        return 1;
    } else {
        ifstream sourcefs(sourcefile.c_str(), ios::in | ios::binary);
        int bytecount = 0;
        char chr;

        if (!sourcefs.is_open()) {
            cerr << "error: could not open " << sourcefile << " for reading." << endl;
            return 1;
        }
        cout << "// Generated by bin2c. Do not edit directly.\n\n";
        if (!textmode) {
            cout << "const unsigned char " << symbol << "[] =";
            cout << hex << setfill('0');
            cout << " {\n";
            while (sourcefs.get(chr)) {
                if ((bytecount & 15) == 0) {
                    cout << "    ";
                } else {
                    cout << " ";
                }
                cout << "0x" << setw(2) << (unsigned)(unsigned char)chr << ",";
                bytecount++;
                if ((bytecount & 15) == 0) {
                    cout << "\n";
                }
            }
            if ((bytecount & 15) > 0) {
                cout << "\n";
            }
            cout << "};\n";
        } else {
            int charcount = 0;

            cout << "const char " << symbol << "[] =";
            cout << "\n";
            while (sourcefs.get(chr)) {
                bytecount++;
                if (charcount == 0) {
                    cout << "    \"";
                }
                charcount++;
                switch (chr) {
                    case '\0':
                        cout << "\\0";
                        break;
                    case '"':
                        cout << "\\\"";
                        break;
                    case '\t':
                        cout << "\\t";
                        break;
                    case '\r':
                        cout << "\\r";
                        break;
                    case '\n':
                        cout << "\\n\"\n";
                        charcount = 0;
                        break;
                    default:
                        if (chr < 32 || chr >= 127) {
                            cout << "\\x" << hex << chr;
                        } else {
                            cout << chr;
                        }
                        break;
                }
            }
            if (charcount != 0) {
                cout << "\"\n";
            }
            cout << ";\n";
        }

        cout << "\nconst int " << symbol << "_size = " << dec << bytecount << ";\n";

        sourcefs.close();
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movq %rsi, 0x88(%rsp)
movl %edi, %ebp
leaq 0x58(%rsp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xc61(%rip), %rsi       # 0x3127
leaq 0xc63(%rip), %rdx       # 0x3130
leaq 0x8(%rsp), %rdi
callq 0x2d10
cmpl $0x2, %ebp
jl 0x270a
leaq 0xa0(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl %ebp, %r12d
xorl %r14d, %r14d
movl $0x1, %r15d
leaq 0x68(%rsp), %r13
xorl %ebp, %ebp
movl $0x0, 0x4(%rsp)
movq 0x88(%rsp), %rax
movq (%rax,%r15,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x261a
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
leaq 0x3(%rsp), %rdx
callq 0x2cd2
movl $0x1, %edx
movq %r13, %rdi
movq %rbx, %rsi
movq $-0x1, %rcx
callq 0x2110
leaq 0x90(%rsp), %rdi
movq %r13, %rsi
callq 0x2130
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x257c
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2100
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x2598
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2100
leaq 0x90(%rsp), %rdi
leaq 0xb8a(%rip), %rsi       # 0x3131
callq 0x2070
testl %eax, %eax
je 0x2675
movl $0x1c, %edx
movq 0x2a30(%rip), %rdi      # 0x4ff0
leaq 0xb6f(%rip), %rsi       # 0x3136
callq 0x2120
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
movq 0x2a0d(%rip), %rdi      # 0x4ff0
callq 0x2120
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movb $0x1, %r14b
movq %rax, %rdi
callq 0x20b0
jmp 0x26c9
movq %r13, %rdi
leaq 0x28(%rsp), %rdx
callq 0x2cd2
leaq 0x90(%rsp), %rdi
movq %r13, %rsi
callq 0x2130
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x2653
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2100
leaq 0x48(%rsp), %rdi
testl %ebp, %ebp
je 0x2666
cmpl $0x1, %ebp
jne 0x267d
leaq 0x8(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x2090
jmp 0x26c7
movb $0x1, %al
movl %eax, 0x4(%rsp)
jmp 0x26c9
movl $0x23, %edx
movq 0x2967(%rip), %rdi      # 0x4ff0
leaq 0xac3(%rip), %rsi       # 0x3153
callq 0x2120
movq 0x2954(%rip), %rcx      # 0x4ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq 0x2936(%rip), %rdi      # 0x4ff0
callq 0x2030
movq %rax, %rdi
callq 0x20b0
incl %ebp
incq %r15
cmpq %r15, %r12
jne 0x2512
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x26fa
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x2100
testb $0x1, %r14b
leaq 0x58(%rsp), %r15
leaq 0x18(%rsp), %r12
je 0x2719
movl $0x1, %ebx
callq 0x22cc
jmp 0x2bdf
movq 0x48(%rsp), %rsi
leaq 0x90(%rsp), %rdi
movl $0xc, %edx
callq 0x2190
leaq 0x108(%rsp), %rdi
callq 0x2050
testb %al, %al
je 0x28eb
movq 0x2884(%rip), %rdi      # 0x4fd0
leaq 0xa49(%rip), %rsi       # 0x319c
movl $0x2e, %edx
callq 0x2120
testb $0x1, 0x4(%rsp)
je 0x2961
movq 0x2861(%rip), %rdi      # 0x4fd0
leaq 0xa81(%rip), %rsi       # 0x31f7
movl $0xb, %edx
callq 0x2120
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x283f(%rip), %rdi      # 0x4fd0
callq 0x2120
leaq 0xa43(%rip), %rsi       # 0x31e0
movl $0x4, %edx
movq %rax, %rdi
callq 0x2120
movq 0x281f(%rip), %r14      # 0x4fd0
leaq 0xa11(%rip), %rsi       # 0x31c9
movl $0x1, %edx
movq %r14, %rdi
callq 0x2120
xorl %ebx, %ebx
leaq 0x90(%rsp), %r15
leaq 0x28(%rsp), %r12
leaq 0xa2e(%rip), %rbp       # 0x3209
xorl %r13d, %r13d
movq %r15, %rdi
movq %r12, %rsi
callq 0x2140
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2ac9
testl %r13d, %r13d
jne 0x2814
movl $0x5, %edx
movq %r14, %rdi
leaq 0x9f4(%rip), %rsi       # 0x3203
callq 0x2120
incl %r13d
movb 0x28(%rsp), %al
movzbl %al, %ecx
cmpl $0x9, %ecx
jle 0x283b
cmpl $0xa, %ecx
je 0x2850
cmpl $0xd, %ecx
je 0x2869
cmpl $0x22, %ecx
jne 0x2884
leaq 0x9d3(%rip), %rsi       # 0x320c
jmp 0x2870
movq %rbp, %rsi
testl %ecx, %ecx
je 0x2870
cmpl $0x9, %ecx
jne 0x2884
leaq 0x9c1(%rip), %rsi       # 0x320f
jmp 0x2870
xorl %r13d, %r13d
movl $0x4, %edx
movq %r14, %rdi
leaq 0x9b3(%rip), %rsi       # 0x3215
callq 0x2120
jmp 0x287d
leaq 0x9a2(%rip), %rsi       # 0x3212
movl $0x2, %edx
movq %r14, %rdi
callq 0x2120
incl %ebx
jmp 0x27de
leal -0x7f(%rax), %ecx
cmpb $-0x60, %cl
ja 0x28d3
movl $0x2, %edx
movq %r14, %rdi
leaq 0x97f(%rip), %rsi       # 0x321a
callq 0x2120
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0x18(%r14,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%r14,%rax)
movb 0x28(%rsp), %al
movb %al, 0x68(%rsp)
movl $0x1, %edx
movq %r14, %rdi
leaq 0x68(%rsp), %rsi
callq 0x2120
jmp 0x287d
movb %al, 0x68(%rsp)
movl $0x1, %edx
movq %r14, %rdi
leaq 0x68(%rsp), %rsi
callq 0x2120
jmp 0x287d
movq 0x26fe(%rip), %rdi      # 0x4ff0
leaq 0x87e(%rip), %rsi       # 0x3177
movl $0x16, %edx
callq 0x2120
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x26dc(%rip), %rdi      # 0x4ff0
callq 0x2120
movq %rax, %rbx
leaq 0x86b(%rip), %rsi       # 0x318e
movl $0xd, %edx
movq %rax, %rdi
callq 0x2120
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movl $0x1, %ebx
movq %rax, %rdi
callq 0x20b0
jmp 0x2bd2
movq 0x2668(%rip), %rdi      # 0x4fd0
leaq 0x85c(%rip), %rsi       # 0x31cb
movl $0x14, %edx
callq 0x2120
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x2646(%rip), %rbx      # 0x4fd0
movq %rbx, %rdi
callq 0x2120
leaq 0x847(%rip), %rsi       # 0x31e0
movl $0x4, %edx
movq %rax, %rdi
callq 0x2120
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movl 0x18(%rbx,%rcx), %edx
andl $-0x4b, %edx
orl $0x8, %edx
movl %edx, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %r14
cmpb $0x0, 0xe1(%rbx,%rax)
jne 0x29e2
movq %r14, %rdi
movl $0x20, %esi
callq 0x20f0
movb $0x1, 0xe1(%r14)
movb $0x30, 0xe0(%r14)
movq 0x25df(%rip), %r14      # 0x4fd0
leaq 0x7ed(%rip), %rsi       # 0x31e5
movl $0x3, %edx
movq %r14, %rdi
callq 0x2120
xorl %ebx, %ebx
leaq 0x90(%rsp), %r15
leaq 0x28(%rsp), %r12
leaq 0x7d3(%rip), %r13       # 0x31ee
leaq 0x7cf(%rip), %rbp       # 0x31f1
movq %r15, %rdi
movq %r12, %rsi
callq 0x2140
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2b0a
xorl %eax, %eax
testb $0xf, %bl
sete %al
leaq 0x79e(%rip), %rsi       # 0x31ec
leaq 0x794(%rip), %rcx       # 0x31e9
cmoveq %rcx, %rsi
leaq (%rax,%rax,2), %rdx
incq %rdx
movq %r14, %rdi
callq 0x2120
movl $0x2, %edx
movq %r14, %rdi
movq %r13, %rsi
callq 0x2120
movq (%r14), %rax
movq -0x18(%rax), %rax
movq $0x2, 0x10(%r14,%rax)
movzbl 0x28(%rsp), %esi
movq %r14, %rdi
callq 0x20a0
movl $0x1, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2120
incl %ebx
testb $0xf, %bl
jne 0x2a22
movl $0x1, %edx
movq %r14, %rdi
leaq 0x70a(%rip), %rsi       # 0x31c9
callq 0x2120
jmp 0x2a22
testl %r13d, %r13d
leaq 0x58(%rsp), %r15
leaq 0x18(%rsp), %r12
je 0x2af0
movq 0x24f1(%rip), %rdi      # 0x4fd0
leaq 0x731(%rip), %rsi       # 0x3217
movl $0x2, %edx
callq 0x2120
movq 0x24d9(%rip), %rdi      # 0x4fd0
leaq 0x6f6(%rip), %rsi       # 0x31f4
movl $0x2, %edx
callq 0x2120
jmp 0x2b49
testb $0xf, %bl
leaq 0x58(%rsp), %r15
leaq 0x18(%rsp), %r12
je 0x2b31
movq 0x24b0(%rip), %rdi      # 0x4fd0
leaq 0x6a2(%rip), %rsi       # 0x31c9
movl $0x1, %edx
callq 0x2120
movq 0x2498(%rip), %rdi      # 0x4fd0
leaq 0x6b4(%rip), %rsi       # 0x31f3
movl $0x3, %edx
callq 0x2120
movq 0x2480(%rip), %rdi      # 0x4fd0
leaq 0x6c6(%rip), %rsi       # 0x321d
movl $0xb, %edx
callq 0x2120
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x245e(%rip), %rdi      # 0x4fd0
callq 0x2120
movq %rax, %r14
leaq 0x6a8(%rip), %rsi       # 0x3229
movl $0x8, %edx
movq %rax, %rdi
callq 0x2120
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0x18(%r14,%rax), %ecx
andl $-0x4b, %ecx
orl $0x2, %ecx
movl %ecx, 0x18(%r14,%rax)
movq %r14, %rdi
movl %ebx, %esi
callq 0x2160
leaq 0x63e(%rip), %rsi       # 0x31f4
movl $0x2, %edx
movq %rax, %rdi
callq 0x2120
xorl %ebx, %ebx
leaq 0x90(%rsp), %rdi
callq 0x2040
leaq 0x90(%rsp), %rdi
callq 0x2060
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x2bf6
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2100
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x2c0d
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2100
movl %ebx, %eax
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2c25
jmp 0x2c58
movq %rax, %rbx
jmp 0x2c92
movq %rax, %rbx
jmp 0x2cae
jmp 0x2c58
jmp 0x2c58
jmp 0x2c6a
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x2c6d
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2100
jmp 0x2c6d
jmp 0x2c6a
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x2060
jmp 0x2c92
movq %rax, %rbx
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x2c92
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x2100
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2cae
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2100
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x2cca
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2100
movq %rbx, %rdi
callq 0x2170