// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3Realloc
SQLITE_PRIVATE void *sqlite3Realloc(void *pOld, u64 nBytes){
  int nOld, nNew, nDiff;
  void *pNew;
  assert( sqlite3MemdebugHasType(pOld, MEMTYPE_HEAP) );
  assert( sqlite3MemdebugNoType(pOld, (u8)~MEMTYPE_HEAP) );
  if( pOld==0 ){
    return sqlite3Malloc(nBytes); /* IMP: R-04300-56712 */
  }
  if( nBytes==0 ){
    sqlite3_free(pOld); /* IMP: R-26507-47431 */
    return 0;
  }
  if( nBytes>=0x7fffff00 ){
    /* The 0x7ffff00 limit term is explained in comments on sqlite3Malloc() */
    return 0;
  }
  nOld = sqlite3MallocSize(pOld);
  /* IMPLEMENTATION-OF: R-46199-30249 SQLite guarantees that the second
  ** argument to xRealloc is always a value returned by a prior call to
  ** xRoundup. */
  nNew = sqlite3GlobalConfig.m.xRoundup((int)nBytes);
  if( nOld==nNew ){
    pNew = pOld;
  }else if( sqlite3GlobalConfig.bMemstat ){
    sqlite3_mutex_enter(mem0.mutex);
    sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, (int)nBytes);
    nDiff = nNew - nOld;
    if( nDiff>0 && sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED) >=
          mem0.alarmThreshold-nDiff ){
      sqlite3MallocAlarm(nDiff);
    }
    pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
    if( pNew==0 && mem0.alarmThreshold>0 ){
      sqlite3MallocAlarm((int)nBytes);
      pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);
    }
#endif
    if( pNew ){
      nNew = sqlite3MallocSize(pNew);
      sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nNew-nOld);
    }
    sqlite3_mutex_leave(mem0.mutex);
  }else{
    pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);
  }
  assert( EIGHT_BYTE_ALIGNMENT(pNew) ); /* IMP: R-11148-40995 */
  return pNew;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x3c0939
movq -0x18(%rbp), %rdi
callq 0x3c0760
movq %rax, -0x8(%rbp)
jmp 0x3c0a3e
cmpq $0x0, -0x18(%rbp)
jne 0x3c0956
movq -0x10(%rbp), %rdi
callq 0x3c0800
movq $0x0, -0x8(%rbp)
jmp 0x3c0a3e
cmpq $0x7fffff00, -0x18(%rbp) # imm = 0x7FFFFF00
jb 0x3c096d
movq $0x0, -0x8(%rbp)
jmp 0x3c0a3e
movq -0x10(%rbp), %rdi
callq 0x3c08a0
movl %eax, -0x1c(%rbp)
movq 0x27ef10(%rip), %rax    # 0x63f890
movq -0x18(%rbp), %rcx
movl %ecx, %edi
callq *%rax
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jne 0x3c09a0
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x3c0a36
cmpl $0x0, 0x27eea9(%rip)    # 0x63f850
je 0x3c0a20
movq -0x18(%rbp), %rax
movl %eax, %esi
movl $0x5, %edi
callq 0x3d5f10
movl -0x20(%rbp), %eax
subl -0x1c(%rbp), %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jle 0x3c09ea
xorl %edi, %edi
callq 0x3c05e0
movq 0x282832(%rip), %rcx    # 0x643208
movslq -0x24(%rbp), %rdx
subq %rdx, %rcx
cmpq %rcx, %rax
jl 0x3c09ea
movl -0x24(%rbp), %edi
callq 0x3d5f50
movq 0x27ee8f(%rip), %rax    # 0x63f880
movq -0x10(%rbp), %rdi
movl -0x20(%rbp), %esi
callq *%rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x3c0a1e
movq -0x30(%rbp), %rdi
callq 0x3c08a0
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %esi
subl -0x1c(%rbp), %esi
xorl %edi, %edi
callq 0x3d5f80
jmp 0x3c0a34
movq 0x27ee59(%rip), %rax    # 0x63f880
movq -0x10(%rbp), %rdi
movl -0x20(%rbp), %esi
callq *%rax
movq %rax, -0x30(%rbp)
jmp 0x3c0a36
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)