// File: /workspace/github_c_makefile_star2_O2/icebert[P]pblat/htslib/cram/cram_io.c
// Function: cram_write_block
int cram_write_block(cram_fd *fd, cram_block *b) {
    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;
    if (itf8_encode(fd, b->content_id)  ==  -1) return -1;
    if (itf8_encode(fd, b->comp_size)   ==  -1) return -1;
    if (itf8_encode(fd, b->uncomp_size) ==  -1) return -1;

    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;
    }

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

	*cp++ = b->method;
	*cp++ = b->content_type;
	cp += itf8_put(cp, b->content_id);
	cp += itf8_put(cp, b->comp_size);
	cp += itf8_put(cp, b->uncomp_size);
	crc = crc32(0L, 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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r15
movq %rdi, %r14
movl (%rsi), %edi
testl %edi, %edi
jne 0x4de7a
movl 0x10(%r15), %eax
cmpl 0x14(%r15), %eax
jne 0x4e154
movq (%r14), %rsi
callq 0x4e173
pushq $-0x1
popq %rbx
cmpl $-0x1, %eax
je 0x4e146
movl 0x8(%r15), %edi
movq (%r14), %rsi
callq 0x4e173
cmpl $-0x1, %eax
je 0x4e146
movl 0xc(%r15), %esi
movq %r14, %rdi
callq 0x4c8c2
cmpl $-0x1, %eax
je 0x4e146
movl 0x10(%r15), %esi
movq %r14, %rdi
callq 0x4c8c2
cmpl $-0x1, %eax
je 0x4e146
movl 0x14(%r15), %esi
movq %r14, %rdi
callq 0x4c8c2
cmpl $-0x1, %eax
je 0x4e146
cmpl $0x0, (%r15)
movq (%r14), %rdi
movq 0x20(%r15), %rsi
je 0x4def5
movslq 0x10(%r15), %r12
jmp 0x4def9
movslq 0x14(%r15), %r12
movq %r12, %rdx
callq 0x4c987
cmpq %r12, %rax
jne 0x4e146
cmpl $0x300, 0xc(%r14)       # imm = 0x300
jl 0x4e144
movb (%r15), %al
leaq 0x2(%rsp), %rdx
movb %al, -0x2(%rdx)
movb 0x8(%r15), %al
movb %al, -0x1(%rdx)
movl 0xc(%r15), %eax
cmpl $0x7f, %eax
ja 0x4df3f
movb %al, 0x2(%rsp)
pushq $0x1
popq %rcx
jmp 0x4dfe3
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x4df60
pushq $0x2
popq %rcx
movl %eax, %esi
shrl $0x8, %esi
orb $-0x80, %sil
movb %sil, 0x2(%rsp)
movb %al, 0x3(%rsp)
jmp 0x4dfe3
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x4df82
pushq $0x3
popq %rcx
movl %eax, %esi
shrl $0x10, %esi
orb $-0x40, %sil
movb %sil, 0x2(%rsp)
movb %ah, 0x3(%rsp)
movb %al, 0x4(%rsp)
jmp 0x4dfe3
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x4dfae
pushq $0x4
popq %rcx
movl %eax, %esi
shrl $0x18, %esi
orb $-0x20, %sil
movb %sil, 0x2(%rsp)
movl %eax, %esi
shrl $0x10, %esi
movb %sil, 0x3(%rsp)
movb %ah, 0x4(%rsp)
movb %al, 0x5(%rsp)
jmp 0x4dfe3
pushq $0x5
popq %rcx
movl %eax, %esi
shrl $0x1c, %esi
orb $-0x10, %sil
movb %sil, 0x2(%rsp)
movl %eax, %esi
shrl $0x14, %esi
movb %sil, 0x3(%rsp)
movl %eax, %esi
shrl $0xc, %esi
movb %sil, 0x4(%rsp)
movl %eax, %esi
shrl $0x4, %esi
movb %sil, 0x5(%rsp)
andb $0xf, %al
movb %al, 0x6(%rsp)
addq %rcx, %rdx
movl 0x10(%r15), %eax
cmpl $0x7f, %eax
ja 0x4dff5
movb %al, (%rdx)
pushq $0x1
jmp 0x4e06e
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x4e00d
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, (%rdx)
movb %al, 0x1(%rdx)
pushq $0x2
jmp 0x4e06e
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x4e026
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, (%rdx)
movb %ah, 0x1(%rdx)
movb %al, 0x2(%rdx)
pushq $0x3
jmp 0x4e06e
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x4e047
shrl $0x18, %ecx
orb $-0x20, %cl
movb %cl, (%rdx)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0x1(%rdx)
movb %ah, 0x2(%rdx)
movb %al, 0x3(%rdx)
pushq $0x4
jmp 0x4e06e
shrl $0x1c, %ecx
orb $-0x10, %cl
movb %cl, (%rdx)
movl %eax, %ecx
shrl $0x14, %ecx
movb %cl, 0x1(%rdx)
movl %eax, %ecx
shrl $0xc, %ecx
movb %cl, 0x2(%rdx)
movl %eax, %ecx
shrl $0x4, %ecx
movb %cl, 0x3(%rdx)
andb $0xf, %al
movb %al, 0x4(%rdx)
pushq $0x5
popq %rax
addq %rax, %rdx
movl 0x14(%r15), %eax
cmpl $0x7f, %eax
ja 0x4e082
pushq $0x1
popq %rcx
movb %al, (%rdx)
jmp 0x4e0fc
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x4e09a
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, (%rdx)
movb %al, 0x1(%rdx)
pushq $0x2
jmp 0x4e0fb
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x4e0b3
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, (%rdx)
movb %ah, 0x1(%rdx)
movb %al, 0x2(%rdx)
pushq $0x3
jmp 0x4e0fb
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x4e0d4
shrl $0x18, %ecx
orb $-0x20, %cl
movb %cl, (%rdx)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0x1(%rdx)
movb %ah, 0x2(%rdx)
movb %al, 0x3(%rdx)
pushq $0x4
jmp 0x4e0fb
shrl $0x1c, %ecx
orb $-0x10, %cl
movb %cl, (%rdx)
movl %eax, %ecx
shrl $0x14, %ecx
movb %cl, 0x1(%rdx)
movl %eax, %ecx
shrl $0xc, %ecx
movb %cl, 0x2(%rdx)
movl %eax, %ecx
shrl $0x4, %ecx
movb %cl, 0x3(%rdx)
andb $0xf, %al
movb %al, 0x4(%rdx)
pushq $0x5
popq %rcx
addl %ecx, %edx
movq %rsp, %rsi
subl %esi, %edx
xorl %edi, %edi
callq 0x64b0
xorl %ecx, %ecx
cmpl $0x0, (%r15)
sete %cl
movl %eax, %edi
movq 0x20(%r15), %rax
testq %rax, %rax
leaq 0x3925a(%rip), %rsi     # 0x8737d
cmovneq %rax, %rsi
movl 0x10(%r15,%rcx,4), %edx
callq 0x64b0
movl %eax, 0x18(%r15)
movq %r14, %rdi
movl %eax, %esi
callq 0x4d8c7
cmpl $-0x1, %eax
je 0x4e146
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x39af6(%rip), %rdi     # 0x87c51
leaq 0x39b24(%rip), %rsi     # 0x87c86
leaq 0x39b2c(%rip), %rcx     # 0x87c95
movl $0x400, %edx            # imm = 0x400
callq 0x6460