// File: /workspace/github_c_makefile_star2_O2/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, %r15
movslq 0x38(%rdi), %rax
movslq %esi, %rbx
subq %rbx, %rax
imulq $0x38, %rax, %r14
addq 0x10(%rdi), %r14
movslq %edx, %rax
movq %rax, -0x38(%rbp)
leaq 0x68(,%rax,8), %r12
leal 0x138(%r12), %r13d
movl %r8d, -0x30(%rbp)
testl %r8d, %r8d
cmovnel %r12d, %r13d
movl %ecx, -0x2c(%rbp)
movq 0x60(%rdi), %rax
movq (%rax,%rbx,8), %rsi
testq %rsi, %rsi
je 0x2f1b4
movq %r15, %rdi
callq 0x25cb8
movq 0x60(%r15), %rax
andq $0x0, (%rax,%rbx,8)
movq %r14, %rdi
movl %r13d, %esi
callq 0x26f9a
testl %eax, %eax
je 0x2f1c7
xorl %eax, %eax
jmp 0x2f244
movq 0x10(%r14), %rax
movq 0x60(%r15), %rcx
movq %rax, (%rcx,%rbx,8)
andq $0x0, 0x60(%rax)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x50(%rax)
movups %xmm0, 0x40(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movl -0x30(%rbp), %edx
movb %dl, (%rax)
movl -0x2c(%rbp), %ecx
movb %cl, 0x1(%rax)
movq -0x38(%rbp), %rcx
movw %cx, 0xc(%rax)
leaq (%rax,%rcx,4), %rcx
addq $0x60, %rcx
movq %rcx, 0x58(%rax)
testb %dl, %dl
jne 0x2f244
movq 0x10(%r14), %rcx
leaq (%rcx,%r12), %rdx
movq %rdx, 0x10(%rax)
movups %xmm0, 0x40(%rcx,%r12)
movups %xmm0, 0x30(%rcx,%r12)
movups %xmm0, 0x20(%rcx,%r12)
movups %xmm0, 0x10(%rcx,%r12)
movups %xmm0, (%rcx,%r12)
andq $0x0, 0x50(%rcx,%r12)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq