// File: karel-brinda[P]ococo/ext/htslib/cram/cram_io.c
// Function: cram_new_slice
cram_slice *cram_new_slice(enum cram_content_type type, int nrecs) {
    cram_slice *s = calloc(1, sizeof(*s));
    if (!s)
	return NULL;

    if (!(s->hdr = (cram_block_slice_hdr *)calloc(1, sizeof(*s->hdr))))
	goto err;
    s->hdr->content_type = type;

    s->hdr_block = NULL;
    s->block = NULL;
    s->block_by_id = NULL;
    s->last_apos = 0;
    if (!(s->crecs = malloc(nrecs * sizeof(cram_record))))  goto err;
    s->cigar = NULL;
    s->cigar_alloc = 0;
    s->ncigar = 0;

    if (!(s->seqs_blk = cram_new_block(EXTERNAL, 0)))       goto err;
    if (!(s->qual_blk = cram_new_block(EXTERNAL, DS_QS)))   goto err;
    if (!(s->name_blk = cram_new_block(EXTERNAL, DS_RN)))   goto err;
    if (!(s->aux_blk  = cram_new_block(EXTERNAL, DS_aux)))  goto err;
    if (!(s->base_blk = cram_new_block(EXTERNAL, DS_IN)))   goto err;
    if (!(s->soft_blk = cram_new_block(EXTERNAL, DS_SC)))   goto err;

    s->features = NULL;
    s->nfeatures = s->afeatures = 0;

#ifndef TN_external
    s->TN = NULL;
    s->nTN = s->aTN = 0;
#endif

    // Volatile keys as we do realloc in dstring
    if (!(s->pair_keys = string_pool_create(8192))) goto err;
    if (!(s->pair[0] = kh_init(m_s2i)))             goto err;
    if (!(s->pair[1] = kh_init(m_s2i)))             goto err;
    
#ifdef BA_external
    s->BA_len = 0;
#endif

    return s;

 err:
    if (s)
	cram_free_slice(s);

    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0xc(%rbp)
movl %esi, -0x10(%rbp)
movl $0x1, %edi
movl $0x100, %esi            # imm = 0x100
callq 0x4370
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x4f6f5
movq $0x0, -0x8(%rbp)
jmp 0x4f915
movl $0x1, %edi
movl $0x48, %esi
callq 0x4370
movq -0x18(%rbp), %rcx
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0x4f716
jmp 0x4f8fd
movl -0xc(%rbp), %ecx
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl %ecx, (%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x20(%rax)
movslq -0x10(%rbp), %rax
imulq $0x70, %rax, %rdi
callq 0x47a0
movq -0x18(%rbp), %rcx
movq %rax, 0x28(%rcx)
cmpq $0x0, %rax
jne 0x4f771
jmp 0x4f8fd
movq -0x18(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x38(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x3c(%rax)
movl $0x4, %edi
xorl %esi, %esi
callq 0x45b10
movq -0x18(%rbp), %rcx
movq %rax, 0x68(%rcx)
cmpq $0x0, %rax
jne 0x4f7b2
jmp 0x4f8fd
movl $0x4, %edi
movl $0xc, %esi
callq 0x45b10
movq -0x18(%rbp), %rcx
movq %rax, 0x70(%rcx)
cmpq $0x0, %rax
jne 0x4f7d4
jmp 0x4f8fd
movl $0x4, %edi
movl $0xb, %esi
callq 0x45b10
movq -0x18(%rbp), %rcx
movq %rax, 0x60(%rcx)
cmpq $0x0, %rax
jne 0x4f7f6
jmp 0x4f8fd
movl $0x4, %edi
movl $0x1, %esi
callq 0x45b10
movq -0x18(%rbp), %rcx
movq %rax, 0x88(%rcx)
cmpq $0x0, %rax
jne 0x4f81b
jmp 0x4f8fd
movl $0x4, %edi
movl $0xd, %esi
callq 0x45b10
movq -0x18(%rbp), %rcx
movq %rax, 0x78(%rcx)
cmpq $0x0, %rax
jne 0x4f83d
jmp 0x4f8fd
movl $0x4, %edi
movl $0xe, %esi
callq 0x45b10
movq -0x18(%rbp), %rcx
movq %rax, 0x80(%rcx)
cmpq $0x0, %rax
jne 0x4f862
jmp 0x4f8fd
movq -0x18(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x4c(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x48(%rax)
movq -0x18(%rbp), %rax
movq $0x0, 0x50(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x5c(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x58(%rax)
movl $0x2000, %edi           # imm = 0x2000
callq 0x5fed0
movq -0x18(%rbp), %rcx
movq %rax, 0xd0(%rcx)
cmpq $0x0, %rax
jne 0x4f8c3
jmp 0x4f8fd
callq 0x4f5c0
movq -0x18(%rbp), %rcx
movq %rax, 0xd8(%rcx)
cmpq $0x0, %rax
jne 0x4f8db
jmp 0x4f8fd
callq 0x4f5c0
movq -0x18(%rbp), %rcx
movq %rax, 0xe0(%rcx)
cmpq $0x0, %rax
jne 0x4f8f3
jmp 0x4f8fd
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4f915
cmpq $0x0, -0x18(%rbp)
je 0x4f90d
movq -0x18(%rbp), %rdi
callq 0x4b920
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
nop