// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/header.c
// Function: sam_hdr_remove_lines
int sam_hdr_remove_lines(sam_hdr_t *bh, const char *type, const char *id, void *vrh) {
    sam_hrecs_t *hrecs;
    rmhash_t *rh = (rmhash_t *)vrh;

    if (!bh || !type)
        return -1;
    if (!rh) // remove all lines
        return sam_hdr_remove_except(bh, type, NULL, NULL);
    if (!id)
        return -1;

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

    khint_t k = kh_get(sam_hrecs_t, hrecs->h, TYPEKEY(type));
    if (k == kh_end(hrecs->h)) // nothing to remove from
        return 0;

    sam_hrec_type_t *head = kh_val(hrecs->h, k);
    if (!head) {
        hts_log_error("Header inconsistency");
        return -1;
    }

    int ret = 0;
    sam_hrec_type_t *step = head->next;
    while (step != head) {
        sam_hrec_tag_t *tag = sam_hrecs_find_key(step, id, NULL);
        if (tag && tag->str && tag->len >= 3) {
           k = kh_get(rm, rh, tag->str+3);
           if (k == kh_end(rh)) { // value is not in the hash table, so remove
               sam_hrec_type_t *to_remove = step;
               step = step->next;
               ret |= sam_hrecs_remove_line(hrecs, type, to_remove, 0);
           } else {
               step = step->next;
           }
        } else { // tag is not on the line, so skip to next line
            step = step->next;
        }
    }

    // process the first line
    sam_hrec_tag_t * tag = sam_hrecs_find_key(head, id, NULL);
    if (tag && tag->str && tag->len >= 3) {
       k = kh_get(rm, rh, tag->str+3);
       if (k == kh_end(rh)) { // value is not in the hash table, so remove
           sam_hrec_type_t *to_remove = head;
           head = head->next;
           ret |= sam_hrecs_remove_line(hrecs, type, to_remove, 0);
       }
    }

    /* if RG or SQ, delete then rebuild the hashes (as it is faster
       to rebuild than delete one by one).
    */

    if ((strncmp(type, "SQ", 2) == 0) || (strncmp(type, "RG", 2) == 0)) {
        if (rebuild_hash(hrecs, type)) {
            return -1;
        }
    }

    if (!ret && hrecs->dirty)
        redact_header_text(bh);

    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0xdc981
cmpq $0x0, -0x18(%rbp)
jne 0xdc98d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xdcc2e
cmpq $0x0, -0x38(%rbp)
jne 0xdc9b0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0xdc480
movl %eax, -0x4(%rbp)
jmp 0xdcc2e
cmpq $0x0, -0x20(%rbp)
jne 0xdc9c3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xdcc2e
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0xdc9fb
movq -0x10(%rbp), %rdi
callq 0xd7490
cmpl $0x0, %eax
je 0xdc9ef
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xdcc2e
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x80(%rbp)
movq -0x18(%rbp), %rdi
callq 0xdabd0
movq -0x80(%rbp), %rdi
movl %eax, %esi
callq 0xdc6d0
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
cmpl (%rcx), %eax
jne 0xdca37
movl $0x0, -0x4(%rbp)
jmp 0xdcc2e
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq 0x20(%rax), %rax
movl -0x3c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0xdca7a
movl $0x1, %edi
leaq 0x1b7d1(%rip), %rsi     # 0xf8231
leaq 0x1b7df(%rip), %rdx     # 0xf8246
movb $0x0, %al
callq 0x1b030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xdcc2e
movl $0x0, -0x4c(%rbp)
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x48(%rbp), %rax
je 0xdcb39
movq -0x58(%rbp), %rdi
movq -0x20(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xdaf50
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0xdcb29
movq -0x60(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xdcb29
movq -0x60(%rbp), %rax
cmpl $0x3, 0x10(%rax)
jl 0xdcb29
movq -0x38(%rbp), %rdi
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0x3, %rsi
callq 0xdcc40
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl (%rcx), %eax
jne 0xdcb1c
movq -0x58(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x58(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x68(%rbp), %rdx
xorl %ecx, %ecx
callq 0xda1c0
orl -0x4c(%rbp), %eax
movl %eax, -0x4c(%rbp)
jmp 0xdcb27
movq -0x58(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0xdcb34
movq -0x58(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0xdca8c
movq -0x48(%rbp), %rdi
movq -0x20(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0xdaf50
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0xdcbbb
movq -0x70(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0xdcbbb
movq -0x70(%rbp), %rax
cmpl $0x3, 0x10(%rax)
jl 0xdcbbb
movq -0x38(%rbp), %rdi
movq -0x70(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0x3, %rsi
callq 0xdcc40
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl (%rcx), %eax
jne 0xdcbb9
movq -0x48(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x78(%rbp), %rdx
xorl %ecx, %ecx
callq 0xda1c0
orl -0x4c(%rbp), %eax
movl %eax, -0x4c(%rbp)
jmp 0xdcbbb
movq -0x18(%rbp), %rdi
leaq 0x15b26(%rip), %rsi     # 0xf26ec
movl $0x2, %edx
callq 0x4200
cmpl $0x0, %eax
je 0xdcbef
movq -0x18(%rbp), %rdi
leaq 0x15a36(%rip), %rsi     # 0xf2616
movl $0x2, %edx
callq 0x4200
cmpl $0x0, %eax
jne 0xdcc0c
movq -0x30(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xdc810
cmpl $0x0, %eax
je 0xdcc0a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xdcc2e
jmp 0xdcc0c
cmpl $0x0, -0x4c(%rbp)
jne 0xdcc28
movq -0x30(%rbp), %rax
cmpl $0x0, 0x90(%rax)
je 0xdcc28
movq -0x10(%rbp), %rdi
callq 0xd8e20
movl -0x4c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)