// File: /workspace/github_c_makefile_star2_O0/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
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), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4054d0
cmpl $0x0, %eax
jle 0x416944
movl $0x5, -0x4(%rbp)
jmp 0x416b19
movq -0x10(%rbp), %rax
cmpb $0x0, 0x166(%rax)
je 0x416961
movq -0x10(%rbp), %rax
movq 0x188(%rax), %rdi
callq 0x406240
movl -0x1c(%rbp), %eax
andl $-0x8, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x8, -0x1c(%rbp)
jg 0x416977
movl $0x0, -0x1c(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x416984
movl $0x0, -0x20(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x416990
cmpl $0x0, -0x20(%rbp)
jne 0x4169a1
movl $0x0, -0x1c(%rbp)
movq $0x0, -0x28(%rbp)
jmp 0x4169e8
cmpq $0x0, -0x18(%rbp)
jne 0x4169de
callq 0x425190
movl -0x1c(%rbp), %eax
imull -0x20(%rbp), %eax
movslq %eax, %rdi
callq 0x406180
movq %rax, -0x28(%rbp)
callq 0x4251e0
cmpq $0x0, -0x28(%rbp)
je 0x4169dc
movq -0x28(%rbp), %rdi
callq 0x4062f0
cltd
idivl -0x1c(%rbp)
movl %eax, -0x20(%rbp)
jmp 0x4169e6
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x4169e8
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x188(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x178(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x180(%rax)
movl -0x1c(%rbp), %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x164(%rax)
cmpq $0x0, -0x28(%rbp)
je 0x416acd
movl -0x20(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x168(%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0x20(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jl 0x416a90
movq -0x10(%rbp), %rax
movq 0x178(%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x178(%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 0x416a4f
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x190(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x160(%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, 0x166(%rax)
jmp 0x416b12
movq -0x10(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x188(%rax)
movq -0x10(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x190(%rax)
movq -0x10(%rbp), %rax
movl $0x1, 0x160(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x166(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x168(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)