// File: /workspace/github_c_makefile_star2_O0/aremmell[P]libsir/tests/tests.c
// Function: main
int main(int argc, char** argv) {
#if defined(__HAIKU__) && !defined(DEBUG)
    disable_debugger(1);
#endif

#include "tests_malloc.h"

#if !defined(__WIN__) && !defined(__HAIKU__) && !defined(__EMSCRIPTEN__)
    /* Disallow execution by root / sudo; some of the tests rely on lack of permissions. */
    if (geteuid() == 0) {
        (void)fprintf(stderr, "Sorry, but this program may not be executed by root." SIR_EOL);
        return EXIT_FAILURE;
    }
#else /* __WIN__ */
# if defined(_DEBUG) && defined(SIR_ASSERT_ENABLED)
    /* Prevents assert() from calling abort() before the user is able to:
     * a.) break into the code and debug (Retry button)
     * b.) ignore the assert() and continue. */
    _set_error_mode(_OUT_TO_MSGBOX);
# endif
#endif

    bool parsed = parse_cmd_line(argc, argv, cl_args, _sir_countof(cl_args),
        sir_tests, _sir_countof(sir_tests), &cl_cfg);
    if (!parsed)
        return EXIT_FAILURE;

    size_t first     = (cl_cfg.only ? 0 : 1);
    size_t tgt_tests = (cl_cfg.only ? cl_cfg.to_run : _sir_countof(sir_tests) - first);
    size_t passed    =  0;
    size_t ran       =  0;
    sir_time timer   = {0};

    print_intro(tgt_tests);
    sir_timer_start(&timer);

    for (size_t n = first; n < _sir_countof(sir_tests); n++) {
        if (cl_cfg.only && !sir_tests[n].run) {
            _sir_selflog("skipping '%s'; not marked to run", sir_tests[n].name);
            continue;
        }

        print_test_intro(ran + 1, tgt_tests, sir_tests[n].name);

        sir_tests[n].pass = sir_tests[n].fn();
        if (sir_tests[n].pass)
            passed++;

        ran++;

        print_test_outro(ran, tgt_tests, sir_tests[n].name, sir_tests[n].pass);
    }

    print_test_summary(tgt_tests, passed, sir_timer_elapsed(&timer));

    if (passed != tgt_tests) {
        print_failed_test_intro(tgt_tests, passed);

        for (size_t t = 0; t < _sir_countof(sir_tests); t++)
            if (!sir_tests[t].pass)
                print_failed_test(sir_tests[t].name);
        (void)printf(SIR_EOL);
    }

    if (cl_cfg.wait)
        wait_for_keypress();

    return passed == tgt_tests ? EXIT_SUCCESS : EXIT_FAILURE;
}

// Assembly:
subq $0x78, %rsp
movl $0x0, 0x74(%rsp)
movl %edi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
callq 0x4220
cmpl $0x0, %eax
jne 0x5844
movq 0x227d2(%rip), %rax     # 0x27ff8
movq (%rax), %rdi
leaq 0x17c90(%rip), %rsi     # 0x1d4c0
movb $0x0, %al
callq 0x4300
movl $0x1, 0x74(%rsp)
jmp 0x5b0c
movl 0x70(%rsp), %edi
movq 0x68(%rsp), %rsi
leaq 0x2204c(%rip), %rdx     # 0x278a0
movl $0x7, %ecx
leaq 0x22aa0(%rip), %r8      # 0x28300
movl $0x25, %r9d
leaq 0x2314b(%rip), %rax     # 0x289b8
movq %rax, (%rsp)
callq 0x4f50
andb $0x1, %al
movb %al, 0x67(%rsp)
testb $0x1, 0x67(%rsp)
jne 0x5890
movl $0x1, 0x74(%rsp)
jmp 0x5b0c
movb 0x23124(%rip), %dl      # 0x289ba
movl $0x1, %eax
xorl %ecx, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
cltq
movq %rax, 0x58(%rsp)
testb $0x1, 0x23109(%rip)     # 0x289ba
je 0x58c1
movq 0x23106(%rip), %rax     # 0x289c0
movq %rax, 0x18(%rsp)
jmp 0x58d0
movl $0x25, %eax
subq 0x58(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x50(%rsp)
movq $0x0, 0x48(%rsp)
movq $0x0, 0x40(%rsp)
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x4210
movq 0x50(%rsp), %rdi
callq 0x46e0
leaq 0x30(%rsp), %rdi
callq 0x5b20
movq 0x58(%rsp), %rax
movq %rax, 0x28(%rsp)
cmpq $0x25, 0x28(%rsp)
jae 0x5a3c
testb $0x1, 0x2308c(%rip)     # 0x289ba
je 0x596c
leaq 0x229c9(%rip), %rax     # 0x28300
imulq $0x18, 0x28(%rsp), %rcx
addq %rcx, %rax
testb $0x1, 0x10(%rax)
jne 0x596c
leaq 0x229b3(%rip), %rax     # 0x28300
imulq $0x18, 0x28(%rsp), %rcx
addq %rcx, %rax
movq (%rax), %rsi
leaq 0x17b96(%rip), %rdi     # 0x1d4f6
movb $0x0, %al
callq 0x5b40
jmp 0x5a29
movq 0x40(%rsp), %rdi
addq $0x1, %rdi
movq 0x50(%rsp), %rsi
leaq 0x2297f(%rip), %rax     # 0x28300
imulq $0x18, 0x28(%rsp), %rcx
addq %rcx, %rax
movq (%rax), %rdx
callq 0x4750
leaq 0x22967(%rip), %rax     # 0x28300
imulq $0x18, 0x28(%rsp), %rcx
addq %rcx, %rax
callq *0x8(%rax)
movb %al, %cl
leaq 0x22952(%rip), %rax     # 0x28300
imulq $0x18, 0x28(%rsp), %rdx
addq %rdx, %rax
andb $0x1, %cl
movb %cl, 0x11(%rax)
leaq 0x2293c(%rip), %rax     # 0x28300
imulq $0x18, 0x28(%rsp), %rcx
addq %rcx, %rax
testb $0x1, 0x11(%rax)
je 0x59e1
movq 0x48(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x48(%rsp)
movq 0x40(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rdi
movq 0x50(%rsp), %rsi
leaq 0x22900(%rip), %rax     # 0x28300
imulq $0x18, 0x28(%rsp), %rcx
addq %rcx, %rax
movq (%rax), %rdx
leaq 0x228ed(%rip), %rax     # 0x28300
imulq $0x18, 0x28(%rsp), %rcx
addq %rcx, %rax
movb 0x11(%rax), %al
andb $0x1, %al
movzbl %al, %ecx
callq 0x4790
movq 0x28(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x28(%rsp)
jmp 0x591b
movq 0x50(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x5b50
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x47f0
movq 0x48(%rsp), %rax
cmpq 0x50(%rsp), %rax
je 0x5ae3
movq 0x50(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0x48c0
movq $0x0, 0x20(%rsp)
cmpq $0x25, 0x20(%rsp)
jae 0x5ad5
leaq 0x22864(%rip), %rax     # 0x28300
imulq $0x18, 0x20(%rsp), %rcx
addq %rcx, %rax
testb $0x1, 0x11(%rax)
jne 0x5ac3
leaq 0x2284e(%rip), %rax     # 0x28300
imulq $0x18, 0x20(%rsp), %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x4910
jmp 0x5ac5
movq 0x20(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x20(%rsp)
jmp 0x5a8d
leaq 0x177ea(%rip), %rdi     # 0x1d2c6
movb $0x0, %al
callq 0x4180
testb $0x1, 0x22ecf(%rip)     # 0x289b9
je 0x5af1
callq 0x5380
movq 0x48(%rsp), %rdx
movq 0x50(%rsp), %rsi
movl $0x1, %eax
xorl %ecx, %ecx
cmpq %rsi, %rdx
cmovel %ecx, %eax
movl %eax, 0x74(%rsp)
movl 0x74(%rsp), %eax
addq $0x78, %rsp
retq
nopw %cs:(%rax,%rax)