// File: /workspace/github_cpp_makefile_star2_O2/sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HPatch/patch.c
// Function: read_diff_head
static hpatch_BOOL read_diff_head(_THDiffHead* out_diffHead,
                                  const hpatch_TStreamInput* serializedDiff){
    hpatch_StreamPos_t       diffPos0;
    const hpatch_StreamPos_t diffPos_end=serializedDiff->streamSize;
    TByte       temp_cache[hpatch_kStreamCacheSize];
    TStreamCacheClip  diffHeadClip;
    _TStreamCacheClip_init(&diffHeadClip,serializedDiff,0,diffPos_end,temp_cache,hpatch_kStreamCacheSize);
    _clip_unpackUIntTo(&out_diffHead->coverCount,&diffHeadClip);
    _clip_unpackUIntTo(&out_diffHead->lengthSize,&diffHeadClip);
    _clip_unpackUIntTo(&out_diffHead->inc_newPosSize,&diffHeadClip);
    _clip_unpackUIntTo(&out_diffHead->inc_oldPosSize,&diffHeadClip);
    _clip_unpackUIntTo(&out_diffHead->newDataDiffSize,&diffHeadClip);
    diffPos0=(hpatch_StreamPos_t)(_TStreamCacheClip_readPosOfSrcStream(&diffHeadClip));
    out_diffHead->headEndPos=diffPos0;
#ifdef __RUN_MEM_SAFE_CHECK
    if (out_diffHead->lengthSize>(hpatch_StreamPos_t)(diffPos_end-diffPos0)) return _hpatch_FALSE;
#endif
    diffPos0+=out_diffHead->lengthSize;
#ifdef __RUN_MEM_SAFE_CHECK
    if (out_diffHead->inc_newPosSize>(hpatch_StreamPos_t)(diffPos_end-diffPos0)) return _hpatch_FALSE;
#endif
    diffPos0+=out_diffHead->inc_newPosSize;
#ifdef __RUN_MEM_SAFE_CHECK
    if (out_diffHead->inc_oldPosSize>(hpatch_StreamPos_t)(diffPos_end-diffPos0)) return _hpatch_FALSE;
#endif
    diffPos0+=out_diffHead->inc_oldPosSize;
    out_diffHead->coverEndPos=diffPos0;
#ifdef __RUN_MEM_SAFE_CHECK
    if (out_diffHead->newDataDiffSize>(hpatch_StreamPos_t)(diffPos_end-diffPos0)) return _hpatch_FALSE;
#endif
    return hpatch_TRUE;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1030, %rsp           # imm = 0x1030
movq %rdi, %rbx
movq 0x8(%rsi), %r14
xorl %r15d, %r15d
movq %rsp, %r12
leaq 0x30(%rsp), %r8
movl $0x1000, %r9d           # imm = 0x1000
movq %r12, %rdi
xorl %edx, %edx
movq %r14, %rcx
callq 0x3b1fb
movq %r12, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x3af7d
testl %eax, %eax
je 0x3dcc4
leaq 0x8(%rbx), %rsi
movq %rsp, %rdi
xorl %r15d, %r15d
xorl %edx, %edx
callq 0x3af7d
testl %eax, %eax
je 0x3dcc4
leaq 0x10(%rbx), %r12
movq %rsp, %rdi
xorl %r15d, %r15d
movq %r12, %rsi
xorl %edx, %edx
callq 0x3af7d
testl %eax, %eax
je 0x3dcc4
leaq 0x18(%rbx), %r13
movq %rsp, %rdi
xorl %r15d, %r15d
movq %r13, %rsi
xorl %edx, %edx
callq 0x3af7d
testl %eax, %eax
je 0x3dcc4
leaq 0x20(%rbx), %rsi
movq %rsp, %rdi
xorl %r15d, %r15d
xorl %edx, %edx
callq 0x3af7d
testl %eax, %eax
je 0x3dcc4
movq 0x20(%rsp), %rax
subq 0x28(%rsp), %rax
addq (%rsp), %rax
movq %rax, 0x28(%rbx)
movq 0x8(%rbx), %rcx
movq %r14, %rdx
subq %rax, %rdx
cmpq %rdx, %rcx
ja 0x3dcc4
addq %rcx, %rax
movq (%r12), %rcx
movq %r14, %rdx
subq %rax, %rdx
cmpq %rdx, %rcx
ja 0x3dcc4
addq %rax, %rcx
movq (%r13), %rax
movq %r14, %rdx
subq %rcx, %rdx
cmpq %rdx, %rax
ja 0x3dcc4
addq %rcx, %rax
movq %rax, 0x30(%rbx)
subq %rax, %r14
xorl %r15d, %r15d
cmpq %r14, 0x20(%rbx)
setbe %r15b
movl %r15d, %eax
addq $0x1030, %rsp           # imm = 0x1030
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq