// File: /workspace/github_c_makefile_star2_O3/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 0x4a7c(%rip), %rdi      # 0x899f
callq 0x2060
leaq 0x4a8d(%rip), %rdi      # 0x89bc
callq 0x2060
leaq 0x4a8b(%rip), %rdi      # 0x89c6
callq 0x2060
leaq 0x4aba(%rip), %rdi      # 0x8a01
callq 0x2060
leaq 0x4b0c(%rip), %rdi      # 0x8a5f
callq 0x2060
leaq 0x4b6f(%rip), %rdi      # 0x8ace
callq 0x2060
leaq 0x4b99(%rip), %rdi      # 0x8b04
callq 0x2060
leaq 0x4bc1(%rip), %rdi      # 0x8b38
callq 0x2060
leaq 0x4bf2(%rip), %rdi      # 0x8b75
callq 0x2060
leaq 0x466e(%rip), %r15      # 0x85fd
leaq 0x46ca(%rip), %rcx      # 0x8660
leaq 0x466b(%rip), %r8       # 0x8608
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 0x463e(%rip), %r14      # 0x860d
leaq 0x463f(%rip), %rcx      # 0x8615
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20b0
leaq 0x4642(%rip), %rcx      # 0x862c
leaq 0x463d(%rip), %r8       # 0x862e
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 0x461d(%rip), %rcx      # 0x8636
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20b0
leaq 0x462f(%rip), %r12      # 0x865c
movq %r12, (%rsp)
leaq 0x460d(%rip), %r13      # 0x8645
leaq 0x461b(%rip), %rcx      # 0x865a
leaq 0x4627(%rip), %r9       # 0x866d
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 0x45f1(%rip), %rcx      # 0x8662
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20b0
movq %r12, (%rsp)
leaq 0x45ea(%rip), %rcx      # 0x8673
leaq 0x45f0(%rip), %r9       # 0x8680
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 0x45ba(%rip), %rcx      # 0x8675
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20b0
leaq 0x4aa4(%rip), %rcx      # 0x8b73
leaq 0x45b1(%rip), %r8       # 0x8687
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 0x4592(%rip), %rcx      # 0x8690
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20b0
leaq 0x45a1(%rip), %rcx      # 0x86b3
leaq 0x459c(%rip), %r8       # 0x86b5
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 0x457c(%rip), %rcx      # 0x86bd
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20b0
leaq 0x4586(%rip), %r15      # 0x86db
leaq 0x4591(%rip), %rcx      # 0x86ed
leaq 0x4583(%rip), %r12      # 0x86e6
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 0x456b(%rip), %rcx      # 0x86f9
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20b0
leaq 0x4548(%rip), %rcx      # 0x86ea
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 0x4528(%rip), %rcx      # 0x86f5
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20b0
leaq 0x4533(%rip), %rcx      # 0x8714
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 0x450f(%rip), %rcx      # 0x871b
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20b0
leaq 0x4524(%rip), %rcx      # 0x8744
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 0x4500(%rip), %rcx      # 0x874b
movq %r14, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x20b0
leaq 0x4511(%rip), %rcx      # 0x8770
leaq 0x4512(%rip), %r8       # 0x8778
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 0x44fc(%rip), %rcx      # 0x8785
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x20b0
movl $0xa, %edi
callq 0x2040
leaq 0x48d5(%rip), %rdi      # 0x8b7e
callq 0x2060
leaq 0x4912(%rip), %rdi      # 0x8bc7
callq 0x2060
leaq 0x496d(%rip), %rdi      # 0x8c2e
callq 0x2060
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq