// File: /workspace/github_c_makefile_star2_O3/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 $0xe8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl (%rsi), %eax
testl %eax, %eax
jne 0x4ca44
movl 0x10(%r14), %ecx
cmpl 0x14(%r14), %ecx
jne 0x4cdea
movq (%rbx), %rsi
movq 0x8(%rsi), %rcx
cmpq 0x18(%rsi), %rcx
jae 0x4ca5d
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rsi)
movb %al, (%rcx)
jmp 0x4ca64
movl %eax, %edi
callq 0xf2cb
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0x4cdd6
movl 0x8(%r14), %eax
movq (%rbx), %rsi
movq 0x8(%rsi), %rcx
cmpq 0x18(%rsi), %rcx
jae 0x4ca8f
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rsi)
movb %al, (%rcx)
jmp 0x4ca96
movl %eax, %edi
callq 0xf2cb
cmpl $-0x1, %eax
je 0x4cdd6
leaq 0x74(%rsp), %r15
movl 0xc(%r14), %edx
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq *0x89c8(%rbx)
movslq %eax, %r12
leaq (%rsp,%r12), %rdi
addq $0x10, %rdi
movl 0x10(%r14), %edx
movq %r15, %rsi
callq *0x89c8(%rbx)
addl %eax, %r12d
movslq %r12d, %r12
leaq (%rsp,%r12), %rdi
addq $0x10, %rdi
movl 0x14(%r14), %edx
movq %r15, %rsi
callq *0x89c8(%rbx)
addl %eax, %r12d
movslq %r12d, %rbp
movq (%rbx), %r12
testb $0x2, 0x30(%r12)
movq 0x18(%r12), %r13
jne 0x4cb28
movq %r13, %rax
subq 0x8(%r12), %rax
cmpq %rbp, %rax
jae 0x4cb28
addq %rbp, %r13
subq (%r12), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0xee24
movq 0x18(%r12), %r13
movq %r13, 0x10(%r12)
movq 0x8(%r12), %rdi
subq %rdi, %r13
cmpq %rbp, %r13
ja 0x4cb3b
cmpq (%r12), %rdi
je 0x4cb5e
cmpq %rbp, %r13
movq %rbp, %r15
cmovbq %r13, %r15
leaq 0x10(%rsp), %rsi
movq %r15, %rdx
callq 0x43c0
addq %r15, 0x8(%r12)
cmpq %rbp, %r13
jb 0x4cb61
jmp 0x4cb77
xorl %r15d, %r15d
leaq 0x10(%rsp), %rsi
movq %r12, %rdi
movq %rbp, %rdx
movq %r15, %rcx
callq 0xf300
movq %rax, %r15
cmpq %rbp, %r15
jne 0x4cc22
movq 0x20(%r14), %rsi
movl (%r14), %ecx
testq %rsi, %rsi
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
je 0x4cc2c
movq (%rbx), %r12
movb 0x30(%r12), %al
movq 0x18(%r12), %r13
testl %ecx, %ecx
movq %rsi, 0x8(%rsp)
je 0x4cc5a
movslq 0x10(%r14), %r15
testb $0x2, %al
jne 0x4cbe6
movq %r13, %rax
subq 0x8(%r12), %rax
cmpq %r15, %rax
jae 0x4cbe6
addq %r15, %r13
subq (%r12), %r13
movq %r12, %rdi
movq %rsi, %rbp
movq %r13, %rsi
callq 0xee24
movq %rbp, %rsi
movq 0x18(%r12), %r13
movq %r13, 0x10(%r12)
movq 0x8(%r12), %rdi
subq %rdi, %r13
cmpq %r15, %r13
ja 0x4cbfd
cmpq (%r12), %rdi
je 0x4ccce
cmpq %r15, %r13
movq %r15, %rbp
cmovbq %r13, %rbp
movq %rbp, %rdx
callq 0x43c0
addq %rbp, 0x8(%r12)
cmpq %r15, %r13
jb 0x4ccd0
jmp 0x4cce6
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x4cdd6
testl %ecx, %ecx
jne 0x4cc3b
cmpl $0x0, 0x14(%r14)
je 0x4cd18
leaq 0x4e235(%rip), %rdi     # 0x9ae77
leaq 0x4e1f1(%rip), %rsi     # 0x9ae3a
leaq 0x4e1f9(%rip), %rcx     # 0x9ae49
movl $0x5fb, %edx            # imm = 0x5FB
callq 0x42f0
movslq 0x14(%r14), %rdx
testb $0x2, %al
movq %rdx, (%rsp)
jne 0x4cc99
movq %r13, %rax
subq 0x8(%r12), %rax
cmpq %rdx, %rax
jae 0x4cc99
addq %rdx, %r13
subq (%r12), %r13
movq %r12, %rdi
movq %rsi, %r15
movq %r13, %rsi
callq 0xee24
movq (%rsp), %rdx
movq %r15, %rsi
movq 0x18(%r12), %r13
movq %r13, 0x10(%r12)
movq 0x8(%r12), %rdi
subq %rdi, %r13
cmpq %rdx, %r13
ja 0x4ccac
cmpq (%r12), %rdi
je 0x4ccf5
cmpq %rdx, %r13
movq %rdx, %r15
cmovbq %r13, %r15
movq %r15, %rdx
callq 0x43c0
movq (%rsp), %rdx
addq %r15, 0x8(%r12)
cmpq %rdx, %r13
jb 0x4ccf8
jmp 0x4cd0f
xorl %ebp, %ebp
movq %r12, %rdi
movq 0x8(%rsp), %rsi
movq %r15, %rdx
movq %rbp, %rcx
callq 0xf300
movq %rax, %rbp
cmpq %r15, %rbp
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
je 0x4cd18
jmp 0x4cdd6
xorl %r15d, %r15d
movq %r12, %rdi
movq 0x8(%rsp), %rsi
movq %r15, %rcx
callq 0xf300
movq (%rsp), %rdx
movq %rax, %r15
cmpq %rdx, %r15
jne 0x4cdd6
cmpl $0x300, 0xc(%rbx)       # imm = 0x300
jl 0x4cdd4
movb (%r14), %al
leaq 0x82(%rsp), %rdi
movb %al, -0x2(%rdi)
movb 0x8(%r14), %al
movb %al, -0x1(%rdi)
leaq 0xe4(%rsp), %r15
movl 0xc(%r14), %edx
movq %r15, %rsi
callq *0x89c8(%rbx)
cltq
leaq (%rsp,%rax), %r12
addq $0x82, %r12
movl 0x10(%r14), %edx
movq %r12, %rdi
movq %r15, %rsi
callq *0x89c8(%rbx)
movslq %eax, %r13
addq %r12, %r13
movl 0x14(%r14), %edx
movq %r13, %rdi
movq %r15, %rsi
callq *0x89c8(%rbx)
addl %eax, %r13d
leaq 0x80(%rsp), %rsi
subl %esi, %r13d
xorl %edi, %edi
movl %r13d, %edx
callq 0x4320
xorl %ecx, %ecx
cmpl $0x0, (%r14)
sete %cl
movl %eax, %edi
movq 0x20(%r14), %rax
testq %rax, %rax
leaq 0x48fba(%rip), %rsi     # 0x95d6d
cmovneq %rax, %rsi
movl 0x10(%r14,%rcx,4), %edx
callq 0x4320
movl %eax, 0x18(%r14)
movq (%rbx), %rdi
movl %eax, %esi
callq 0x4ce09
cmpl $-0x1, %eax
je 0x4cdd6
xorl %ebp, %ebp
movl %ebp, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4e014(%rip), %rdi     # 0x9ae05
leaq 0x4e042(%rip), %rsi     # 0x9ae3a
leaq 0x4e04a(%rip), %rcx     # 0x9ae49
movl $0x5e7, %edx            # imm = 0x5E7
callq 0x42f0