// File: /workspace/github_c_makefile_star2_O3/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 0x187bd
retq
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %r12d
movl %edx, %r15d
movq %rdi, %rbx
movq %rsi, -0x30(%rbp)
cmpb $0x0, 0x153(%rdi)
je 0x187ed
movq 0x170(%rbx), %rdi
callq 0xa630
andl $-0x8, %r15d
xorl %eax, %eax
cmpl $0x9, %r15d
setl %cl
movl %r15d, %r14d
cmovll %eax, %r14d
testl %r12d, %r12d
cmovlel %eax, %r12d
setle %dl
orb %cl, %dl
je 0x1883d
movq $0x0, 0x168(%rbx)
movw %ax, 0x150(%rbx)
movq %rbx, 0x170(%rbx)
movq %rbx, 0x178(%rbx)
movb $0x0, 0x152(%rbx)
xorl %eax, %eax
jmp 0x188ed
movq -0x30(%rbp), %rdx
testq %rdx, %rdx
je 0x1884b
movq %rdx, %r13
jmp 0x18892
movq 0x7ac96(%rip), %rax     # 0x934e8
testq %rax, %rax
je 0x18859
callq *%rax
imull %r15d, %r12d
movq %r12, %rdi
callq 0xc0e2
movq %rax, %r13
movq 0x7ac81(%rip), %rax     # 0x934f0
testq %rax, %rax
je 0x18876
callq *%rax
movl %r14d, %eax
testq %r13, %r13
je 0x1880f
movq %r13, %rdi
callq *0x78ae9(%rip)          # 0x91370
cltd
idivl %r15d
movl %eax, %r12d
movq -0x30(%rbp), %rdx
movq %r13, 0x170(%rbx)
movq $0x0, 0x168(%rbx)
movw %r15w, 0x150(%rbx)
testl %r12d, %r12d
jle 0x188d9
movl %r15d, %eax
incl %r12d
xorl %ecx, %ecx
movq %rcx, (%r13)
movq %r13, %rcx
addq %rax, %r13
decl %r12d
cmpl $0x1, %r12d
ja 0x188b9
movq %r13, %rax
subq %r15, %rax
movq %rax, 0x168(%rbx)
testq %rdx, %rdx
sete %al
movq %r13, 0x178(%rbx)
movb $0x1, 0x152(%rbx)
movb %al, 0x153(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq