// File: /workspace/github_c_makefile_star2_O0/samtools[P]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 == fd->vv.varint_decode32_crc(fd, &b->content_id, &crc))  { free(b); return NULL; }
    if (-1 == fd->vv.varint_decode32_crc(fd, &b->comp_size, &crc))   { free(b); return NULL; }
    if (-1 == fd->vv.varint_decode32_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) {
        if (b->uncomp_size < 0 || b->comp_size != b->uncomp_size) {
            free(b);
            return NULL;
        }
        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 {
        if (b->comp_size < 0 || b->uncomp_size < 0) {
            free(b);
            return NULL;
        }
        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->data);
            free(b);
            return NULL;
        }

        b->crc32_checked = fd->ignore_md5;
        b->crc_part = crc;
    } else {
        b->crc32_checked = 1; // CRC not present
    }

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

    return b;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl $0x50, %edi
callq 0x4650
movq %rax, -0x18(%rbp)
movl $0x0, -0x20(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x6eef5
movq $0x0, -0x8(%rbp)
jmp 0x6f29d
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x6cbf0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x6ef28
movq -0x18(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0x6f29d
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 0x4310
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x6cbf0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x8(%rax)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x6ef7b
movq -0x18(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0x6f29d
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 0x4310
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x8990(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0xc, %rsi
leaq -0x20(%rbp), %rdx
callq *%rax
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x6efd9
movq -0x18(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0x6f29d
movq -0x10(%rbp), %rax
movq 0x8990(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x10, %rsi
leaq -0x20(%rbp), %rdx
callq *%rax
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x6f017
movq -0x18(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0x6f29d
movq -0x10(%rbp), %rax
movq 0x8990(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x14, %rsi
leaq -0x20(%rbp), %rdx
callq *%rax
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x6f055
movq -0x18(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0x6f29d
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x6f12f
movq -0x18(%rbp), %rax
cmpl $0x0, 0x14(%rax)
jl 0x6f07c
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x14(%rcx), %eax
je 0x6f092
movq -0x18(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0x6f29d
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 0x4650
movq -0x18(%rbp), %rcx
movq %rax, 0x20(%rcx)
cmpq $0x0, %rax
jne 0x6f0d3
movq -0x18(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0x6f29d
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 0x6cee0
movq %rax, %rcx
movq -0x28(%rbp), %rax
cmpq %rcx, %rax
je 0x6f12a
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x45a0
movq -0x18(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0x6f29d
jmp 0x6f1f3
movq -0x18(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jl 0x6f143
movq -0x18(%rbp), %rax
cmpl $0x0, 0x14(%rax)
jge 0x6f159
movq -0x18(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0x6f29d
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 0x4650
movq -0x18(%rbp), %rcx
movq %rax, 0x20(%rcx)
cmpq $0x0, %rax
jne 0x6f19a
movq -0x18(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0x6f29d
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 0x6cee0
movq %rax, %rcx
movq -0x30(%rbp), %rax
cmpq %rcx, %rax
je 0x6f1f1
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x45a0
movq -0x18(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0x6f29d
jmp 0x6f1f3
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
cmpl $0x3, %eax
jl 0x6f25b
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x18, %rsi
callq 0x6f2b0
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x6f23e
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x45a0
movq -0x18(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
jmp 0x6f29d
movq -0x10(%rbp), %rax
movl 0x22c(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x48(%rax)
movl -0x20(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x4c(%rax)
jmp 0x6f266
movq -0x18(%rbp), %rax
movl $0x1, 0x48(%rax)
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 $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)