// File: /workspace/github_cpp_makefile_star2_O3/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 0x31dee
movl 0x10(%r14), %ecx
cmpl 0x14(%r14), %ecx
jne 0x32195
movq (%rbx), %rsi
movq 0x8(%rsi), %rcx
cmpq 0x18(%rsi), %rcx
jae 0x31e07
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rsi)
movb %al, (%rcx)
jmp 0x31e0e
movl %eax, %edi
callq 0x472d4
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0x32183
movl 0x8(%r14), %eax
movq (%rbx), %rsi
movq 0x8(%rsi), %rcx
cmpq 0x18(%rsi), %rcx
jae 0x31e3a
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rsi)
movb %al, (%rcx)
jmp 0x31e41
movl %eax, %edi
callq 0x472d4
cmpl $-0x1, %eax
je 0x32183
movl 0xc(%r14), %esi
movq %rbx, %rdi
callq 0x30033
cmpl $-0x1, %eax
je 0x32183
movl 0x10(%r14), %esi
movq %rbx, %rdi
callq 0x30033
cmpl $-0x1, %eax
je 0x32183
movl 0x14(%r14), %esi
movq %rbx, %rdi
callq 0x30033
cmpl $-0x1, %eax
je 0x32183
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 0x31eeb
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 0x31edb
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x47309
movq %rax, %r13
cmpq %r12, %r13
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
je 0x31f2f
jmp 0x32183
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 0x31f20
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rdx
movq %r13, %rcx
callq 0x47309
movq %rax, %r13
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpq %r12, %r13
jne 0x32183
cmpl $0x300, 0xc(%rbx)       # imm = 0x300
jl 0x32180
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 0x31f65
movb %al, 0x12(%rsp)
movl $0x1, %eax
jmp 0x31ffc
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x31f83
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, 0x12(%rsp)
movb %al, 0x13(%rsp)
movl $0x2, %eax
jmp 0x31ffc
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x31fa3
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, 0x12(%rsp)
movb %ah, 0x13(%rsp)
movb %al, 0x14(%rsp)
movl $0x3, %eax
jmp 0x31ffc
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x31fcc
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 0x31ffc
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 0x32014
movb %al, (%rdx)
movl $0x1, %eax
jmp 0x32099
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x3202f
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, (%rdx)
movb %al, 0x1(%rdx)
movl $0x2, %eax
jmp 0x32099
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x3204b
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, (%rdx)
movb %ah, 0x1(%rdx)
movb %al, 0x2(%rdx)
movl $0x3, %eax
jmp 0x32099
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x3206f
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 0x32099
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 0x320b1
movb %al, (%rdx)
movl $0x1, %eax
jmp 0x32136
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x320cc
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, (%rdx)
movb %al, 0x1(%rdx)
movl $0x2, %eax
jmp 0x32136
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x320e8
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, (%rdx)
movb %ah, 0x1(%rdx)
movb %al, 0x2(%rdx)
movl $0x3, %eax
jmp 0x32136
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x3210c
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 0x32136
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 0x1ea54(%rip), %rsi     # 0x50bb3
cmovneq %rax, %rsi
movl 0x10(%r14,%rcx,4), %edx
callq 0x43b0
movl %eax, 0x18(%r14)
movq %rbx, %rdi
movl %eax, %esi
callq 0x3175d
cmpl $-0x1, %eax
je 0x32183
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x20a4d(%rip), %rdi     # 0x52be9
leaq 0x20a7b(%rip), %rsi     # 0x52c1e
leaq 0x20a83(%rip), %rcx     # 0x52c2d
movl $0x401, %edx            # imm = 0x401
callq 0x4350