// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x84(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x6f436
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jne 0x6f438
jmp 0x6f457
leaq 0x8619e(%rip), %rdi     # 0xf55dd
leaq 0x861cc(%rip), %rsi     # 0xf5612
movl $0x5e7, %edx            # imm = 0x5E7
leaq 0x861cf(%rip), %rcx     # 0xf5621
callq 0x42e0
movq -0x18(%rbp), %rax
movl (%rax), %edi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x6f890
cmpl $-0x1, %eax
jne 0x6f47a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6f883
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x6f890
cmpl $-0x1, %eax
jne 0x6f49e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6f883
movq -0x10(%rbp), %rax
movq 0x89c8(%rax), %rax
leaq -0x80(%rbp), %rdi
leaq -0x80(%rbp), %rsi
addq $0x64, %rsi
movq -0x18(%rbp), %rcx
movl 0xc(%rcx), %edx
callq *%rax
addl -0x84(%rbp), %eax
movl %eax, -0x84(%rbp)
movq -0x10(%rbp), %rax
movq 0x89c8(%rax), %rax
leaq -0x80(%rbp), %rdi
movslq -0x84(%rbp), %rcx
addq %rcx, %rdi
leaq -0x80(%rbp), %rsi
addq $0x64, %rsi
movq -0x18(%rbp), %rcx
movl 0x10(%rcx), %edx
callq *%rax
addl -0x84(%rbp), %eax
movl %eax, -0x84(%rbp)
movq -0x10(%rbp), %rax
movq 0x89c8(%rax), %rax
leaq -0x80(%rbp), %rdi
movslq -0x84(%rbp), %rcx
addq %rcx, %rdi
leaq -0x80(%rbp), %rsi
addq $0x64, %rsi
movq -0x18(%rbp), %rcx
movl 0x14(%rcx), %edx
callq *%rax
addl -0x84(%rbp), %eax
movl %eax, -0x84(%rbp)
movslq -0x84(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq -0x80(%rbp), %rsi
movslq -0x84(%rbp), %rdx
callq 0x6d1e0
movq %rax, %rcx
movq -0x108(%rbp), %rax
cmpq %rcx, %rax
je 0x6f576
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6f883
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x6f620
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x6f5d6
movq -0x18(%rbp), %rax
movslq 0x14(%rax), %rax
movq %rax, -0x110(%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 0x6d1e0
movq %rax, %rcx
movq -0x110(%rbp), %rax
cmpq %rcx, %rax
je 0x6f5d4
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6f883
jmp 0x6f61e
movq -0x18(%rbp), %rax
movslq 0x10(%rax), %rax
movq %rax, -0x118(%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 0x6d1e0
movq %rax, %rcx
movq -0x118(%rbp), %rax
cmpq %rcx, %rax
je 0x6f61c
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6f883
jmp 0x6f61e
jmp 0x6f656
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x6f635
movq -0x18(%rbp), %rax
cmpl $0x0, 0x14(%rax)
jne 0x6f635
jmp 0x6f654
leaq 0x86013(%rip), %rdi     # 0xf564f
leaq 0x85fcf(%rip), %rsi     # 0xf5612
movl $0x5fb, %edx            # imm = 0x5FB
leaq 0x85fd2(%rip), %rcx     # 0xf5621
callq 0x42e0
jmp 0x6f656
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
cmpl $0x3, %eax
jl 0x6f87c
leaq -0xf0(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movb %al, %cl
movq -0xf8(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0xf8(%rbp)
movb %cl, (%rax)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
movb %al, %cl
movq -0xf8(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0xf8(%rbp)
movb %cl, (%rax)
movq -0x10(%rbp), %rax
movq 0x89c8(%rax), %rax
movq -0xf8(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
addq $0x64, %rsi
movq -0x18(%rbp), %rcx
movl 0xc(%rcx), %edx
callq *%rax
movl %eax, %ecx
movq -0xf8(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0xf8(%rbp)
movq -0x10(%rbp), %rax
movq 0x89c8(%rax), %rax
movq -0xf8(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
addq $0x64, %rsi
movq -0x18(%rbp), %rcx
movl 0x10(%rcx), %edx
callq *%rax
movl %eax, %ecx
movq -0xf8(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0xf8(%rbp)
movq -0x10(%rbp), %rax
movq 0x89c8(%rax), %rax
movq -0xf8(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
addq $0x64, %rsi
movq -0x18(%rbp), %rcx
movl 0x14(%rcx), %edx
callq *%rax
movl %eax, %ecx
movq -0xf8(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0xf8(%rbp)
leaq -0xf0(%rbp), %rsi
movq -0xf8(%rbp), %rax
leaq -0xf0(%rbp), %rcx
subq %rcx, %rax
movl %eax, %edx
xorl %eax, %eax
movl %eax, %edi
callq 0x4310
movl %eax, -0xfc(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x6f7fa
movl -0xfc(%rbp), %eax
movq %rax, -0x120(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x6f7c5
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x128(%rbp)
jmp 0x6f7d5
leaq 0x807a9(%rip), %rax     # 0xeff75
movq %rax, -0x128(%rbp)
jmp 0x6f7d5
movq -0x120(%rbp), %rdi
movq -0x128(%rbp), %rsi
movq -0x18(%rbp), %rax
movl 0x14(%rax), %edx
callq 0x4310
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x18(%rax)
jmp 0x6f856
movl -0xfc(%rbp), %eax
movq %rax, -0x130(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x6f823
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x138(%rbp)
jmp 0x6f833
leaq 0x8074b(%rip), %rax     # 0xeff75
movq %rax, -0x138(%rbp)
jmp 0x6f833
movq -0x130(%rbp), %rdi
movq -0x138(%rbp), %rsi
movq -0x18(%rbp), %rax
movl 0x10(%rax), %edx
callq 0x4310
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x18(%rax), %esi
callq 0x6f8f0
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x6f87a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6f883
jmp 0x6f87c
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
nop