// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3VdbeMemGrow
int sqlite3VdbeMemGrow(Mem *pMem, int n, int bPreserve){
  assert( sqlite3VdbeCheckMemInvariants(pMem) );
  assert( !sqlite3VdbeMemIsRowSet(pMem) );
  testcase( pMem->db==0 );

  /* If the bPreserve flag is set to true, then the memory cell must already
  ** contain a valid string or blob value.  */
  assert( bPreserve==0 || pMem->flags&(MEM_Blob|MEM_Str) );
  testcase( bPreserve && pMem->z==0 );

  assert( pMem->szMalloc==0
       || pMem->szMalloc==sqlite3DbMallocSize(pMem->db, pMem->zMalloc) );
  if( pMem->szMalloc>0 && bPreserve && pMem->z==pMem->zMalloc ){
    if( pMem->db ){
      pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
    }else{
      pMem->zMalloc = sqlite3Realloc(pMem->z, n);
      if( pMem->zMalloc==0 ) sqlite3_free(pMem->z);
      pMem->z = pMem->zMalloc;
    }
    bPreserve = 0;
  }else{
    if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc);
    pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n);
  }
  if( pMem->zMalloc==0 ){
    sqlite3VdbeMemSetNull(pMem);
    pMem->z = 0;
    pMem->szMalloc = 0;
    return SQLITE_NOMEM_BKPT;
  }else{
    pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->zMalloc);
  }

  if( bPreserve && pMem->z ){
    assert( pMem->z!=pMem->zMalloc );
    memcpy(pMem->zMalloc, pMem->z, pMem->n);
  }
  if( (pMem->flags&MEM_Dyn)!=0 ){
    assert( pMem->xDel!=0 && pMem->xDel!=SQLITE_DYNAMIC );
    pMem->xDel((void *)(pMem->z));
  }

  pMem->z = pMem->zMalloc;
  pMem->flags &= ~(MEM_Dyn|MEM_Ephem|MEM_Static);
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
movl 0x20(%rdi), %eax
testl %eax, %eax
setle %cl
testl %edx, %edx
sete %dl
orb %cl, %dl
jne 0x2918ad
movq 0x10(%rbx), %rsi
movq 0x18(%rbx), %rax
cmpq %rax, %rsi
jne 0x2918b5
movq 0x28(%rbx), %rdi
movslq %r14d, %rdx
testq %rdi, %rdi
je 0x291999
callq 0x2919d2
movq %rax, 0x18(%rbx)
jmp 0x2919ba
testl %eax, %eax
jle 0x2918c1
movq 0x18(%rbx), %rax
movq 0x28(%rbx), %rdi
movq %rax, %rsi
callq 0x282904
movq 0x28(%rbx), %rdi
movslq %r14d, %rsi
testq %rdi, %rdi
je 0x2918d4
callq 0x282a35
jmp 0x2918dc
movq %rsi, %rdi
callq 0x272ae6
movq %rax, 0x18(%rbx)
testl %ebp, %ebp
sete %bpl
testq %rax, %rax
je 0x29196a
movq 0x28(%rbx), %rdx
testq %rdx, %rdx
je 0x291918
cmpq %rax, 0x1c0(%rdx)
jbe 0x291918
movl $0x80, %ecx
cmpq %rax, 0x1b0(%rdx)
jbe 0x291923
cmpq %rax, 0x1b8(%rdx)
jbe 0x2919c6
movq %rax, %rdi
callq *0x229d77(%rip)         # 0x4bb698
movl %eax, %ecx
movl %ecx, 0x20(%rbx)
testb %bpl, %bpl
jne 0x291941
movq 0x10(%rbx), %rsi
testq %rsi, %rsi
je 0x291941
movq 0x18(%rbx), %rdi
movslq 0xc(%rbx), %rdx
callq 0x17660
movl 0x8(%rbx), %eax
btl $0xa, %eax
jae 0x291955
movq 0x10(%rbx), %rdi
callq *0x30(%rbx)
movzwl 0x8(%rbx), %eax
movq 0x18(%rbx), %rcx
movq %rcx, 0x10(%rbx)
andl $0xe3ff, %eax           # imm = 0xE3FF
movw %ax, 0x8(%rbx)
xorl %eax, %eax
jmp 0x291994
testb $0x24, 0x9(%rbx)
je 0x29197a
movq %rbx, %rdi
callq 0x2917ab
jmp 0x291980
movw $0x1, 0x8(%rbx)
movq $0x0, 0x10(%rbx)
movl $0x0, 0x20(%rbx)
movl $0x7, %eax
popq %rbx
popq %r14
popq %rbp
retq
movq %rsi, %rdi
movq %rdx, %rsi
callq 0x272c63
movq %rax, 0x18(%rbx)
testq %rax, %rax
jne 0x2919ba
movq 0x10(%rbx), %rdi
callq 0x272c00
movq 0x18(%rbx), %rax
movq %rax, 0x10(%rbx)
movb $0x1, %bpl
jmp 0x2918e6
movzwl 0x176(%rdx), %ecx
jmp 0x291923