// File: ctSkennerton[P]fxtract/util/bndm_t.c
// Function: main
int main(int argc, char **argv)
{
    plan_tests(1);
    char dflt[] = "one", *patt = argc > 1 ? argv[1] : dflt;
    char const *util = getenv("util") ? getenv("util") : ".";
    char const *file = argc > 1 ? argv[1] : "words";
    FILE *fp = fopenf("r", "%s/%s", util, file);
    if (!fp) return fprintf(stderr, "bndm_t: cannot open %s\n", file);
    int patlen = strlen(patt), lines = 0, goods = 0, hits = 0;
    char buf[999];

    while (fgets(buf, sizeof buf, fp)) {
        lines++;
        char *cp = strstr(buf, patt);
        hits += !!cp;
        if (cp == bndmem(buf, strlen(buf) - 1, patt, patlen)) ++goods;
        else fprintf(stderr, "# failed: %s", buf);
    }
    ok(goods == lines, "strstr == bndmem %d/%d times (%d hits)", goods, lines, hits);

    return exit_status();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x490, %rsp            # imm = 0x490
movl $0x0, -0x14(%rbp)
movl %edi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movl $0x1, %edi
callq 0x6b90
movl 0x3b58(%rip), %eax      # 0x7004
movl %eax, -0x24(%rbp)
cmpl $0x1, -0x18(%rbp)
jle 0x34c6
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x450(%rbp)
jmp 0x34d1
leaq -0x24(%rbp), %rax
movq %rax, -0x450(%rbp)
movq -0x450(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq 0x3b25(%rip), %rdi      # 0x7008
callq 0x3230
cmpq $0x0, %rax
je 0x3503
leaq 0x3b13(%rip), %rdi      # 0x7008
callq 0x3230
movq %rax, -0x458(%rbp)
jmp 0x3513
leaq 0x44b8(%rip), %rax      # 0x79c2
movq %rax, -0x458(%rbp)
jmp 0x3513
movq -0x458(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpl $0x1, -0x18(%rbp)
jle 0x3535
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x460(%rbp)
jmp 0x3545
leaq 0x3ad1(%rip), %rax      # 0x700d
movq %rax, -0x460(%rbp)
jmp 0x3545
movq -0x460(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdx
movq -0x40(%rbp), %rcx
leaq 0x452e(%rip), %rdi      # 0x7a8d
leaq 0x3aad(%rip), %rsi      # 0x7013
movb $0x0, %al
callq 0x5220
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x359c
movq 0x6a61(%rip), %rax      # 0x9fe0
movq (%rax), %rdi
movq -0x40(%rbp), %rdx
leaq 0x3a8c(%rip), %rsi      # 0x7019
movb $0x0, %al
callq 0x3290
movl %eax, -0x14(%rbp)
jmp 0x3755
movq -0x30(%rbp), %rdi
callq 0x30a0
movl %eax, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movl $0x0, -0x58(%rbp)
leaq -0x440(%rbp), %rdi
movq -0x48(%rbp), %rdx
movl $0x3e7, %esi            # imm = 0x3E7
callq 0x32d0
cmpq $0x0, %rax
je 0x3695
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
leaq -0x440(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x3050
movq %rax, -0x448(%rbp)
cmpq $0x0, -0x448(%rbp)
setne %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
addl -0x58(%rbp), %eax
movl %eax, -0x58(%rbp)
movq -0x448(%rbp), %rax
movq %rax, -0x468(%rbp)
leaq -0x440(%rbp), %rax
movq %rax, -0x470(%rbp)
leaq -0x440(%rbp), %rdi
callq 0x30a0
movq -0x470(%rbp), %rdi
subq $0x1, %rax
movl %eax, %esi
movq -0x30(%rbp), %rdx
movl -0x4c(%rbp), %ecx
callq 0x3770
movq %rax, %rcx
movq -0x468(%rbp), %rax
cmpq %rcx, %rax
jne 0x3671
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x3690
movq 0x6968(%rip), %rax      # 0x9fe0
movq (%rax), %rdi
leaq -0x440(%rbp), %rdx
leaq 0x39a8(%rip), %rsi      # 0x7031
movb $0x0, %al
callq 0x3290
jmp 0x35bd
movl -0x54(%rbp), %eax
cmpl -0x50(%rbp), %eax
jne 0x36f7
movl -0x54(%rbp), %r11d
movl -0x50(%rbp), %r10d
movl -0x58(%rbp), %eax
xorl %edi, %edi
movl $0x1, %esi
xorl %ecx, %ecx
movl %ecx, %r8d
leaq 0x3983(%rip), %r9       # 0x703e
leaq 0x3981(%rip), %r14      # 0x7043
leaq 0x3983(%rip), %rbx      # 0x704c
movq %r8, %rdx
movq %r8, %rcx
movq %r14, (%rsp)
movl $0x2a, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movl %r11d, 0x18(%rsp)
movl %r10d, 0x20(%rsp)
movl %eax, 0x28(%rsp)
movb $0x0, %al
callq 0x5eb0
jmp 0x374d
movl -0x54(%rbp), %r11d
movl -0x50(%rbp), %r10d
movl -0x58(%rbp), %eax
xorl %edi, %edi
xorl %ecx, %ecx
movl %ecx, %r8d
leaq 0x392e(%rip), %r9       # 0x703e
leaq 0x392c(%rip), %r14      # 0x7043
leaq 0x392e(%rip), %rbx      # 0x704c
movq %r8, %rsi
movq %r8, %rdx
movq %r8, %rcx
movq %r14, (%rsp)
movl $0x2a, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movl %r11d, 0x18(%rsp)
movl %r10d, 0x20(%rsp)
movl %eax, 0x28(%rsp)
movb $0x0, %al
callq 0x5eb0
callq 0x6ee0
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
addq $0x490, %rsp            # imm = 0x490
popq %rbx
popq %r14
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop