// File: /workspace/github_c_makefile_star2_O1/jogolden[P]ps4flashtool/flashtool.c
// Function: print_usage
void print_usage() {
    char strbuffer[1024];

    printf("Usage: flashtool [option(s)]\n");
    printf("Examples:\n");
    printf("\tflashtool -k CXD42G.keys --extract dumps -i flashdump.bin\n");
    printf("\tflashtool --emcipl patchedipl.bin -k CXD44G.keys --input flashdump.bin --output flashout.bin\n");
    printf("\tflashtool --eapkbl patchedkbl.bin -k cec_h4x_sram_dmp_CXD36G.keys --input flashdump.bin --output flashout.bin\n");
    printf("\tflashtool -k CXD42G.keys -v -n --input flashdump.bin\n");
    printf("\tflashtool --extract dumps -n --input flashdump.bin\n");
    printf("\tflashtool --eapkern eapkern_hdd_enc.bin,eapkern_hdd_dec.bin\n");
    printf("Options:\n");

    #define PRINT_OPTION(short, long, hasarg, arg, comment) if(hasarg) { \
                snprintf(strbuffer, sizeof(strbuffer), "\t-%s [%s], --%s [%s]", short, arg, long, arg); \
            } else { \
                snprintf(strbuffer, sizeof(strbuffer), "\t-%s, --%s", short, long); \
            } printf("%s %*s\n", strbuffer, (int)(80 - strlen(strbuffer)), comment);
    #define PRINT_LONG_OPTION(long, hasarg, arg, comment) if(hasarg) { \
                snprintf(strbuffer, sizeof(strbuffer), "\t--%s [%s]", long, arg); \
            } else { \
                snprintf(strbuffer, sizeof(strbuffer), "\t--%s", long); \
            } printf("%s %*s\n", strbuffer, (int)(80 - strlen(strbuffer)), comment);

    PRINT_OPTION("h", "help", 0, "", "show this help message")
    PRINT_OPTION("v", "verbose", 0, "", "verbose output")
    PRINT_OPTION("i", "input", 1, "flash", "flash file input")
    PRINT_OPTION("o", "output", 1, "flash", "flash file output")
    PRINT_OPTION("n", "noverify", 0, "", "do not verify the flash signatures")
    PRINT_OPTION("k", "keyfile", 0, "", "override the default key file")
    PRINT_LONG_OPTION("extract", 1, "dir", "extract files to directory")
    PRINT_LONG_OPTION("rawextract", 1, "dir", "raw extract files to directory")
    PRINT_LONG_OPTION("emcipl", 1, "emcipl", "replace EMC IPL (initial program loader)")
    PRINT_LONG_OPTION("eapkbl", 1, "eapkbl", "replace EAP KBL (kernel boot loader)")
    PRINT_LONG_OPTION("eapkern", 1, "input,output", "decrypt the EAP kernel")

    printf("\n");
    printf("Everything you can replace in the flash is resigned when you replace it.\n");
    printf("Also, when the extract option is enabled, the files will be extracted after the replacement/resigning.\n");
    printf("!! This tool will never overwrite your existing flash dump file! You must specify an output. !!\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x418, %rsp            # imm = 0x418
leaq 0x4cca(%rip), %rdi      # 0x897f
callq 0x2060
leaq 0x4cdb(%rip), %rdi      # 0x899c
callq 0x2060
leaq 0x4cd9(%rip), %rdi      # 0x89a6
callq 0x2060
leaq 0x4d08(%rip), %rdi      # 0x89e1
callq 0x2060
leaq 0x4d5a(%rip), %rdi      # 0x8a3f
callq 0x2060
leaq 0x4dbd(%rip), %rdi      # 0x8aae
callq 0x2060
leaq 0x4de7(%rip), %rdi      # 0x8ae4
callq 0x2060
leaq 0x4e0f(%rip), %rdi      # 0x8b18
callq 0x2060
leaq 0x4e40(%rip), %rdi      # 0x8b55
callq 0x2060
leaq 0x48bc(%rip), %r15      # 0x85dd
leaq 0x4918(%rip), %rcx      # 0x8640
leaq 0x48b9(%rip), %r8       # 0x85e8
leaq 0x10(%rsp), %rbx
movl $0x400, %esi            # imm = 0x400
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x20c0
movq %rbx, %rdi
callq 0x2090
movl $0x50, %ebp
movl $0x50, %edx
subl %eax, %edx
leaq 0x488c(%rip), %r14      # 0x85ed
leaq 0x488d(%rip), %rcx      # 0x85f5
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20b0
leaq 0x4890(%rip), %rcx      # 0x860c
leaq 0x488b(%rip), %r8       # 0x860e
movl $0x400, %esi            # imm = 0x400
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x20c0
movq %rbx, %rdi
callq 0x2090
movl $0x50, %edx
subl %eax, %edx
leaq 0x486b(%rip), %rcx      # 0x8616
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20b0
leaq 0x487d(%rip), %r12      # 0x863c
movq %r12, (%rsp)
leaq 0x485b(%rip), %r13      # 0x8625
leaq 0x4869(%rip), %rcx      # 0x863a
leaq 0x4875(%rip), %r9       # 0x864d
movl $0x400, %esi            # imm = 0x400
movq %rbx, %rdi
movq %r13, %rdx
movq %r12, %r8
xorl %eax, %eax
callq 0x20c0
movq %rbx, %rdi
callq 0x2090
movl $0x50, %edx
subl %eax, %edx
leaq 0x483f(%rip), %rcx      # 0x8642
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20b0
movq %r12, (%rsp)
leaq 0x4838(%rip), %rcx      # 0x8653
leaq 0x483e(%rip), %r9       # 0x8660
movl $0x400, %esi            # imm = 0x400
movq %rbx, %rdi
movq %r13, %rdx
movq %r12, %r8
xorl %eax, %eax
callq 0x20c0
movq %rbx, %rdi
callq 0x2090
movl $0x50, %edx
subl %eax, %edx
leaq 0x4808(%rip), %rcx      # 0x8655
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20b0
leaq 0x4cf2(%rip), %rcx      # 0x8b53
leaq 0x47ff(%rip), %r8       # 0x8667
movl $0x400, %esi            # imm = 0x400
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x20c0
movq %rbx, %rdi
callq 0x2090
movl $0x50, %edx
subl %eax, %edx
leaq 0x47e0(%rip), %rcx      # 0x8670
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20b0
leaq 0x47ef(%rip), %rcx      # 0x8693
leaq 0x47ea(%rip), %r8       # 0x8695
movl $0x400, %esi            # imm = 0x400
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x20c0
movq %rbx, %rdi
callq 0x2090
movl $0x50, %edx
subl %eax, %edx
leaq 0x47ca(%rip), %rcx      # 0x869d
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20b0
leaq 0x47d4(%rip), %r15      # 0x86bb
leaq 0x47df(%rip), %rcx      # 0x86cd
leaq 0x47d1(%rip), %r12      # 0x86c6
movl $0x400, %esi            # imm = 0x400
movq %rbx, %rdi
movq %r15, %rdx
movq %r12, %r8
xorl %eax, %eax
callq 0x20c0
movq %rbx, %rdi
callq 0x2090
movl $0x50, %edx
subl %eax, %edx
leaq 0x47b9(%rip), %rcx      # 0x86d9
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20b0
leaq 0x4796(%rip), %rcx      # 0x86ca
movl $0x400, %esi            # imm = 0x400
movq %rbx, %rdi
movq %r15, %rdx
movq %r12, %r8
xorl %eax, %eax
callq 0x20c0
movq %rbx, %rdi
callq 0x2090
movl $0x50, %edx
subl %eax, %edx
leaq 0x4776(%rip), %rcx      # 0x86d5
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20b0
leaq 0x4781(%rip), %rcx      # 0x86f4
movl $0x400, %esi            # imm = 0x400
movq %rbx, %rdi
movq %r15, %rdx
movq %rcx, %r8
xorl %eax, %eax
callq 0x20c0
movq %rbx, %rdi
callq 0x2090
movl $0x50, %edx
subl %eax, %edx
leaq 0x475d(%rip), %rcx      # 0x86fb
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20b0
leaq 0x4772(%rip), %rcx      # 0x8724
movl $0x400, %esi            # imm = 0x400
movq %rbx, %rdi
movq %r15, %rdx
movq %rcx, %r8
xorl %eax, %eax
callq 0x20c0
movq %rbx, %rdi
callq 0x2090
movl $0x50, %edx
subl %eax, %edx
leaq 0x474e(%rip), %rcx      # 0x872b
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20b0
leaq 0x475f(%rip), %rcx      # 0x8750
leaq 0x4760(%rip), %r8       # 0x8758
movl $0x400, %esi            # imm = 0x400
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x20c0
movq %rbx, %rdi
callq 0x2090
subl %eax, %ebp
leaq 0x474a(%rip), %rcx      # 0x8765
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x20b0
movl $0xa, %edi
callq 0x2040
leaq 0x4b23(%rip), %rdi      # 0x8b5e
callq 0x2060
leaq 0x4b60(%rip), %rdi      # 0x8ba7
callq 0x2060
leaq 0x4bbb(%rip), %rdi      # 0x8c0e
callq 0x2060
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq