// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/lib/udc.c
// Function: setInitialCachedDataBounds
static void setInitialCachedDataBounds(struct udcFile *file, boolean useCacheInfo)
/* Open up bitmap file and read a little bit of it to see if cache is stale,
 * and if not to see if the initial part is cached.  Sets the data members
 * startData, and endData.  If the case is stale it makes fresh empty
 * cacheDir/sparseData and cacheDir/bitmap files. */
{
bits32 version = 0;

/* Get existing bitmap, and if it's stale clean up. */
struct udcBitmap *bits = udcBitmapOpen(file->bitmapFileName);
if (bits != NULL)
    {
    if (useCacheInfo)
	{
	file->size = bits->fileSize;
	file->updateTime = bits->remoteUpdate;
	}
    version = bits->version;
    if (bits->remoteUpdate != file->updateTime || bits->fileSize != file->size ||
	!fileExists(file->sparseFileName) ||
	(fileSize(file->sparseFileName) == 0 && file->size > 0 && fileSize(file->bitmapFileName) > udcBitmapHeaderSize))
	{
	verbose(4, "removing stale version (%lld! = %lld or %lld! = %lld or %s doesn't exist or should not be size 0), "
		"new version %d\n",
		bits->remoteUpdate, (long long)file->updateTime, bits->fileSize, file->size,
		file->sparseFileName, version);
        udcBitmapClose(&bits);
	remove(file->bitmapFileName);
	remove(file->sparseFileName);
	if (fileExists(file->redirFileName))
	    remove(file->redirFileName);
	++version;
	}
    }
else
    verbose(4, "bitmap file %s does not already exist, creating.\n", file->bitmapFileName);

/* If no bitmap, then create one, and also an empty sparse data file. */
if (bits == NULL)
    {
    udcNewCreateBitmapAndSparse(file, file->updateTime, file->size, version);
    bits = udcBitmapOpen(file->bitmapFileName);
    if (bits == NULL)
        errAbort("Unable to open bitmap file %s", file->bitmapFileName);
    }

file->bitmapVersion = bits->version;

/* Read in a little bit from bitmap while we have it open to see if we have anything cached. */
if (file->size > 0)
    {
    Bits b;
    off_t wasAt = lseek(bits->fd, 0, SEEK_CUR);
    mustReadOneFd(bits->fd, b);
    int endBlock = (file->size + udcBlockSize - 1)/udcBlockSize;
    if (endBlock > 8)
        endBlock = 8;
    int initialCachedBlocks = bitFindClear(&b, 0, endBlock);
    file->endData = initialCachedBlocks * udcBlockSize;
    ourMustLseek(&file->ios.bit, bits->fd, wasAt, SEEK_SET);
    } 

file->bits = bits;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x5e100
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x5d458
cmpl $0x0, -0xc(%rbp)
je 0x5d348
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x10(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jne 0x5d3c5
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x8(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jne 0x5d3c5
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x30cb0
cmpl $0x0, %eax
je 0x5d3c5
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x4a3e0
cmpq $0x0, %rax
jne 0x5d456
movq -0x8(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jbe 0x5d456
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x4a3e0
cmpq $0x40, %rax
jle 0x5d456
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x18(%rbp), %rax
movq 0x18(%rax), %r8
movq -0x8(%rbp), %rax
movq 0x28(%rax), %r9
movq -0x8(%rbp), %rax
movq 0x48(%rax), %r10
movl -0x10(%rbp), %eax
movl $0x4, %edi
leaq 0x81d62(%rip), %rsi     # 0xdf15e
movq %r10, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x60040
leaq -0x18(%rbp), %rdi
callq 0x5dbd0
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x6da0
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x6da0
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0x30cb0
cmpl $0x0, %eax
je 0x5d44d
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0x6da0
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x5d473
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rdx
movl $0x4, %edi
leaq 0x81d65(%rip), %rsi     # 0xdf1d1
movb $0x0, %al
callq 0x60040
cmpq $0x0, -0x18(%rbp)
jne 0x5d4c6
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdx
movl -0x10(%rbp), %ecx
callq 0x5f830
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x5e100
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x5d4c4
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rsi
leaq 0x81d46(%rip), %rdi     # 0xdf203
movb $0x0, %al
callq 0x35d40
jmp 0x5d4c6
movq -0x18(%rbp), %rax
movl 0x20(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x88(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jbe 0x5d57c
movq -0x18(%rbp), %rax
movl 0x3c(%rax), %edi
xorl %eax, %eax
movl %eax, %esi
movl $0x1, %edx
callq 0x65b0
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movl 0x3c(%rax), %edi
leaq -0x19(%rbp), %rsi
movl $0x1, %edx
callq 0x2fdb0
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
addq $0x2000, %rax           # imm = 0x2000
subq $0x1, %rax
shrq $0xd, %rax
movl %eax, -0x2c(%rbp)
cmpl $0x8, -0x2c(%rbp)
jle 0x5d53a
movl $0x8, -0x2c(%rbp)
movl -0x2c(%rbp), %edx
leaq -0x19(%rbp), %rdi
xorl %esi, %esi
callq 0x240b0
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
shll $0xd, %eax
movslq %eax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x80(%rax)
movq -0x8(%rbp), %rdi
addq $0xb8, %rdi
movq -0x18(%rbp), %rax
movl 0x3c(%rax), %esi
movq -0x28(%rbp), %rdx
xorl %ecx, %ecx
callq 0x5e3b0
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x70(%rax)
addq $0x40, %rsp
popq %rbp
retq
nop