// File: /workspace/github_cpp_makefile_star2_O2/sisong[P]ApkDiffPatch/src/zip_patch.cpp
// Function: zippatch_cmd_line(int, char const**)
int zippatch_cmd_line(int argc, const char * argv[]) {
    const char* oldZipPath=0;
    const char* zipDiffPath=0;
    const char* outNewZipPath=0;
    size_t      maxUncompressMemory=0;
    const char* tempUncompressFileName=0;
    hpatch_BOOL isOutputVersion=_kNULL_VALUE;
    size_t      threadNum = _THREAD_NUMBER_NULL;
    #define kMax_arg_values_size 5
    const char * arg_values[kMax_arg_values_size]={0};
    int          arg_values_size=0;
    int         i;
    for (i=1; i<argc; ++i) {
        const char* op=argv[i];
        _options_check((op!=0)&&(strlen(op)>0),"?");
        if (op[0]!='-'){
            _options_check(arg_values_size<kMax_arg_values_size,"count");
            arg_values[arg_values_size]=op;
            ++arg_values_size;
            continue;
        }
        _options_check((op!=0)&&(op[0]=='-'),"?");
        switch (op[1]) {
            case 'v':{
                _options_check((isOutputVersion==_kNULL_VALUE)&&(op[2]=='\0'),"-v");
                isOutputVersion=hpatch_TRUE;
            } break;
#if (_IS_USED_MULTITHREAD)
            case 'p':{
                _options_check((threadNum==_THREAD_NUMBER_NULL)&&((op[2]=='-')),"-p-?");
                const char* pnum=op+3;
                _options_check(a_to_size(pnum,strlen(pnum),&threadNum),"-p-?");
                _options_check(threadNum>=_THREAD_NUMBER_MIN,"-p-?");
            } break;
#endif
            default: {
                _options_check(hpatch_FALSE,"-?");
            } break;
        }//swich
    }
    if (isOutputVersion==_kNULL_VALUE)
        isOutputVersion=hpatch_FALSE;
    if (isOutputVersion){
        printf("ApkDiffPatch::ZipPatch v" APKDIFFPATCH_VERSION_STRING "\n\n");
        if (arg_values_size==0)
            return 0; //ok
    }
    if (threadNum==_THREAD_NUMBER_NULL)
        threadNum=_THREAD_NUMBER_MIN;
    else if (threadNum>_THREAD_NUMBER_MAX)
        threadNum=_THREAD_NUMBER_MAX;
    
    if(arg_values_size==3){
        oldZipPath   =arg_values[0];
        zipDiffPath  =arg_values[1];
        outNewZipPath=arg_values[2];
    }else if(arg_values_size==5){
        oldZipPath   =arg_values[0];
        zipDiffPath  =arg_values[1];
        outNewZipPath=arg_values[2];
        _options_check(kmg_to_size(arg_values[3],strlen(arg_values[3]),
                                   &maxUncompressMemory),"maxUncompressMemory");
        tempUncompressFileName=arg_values[4];
        _options_check((tempUncompressFileName!=0)
                       &&(strlen(tempUncompressFileName)>0),"tempUncompressFileName");
    }else{
        _options_check(false,"count");
    }
    hpatch_printPath_utf8((std::string("oldZip   : \"")+oldZipPath+"\"\n").c_str());
    hpatch_printPath_utf8((std::string("zipDiff  : \"")+zipDiffPath+"\"\n").c_str());
    hpatch_printPath_utf8((std::string("outNewZip: \"")+outNewZipPath+"\"\n").c_str());
    if (tempUncompressFileName!=0){
        printf("maxUncompressMemory:%" PRSizeT "\n",maxUncompressMemory);
        hpatch_printPath_utf8((std::string("tempUncompressFileName:\"")+tempUncompressFileName+"\"\n").c_str());
    }
    
    double time0=clock_s();
    int exitCode=ZipPatch(oldZipPath,zipDiffPath,outNewZipPath,
                          maxUncompressMemory,tempUncompressFileName,(int)threadNum);
    double time1=clock_s();
    if (exitCode==PATCH_SUCCESS)
        printf("  zip file patch ok!\n");
    else
        printf("  zip file patch error!\n");
    printf("\nZipPatch time: %.3f s\n",(time1-time0));
    return exitCode;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rsi, %rbx
leaq 0x88(%rsp), %rax
andq $0x0, (%rax)
xorps %xmm0, %xmm0
andq $0x0, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movslq %edi, %r12
movq $0x0, 0x10(%rsp)
pushq $-0x1
popq %r13
pushq $0x1
popq %r14
xorl %ebp, %ebp
cmpq %r12, %r14
jge 0x1aea2
movq (%rbx,%r14,8), %r15
testq %r15, %r15
je 0x1ae96
movzbl (%r15), %eax
cmpl $0x2d, %eax
je 0x1ae0d
testl %eax, %eax
je 0x1ae96
cmpl $0x5, %ebp
jge 0x1b14d
movslq %ebp, %rax
movq %r15, 0x90(%rsp,%rax,8)
incl %ebp
jmp 0x1ae8e
movzbl 0x1(%r15), %eax
cmpl $0x70, %eax
je 0x1ae3a
cmpl $0x76, %eax
jne 0x1b1e6
cmpl $-0x1, %r13d
jne 0x1b159
cmpb $0x0, 0x2(%r15)
pushq $0x1
popq %r13
je 0x1ae8e
jmp 0x1b159
cmpq $0x0, 0x10(%rsp)
jne 0x1b141
cmpb $0x2d, 0x2(%r15)
jne 0x1b141
addq $0x3, %r15
movq %r15, %rdi
callq 0x20e0
movq %r15, %rdi
movq %rax, %rsi
leaq 0x88(%rsp), %rdx
callq 0x1b2da
testl %eax, %eax
je 0x1b141
movq 0x88(%rsp), %rax
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x1b141
incq %r14
jmp 0x1adcb
leaq 0xa002(%rip), %rdi      # 0x24e9f
jmp 0x1b234
incl %r13d
cmpl $0x2, %r13d
jb 0x1aebf
leaq 0x9f58(%rip), %rdi      # 0x24e0a
callq 0x2330
testl %ebp, %ebp
je 0x1b1ef
movl $0x100, %r14d           # imm = 0x100
movq 0x10(%rsp), %r13
cmpq %r14, %r13
cmovbq %r13, %r14
cmpl $0x5, %ebp
je 0x1b165
cmpl $0x3, %ebp
jne 0x1b14d
movq 0x90(%rsp), %rbp
movq 0x98(%rsp), %rbx
movq 0xa0(%rsp), %rax
movq %rax, 0x80(%rsp)
movq $0x0, 0x18(%rsp)
xorl %r12d, %r12d
leaq 0x9e1a(%rip), %rsi      # 0x24d30
leaq 0x40(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x1b3ac
leaq 0x60(%rsp), %rdi
leaq 0x40(%rsp), %rsi
movq %rbp, %rdx
callq 0x1b38d
leaq 0x9dff(%rip), %rdx      # 0x24d3d
leaq 0x20(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x1b38d
movq 0x20(%rsp), %rdi
callq 0xb70c
movq %rbx, %r15
leaq 0x20(%rsp), %rdi
callq 0x20f0
leaq 0x60(%rsp), %rdi
callq 0x20f0
leaq 0x40(%rsp), %rdi
callq 0x20f0
leaq 0x9dc1(%rip), %rsi      # 0x24d40
leaq 0x40(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x1b3ac
movq 0x80(%rsp), %rbx
leaq 0x60(%rsp), %rdi
leaq 0x40(%rsp), %rsi
movq %r15, %rdx
callq 0x1b38d
leaq 0x9d8e(%rip), %rdx      # 0x24d3d
leaq 0x20(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x1b38d
movq 0x20(%rsp), %rdi
callq 0xb70c
leaq 0x20(%rsp), %rdi
callq 0x20f0
leaq 0x60(%rsp), %rdi
callq 0x20f0
leaq 0x40(%rsp), %rdi
callq 0x20f0
leaq 0x9d60(%rip), %rsi      # 0x24d4d
leaq 0x40(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x1b3ac
leaq 0x60(%rsp), %rdi
leaq 0x40(%rsp), %rsi
movq %rbx, %rdx
callq 0x1b38d
leaq 0x9d28(%rip), %rdx      # 0x24d3d
leaq 0x20(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x1b38d
movq 0x20(%rsp), %rdi
callq 0xb70c
leaq 0x20(%rsp), %rdi
callq 0x20f0
leaq 0x60(%rsp), %rdi
callq 0x20f0
leaq 0x40(%rsp), %rdi
callq 0x20f0
testq %r12, %r12
je 0x1b0ca
leaq 0x9d02(%rip), %rdi      # 0x24d5a
movq 0x18(%rsp), %rsi
xorl %eax, %eax
callq 0x2040
leaq 0x9d08(%rip), %rsi      # 0x24d73
leaq 0x40(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x1b3ac
leaq 0x60(%rsp), %rdi
leaq 0x40(%rsp), %rsi
movq %r12, %rdx
callq 0x1b38d
leaq 0x9caa(%rip), %rdx      # 0x24d3d
leaq 0x20(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x1b38d
movq 0x20(%rsp), %rdi
callq 0xb70c
leaq 0x20(%rsp), %rdi
callq 0x20f0
leaq 0x60(%rsp), %rdi
callq 0x20f0
leaq 0x40(%rsp), %rdi
callq 0x20f0
callq 0x1b33a
movsd %xmm0, 0xc0(%rsp)
testq %r13, %r13
pushq $0x1
popq %r9
cmovnel %r14d, %r9d
movq %rbp, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq 0x18(%rsp), %rcx
movq %r12, %r8
callq 0x17311
movl %eax, %ebx
callq 0x1b33a
movsd %xmm0, 0x10(%rsp)
testl %ebx, %ebx
leaq 0x9d7b(%rip), %rax      # 0x24e8a
leaq 0x9d5c(%rip), %rdi      # 0x24e72
cmoveq %rax, %rdi
callq 0x2330
movsd 0x10(%rsp), %xmm0
subsd 0xc0(%rsp), %xmm0
leaq 0x9c57(%rip), %rdi      # 0x24d8c
movb $0x1, %al
callq 0x2040
jmp 0x1b241
leaq 0x9d68(%rip), %rdi      # 0x24eb0
jmp 0x1b234
leaq 0x9d94(%rip), %rdi      # 0x24ee8
jmp 0x1b234
leaq 0x9d64(%rip), %rdi      # 0x24ec4
jmp 0x1b234
movq 0x90(%rsp), %rbp
movq 0x98(%rsp), %rbx
movq 0xa0(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0xa8(%rsp), %r12
movq %r12, %rdi
callq 0x20e0
testq %rax, %rax
je 0x1b22d
movzbl -0x1(%r12,%rax), %ecx
xorl %r15d, %r15d
addl $-0x47, %ecx
cmpl $0x26, %ecx
ja 0x1b201
movabsq $0x100000001, %rdx      # imm = 0x100000001
btq %rcx, %rdx
jb 0x1b1fa
movabsq $0x1000000010, %rdx     # imm = 0x1000000010
btq %rcx, %rdx
jb 0x1b1f3
movabsq $0x4000000040, %rdx     # imm = 0x4000000040
btq %rcx, %rdx
jae 0x1b201
decq %rax
pushq $0x14
jmp 0x1b1ff
leaq 0x9ce9(%rip), %rdi      # 0x24ed6
jmp 0x1b234
xorl %ebx, %ebx
jmp 0x1b241
decq %rax
pushq $0xa
jmp 0x1b1ff
decq %rax
pushq $0x1e
popq %r15
leaq 0x20(%rsp), %rdx
movq %r12, %rdi
movq %rax, %rsi
callq 0x1b2da
testl %eax, %eax
je 0x1b22d
movq 0x20(%rsp), %rdx
pushq $-0x1
popq %rax
movl %r15d, %ecx
shrq %cl, %rax
movq %rdx, 0x18(%rsp)
cmpq %rax, %rdx
jbe 0x1b255
leaq 0x9bf5(%rip), %rdi      # 0x24e29
callq 0x2330
callq 0x1b2ce
pushq $0x1
popq %rbx
movl %ebx, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xb0(%rsp), %r12
testq %r12, %r12
je 0x1b275
movl %r15d, %ecx
shlq %cl, 0x18(%rsp)
cmpb $0x0, (%r12)
jne 0x1af0f
leaq 0x9bd0(%rip), %rdi      # 0x24e4c
jmp 0x1b234
jmp 0x1b296
jmp 0x1b2a5
jmp 0x1b2b4
jmp 0x1b2c3
jmp 0x1b296
jmp 0x1b2a5
jmp 0x1b2b4
jmp 0x1b2c3
jmp 0x1b296
jmp 0x1b2a5
jmp 0x1b2b4
jmp 0x1b2c3
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x20f0
jmp 0x1b2a8
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x20f0
jmp 0x1b2b7
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x20f0
jmp 0x1b2c6
movq %rax, %rbx
movq %rbx, %rdi
callq 0x23c0