// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/header.c
// Function: sam_hrecs_new
sam_hrecs_t *sam_hrecs_new(void) {
    sam_hrecs_t *hrecs = calloc(1, sizeof(*hrecs));

    if (!hrecs)
        return NULL;

    hrecs->h = kh_init(sam_hrecs_t);
    if (!hrecs->h)
        goto err;

    hrecs->ID_cnt = 1;

    hrecs->nref = 0;
    hrecs->ref_sz = 0;
    hrecs->ref  = NULL;
    if (!(hrecs->ref_hash = kh_init(m_s2i)))
        goto err;
    hrecs->refs_changed = -1;

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

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

    if (!(hrecs->tag_pool = pool_create(sizeof(sam_hrec_tag_t))))
        goto err;

    if (!(hrecs->type_pool = pool_create(sizeof(sam_hrec_type_t))))
        goto err;

    if (!(hrecs->str_pool = string_pool_create(65536)))
        goto err;

    if (sam_hrecs_init_type_order(hrecs, NULL))
        goto err;

    return hrecs;

err:
    if (hrecs->h)
        kh_destroy(sam_hrecs_t, hrecs->h);

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

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

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

    free(hrecs);

    return NULL;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl $0x1, %edi
movl $0xa8, %esi
callq 0x4300
testq %rax, %rax
je 0x86cc1
movq %rax, %rbx
movl $0x1, %edi
movl $0x28, %esi
callq 0x4300
movq %rax, (%rbx)
testq %rax, %rax
je 0x86c64
movl $0x1, 0x8c(%rbx)
movl $0x1, %edi
movl $0x28, %esi
callq 0x4300
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rbx)
movq %rax, 0x38(%rbx)
testq %rax, %rax
je 0x86c64
movl $0xffffffff, 0x94(%rbx) # imm = 0xFFFFFFFF
movl $0x1, %edi
movl $0x28, %esi
callq 0x4300
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rbx)
movq %rax, 0x50(%rbx)
testq %rax, %rax
je 0x86c64
xorl %r14d, %r14d
movq %r14, 0x78(%rbx)
movl $0x1, %edi
movl $0x28, %esi
callq 0x4300
xorps %xmm0, %xmm0
movups %xmm0, 0x58(%rbx)
movq %r14, 0x68(%rbx)
movq %rax, 0x70(%rbx)
testq %rax, %rax
je 0x86c64
movl $0x18, %edi
callq 0x5a760
movq %rax, 0x20(%rbx)
testq %rax, %rax
je 0x86c64
movl $0x30, %edi
callq 0x5a760
movq %rax, 0x18(%rbx)
testq %rax, %rax
je 0x86c64
movl $0x10000, %edi          # imm = 0x10000
callq 0x5a90c
movq %rax, 0x10(%rbx)
testq %rax, %rax
je 0x86c64
movl $0x5, 0x9c(%rbx)
movl $0x5, %edi
movl $0x3, %esi
callq 0x4300
movq %rax, 0xa0(%rbx)
testq %rax, %rax
je 0x86c64
movw $0x4448, (%rax)         # imm = 0x4448
movw $0x5153, 0x3(%rax)      # imm = 0x5153
movw $0x4752, 0x6(%rax)      # imm = 0x4752
movw $0x4750, 0x9(%rax)      # imm = 0x4750
movw $0x4f43, 0xc(%rax)      # imm = 0x4F43
jmp 0x86cc3
movq (%rbx), %r14
testq %r14, %r14
je 0x86c8f
movq 0x18(%r14), %rdi
callq 0x45c0
movq 0x10(%r14), %rdi
callq 0x45c0
movq 0x20(%r14), %rdi
callq 0x45c0
movq %r14, %rdi
callq 0x45c0
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x86c9d
callq 0x5a7dd
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x86cab
callq 0x5a7dd
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x86cb9
callq 0x5a947
movq %rbx, %rdi
callq 0x45c0
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq