// File: /workspace/github_c_makefile_star2_O1/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 0x563fa
movl 0x10(%r14), %ecx
cmpl 0x14(%r14), %ecx
jne 0x567a1
movq (%rbx), %rsi
movq 0x8(%rsi), %rcx
cmpq 0x18(%rsi), %rcx
jae 0x56413
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rsi)
movb %al, (%rcx)
jmp 0x5641a
movl %eax, %edi
callq 0x6b1ed
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0x5678f
movl 0x8(%r14), %eax
movq (%rbx), %rsi
movq 0x8(%rsi), %rcx
cmpq 0x18(%rsi), %rcx
jae 0x56446
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rsi)
movb %al, (%rcx)
jmp 0x5644d
movl %eax, %edi
callq 0x6b1ed
cmpl $-0x1, %eax
je 0x5678f
movl 0xc(%r14), %esi
movq %rbx, %rdi
callq 0x5456b
cmpl $-0x1, %eax
je 0x5678f
movl 0x10(%r14), %esi
movq %rbx, %rdi
callq 0x5456b
cmpl $-0x1, %eax
je 0x5678f
movl 0x14(%r14), %esi
movq %rbx, %rdi
callq 0x5456b
cmpl $-0x1, %eax
je 0x5678f
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 0x564f7
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 0x564e7
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x6b222
movq %rax, %r13
cmpq %r12, %r13
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
je 0x5653b
jmp 0x5678f
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 0x5652c
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x6b222
movq %rax, %r13
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpq %r12, %r13
jne 0x5678f
cmpl $0x300, 0xc(%rbx)       # imm = 0x300
jl 0x5678c
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 0x56571
movb %al, 0x12(%rsp)
movl $0x1, %eax
jmp 0x56608
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x5658f
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, 0x12(%rsp)
movb %al, 0x13(%rsp)
movl $0x2, %eax
jmp 0x56608
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x565af
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, 0x12(%rsp)
movb %ah, 0x13(%rsp)
movb %al, 0x14(%rsp)
movl $0x3, %eax
jmp 0x56608
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x565d8
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 0x56608
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 0x56620
movb %al, (%rdx)
movl $0x1, %eax
jmp 0x566a5
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x5663b
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, (%rdx)
movb %al, 0x1(%rdx)
movl $0x2, %eax
jmp 0x566a5
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x56657
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, (%rdx)
movb %ah, 0x1(%rdx)
movb %al, 0x2(%rdx)
movl $0x3, %eax
jmp 0x566a5
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x5667b
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 0x566a5
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 0x566bd
movb %al, (%rdx)
movl $0x1, %eax
jmp 0x56742
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x566d8
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, (%rdx)
movb %al, 0x1(%rdx)
movl $0x2, %eax
jmp 0x56742
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x566f4
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, (%rdx)
movb %ah, 0x1(%rdx)
movb %al, 0x2(%rdx)
movl $0x3, %eax
jmp 0x56742
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x56718
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 0x56742
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 0x41bf5(%rip), %rsi     # 0x98360
cmovneq %rax, %rsi
movl 0x10(%r14,%rcx,4), %edx
callq 0x64b0
movl %eax, 0x18(%r14)
movq %rbx, %rdi
movl %eax, %esi
callq 0x55bc6
cmpl $-0x1, %eax
je 0x5678f
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x424f1(%rip), %rdi     # 0x98c99
leaq 0x4251f(%rip), %rsi     # 0x98cce
leaq 0x42527(%rip), %rcx     # 0x98cdd
movl $0x400, %edx            # imm = 0x400
callq 0x6460