// File: karel-brinda[P]ococo/ext/htslib/cram/sam_header.c
// Function: sam_hdr_new
SAM_hdr *sam_hdr_new() {
    SAM_hdr *sh = calloc(1, sizeof(*sh));

    if (!sh)
	return NULL;
    
    sh->h = kh_init(sam_hdr);
    if (!sh->h)
	goto err;

    sh->ID_cnt = 1;
    sh->ref_count = 1;

    sh->nref = 0;
    sh->ref  = NULL;
    if (!(sh->ref_hash = kh_init(m_s2i)))
	goto err;

    sh->nrg = 0;
    sh->rg  = NULL;
    if (!(sh->rg_hash = kh_init(m_s2i)))
	goto err;

    sh->npg = 0;
    sh->pg  = NULL;
    sh->npg_end = sh->npg_end_alloc = 0;
    sh->pg_end = NULL;
    if (!(sh->pg_hash = kh_init(m_s2i)))
	goto err;

    KS_INIT(&sh->text);

    if (!(sh->tag_pool = pool_create(sizeof(SAM_hdr_tag))))
	goto err;

    if (!(sh->type_pool = pool_create(sizeof(SAM_hdr_type))))
	goto err;

    if (!(sh->str_pool = string_pool_create(8192)))
	goto err;

    return sh;

 err:
    if (sh->h)
	kh_destroy(sam_hdr, sh->h);

    if (sh->tag_pool)
	pool_destroy(sh->tag_pool);

    if (sh->type_pool)
	pool_destroy(sh->type_pool);

    if (sh->str_pool)
	string_pool_destroy(sh->str_pool);

    free(sh);

    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl $0x1, %edi
movl $0x4a0, %esi            # imm = 0x4A0
callq 0x4370
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x5e07f
movq $0x0, -0x8(%rbp)
jmp 0x5e259
callq 0x5e270
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x5e09f
jmp 0x5e1e8
movq -0x10(%rbp), %rax
movl $0x1, 0x494(%rax)
movq -0x10(%rbp), %rax
movl $0x1, 0x498(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x38(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x40(%rax)
callq 0x5e290
movq -0x10(%rbp), %rcx
movq %rax, 0x48(%rcx)
cmpq $0x0, %rax
jne 0x5e0ea
jmp 0x5e1e8
movq -0x10(%rbp), %rax
movl $0x0, 0x50(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x58(%rax)
callq 0x5e290
movq -0x10(%rbp), %rcx
movq %rax, 0x60(%rcx)
cmpq $0x0, %rax
jne 0x5e119
jmp 0x5e1e8
movq -0x10(%rbp), %rax
movl $0x0, 0x68(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x78(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x70(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x6c(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x88(%rax)
callq 0x5e290
movq -0x10(%rbp), %rcx
movq %rax, 0x80(%rcx)
cmpq $0x0, %rax
jne 0x5e16d
jmp 0x5e1e8
movq -0x10(%rbp), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x10(%rax)
movl $0x18, %edi
callq 0x75d40
movq -0x10(%rbp), %rcx
movq %rax, 0x30(%rcx)
cmpq $0x0, %rax
jne 0x5e1aa
jmp 0x5e1e8
movl $0x20, %edi
callq 0x75d40
movq -0x10(%rbp), %rcx
movq %rax, 0x28(%rcx)
cmpq $0x0, %rax
jne 0x5e1c4
jmp 0x5e1e8
movl $0x2000, %edi           # imm = 0x2000
callq 0x5fed0
movq -0x10(%rbp), %rcx
movq %rax, 0x20(%rcx)
cmpq $0x0, %rax
jne 0x5e1de
jmp 0x5e1e8
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x5e259
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x5e200
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x5e2b0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x5e218
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x75e80
movq -0x10(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x5e230
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x75e80
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x5e248
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x5ff50
movq -0x10(%rbp), %rdi
callq 0x46a0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)