// File: /workspace/github_c_makefile_star2_O0/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: sqlite3VdbeSerialType
SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem *pMem, int file_format, u32 *pLen){
  int flags = pMem->flags;
  u32 n;

  assert( pLen!=0 );
  if( flags&MEM_Null ){
    *pLen = 0;
    return 0;
  }
  if( flags&MEM_Int ){
    /* Figure out whether to use 1, 2, 4, 6 or 8 bytes. */
#   define MAX_6BYTE ((((i64)0x00008000)<<32)-1)
    i64 i = pMem->u.i;
    u64 u;
    if( i<0 ){
      u = ~i;
    }else{
      u = i;
    }
    if( u<=127 ){
      if( (i&1)==i && file_format>=4 ){
        *pLen = 0;
        return 8+(u32)u;
      }else{
        *pLen = 1;
        return 1;
      }
    }
    if( u<=32767 ){ *pLen = 2; return 2; }
    if( u<=8388607 ){ *pLen = 3; return 3; }
    if( u<=2147483647 ){ *pLen = 4; return 4; }
    if( u<=MAX_6BYTE ){ *pLen = 6; return 5; }
    *pLen = 8;
    return 6;
  }
  if( flags&MEM_Real ){
    *pLen = 8;
    return 7;
  }
  assert( pMem->db->mallocFailed || flags&(MEM_Str|MEM_Blob) );
  assert( pMem->n>=0 );
  n = (u32)pMem->n;
  if( flags & MEM_Zero ){
    n += pMem->u.nZero;
  }
  *pLen = n;
  return ((n*2) + 12 + ((flags&MEM_Str)!=0));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movzwl 0x8(%rax), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x438ab
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x43a2b
movl -0x24(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x439c2
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jge 0x438da
movq -0x30(%rbp), %rax
xorq $-0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x438e2
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x7f, -0x38(%rbp)
ja 0x4392c
movq -0x30(%rbp), %rax
andq $0x1, %rax
cmpq -0x30(%rbp), %rax
jne 0x43916
cmpl $0x4, -0x14(%rbp)
jl 0x43916
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movq -0x38(%rbp), %rax
addl $0x8, %eax
movl %eax, -0x4(%rbp)
jmp 0x43a2b
movq -0x20(%rbp), %rax
movl $0x1, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x43a2b
cmpq $0x7fff, -0x38(%rbp)    # imm = 0x7FFF
ja 0x4394c
movq -0x20(%rbp), %rax
movl $0x2, (%rax)
movl $0x2, -0x4(%rbp)
jmp 0x43a2b
cmpq $0x7fffff, -0x38(%rbp)  # imm = 0x7FFFFF
ja 0x4396c
movq -0x20(%rbp), %rax
movl $0x3, (%rax)
movl $0x3, -0x4(%rbp)
jmp 0x43a2b
cmpq $0x7fffffff, -0x38(%rbp) # imm = 0x7FFFFFFF
ja 0x4398c
movq -0x20(%rbp), %rax
movl $0x4, (%rax)
movl $0x4, -0x4(%rbp)
jmp 0x43a2b
movabsq $0x7fffffffffff, %rax   # imm = 0x7FFFFFFFFFFF
cmpq %rax, -0x38(%rbp)
ja 0x439af
movq -0x20(%rbp), %rax
movl $0x6, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x43a2b
movq -0x20(%rbp), %rax
movl $0x8, (%rax)
movl $0x6, -0x4(%rbp)
jmp 0x43a2b
movl -0x24(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x439e0
movq -0x20(%rbp), %rax
movl $0x8, (%rax)
movl $0x7, -0x4(%rbp)
jmp 0x43a2b
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
je 0x43a03
movq -0x10(%rbp), %rax
movl (%rax), %eax
addl -0x28(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x28(%rbp), %eax
shll %eax
addl $0xc, %eax
movl -0x24(%rbp), %ecx
andl $0x2, %ecx
cmpl $0x0, %ecx
setne %cl
andb $0x1, %cl
movzbl %cl, %ecx
addl %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq