// File: /workspace/github_c_makefile_star2_O3/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl (%rsi), %eax
testl %eax, %eax
jne 0x5668a
movl 0x10(%r14), %ecx
cmpl 0x14(%r14), %ecx
jne 0x56a31
movq (%rbx), %rsi
movq 0x8(%rsi), %rcx
cmpq 0x18(%rsi), %rcx
jae 0x566a3
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rsi)
movb %al, (%rcx)
jmp 0x566aa
movl %eax, %edi
callq 0x6b20c
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0x56a1f
movl 0x8(%r14), %eax
movq (%rbx), %rsi
movq 0x8(%rsi), %rcx
cmpq 0x18(%rsi), %rcx
jae 0x566d6
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rsi)
movb %al, (%rcx)
jmp 0x566dd
movl %eax, %edi
callq 0x6b20c
cmpl $-0x1, %eax
je 0x56a1f
movl 0xc(%r14), %esi
movq %rbx, %rdi
callq 0x548cf
cmpl $-0x1, %eax
je 0x56a1f
movl 0x10(%r14), %esi
movq %rbx, %rdi
callq 0x548cf
cmpl $-0x1, %eax
je 0x56a1f
movl 0x14(%r14), %esi
movq %rbx, %rdi
callq 0x548cf
cmpl $-0x1, %eax
je 0x56a1f
movq (%rbx), %r15
movq 0x8(%r15), %rdi
movq 0x18(%r15), %rbp
subq %rdi, %rbp
cmpl $0x0, (%r14)
movq 0x20(%r14), %rsi
movq %rsi, 0x8(%rsp)
je 0x56787
movslq 0x10(%r14), %r12
cmpq %r12, %rbp
movq %r12, %r13
cmovbq %rbp, %r13
movq %r13, %rdx
callq 0x6570
addq %r13, 0x8(%r15)
cmpq %r12, %rbp
jae 0x56777
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x6b241
movq %rax, %r13
cmpq %r12, %r13
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
je 0x567cb
jmp 0x56a1f
movslq 0x14(%r14), %r12
cmpq %r12, %rbp
movq %r12, %r13
cmovbq %rbp, %r13
movq %r13, %rdx
callq 0x6570
addq %r13, 0x8(%r15)
cmpq %r12, %rbp
jae 0x567bc
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x6b241
movq %rax, %r13
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpq %r12, %r13
jne 0x56a1f
cmpl $0x300, 0xc(%rbx)       # imm = 0x300
jl 0x56a1c
movb (%r14), %al
leaq 0x12(%rsp), %rdx
movb %al, -0x2(%rdx)
movb 0x8(%r14), %al
movb %al, -0x1(%rdx)
movl 0xc(%r14), %eax
cmpl $0x7f, %eax
ja 0x56801
movb %al, 0x12(%rsp)
movl $0x1, %eax
jmp 0x56898
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x5681f
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, 0x12(%rsp)
movb %al, 0x13(%rsp)
movl $0x2, %eax
jmp 0x56898
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x5683f
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, 0x12(%rsp)
movb %ah, 0x13(%rsp)
movb %al, 0x14(%rsp)
movl $0x3, %eax
jmp 0x56898
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x56868
shrl $0x18, %ecx
orb $-0x20, %cl
movb %cl, 0x12(%rsp)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0x13(%rsp)
movb %ah, 0x14(%rsp)
movb %al, 0x15(%rsp)
movl $0x4, %eax
jmp 0x56898
shrl $0x1c, %ecx
orb $-0x10, %cl
movb %cl, 0x12(%rsp)
movl %eax, %ecx
shrl $0x14, %ecx
movb %cl, 0x13(%rsp)
movl %eax, %ecx
shrl $0xc, %ecx
movb %cl, 0x14(%rsp)
movl %eax, %ecx
shrl $0x4, %ecx
movb %cl, 0x15(%rsp)
andb $0xf, %al
movb %al, 0x16(%rsp)
movl $0x5, %eax
addq %rax, %rdx
movl 0x10(%r14), %eax
cmpl $0x7f, %eax
ja 0x568b0
movb %al, (%rdx)
movl $0x1, %eax
jmp 0x56935
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x568cb
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, (%rdx)
movb %al, 0x1(%rdx)
movl $0x2, %eax
jmp 0x56935
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x568e7
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, (%rdx)
movb %ah, 0x1(%rdx)
movb %al, 0x2(%rdx)
movl $0x3, %eax
jmp 0x56935
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x5690b
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)
movl $0x4, %eax
jmp 0x56935
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)
movl $0x5, %eax
addq %rax, %rdx
movl 0x14(%r14), %eax
cmpl $0x7f, %eax
ja 0x5694d
movb %al, (%rdx)
movl $0x1, %eax
jmp 0x569d2
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x56968
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, (%rdx)
movb %al, 0x1(%rdx)
movl $0x2, %eax
jmp 0x569d2
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x56984
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, (%rdx)
movb %ah, 0x1(%rdx)
movb %al, 0x2(%rdx)
movl $0x3, %eax
jmp 0x569d2
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x569a8
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)
movl $0x4, %eax
jmp 0x569d2
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)
movl $0x5, %eax
addl %eax, %edx
leaq 0x10(%rsp), %rsi
subl %esi, %edx
xorl %edi, %edi
callq 0x64b0
xorl %ecx, %ecx
cmpl $0x0, (%r14)
sete %cl
movl %eax, %edi
movq 0x20(%r14), %rax
testq %rax, %rax
leaq 0x41a59(%rip), %rsi     # 0x98454
cmovneq %rax, %rsi
movl 0x10(%r14,%rcx,4), %edx
callq 0x64b0
movl %eax, 0x18(%r14)
movq %rbx, %rdi
movl %eax, %esi
callq 0x55ff9
cmpl $-0x1, %eax
je 0x56a1f
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x42469(%rip), %rdi     # 0x98ea1
leaq 0x42497(%rip), %rsi     # 0x98ed6
leaq 0x4249f(%rip), %rcx     # 0x98ee5
movl $0x400, %edx            # imm = 0x400
callq 0x6460