// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x7ed2c
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x18(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jne 0x7ed2e
jmp 0x7ed4d
leaq 0x63f1c(%rip), %rdi     # 0xe2c51
leaq 0x63f4a(%rip), %rsi     # 0xe2c86
movl $0x400, %edx            # imm = 0x400
leaq 0x63f4d(%rip), %rcx     # 0xe2c95
callq 0x6450
movq -0x18(%rbp), %rax
movl (%rax), %edi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x7f6f0
cmpl $-0x1, %eax
jne 0x7ed70
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7f6de
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x7f6f0
cmpl $-0x1, %eax
jne 0x7ed94
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7f6de
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0xc(%rax), %esi
callq 0x7bb20
cmpl $-0x1, %eax
jne 0x7edb5
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7f6de
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x10(%rax), %esi
callq 0x7bb20
cmpl $-0x1, %eax
jne 0x7edd6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7f6de
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x14(%rax), %esi
callq 0x7bb20
cmpl $-0x1, %eax
jne 0x7edf7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7f6de
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x7ee48
movq -0x18(%rbp), %rax
movslq 0x14(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x18(%rbp), %rax
movslq 0x14(%rax), %rdx
callq 0x7bcb0
movq %rax, %rcx
movq -0x98(%rbp), %rax
cmpq %rcx, %rax
je 0x7ee46
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7f6de
jmp 0x7ee90
movq -0x18(%rbp), %rax
movslq 0x10(%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x18(%rbp), %rax
movslq 0x10(%rax), %rdx
callq 0x7bcb0
movq %rax, %rcx
movq -0xa0(%rbp), %rax
cmpq %rcx, %rax
je 0x7ee8e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7f6de
jmp 0x7ee90
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
cmpl $0x3, %eax
jl 0x7f6d7
leaq -0x80(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x88(%rbp)
movb %cl, (%rax)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x88(%rbp)
movb %cl, (%rax)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
andl $-0x80, %eax
cmpl $0x0, %eax
jne 0x7ef1e
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, (%rax)
movl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x7f11d
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
andl $0xffffc000, %eax       # imm = 0xFFFFC000
cmpl $0x0, %eax
jne 0x7ef71
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
orl $0x80, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, (%rax)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x1(%rax)
movl $0x2, %eax
movl %eax, -0xa8(%rbp)
jmp 0x7f111
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
andl $0xffe00000, %eax       # imm = 0xFFE00000
cmpl $0x0, %eax
jne 0x7efdf
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x10, %eax
orl $0xc0, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, (%rax)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x2(%rax)
movl $0x3, %eax
movl %eax, -0xac(%rbp)
jmp 0x7f105
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
andl $0xf0000000, %eax       # imm = 0xF0000000
cmpl $0x0, %eax
jne 0x7f068
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x18, %eax
orl $0xe0, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, (%rax)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x10, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x2(%rax)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x3(%rax)
movl $0x4, %eax
movl %eax, -0xb0(%rbp)
jmp 0x7f0f9
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x1c, %eax
andl $0xff, %eax
orl $0xf0, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, (%rax)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x14, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0xc, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x2(%rax)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x4, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x3(%rax)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
andl $0xf, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x4(%rax)
movl $0x5, %eax
movl %eax, -0xb0(%rbp)
movl -0xb0(%rbp), %eax
movl %eax, -0xac(%rbp)
movl -0xac(%rbp), %eax
movl %eax, -0xa8(%rbp)
movl -0xa8(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl -0xa4(%rbp), %ecx
movq -0x88(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
andl $-0x80, %eax
cmpl $0x0, %eax
jne 0x7f168
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, (%rax)
movl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x7f367
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
andl $0xffffc000, %eax       # imm = 0xFFFFC000
cmpl $0x0, %eax
jne 0x7f1bb
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
sarl $0x8, %eax
orl $0x80, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, (%rax)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x1(%rax)
movl $0x2, %eax
movl %eax, -0xb8(%rbp)
jmp 0x7f35b
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
andl $0xffe00000, %eax       # imm = 0xFFE00000
cmpl $0x0, %eax
jne 0x7f229
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
sarl $0x10, %eax
orl $0xc0, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, (%rax)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x2(%rax)
movl $0x3, %eax
movl %eax, -0xbc(%rbp)
jmp 0x7f34f
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
andl $0xf0000000, %eax       # imm = 0xF0000000
cmpl $0x0, %eax
jne 0x7f2b2
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
sarl $0x18, %eax
orl $0xe0, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, (%rax)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
sarl $0x10, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x2(%rax)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x3(%rax)
movl $0x4, %eax
movl %eax, -0xc0(%rbp)
jmp 0x7f343
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
sarl $0x1c, %eax
andl $0xff, %eax
orl $0xf0, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, (%rax)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
sarl $0x14, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
sarl $0xc, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x2(%rax)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
sarl $0x4, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x3(%rax)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
andl $0xf, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x4(%rax)
movl $0x5, %eax
movl %eax, -0xc0(%rbp)
movl -0xc0(%rbp), %eax
movl %eax, -0xbc(%rbp)
movl -0xbc(%rbp), %eax
movl %eax, -0xb8(%rbp)
movl -0xb8(%rbp), %eax
movl %eax, -0xb4(%rbp)
movl -0xb4(%rbp), %ecx
movq -0x88(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
andl $-0x80, %eax
cmpl $0x0, %eax
jne 0x7f3b2
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, (%rax)
movl $0x1, %eax
movl %eax, -0xc4(%rbp)
jmp 0x7f5b1
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
andl $0xffffc000, %eax       # imm = 0xFFFFC000
cmpl $0x0, %eax
jne 0x7f405
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
sarl $0x8, %eax
orl $0x80, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, (%rax)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x1(%rax)
movl $0x2, %eax
movl %eax, -0xc8(%rbp)
jmp 0x7f5a5
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
andl $0xffe00000, %eax       # imm = 0xFFE00000
cmpl $0x0, %eax
jne 0x7f473
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
sarl $0x10, %eax
orl $0xc0, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, (%rax)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x2(%rax)
movl $0x3, %eax
movl %eax, -0xcc(%rbp)
jmp 0x7f599
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
andl $0xf0000000, %eax       # imm = 0xF0000000
cmpl $0x0, %eax
jne 0x7f4fc
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
sarl $0x18, %eax
orl $0xe0, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, (%rax)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
sarl $0x10, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x2(%rax)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x3(%rax)
movl $0x4, %eax
movl %eax, -0xd0(%rbp)
jmp 0x7f58d
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
sarl $0x1c, %eax
andl $0xff, %eax
orl $0xf0, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, (%rax)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
sarl $0x14, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
sarl $0xc, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x2(%rax)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
sarl $0x4, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x3(%rax)
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
andl $0xf, %eax
movb %al, %cl
movq -0x88(%rbp), %rax
movb %cl, 0x4(%rax)
movl $0x5, %eax
movl %eax, -0xd0(%rbp)
movl -0xd0(%rbp), %eax
movl %eax, -0xcc(%rbp)
movl -0xcc(%rbp), %eax
movl %eax, -0xc8(%rbp)
movl -0xc8(%rbp), %eax
movl %eax, -0xc4(%rbp)
movl -0xc4(%rbp), %ecx
movq -0x88(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
leaq -0x80(%rbp), %rsi
movq -0x88(%rbp), %rax
leaq -0x80(%rbp), %rcx
subq %rcx, %rax
movl %eax, %edx
xorl %eax, %eax
movl %eax, %edi
callq 0x64a0
movl %eax, -0x8c(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x7f655
movl -0x8c(%rbp), %eax
movq %rax, -0xd8(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x7f620
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xe0(%rbp)
jmp 0x7f630
leaq 0x65ddf(%rip), %rax     # 0xe5406
movq %rax, -0xe0(%rbp)
jmp 0x7f630
movq -0xd8(%rbp), %rdi
movq -0xe0(%rbp), %rsi
movq -0x18(%rbp), %rax
movl 0x14(%rax), %edx
callq 0x64a0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x18(%rax)
jmp 0x7f6b1
movl -0x8c(%rbp), %eax
movq %rax, -0xe8(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x7f67e
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xf0(%rbp)
jmp 0x7f68e
leaq 0x65d81(%rip), %rax     # 0xe5406
movq %rax, -0xf0(%rbp)
jmp 0x7f68e
movq -0xe8(%rbp), %rdi
movq -0xf0(%rbp), %rsi
movq -0x18(%rbp), %rax
movl 0x10(%rax), %edx
callq 0x64a0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x18(%rax), %esi
callq 0x7dc70
movl %eax, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %ecx, %eax
jne 0x7f6d5
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x7f6de
jmp 0x7f6d7
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xf0, %rsp
popq %rbp
retq
nopw (%rax,%rax)