// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/lib/udc.c
// Function: udcBitmapOpen
static struct udcBitmap *udcBitmapOpen(char *fileName)
/* Open up a bitmap file and read and verify header.  Return NULL if file doesn't
 * exist, abort on error. */
{
/* Open file, returning NULL if can't. */
int fd = open(fileName, O_RDWR);
if (fd < 0)
    {
    if (errno == ENOENT)
	return NULL;
    else
	errnoAbort("Can't open(%s, O_RDWR)", fileName);
    }

/* Get status info from file. */
struct stat status;
fstat(fd, &status);
if (status.st_size < udcBitmapHeaderSize) // check for truncated invalid bitmap files.
    {
    close(fd);
    return NULL;  // returning NULL will cause the fresh creation of bitmap and sparseData files.
    }  

/* Read signature and decide if byte-swapping is needed. */
// TODO: maybe buffer the I/O for performance?  Don't read past header - 
// fd offset needs to point to first data block when we return.
bits32 magic;
boolean isSwapped = FALSE;
mustReadOneFd(fd, magic);
if (magic != udcBitmapSig)
    {
    magic = byteSwap32(magic);
    isSwapped = TRUE;
    if (magic != udcBitmapSig)
       errAbort("%s is not a udcBitmap file", fileName);
    }

/* Allocate bitmap object, fill it in, and return it. */
struct udcBitmap *bits;
AllocVar(bits);
bits->blockSize = fdReadBits32(fd, isSwapped);
bits->remoteUpdate = fdReadBits64(fd, isSwapped);
bits->fileSize = fdReadBits64(fd, isSwapped);
bits->version = fdReadBits32(fd, isSwapped);
fdReadBits32(fd, isSwapped); // ignore result
fdReadBits64(fd, isSwapped); // ignore result
fdReadBits64(fd, isSwapped); // ignore result
fdReadBits64(fd, isSwapped); // ignore result
fdReadBits64(fd, isSwapped); // ignore result
bits->localUpdate = status.st_mtime;
bits->localAccess = status.st_atime;
bits->isSwapped = isSwapped;
bits->fd = fd;

return bits;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movl $0x2, %esi
movb $0x0, %al
callq 0x6d10
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jge 0x5e153
callq 0x6060
cmpl $0x2, (%rax)
jne 0x5e13f
movq $0x0, -0x8(%rbp)
jmp 0x5e2ec
movq -0x10(%rbp), %rsi
leaq 0x8116e(%rip), %rdi     # 0xdf2b8
movb $0x0, %al
callq 0x35ee0
jmp 0x5e153
movl -0x14(%rbp), %edi
leaq -0xa8(%rbp), %rsi
callq 0x6db0
cmpq $0x40, -0x78(%rbp)
jge 0x5e17e
movl -0x14(%rbp), %edi
callq 0x6e90
movq $0x0, -0x8(%rbp)
jmp 0x5e2ec
movl $0x0, -0xb0(%rbp)
movl -0x14(%rbp), %edi
leaq -0xac(%rbp), %rsi
movl $0x4, %edx
callq 0x2fdb0
cmpl $0x4187e2f6, -0xac(%rbp) # imm = 0x4187E2F6
je 0x5e1e3
movl -0xac(%rbp), %edi
callq 0x30770
movl %eax, -0xac(%rbp)
movl $0x1, -0xb0(%rbp)
cmpl $0x4187e2f6, -0xac(%rbp) # imm = 0x4187E2F6
je 0x5e1e1
movq -0x10(%rbp), %rsi
leaq 0x810f5(%rip), %rdi     # 0xdf2cf
movb $0x0, %al
callq 0x35d40
jmp 0x5e1e3
movl $0x40, %edi
callq 0x40c50
movq %rax, -0xb8(%rbp)
movl -0x14(%rbp), %edi
movl -0xb0(%rbp), %esi
callq 0x307e0
movl %eax, %ecx
movq -0xb8(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x14(%rbp), %edi
movl -0xb0(%rbp), %esi
callq 0x306e0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq %rcx, 0x10(%rax)
movl -0x14(%rbp), %edi
movl -0xb0(%rbp), %esi
callq 0x306e0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x14(%rbp), %edi
movl -0xb0(%rbp), %esi
callq 0x307e0
movl %eax, %ecx
movq -0xb8(%rbp), %rax
movl %ecx, 0x20(%rax)
movl -0x14(%rbp), %edi
movl -0xb0(%rbp), %esi
callq 0x307e0
movl -0x14(%rbp), %edi
movl -0xb0(%rbp), %esi
callq 0x306e0
movl -0x14(%rbp), %edi
movl -0xb0(%rbp), %esi
callq 0x306e0
movl -0x14(%rbp), %edi
movl -0xb0(%rbp), %esi
callq 0x306e0
movl -0x14(%rbp), %edi
movl -0xb0(%rbp), %esi
callq 0x306e0
movq -0x50(%rbp), %rcx
movq -0xb8(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x60(%rbp), %rcx
movq -0xb8(%rbp), %rax
movq %rcx, 0x30(%rax)
movl -0xb0(%rbp), %ecx
movq -0xb8(%rbp), %rax
movl %ecx, 0x38(%rax)
movl -0x14(%rbp), %ecx
movq -0xb8(%rbp), %rax
movl %ecx, 0x3c(%rax)
movq -0xb8(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax)