// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/header.c
// Function: sam_hrecs_remove_line
static int sam_hrecs_remove_line(sam_hrecs_t *hrecs, const char *type_name, sam_hrec_type_t *type_found, int remove_hash) {
    if (!hrecs || !type_name || !type_found)
        return -1;

    khint32_t itype = TYPEKEY(type_name);
    khint_t k = kh_get(sam_hrecs_t, hrecs->h, itype);
    if (k == kh_end(hrecs->h))
        return -1;

    // Remove from global list (remembering it could be the only line)
    if (hrecs->first_line == type_found) {
        hrecs->first_line = (type_found->global_next != type_found
                             ? type_found->global_next : NULL);
    }
    type_found->global_next->global_prev = type_found->global_prev;
    type_found->global_prev->global_next = type_found->global_next;

    /* single element in the list */
    if (type_found->prev == type_found || type_found->next == type_found) {
        kh_del(sam_hrecs_t, hrecs->h, k);
    } else {
        type_found->prev->next = type_found->next;
        type_found->next->prev = type_found->prev;
        if (kh_val(hrecs->h, k) == type_found) { //first element
            kh_val(hrecs->h, k) = type_found->next;
        }
    }

    if (remove_hash && (!strncmp(type_name, "SQ", 2) || !strncmp(type_name, "RG", 2)))
        sam_hrecs_remove_hash_entry(hrecs, itype, type_found);

    sam_hrecs_free_tags(hrecs, type_found->tag);
    pool_free(hrecs->type_pool, type_found);

    hrecs->dirty = 1;

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %r12d
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
testq %rdx, %rdx
sete %al
pushq $-0x1
popq %rbx
orb %cl, %al
jne 0x6afeb
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbp
movzwl (%rsi), %eax
rolw $0x8, %ax
movzwl %ax, %esi
movq (%rdi), %r13
movq %r13, %rdi
movl %esi, 0x4(%rsp)
callq 0x6c54d
cmpl (%r13), %eax
je 0x6afeb
movq 0x10(%r14), %rcx
cmpq %r14, 0x8(%rbp)
movq %rbp, %r9
jne 0x6adca
xorl %edx, %edx
cmpq %r14, %rcx
cmovneq %rcx, %rdx
movq %rdx, 0x8(%r9)
movq 0x18(%r14), %rdx
movq %rdx, 0x18(%rcx)
movq %rcx, 0x10(%rdx)
movq 0x8(%r14), %rcx
cmpq %r14, %rcx
je 0x6ae03
movq (%r14), %rdx
cmpq %r14, %rdx
je 0x6ae03
movq %rdx, (%rcx)
movq (%r14), %rdx
movq %rcx, 0x8(%rdx)
movq 0x20(%r13), %rcx
movl %eax, %eax
cmpq %r14, (%rcx,%rax,8)
jne 0x6ae2c
movq %rdx, (%rcx,%rax,8)
jmp 0x6ae2c
movq 0x10(%r13), %rdx
movl %eax, %esi
shrl $0x4, %esi
movl (%rdx,%rsi,4), %edi
addl %eax, %eax
andl $0x1e, %eax
movl %edi, %r8d
movl %eax, %ecx
shrl %cl, %r8d
testb $0x3, %r8b
jne 0x6ae2c
btsl %eax, %edi
movl %edi, (%rdx,%rsi,4)
decl 0x4(%r13)
testl %r12d, %r12d
je 0x6afc4
movzbl (%r15), %eax
cmpl $0x52, %eax
je 0x6ae53
cmpl $0x53, %eax
jne 0x6afc4
cmpb $0x51, 0x1(%r15)
je 0x6ae5e
jmp 0x6afc4
cmpb $0x47, 0x1(%r15)
jne 0x6afc4
movl 0x4(%rsp), %eax
cmpl $0x5247, %eax           # imm = 0x5247
je 0x6aecc
cmpl $0x5351, %eax           # imm = 0x5351
jne 0x6afc4
leaq 0x20(%r14), %rax
xorl %esi, %esi
xorl %r15d, %r15d
movq (%rax), %rax
testq %rax, %rax
je 0x6afa9
movq 0x8(%rax), %rcx
movzbl (%rcx), %edx
cmpl $0x41, %edx
je 0x6aeb3
cmpl $0x53, %edx
jne 0x6ae7d
cmpb $0x4e, 0x1(%rcx)
jne 0x6ae7d
cmpl $0x2, 0x10(%rax)
jle 0x6b0e0
addq $0x3, %rcx
movq %rcx, %rsi
jmp 0x6ae7d
cmpb $0x4e, 0x1(%rcx)
jne 0x6ae7d
cmpl $0x2, 0x10(%rax)
jle 0x6b0ff
addq $0x3, %rcx
movq %rcx, %r15
jmp 0x6ae7d
leaq 0x20(%r14), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x6afc4
movq 0x8(%rax), %rsi
cmpb $0x49, (%rsi)
jne 0x6aed0
cmpb $0x44, 0x1(%rsi)
jne 0x6aed0
cmpl $0x2, 0x10(%rax)
jle 0x6b0c1
addq $0x3, %rsi
movq 0x50(%r9), %r15
movq %r15, %rdi
movq %r9, %r12
callq 0x6b87d
movq %r12, %r9
cmpl (%r15), %eax
je 0x6afc4
movl %eax, %ebp
movq 0x20(%r15), %rax
movl %ebp, %ecx
movslq (%rax,%rcx,4), %rbx
leaq 0x1(%rbx), %rcx
movl 0x40(%r9), %eax
cmpl %eax, %ecx
jge 0x6af54
movq 0x48(%r9), %rdx
imulq $0x18, %rbx, %rdi
addq %rdx, %rdi
imulq $0x18, %rcx, %rsi
addq %rdx, %rsi
movl %ebx, %ecx
notl %ecx
addl %ecx, %eax
cltq
imulq $0x18, %rax, %rdx
callq 0x4830
movq 0x50(%r12), %r15
movq %r15, %rdi
movl %ebp, %esi
callq 0x6b983
movq %r12, %r9
decl 0x40(%r12)
movq 0x50(%r12), %rax
xorl %edx, %edx
xorl %esi, %esi
movl (%rax), %ecx
cmpq %rcx, %rsi
jae 0x6afc4
movq 0x10(%rax), %rcx
movq %rsi, %rdi
shrq $0x4, %rdi
movl (%rcx,%rdi,4), %edi
movl %edx, %ecx
andb $0x1e, %cl
shrl %cl, %edi
testb $0x3, %dil
jne 0x6afa1
movq 0x20(%rax), %rcx
movl (%rcx,%rsi,4), %edi
cmpl %ebx, %edi
jle 0x6afa1
decl %edi
movl %edi, (%rcx,%rsi,4)
incq %rsi
addl $0x2, %edx
jmp 0x6af6f
testq %rsi, %rsi
je 0x6afc4
movq 0x38(%r9), %rbx
movq %rbx, %rdi
movq %r9, %r13
callq 0x6b87d
movq %r13, %r9
cmpl (%rbx), %eax
jne 0x6affc
movq 0x20(%r14), %rsi
movq %r9, %rdi
movq %r9, %rbx
callq 0x6de53
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0x4924e
movl $0x1, 0x90(%rbx)
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %r12d
movq 0x20(%rbx), %rax
movl %r12d, %ecx
movl (%rax,%rcx,4), %ebp
movslq %ebp, %rax
leaq 0x1(%rax), %rdx
movl 0x28(%r9), %ecx
cmpl %ecx, %edx
jge 0x6b03d
movq 0x30(%r9), %r8
imulq $0x18, %rax, %rdi
addq %r8, %rdi
imulq $0x18, %rdx, %rsi
addq %r8, %rsi
notl %eax
addl %eax, %ecx
movslq %ecx, %rax
imulq $0x18, %rax, %rdx
callq 0x4830
movq %r13, %r9
testq %r15, %r15
je 0x6b052
movq %r9, %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x6d616
movq %r13, %r9
movq 0x38(%r9), %rdi
movl %r12d, %esi
callq 0x6b983
movq %r13, %r9
decl 0x28(%r13)
movl 0x94(%r13), %eax
testl %eax, %eax
js 0x6b074
cmpl %ebp, %eax
jle 0x6b07b
movl %ebp, 0x94(%r9)
movq 0x38(%r9), %rax
xorl %edx, %edx
xorl %esi, %esi
movl (%rax), %ecx
cmpq %rcx, %rsi
jae 0x6afc4
movq 0x10(%rax), %rcx
movq %rsi, %rdi
shrq $0x4, %rdi
movl (%rcx,%rdi,4), %edi
movl %edx, %ecx
andb $0x1e, %cl
shrl %cl, %edi
testb $0x3, %dil
jne 0x6b0b9
movq 0x20(%rax), %rcx
movl (%rcx,%rsi,4), %edi
cmpl %ebp, %edi
jle 0x6b0b9
decl %edi
movl %edi, (%rcx,%rsi,4)
incq %rsi
addl $0x2, %edx
jmp 0x6b083
leaq 0x18e9d(%rip), %rdi     # 0x83f65
leaq 0x1868c(%rip), %rsi     # 0x8375b
leaq 0x18c73(%rip), %rcx     # 0x83d49
movl $0x1d0, %edx            # imm = 0x1D0
callq 0x42f0
leaq 0x18e7e(%rip), %rdi     # 0x83f65
leaq 0x1866d(%rip), %rsi     # 0x8375b
leaq 0x18c54(%rip), %rcx     # 0x83d49
movl $0x1aa, %edx            # imm = 0x1AA
callq 0x42f0
leaq 0x18e5f(%rip), %rdi     # 0x83f65
leaq 0x1864e(%rip), %rsi     # 0x8375b
leaq 0x18c35(%rip), %rcx     # 0x83d49
movl $0x1ad, %edx            # imm = 0x1AD
callq 0x42f0