// File: /workspace/github_c_makefile_star2_O1/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 0x4049d6
movl %eax, %ecx
movl $0x5, %eax
testl %ecx, %ecx
jg 0x412b79
cmpb $0x0, 0x166(%rbx)
je 0x412a6a
movq 0x188(%rbx), %rdi
callq 0x405420
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 0x412a8f
xorl %r12d, %r12d
jmp 0x412ae2
testq %r14, %r14
je 0x412a9c
movl %r13d, %eax
movq %r14, %r12
jmp 0x412ae2
movq 0x192315(%rip), %rax    # 0x5a4db8
testq %rax, %rax
je 0x412aaa
callq *%rax
movl %r13d, %edi
imull %ebp, %edi
callq 0x4052d6
movq %rax, %r12
movq 0x192301(%rip), %rax    # 0x5a4dc0
testq %rax, %rax
je 0x412ac6
callq *%rax
testq %r12, %r12
je 0x412adc
movq %r12, %rdi
callq *0x18d6a4(%rip)         # 0x5a0178
cltd
idivl %r15d
movl %eax, %ebp
jmp 0x412adf
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 0x412b4e
movl %ebp, 0x168(%rbx)
testl %ebp, %ebp
jle 0x412b31
leaq 0x178(%rbx), %rcx
cltq
movq (%rcx), %rdx
incl %ebp
movq %rdx, (%r12)
movq %r12, %rdx
addq %rax, %r12
decl %ebp
cmpl $0x1, %ebp
jg 0x412b17
movq %r12, %rdx
subq %rax, %rdx
movq %rdx, (%rcx)
movq %r12, 0x190(%rbx)
movl $0x0, 0x160(%rbx)
testq %r14, %r14
sete 0x166(%rbx)
jmp 0x412b77
movq %rbx, 0x188(%rbx)
movq %rbx, 0x190(%rbx)
movl $0x1, 0x160(%rbx)
movb $0x0, 0x166(%rbx)
movl $0x0, 0x168(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq