// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: setupLookaside
static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){
#ifndef SQLITE_OMIT_LOOKASIDE
  void *pStart;
  sqlite3_int64 szAlloc = sz*(sqlite3_int64)cnt;
  int nBig;   /* Number of full-size slots */
  int nSm;    /* Number smaller LOOKASIDE_SMALL-byte slots */

  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( szAlloc );  /* IMP: R-61949-35727 */
    sqlite3EndBenignMalloc();
    if( pStart ) szAlloc = sqlite3MallocSize(pStart);
  }else{
    pStart = pBuf;
  }
#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE
  if( sz>=LOOKASIDE_SMALL*3 ){
    nBig = szAlloc/(3*LOOKASIDE_SMALL+sz);
    nSm = (szAlloc - sz*nBig)/LOOKASIDE_SMALL;
  }else if( sz>=LOOKASIDE_SMALL*2 ){
    nBig = szAlloc/(LOOKASIDE_SMALL+sz);
    nSm = (szAlloc - sz*nBig)/LOOKASIDE_SMALL;
  }else
#endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */
  if( sz>0 ){
    nBig = szAlloc/sz;
    nSm = 0;
  }else{
    nBig = nSm = 0;
  }
  db->lookaside.pStart = pStart;
  db->lookaside.pInit = 0;
  db->lookaside.pFree = 0;
  db->lookaside.sz = (u16)sz;
  db->lookaside.szTrue = (u16)sz;
  if( pStart ){
    int i;
    LookasideSlot *p;
    assert( sz > (int)sizeof(LookasideSlot*) );
    p = (LookasideSlot*)pStart;
    for(i=0; i<nBig; i++){
      p->pNext = db->lookaside.pInit;
      db->lookaside.pInit = p;
      p = (LookasideSlot*)&((u8*)p)[sz];
    }
#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE
    db->lookaside.pSmallInit = 0;
    db->lookaside.pSmallFree = 0;
    db->lookaside.pMiddle = p;
    for(i=0; i<nSm; i++){
      p->pNext = db->lookaside.pSmallInit;
      db->lookaside.pSmallInit = p;
      p = (LookasideSlot*)&((u8*)p)[LOOKASIDE_SMALL];
    }
#endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */
    assert( ((uptr)p)<=szAlloc + (uptr)pStart );
    db->lookaside.pEnd = p;
    db->lookaside.bDisable = 0;
    db->lookaside.bMalloced = pBuf==0 ?1:0;
    db->lookaside.nSlot = nBig+nSm;
  }else{
    db->lookaside.pStart = db;
#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE
    db->lookaside.pSmallInit = 0;
    db->lookaside.pSmallFree = 0;
    db->lookaside.pMiddle = db;
#endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */
    db->lookaside.pEnd = db;
    db->lookaside.bDisable = 1;
    db->lookaside.sz = 0;
    db->lookaside.bMalloced = 0;
    db->lookaside.nSlot = 0;
  }
  assert( sqlite3LookasideUsed(db,0)==0 );
#endif /* SQLITE_OMIT_LOOKASIDE */
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movslq -0x1c(%rbp), %rax
movslq -0x20(%rbp), %rcx
imulq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3bfca0
cmpl $0x0, %eax
jle 0x3d0e54
movl $0x5, -0x4(%rbp)
jmp 0x3d1199
movq -0x10(%rbp), %rax
cmpb $0x0, 0x178(%rax)
je 0x3d0e71
movq -0x10(%rbp), %rax
movq 0x1b8(%rax), %rdi
callq 0x3c0800
movl -0x1c(%rbp), %eax
andl $-0x8, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x8, -0x1c(%rbp)
jg 0x3d0e87
movl $0x0, -0x1c(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x3d0e94
movl $0x0, -0x20(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x3d0ea0
cmpl $0x0, -0x20(%rbp)
jne 0x3d0eb1
movl $0x0, -0x1c(%rbp)
movq $0x0, -0x28(%rbp)
jmp 0x3d0ef1
cmpq $0x0, -0x18(%rbp)
jne 0x3d0ee7
callq 0x3e01d0
movq -0x30(%rbp), %rdi
callq 0x3c0760
movq %rax, -0x28(%rbp)
callq 0x3e0220
cmpq $0x0, -0x28(%rbp)
je 0x3d0ee5
movq -0x28(%rbp), %rdi
callq 0x3c08a0
cltq
movq %rax, -0x30(%rbp)
jmp 0x3d0eef
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x3d0ef1
cmpl $0x180, -0x1c(%rbp)     # imm = 0x180
jl 0x3d0f32
movq -0x30(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl $0x180, %ecx            # imm = 0x180
movslq %ecx, %rcx
cqto
idivq %rcx
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rax
movl -0x1c(%rbp), %ecx
imull -0x34(%rbp), %ecx
movslq %ecx, %rcx
subq %rcx, %rax
movl $0x80, %ecx
cqto
idivq %rcx
movl %eax, -0x38(%rbp)
jmp 0x3d0fa4
cmpl $0x100, -0x1c(%rbp)     # imm = 0x100
jl 0x3d0f73
movq -0x30(%rbp), %rax
movl -0x1c(%rbp), %ecx
addl $0x80, %ecx
movslq %ecx, %rcx
cqto
idivq %rcx
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rax
movl -0x1c(%rbp), %ecx
imull -0x34(%rbp), %ecx
movslq %ecx, %rcx
subq %rcx, %rax
movl $0x80, %ecx
cqto
idivq %rcx
movl %eax, -0x38(%rbp)
jmp 0x3d0fa2
cmpl $0x0, -0x1c(%rbp)
jle 0x3d0f92
movq -0x30(%rbp), %rax
movslq -0x1c(%rbp), %rcx
cqto
idivq %rcx
movl %eax, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
jmp 0x3d0fa0
movl $0x0, -0x38(%rbp)
movl $0x0, -0x34(%rbp)
jmp 0x3d0fa2
jmp 0x3d0fa4
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x1b8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x190(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x198(%rax)
movl -0x1c(%rbp), %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x174(%rax)
movl -0x1c(%rbp), %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x176(%rax)
cmpq $0x0, -0x28(%rbp)
je 0x3d1113
movq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x3d1050
movq -0x10(%rbp), %rax
movq 0x190(%rax), %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x190(%rax)
movq -0x48(%rbp), %rax
movslq -0x1c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x3d100d
movq -0x10(%rbp), %rax
movq $0x0, 0x1a0(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x1a8(%rax)
movq -0x48(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x1b0(%rax)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x38(%rbp), %eax
jge 0x3d10c6
movq -0x10(%rbp), %rax
movq 0x1a0(%rax), %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x1a0(%rax)
movq -0x48(%rbp), %rax
addq $0x80, %rax
movq %rax, -0x48(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x3d1084
movq -0x48(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x1c0(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x170(%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, 0x178(%rax)
movl -0x34(%rbp), %ecx
addl -0x38(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x17c(%rax)
jmp 0x3d1192
movq -0x10(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x1b8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x1a0(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x1a8(%rax)
movq -0x10(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x1b0(%rax)
movq -0x10(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x1c0(%rax)
movq -0x10(%rbp), %rax
movl $0x1, 0x170(%rax)
movq -0x10(%rbp), %rax
movw $0x0, 0x174(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x178(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x17c(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)