// File: /workspace/github_c_makefile_star2_O3/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 %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl $0x1, %edi
movl $0xa8, %esi
callq 0x4300
testq %rax, %rax
je 0x8474d
movq %rax, %rbx
movl $0x1, %edi
movl $0x28, %esi
callq 0x4300
movq %rax, (%rbx)
testq %rax, %rax
je 0x84737
movq %rax, %r14
movl $0x1, 0x8c(%rbx)
movl $0x1, %edi
movl $0x28, %esi
callq 0x4300
movq %rax, 0x38(%rbx)
testq %rax, %rax
je 0x846f0
movl $0xffffffff, 0x94(%rbx) # imm = 0xFFFFFFFF
movl $0x1, %edi
movl $0x28, %esi
callq 0x4300
movq %rax, 0x50(%rbx)
testq %rax, %rax
je 0x846f0
movl $0x1, %edi
movl $0x28, %esi
callq 0x4300
movq %rax, 0x70(%rbx)
testq %rax, %rax
je 0x846f0
movl $0x18, %edi
callq 0x57cec
movq %rax, 0x20(%rbx)
testq %rax, %rax
je 0x846f0
movq %rax, %r12
movl $0x30, %edi
callq 0x57cec
movq %rax, 0x18(%rbx)
testq %rax, %rax
je 0x8475e
movq %rax, %r15
movl $0x10000, %edi          # imm = 0x10000
callq 0x57e90
movq %rax, 0x10(%rbx)
testq %rax, %rax
je 0x846f6
movl $0x5, 0x9c(%rbx)
movl $0x5, %edi
movl $0x3, %esi
callq 0x4300
movq %rax, 0xa0(%rbx)
testq %rax, %rax
je 0x846f6
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 0x8474f
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x18(%r14), %rdi
callq 0x45c0
movq 0x10(%r14), %rdi
callq 0x45c0
movq 0x20(%r14), %rdi
callq 0x45c0
movq %r14, %rdi
callq 0x45c0
testq %r12, %r12
je 0x8472a
movq %r12, %rdi
callq 0x57d65
movq 0x18(%rbx), %r15
testq %r15, %r15
je 0x84737
movq %r15, %rdi
callq 0x57d65
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x84745
callq 0x57ec7
movq %rbx, %rdi
callq 0x45c0
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
xorl %r15d, %r15d
jmp 0x846f6