// File: /workspace/github_c_makefile_star2_O1/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 0x8beb4
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq 0x38(%rdi), %r15
testq %r15, %r15
je 0x8bebb
movq 0x70(%r15), %rax
movq %rax, 0x10(%rsp)
movl (%rax), %eax
testl %eax, %eax
movq %rbx, 0x8(%rsp)
movq %r15, 0x18(%rsp)
je 0x8bed1
movq %rax, 0x20(%rsp)
leal -0x1(%rax), %r14d
movb (%rbx), %cl
testb %cl, %cl
je 0x8bed9
leaq 0x1(%rbx), %rax
movl $0x811c9dc5, %ebx       # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %ebx, %ecx
imull $0x1000193, %ecx, %ebx  # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x8be9e
jmp 0x8bede
xorl %edx, %edx
jmp 0x8c101
movq %r14, %rdi
callq 0x866a8
testl %eax, %eax
jne 0x8c0f1
movq 0x38(%r14), %r15
jmp 0x8be6d
xorl %r12d, %r12d
jmp 0x8bf6f
movl $0x811c9dc5, %ebx       # imm = 0x811C9DC5
andl %r14d, %ebx
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rsi
movl $0x1, %r15d
movl %ebx, %r12d
movq %rsi, 0x28(%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 0x8bf53
testb $0x1, %al
jne 0x8bf3b
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movl %r12d, %ecx
movq (%rax,%rcx,8), %rdi
movq 0x8(%rsp), %rsi
callq 0x46c0
movq 0x28(%rsp), %rsi
testl %eax, %eax
je 0x8bf53
addl %r15d, %r12d
andl %r14d, %r12d
incl %r15d
cmpl %ebx, %r12d
jne 0x8bef8
movq 0x20(%rsp), %rax
movl %eax, %r12d
jmp 0x8bf65
movl %ebp, %ecx
shrl %cl, %r13d
testb $0x3, %r13b
movq 0x20(%rsp), %rax
cmovnel %eax, %r12d
movq 0x8(%rsp), %rbx
movq 0x18(%rsp), %r15
cmpl %eax, %r12d
jne 0x8bf7c
movq %rbx, %rdx
jmp 0x8c0f3
movq %rbx, %rdi
callq 0x41d0
movl $0x3e8, %r14d           # imm = 0x3E8
cmpq %r14, %rax
cmovbq %rax, %r14
movl 0x88(%r15), %eax
addq $0x11, %r14
cmpq %rax, %r14
jbe 0x8bfc7
movq 0x80(%r15), %rdi
movq %r14, %rsi
callq 0x4840
testq %rax, %rax
je 0x8c0f1
movq %rax, 0x80(%r15)
movl %r14d, 0x88(%r15)
movq 0x80(%r15), %rdi
movl 0x88(%r15), %esi
movl 0x8c(%r15), %r8d
leal 0x1(%r8), %eax
movl %eax, 0x8c(%r15)
xorl %r13d, %r13d
leaq 0x18875(%rip), %rdx     # 0xa4866
movq %rbx, %rcx
xorl %eax, %eax
callq 0x4800
movq 0x70(%r15), %rax
movq 0x80(%r15), %rdx
movq %rax, 0x10(%rsp)
movl (%rax), %esi
testl %esi, %esi
je 0x8c0e6
movb (%rdx), %cl
testb %cl, %cl
je 0x8c03a
leaq 0x1(%rdx), %rax
movl $0x811c9dc5, %ebx       # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %ebx, %ecx
imull $0x1000193, %ecx, %ebx  # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x8c024
jmp 0x8c03f
movl $0x811c9dc5, %ebx       # imm = 0x811C9DC5
movq %rsi, 0x30(%rsp)
decl %esi
andl %esi, %ebx
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
movl $0x1, %r14d
movl %ebx, %r13d
movl %esi, 0x28(%rsp)
movq %rdi, 0x20(%rsp)
movl %r13d, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %r12d
leal (,%r13,2), %ebp
andl $0x1e, %ebp
movl %r12d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x8c0ca
testb $0x1, %al
jne 0x8c0b2
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
movl %r13d, %ecx
movq (%rax,%rcx,8), %rdi
movq %rdx, %r15
movq %rdx, %rsi
callq 0x46c0
movq 0x20(%rsp), %rdi
movl 0x28(%rsp), %esi
movq %r15, %rdx
testl %eax, %eax
je 0x8c0ca
addl %r14d, %r13d
andl %esi, %r13d
incl %r14d
cmpl %ebx, %r13d
jne 0x8c063
movq 0x30(%rsp), %rsi
movl %esi, %r13d
jmp 0x8c0dc
movl %ebp, %ecx
shrl %cl, %r12d
testb $0x3, %r12b
movq 0x30(%rsp), %rsi
cmovnel %esi, %r13d
movq 0x8(%rsp), %rbx
movq 0x18(%rsp), %r15
cmpl %esi, %r13d
jne 0x8bfc7
jmp 0x8c0f3
xorl %edx, %edx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
movq %rdx, %rax
retq