// File: /workspace/github_cpp_makefile_star2_O1/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 %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 0x32ae2
movl 0x10(%r14), %ecx
cmpl 0x14(%r14), %ecx
jne 0x32e89
movq (%rbx), %rsi
movq 0x8(%rsi), %rcx
cmpq 0x18(%rsi), %rcx
jae 0x32afb
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rsi)
movb %al, (%rcx)
jmp 0x32b02
movl %eax, %edi
callq 0x48321
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0x32e77
movl 0x8(%r14), %eax
movq (%rbx), %rsi
movq 0x8(%rsi), %rcx
cmpq 0x18(%rsi), %rcx
jae 0x32b2e
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rsi)
movb %al, (%rcx)
jmp 0x32b35
movl %eax, %edi
callq 0x48321
cmpl $-0x1, %eax
je 0x32e77
movl 0xc(%r14), %esi
movq %rbx, %rdi
callq 0x30c53
cmpl $-0x1, %eax
je 0x32e77
movl 0x10(%r14), %esi
movq %rbx, %rdi
callq 0x30c53
cmpl $-0x1, %eax
je 0x32e77
movl 0x14(%r14), %esi
movq %rbx, %rdi
callq 0x30c53
cmpl $-0x1, %eax
je 0x32e77
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 0x32bdf
movslq 0x10(%r14), %r12
cmpq %r12, %rbp
movq %r12, %r13
cmovbq %rbp, %r13
movq %r13, %rdx
callq 0x4420
addq %r13, 0x8(%r15)
cmpq %r12, %rbp
jae 0x32bcf
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x48356
movq %rax, %r13
cmpq %r12, %r13
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
je 0x32c23
jmp 0x32e77
movslq 0x14(%r14), %r12
cmpq %r12, %rbp
movq %r12, %r13
cmovbq %rbp, %r13
movq %r13, %rdx
callq 0x4420
addq %r13, 0x8(%r15)
cmpq %r12, %rbp
jae 0x32c14
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x48356
movq %rax, %r13
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpq %r12, %r13
jne 0x32e77
cmpl $0x300, 0xc(%rbx)       # imm = 0x300
jl 0x32e74
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 0x32c59
movb %al, 0x12(%rsp)
movl $0x1, %eax
jmp 0x32cf0
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x32c77
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, 0x12(%rsp)
movb %al, 0x13(%rsp)
movl $0x2, %eax
jmp 0x32cf0
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x32c97
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, 0x12(%rsp)
movb %ah, 0x13(%rsp)
movb %al, 0x14(%rsp)
movl $0x3, %eax
jmp 0x32cf0
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x32cc0
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 0x32cf0
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 0x32d08
movb %al, (%rdx)
movl $0x1, %eax
jmp 0x32d8d
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x32d23
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, (%rdx)
movb %al, 0x1(%rdx)
movl $0x2, %eax
jmp 0x32d8d
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x32d3f
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, (%rdx)
movb %ah, 0x1(%rdx)
movb %al, 0x2(%rdx)
movl $0x3, %eax
jmp 0x32d8d
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x32d63
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 0x32d8d
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 0x32da5
movb %al, (%rdx)
movl $0x1, %eax
jmp 0x32e2a
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x32dc0
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, (%rdx)
movb %al, 0x1(%rdx)
movl $0x2, %eax
jmp 0x32e2a
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x32ddc
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, (%rdx)
movb %ah, 0x1(%rdx)
movb %al, 0x2(%rdx)
movl $0x3, %eax
jmp 0x32e2a
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x32e00
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 0x32e2a
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 0x43b0
xorl %ecx, %ecx
cmpl $0x0, (%r14)
sete %cl
movl %eax, %edi
movq 0x20(%r14), %rax
testq %rax, %rax
leaq 0x1fd2c(%rip), %rsi     # 0x52b7f
cmovneq %rax, %rsi
movl 0x10(%r14,%rcx,4), %edx
callq 0x43b0
movl %eax, 0x18(%r14)
movq %rbx, %rdi
movl %eax, %esi
callq 0x322ae
cmpl $-0x1, %eax
je 0x32e77
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x21ab1(%rip), %rdi     # 0x54941
leaq 0x21adf(%rip), %rsi     # 0x54976
leaq 0x21ae7(%rip), %rcx     # 0x54985
movl $0x401, %edx            # imm = 0x401
callq 0x4350