// File: /workspace/github_cpp_makefile_star2_O1/sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HPatchLite/hpatch_lite.c
// Function: hpatchi_inplace_open
hpi_BOOL hpatchi_inplace_open(hpi_TInputStreamHandle diff_data,hpi_TInputStream_read read_diff,
                              hpi_compressType* out_compress_type,hpi_pos_t* out_newSize,
                              hpi_pos_t* out_uncompressSize,hpi_size_t* out_extraSafeSize){
    #define kHPatchLite_inplaceCode     2
    hpi_size_t lenn=hpi_kInplaceHeadSize;
    hpi_size_t lenu,lene;
    hpi_byte   buf[(hpi_kInplaceHeadSize>sizeof(hpi_pos_t))?hpi_kInplaceHeadSize:sizeof(hpi_pos_t)];
    
    _CHECK(read_diff(diff_data,buf,&lenn));
    //HPatchLite type tag 2byte, version code(high 2bit)
    lenu=buf[3];
    _SAFE_CHECK((lenn==hpi_kInplaceHeadSize)&(buf[0]=='h')&(buf[1]=='I')&((lenu>>6)==kHPatchLite_inplaceCode));
    *out_compress_type=buf[2]; //compress type
    lenn=lenu&7; //newSize bytes(low 3bit)
    lenu=(lenu>>3)&7; //uncompressSize bytes(mid 3bit)
    lene=buf[4];

    _SAFE_CHECK((lenn<=sizeof(hpi_pos_t))&(lenu<=sizeof(hpi_pos_t))&(lene<=sizeof(hpi_size_t)));
    _CHECK(read_diff(diff_data,buf,&lenn));
    *out_newSize=_hpi_readSize(buf,lenn);
    _CHECK(read_diff(diff_data,buf,&lenu));
    *out_uncompressSize=_hpi_readSize(buf,lenu);
    _CHECK(read_diff(diff_data,buf,&lene));
    *out_extraSafeSize=(hpi_size_t)_hpi_readSize(buf,lene);
    return hpi_TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, 0x20(%rsp)
movq %r8, %r12
movq %rcx, %r13
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x14(%rsp), %rdx
movl $0x5, (%rdx)
leaq 0xf(%rsp), %rsi
callq *%r14
xorl %ebp, %ebp
testl %eax, %eax
je 0xd14f
movzbl 0x12(%rsp), %eax
movl %eax, 0x18(%rsp)
movl %eax, %ecx
andl $-0x40, %ecx
cmpl $0x80, %ecx
jne 0xd14f
cmpl $0x5, 0x14(%rsp)
jne 0xd14f
cmpb $0x68, 0xf(%rsp)
jne 0xd14f
cmpb $0x49, 0x10(%rsp)
jne 0xd14f
movzbl 0x11(%rsp), %ecx
movl %ecx, (%rbx)
movl %eax, %ecx
andl $0x7, %ecx
movl %ecx, 0x14(%rsp)
shrl $0x3, %eax
andl $0x7, %eax
movl %eax, 0x18(%rsp)
movzbl 0x13(%rsp), %edx
cmpl $0x5, %edx
setae %sil
movl %edx, 0x1c(%rsp)
cmpl $0x5, %ecx
setae %cl
cmpl $0x5, %eax
setae %al
orb %sil, %cl
orb %al, %cl
jne 0xd14f
leaq 0xf(%rsp), %rsi
leaq 0x14(%rsp), %rdx
movq %r15, %rdi
callq *%r14
testl %eax, %eax
je 0xd14f
movl 0x14(%rsp), %eax
xorl %ebp, %ebp
movl $0x0, %ecx
testq %rax, %rax
je 0xd0d8
xorl %ecx, %ecx
shll $0x8, %ecx
movzbl 0xe(%rsp,%rax), %edx
orl %edx, %ecx
decq %rax
jne 0xd0c9
movl %ecx, (%r13)
leaq 0xf(%rsp), %rsi
leaq 0x18(%rsp), %rdx
movq %r15, %rdi
callq *%r14
testl %eax, %eax
je 0xd14f
movl 0x18(%rsp), %eax
xorl %ebp, %ebp
movl $0x0, %ecx
testq %rax, %rax
je 0xd111
xorl %ecx, %ecx
shll $0x8, %ecx
movzbl 0xe(%rsp,%rax), %edx
orl %edx, %ecx
decq %rax
jne 0xd102
movl %ecx, (%r12)
leaq 0xf(%rsp), %rsi
leaq 0x1c(%rsp), %rdx
movq %r15, %rdi
callq *%r14
testl %eax, %eax
je 0xd14f
movl 0x1c(%rsp), %eax
xorl %ecx, %ecx
testq %rax, %rax
je 0xd143
shll $0x8, %ecx
movzbl 0xe(%rsp,%rax), %edx
orl %edx, %ecx
decq %rax
jne 0xd134
movq 0x20(%rsp), %rax
movl %ecx, (%rax)
movl $0x1, %ebp
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq