// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/hts_expr.c
// Function: eq_expr
static int eq_expr(hts_filter_t *filt, void *data, hts_expr_sym_func *fn,
                   char *str, char **end, hts_expr_val_t *res) {
    if (cmp_expr(filt, data, fn, str, end, res)) return -1;

    str = ws(*end);

    int err = 0, eq_done = 0;
    hts_expr_val_t val = HTS_EXPR_VAL_INIT;

    // numeric vs numeric comparison is as expected
    // string vs string comparison is as expected
    // numeric vs string is false
    if (str[0] == '=' && str[1] == '=') {
        eq_done = 1;
        if ((err = eq_expr(filt, data, fn, str+2, end, &val))) {
            res->is_true = res->d = 0;
        } else {
            if (!hts_expr_val_exists(res) || !hts_expr_val_exists(&val)) {
                hts_expr_val_undef(res);
            } else {
                res->is_true = res->d = res->is_str
                    ? (res->s.s && val.s.s ?strcmp(res->s.s, val.s.s)==0 :0)
                    : !res->is_str && !val.is_str && res->d == val.d;
            }
        }
        res->is_str = 0;

    } else if (str[0] == '!' && str[1] == '=') {
        eq_done = 1;
        if ((err = eq_expr(filt, data, fn, str+2, end, &val))) {
            res->is_true = res->d = 0;
        } else {
            if (!hts_expr_val_exists(res) || !hts_expr_val_exists(&val)) {
                hts_expr_val_undef(res);
            } else {
                res->is_true = res->d = res->is_str
                    ? (res->s.s && val.s.s ?strcmp(res->s.s, val.s.s) != 0 :1)
                    : res->is_str != val.is_str || res->d != val.d;
            }
        }
        res->is_str = 0;

    } else if ((str[0] == '=' && str[1] == '~') ||
               (str[0] == '!' && str[1] == '~')) {
        eq_done = 1;
        err = eq_expr(filt, data, fn, str+2, end, &val);
        if (!val.is_str || !res->is_str) {
            hts_expr_val_free(&val);
            return -1;
        }
        if (val.s.s && res->s.s && val.is_true >= 0 && res->is_true >= 0) {
            regex_t preg_, *preg;
            if (filt->curr_regex >= filt->max_regex) {
                // Compile regex if not seen before
                if (filt->curr_regex >= MAX_REGEX) {
                    preg = &preg_;
                } else {
                    preg = &filt->preg[filt->curr_regex];
                    filt->max_regex++;
                }

                int ec = regcomp(preg, val.s.s, REG_EXTENDED | REG_NOSUB);
                if (ec != 0) {
                    char errbuf[1024];
                    regerror(ec, preg, errbuf, 1024);
                    fprintf(stderr, "Failed regex: %.1024s\n", errbuf);
                    hts_expr_val_free(&val);
                    return -1;
                }
            } else {
                preg = &filt->preg[filt->curr_regex];
            }
            res->is_true = res->d = regexec(preg, res->s.s, 0, NULL, 0) == 0
                ? *str == '='  // matcn
                : *str == '!'; // no-match
            if (preg == &preg_)
                regfree(preg);

            filt->curr_regex++;
        } else {
            // nul regexp or input is considered false
            res->is_true = 0;
        }
        res->is_str = 0;
    }

    if (eq_done && ((!hts_expr_val_exists(&val)) || !hts_expr_val_exists(res)))
        hts_expr_val_undef(res);
    hts_expr_val_free(&val);

    return err ? -1 : 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4e0, %rsp            # imm = 0x4E0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
movq -0x38(%rbp), %r9
callq 0x2a7b0
cmpl $0x0, %eax
je 0x2a151
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2a6e8
movq -0x30(%rbp), %rax
movq (%rax), %rdi
callq 0x29c80
movq %rax, -0x28(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x4250
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3d, %eax
jne 0x2a2e3
movq -0x28(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x3d, %eax
jne 0x2a2e3
movl $0x1, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
addq $0x2, %rcx
movq -0x30(%rbp), %r8
leaq -0x68(%rbp), %r9
callq 0x2a100
movl %eax, -0x3c(%rbp)
cmpl $0x0, %eax
je 0x2a1e9
movq -0x38(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x20(%rax)
movq -0x38(%rbp), %rax
movb $0x0, 0x1(%rax)
jmp 0x2a2d7
movq -0x38(%rbp), %rdi
callq 0x29ce0
cmpl $0x0, %eax
je 0x2a205
leaq -0x68(%rbp), %rdi
callq 0x29ce0
cmpl $0x0, %eax
jne 0x2a213
movq -0x38(%rbp), %rdi
callq 0x2a750
jmp 0x2a2d5
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x2a26d
movq -0x38(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x2a255
cmpq $0x0, -0x50(%rbp)
je 0x2a255
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x50(%rbp), %rsi
callq 0x4690
cmpl $0x0, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4c4(%rbp)
jmp 0x2a25f
xorl %eax, %eax
movl %eax, -0x4c4(%rbp)
jmp 0x2a25f
movl -0x4c4(%rbp), %eax
movl %eax, -0x4c8(%rbp)
jmp 0x2a2b9
movq -0x38(%rbp), %rcx
xorl %eax, %eax
cmpb $0x0, (%rcx)
movb %al, -0x4c9(%rbp)
jne 0x2a2a8
xorl %eax, %eax
cmpb $0x0, -0x68(%rbp)
movb %al, -0x4c9(%rbp)
jne 0x2a2a8
movq -0x38(%rbp), %rax
movsd 0x20(%rax), %xmm0
ucomisd -0x48(%rbp), %xmm0
sete %al
setnp %cl
andb %cl, %al
movb %al, -0x4c9(%rbp)
movb -0x4c9(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4c8(%rbp)
movl -0x4c8(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq -0x38(%rbp), %rcx
movsd %xmm0, 0x20(%rcx)
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, 0x1(%rax)
jmp 0x2a2d7
movq -0x38(%rbp), %rax
movb $0x0, (%rax)
jmp 0x2a6a1
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x21, %eax
jne 0x2a442
movq -0x28(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x3d, %eax
jne 0x2a442
movl $0x1, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
addq $0x2, %rcx
movq -0x30(%rbp), %r8
leaq -0x68(%rbp), %r9
callq 0x2a100
movl %eax, -0x3c(%rbp)
cmpl $0x0, %eax
je 0x2a34d
movq -0x38(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, 0x20(%rax)
movq -0x38(%rbp), %rax
movb $0x0, 0x1(%rax)
jmp 0x2a436
movq -0x38(%rbp), %rdi
callq 0x29ce0
cmpl $0x0, %eax
je 0x2a369
leaq -0x68(%rbp), %rdi
callq 0x29ce0
cmpl $0x0, %eax
jne 0x2a377
movq -0x38(%rbp), %rdi
callq 0x2a750
jmp 0x2a434
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x2a3d4
movq -0x38(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x2a3b9
cmpq $0x0, -0x50(%rbp)
je 0x2a3b9
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x50(%rbp), %rsi
callq 0x4690
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4d0(%rbp)
jmp 0x2a3c6
movl $0x1, %eax
movl %eax, -0x4d0(%rbp)
jmp 0x2a3c6
movl -0x4d0(%rbp), %eax
movl %eax, -0x4d4(%rbp)
jmp 0x2a418
movq -0x38(%rbp), %rax
movsbl (%rax), %ecx
movsbl -0x68(%rbp), %edx
movb $0x1, %al
cmpl %edx, %ecx
movb %al, -0x4d5(%rbp)
jne 0x2a407
movq -0x38(%rbp), %rax
movsd 0x20(%rax), %xmm0
ucomisd -0x48(%rbp), %xmm0
setne %al
setp %cl
orb %cl, %al
movb %al, -0x4d5(%rbp)
movb -0x4d5(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4d4(%rbp)
movl -0x4d4(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq -0x38(%rbp), %rcx
movsd %xmm0, 0x20(%rcx)
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, 0x1(%rax)
jmp 0x2a436
movq -0x38(%rbp), %rax
movb $0x0, (%rax)
jmp 0x2a69f
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3d, %eax
jne 0x2a45b
movq -0x28(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x7e, %eax
je 0x2a47c
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x21, %eax
jne 0x2a69d
movq -0x28(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x7e, %eax
jne 0x2a69d
movl $0x1, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
addq $0x2, %rcx
movq -0x30(%rbp), %r8
leaq -0x68(%rbp), %r9
callq 0x2a100
movl %eax, -0x3c(%rbp)
cmpb $0x0, -0x68(%rbp)
je 0x2a4b6
movq -0x38(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x2a4cb
leaq -0x68(%rbp), %rdi
callq 0x2a790
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2a6e8
cmpq $0x0, -0x50(%rbp)
je 0x2a68e
movq -0x38(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x2a68e
movsbl -0x67(%rbp), %eax
cmpl $0x0, %eax
jl 0x2a68e
movq -0x38(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jl 0x2a68e
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jl 0x2a5d4
movq -0x10(%rbp), %rax
cmpl $0xa, 0xc(%rax)
jl 0x2a531
leaq -0xa8(%rbp), %rax
movq %rax, -0xb0(%rbp)
jmp 0x2a55c
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq -0x10(%rbp), %rcx
movslq 0xc(%rcx), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0xb0(%rbp)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
movq -0xb0(%rbp), %rdi
movq -0x50(%rbp), %rsi
movl $0x9, %edx
callq 0x4550
movl %eax, -0xb4(%rbp)
cmpl $0x0, -0xb4(%rbp)
je 0x2a5d2
movl -0xb4(%rbp), %edi
movq -0xb0(%rbp), %rsi
leaq -0x4c0(%rbp), %rdx
movl $0x400, %ecx            # imm = 0x400
callq 0x4210
movq 0xe2a3b(%rip), %rax     # 0x10cfe0
movq (%rax), %rdi
leaq -0x4c0(%rbp), %rdx
leaq 0xc69cb(%rip), %rsi     # 0xf0f81
movb $0x0, %al
callq 0x46d0
leaq -0x68(%rbp), %rdi
callq 0x2a790
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2a6e8
jmp 0x2a5f2
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq -0x10(%rbp), %rcx
movslq 0xc(%rcx), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rsi
xorl %eax, %eax
movl %eax, %ecx
xorl %r8d, %r8d
movq %rcx, %rdx
callq 0x45f0
cmpl $0x0, %eax
jne 0x2a62f
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3d, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4dc(%rbp)
jmp 0x2a647
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x21, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4dc(%rbp)
movl -0x4dc(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq -0x38(%rbp), %rcx
movsd %xmm0, 0x20(%rcx)
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, 0x1(%rax)
leaq -0xa8(%rbp), %rax
cmpq %rax, -0xb0(%rbp)
jne 0x2a67f
movq -0xb0(%rbp), %rdi
callq 0x44b0
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
jmp 0x2a696
movq -0x38(%rbp), %rax
movb $0x0, 0x1(%rax)
movq -0x38(%rbp), %rax
movb $0x0, (%rax)
jmp 0x2a69f
jmp 0x2a6a1
cmpl $0x0, -0x40(%rbp)
je 0x2a6cc
leaq -0x68(%rbp), %rdi
callq 0x29ce0
cmpl $0x0, %eax
je 0x2a6c3
movq -0x38(%rbp), %rdi
callq 0x29ce0
cmpl $0x0, %eax
jne 0x2a6cc
movq -0x38(%rbp), %rdi
callq 0x2a750
leaq -0x68(%rbp), %rdi
callq 0x2a790
movl -0x3c(%rbp), %edx
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x4e0, %rsp            # imm = 0x4E0
popq %rbp
retq
nopw %cs:(%rax,%rax)