// File: /workspace/github_c_makefile_star2_O1/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 0x29b57a
movq 0x10(%rbx), %rsi
cmpq 0x18(%rbx), %rsi
je 0x29b637
testl %eax, %eax
jle 0x29b58b
movq 0x18(%rbx), %rsi
movq 0x28(%rbx), %rdi
callq 0x28c3e7
movq 0x28(%rbx), %rdi
movslq %r14d, %rsi
testq %rdi, %rdi
je 0x29b59e
callq 0x28c518
jmp 0x29b5a6
movq %rsi, %rdi
callq 0x27c381
movq %rax, 0x18(%rbx)
testl %ebp, %ebp
sete %bpl
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x29b627
movq 0x28(%rbx), %rcx
testq %rcx, %rcx
je 0x29b5e6
cmpq %rdi, 0x1c0(%rcx)
jbe 0x29b5e6
movl $0x80, %eax
cmpq %rdi, 0x1b0(%rcx)
jbe 0x29b5ec
cmpq %rdi, 0x1b8(%rcx)
jbe 0x29b69a
callq *0x22b0ac(%rip)         # 0x4c6698
movl %eax, 0x20(%rbx)
testb %bpl, %bpl
jne 0x29b60a
movq 0x10(%rbx), %rsi
testq %rsi, %rsi
je 0x29b60a
movq 0x18(%rbx), %rdi
movslq 0xc(%rbx), %rdx
callq 0x17660
testb $0x4, 0x9(%rbx)
je 0x29b617
movq 0x10(%rbx), %rdi
callq *0x30(%rbx)
movq 0x18(%rbx), %rax
movq %rax, 0x10(%rbx)
andb $-0x1d, 0x9(%rbx)
xorl %eax, %eax
jmp 0x29b668
testb $0x24, 0x9(%rbx)
je 0x29b64e
movq %rbx, %rdi
callq 0x29b491
jmp 0x29b654
movq 0x28(%rbx), %rdi
movslq %r14d, %rdx
testq %rdi, %rdi
je 0x29b66d
callq 0x29b6a6
movq %rax, 0x18(%rbx)
jmp 0x29b68e
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 0x27c4f3
movq %rax, 0x18(%rbx)
testq %rax, %rax
jne 0x29b68a
movq 0x10(%rbx), %rdi
callq 0x27c490
movq 0x18(%rbx), %rax
movq %rax, 0x10(%rbx)
movb $0x1, %bpl
jmp 0x29b5b0
movzwl 0x176(%rcx), %eax
jmp 0x29b5ec