// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x488, %rsp            # imm = 0x488
movq %r9, %r15
movq %r8, %r12
movq %rdx, %r13
movq %rsi, %rbx
movq %rdi, %r14
callq 0x1dc49
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x1db9c
movq %r15, 0x8(%rsp)
movq (%r12), %r15
addq $0x2, %r15
movzbl -0x2(%r15), %eax
cmpl $0x20, %eax
je 0x1d771
cmpl $0x9, %eax
jne 0x1d776
incq %r15
jmp 0x1d762
xorpd %xmm0, %xmm0
movapd %xmm0, 0x20(%rsp)
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x30(%rsp)
movb -0x2(%r15), %al
cmpb $0x3d, %al
jne 0x1d86b
cmpb $0x3d, -0x1(%r15)
jne 0x1d86b
leaq 0x10(%rsp), %r9
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r15, %rcx
movq %r12, %r8
callq 0x1d723
testl %eax, %eax
jne 0x1d897
movl %eax, %r12d
movq 0x8(%rsp), %r15
testq %r15, %r15
je 0x1d9ec
movzbl (%r15), %eax
testl %eax, %eax
je 0x1d7f4
cmpl $0x1, %eax
jne 0x1d804
cmpq $0x0, 0x18(%r15)
je 0x1d9ec
testb %al, %al
jne 0x1d804
movsd 0x20(%r15), %xmm0
ucomisd %xmm0, %xmm0
jp 0x1d9ec
movzbl 0x10(%rsp), %eax
testl %eax, %eax
je 0x1d822
cmpl $0x1, %eax
jne 0x1d832
cmpq $0x0, 0x28(%rsp)
je 0x1d9ec
testb %al, %al
jne 0x1d832
movsd 0x30(%rsp), %xmm0
ucomisd %xmm0, %xmm0
jp 0x1d9ec
cmpb $0x0, (%r15)
je 0x1da0d
movq 0x18(%r15), %rdi
testq %rdi, %rdi
setne %al
movq 0x28(%rsp), %rsi
testq %rsi, %rsi
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1da11
callq 0x46c0
testl %eax, %eax
sete %al
jmp 0x1da56
cmpb $0x21, %al
jne 0x1d8b4
cmpb $0x3d, -0x1(%r15)
jne 0x1d8b4
leaq 0x10(%rsp), %r9
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r15, %rcx
movq %r12, %r8
callq 0x1d723
testl %eax, %eax
je 0x1d965
movq 0x8(%rsp), %r15
movq $0x0, 0x20(%r15)
movb $0x0, 0x1(%r15)
movl $0x1, %r12d
jmp 0x1daf7
cmpb $0x3d, %al
jne 0x1d8bf
cmpb $0x7e, -0x1(%r15)
je 0x1d8d6
movb $0x1, %cl
xorl %ebp, %ebp
cmpb $0x21, %al
jne 0x1db07
cmpb $0x7e, -0x1(%r15)
jne 0x1db07
leaq 0x10(%rsp), %rbp
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r15, %rcx
movq %r12, %r8
movq %rbp, %r9
callq 0x1d723
cmpb $0x0, (%rbp)
je 0x1dbe5
movl %eax, %r12d
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x1dbe5
movq 0x28(%rsp), %rsi
testq %rsi, %rsi
je 0x1d956
movq 0x8(%rsp), %rax
cmpq $0x0, 0x18(%rax)
je 0x1d956
cmpb $0x0, 0x11(%rsp)
js 0x1d956
movq 0x8(%rsp), %rax
cmpb $0x0, 0x1(%rax)
js 0x1d956
movslq 0xc(%r14), %rax
movl 0x10(%r14), %ecx
cmpl %ecx, %eax
jge 0x1da35
shlq $0x6, %rax
leaq (%r14,%rax), %rbx
addq $0x18, %rbx
jmp 0x1da96
movq 0x8(%rsp), %r15
movb $0x0, 0x1(%r15)
jmp 0x1daf7
movl %eax, %r12d
movq 0x8(%rsp), %r15
testq %r15, %r15
je 0x1d9ec
movzbl (%r15), %eax
testl %eax, %eax
je 0x1d98a
cmpl $0x1, %eax
jne 0x1d996
cmpq $0x0, 0x18(%r15)
je 0x1d9ec
testb %al, %al
jne 0x1d996
movsd 0x20(%r15), %xmm0
ucomisd %xmm0, %xmm0
jp 0x1d9ec
movzbl 0x10(%rsp), %eax
testl %eax, %eax
je 0x1d9b0
cmpl $0x1, %eax
jne 0x1d9bc
cmpq $0x0, 0x28(%rsp)
je 0x1d9ec
testb %al, %al
jne 0x1d9bc
movsd 0x30(%rsp), %xmm0
ucomisd %xmm0, %xmm0
jp 0x1d9ec
cmpb $0x0, (%r15)
je 0x1da15
movq 0x18(%r15), %rdi
testq %rdi, %rdi
setne %al
movq 0x28(%rsp), %rsi
testq %rsi, %rsi
setne %dl
andb %al, %dl
movb $0x1, %cl
cmpb $0x1, %dl
jne 0x1da30
callq 0x46c0
testl %eax, %eax
setne %cl
jmp 0x1da30
movq $0x0, 0x8(%r15)
movw $0x0, (%r15)
movabsq $0x7ff8000000000000, %rax # imm = 0x7FF8000000000000
movq %rax, 0x20(%r15)
jmp 0x1daf7
testb %al, %al
je 0x1da41
xorl %eax, %eax
jmp 0x1da56
movb $0x1, %cl
testb %al, %al
jne 0x1da30
movsd 0x30(%rsp), %xmm0
cmpneqsd 0x20(%r15), %xmm0
movq %xmm0, %rcx
andl $0x1, %ecx
movzbl %cl, %eax
jmp 0x1da59
cmpl $0x9, %eax
jle 0x1da6f
leaq 0x40(%rsp), %rbx
jmp 0x1da81
movsd 0x30(%rsp), %xmm0
cmpeqsd 0x20(%r15), %xmm0
movq %xmm0, %rax
andl $0x1, %eax
movzbl %al, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x20(%r15)
movb %al, 0x1(%r15)
jmp 0x1daf7
shlq $0x6, %rax
leaq (%r14,%rax), %rbx
addq $0x18, %rbx
incl %ecx
movl %ecx, 0x10(%r14)
movq %rbx, %rdi
movl $0x9, %edx
callq 0x4570
testl %eax, %eax
jne 0x1dbb0
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rsi
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x4610
testl %eax, %eax
movl $0x3d, %eax
movl $0x21, %ecx
cmovel %eax, %ecx
cmpb %cl, -0x2(%r15)
je 0x1dac9
xorpd %xmm0, %xmm0
jmp 0x1dad1
movsd 0x7853f(%rip), %xmm0    # 0x96010
movq 0x8(%rsp), %r15
movsd %xmm0, 0x20(%r15)
sete 0x1(%r15)
leaq 0x40(%rsp), %rax
cmpq %rax, %rbx
jne 0x1daf3
movq %rbx, %rdi
callq 0x44c0
incl 0xc(%r14)
movb $0x0, (%r15)
xorl %ecx, %ecx
negl %r12d
movl $0x0, %ebp
sbbl %ebp, %ebp
testb %cl, %cl
movq 0x8(%rsp), %rcx
jne 0x1db7f
movzbl 0x10(%rsp), %eax
testl %eax, %eax
je 0x1db31
cmpl $0x1, %eax
jne 0x1db2a
cmpq $0x0, 0x28(%rsp)
je 0x1db64
testb %al, %al
je 0x1db31
testq %rcx, %rcx
jne 0x1db42
jmp 0x1db64
testq %rcx, %rcx
je 0x1db64
movsd 0x30(%rsp), %xmm0
ucomisd %xmm0, %xmm0
jp 0x1db64
movzbl (%rcx), %eax
testl %eax, %eax
je 0x1db59
cmpl $0x1, %eax
jne 0x1db7f
cmpq $0x0, 0x18(%rcx)
je 0x1db64
testb %al, %al
jne 0x1db7f
movsd 0x20(%rcx), %xmm0
ucomisd %xmm0, %xmm0
jnp 0x1db7f
movq $0x0, 0x8(%rcx)
movw $0x0, (%rcx)
movabsq $0x7ff8000000000000, %rax # imm = 0x7FF8000000000000
movq %rax, 0x20(%rcx)
movq 0x28(%rsp), %rdi
callq 0x45c0
xorpd %xmm0, %xmm0
movupd %xmm0, 0x18(%rsp)
movq $0x0, 0x28(%rsp)
movl %ebp, %eax
addq $0x488, %rsp            # imm = 0x488
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x80(%rsp), %r14
movl $0x400, %ecx            # imm = 0x400
movl %eax, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x4220
movq 0x9b407(%rip), %rax     # 0xb8fd8
movq (%rax), %rdi
leaq 0x7c166(%rip), %rsi     # 0x99d41
movq %r14, %rdx
xorl %eax, %eax
callq 0x4700
movq 0x28(%rsp), %rdi
callq 0x45c0
xorpd %xmm0, %xmm0
movupd %xmm0, 0x18(%rsp)
movq $0x0, 0x28(%rsp)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x1db9c