// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/cram/cram_io.c
// Function: cram_write_block
int cram_write_block(cram_fd *fd, cram_block *b) {
    char vardata[100];
    int vardata_o = 0;

    assert(b->method != RAW || (b->comp_size == b->uncomp_size));

    if (hputc(b->method,       fd->fp)  == EOF) return -1;
    if (hputc(b->content_type, fd->fp)  == EOF) return -1;
    vardata_o += fd->vv.varint_put32(vardata          , vardata+100, b->content_id);
    vardata_o += fd->vv.varint_put32(vardata+vardata_o, vardata+100, b->comp_size);
    vardata_o += fd->vv.varint_put32(vardata+vardata_o, vardata+100, b->uncomp_size);
    if (vardata_o != hwrite(fd->fp, vardata, vardata_o))
        return -1;

    if (b->data) {
        if (b->method == RAW) {
            if (b->uncomp_size != hwrite(fd->fp, b->data, b->uncomp_size))
                return -1;
        } else {
            if (b->comp_size != hwrite(fd->fp, b->data, b->comp_size))
                return -1;
        }
    } else {
        // Absent blocks should be size 0
        assert(b->method == RAW && b->uncomp_size == 0);
    }

    if (CRAM_MAJOR_VERS(fd->version) >= 3) {
        char dat[100], *cp = (char *)dat;
        uint32_t crc;

        *cp++ = b->method;
        *cp++ = b->content_type;
        cp += fd->vv.varint_put32(cp, dat+100, b->content_id);
        cp += fd->vv.varint_put32(cp, dat+100, b->comp_size);
        cp += fd->vv.varint_put32(cp, dat+100, b->uncomp_size);
        crc = crc32(0L, (uc *)dat, cp-dat);

        if (b->method == RAW) {
            b->crc32 = crc32(crc, b->data ? b->data : (uc*)"", b->uncomp_size);
        } else {
            b->crc32 = crc32(crc, b->data ? b->data : (uc*)"", b->comp_size);
        }

        if (-1 == int32_encode(fd, b->crc32))
            return -1;
    }

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rsi, %r15
movq %rdi, %r14
movl (%rsi), %edi
testl %edi, %edi
jne 0x3f6e7
movl 0x10(%r15), %eax
cmpl 0x14(%r15), %eax
jne 0x3f89b
movq (%r14), %rsi
callq 0x3f8ba
pushq $-0x1
popq %rbx
cmpl $-0x1, %eax
je 0x3f887
movl 0x8(%r15), %edi
movq (%r14), %rsi
callq 0x3f8ba
cmpl $-0x1, %eax
je 0x3f887
leaq 0xd4(%rsp), %r13
movl 0xc(%r15), %edx
leaq 0x70(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
callq *0x89c8(%r14)
movslq %eax, %rbp
leaq (%rsp,%rbp), %rdi
addq $0x70, %rdi
movl 0x10(%r15), %edx
movq %r13, %rsi
callq *0x89c8(%r14)
addl %eax, %ebp
movslq %ebp, %rbp
leaq (%rsp,%rbp), %rdi
addq $0x70, %rdi
movl 0x14(%r15), %edx
movq %r13, %rsi
callq *0x89c8(%r14)
addl %eax, %ebp
movslq %ebp, %r13
movq (%r14), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x3e79d
cmpq %r13, %rax
jne 0x3f887
movq 0x20(%r15), %rsi
movl (%r15), %eax
testq %rsi, %rsi
je 0x3f797
movq (%r14), %rdi
testl %eax, %eax
je 0x3f7c1
movslq 0x10(%r15), %r12
jmp 0x3f7c5
testl %eax, %eax
jne 0x3f7a2
cmpl $0x0, 0x14(%r15)
je 0x3f7d6
leaq 0x3d4ce(%rip), %rdi     # 0x7cc77
leaq 0x3d48a(%rip), %rsi     # 0x7cc3a
leaq 0x3d492(%rip), %rcx     # 0x7cc49
movl $0x5fb, %edx            # imm = 0x5FB
callq 0x42f0
movslq 0x14(%r15), %r12
movq %r12, %rdx
callq 0x3e79d
cmpq %r12, %rax
jne 0x3f887
cmpl $0x300, 0xc(%r14)       # imm = 0x300
jl 0x3f885
movb (%r15), %al
leaq 0x2(%rsp), %rdi
movb %al, -0x2(%rdi)
movb 0x8(%r15), %al
movb %al, -0x1(%rdi)
leaq 0x64(%rsp), %r12
movl 0xc(%r15), %edx
movq %r12, %rsi
callq *0x89c8(%r14)
cltq
leaq (%rsp,%rax), %r13
addq $0x2, %r13
movl 0x10(%r15), %edx
movq %r13, %rdi
movq %r12, %rsi
callq *0x89c8(%r14)
movslq %eax, %rbp
addq %r13, %rbp
movl 0x14(%r15), %edx
movq %rbp, %rdi
movq %r12, %rsi
callq *0x89c8(%r14)
addl %eax, %ebp
movq %rsp, %rsi
subl %esi, %ebp
xorl %edi, %edi
movl %ebp, %edx
callq 0x4320
xorl %ecx, %ecx
cmpl $0x0, (%r15)
sete %cl
movl %eax, %edi
movq 0x20(%r15), %rax
testq %rax, %rax
leaq 0x384f2(%rip), %rsi     # 0x77d56
cmovneq %rax, %rsi
movl 0x10(%r15,%rcx,4), %edx
callq 0x4320
movl %eax, 0x18(%r15)
movq %r14, %rdi
movl %eax, %esi
callq 0x3f8d6
cmpl $-0x1, %eax
je 0x3f887
xorl %ebx, %ebx
movl %ebx, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3d363(%rip), %rdi     # 0x7cc05
leaq 0x3d391(%rip), %rsi     # 0x7cc3a
leaq 0x3d399(%rip), %rcx     # 0x7cc49
movl $0x5e7, %edx            # imm = 0x5E7
callq 0x42f0