// File: /workspace/github_c_makefile_star2_O3/icebert[P]pblat/htslib/cram/cram_io.c
// Function: cram_store_container
int cram_store_container(cram_fd *fd, cram_container *c, char *dat, int *size)
{
    char *cp = dat;
    int i;

    // Check the input buffer is large enough according to our stated
    // requirements. (NOTE: it may actually take less.)
    if (cram_container_size(c) > *size)
        return -1;

    if (CRAM_MAJOR_VERS(fd->version) == 1) {
	cp += itf8_put(cp, c->length);
    } else {
	*(int32_t *)cp = le_int4(c->length);
	cp += 4;
    }
    if (c->multi_seq) {
	cp += itf8_put(cp, -2);
	cp += itf8_put(cp, 0);
	cp += itf8_put(cp, 0);
    } else {
	cp += itf8_put(cp, c->ref_seq_id);
	cp += itf8_put(cp, c->ref_seq_start);
	cp += itf8_put(cp, c->ref_seq_span);
    }
    cp += itf8_put(cp, c->num_records);
    if (CRAM_MAJOR_VERS(fd->version) == 2) {
	cp += itf8_put(cp, c->record_counter);
	cp += ltf8_put(cp, c->num_bases);
    } else if (CRAM_MAJOR_VERS(fd->version) >= 3) {
	cp += ltf8_put(cp, c->record_counter);
	cp += ltf8_put(cp, c->num_bases);
    }

    cp += itf8_put(cp, c->num_blocks);
    cp += itf8_put(cp, c->num_landmarks);
    for (i = 0; i < c->num_landmarks; i++)
	cp += itf8_put(cp, c->landmark[i]);

    if (CRAM_MAJOR_VERS(fd->version) >= 3) {
	c->crc32 = crc32(0L, (uc *)dat, cp-dat);
	cp[0] =  c->crc32        & 0xff;
	cp[1] = (c->crc32 >>  8) & 0xff;
	cp[2] = (c->crc32 >> 16) & 0xff;
	cp[3] = (c->crc32 >> 24) & 0xff;
	cp += 4;
    }

    *size = cp-dat; // actual used size

    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %rbx
movl 0x28(%rsi), %eax
leal (%rax,%rax,4), %ecx
addl $0x37, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl (%rbx), %ecx
jg 0x5a5e5
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
movl $0xffffff00, %ecx       # imm = 0xFFFFFF00
andl 0xc(%rdi), %ecx
movl (%rsi), %eax
cmpl $0x100, %ecx            # imm = 0x100
jne 0x59dd1
cmpl $0x7f, %eax
ja 0x59e1b
movb %al, (%r14)
movl $0x1, %r13d
jmp 0x59dda
movl %eax, (%r14)
movl $0x4, %r13d
addq %r14, %r13
cmpl $0x0, 0x94(%r15)
je 0x59e04
movl $0xffffffff, (%r13)     # imm = 0xFFFFFFFF
movw $0xe, 0x4(%r13)
movb $0x0, 0x6(%r13)
addq $0x7, %r13
jmp 0x5a114
movl 0x4(%r15), %eax
cmpl $0x7f, %eax
ja 0x59e39
movb %al, (%r13)
movl $0x1, %eax
jmp 0x59f7b
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x59e5b
shrl $0x8, %eax
orb $-0x80, %al
movb %al, (%r14)
movb (%r15), %al
movb %al, 0x1(%r14)
movl $0x2, %r13d
jmp 0x59dda
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x59e84
shrl $0x8, %eax
orb $-0x80, %al
movb %al, (%r13)
movb 0x4(%r15), %al
movb %al, 0x1(%r13)
movl $0x2, %eax
jmp 0x59f7b
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x59eae
shrl $0x10, %eax
orb $-0x40, %al
movb %al, (%r14)
movb 0x1(%r15), %al
movb %al, 0x1(%r14)
movb (%r15), %al
movb %al, 0x2(%r14)
movl $0x3, %r13d
jmp 0x59dda
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x59ed9
shrl $0x10, %eax
orb $-0x40, %al
movb %al, (%r13)
movb 0x5(%r15), %al
movb %al, 0x1(%r13)
movb 0x4(%r15), %al
movb %al, 0x2(%r13)
movl $0x3, %eax
jmp 0x59f7b
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x59f08
shrl $0x18, %eax
orb $-0x20, %al
movb %al, (%r14)
movb 0x2(%r15), %al
movb %al, 0x1(%r14)
movb 0x1(%r15), %al
movb %al, 0x2(%r14)
movb (%r15), %al
movb %al, 0x3(%r14)
jmp 0x59dd4
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x59f42
shrl $0x18, %eax
orb $-0x20, %al
movb %al, (%r13)
movb 0x6(%r15), %al
movb %al, 0x1(%r13)
movb 0x5(%r15), %al
movb %al, 0x2(%r13)
movb 0x4(%r15), %al
movb %al, 0x3(%r13)
movl $0x4, %eax
jmp 0x59f7b
shrl $0x1c, %eax
orb $-0x10, %al
movb %al, (%r14)
movl (%r15), %eax
shrl $0x14, %eax
movb %al, 0x1(%r14)
movl (%r15), %eax
shrl $0xc, %eax
movb %al, 0x2(%r14)
movl (%r15), %eax
shrl $0x4, %eax
movb %al, 0x3(%r14)
movb (%r15), %al
andb $0xf, %al
movb %al, 0x4(%r14)
movl $0x5, %r13d
jmp 0x59dda
shrl $0x1c, %eax
orb $-0x10, %al
movb %al, (%r13)
movl 0x4(%r15), %eax
shrl $0x14, %eax
movb %al, 0x1(%r13)
movl 0x4(%r15), %eax
shrl $0xc, %eax
movb %al, 0x2(%r13)
movl 0x4(%r15), %eax
shrl $0x4, %eax
movb %al, 0x3(%r13)
movb 0x4(%r15), %al
andb $0xf, %al
movb %al, 0x4(%r13)
movl $0x5, %eax
addq %rax, %r13
movl 0x8(%r15), %eax
cmpl $0x7f, %eax
ja 0x59f95
movb %al, (%r13)
movl $0x1, %eax
jmp 0x5a046
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x59fb7
shrl $0x8, %eax
orb $-0x80, %al
movb %al, (%r13)
movb 0x8(%r15), %al
movb %al, 0x1(%r13)
movl $0x2, %eax
jmp 0x5a046
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x59fde
shrl $0x10, %eax
orb $-0x40, %al
movb %al, (%r13)
movb 0x9(%r15), %al
movb %al, 0x1(%r13)
movb 0x8(%r15), %al
movb %al, 0x2(%r13)
movl $0x3, %eax
jmp 0x5a046
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x5a00d
shrl $0x18, %eax
orb $-0x20, %al
movb %al, (%r13)
movb 0xa(%r15), %al
movb %al, 0x1(%r13)
movb 0x9(%r15), %al
movb %al, 0x2(%r13)
movb 0x8(%r15), %al
movb %al, 0x3(%r13)
movl $0x4, %eax
jmp 0x5a046
shrl $0x1c, %eax
orb $-0x10, %al
movb %al, (%r13)
movl 0x8(%r15), %eax
shrl $0x14, %eax
movb %al, 0x1(%r13)
movl 0x8(%r15), %eax
shrl $0xc, %eax
movb %al, 0x2(%r13)
movl 0x8(%r15), %eax
shrl $0x4, %eax
movb %al, 0x3(%r13)
movb 0x8(%r15), %al
andb $0xf, %al
movb %al, 0x4(%r13)
movl $0x5, %eax
addq %rax, %r13
movl 0xc(%r15), %eax
cmpl $0x7f, %eax
ja 0x5a060
movb %al, (%r13)
movl $0x1, %eax
jmp 0x5a111
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x5a082
shrl $0x8, %eax
orb $-0x80, %al
movb %al, (%r13)
movb 0xc(%r15), %al
movb %al, 0x1(%r13)
movl $0x2, %eax
jmp 0x5a111
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x5a0a9
shrl $0x10, %eax
orb $-0x40, %al
movb %al, (%r13)
movb 0xd(%r15), %al
movb %al, 0x1(%r13)
movb 0xc(%r15), %al
movb %al, 0x2(%r13)
movl $0x3, %eax
jmp 0x5a111
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x5a0d8
shrl $0x18, %eax
orb $-0x20, %al
movb %al, (%r13)
movb 0xe(%r15), %al
movb %al, 0x1(%r13)
movb 0xd(%r15), %al
movb %al, 0x2(%r13)
movb 0xc(%r15), %al
movb %al, 0x3(%r13)
movl $0x4, %eax
jmp 0x5a111
shrl $0x1c, %eax
orb $-0x10, %al
movb %al, (%r13)
movl 0xc(%r15), %eax
shrl $0x14, %eax
movb %al, 0x1(%r13)
movl 0xc(%r15), %eax
shrl $0xc, %eax
movb %al, 0x2(%r13)
movl 0xc(%r15), %eax
shrl $0x4, %eax
movb %al, 0x3(%r13)
movb 0xc(%r15), %al
andb $0xf, %al
movb %al, 0x4(%r13)
movl $0x5, %eax
addq %rax, %r13
movl 0x20(%r15), %eax
cmpl $0x7f, %eax
ja 0x5a12b
movb %al, (%r13)
movl $0x1, %eax
jmp 0x5a1dc
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x5a14d
shrl $0x8, %eax
orb $-0x80, %al
movb %al, (%r13)
movb 0x20(%r15), %al
movb %al, 0x1(%r13)
movl $0x2, %eax
jmp 0x5a1dc
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x5a174
shrl $0x10, %eax
orb $-0x40, %al
movb %al, (%r13)
movb 0x21(%r15), %al
movb %al, 0x1(%r13)
movb 0x20(%r15), %al
movb %al, 0x2(%r13)
movl $0x3, %eax
jmp 0x5a1dc
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x5a1a3
shrl $0x18, %eax
orb $-0x20, %al
movb %al, (%r13)
movb 0x22(%r15), %al
movb %al, 0x1(%r13)
movb 0x21(%r15), %al
movb %al, 0x2(%r13)
movb 0x20(%r15), %al
movb %al, 0x3(%r13)
movl $0x4, %eax
jmp 0x5a1dc
shrl $0x1c, %eax
orb $-0x10, %al
movb %al, (%r13)
movl 0x20(%r15), %eax
shrl $0x14, %eax
movb %al, 0x1(%r13)
movl 0x20(%r15), %eax
shrl $0xc, %eax
movb %al, 0x2(%r13)
movl 0x20(%r15), %eax
shrl $0x4, %eax
movb %al, 0x3(%r13)
movb 0x20(%r15), %al
andb $0xf, %al
movb %al, 0x4(%r13)
movl $0x5, %eax
addq %rax, %r13
movl 0xc(%r12), %eax
sarl $0x8, %eax
cmpl $0x2, %eax
jne 0x5a204
movq 0x10(%r15), %rax
cmpq $0x7f, %rax
ja 0x5a21d
movb %al, (%r13)
movl $0x1, %eax
jmp 0x5a2d1
jle 0x5a2e5
movq 0x10(%r15), %rsi
movq %r13, %rdi
callq 0x549dd
movl %eax, %eax
jmp 0x5a2d1
cmpq $0x3fff, %rax           # imm = 0x3FFF
ja 0x5a240
shrl $0x8, %eax
orb $-0x80, %al
movb %al, (%r13)
movb 0x10(%r15), %al
movb %al, 0x1(%r13)
movl $0x2, %eax
jmp 0x5a2d1
cmpq $0x1fffff, %rax         # imm = 0x1FFFFF
ja 0x5a268
shrl $0x10, %eax
orb $-0x40, %al
movb %al, (%r13)
movb 0x11(%r15), %al
movb %al, 0x1(%r13)
movb 0x10(%r15), %al
movb %al, 0x2(%r13)
movl $0x3, %eax
jmp 0x5a2d1
cmpq $0xfffffff, %rax        # imm = 0xFFFFFFF
ja 0x5a298
shrl $0x18, %eax
orb $-0x20, %al
movb %al, (%r13)
movb 0x12(%r15), %al
movb %al, 0x1(%r13)
movb 0x11(%r15), %al
movb %al, 0x2(%r13)
movb 0x10(%r15), %al
movb %al, 0x3(%r13)
movl $0x4, %eax
jmp 0x5a2d1
shrl $0x1c, %eax
orb $-0x10, %al
movb %al, (%r13)
movl 0x10(%r15), %eax
shrl $0x14, %eax
movb %al, 0x1(%r13)
movl 0x10(%r15), %eax
shrl $0xc, %eax
movb %al, 0x2(%r13)
movl 0x10(%r15), %eax
shrl $0x4, %eax
movb %al, 0x3(%r13)
movb 0x10(%r15), %al
andb $0xf, %al
movb %al, 0x4(%r13)
movl $0x5, %eax
addq %rax, %r13
movq 0x18(%r15), %rsi
movq %r13, %rdi
callq 0x549dd
movl %eax, %eax
addq %rax, %r13
movl 0x24(%r15), %eax
cmpl $0x7f, %eax
ja 0x5a2fc
movb %al, (%r13)
movl $0x1, %eax
jmp 0x5a3ad
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x5a31e
shrl $0x8, %eax
orb $-0x80, %al
movb %al, (%r13)
movb 0x24(%r15), %al
movb %al, 0x1(%r13)
movl $0x2, %eax
jmp 0x5a3ad
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x5a345
shrl $0x10, %eax
orb $-0x40, %al
movb %al, (%r13)
movb 0x25(%r15), %al
movb %al, 0x1(%r13)
movb 0x24(%r15), %al
movb %al, 0x2(%r13)
movl $0x3, %eax
jmp 0x5a3ad
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x5a374
shrl $0x18, %eax
orb $-0x20, %al
movb %al, (%r13)
movb 0x26(%r15), %al
movb %al, 0x1(%r13)
movb 0x25(%r15), %al
movb %al, 0x2(%r13)
movb 0x24(%r15), %al
movb %al, 0x3(%r13)
movl $0x4, %eax
jmp 0x5a3ad
shrl $0x1c, %eax
orb $-0x10, %al
movb %al, (%r13)
movl 0x24(%r15), %eax
shrl $0x14, %eax
movb %al, 0x1(%r13)
movl 0x24(%r15), %eax
shrl $0xc, %eax
movb %al, 0x2(%r13)
movl 0x24(%r15), %eax
shrl $0x4, %eax
movb %al, 0x3(%r13)
movb 0x24(%r15), %al
andb $0xf, %al
movb %al, 0x4(%r13)
movl $0x5, %eax
addq %rax, %r13
movl 0x28(%r15), %eax
cmpl $0x7f, %eax
ja 0x5a3c7
movb %al, (%r13)
movl $0x1, %eax
jmp 0x5a478
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x5a3e9
shrl $0x8, %eax
orb $-0x80, %al
movb %al, (%r13)
movb 0x28(%r15), %al
movb %al, 0x1(%r13)
movl $0x2, %eax
jmp 0x5a478
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x5a410
shrl $0x10, %eax
orb $-0x40, %al
movb %al, (%r13)
movb 0x29(%r15), %al
movb %al, 0x1(%r13)
movb 0x28(%r15), %al
movb %al, 0x2(%r13)
movl $0x3, %eax
jmp 0x5a478
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x5a43f
shrl $0x18, %eax
orb $-0x20, %al
movb %al, (%r13)
movb 0x2a(%r15), %al
movb %al, 0x1(%r13)
movb 0x29(%r15), %al
movb %al, 0x2(%r13)
movb 0x28(%r15), %al
movb %al, 0x3(%r13)
movl $0x4, %eax
jmp 0x5a478
shrl $0x1c, %eax
orb $-0x10, %al
movb %al, (%r13)
movl 0x28(%r15), %eax
shrl $0x14, %eax
movb %al, 0x1(%r13)
movl 0x28(%r15), %eax
shrl $0xc, %eax
movb %al, 0x2(%r13)
movl 0x28(%r15), %eax
shrl $0x4, %eax
movb %al, 0x3(%r13)
movb 0x28(%r15), %al
andb $0xf, %al
movb %al, 0x4(%r13)
movl $0x5, %eax
addq %rax, %r13
cmpl $0x0, 0x28(%r15)
jle 0x5a592
xorl %eax, %eax
movq 0x30(%r15), %rcx
movl (%rcx,%rax,4), %ecx
cmpl $0x7f, %ecx
ja 0x5a4a2
movb %cl, (%r13)
movl $0x1, %ecx
jmp 0x5a57f
cmpl $0x3fff, %ecx           # imm = 0x3FFF
ja 0x5a4c9
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, (%r13)
movq 0x30(%r15), %rcx
movb (%rcx,%rax,4), %cl
movb %cl, 0x1(%r13)
movl $0x2, %ecx
jmp 0x5a57f
cmpl $0x1fffff, %ecx         # imm = 0x1FFFFF
ja 0x5a4fc
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, (%r13)
movq 0x30(%r15), %rcx
movb 0x1(%rcx,%rax,4), %cl
movb %cl, 0x1(%r13)
movq 0x30(%r15), %rcx
movb (%rcx,%rax,4), %cl
movb %cl, 0x2(%r13)
movl $0x3, %ecx
jmp 0x5a57f
cmpl $0xfffffff, %ecx        # imm = 0xFFFFFFF
ja 0x5a538
shrl $0x18, %ecx
orb $-0x20, %cl
movb %cl, (%r13)
movq 0x30(%r15), %rcx
movb 0x2(%rcx,%rax,4), %cl
movb %cl, 0x1(%r13)
movq 0x30(%r15), %rcx
movb 0x1(%rcx,%rax,4), %cl
movb %cl, 0x2(%r13)
movq 0x30(%r15), %rcx
movb (%rcx,%rax,4), %cl
movb %cl, 0x3(%r13)
movl $0x4, %ecx
jmp 0x5a57f
shrl $0x1c, %ecx
orb $-0x10, %cl
movb %cl, (%r13)
movq 0x30(%r15), %rcx
movl (%rcx,%rax,4), %ecx
shrl $0x14, %ecx
movb %cl, 0x1(%r13)
movq 0x30(%r15), %rcx
movl (%rcx,%rax,4), %ecx
shrl $0xc, %ecx
movb %cl, 0x2(%r13)
movq 0x30(%r15), %rcx
movl (%rcx,%rax,4), %ecx
shrl $0x4, %ecx
movb %cl, 0x3(%r13)
movq 0x30(%r15), %rcx
movb (%rcx,%rax,4), %cl
andb $0xf, %cl
movb %cl, 0x4(%r13)
movl $0x5, %ecx
addq %rcx, %r13
incq %rax
movslq 0x28(%r15), %rcx
cmpq %rcx, %rax
jl 0x5a488
cmpl $0x2ff, 0xc(%r12)       # imm = 0x2FF
jle 0x5a5dd
movl %r13d, %edx
subl %r14d, %edx
xorl %edi, %edi
movq %r14, %rsi
callq 0x64b0
movl %eax, 0x248(%r15)
movb %al, (%r13)
movb 0x249(%r15), %al
movb %al, 0x1(%r13)
movb 0x24a(%r15), %al
movb %al, 0x2(%r13)
movb 0x24b(%r15), %al
movb %al, 0x3(%r13)
addq $0x4, %r13
subl %r14d, %r13d
movl %r13d, (%rbx)
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq