// File: ctSkennerton[P]fxtract/util/tap.c
// Function: cleanup
static void
_cleanup(void)
{
    /* If we forked, don't do cleanup in child! */
    if (getpid() != test_pid)
        return;

    LOCK;

    /* If plan_no_plan() wasn't called, and we don't have a plan,
       and we're not skipping everything, then something happened
       before we could produce any output */
    if(!no_plan && !have_plan && !skip_all) {
        _diag("Looks like your test died before it could output anything.");
        UNLOCK;
        return;
    }

    if(test_died) {
        _diag("Looks like your test died just after %d.", test_count);
        UNLOCK;
        return;
    }

    /* No plan provided, but now we know how many tests were run, and can
       print the header at the end */
    if(!skip_all && (no_plan || !have_plan)) {
        fprintf(tap_out, "1..%d\n", test_count);
    }

    if((have_plan && !no_plan) && e_tests < test_count) {
        _diag("Looks like you planned %d tests but ran %d extra.",
              e_tests, test_count - e_tests);
        if(failures) {
            _diag("Looks like you failed %d tests of %d run.",
                  failures, test_count);
        }
        UNLOCK;
        return;
    }

    if((have_plan || !no_plan) && e_tests > test_count) {
        _diag("Looks like you planned %d tests but only ran %d.",
              e_tests, test_count);
        if(failures) {
            _diag("Looks like you failed %d tests of %d run.",
                  failures, test_count);
        }
        UNLOCK;
        return;
    }

    if(failures)
        _diag("Looks like you failed %d tests of %d.",
              failures, test_count);

    UNLOCK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
callq 0x32e0
cmpl 0x5551(%rip), %eax      # 0x107f0
je 0xb2a6
jmp 0xb416
cmpl $0x0, 0x5763(%rip)      # 0x10a10
jne 0xb2d4
cmpl $0x0, 0x5752(%rip)      # 0x10a08
jne 0xb2d4
cmpl $0x0, 0x5755(%rip)      # 0x10a14
jne 0xb2d4
leaq 0x19d7(%rip), %rdi      # 0xcc9f
movb $0x0, %al
callq 0xb150
jmp 0xb416
cmpl $0x0, 0x5731(%rip)      # 0x10a0c
je 0xb2f6
movl 0x54e5(%rip), %esi      # 0x107c8
leaq 0x19f0(%rip), %rdi      # 0xccda
movb $0x0, %al
callq 0xb150
jmp 0xb416
cmpl $0x0, 0x5717(%rip)      # 0x10a14
jne 0xb32c
cmpl $0x0, 0x570a(%rip)      # 0x10a10
jne 0xb311
cmpl $0x0, 0x56f9(%rip)      # 0x10a08
jne 0xb32c
movq 0x54a8(%rip), %rdi      # 0x107c0
movl 0x54aa(%rip), %edx      # 0x107c8
leaq 0x19de(%rip), %rsi      # 0xcd03
movb $0x0, %al
callq 0x32c0
cmpl $0x0, 0x56d5(%rip)      # 0x10a08
je 0xb394
cmpl $0x0, 0x56d4(%rip)      # 0x10a10
jne 0xb394
movl 0x56d4(%rip), %eax      # 0x10a18
cmpl 0x547e(%rip), %eax      # 0x107c8
jae 0xb394
movl 0x56c6(%rip), %esi      # 0x10a18
movl 0x5470(%rip), %edx      # 0x107c8
subl 0x56ba(%rip), %edx      # 0x10a18
leaq 0x19a5(%rip), %rdi      # 0xcd0a
movb $0x0, %al
callq 0xb150
cmpl $0x0, 0x5459(%rip)      # 0x107cc
je 0xb38f
movl 0x5451(%rip), %esi      # 0x107cc
movl 0x5447(%rip), %edx      # 0x107c8
leaq 0x19b4(%rip), %rdi      # 0xcd3c
movb $0x0, %al
callq 0xb150
jmp 0xb416
cmpl $0x0, 0x566d(%rip)      # 0x10a08
jne 0xb3a6
cmpl $0x0, 0x566c(%rip)      # 0x10a10
jne 0xb3f3
movl 0x566c(%rip), %eax      # 0x10a18
cmpl 0x5416(%rip), %eax      # 0x107c8
jbe 0xb3f3
movl 0x565e(%rip), %esi      # 0x10a18
movl 0x5408(%rip), %edx      # 0x107c8
leaq 0x199f(%rip), %rdi      # 0xcd66
movb $0x0, %al
callq 0xb150
cmpl $0x0, 0x53f7(%rip)      # 0x107cc
je 0xb3f1
movl 0x53ef(%rip), %esi      # 0x107cc
movl 0x53e5(%rip), %edx      # 0x107c8
leaq 0x1952(%rip), %rdi      # 0xcd3c
movb $0x0, %al
callq 0xb150
jmp 0xb416
cmpl $0x0, 0x53d2(%rip)      # 0x107cc
je 0xb416
movl 0x53ca(%rip), %esi      # 0x107cc
movl 0x53c0(%rip), %edx      # 0x107c8
leaq 0x1988(%rip), %rdi      # 0xcd97
movb $0x0, %al
callq 0xb150
popq %rbp
retq
nopl (%rax,%rax)