// File: /workspace/github_c_makefile_star2_O1/samtools[P]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 = (char *)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 += fd->vv.varint_put32(cp, NULL, -2);
        cp += fd->vv.varint_put32(cp, NULL, 0);
        cp += fd->vv.varint_put32(cp, NULL, 0);
    } else {
        cp += fd->vv.varint_put32s(cp, NULL, c->ref_seq_id);
        if (CRAM_MAJOR_VERS(fd->version) >= 4) {
            cp += fd->vv.varint_put64(cp, NULL, c->ref_seq_start);
            cp += fd->vv.varint_put64(cp, NULL, c->ref_seq_span);
        } else {
            cp += fd->vv.varint_put32(cp, NULL, c->ref_seq_start);
            cp += fd->vv.varint_put32(cp, NULL, c->ref_seq_span);
        }
    }
    cp += fd->vv.varint_put32(cp, NULL, c->num_records);
    if (CRAM_MAJOR_VERS(fd->version) == 2) {
        cp += fd->vv.varint_put64(cp, NULL, c->record_counter);
    } else if (CRAM_MAJOR_VERS(fd->version) >= 3) {
        cp += fd->vv.varint_put32(cp, NULL, c->record_counter);
    }
    cp += fd->vv.varint_put64(cp, NULL, c->num_bases);
    cp += fd->vv.varint_put32(cp, NULL, c->num_blocks);
    cp += fd->vv.varint_put32(cp, NULL, c->num_landmarks);
    for (i = 0; i < c->num_landmarks; i++)
        cp += fd->vv.varint_put32(cp, NULL, 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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movl 0x30(%rsi), %eax
leal (%rax,%rax,4), %ecx
addl $0x37, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl (%rbx), %ecx
jg 0x534d2
movq %rdx, %rbp
movq %rsi, %r14
movq %rdi, %r15
movl $0xffffff00, %ecx       # imm = 0xFFFFFF00
andl 0xc(%rdi), %ecx
movl (%rsi), %eax
cmpl $0x100, %ecx            # imm = 0x100
jne 0x532de
cmpl $0x7f, %eax
ja 0x53373
movb %al, (%rbp)
movl $0x1, %r12d
jmp 0x532e7
movl %eax, (%rbp)
movl $0x4, %r12d
addq %rbp, %r12
cmpl $0x0, 0xac(%r14)
je 0x5332b
movq %r12, %rdi
xorl %esi, %esi
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
callq *0x89c8(%r15)
movslq %eax, %r13
addq %r12, %r13
movq %r13, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq *0x89c8(%r15)
movslq %eax, %r12
addq %r13, %r12
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
jmp 0x533af
movl 0x4(%r14), %edx
movq %r12, %rdi
xorl %esi, %esi
callq *0x89d0(%r15)
movslq %eax, %r13
addq %r12, %r13
cmpl $0x400, 0xc(%r15)       # imm = 0x400
movq 0x8(%r14), %rdx
movq %r13, %rdi
jl 0x53397
xorl %esi, %esi
callq *0x89d8(%r15)
movslq %eax, %r12
addq %r13, %r12
movq 0x10(%r14), %rdx
movq %r12, %rdi
xorl %esi, %esi
callq *0x89d8(%r15)
jmp 0x533b6
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x534e1
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, (%rbp)
movb %al, 0x1(%rbp)
movl $0x2, %r12d
jmp 0x532e7
xorl %esi, %esi
callq *0x89c8(%r15)
movslq %eax, %r12
addq %r13, %r12
movl 0x10(%r14), %edx
movq %r12, %rdi
xorl %esi, %esi
callq *0x89c8(%r15)
movslq %eax, %r13
addq %r12, %r13
movl 0x28(%r14), %edx
movq %r13, %rdi
xorl %esi, %esi
callq *0x89c8(%r15)
movslq %eax, %r12
addq %r13, %r12
movl 0xc(%r15), %eax
sarl $0x8, %eax
cmpl $0x2, %eax
movq %rbx, (%rsp)
jne 0x533f4
movq 0x18(%r14), %rdx
movq %r12, %rdi
xorl %esi, %esi
callq *0x89d8(%r15)
jmp 0x53406
jle 0x5340b
movl 0x18(%r14), %edx
movq %r12, %rdi
xorl %esi, %esi
callq *0x89c8(%r15)
cltq
addq %rax, %r12
movq 0x20(%r14), %rdx
movq %r12, %rdi
xorl %esi, %esi
callq *0x89d8(%r15)
movslq %eax, %r13
addq %r12, %r13
movl 0x2c(%r14), %edx
movq %r13, %rdi
xorl %esi, %esi
callq *0x89c8(%r15)
movslq %eax, %rbx
addq %r13, %rbx
movl 0x30(%r14), %edx
movq %rbx, %rdi
xorl %esi, %esi
callq *0x89c8(%r15)
movslq %eax, %r12
addq %rbx, %r12
cmpl $0x0, 0x30(%r14)
jle 0x5347a
xorl %ebx, %ebx
movq 0x38(%r14), %rax
movl (%rax,%rbx,4), %edx
movq %r12, %rdi
xorl %esi, %esi
callq *0x89c8(%r15)
cltq
addq %rax, %r12
incq %rbx
movslq 0x30(%r14), %rax
cmpq %rax, %rbx
jl 0x53456
cmpl $0x300, 0xc(%r15)       # imm = 0x300
jl 0x534c6
movl %r12d, %edx
subl %ebp, %edx
xorl %edi, %edi
movq %rbp, %rsi
callq 0x4320
movl %eax, 0x280(%r14)
movb %al, (%r12)
movb 0x281(%r14), %al
movb %al, 0x1(%r12)
movb 0x282(%r14), %al
movb %al, 0x2(%r12)
movb 0x283(%r14), %al
movb %al, 0x3(%r12)
addq $0x4, %r12
movq (%rsp), %rax
subl %ebp, %r12d
movl %r12d, (%rax)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x53502
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, (%rbp)
movb %ah, 0x1(%rbp)
movb %al, 0x2(%rbp)
movl $0x3, %r12d
jmp 0x532e7
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x53525
shrl $0x18, %ecx
orb $-0x20, %cl
movb %cl, (%rbp)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0x1(%rbp)
movb %ah, 0x2(%rbp)
movb %al, 0x3(%rbp)
jmp 0x532e1
shrl $0x1c, %ecx
orb $-0x10, %cl
movb %cl, (%rbp)
movl %eax, %ecx
shrl $0x14, %ecx
movb %cl, 0x1(%rbp)
movl %eax, %ecx
shrl $0xc, %ecx
movb %cl, 0x2(%rbp)
movl %eax, %ecx
shrl $0x4, %ecx
movb %cl, 0x3(%rbp)
andb $0xf, %al
movb %al, 0x4(%rbp)
movl $0x5, %r12d
jmp 0x532e7