// File: /workspace/github_c_makefile_star2_O3/aremmell[P]libsir/tests/tests.c
// Function: sirtest_squelchspam
bool sirtest_squelchspam(void) {
    INIT(si, SIRL_ALL, 0, 0, 0);
    bool pass = si_init;

    static const size_t alternate  = 50;
    static const size_t sequence[] = {
        1000, /* non-repeating messages. */
        1000, /* repeating messages. */
        1000, /* alternating repeating and non-repeating messages. */
        100   /* repeating messages, but on different levels. */
    };

    sir_time timer;
    sir_timer_start(&timer);

    TEST_MSG(SIR_BLUE("%zu non-repeating messages..."), sequence[0]);

    for (size_t n = 0, ascii_idx = 33; n < sequence[0]; n++, ascii_idx++) {
        _sir_eqland(pass, sir_debug("%c%c a non-repeating message", (char)ascii_idx,
            (char)ascii_idx + 1));

        if (ascii_idx == 125)
            ascii_idx = 33;
    }

    TEST_MSG(SIR_BLUE("%zu repeating messages..."), sequence[1]);

    for (size_t n = 0; n < sequence[1]; n++) {
        bool ret = sir_debug("a repeating message");

        if (n >= SIR_SQUELCH_THRESHOLD - 1)
            _sir_eqland(pass, !ret);
        else
            _sir_eqland(pass, ret);
    }

    TEST_MSG(SIR_BLUE("%zu alternating repeating and non-repeating messages..."),
        sequence[2]);

    bool repeating   = false;
    size_t counter   = 0;
    size_t repeat_id = 0;
    for (size_t n = 0, ascii_idx = 33; n < sequence[2]; n++, counter++, ascii_idx++) {
        if (!repeating) {
            _sir_eqland(pass, sir_debug("%c%c a non-repeating message", (char)ascii_idx,
                (char)ascii_idx + 1));
        } else {
            bool ret = sir_debug("%zu a repeating message", repeat_id);

            if (counter - 1 >= SIR_SQUELCH_THRESHOLD - 1)
                _sir_eqland(pass, !ret);
            else
                _sir_eqland(pass, ret);
        }

        if (counter == alternate) {
            repeating = !repeating;
            counter = 0;
            repeat_id++;
        }

        if (ascii_idx == 125)
            ascii_idx = 33;
    }

    TEST_MSG(SIR_BLUE("%zu repeating messages, but on different levels..."), sequence[3]);

    for (size_t n = 0; n < sequence[3]; n++) {
        if (n % 2 == 0)
            _sir_eqland(pass, sir_debug("a repeating message"));
        else
            _sir_eqland(pass, sir_info("a repeating message"));
    }

    _sir_eqland(pass, sir_cleanup());
    return PRINT_RESULT_RETURN(pass);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
leaq 0x10(%rsp), %rbx
movl $0x108, %edx            # imm = 0x108
movq %rbx, %rdi
xorl %esi, %esi
callq 0x31f0
movl $0x100000, %eax         # imm = 0x100000
movl %eax, 0x4(%rbx)
movw $0xff, (%rbx)
movl %eax, 0xc(%rbx)
movq %rbx, %rdi
callq 0x9a21
movl %eax, %ebx
movq %rsp, %rsi
xorl %edi, %edi
callq 0xdff1
leaq 0xb2aa(%rip), %rsi      # 0x1392a
movl $0x3e8, %r15d           # imm = 0x3E8
movl $0x3e8, %edx            # imm = 0x3E8
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
movl $0x21, %r13d
leaq 0xb2ba(%rip), %r14      # 0x1395e
movl $0x22, %r12d
movsbl %r13b, %esi
leal 0x1(%rsi), %edx
movq %r14, %rdi
xorl %eax, %eax
callq 0x9a45
andb %al, %bl
cmpq $0x7d, %r13
leaq 0x1(%r13), %r13
cmoveq %r12, %r13
decq %r15
jne 0x86aa
leaq 0xb2a6(%rip), %rsi      # 0x1397b
movl $0x3e8, %edx            # imm = 0x3E8
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
leaq 0xb310(%rip), %r14      # 0x139fd
xorl %r15d, %r15d
movq %r14, %rdi
xorl %eax, %eax
callq 0x9a45
cmpq $0x4, %r15
setae %cl
xorb %al, %cl
andb %cl, %bl
incq %r15
cmpq $0x3e8, %r15            # imm = 0x3E8
jne 0x86f0
leaq 0xb293(%rip), %rsi      # 0x139ab
xorl %r13d, %r13d
movl $0x3e8, %ebp            # imm = 0x3E8
movl $0x3e8, %edx            # imm = 0x3E8
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
movl $0x21, %r14d
xorl %r12d, %r12d
xorl %r15d, %r15d
testb $0x1, %r13b
je 0x8765
leaq 0xb2af(%rip), %rdi      # 0x139f9
movq %r12, %rsi
xorl %eax, %eax
callq 0x9a45
movl %eax, %ecx
leaq -0x5(%r15), %rax
cmpq $-0x4, %rax
setb %al
xorb %cl, %al
jmp 0x877a
movsbl %r14b, %esi
leal 0x1(%rsi), %edx
leaq 0xb1eb(%rip), %rdi      # 0x1395e
xorl %eax, %eax
callq 0x9a45
andb %al, %bl
xorl %eax, %eax
cmpq $0x32, %r15
leaq 0x1(%r15), %r15
sete %al
movl $0x1, %ecx
cmoveq %rcx, %r15
xorb %al, %r13b
addq %rax, %r12
cmpq $0x7d, %r14
leaq 0x1(%r14), %r14
movl $0x22, %eax
cmoveq %rax, %r14
decq %rbp
jne 0x873d
leaq 0xb25c(%rip), %rsi      # 0x13a11
movl $0x64, %edx
movl $0x1, %edi
xorl %eax, %eax
callq 0x3400
leaq 0xb230(%rip), %r14      # 0x139fd
xorl %r15d, %r15d
movq %r14, %rdi
xorl %eax, %eax
testb $0x1, %r15b
jne 0x87e2
callq 0x9a45
jmp 0x87e7
callq 0x9b03
andb %al, %bl
incq %r15
cmpq $0x64, %r15
jne 0x87d0
callq 0x9a26
andb %bl, %al
movzbl %al, %edi
xorl %esi, %esi
callq 0x3b6d
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq