// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/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 0x27e12
movl 0x10(%r15), %eax
cmpl 0x14(%r15), %eax
jne 0x280ec
movq (%r14), %rsi
callq 0x2810b
pushq $-0x1
popq %rbx
cmpl $-0x1, %eax
je 0x280de
movl 0x8(%r15), %edi
movq (%r14), %rsi
callq 0x2810b
cmpl $-0x1, %eax
je 0x280de
movl 0xc(%r15), %esi
movq %r14, %rdi
callq 0x2685a
cmpl $-0x1, %eax
je 0x280de
movl 0x10(%r15), %esi
movq %r14, %rdi
callq 0x2685a
cmpl $-0x1, %eax
je 0x280de
movl 0x14(%r15), %esi
movq %r14, %rdi
callq 0x2685a
cmpl $-0x1, %eax
je 0x280de
cmpl $0x0, (%r15)
movq (%r14), %rdi
movq 0x20(%r15), %rsi
je 0x27e8d
movslq 0x10(%r15), %r12
jmp 0x27e91
movslq 0x14(%r15), %r12
movq %r12, %rdx
callq 0x2691f
cmpq %r12, %rax
jne 0x280de
cmpl $0x300, 0xc(%r14)       # imm = 0x300
jl 0x280dc
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 0x27ed7
movb %al, 0x2(%rsp)
pushq $0x1
popq %rcx
jmp 0x27f7b
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x27ef8
pushq $0x2
popq %rcx
movl %eax, %esi
shrl $0x8, %esi
orb $-0x80, %sil
movb %sil, 0x2(%rsp)
movb %al, 0x3(%rsp)
jmp 0x27f7b
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x27f1a
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 0x27f7b
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x27f46
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 0x27f7b
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 0x27f8d
movb %al, (%rdx)
pushq $0x1
jmp 0x28006
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x27fa5
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, (%rdx)
movb %al, 0x1(%rdx)
pushq $0x2
jmp 0x28006
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x27fbe
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, (%rdx)
movb %ah, 0x1(%rdx)
movb %al, 0x2(%rdx)
pushq $0x3
jmp 0x28006
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x27fdf
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 0x28006
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 0x2801a
pushq $0x1
popq %rcx
movb %al, (%rdx)
jmp 0x28094
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x28032
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, (%rdx)
movb %al, 0x1(%rdx)
pushq $0x2
jmp 0x28093
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x2804b
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, (%rdx)
movb %ah, 0x1(%rdx)
movb %al, 0x2(%rdx)
pushq $0x3
jmp 0x28093
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x2806c
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 0x28093
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 0x43b0
xorl %ecx, %ecx
cmpl $0x0, (%r15)
sete %cl
movl %eax, %edi
movq 0x20(%r15), %rax
testq %rax, %rax
leaq 0x1bb31(%rip), %rsi     # 0x43bec
cmovneq %rax, %rsi
movl 0x10(%r15,%rcx,4), %edx
callq 0x43b0
movl %eax, 0x18(%r15)
movq %r14, %rdi
movl %eax, %esi
callq 0x2785f
cmpl $-0x1, %eax
je 0x280de
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x1d876(%rip), %rdi     # 0x45969
leaq 0x1d8a4(%rip), %rsi     # 0x4599e
leaq 0x1d8ac(%rip), %rcx     # 0x459ad
movl $0x401, %edx            # imm = 0x401
callq 0x4360