// File: /workspace/github_c_makefile_star2_O1/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), %r13
movq %r13, -0x10(%r13)
leaq 0xc62(%rip), %rsi       # 0x3127
leaq 0xc64(%rip), %rdx       # 0x3130
leaq 0x8(%rsp), %rdi
callq 0x2d22
xorl %r12d, %r12d
cmpl $0x2, %ebp
jge 0x24e8
movb $0x1, %r14b
xorl %ebx, %ebx
jmp 0x2710
leaq 0xa0(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl %ebp, %r15d
movl $0x1, %ebp
leaq 0x68(%rsp), %r13
xorl %r14d, %r14d
movl $0x0, 0x4(%rsp)
movq 0x88(%rsp), %rax
movq (%rax,%rbp,8), %rsi
cmpb $0x2d, (%rsi)
jne 0x261f
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
leaq 0x3(%rsp), %rdx
callq 0x2ce4
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 0x2581
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2100
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x259d
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2100
leaq 0x90(%rsp), %rdi
leaq 0xb85(%rip), %rsi       # 0x3131
callq 0x2070
testl %eax, %eax
je 0x267c
movl $0x1c, %edx
movq 0x2a2b(%rip), %rdi      # 0x4ff0
leaq 0xb6a(%rip), %rsi       # 0x3136
callq 0x2120
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
movq 0x2a08(%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 0x26d1
movq %r13, %rdi
leaq 0x28(%rsp), %rdx
callq 0x2ce4
leaq 0x90(%rsp), %rdi
movq %r13, %rsi
callq 0x2130
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x2658
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2100
leaq 0x48(%rsp), %rdi
testl %r12d, %r12d
je 0x266d
cmpl $0x1, %r12d
jne 0x2684
leaq 0x8(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x2090
jmp 0x26ce
movb $0x1, %al
movl %eax, 0x4(%rsp)
jmp 0x26d1
movl $0x23, %edx
movq 0x2960(%rip), %rdi      # 0x4ff0
leaq 0xabc(%rip), %rsi       # 0x3153
callq 0x2120
movq 0x294d(%rip), %rcx      # 0x4ff0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq 0x292f(%rip), %rdi      # 0x4ff0
callq 0x2030
movq %rax, %rdi
callq 0x20b0
incl %r12d
incq %rbp
cmpq %rbp, %r15
jne 0x2517
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x2702
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x2100
leaq 0x58(%rsp), %r15
leaq 0x18(%rsp), %r13
movl 0x4(%rsp), %ebx
testb $0x1, %r14b
je 0x2725
movl $0x1, %ebx
callq 0x22cc
jmp 0x2bf0
movq 0x48(%rsp), %rsi
leaq 0x90(%rsp), %rdi
movl $0xc, %edx
callq 0x2190
leaq 0x108(%rsp), %rdi
callq 0x2050
testb %al, %al
je 0x28f5
movq 0x2878(%rip), %rdi      # 0x4fd0
leaq 0xa3d(%rip), %rsi       # 0x319c
movl $0x2e, %edx
callq 0x2120
testb $0x1, %bl
je 0x296b
movq 0x2857(%rip), %rdi      # 0x4fd0
leaq 0xa77(%rip), %rsi       # 0x31f7
movl $0xb, %edx
callq 0x2120
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x2835(%rip), %rdi      # 0x4fd0
callq 0x2120
leaq 0xa39(%rip), %rsi       # 0x31e0
movl $0x4, %edx
movq %rax, %rdi
callq 0x2120
movq 0x2815(%rip), %r14      # 0x4fd0
leaq 0xa07(%rip), %rsi       # 0x31c9
movl $0x1, %edx
movq %r14, %rdi
callq 0x2120
xorl %ebx, %ebx
leaq 0x90(%rsp), %r15
leaq 0x28(%rsp), %r12
leaq 0xa24(%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 0x2ada
testl %r13d, %r13d
jne 0x281e
movl $0x5, %edx
movq %r14, %rdi
leaq 0x9ea(%rip), %rsi       # 0x3203
callq 0x2120
incl %r13d
movb 0x28(%rsp), %al
movzbl %al, %ecx
cmpl $0x9, %ecx
jle 0x2845
cmpl $0xa, %ecx
je 0x285a
cmpl $0xd, %ecx
je 0x2873
cmpl $0x22, %ecx
jne 0x288e
leaq 0x9c9(%rip), %rsi       # 0x320c
jmp 0x287a
movq %rbp, %rsi
testl %ecx, %ecx
je 0x287a
cmpl $0x9, %ecx
jne 0x288e
leaq 0x9b7(%rip), %rsi       # 0x320f
jmp 0x287a
xorl %r13d, %r13d
movl $0x4, %edx
movq %r14, %rdi
leaq 0x9a9(%rip), %rsi       # 0x3215
callq 0x2120
jmp 0x2887
leaq 0x998(%rip), %rsi       # 0x3212
movl $0x2, %edx
movq %r14, %rdi
callq 0x2120
incl %ebx
jmp 0x27e8
leal -0x7f(%rax), %ecx
cmpb $-0x60, %cl
ja 0x28dd
movl $0x2, %edx
movq %r14, %rdi
leaq 0x975(%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 0x2887
movb %al, 0x68(%rsp)
movl $0x1, %edx
movq %r14, %rdi
leaq 0x68(%rsp), %rsi
callq 0x2120
jmp 0x2887
movq 0x26f4(%rip), %rdi      # 0x4ff0
leaq 0x874(%rip), %rsi       # 0x3177
movl $0x16, %edx
callq 0x2120
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x26d2(%rip), %rdi      # 0x4ff0
callq 0x2120
movq %rax, %rbx
leaq 0x861(%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 0x2be3
movq 0x265e(%rip), %rdi      # 0x4fd0
leaq 0x852(%rip), %rsi       # 0x31cb
movl $0x14, %edx
callq 0x2120
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x263c(%rip), %rbx      # 0x4fd0
movq %rbx, %rdi
callq 0x2120
leaq 0x83d(%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 0x29f3
movq %r14, %rdi
movl $0x20, %esi
callq 0x20f0
movb %al, 0xe0(%r14)
movb $0x1, 0xe1(%r14)
movb $0x30, 0xe0(%r14)
movq 0x25ce(%rip), %r14      # 0x4fd0
leaq 0x7dc(%rip), %rsi       # 0x31e5
movl $0x3, %edx
movq %r14, %rdi
callq 0x2120
xorl %ebx, %ebx
leaq 0x90(%rsp), %r15
leaq 0x28(%rsp), %r12
leaq 0x7c2(%rip), %r13       # 0x31ee
leaq 0x7be(%rip), %rbp       # 0x31f1
movq %r15, %rdi
movq %r12, %rsi
callq 0x2140
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2b1b
xorl %eax, %eax
testb $0xf, %bl
sete %al
leaq 0x78d(%rip), %rsi       # 0x31ec
leaq 0x783(%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 0x2a33
movl $0x1, %edx
movq %r14, %rdi
leaq 0x6f9(%rip), %rsi       # 0x31c9
callq 0x2120
jmp 0x2a33
testl %r13d, %r13d
leaq 0x58(%rsp), %r15
leaq 0x18(%rsp), %r13
je 0x2b01
movq 0x24e0(%rip), %rdi      # 0x4fd0
leaq 0x720(%rip), %rsi       # 0x3217
movl $0x2, %edx
callq 0x2120
movq 0x24c8(%rip), %rdi      # 0x4fd0
leaq 0x6e5(%rip), %rsi       # 0x31f4
movl $0x2, %edx
callq 0x2120
jmp 0x2b5a
testb $0xf, %bl
leaq 0x58(%rsp), %r15
leaq 0x18(%rsp), %r13
je 0x2b42
movq 0x249f(%rip), %rdi      # 0x4fd0
leaq 0x691(%rip), %rsi       # 0x31c9
movl $0x1, %edx
callq 0x2120
movq 0x2487(%rip), %rdi      # 0x4fd0
leaq 0x6a3(%rip), %rsi       # 0x31f3
movl $0x3, %edx
callq 0x2120
movq 0x246f(%rip), %rdi      # 0x4fd0
leaq 0x6b5(%rip), %rsi       # 0x321d
movl $0xb, %edx
callq 0x2120
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x244d(%rip), %rdi      # 0x4fd0
callq 0x2120
movq %rax, %r14
leaq 0x697(%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 0x62d(%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 %r13, %rdi
je 0x2c07
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2100
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x2c1e
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 0x2c34
movq %rax, %rbx
jmp 0x2ca3
jmp 0x2c69
movq %rax, %rbx
jmp 0x2cbf
jmp 0x2c69
jmp 0x2c7b
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x2c7e
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2100
jmp 0x2c7e
jmp 0x2c7b
jmp 0x2c69
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x2060
jmp 0x2ca3
movq %rax, %rbx
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x2ca3
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x2100
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2cbf
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2100
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x2cdb
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2100
movq %rbx, %rdi
callq 0x2170
nop