// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3VdbeMemFromBtree
SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(
  BtCursor *pCur,   /* Cursor pointing at record to retrieve. */
  int offset,       /* Offset from the start of data to return bytes from. */
  int amt,          /* Number of bytes to return. */
  int key,          /* If true, retrieve from the btree key, not data. */
  Mem *pMem         /* OUT: Return data in this Mem structure. */
){
  char *zData;        /* Data from the btree layer */
  int available = 0;  /* Number of bytes available on the local btree page */
  int rc = SQLITE_OK; /* Return code */

  assert( sqlite3BtreeCursorIsValid(pCur) );

  /* Note: the calls to BtreeKeyFetch() and DataFetch() below assert() 
  ** that both the BtShared and database handle mutexes are held. */
  assert( (pMem->flags & MEM_RowSet)==0 );
  if( key ){
    zData = (char *)sqlite3BtreeKeyFetch(pCur, &available);
  }else{
    zData = (char *)sqlite3BtreeDataFetch(pCur, &available);
  }
  assert( zData!=0 );

  if( offset+amt<=available && (pMem->flags&MEM_Dyn)==0 ){
    sqlite3VdbeMemRelease(pMem);
    pMem->z = &zData[offset];
    pMem->flags = MEM_Blob|MEM_Ephem;
  }else if( SQLITE_OK==(rc = sqlite3VdbeMemGrow(pMem, amt+2, 0)) ){
    pMem->flags = MEM_Blob|MEM_Dyn|MEM_Term;
    pMem->enc = 0;
    pMem->type = SQLITE_BLOB;
    if( key ){
      rc = sqlite3BtreeKey(pCur, offset, amt, pMem->z);
    }else{
      rc = sqlite3BtreeData(pCur, offset, amt, pMem->z);
    }
    pMem->z[amt] = 0;
    pMem->z[amt+1] = 0;
    if( rc!=SQLITE_OK ){
      sqlite3VdbeMemRelease(pMem);
    }
  }
  pMem->n = amt;

  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movq %r8, -0x20(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x3b7d0
movq -0x8(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x3b6f0
movq %rax, -0x28(%rbp)
jmp 0x3b7e1
movq -0x8(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x3b740
movq %rax, -0x28(%rbp)
movl -0xc(%rbp), %eax
addl -0x10(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jg 0x3b829
movq -0x20(%rbp), %rax
movzwl 0x24(%rax), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
jne 0x3b829
movq -0x20(%rbp), %rdi
callq 0x10190
movq -0x28(%rbp), %rcx
movslq -0xc(%rbp), %rax
addq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movw $0x1010, 0x24(%rax)     # imm = 0x1010
jmp 0x3b8d7
movq -0x20(%rbp), %rdi
movl -0x10(%rbp), %esi
addl $0x2, %esi
xorl %edx, %edx
callq 0x11940
movl %eax, %ecx
movl %ecx, -0x30(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x3b8d5
movq -0x20(%rbp), %rax
movw $0x610, 0x24(%rax)      # imm = 0x610
movq -0x20(%rbp), %rax
movb $0x0, 0x27(%rax)
movq -0x20(%rbp), %rax
movb $0x4, 0x26(%rax)
cmpl $0x0, -0x14(%rbp)
je 0x3b885
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
callq 0x2bfc0
movl %eax, -0x30(%rbp)
jmp 0x3b89f
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
callq 0x14730
movl %eax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x10(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movb $0x0, (%rax,%rcx)
cmpl $0x0, -0x30(%rbp)
je 0x3b8d3
movq -0x20(%rbp), %rdi
callq 0x10190
jmp 0x3b8d5
jmp 0x3b8d7
movl -0x10(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x20(%rax)
movl -0x30(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)