// File: sisong[P]ApkDiffPatch/src/zip_diff.cpp
// Function: tryGetCompressSet(char const**, char const*, char const*, char const*, char const*, unsigned long*, unsigned long, unsigned long, unsigned long, unsigned long*, unsigned long, unsigned long, unsigned long)
static bool _tryGetCompressSet(const char** isMatchedType,const char* ptype,const char* ptypeEnd,
                               const char* cmpType,const char* cmpType2=0,
                               size_t* compressLevel=0,size_t levelMin=0,size_t levelMax=0,size_t levelDefault=0,
                               size_t* dictSize=0,size_t dictSizeMin=0,size_t dictSizeMax=0,size_t dictSizeDefault=0){
    if (*isMatchedType) return true; //ok
    const size_t ctypeLen=strlen(cmpType);
    const size_t ctype2Len=(cmpType2!=0)?strlen(cmpType2):0;
    if ( ((ctypeLen==(size_t)(ptypeEnd-ptype))&&(0==strncmp(ptype,cmpType,ctypeLen)))
        || ((cmpType2!=0)&&(ctype2Len==(size_t)(ptypeEnd-ptype))&&(0==strncmp(ptype,cmpType2,ctype2Len))) )
        *isMatchedType=cmpType; //ok
    else
        return true;//type mismatch
    
    if ((compressLevel)&&(ptypeEnd[0]=='-')){
        const char* plevel=ptypeEnd+1;
        const char* plevelEnd=findUntilEnd(plevel,'-');
        if (!a_to_size(plevel,plevelEnd-plevel,compressLevel)) return false; //error
        if (*compressLevel<levelMin) *compressLevel=levelMin;
        else if (*compressLevel>levelMax) *compressLevel=levelMax;
        if ((dictSize)&&(plevelEnd[0]=='-')){
            const char* pdictSize=plevelEnd+1;
            const char* pdictSizeEnd=findUntilEnd(pdictSize,'-');
            if (!kmg_to_size(pdictSize,pdictSizeEnd-pdictSize,dictSize)) return false; //error
            if (*dictSize<dictSizeMin) *dictSize=dictSizeMin;
            else if (*dictSize>dictSizeMax) *dictSize=dictSizeMax;
        }else{
            if (plevelEnd[0]!='\0') return false; //error
            if (dictSize) *dictSize=dictSizeDefault;
        }
    }else{
        if (ptypeEnd[0]!='\0') return false; //error
        if (compressLevel) *compressLevel=levelDefault;
        if (dictSize) *dictSize=dictSizeDefault;
    }
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0x624f
movb $0x1, -0x1(%rbp)
jmp 0x6481
movq -0x28(%rbp), %rdi
callq 0x4180
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x6272
movq -0x30(%rbp), %rdi
callq 0x4180
movq %rax, -0x70(%rbp)
jmp 0x627a
xorl %eax, %eax
movq %rax, -0x70(%rbp)
jmp 0x627a
movq -0x70(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %rdx
subq %rdx, %rcx
cmpq %rcx, %rax
jne 0x62af
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x41d0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x62e3
cmpq $0x0, -0x30(%rbp)
je 0x62f0
movq -0x48(%rbp), %rax
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %rdx
subq %rdx, %rcx
cmpq %rcx, %rax
jne 0x62f0
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x41d0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x62f0
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
jmp 0x62f9
movb $0x1, -0x1(%rbp)
jmp 0x6481
cmpq $0x0, -0x38(%rbp)
je 0x6445
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x6445
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
movl $0x2d, %esi
callq 0x5a10
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rax
subq %rax, %rsi
movq -0x38(%rbp), %rdx
callq 0x58b0
cmpl $0x0, %eax
jne 0x6358
movb $0x0, -0x1(%rbp)
jmp 0x6481
movq -0x38(%rbp), %rax
movq (%rax), %rax
cmpq 0x10(%rbp), %rax
jae 0x6372
movq 0x10(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
jmp 0x638c
movq -0x38(%rbp), %rax
movq (%rax), %rax
cmpq 0x18(%rbp), %rax
jbe 0x638a
movq 0x18(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
jmp 0x638c
cmpq $0x0, 0x28(%rbp)
je 0x641d
movq -0x58(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x641d
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
movl $0x2d, %esi
callq 0x5a10
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rax
subq %rax, %rsi
movq 0x28(%rbp), %rdx
callq 0x5780
cmpl $0x0, %eax
jne 0x63e7
movb $0x0, -0x1(%rbp)
jmp 0x6481
movq 0x28(%rbp), %rax
movq (%rax), %rax
cmpq 0x30(%rbp), %rax
jae 0x6401
movq 0x30(%rbp), %rcx
movq 0x28(%rbp), %rax
movq %rcx, (%rax)
jmp 0x641b
movq 0x28(%rbp), %rax
movq (%rax), %rax
cmpq 0x38(%rbp), %rax
jbe 0x6419
movq 0x38(%rbp), %rcx
movq 0x28(%rbp), %rax
movq %rcx, (%rax)
jmp 0x641b
jmp 0x6443
movq -0x58(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x642f
movb $0x0, -0x1(%rbp)
jmp 0x6481
cmpq $0x0, 0x28(%rbp)
je 0x6441
movq 0x40(%rbp), %rcx
movq 0x28(%rbp), %rax
movq %rcx, (%rax)
jmp 0x6443
jmp 0x647d
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x6457
movb $0x0, -0x1(%rbp)
jmp 0x6481
cmpq $0x0, -0x38(%rbp)
je 0x6469
movq 0x20(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
cmpq $0x0, 0x28(%rbp)
je 0x647b
movq 0x40(%rbp), %rcx
movq 0x28(%rbp), %rax
movq %rcx, (%rax)
jmp 0x647d
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)