// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl $0x1, %edi
movl $0xa8, %esi
callq 0x42f0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xd75df
movq $0x0, -0x8(%rbp)
jmp 0xd77c1
callq 0xde480
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
jne 0xd75fd
jmp 0xd7752
movq -0x10(%rbp), %rax
movl $0x1, 0x8c(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x28(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x2c(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x30(%rax)
callq 0xde4a0
movq -0x10(%rbp), %rcx
movq %rax, 0x38(%rcx)
cmpq $0x0, %rax
jne 0xd7645
jmp 0xd7752
movq -0x10(%rbp), %rax
movl $0xffffffff, 0x94(%rax) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movl $0x0, 0x40(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x44(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x48(%rax)
callq 0xde4a0
movq -0x10(%rbp), %rcx
movq %rax, 0x50(%rcx)
cmpq $0x0, %rax
jne 0xd768d
jmp 0xd7752
movq -0x10(%rbp), %rax
movl $0x0, 0x58(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x5c(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x68(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x64(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x60(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x78(%rax)
callq 0xde4a0
movq -0x10(%rbp), %rcx
movq %rax, 0x70(%rcx)
cmpq $0x0, %rax
jne 0xd76e6
jmp 0xd7752
movl $0x18, %edi
callq 0x81f60
movq -0x10(%rbp), %rcx
movq %rax, 0x20(%rcx)
cmpq $0x0, %rax
jne 0xd7700
jmp 0xd7752
movl $0x30, %edi
callq 0x81f60
movq -0x10(%rbp), %rcx
movq %rax, 0x18(%rcx)
cmpq $0x0, %rax
jne 0xd771a
jmp 0xd7752
movl $0x10000, %edi          # imm = 0x10000
callq 0x82320
movq -0x10(%rbp), %rcx
movq %rax, 0x10(%rcx)
cmpq $0x0, %rax
jne 0xd7734
jmp 0xd7752
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xde4c0
cmpl $0x0, %eax
je 0xd7748
jmp 0xd7752
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0xd77c1
movq -0x10(%rbp), %rax
cmpq $0x0, (%rax)
je 0xd7768
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0xde5c0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0xd7780
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x820a0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0xd7798
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x820a0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0xd77b0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x823b0
movq -0x10(%rbp), %rdi
callq 0x45a0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)