// File: /workspace/github_c_makefile_star2_O2/ukontainer[P]sqlite-bench/sqlite3.c
// Function: setupLookaside
static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){
#ifndef SQLITE_OMIT_LOOKASIDE
  void *pStart;
  
  if( sqlite3LookasideUsed(db,0)>0 ){
    return SQLITE_BUSY;
  }
  /* Free any existing lookaside buffer for this handle before
  ** allocating a new one so we don't have to have space for 
  ** both at the same time.
  */
  if( db->lookaside.bMalloced ){
    sqlite3_free(db->lookaside.pStart);
  }
  /* The size of a lookaside slot after ROUNDDOWN8 needs to be larger
  ** than a pointer to be useful.
  */
  sz = ROUNDDOWN8(sz);  /* IMP: R-33038-09382 */
  if( sz<=(int)sizeof(LookasideSlot*) ) sz = 0;
  if( cnt<0 ) cnt = 0;
  if( sz==0 || cnt==0 ){
    sz = 0;
    pStart = 0;
  }else if( pBuf==0 ){
    sqlite3BeginBenignMalloc();
    pStart = sqlite3Malloc( sz*cnt );  /* IMP: R-61949-35727 */
    sqlite3EndBenignMalloc();
    if( pStart ) cnt = sqlite3MallocSize(pStart)/sz;
  }else{
    pStart = pBuf;
  }
  db->lookaside.pStart = pStart;
  db->lookaside.pInit = 0;
  db->lookaside.pFree = 0;
  db->lookaside.sz = (u16)sz;
  if( pStart ){
    int i;
    LookasideSlot *p;
    assert( sz > (int)sizeof(LookasideSlot*) );
    db->lookaside.nSlot = cnt;
    p = (LookasideSlot*)pStart;
    for(i=cnt-1; i>=0; i--){
      p->pNext = db->lookaside.pInit;
      db->lookaside.pInit = p;
      p = (LookasideSlot*)&((u8*)p)[sz];
    }
    db->lookaside.pEnd = p;
    db->lookaside.bDisable = 0;
    db->lookaside.bMalloced = pBuf==0 ?1:0;
  }else{
    db->lookaside.pStart = db;
    db->lookaside.pEnd = db;
    db->lookaside.bDisable = 1;
    db->lookaside.bMalloced = 0;
    db->lookaside.nSlot = 0;
  }
#endif /* SQLITE_OMIT_LOOKASIDE */
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebp
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %rbx
xorl %esi, %esi
callq 0x40423c
testl %eax, %eax
jle 0x410241
pushq $0x5
popq %rax
jmp 0x410353
cmpb $0x0, 0x166(%rbx)
je 0x410256
movq 0x188(%rbx), %rdi
callq 0x404c6c
andl $-0x8, %r15d
xorl %eax, %eax
cmpl $0x9, %r15d
setl %cl
movl %r15d, %r13d
cmovll %eax, %r13d
testl %ebp, %ebp
cmovlel %eax, %ebp
setle %dl
orb %cl, %dl
je 0x41027b
xorl %r12d, %r12d
jmp 0x4102ce
testq %r14, %r14
je 0x410288
movl %r13d, %eax
movq %r14, %r12
jmp 0x4102ce
movq 0x187b29(%rip), %rax    # 0x597db8
testq %rax, %rax
je 0x410296
callq *%rax
movl %ebp, %edi
imull %r15d, %edi
callq 0x404b49
movq %rax, %r12
movq 0x187b15(%rip), %rax    # 0x597dc0
testq %rax, %rax
je 0x4102b2
callq *%rax
testq %r12, %r12
je 0x4102c8
movq %r12, %rdi
callq *0x182eb8(%rip)         # 0x593178
cltd
idivl %r15d
movl %eax, %ebp
jmp 0x4102cb
xorl %r12d, %r12d
movl %r13d, %eax
movq %r12, 0x188(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x178(%rbx)
movw %ax, 0x164(%rbx)
testq %r12, %r12
je 0x41032b
leaq 0x178(%rbx), %rcx
movl %ebp, 0x168(%rbx)
movl %eax, %eax
xorl %edx, %edx
testl %ebp, %ebp
jle 0x410311
decl %ebp
movq %rdx, (%r12)
movq %r12, (%rcx)
movq %r12, %rdx
addq %rax, %r12
jmp 0x4102fc
movq %r12, 0x190(%rbx)
andl $0x0, 0x160(%rbx)
testq %r14, %r14
sete 0x166(%rbx)
jmp 0x410351
movq %rbx, 0x188(%rbx)
movq %rbx, 0x190(%rbx)
movl $0x1, 0x160(%rbx)
movb $0x0, 0x166(%rbx)
andl $0x0, 0x168(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq