// File: /workspace/github_c_makefile_star2_O3/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, %r12d
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %rbx
xorl %esi, %esi
callq 0x4049fd
movl $0x5, %ebp
testl %eax, %eax
jg 0x412aee
movq %r14, (%rsp)
cmpb $0x0, 0x166(%rbx)
je 0x4129cd
movq 0x188(%rbx), %rdi
callq 0x4054f6
andl $-0x8, %r15d
xorl %ebp, %ebp
cmpl $0x9, %r15d
movl %r15d, %r14d
cmovll %ebp, %r14d
setl %al
testl %r12d, %r12d
cmovlel %ebp, %r12d
setle %cl
orb %al, %cl
movl $0x0, %eax
je 0x412a33
xorps %xmm0, %xmm0
movups %xmm0, 0x178(%rbx)
movw %ax, 0x164(%rbx)
movq %rbx, 0x188(%rbx)
movq %rbx, 0x190(%rbx)
movl $0x1, 0x160(%rbx)
movb $0x0, 0x166(%rbx)
movl $0x0, 0x168(%rbx)
jmp 0x412aee
movq (%rsp), %r13
testq %r13, %r13
jne 0x412a7f
movq 0x192375(%rip), %rax    # 0x5a4db8
testq %rax, %rax
je 0x412a4a
callq *%rax
imull %r15d, %r12d
movq %r12, %rdi
callq 0x4053ac
movq %rax, %r13
movq 0x192360(%rip), %rax    # 0x5a4dc0
testq %rax, %rax
je 0x412a67
callq *%rax
movl %r14d, %eax
testq %r13, %r13
je 0x4129f4
movq %r13, %rdi
callq *0x18d700(%rip)         # 0x5a0178
cltd
idivl %r15d
movl %eax, %r12d
movq %r13, 0x188(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x178(%rbx)
movw %r15w, 0x164(%rbx)
movl %r12d, 0x168(%rbx)
testl %r12d, %r12d
jle 0x412acf
leaq 0x178(%rbx), %rax
movl %r15d, %ecx
incl %r12d
xorl %edx, %edx
movq %rdx, (%r13)
movq %r13, %rdx
addq %rcx, %r13
decl %r12d
cmpl $0x1, %r12d
ja 0x412ab3
movq %r13, %rcx
subq %r15, %rcx
movq %rcx, (%rax)
cmpq $0x0, (%rsp)
movq %r13, 0x190(%rbx)
movl $0x0, 0x160(%rbx)
sete 0x166(%rbx)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq