// File: /workspace/github_cpp_makefile_star2_O2/ctSkennerton[P]fxtract/util/ssearch_x.c
// Function: main
int
main(int argc, char **argv)
{
    char    *pgm = strrchr(argv[0], '/');
    pgm	= pgm ? pgm + 1 : argv[0];

    while (argc > 1 && !strcmp(argv[1], "-v"))
	++verbose, ++argv;

    if (argc < 2) {
	fprintf(stderr, "Usage: %s [-v [-v]...] <patt_file> [text_file [matches]]\n", pgm);
	return	1;
    }

    MEMBUF  patt = chomp(slurp(argv[1]));
    fprintf(stderr, "# %s: %"FSIZE"d bytes\n", argv[1], patt.len);

    int	    npatts, i;
    MEMREF  *pattv = refsplit(patt.ptr, '\n', &npatts);
    text = argc > 2 && strcmp(argv[1], argv[2]) ? slurp(argv[2]) : patt;
    // text now contains \0's instead of \n's,
    //  but ssearch treats \0 like any other byte.
    int	    matches = argc > 3 ? atoi(argv[3]) : npatts;

    SSEARCH *ssp = ssearch_create(pattv, npatts);
    ssearch_dump(ssp, verbose ? stderr : fopen("/dev/null", "w")); // coverage

    plan_tests(4);
    ok(patt.ptr, "patt_file loaded");
    ok(npatts, "text_file loaded");
    ok(ssp, "ssearch_create returns a value");

    hits = 0;
    double	t = tick();
    (void)ssearch_scan(ssp, bufref(text), (SSEARCH_CB)on_match, pattv);
    t = tick() - t;
    if (!ok(hits == matches, "match count"))
	fprintf(stderr, "# actual: %d expected: %d\n", hits, matches);
    fprintf(stderr, "# elapsed: %G secs\n", t);
    if (verbose)
        for (i = 0; i < 16; ++i)
            if (ssearch_skip[i]) 
                fprintf(stderr, "# skip %2d: %8d\n", i, ssearch_skip[i]);
    ssearch_destroy(ssp);   // coverage
    buffree(patt);
    free(pattv);
    return exit_status();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
cmpl $0x2, %edi
jl 0x348c
movl %edi, %ebp
movl 0x72ee(%rip), %eax      # 0xa758
incl %eax
addq $0x8, %r15
movq (%r15), %rdi
cmpb $0x2d, (%rdi)
jne 0x34c5
cmpb $0x76, 0x1(%rdi)
jne 0x34c5
cmpb $0x0, 0x2(%rdi)
jne 0x34c5
movl %eax, 0x72ce(%rip)      # 0xa758
jmp 0x346a
movq (%r15), %rbx
pushq $0x2f
popq %rsi
movq %rbx, %rdi
callq 0x31b0
leaq 0x1(%rax), %rdx
testq %rax, %rax
cmoveq %rbx, %rdx
movq 0x6b2c(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
leaq 0x3b4e(%rip), %rsi      # 0x7004
xorl %eax, %eax
callq 0x3260
pushq $0x1
popq %rax
jmp 0x378f
callq 0x4520
movq %rax, %rdi
movq %rdx, %rsi
callq 0x3ecb
movq %rax, %rbx
movq %rdx, %r12
movq 0x6af6(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
movq (%r15), %rdx
leaq 0x3b4f(%rip), %rsi      # 0x703e
movq %r12, %rcx
xorl %eax, %eax
callq 0x3260
pushq $0xa
popq %rsi
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
callq 0x4424
movq %rax, %r14
cmpl $0x2, %ebp
jne 0x3521
movq %rbx, 0x7248(%rip)      # 0xa760
movq %r12, 0x7249(%rip)      # 0xa768
jmp 0x3568
movq (%r15), %rdi
movq 0x8(%r15), %r13
movq %r13, %rsi
callq 0x3350
movl %eax, %ecx
movq %rbx, %rax
testl %ecx, %ecx
je 0x3544
movq %r13, %rdi
callq 0x4520
movq %rdx, %r12
movq %rax, 0x7215(%rip)      # 0xa760
movq %r12, 0x7216(%rip)      # 0xa768
cmpl $0x4, %ebp
jb 0x3568
movq 0x10(%r15), %rdi
callq 0x3290
movl %eax, %ebp
movl 0xc(%rsp), %esi
jmp 0x356e
movl 0xc(%rsp), %esi
movl %esi, %ebp
movq %r14, %rdi
callq 0x47b8
movq %rax, %r15
cmpl $0x0, 0x71d8(%rip)      # 0xa758
jne 0x359a
leaq 0x3ac6(%rip), %rdi      # 0x704f
leaq 0x3ac9(%rip), %rsi      # 0x7059
callq 0x31e0
movq %rax, %rsi
jmp 0x35a4
movq 0x6a37(%rip), %rax      # 0x9fd8
movq (%rax), %rsi
movq %r15, %rdi
callq 0x4d44
pushq $0x4
popq %rdi
callq 0x5f2b
xorl %esi, %esi
testq %rbx, %rbx
setne %sil
subq $0x8, %rsp
leaq 0x3aa4(%rip), %r10      # 0x706c
leaq 0x3a91(%rip), %r13      # 0x7060
leaq 0x3a85(%rip), %r12      # 0x705b
xorl %edi, %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r12, %r9
xorl %eax, %eax
pushq %r10
pushq $0x2c
pushq %r13
callq 0x561c
addq $0x20, %rsp
xorl %esi, %esi
cmpl $0x0, 0xc(%rsp)
setne %sil
subq $0x8, %rsp
leaq 0x3a74(%rip), %r10      # 0x707d
xorl %edi, %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r12, %r9
xorl %eax, %eax
pushq %r10
pushq $0x2d
pushq %r13
callq 0x561c
addq $0x20, %rsp
xorl %esi, %esi
testq %r15, %r15
setne %sil
subq $0x8, %rsp
leaq 0x3a54(%rip), %r10      # 0x708e
xorl %edi, %edi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
movq %r12, %r9
xorl %eax, %eax
pushq %r10
pushq $0x2e
pushq %r13
callq 0x561c
addq $0x20, %rsp
andl $0x0, 0x7112(%rip)      # 0xa770
callq 0x4789
movsd %xmm0, 0x10(%rsp)
movq 0x70f0(%rip), %rsi      # 0xa760
movq 0x70f1(%rip), %rdx      # 0xa768
leaq 0x120(%rip), %rcx       # 0x379e
movq %r15, %rdi
movq %r14, %r8
callq 0x4b27
callq 0x4789
subsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
cmpl %ebp, 0x70d0(%rip)      # 0xa770
jne 0x36bb
subq $0x8, %rsp
leaq 0x3a00(%rip), %r10      # 0x70ad
leaq 0x39a7(%rip), %r9       # 0x705b
pushq $0x1
popq %rsi
xorl %edi, %edi
jmp 0x36d1
subq $0x8, %rsp
leaq 0x39e7(%rip), %r10      # 0x70ad
leaq 0x398e(%rip), %r9       # 0x705b
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %eax, %eax
pushq %r10
pushq $0x34
pushq %r13
callq 0x561c
addq $0x20, %rsp
testl %eax, %eax
jne 0x370d
movq 0x68e4(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
movl 0x7073(%rip), %edx      # 0xa770
leaq 0x39b5(%rip), %rsi      # 0x70b9
movl %ebp, %ecx
xorl %eax, %eax
callq 0x3260
movq 0x68c4(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
leaq 0x39b6(%rip), %rsi      # 0x70d4
movsd 0x10(%rsp), %xmm0
movb $0x1, %al
callq 0x3260
cmpl $0x0, 0x7026(%rip)      # 0xa758
je 0x3772
leaq 0x7045(%rip), %rbp      # 0xa780
leaq 0x39a6(%rip), %r12      # 0x70e8
xorl %r13d, %r13d
cmpq $0x10, %r13
je 0x3772
movl (%rbp,%r13,4), %ecx
testl %ecx, %ecx
jne 0x3759
incq %r13
jmp 0x3745
movq 0x6878(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
movq %r12, %rsi
movl %r13d, %edx
xorl %eax, %eax
callq 0x3260
jmp 0x3754
movq %r15, %rdi
callq 0x4af9
movq %rbx, %rdi
callq 0x3200
movq %r14, %rdi
callq 0x3200
callq 0x61c9
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq