// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/cram/cram_io.c
// Function: cram_write_container
int cram_write_container(cram_fd *fd, cram_container *c) {
    char buf_a[1024], *buf = buf_a, *cp;
    int i;

    if (61 + c->num_landmarks * 10 >= 1024) {
        buf = malloc(61 + c->num_landmarks * 10);
        if (!buf)
            return -1;
    }
    cp = buf;

    if (CRAM_MAJOR_VERS(fd->version) == 1) {
        cp += itf8_put(cp, c->length);
    } else if (CRAM_MAJOR_VERS(fd->version) <= 3) {
        *(int32_t *)cp = le_int4(c->length);
        cp += 4;
    } else {
        cp += fd->vv.varint_put32(cp, NULL, c->length);
    }
    if (c->multi_seq) {
        cp += fd->vv.varint_put32(cp, NULL, (uint32_t)-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) >= 3)
        cp += fd->vv.varint_put64(cp, NULL, c->record_counter);
    else
        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 *)buf, cp-buf);
        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;
    }

    if (cp-buf != hwrite(fd->fp, buf, cp-buf)) {
        if (buf != buf_a)
            free(buf);
        return -1;
    }

    if (buf != buf_a)
        free(buf);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x440, %rsp            # imm = 0x440
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq -0x420(%rbp), %rax
movq %rax, -0x428(%rbp)
movq -0x18(%rbp), %rax
imull $0xa, 0x30(%rax), %eax
addl $0x3d, %eax
cmpl $0x400, %eax            # imm = 0x400
jl 0x76095
movq -0x18(%rbp), %rax
imull $0xa, 0x30(%rax), %eax
addl $0x3d, %eax
movslq %eax, %rdi
callq 0x4650
movq %rax, -0x428(%rbp)
cmpq $0x0, -0x428(%rbp)
jne 0x76093
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x76630
jmp 0x76095
movq -0x428(%rbp), %rax
movq %rax, -0x430(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
cmpl $0x1, %eax
jne 0x760dc
movq -0x430(%rbp), %rdi
movq -0x18(%rbp), %rax
movl (%rax), %esi
callq 0x6cfe0
movl %eax, %ecx
movq -0x430(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x430(%rbp)
jmp 0x76144
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
cmpl $0x3, %eax
jg 0x7610e
movq -0x18(%rbp), %rax
movl (%rax), %ecx
movq -0x430(%rbp), %rax
movl %ecx, (%rax)
movq -0x430(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x430(%rbp)
jmp 0x76142
movq -0x10(%rbp), %rax
movq 0x89c8(%rax), %rax
movq -0x430(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl (%rcx), %edx
xorl %ecx, %ecx
movl %ecx, %esi
callq *%rax
movl %eax, %ecx
movq -0x430(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x430(%rbp)
jmp 0x76144
movq -0x18(%rbp), %rax
cmpl $0x0, 0xac(%rax)
je 0x761ed
movq -0x10(%rbp), %rax
movq 0x89c8(%rax), %rax
movq -0x430(%rbp), %rdi
xorl %ecx, %ecx
movl %ecx, %esi
movl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
callq *%rax
movl %eax, %ecx
movq -0x430(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x430(%rbp)
movq -0x10(%rbp), %rax
movq 0x89c8(%rax), %rax
movq -0x430(%rbp), %rdi
xorl %ecx, %ecx
movl %ecx, %esi
xorl %edx, %edx
callq *%rax
movl %eax, %ecx
movq -0x430(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x430(%rbp)
movq -0x10(%rbp), %rax
movq 0x89c8(%rax), %rax
movq -0x430(%rbp), %rdi
xorl %ecx, %ecx
movl %ecx, %esi
xorl %edx, %edx
callq *%rax
movl %eax, %ecx
movq -0x430(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x430(%rbp)
jmp 0x76311
movq -0x10(%rbp), %rax
movq 0x89d0(%rax), %rax
movq -0x430(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl 0x4(%rcx), %edx
xorl %ecx, %ecx
movl %ecx, %esi
callq *%rax
movl %eax, %ecx
movq -0x430(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x430(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
cmpl $0x4, %eax
jl 0x7629f
movq -0x10(%rbp), %rax
movq 0x89d8(%rax), %rax
movq -0x430(%rbp), %rdi
movq -0x18(%rbp), %rcx
movq 0x8(%rcx), %rdx
xorl %ecx, %ecx
movl %ecx, %esi
callq *%rax
movl %eax, %ecx
movq -0x430(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x430(%rbp)
movq -0x10(%rbp), %rax
movq 0x89d8(%rax), %rax
movq -0x430(%rbp), %rdi
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rdx
xorl %ecx, %ecx
movl %ecx, %esi
callq *%rax
movl %eax, %ecx
movq -0x430(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x430(%rbp)
jmp 0x7630f
movq -0x10(%rbp), %rax
movq 0x89c8(%rax), %rax
movq -0x430(%rbp), %rdi
movq -0x18(%rbp), %rcx
movq 0x8(%rcx), %rcx
movl %ecx, %edx
xorl %ecx, %ecx
movl %ecx, %esi
callq *%rax
movl %eax, %ecx
movq -0x430(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x430(%rbp)
movq -0x10(%rbp), %rax
movq 0x89c8(%rax), %rax
movq -0x430(%rbp), %rdi
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl %ecx, %edx
xorl %ecx, %ecx
movl %ecx, %esi
callq *%rax
movl %eax, %ecx
movq -0x430(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x430(%rbp)
jmp 0x76311
movq -0x10(%rbp), %rax
movq 0x89c8(%rax), %rax
movq -0x430(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl 0x28(%rcx), %edx
xorl %ecx, %ecx
movl %ecx, %esi
callq *%rax
movl %eax, %ecx
movq -0x430(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x430(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
cmpl $0x3, %eax
jl 0x7638d
movq -0x10(%rbp), %rax
movq 0x89d8(%rax), %rax
movq -0x430(%rbp), %rdi
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rdx
xorl %ecx, %ecx
movl %ecx, %esi
callq *%rax
movl %eax, %ecx
movq -0x430(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x430(%rbp)
jmp 0x763c5
movq -0x10(%rbp), %rax
movq 0x89c8(%rax), %rax
movq -0x430(%rbp), %rdi
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl %ecx, %edx
xorl %ecx, %ecx
movl %ecx, %esi
callq *%rax
movl %eax, %ecx
movq -0x430(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x430(%rbp)
movq -0x10(%rbp), %rax
movq 0x89d8(%rax), %rax
movq -0x430(%rbp), %rdi
movq -0x18(%rbp), %rcx
movq 0x20(%rcx), %rdx
xorl %ecx, %ecx
movl %ecx, %esi
callq *%rax
movl %eax, %ecx
movq -0x430(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x430(%rbp)
movq -0x10(%rbp), %rax
movq 0x89c8(%rax), %rax
movq -0x430(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl 0x2c(%rcx), %edx
xorl %ecx, %ecx
movl %ecx, %esi
callq *%rax
movl %eax, %ecx
movq -0x430(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x430(%rbp)
movq -0x10(%rbp), %rax
movq 0x89c8(%rax), %rax
movq -0x430(%rbp), %rdi
movq -0x18(%rbp), %rcx
movl 0x30(%rcx), %edx
xorl %ecx, %ecx
movl %ecx, %esi
callq *%rax
movl %eax, %ecx
movq -0x430(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x430(%rbp)
movl $0x0, -0x434(%rbp)
movl -0x434(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x30(%rcx), %eax
jge 0x764cf
movq -0x10(%rbp), %rax
movq 0x89c8(%rax), %rax
movq -0x430(%rbp), %rdi
movq -0x18(%rbp), %rcx
movq 0x38(%rcx), %rcx
movslq -0x434(%rbp), %rdx
movl (%rcx,%rdx,4), %edx
xorl %ecx, %ecx
movl %ecx, %esi
callq *%rax
movl %eax, %ecx
movq -0x430(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x430(%rbp)
movl -0x434(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x434(%rbp)
jmp 0x7646f
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
sarl $0x8, %eax
cmpl $0x3, %eax
jl 0x76597
movq -0x428(%rbp), %rsi
movq -0x430(%rbp), %rax
movq -0x428(%rbp), %rcx
subq %rcx, %rax
movl %eax, %edx
xorl %eax, %eax
movl %eax, %edi
callq 0x4310
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x280(%rax)
movq -0x18(%rbp), %rax
movl 0x280(%rax), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x430(%rbp), %rax
movb %cl, (%rax)
movq -0x18(%rbp), %rax
movl 0x280(%rax), %eax
shrl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x430(%rbp), %rax
movb %cl, 0x1(%rax)
movq -0x18(%rbp), %rax
movl 0x280(%rax), %eax
shrl $0x10, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x430(%rbp), %rax
movb %cl, 0x2(%rax)
movq -0x18(%rbp), %rax
movl 0x280(%rax), %eax
shrl $0x18, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x430(%rbp), %rax
movb %cl, 0x3(%rax)
movq -0x430(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x430(%rbp)
movq -0x430(%rbp), %rax
movq -0x428(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x440(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x428(%rbp), %rsi
movq -0x430(%rbp), %rdx
movq -0x428(%rbp), %rax
subq %rax, %rdx
callq 0x6d1e0
movq %rax, %rcx
movq -0x440(%rbp), %rax
cmpq %rcx, %rax
je 0x7660a
movq -0x428(%rbp), %rax
leaq -0x420(%rbp), %rcx
cmpq %rcx, %rax
je 0x76601
movq -0x428(%rbp), %rdi
callq 0x45a0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x76630
movq -0x428(%rbp), %rax
leaq -0x420(%rbp), %rcx
cmpq %rcx, %rax
je 0x76629
movq -0x428(%rbp), %rdi
callq 0x45a0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x440, %rsp            # imm = 0x440
popq %rbp
retq
nopl (%rax)