// File: /workspace/github_c_makefile_star2_O1/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:
movl $0x5, %eax
cmpl $0x0, 0x154(%rdi)
je 0x18986
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 0x189b8
movq 0x170(%rbx), %rdi
movq %rsi, %r14
callq 0xa620
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 0x189df
xorl %r12d, %r12d
jmp 0x18a3c
testq %rsi, %rsi
je 0x189ec
movl %r14d, %eax
movq %rsi, %r12
jmp 0x18a3c
movq %rsi, -0x30(%rbp)
movq 0x7cae1(%rip), %rax     # 0x954d8
testq %rax, %rax
je 0x189fe
callq *%rax
movl %r14d, %edi
imull %r15d, %edi
callq 0xbf9b
movq %rax, %r12
movq 0x7cacc(%rip), %rax     # 0x954e0
testq %rax, %rax
je 0x18a1b
callq *%rax
testq %r12, %r12
je 0x18a32
movq %r12, %rdi
callq *0x7a937(%rip)          # 0x93360
cltd
idivl %r13d
movl %eax, %r15d
jmp 0x18a35
xorl %r12d, %r12d
movl %r14d, %eax
movq -0x30(%rbp), %rsi
movq %r12, 0x170(%rbx)
movq $0x0, 0x168(%rbx)
movw %ax, 0x150(%rbx)
testq %r12, %r12
je 0x18aa1
testl %r15d, %r15d
jle 0x18a8b
cltq
movq 0x168(%rbx), %rcx
incl %r15d
movq %rcx, (%r12)
movq %r12, %rcx
addq %rax, %r12
decl %r15d
cmpl $0x1, %r15d
jg 0x18a6b
movq %r12, %rcx
subq %rax, %rcx
movq %rcx, 0x168(%rbx)
movq %r12, 0x178(%rbx)
movb $0x1, 0x152(%rbx)
testq %rsi, %rsi
sete %al
jmp 0x18ab8
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