// File: /workspace/github_c_makefile_star2_O0/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:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x154(%rax)
je 0x1d07f
movl $0x5, -0x4(%rbp)
jmp 0x1d224
movq -0x10(%rbp), %rax
cmpb $0x0, 0x153(%rax)
je 0x1d09c
movq -0x10(%rbp), %rax
movq 0x170(%rax), %rdi
callq 0xb958
movl -0x1c(%rbp), %eax
andl $-0x8, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x8, -0x1c(%rbp)
jg 0x1d0b2
movl $0x0, -0x1c(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x1d0bf
movl $0x0, -0x20(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x1d0cb
cmpl $0x0, -0x20(%rbp)
jne 0x1d0dc
movl $0x0, -0x1c(%rbp)
movq $0x0, -0x28(%rbp)
jmp 0x1d123
cmpq $0x0, -0x18(%rbp)
jne 0x1d119
callq 0x2a3f0
movl -0x1c(%rbp), %eax
imull -0x20(%rbp), %eax
movslq %eax, %rdi
callq 0xdba0
movq %rax, -0x28(%rbp)
callq 0x2a440
cmpq $0x0, -0x28(%rbp)
je 0x1d117
movq -0x28(%rbp), %rdi
callq 0xdd10
cltd
idivl -0x1c(%rbp)
movl %eax, -0x20(%rbp)
jmp 0x1d121
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x1d123
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x170(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x168(%rax)
movl -0x1c(%rbp), %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x150(%rax)
cmpq $0x0, -0x28(%rbp)
je 0x1d1e9
movq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0x20(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jl 0x1d1af
movq -0x10(%rbp), %rax
movq 0x168(%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x168(%rax)
movq -0x38(%rbp), %rax
movslq -0x1c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1d16e
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x178(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x152(%rax)
movq -0x18(%rbp), %rdx
xorl %eax, %eax
movl $0x1, %ecx
cmpq $0x0, %rdx
cmovel %ecx, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x153(%rax)
jmp 0x1d21d
movq -0x10(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x170(%rax)
movq -0x10(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x178(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x152(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x153(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)