// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/htslib/cram/cram_io.c
// Function: cram_read_block
cram_block *cram_read_block(cram_fd *fd) {
    cram_block *b = malloc(sizeof(*b));
    unsigned char c;
    uint32_t crc = 0;
    if (!b)
	return NULL;

    //fprintf(stderr, "Block at %d\n", (int)ftell(fd->fp));

    if (-1 == (b->method      = hgetc(fd->fp))) { free(b); return NULL; }
    c = b->method; crc = crc32(crc, &c, 1);
    if (-1 == (b->content_type= hgetc(fd->fp))) { free(b); return NULL; }
    c = b->content_type; crc = crc32(crc, &c, 1);
    if (-1 == itf8_decode_crc(fd, &b->content_id, &crc))  { free(b); return NULL; }
    if (-1 == itf8_decode_crc(fd, &b->comp_size, &crc))   { free(b); return NULL; }
    if (-1 == itf8_decode_crc(fd, &b->uncomp_size, &crc)) { free(b); return NULL; }

    //    fprintf(stderr, "  method %d, ctype %d, cid %d, csize %d, ucsize %d\n",
    //	    b->method, b->content_type, b->content_id, b->comp_size, b->uncomp_size);

    if (b->method == RAW) {
	b->alloc = b->uncomp_size;
	if (!(b->data = malloc(b->uncomp_size))){ free(b); return NULL; }
	if (b->uncomp_size != hread(fd->fp, b->data, b->uncomp_size)) {
	    free(b->data);
	    free(b);
	    return NULL;
	}
    } else {
	b->alloc = b->comp_size;
	if (!(b->data = malloc(b->comp_size)))  { free(b); return NULL; }
	if (b->comp_size != hread(fd->fp, b->data, b->comp_size)) {
	    free(b->data);
	    free(b);
	    return NULL;
	}
    }

    if (CRAM_MAJOR_VERS(fd->version) >= 3) {
	if (-1 == int32_decode(fd, (int32_t *)&b->crc32)) {
	    free(b);
	    return NULL;
	}

	crc = crc32(crc, b->data ? b->data : (uc *)"", b->alloc);
	if (crc != b->crc32) {
	    fprintf(stderr, "Block CRC32 failure\n");
	    free(b->data);
	    free(b);
	    return NULL;
	}
    }

    b->orig_method = b->method;
    b->idx = 0;
    b->byte = 0;
    b->bit = 7; // MSB

    return b;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl $0x40, %edi
callq 0x69c0
movq %rax, -0x18(%rbp)
movl $0x0, -0x20(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x7e285
movq $0x0, -0x8(%rbp)
jmp 0x7e61a
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x7b7c0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x7e2b8
movq -0x18(%rbp), %rdi
callq 0x6880
movq $0x0, -0x8(%rbp)
jmp 0x7e61a
movq -0x18(%rbp), %rax
movl (%rax), %eax
movb %al, -0x19(%rbp)
movl -0x20(%rbp), %eax
movl %eax, %edi
leaq -0x19(%rbp), %rsi
movl $0x1, %edx
callq 0x64a0
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x7b7c0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x8(%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x7e30b
movq -0x18(%rbp), %rdi
callq 0x6880
movq $0x0, -0x8(%rbp)
jmp 0x7e61a
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
movb %al, -0x19(%rbp)
movl -0x20(%rbp), %eax
movl %eax, %edi
leaq -0x19(%rbp), %rsi
movl $0x1, %edx
callq 0x64a0
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0xc, %rsi
leaq -0x20(%rbp), %rdx
callq 0x7b810
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x7e361
movq -0x18(%rbp), %rdi
callq 0x6880
movq $0x0, -0x8(%rbp)
jmp 0x7e61a
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x10, %rsi
leaq -0x20(%rbp), %rdx
callq 0x7b810
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x7e397
movq -0x18(%rbp), %rdi
callq 0x6880
movq $0x0, -0x8(%rbp)
jmp 0x7e61a
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x14, %rsi
leaq -0x20(%rbp), %rdx
callq 0x7b810
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x7e3cd
movq -0x18(%rbp), %rdi
callq 0x6880
movq $0x0, -0x8(%rbp)
jmp 0x7e61a
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x7e477
movq -0x18(%rbp), %rax
movslq 0x14(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x18(%rbp), %rax
movslq 0x14(%rax), %rdi
callq 0x69c0
movq -0x18(%rbp), %rcx
movq %rax, 0x20(%rcx)
cmpq $0x0, %rax
jne 0x7e41b
movq -0x18(%rbp), %rdi
callq 0x6880
movq $0x0, -0x8(%rbp)
jmp 0x7e61a
movq -0x18(%rbp), %rax
movslq 0x14(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x18(%rbp), %rax
movslq 0x14(%rax), %rdx
callq 0x7dbd0
movq %rax, %rcx
movq -0x28(%rbp), %rax
cmpq %rcx, %rax
je 0x7e472
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x6880
movq -0x18(%rbp), %rdi
callq 0x6880
movq $0x0, -0x8(%rbp)
jmp 0x7e61a
jmp 0x7e511
movq -0x18(%rbp), %rax
movslq 0x10(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x18(%rbp), %rax
movslq 0x10(%rax), %rdi
callq 0x69c0
movq -0x18(%rbp), %rcx
movq %rax, 0x20(%rcx)
cmpq $0x0, %rax
jne 0x7e4b8
movq -0x18(%rbp), %rdi
callq 0x6880
movq $0x0, -0x8(%rbp)
jmp 0x7e61a
movq -0x18(%rbp), %rax
movslq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x18(%rbp), %rax
movslq 0x10(%rax), %rdx
callq 0x7dbd0
movq %rax, %rcx
movq -0x30(%rbp), %rax
cmpq %rcx, %rax
je 0x7e50f
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x6880
movq -0x18(%rbp), %rdi
callq 0x6880
movq $0x0, -0x8(%rbp)
jmp 0x7e61a
jmp 0x7e511
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
cmpl $0x3, %eax
jl 0x7e5e3
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x18, %rsi
callq 0x7db70
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x7e556
movq -0x18(%rbp), %rdi
callq 0x6880
movq $0x0, -0x8(%rbp)
jmp 0x7e61a
movl -0x20(%rbp), %eax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x7e576
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x7e583
leaq 0x66e89(%rip), %rax     # 0xe5406
movq %rax, -0x40(%rbp)
jmp 0x7e583
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movl %eax, %edx
callq 0x64a0
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x18(%rcx), %eax
je 0x7e5e1
movq 0x86a20(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
leaq 0x64682(%rip), %rsi     # 0xe2c3c
movb $0x0, %al
callq 0x6a80
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x6880
movq -0x18(%rbp), %rdi
callq 0x6880
movq $0x0, -0x8(%rbp)
jmp 0x7e61a
jmp 0x7e5e3
movq -0x18(%rbp), %rax
movl (%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x1c(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x18(%rbp), %rax
movl $0x7, 0x38(%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)