// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/lib/udc.c
// Function: fetchMissingBits
static boolean fetchMissingBits(struct udcFile *file, struct udcBitmap *bits,
	bits64 start, bits64 end, bits64 *retFetchedStart, bits64 *retFetchedEnd)
/* Scan through relevant parts of bitmap, fetching blocks we don't already have. */
{
/* Fetch relevant part of bitmap into memory */
int partOffset;
Bits *b;
int startBlock = start / bits->blockSize;
int endBlock = (end + bits->blockSize - 1) / bits->blockSize;
readBitsIntoBuf(file, bits->fd, udcBitmapHeaderSize, startBlock, endBlock, &b, &partOffset);
if (allBitsSetInFile(startBlock, endBlock, partOffset, b))
    {  // it is already in the cache
    freeMem(b);
    return TRUE;
    }

/* Loop around first skipping set bits, then fetching clear bits. */
boolean dirty = FALSE;
int s = startBlock - partOffset;
int e = endBlock - partOffset;
for (;;)
    {
    int nextClearBit = bitFindClear(b, s, e);
    if (nextClearBit >= e)
        break;
    int nextSetBit = bitFindSet(b, nextClearBit, e);
    int clearSize =  nextSetBit - nextClearBit;

    fetchMissingBlocks(file, bits, nextClearBit + partOffset, clearSize, bits->blockSize);
    bitSetRange(b, nextClearBit, clearSize);

    dirty = TRUE;
    if (nextSetBit >= e)
        break;
    s = nextSetBit;
    }

if (dirty)
    {
    /* Update bitmap on disk.... */
    int byteStart = startBlock/8;
    int byteEnd = bitToByteSize(endBlock);
    int byteSize = byteEnd - byteStart;
    ourMustLseek(&file->ios.bit, bits->fd, byteStart + udcBitmapHeaderSize, SEEK_SET);
    ourMustWrite(&file->ios.bit, bits->fd, b, byteSize);
    }

freeMem(b);
*retFetchedStart = startBlock * bits->blockSize;
*retFetchedEnd = endBlock * bits->blockSize;
return FALSE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
movl 0x8(%rcx), %ecx
xorl %edx, %edx
divq %rcx
movl %eax, -0x4c(%rbp)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movl 0x8(%rcx), %ecx
addq %rcx, %rax
subq $0x1, %rax
movq -0x18(%rbp), %rcx
movl 0x8(%rcx), %ecx
xorl %edx, %edx
divq %rcx
movl %eax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x3c(%rax), %esi
movl -0x4c(%rbp), %ecx
movl -0x50(%rbp), %r8d
movl $0x40, %edx
leaq -0x48(%rbp), %r9
leaq -0x3c(%rbp), %rax
movq %rax, (%rsp)
callq 0x5e300
movl -0x4c(%rbp), %edi
movl -0x50(%rbp), %esi
movl -0x3c(%rbp), %edx
movq -0x48(%rbp), %rcx
callq 0x5fd90
cmpl $0x0, %eax
je 0x5fbcb
movq -0x48(%rbp), %rdi
callq 0x40d40
movl $0x1, -0x4(%rbp)
jmp 0x5fd0c
movl $0x0, -0x54(%rbp)
movl -0x4c(%rbp), %eax
subl -0x3c(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x50(%rbp), %eax
subl -0x3c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0x48(%rbp), %rdi
movl -0x58(%rbp), %esi
movl -0x5c(%rbp), %edx
callq 0x240b0
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jl 0x5fc00
jmp 0x5fc61
movq -0x48(%rbp), %rdi
movl -0x60(%rbp), %esi
movl -0x5c(%rbp), %edx
callq 0x24080
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
subl -0x60(%rbp), %eax
movl %eax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x60(%rbp), %edx
addl -0x3c(%rbp), %edx
movl -0x68(%rbp), %ecx
movq -0x18(%rbp), %rax
movl 0x8(%rax), %r8d
callq 0x5fdf0
movq -0x48(%rbp), %rdi
movl -0x60(%rbp), %esi
movl -0x68(%rbp), %edx
callq 0x23cd0
movl $0x1, -0x54(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x5c(%rbp), %eax
jl 0x5fc59
jmp 0x5fc61
movl -0x64(%rbp), %eax
movl %eax, -0x58(%rbp)
jmp 0x5fbe4
cmpl $0x0, -0x54(%rbp)
je 0x5fcd0
movl -0x4c(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, -0x6c(%rbp)
movl -0x50(%rbp), %eax
addl $0x7, %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
subl -0x6c(%rbp), %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
addq $0xb8, %rdi
movq -0x18(%rbp), %rax
movl 0x3c(%rax), %esi
movl -0x6c(%rbp), %eax
addl $0x40, %eax
movslq %eax, %rdx
xorl %ecx, %ecx
callq 0x5e3b0
movq -0x10(%rbp), %rdi
addq $0xb8, %rdi
movq -0x18(%rbp), %rax
movl 0x3c(%rax), %esi
movq -0x48(%rbp), %rdx
movslq -0x74(%rbp), %rcx
callq 0x5fa10
movq -0x48(%rbp), %rdi
callq 0x40d40
movl -0x4c(%rbp), %eax
movq -0x18(%rbp), %rcx
imull 0x8(%rcx), %eax
movl %eax, %eax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movl -0x50(%rbp), %eax
movq -0x18(%rbp), %rcx
imull 0x8(%rcx), %eax
movl %eax, %eax
movl %eax, %ecx
movq -0x38(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)