// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/header.c
// Function: sam_hdr_pg_id
const char *sam_hdr_pg_id(sam_hdr_t *bh, const char *name) {
    sam_hrecs_t *hrecs;
    size_t name_len;
    const size_t name_extra = 17;
    if (!bh || !name)
        return NULL;

    if (!(hrecs = bh->hrecs)) {
        if (sam_hdr_fill_hrecs(bh) != 0)
            return NULL;
        hrecs = bh->hrecs;
    }

    khint_t k = kh_get(m_s2i, hrecs->pg_hash, name);
    if (k == kh_end(hrecs->pg_hash))
        return name;

    name_len = strlen(name);
    if (name_len > 1000) name_len = 1000;
    if (hrecs->ID_buf_sz < name_len + name_extra) {
        char *new_ID_buf = realloc(hrecs->ID_buf, name_len + name_extra);
        if (new_ID_buf == NULL)
            return NULL;
        hrecs->ID_buf = new_ID_buf;
        hrecs->ID_buf_sz = name_len + name_extra;
    }

    do {
        snprintf(hrecs->ID_buf, hrecs->ID_buf_sz, "%.1000s.%d", name, hrecs->ID_cnt++);
        k = kh_get(m_s2i, hrecs->pg_hash, hrecs->ID_buf);
    } while (k != kh_end(hrecs->pg_hash));

    return hrecs->ID_buf;
}

// Assembly:
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
jne 0x89571
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x38(%rdi), %r13
testq %r13, %r13
je 0x89578
movq 0x70(%r13), %rax
movq %rax, 0x8(%rsp)
movl (%rax), %eax
testl %eax, %eax
movq %rbx, 0x10(%rsp)
movq %r13, 0x28(%rsp)
je 0x8958f
leal -0x1(%rax), %edx
movb (%rbx), %cl
testb %cl, %cl
movq %rax, 0x18(%rsp)
je 0x89597
leaq 0x1(%rbx), %rax
movl $0x811c9dc5, %r14d      # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %r14d, %ecx
imull $0x1000193, %ecx, %r14d # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x89559
jmp 0x8959d
xorl %edx, %edx
jmp 0x89645
movq %r14, %rdi
callq 0x8413e
testl %eax, %eax
je 0x897c5
xorl %edx, %edx
jmp 0x89637
xorl %r12d, %r12d
jmp 0x8962f
movl $0x811c9dc5, %r14d      # imm = 0x811C9DC5
andl %edx, %r14d
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rsi
movl $0x1, %r15d
movl %r14d, %r12d
movq %rsi, 0x20(%rsp)
movl %r12d, %eax
shrl $0x4, %eax
movl (%rsi,%rax,4), %r13d
leal (%r12,%r12), %ebp
andl $0x1e, %ebp
movl %r13d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x89613
testb $0x1, %al
jne 0x895fe
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movl %r12d, %ecx
movq (%rax,%rcx,8), %rdi
movq 0x10(%rsp), %rsi
movl %edx, %ebx
callq 0x46c0
movq 0x20(%rsp), %rsi
movl %ebx, %edx
testl %eax, %eax
je 0x89613
addl %r15d, %r12d
andl %edx, %r12d
incl %r15d
cmpl %r14d, %r12d
jne 0x895b7
movq 0x10(%rsp), %rdx
jmp 0x89637
movl %ebp, %ecx
shrl %cl, %r13d
testb $0x3, %r13b
movq 0x18(%rsp), %rax
cmovnel %eax, %r12d
movq 0x10(%rsp), %rbx
movq 0x28(%rsp), %r13
cmpl %eax, %r12d
jne 0x89649
movq %rbx, %rdx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
movq %rdx, %rax
retq
movq %rbx, %rdi
callq 0x41d0
movl $0x3e8, %r15d           # imm = 0x3E8
cmpq %r15, %rax
cmovbq %rax, %r15
movl 0x88(%r13), %eax
addq $0x11, %r15
movq 0x80(%r13), %rdx
cmpq %rax, %r15
jbe 0x8969a
movq %rdx, %rdi
movq %r15, %rsi
callq 0x4840
testq %rax, %rax
je 0x89588
movq %rax, %rdx
movq %rax, 0x80(%r13)
movl %r15d, 0x88(%r13)
leaq 0x18944(%rip), %r14     # 0xa1fe5
movl 0x88(%r13), %esi
movl 0x8c(%r13), %r8d
leal 0x1(%r8), %eax
movl %eax, 0x8c(%r13)
xorl %r12d, %r12d
movq %rdx, %rdi
movq %r14, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x4800
movq 0x70(%r13), %rax
movq 0x80(%r13), %rdx
movq %rax, 0x8(%rsp)
movl (%rax), %esi
testl %esi, %esi
je 0x897b7
movb (%rdx), %cl
testb %cl, %cl
je 0x8970f
leaq 0x1(%rdx), %rax
movl $0x811c9dc5, %r13d      # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %r13d, %ecx
imull $0x1000193, %ecx, %r13d # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x896f7
jmp 0x89715
movl $0x811c9dc5, %r13d      # imm = 0x811C9DC5
movq %rsi, 0x30(%rsp)
decl %esi
andl %esi, %r13d
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
movl $0x1, %r14d
movl %r13d, %r12d
movl %esi, 0x20(%rsp)
movq %rdi, 0x18(%rsp)
movl %r12d, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %ebx
leal (%r12,%r12), %ebp
andl $0x1e, %ebp
movl %ebx, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x89796
testb $0x1, %al
jne 0x89783
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movl %r12d, %ecx
movq (%rax,%rcx,8), %rdi
movq %rdx, %rsi
movq %rdx, %r15
callq 0x46c0
movq 0x18(%rsp), %rdi
movl 0x20(%rsp), %esi
movq %r15, %rdx
testl %eax, %eax
je 0x89796
addl %r14d, %r12d
andl %esi, %r12d
incl %r14d
cmpl %r13d, %r12d
jne 0x8973a
jmp 0x89637
movl %ebp, %ecx
shrl %cl, %ebx
testb $0x3, %bl
movq 0x30(%rsp), %rsi
cmovnel %esi, %r12d
movq 0x10(%rsp), %rbx
movq 0x28(%rsp), %r13
leaq 0x1882e(%rip), %r14     # 0xa1fe5
cmpl %esi, %r12d
jne 0x896a1
jmp 0x89637
movq 0x38(%r14), %r13
jmp 0x89528