// File: /workspace/github_c_makefile_star2_O3/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: allocateCursor
static VdbeCursor *allocateCursor(
  Vdbe *p,              /* The virtual machine */
  int iCur,             /* Index of the new VdbeCursor */
  int nField,           /* Number of fields in the table or index */
  int iDb,              /* Database the cursor belongs to, or -1 */
  u8 eCurType           /* Type of the new cursor */
){
  /* Find the memory cell that will be used to store the blob of memory
  ** required for this VdbeCursor structure. It is convenient to use a 
  ** vdbe memory cell to manage the memory allocation required for a
  ** VdbeCursor structure for the following reasons:
  **
  **   * Sometimes cursor numbers are used for a couple of different
  **     purposes in a vdbe program. The different uses might require
  **     different sized allocations. Memory cells provide growable
  **     allocations.
  **
  **   * When using ENABLE_MEMORY_MANAGEMENT, memory cell buffers can
  **     be freed lazily via the sqlite3_release_memory() API. This
  **     minimizes the number of malloc calls made by the system.
  **
  ** Memory cells for cursors are allocated at the top of the address
  ** space. Memory cell (p->nMem) corresponds to cursor 0. Space for
  ** cursor 1 is managed by memory cell (p->nMem-1), etc.
  */
  Mem *pMem = &p->aMem[p->nMem-iCur];

  int nByte;
  VdbeCursor *pCx = 0;
  nByte = 
      ROUND8(sizeof(VdbeCursor)) + 2*sizeof(u32)*nField + 
      (eCurType==CURTYPE_BTREE?sqlite3BtreeCursorSize():0);

  assert( iCur<p->nCursor );
  if( p->apCsr[iCur] ){
    sqlite3VdbeFreeCursor(p, p->apCsr[iCur]);
    p->apCsr[iCur] = 0;
  }
  if( SQLITE_OK==sqlite3VdbeMemClearAndResize(pMem, nByte) ){
    p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z;
    memset(pCx, 0, sizeof(VdbeCursor));
    pCx->eCurType = eCurType;
    pCx->iDb = iDb;
    pCx->nField = nField;
    pCx->aOffset = &pCx->aType[nField];
    if( eCurType==CURTYPE_BTREE ){
      pCx->uc.pCursor = (BtCursor*)
          &pMem->z[ROUND8(sizeof(VdbeCursor))+2*sizeof(u32)*nField];
      sqlite3BtreeCursorZero(pCx->uc.pCursor);
    }
  }
  return pCx;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r12
movslq 0x38(%rdi), %rax
movslq %esi, %rbx
subq %rbx, %rax
imulq $0x38, %rax, %r14
addq 0x10(%rdi), %r14
movslq %edx, %rax
movq %rax, -0x40(%rbp)
leaq 0x68(,%rax,8), %rax
leal 0x138(%rax), %r13d
movl %r8d, -0x30(%rbp)
testl %r8d, %r8d
movq %rax, -0x38(%rbp)
cmovnel %eax, %r13d
movl %ecx, -0x2c(%rbp)
movq 0x60(%rdi), %rax
movq (%rax,%rbx,8), %rsi
testq %rsi, %rsi
je 0x32669
movq %r12, %rdi
callq 0x29792
movq 0x60(%r12), %rax
movq $0x0, (%rax,%rbx,8)
cmpl %r13d, 0x20(%r14)
jge 0x3268d
xorl %r15d, %r15d
movq %r14, %rdi
movl %r13d, %esi
xorl %edx, %edx
callq 0x2a35d
testl %eax, %eax
jne 0x32723
movq 0x10(%r14), %r15
jmp 0x3269b
movq 0x18(%r14), %r15
movq %r15, 0x10(%r14)
andw $0xd, 0x8(%r14)
movq 0x60(%r12), %rax
movq %r15, (%rax,%rbx,8)
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
movups %xmm0, 0x50(%r15)
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x30(%r15)
movups %xmm0, 0x20(%r15)
movups %xmm0, 0x10(%r15)
movq $0x0, 0x60(%r15)
movl -0x30(%rbp), %ecx
movb %cl, (%r15)
movl -0x2c(%rbp), %eax
movb %al, 0x1(%r15)
movq -0x40(%rbp), %rax
movw %ax, 0xc(%r15)
leaq (%r15,%rax,4), %rax
addq $0x60, %rax
movq %rax, 0x58(%r15)
testb %cl, %cl
jne 0x32723
movq 0x10(%r14), %rax
movq -0x38(%rbp), %rdx
leaq (%rax,%rdx), %rcx
movq %rcx, 0x10(%r15)
movups %xmm0, 0x40(%rax,%rdx)
movups %xmm0, 0x30(%rax,%rdx)
movups %xmm0, 0x20(%rax,%rdx)
movups %xmm0, 0x10(%rax,%rdx)
movups %xmm0, (%rax,%rdx)
movq $0x0, 0x50(%rax,%rdx)
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq