// File: sisong[P]ApkDiffPatch/HDiffPatch/libHDiffPatch/HPatch/patch.c
// Function: hpatch_packUIntWithTag
hpatch_BOOL hpatch_packUIntWithTag(TByte** out_code,TByte* out_code_end,
                                   hpatch_StreamPos_t uValue,hpatch_uint highTag,
                                   const hpatch_uint kTagBit){//写入整数并前进指针.
    TByte*          pcode=*out_code;
    const hpatch_StreamPos_t kMaxValueWithTag=((hpatch_StreamPos_t)1<<(7-kTagBit))-1;
    TByte           codeBuf[hpatch_kMaxPackedUIntBytes];
    TByte*          codeEnd=codeBuf;
#ifdef __RUN_MEM_SAFE_CHECK
    //static const hpatch_uint kPackMaxTagBit=7;
    //assert((0<=kTagBit)&&(kTagBit<=kPackMaxTagBit));
    //assert((highTag>>kTagBit)==0);
#endif
    while (uValue>kMaxValueWithTag) {
        *codeEnd=uValue&((1<<7)-1); ++codeEnd;
        uValue>>=7;
    }
#ifdef __RUN_MEM_SAFE_CHECK
    if ((out_code_end-pcode)<(1+(codeEnd-codeBuf))) return _hpatch_FALSE;
#endif
    *pcode=(TByte)( (TByte)uValue | (highTag<<(8-kTagBit))
                   | (((codeBuf!=codeEnd)?1:0)<<(7-kTagBit))  );
    ++pcode;
    while (codeBuf!=codeEnd) {
        --codeEnd;
        *pcode=(*codeEnd) | (TByte)(((codeBuf!=codeEnd)?1:0)<<7);
        ++pcode;
    }
    *out_code=pcode;
    return hpatch_TRUE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movl $0x7, %eax
subl -0x28(%rbp), %eax
movl %eax, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
subq $0x1, %rax
movq %rax, -0x38(%rbp)
leaq -0x43(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x38(%rbp), %rax
jbe 0x858ca
movq -0x20(%rbp), %rax
andq $0x7f, %rax
movb %al, %cl
movq -0x50(%rbp), %rax
movb %cl, (%rax)
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rax
shrq $0x7, %rax
movq %rax, -0x20(%rbp)
jmp 0x85896
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
subq %rcx, %rax
movq -0x50(%rbp), %rcx
leaq -0x43(%rbp), %rdx
subq %rdx, %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jge 0x858f5
movl $0x0, -0x4(%rbp)
jmp 0x859a6
movq -0x20(%rbp), %rax
movzbl %al, %eax
movl -0x24(%rbp), %edx
movl $0x8, %ecx
subl -0x28(%rbp), %ecx
shll %cl, %edx
movl %edx, %ecx
orl %ecx, %eax
leaq -0x43(%rbp), %rsi
movq -0x50(%rbp), %rdi
xorl %edx, %edx
movl $0x1, %ecx
cmpq %rdi, %rsi
cmovnel %ecx, %edx
movl $0x7, %ecx
subl -0x28(%rbp), %ecx
shll %cl, %edx
movl %edx, %ecx
orl %ecx, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, (%rax)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
leaq -0x43(%rbp), %rax
cmpq -0x50(%rbp), %rax
je 0x85994
movq -0x50(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movzbl (%rax), %eax
leaq -0x43(%rbp), %rsi
movq -0x50(%rbp), %rdi
xorl %ecx, %ecx
movl $0x1, %edx
cmpq %rdi, %rsi
cmovnel %edx, %ecx
shll $0x7, %ecx
movzbl %cl, %ecx
orl %ecx, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, (%rax)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x85944
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax,%rax)