// File: /workspace/github_c_makefile_star2_O2/morozov312[P]documentary/thirdparty/ctest.h
// Function: ctest_main
__attribute__((no_sanitize_address)) int ctest_main(int argc, const char *argv[])
{
    static int total = 0;
    static int num_ok = 0;
    static int num_fail = 0;
    static int num_skip = 0;
    static int idx = 1;
    static ctest_filter_func filter = suite_all;

#ifdef CTEST_SEGFAULT
    signal(SIGSEGV, sighandler);
#endif

    if (argc == 2) {
        suite_name = argv[1];
        filter = suite_filter;
    }
#ifdef CTEST_NO_COLORS
    color_output = 0;
#else
    color_output = isatty(1);
#endif
    uint64_t t1 = getCurrentTime();

    struct ctest* ctest_begin = &CTEST_IMPL_TNAME(suite, test);
    struct ctest* ctest_end = &CTEST_IMPL_TNAME(suite, test);
    // find begin and end of section by comparing magics
    while (1) {
        struct ctest* t = ctest_begin-1;
        if (t->magic != CTEST_IMPL_MAGIC) break;
        ctest_begin--;
    }
    while (1) {
        struct ctest* t = ctest_end+1;
        if (t->magic != CTEST_IMPL_MAGIC) break;
        ctest_end++;
    }
    ctest_end++;    // end after last one

    static struct ctest* test;
    for (test = ctest_begin; test != ctest_end; test++) {
        if (test == &CTEST_IMPL_TNAME(suite, test)) continue;
        if (filter(test)) total++;
    }

    for (test = ctest_begin; test != ctest_end; test++) {
        if (test == &CTEST_IMPL_TNAME(suite, test)) continue;
        if (filter(test)) {
            ctest_errorbuffer[0] = 0;
            ctest_errorsize = MSG_SIZE-1;
            ctest_errormsg = ctest_errorbuffer;
            printf("TEST %d/%d %s:%s ", idx, total, test->ssname, test->ttname);
            fflush(stdout);
            if (test->skip) {
                color_print(ANSI_BYELLOW, "[SKIPPED]");
                num_skip++;
            } else {
                int result = setjmp(ctest_err);
                if (result == 0) {
                    if (test->setup && *test->setup) (*test->setup)(test->data);
                    if (test->data)
                        test->run(test->data);
                    else
                        test->run();
                    if (test->teardown && *test->teardown) (*test->teardown)(test->data);
                    // if we got here it's ok
#ifdef CTEST_COLOR_OK
                    color_print(ANSI_BGREEN, "[OK]");
#else
                    printf("[OK]\n");
#endif
                    num_ok++;
                } else {
                    color_print(ANSI_BRED, "[FAIL]");
                    num_fail++;
                }
                if (ctest_errorsize != MSG_SIZE-1) printf("%s", ctest_errorbuffer);
            }
            idx++;
        }
    }
    uint64_t t2 = getCurrentTime();

    const char* color = (num_fail) ? ANSI_BRED : ANSI_GREEN;
    char results[80];
    snprintf(results, sizeof(results), "RESULTS: %d tests (%d ok, %d failed, %d skipped) ran in %" PRIu64 " ms", total, num_ok, num_fail, num_skip, (t2 - t1)/1000);
    color_print(color, results);
    return num_fail;
}

// Assembly:
cmpl $0x2, %edi
jne 0x282e
movq 0x8(%rsi), %rax
movq %rax, 0x5d78(%rip)      # 0x8598
leaq 0x2b7(%rip), %rax       # 0x2ade
movq %rax, 0x58f2(%rip)      # 0x8120
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
pushq $0x1
popq %rdi
callq 0x2090
movl %eax, 0x58db(%rip)      # 0x8128
leaq 0x5910(%rip), %rbx      # 0x8164
callq 0x2b13
movq %rax, -0x30(%rbp)
movq %rbx, %rax
leaq -0x38(%rax), %r12
cmpl $0xdeadbeef, -0x3c(%rax) # imm = 0xDEADBEEF
movq %r12, %rax
je 0x2860
leaq 0x58b5(%rip), %rax      # 0x812c
leaq 0x38(%rax), %r13
cmpl $0xdeadbeef, 0x6c(%rax) # imm = 0xDEADBEEF
movq %r13, %rax
je 0x2877
leaq 0x589e(%rip), %rbx      # 0x812c
movq %r12, %rdi
movq %rdi, 0x5d08(%rip)      # 0x85a0
cmpq %rdi, %r13
je 0x28c2
cmpq %rbx, %rdi
je 0x28b2
callq *0x5878(%rip)           # 0x8120
testl %eax, %eax
je 0x28b2
incl 0x5cd6(%rip)            # 0x8588
movq 0x5ce7(%rip), %rax      # 0x85a0
addq $0x38, %rax
movq %rax, %rdi
jmp 0x2891
leaq 0x5ce7(%rip), %r15      # 0x85b0
xorl %r14d, %r14d
leaq 0x2965(%rip), %rax      # 0x5238
movq %r12, %rdi
movq %rax, %r12
movq %rdi, 0x5cc0(%rip)      # 0x85a0
cmpq %rdi, %r13
je 0x2a51
movq %rbx, %rax
cmpq %rbx, %rdi
je 0x2a45
callq *0x5825(%rip)           # 0x8120
movq 0x5c9e(%rip), %rdi      # 0x85a0
testl %eax, %eax
je 0x297b
movb $0x0, 0x5ca3(%rip)      # 0x85b0
movq $0xfff, 0x6c98(%rip) # imm = 0xFFF
movq %r15, 0x6c99(%rip)      # 0x95b8
movl 0x57f3(%rip), %esi      # 0x8118
movl 0x5c5d(%rip), %edx      # 0x8588
movq (%rdi), %rcx
movq 0x8(%rdi), %r8
movl %r14d, %eax
leaq 0x28d7(%rip), %rdi      # 0x5213
callq 0x2100
movq 0x5690(%rip), %rax      # 0x7fd8
movq (%rax), %rdi
callq 0x21d0
movq 0x5c49(%rip), %rax      # 0x85a0
cmpl $0x0, 0x30(%rax)
je 0x2983
leaq 0x28c1(%rip), %rdi      # 0x5225
leaq 0x28c3(%rip), %rsi      # 0x522e
callq 0x2b3c
incl 0x5c1e(%rip)            # 0x8594
jmp 0x2a38
movq %rdi, %rax
jmp 0x2a45
leaq 0x5b36(%rip), %rdi      # 0x84c0
callq 0x2170
testl %eax, %eax
je 0x29ab
movq %r12, %rdi
leaq 0x28a4(%rip), %rsi      # 0x5241
callq 0x2b3c
leaq 0x5be7(%rip), %rax      # 0x8590
jmp 0x2a17
movq 0x5bee(%rip), %rax      # 0x85a0
movq 0x20(%rax), %rcx
testq %rcx, %rcx
je 0x29d0
movq (%rcx), %rcx
testq %rcx, %rcx
je 0x29d0
movq 0x18(%rax), %rdi
callq *%rcx
movq 0x5bd0(%rip), %rax      # 0x85a0
movq 0x10(%rax), %rcx
movq 0x18(%rax), %rdi
movl %r14d, %eax
testq %rdi, %rdi
je 0x29e4
callq *%rcx
jmp 0x29e6
callq *%rcx
movq 0x5bb3(%rip), %rax      # 0x85a0
movq 0x28(%rax), %rcx
testq %rcx, %rcx
je 0x2a04
movq (%rcx), %rcx
testq %rcx, %rcx
je 0x2a04
movq 0x18(%rax), %rdi
callq *%rcx
leaq 0x2895(%rip), %rdi      # 0x52a0
callq 0x2080
leaq 0x5b75(%rip), %rax      # 0x858c
incl (%rax)
cmpq $0xfff, 0x6b8c(%rip) # imm = 0xFFF
je 0x2a38
movl %r14d, %eax
leaq 0x3037(%rip), %rdi      # 0x5a67
movq %r15, %rsi
callq 0x2100
incl 0x56da(%rip)            # 0x8118
movq 0x5b5b(%rip), %rax      # 0x85a0
addq $0x38, %rax
movq %rax, %rdi
jmp 0x28d9
callq 0x2b13
movl 0x5b33(%rip), %r9d      # 0x8590
testl %r9d, %r9d
leaq 0x27e1(%rip), %rcx      # 0x5248
cmoveq %rcx, %r12
movl 0x5b17(%rip), %ecx      # 0x8588
movl 0x5b14(%rip), %r8d      # 0x858c
movl 0x5b15(%rip), %r11d     # 0x8594
subq -0x30(%rbp), %rax
xorl %esi, %esi
movl %esi, %edx
movl $0x3e8, %edi            # imm = 0x3E8
divq %rdi
movq %rax, %r10
leaq 0x27b7(%rip), %rdx      # 0x5250
movl %esi, %eax
leaq -0x80(%rbp), %r14
pushq $0x50
popq %rsi
movq %r14, %rdi
pushq %r10
movl %r11d, %r10d
pushq %r10
callq 0x2110
popq %rcx
popq %rdx
movq %r12, %rdi
movq %r14, %rsi
callq 0x2b3c
movl 0x5acc(%rip), %eax      # 0x8590
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq