// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/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 (55 + c->num_landmarks * 5 >= 1024)
	buf = malloc(55 + c->num_landmarks * 5);
    cp = buf;

    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 *)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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x400, %rsp            # imm = 0x400
movq %rsi, %r15
movq %rdi, %r14
movl 0x28(%rsi), %eax
cmpl $0xc2, %eax
jl 0x5a3e0
leaq (%rax,%rax,4), %rdi
addq $0x37, %rdi
callq 0x69d0
movq %rax, %rbx
jmp 0x5a3e3
movq %rsp, %rbx
movl $0xffffff00, %ecx       # imm = 0xFFFFFF00
andl 0xc(%r14), %ecx
movl (%r15), %eax
cmpl $0x100, %ecx            # imm = 0x100
jne 0x5a405
cmpl $0x7f, %eax
ja 0x5a449
movb %al, (%rbx)
movl $0x1, %ebp
jmp 0x5a40c
movl %eax, (%rbx)
movl $0x4, %ebp
addq %rbx, %rbp
cmpl $0x0, 0x94(%r15)
je 0x5a433
movl $0xffffffff, (%rbp)     # imm = 0xFFFFFFFF
movw $0xe, 0x4(%rbp)
movb $0x0, 0x6(%rbp)
addq $0x7, %rbp
jmp 0x5a6d9
movl 0x4(%r15), %eax
cmpl $0x7f, %eax
ja 0x5a464
movb %al, (%rbp)
movl $0x1, %eax
jmp 0x5a570
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x5a483
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, (%rbx)
movb %al, 0x1(%rbx)
movl $0x2, %ebp
jmp 0x5a40c
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x5a4a2
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, (%rbp)
movb %al, 0x1(%rbp)
movl $0x2, %eax
jmp 0x5a570
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x5a4c6
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, (%rbx)
movb %ah, 0x1(%rbx)
movb %al, 0x2(%rbx)
movl $0x3, %ebp
jmp 0x5a40c
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x5a4e8
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, (%rbp)
movb %ah, 0x1(%rbp)
movb 0x4(%r15), %al
movb %al, 0x2(%rbp)
movl $0x3, %eax
jmp 0x5a570
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x5a512
shrl $0x18, %ecx
orb $-0x20, %cl
movb %cl, (%rbx)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0x1(%rbx)
movb %ah, 0x2(%rbx)
movb %al, 0x3(%rbx)
jmp 0x5a407
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x5a541
shrl $0x18, %ecx
orb $-0x20, %cl
movb %cl, (%rbp)
shrl $0x10, %eax
movb %al, 0x1(%rbp)
movzwl 0x4(%r15), %eax
rolw $0x8, %ax
movw %ax, 0x2(%rbp)
movl $0x4, %eax
jmp 0x5a570
shrl $0x1c, %ecx
orb $-0x10, %cl
movb %cl, (%rbx)
movl %eax, %ecx
shrl $0x14, %ecx
movb %cl, 0x1(%rbx)
movl %eax, %ecx
shrl $0xc, %ecx
movb %cl, 0x2(%rbx)
movl %eax, %ecx
shrl $0x4, %ecx
movb %cl, 0x3(%rbx)
andb $0xf, %al
movb %al, 0x4(%rbx)
movl $0x5, %ebp
jmp 0x5a40c
shrl $0x1c, %ecx
orb $-0x10, %cl
movb %cl, (%rbp)
shrl $0x14, %eax
movb %al, 0x1(%rbp)
movl 0x4(%r15), %eax
movl %eax, %ecx
shrl $0xc, %ecx
movb %cl, 0x2(%rbp)
shrl $0x4, %eax
movb %al, 0x3(%rbp)
movb 0x4(%r15), %al
andb $0xf, %al
movb %al, 0x4(%rbp)
movl $0x5, %eax
addq %rax, %rbp
movl 0x8(%r15), %eax
cmpl $0x7f, %eax
ja 0x5a589
movb %al, (%rbp)
movl $0x1, %eax
jmp 0x5a623
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x5a5a6
shrl $0x8, %eax
orb $-0x80, %al
movb %al, (%rbp)
movb 0x8(%r15), %al
movb %al, 0x1(%rbp)
movl $0x2, %eax
jmp 0x5a623
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x5a5c9
shrl $0x10, %eax
orb $-0x40, %al
movb %al, (%rbp)
movzwl 0x8(%r15), %eax
rolw $0x8, %ax
movw %ax, 0x1(%rbp)
movl $0x3, %eax
jmp 0x5a623
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x5a5f3
shrl $0x18, %eax
orb $-0x20, %al
movb %al, (%rbp)
movzwl 0x9(%r15), %eax
rolw $0x8, %ax
movw %ax, 0x1(%rbp)
movb 0x8(%r15), %al
movb %al, 0x3(%rbp)
movl $0x4, %eax
jmp 0x5a623
shrl $0x1c, %eax
orb $-0x10, %al
movb %al, (%rbp)
movl 0x8(%r15), %eax
movl %eax, %ecx
shrl $0x14, %ecx
movb %cl, 0x1(%rbp)
shrl $0xc, %eax
movb %al, 0x2(%rbp)
movl 0x8(%r15), %eax
movl %eax, %ecx
shrl $0x4, %ecx
movb %cl, 0x3(%rbp)
andb $0xf, %al
movb %al, 0x4(%rbp)
movl $0x5, %eax
addq %rax, %rbp
movl 0xc(%r15), %eax
cmpl $0x7f, %eax
ja 0x5a63c
movb %al, (%rbp)
movl $0x1, %eax
jmp 0x5a6d6
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x5a659
shrl $0x8, %eax
orb $-0x80, %al
movb %al, (%rbp)
movb 0xc(%r15), %al
movb %al, 0x1(%rbp)
movl $0x2, %eax
jmp 0x5a6d6
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x5a67c
shrl $0x10, %eax
orb $-0x40, %al
movb %al, (%rbp)
movzwl 0xc(%r15), %eax
rolw $0x8, %ax
movw %ax, 0x1(%rbp)
movl $0x3, %eax
jmp 0x5a6d6
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x5a6a6
shrl $0x18, %eax
orb $-0x20, %al
movb %al, (%rbp)
movzwl 0xd(%r15), %eax
rolw $0x8, %ax
movw %ax, 0x1(%rbp)
movb 0xc(%r15), %al
movb %al, 0x3(%rbp)
movl $0x4, %eax
jmp 0x5a6d6
shrl $0x1c, %eax
orb $-0x10, %al
movb %al, (%rbp)
movl 0xc(%r15), %eax
movl %eax, %ecx
shrl $0x14, %ecx
movb %cl, 0x1(%rbp)
shrl $0xc, %eax
movb %al, 0x2(%rbp)
movl 0xc(%r15), %eax
movl %eax, %ecx
shrl $0x4, %ecx
movb %cl, 0x3(%rbp)
andb $0xf, %al
movb %al, 0x4(%rbp)
movl $0x5, %eax
addq %rax, %rbp
movl 0x20(%r15), %eax
cmpl $0x7f, %eax
ja 0x5a6ef
movb %al, (%rbp)
movl $0x1, %eax
jmp 0x5a792
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x5a70f
shrl $0x8, %eax
orb $-0x80, %al
movb %al, (%rbp)
movb 0x20(%r15), %al
movb %al, 0x1(%rbp)
movl $0x2, %eax
jmp 0x5a792
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x5a733
shrl $0x10, %eax
orb $-0x40, %al
movb %al, (%rbp)
movb 0x21(%r15), %al
movb %al, 0x1(%rbp)
movb 0x20(%r15), %al
movb %al, 0x2(%rbp)
movl $0x3, %eax
jmp 0x5a792
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x5a75e
shrl $0x18, %eax
orb $-0x20, %al
movb %al, (%rbp)
movb 0x22(%r15), %al
movb %al, 0x1(%rbp)
movb 0x21(%r15), %al
movb %al, 0x2(%rbp)
movb 0x20(%r15), %al
movb %al, 0x3(%rbp)
movl $0x4, %eax
jmp 0x5a792
shrl $0x1c, %eax
orb $-0x10, %al
movb %al, (%rbp)
movl 0x20(%r15), %eax
shrl $0x14, %eax
movb %al, 0x1(%rbp)
movl 0x20(%r15), %eax
shrl $0xc, %eax
movb %al, 0x2(%rbp)
movl 0x20(%r15), %eax
shrl $0x4, %eax
movb %al, 0x3(%rbp)
movb 0x20(%r15), %al
andb $0xf, %al
movb %al, 0x4(%rbp)
movl $0x5, %eax
addq %rax, %rbp
movl 0xc(%r14), %eax
sarl $0x8, %eax
cmpl $0x2, %eax
jne 0x5a7b8
movq 0x10(%r15), %rax
cmpq $0x7f, %rax
ja 0x5a7d1
movb %al, (%rbp)
movl $0x1, %eax
jmp 0x5a877
jle 0x5a88b
movq 0x10(%r15), %rsi
movq %rbp, %rdi
callq 0x54679
movl %eax, %eax
jmp 0x5a877
cmpq $0x3fff, %rax           # imm = 0x3FFF
ja 0x5a7f2
shrl $0x8, %eax
orb $-0x80, %al
movb %al, (%rbp)
movb 0x10(%r15), %al
movb %al, 0x1(%rbp)
movl $0x2, %eax
jmp 0x5a877
cmpq $0x1fffff, %rax         # imm = 0x1FFFFF
ja 0x5a817
shrl $0x10, %eax
orb $-0x40, %al
movb %al, (%rbp)
movb 0x11(%r15), %al
movb %al, 0x1(%rbp)
movb 0x10(%r15), %al
movb %al, 0x2(%rbp)
movl $0x3, %eax
jmp 0x5a877
cmpq $0xfffffff, %rax        # imm = 0xFFFFFFF
ja 0x5a843
shrl $0x18, %eax
orb $-0x20, %al
movb %al, (%rbp)
movb 0x12(%r15), %al
movb %al, 0x1(%rbp)
movb 0x11(%r15), %al
movb %al, 0x2(%rbp)
movb 0x10(%r15), %al
movb %al, 0x3(%rbp)
movl $0x4, %eax
jmp 0x5a877
shrl $0x1c, %eax
orb $-0x10, %al
movb %al, (%rbp)
movl 0x10(%r15), %eax
shrl $0x14, %eax
movb %al, 0x1(%rbp)
movl 0x10(%r15), %eax
shrl $0xc, %eax
movb %al, 0x2(%rbp)
movl 0x10(%r15), %eax
shrl $0x4, %eax
movb %al, 0x3(%rbp)
movb 0x10(%r15), %al
andb $0xf, %al
movb %al, 0x4(%rbp)
movl $0x5, %eax
addq %rax, %rbp
movq 0x18(%r15), %rsi
movq %rbp, %rdi
callq 0x54679
movl %eax, %eax
addq %rax, %rbp
movl 0x24(%r15), %eax
cmpl $0x7f, %eax
ja 0x5a8a1
movb %al, (%rbp)
movl $0x1, %eax
jmp 0x5a944
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x5a8c1
shrl $0x8, %eax
orb $-0x80, %al
movb %al, (%rbp)
movb 0x24(%r15), %al
movb %al, 0x1(%rbp)
movl $0x2, %eax
jmp 0x5a944
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x5a8e5
shrl $0x10, %eax
orb $-0x40, %al
movb %al, (%rbp)
movb 0x25(%r15), %al
movb %al, 0x1(%rbp)
movb 0x24(%r15), %al
movb %al, 0x2(%rbp)
movl $0x3, %eax
jmp 0x5a944
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x5a910
shrl $0x18, %eax
orb $-0x20, %al
movb %al, (%rbp)
movb 0x26(%r15), %al
movb %al, 0x1(%rbp)
movb 0x25(%r15), %al
movb %al, 0x2(%rbp)
movb 0x24(%r15), %al
movb %al, 0x3(%rbp)
movl $0x4, %eax
jmp 0x5a944
shrl $0x1c, %eax
orb $-0x10, %al
movb %al, (%rbp)
movl 0x24(%r15), %eax
shrl $0x14, %eax
movb %al, 0x1(%rbp)
movl 0x24(%r15), %eax
shrl $0xc, %eax
movb %al, 0x2(%rbp)
movl 0x24(%r15), %eax
shrl $0x4, %eax
movb %al, 0x3(%rbp)
movb 0x24(%r15), %al
andb $0xf, %al
movb %al, 0x4(%rbp)
movl $0x5, %eax
addq %rax, %rbp
movl 0x28(%r15), %eax
cmpl $0x7f, %eax
ja 0x5a95d
movb %al, (%rbp)
movl $0x1, %eax
jmp 0x5aa00
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x5a97d
shrl $0x8, %eax
orb $-0x80, %al
movb %al, (%rbp)
movb 0x28(%r15), %al
movb %al, 0x1(%rbp)
movl $0x2, %eax
jmp 0x5aa00
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x5a9a1
shrl $0x10, %eax
orb $-0x40, %al
movb %al, (%rbp)
movb 0x29(%r15), %al
movb %al, 0x1(%rbp)
movb 0x28(%r15), %al
movb %al, 0x2(%rbp)
movl $0x3, %eax
jmp 0x5aa00
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x5a9cc
shrl $0x18, %eax
orb $-0x20, %al
movb %al, (%rbp)
movb 0x2a(%r15), %al
movb %al, 0x1(%rbp)
movb 0x29(%r15), %al
movb %al, 0x2(%rbp)
movb 0x28(%r15), %al
movb %al, 0x3(%rbp)
movl $0x4, %eax
jmp 0x5aa00
shrl $0x1c, %eax
orb $-0x10, %al
movb %al, (%rbp)
movl 0x28(%r15), %eax
shrl $0x14, %eax
movb %al, 0x1(%rbp)
movl 0x28(%r15), %eax
shrl $0xc, %eax
movb %al, 0x2(%rbp)
movl 0x28(%r15), %eax
shrl $0x4, %eax
movb %al, 0x3(%rbp)
movb 0x28(%r15), %al
andb $0xf, %al
movb %al, 0x4(%rbp)
movl $0x5, %eax
addq %rax, %rbp
cmpl $0x0, 0x28(%r15)
jle 0x5ab08
xorl %eax, %eax
movq 0x30(%r15), %rcx
movl (%rcx,%rax,4), %ecx
cmpl $0x7f, %ecx
ja 0x5aa29
movb %cl, (%rbp)
movl $0x1, %ecx
jmp 0x5aaf5
cmpl $0x3fff, %ecx           # imm = 0x3FFF
ja 0x5aa4e
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, (%rbp)
movq 0x30(%r15), %rcx
movb (%rcx,%rax,4), %cl
movb %cl, 0x1(%rbp)
movl $0x2, %ecx
jmp 0x5aaf5
cmpl $0x1fffff, %ecx         # imm = 0x1FFFFF
ja 0x5aa7b
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, (%rbp)
movq 0x30(%r15), %rcx
movb 0x1(%rcx,%rax,4), %cl
movb %cl, 0x1(%rbp)
movq 0x30(%r15), %rcx
movb (%rcx,%rax,4), %cl
movb %cl, 0x2(%rbp)
movl $0x3, %ecx
jmp 0x5aaf5
cmpl $0xfffffff, %ecx        # imm = 0xFFFFFFF
ja 0x5aab3
shrl $0x18, %ecx
orb $-0x20, %cl
movb %cl, (%rbp)
movq 0x30(%r15), %rcx
movb 0x2(%rcx,%rax,4), %cl
movb %cl, 0x1(%rbp)
movq 0x30(%r15), %rcx
movb 0x1(%rcx,%rax,4), %cl
movb %cl, 0x2(%rbp)
movq 0x30(%r15), %rcx
movb (%rcx,%rax,4), %cl
movb %cl, 0x3(%rbp)
movl $0x4, %ecx
jmp 0x5aaf5
shrl $0x1c, %ecx
orb $-0x10, %cl
movb %cl, (%rbp)
movq 0x30(%r15), %rcx
movl (%rcx,%rax,4), %ecx
shrl $0x14, %ecx
movb %cl, 0x1(%rbp)
movq 0x30(%r15), %rcx
movl (%rcx,%rax,4), %ecx
shrl $0xc, %ecx
movb %cl, 0x2(%rbp)
movq 0x30(%r15), %rcx
movl (%rcx,%rax,4), %ecx
shrl $0x4, %ecx
movb %cl, 0x3(%rbp)
movq 0x30(%r15), %rcx
movb (%rcx,%rax,4), %cl
andb $0xf, %cl
movb %cl, 0x4(%rbp)
movl $0x5, %ecx
addq %rcx, %rbp
incq %rax
movslq 0x28(%r15), %rcx
cmpq %rcx, %rax
jl 0x5aa10
cmpl $0x300, 0xc(%r14)       # imm = 0x300
jl 0x5ab4c
movl %ebp, %edx
subl %ebx, %edx
xorl %edi, %edi
movq %rbx, %rsi
callq 0x64b0
movl %eax, 0x248(%r15)
movb %al, (%rbp)
movb 0x249(%r15), %al
movb %al, 0x1(%rbp)
movb 0x24a(%r15), %al
movb %al, 0x2(%rbp)
movb 0x24b(%r15), %al
movb %al, 0x3(%rbp)
addq $0x4, %rbp
subq %rbx, %rbp
movq (%r14), %r15
movq 0x8(%r15), %rdi
movq 0x18(%r15), %r12
subq %rdi, %r12
cmpq %rbp, %r12
movq %rbp, %r14
cmovbq %r12, %r14
movq %rbx, %rsi
movq %r14, %rdx
callq 0x6570
addq %r14, 0x8(%r15)
cmpq %rbp, %r12
jae 0x5ab8f
movq %r15, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x6b222
movq %rax, %r14
movq %rsp, %rax
cmpq %rax, %rbx
je 0x5ab9f
movq %rbx, %rdi
callq 0x68a0
xorl %eax, %eax
cmpq %r14, %rbp
setne %al
negl %eax
addq $0x400, %rsp            # imm = 0x400
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq