// File: /workspace/github_c_makefile_star2_O2/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: setupLookaside
static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){
#ifndef SQLITE_OMIT_LOOKASIDE
  void *pStart;
  if( db->lookaside.nOut ){
    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.pFree = 0;
  db->lookaside.sz = (u16)sz;
  if( pStart ){
    int i;
    LookasideSlot *p;
    assert( sz > (int)sizeof(LookasideSlot*) );
    p = (LookasideSlot*)pStart;
    for(i=cnt-1; i>=0; i--){
      p->pNext = db->lookaside.pFree;
      db->lookaside.pFree = p;
      p = (LookasideSlot*)&((u8*)p)[sz];
    }
    db->lookaside.pEnd = p;
    db->lookaside.bEnabled = 1;
    db->lookaside.bMalloced = pBuf==0 ?1:0;
  }else{
    db->lookaside.pStart = db;
    db->lookaside.pEnd = db;
    db->lookaside.bEnabled = 0;
    db->lookaside.bMalloced = 0;
  }
#endif /* SQLITE_OMIT_LOOKASIDE */
  return SQLITE_OK;
}

// Assembly:
cmpl $0x0, 0x154(%rdi)
je 0x16c8b
pushq $0x5
popq %rax
retq
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %r15d
movl %edx, %r13d
movq %rdi, %rbx
cmpb $0x0, 0x153(%rdi)
je 0x16cbd
movq 0x170(%rbx), %rdi
movq %rsi, %r14
callq 0xa828
movq %r14, %rsi
andl $-0x8, %r13d
xorl %eax, %eax
cmpl $0x9, %r13d
setl %cl
movl %r13d, %r14d
cmovll %eax, %r14d
testl %r15d, %r15d
cmovlel %eax, %r15d
setle %dl
orb %cl, %dl
je 0x16ce4
xorl %r12d, %r12d
jmp 0x16d41
testq %rsi, %rsi
je 0x16cf1
movl %r14d, %eax
movq %rsi, %r12
jmp 0x16d41
movq %rsi, -0x30(%rbp)
movq 0x6e8dc(%rip), %rax     # 0x855d8
testq %rax, %rax
je 0x16d03
callq *%rax
movl %r15d, %edi
imull %r13d, %edi
callq 0xc13f
movq %rax, %r12
movq 0x6e8c7(%rip), %rax     # 0x855e0
testq %rax, %rax
je 0x16d20
callq *%rax
testq %r12, %r12
je 0x16d37
movq %r12, %rdi
callq *0x6c732(%rip)          # 0x83460
cltd
idivl %r13d
movl %eax, %r15d
jmp 0x16d3a
xorl %r12d, %r12d
movl %r14d, %eax
movq -0x30(%rbp), %rsi
movq %r12, 0x170(%rbx)
andq $0x0, 0x168(%rbx)
movw %ax, 0x150(%rbx)
testq %r12, %r12
je 0x16d91
movl %eax, %eax
xorl %ecx, %ecx
testl %r15d, %r15d
jle 0x16d7b
decl %r15d
movq %rcx, (%r12)
movq %r12, 0x168(%rbx)
movq %r12, %rcx
addq %rax, %r12
jmp 0x16d60
movq %r12, 0x178(%rbx)
movb $0x1, 0x152(%rbx)
testq %rsi, %rsi
sete %al
jmp 0x16da8
movq %rbx, 0x170(%rbx)
movq %rbx, 0x178(%rbx)
movb $0x0, 0x152(%rbx)
xorl %eax, %eax
movb %al, 0x153(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq