// File: /workspace/github_c_makefile_star2_O1/aremmell[P]libsir/tests/tests.c
// Function: sirtest_syslog
static
bool generic_syslog_test(const char* sl_name, const char* identity, const char* category) {
    static const int runs = 5;

    /* repeat initializing, opening, logging, closing, cleaning up n times. */
    (void)printf("\trunning %d passes of random configs (system logger: '%s', "
                 "identity: '%s', category: '%s')..." SIR_EOL, runs, sl_name, identity, category);

# if !defined(__WIN__)
    uint32_t rnd = (uint32_t)(_sir_getpid() + _sir_gettid());
# else
    uint32_t rnd = (uint32_t)GetTickCount64();
# endif

    bool pass = true;
    for (int i = 1; i <= runs; i++) {
        /* randomly skip setting process name, identity/category to thoroughly
         * test fallback routines; randomly update the config mid-run. */
        bool set_procname = getrand_bool(rnd ^ 0x5a5a5a5aU);
        bool set_identity = getrand_bool(rnd ^ 0xc9c9c9c9U);
        bool set_category = getrand_bool(rnd ^ 0x32323232U);
        bool do_update    = getrand_bool(rnd ^ 0xe7e7e7e7U);

        TEST_MSG("set_procname: %d, set_identity: %d, set_category: %d, do_update: %d",
            set_procname, set_identity, set_category, do_update);

        INIT_SL(si, SIRL_ALL, SIRO_NOHOST | SIRO_NOTID, 0, 0, (set_procname ? "sir_sltest" : ""));
        si.d_syslog.opts   = SIRO_DEFAULT;
        si.d_syslog.levels = SIRL_DEFAULT;

        if (set_identity)
            (void)_sir_strncpy(si.d_syslog.identity, SIR_MAX_SYSLOG_CAT, identity, SIR_MAX_SYSLOG_ID);

        if (set_category)
            (void)_sir_strncpy(si.d_syslog.category, SIR_MAX_SYSLOG_CAT, category, SIR_MAX_SYSLOG_CAT);

        _sir_eqland(pass, sir_init(&si));

        if (do_update)
            _sir_eqland(pass, sir_sysloglevels(SIRL_ALL));

        _sir_eqland(pass, sir_debug("%d/%d: this debug message sent to stdout and %s.", i, runs, sl_name));
        _sir_eqland(pass, sir_info("%d/%d: this info message sent to stdout and %s.", i, runs, sl_name));

        _sir_eqland(pass, sir_notice("%d/%d: this notice message sent to stdout and %s.", i, runs, sl_name));
        _sir_eqland(pass, sir_warn("%d/%d: this warning message sent to stdout and %s.", i, runs, sl_name));
        _sir_eqland(pass, sir_error("%d/%d: this error message sent to stdout and %s.", i, runs, sl_name));

        if (set_identity) {
            _sir_eqland(pass, sir_syslogid("my test ID"));
            _sir_eqland(pass, sir_syslogid("my test ID")); /* test deduping. */
        }

        if (set_category) {
            _sir_eqland(pass, sir_syslogcat("my test category"));
            _sir_eqland(pass, sir_syslogcat("my test category")); /* test deduping. */
        }

        if (do_update)
            _sir_eqland(pass, sir_syslogopts(SIRO_MSGONLY & ~(SIRO_NOLEVEL | SIRO_NOPID)));

        _sir_eqland(pass, sir_crit("%d/%d: this critical message sent to stdout and %s.", i, runs, sl_name));
        _sir_eqland(pass, sir_alert("%d/%d: this alert message sent to stdout and %s.", i, runs, sl_name));
        _sir_eqland(pass, sir_emerg("%d/%d: this emergency message sent to stdout and %s.", i, runs, sl_name));

# if defined(SIR_OS_LOG_ENABLED)
#  if defined(__MACOS__) && !defined(__INTEL_COMPILER)
        if (i == runs -1 && 0 == strncmp(sl_name, "os_log", 6)) {
            TEST_MSG_0("testing os_log activity feature...");

            /* also test activity grouping in Console. there's only one way to validate
             * this and that's by manually viewing the log. */
            os_activity_t parent = os_activity_create("flying to the moon", //-V530
                OS_ACTIVITY_NONE, OS_ACTIVITY_FLAG_DETACHED);

            /* execution now passes to os_log_parent_activity(), where some logging
             * will occur, then a sub-activity will be created, and more logging. */
            os_activity_apply_f(parent, (void*)parent, os_log_parent_activity);
        }
#  endif
# endif

        _sir_eqland(pass, sir_cleanup());

        if (!pass)
            break;
    }

    return PRINT_RESULT_RETURN(pass);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
leaq 0xce25(%rip), %rsi      # 0x14acb
leaq 0xb7dc(%rip), %rcx      # 0x13489
leaq 0xb7dc(%rip), %r8       # 0x13490
leaq 0xb7d8(%rip), %r9       # 0x13493
movl $0x1, %ebp
movl $0x1, %edi
movl $0x5, %edx
xorl %eax, %eax
callq 0x3400
callq 0xd294
movl %eax, %r14d
callq 0xe2c3
movl %eax, %r15d
addl %r14d, %r15d
movl %r15d, %eax
xorl $0x5a5a5a5a, %eax       # imm = 0x5A5A5A5A
movl %eax, 0x18(%rsp)
movl %r15d, %eax
xorl $0xc9c9c9c9, %eax       # imm = 0xC9C9C9C9
movl %eax, 0x14(%rsp)
movl %r15d, %eax
xorl $0x32323232, %eax       # imm = 0x32323232
movl %eax, 0x10(%rsp)
movl %r15d, %eax
xorl $0xe7e7e7e7, %eax       # imm = 0xE7E7E7E7
movl %eax, 0xc(%rsp)
leaq 0x20(%rsp), %r12
movl %r15d, 0x1c(%rsp)
movb $0x1, 0x9(%rsp)
movb $0x1, %bl
cmpl $0x5a5a5a5a, %r15d      # imm = 0x5A5A5A5A
je 0x7d3c
movl 0x18(%rsp), %edi
callq 0x403f
testb $0x1, %al
sete %bl
cmpl $0xc9c9c9c9, %r15d      # imm = 0xC9C9C9C9
je 0x7d55
movl 0x14(%rsp), %edi
callq 0x403f
testb $0x1, %al
sete 0x9(%rsp)
movb $0x1, %r13b
movb $0x1, 0x8(%rsp)
cmpl $0x32323232, %r15d      # imm = 0x32323232
je 0x7d76
movl 0x10(%rsp), %edi
callq 0x403f
testb $0x1, %al
sete 0x8(%rsp)
cmpl $0xe7e7e7e7, %r15d      # imm = 0xE7E7E7E7
je 0x7d8e
movl 0xc(%rsp), %edi
callq 0x403f
testb $0x1, %al
sete %r13b
movzbl %bl, %r14d
movzbl 0x9(%rsp), %ecx
movzbl 0x8(%rsp), %r8d
movzbl %r13b, %r9d
movl $0x1, %edi
leaq 0xcd7d(%rip), %rsi      # 0x14b2a
movl %r14d, %edx
xorl %eax, %eax
callq 0x3400
movl $0x108, %edx            # imm = 0x108
movq %r12, %rdi
xorl %esi, %esi
callq 0x31f0
movl $0x4400, 0x24(%rsp)     # imm = 0x4400
movw $0xff, 0x20(%rsp)
movl $0x100000, 0x2c(%rsp)   # imm = 0x100000
movw $0x0, 0x28(%rsp)
testb %r14b, %r14b
leaq 0x94d9(%rip), %rdx      # 0x112c7
leaq 0xcd7b(%rip), %rax      # 0x14b70
cmovneq %rax, %rdx
cmpb $0x0, (%rdx)
je 0x7e15
movl $0x20, %esi
movl $0x20, %ecx
leaq 0x108(%rsp), %rdi
callq 0xc950
movl $0x100000, 0x34(%rsp)   # imm = 0x100000
movw $0x100, 0x30(%rsp)      # imm = 0x100
cmpb $0x0, 0x9(%rsp)
je 0x7e46
movl $0x40, %esi
movl $0x80, %ecx
leaq 0x48(%rsp), %rdi
leaq 0xb64f(%rip), %rdx      # 0x13490
callq 0xc950
cmpb $0x0, 0x8(%rsp)
je 0x7e6b
movl $0x40, %esi
movl $0x40, %ecx
leaq 0xc8(%rsp), %rdi
leaq 0xb62d(%rip), %rdx      # 0x13493
callq 0xc950
movq %r12, %rdi
callq 0x9a31
movl %eax, %ebx
testb %r13b, %r13b
movb %r13b, 0xb(%rsp)
je 0x7e8b
movl $0xff, %edi
callq 0xa23d
andb %al, %bl
movb %bl, 0xa(%rsp)
leaq 0xcce5(%rip), %rdi      # 0x14b7b
movl %ebp, %esi
movl $0x5, %edx
leaq 0xb5e5(%rip), %r13      # 0x13489
movq %r13, %rcx
xorl %eax, %eax
callq 0x9a55
movl %eax, %r15d
leaq 0xccf4(%rip), %rdi      # 0x14bac
movl %ebp, %esi
movl $0x5, %edx
movq %r13, %rcx
xorl %eax, %eax
callq 0x9b13
movl %eax, %r14d
leaq 0xcd09(%rip), %rdi      # 0x14bdc
movl %ebp, %esi
movl $0x5, %edx
movq %r13, %rcx
xorl %eax, %eax
callq 0x9bd1
movl %eax, %ebx
leaq 0xcd21(%rip), %rdi      # 0x14c0e
movl %ebp, %esi
movl $0x5, %edx
movq %r13, %rcx
xorl %eax, %eax
callq 0x9c8f
movl %eax, %r12d
leaq 0xcd39(%rip), %rdi      # 0x14c41
movl %ebp, %esi
movl $0x5, %edx
movq %r13, %rcx
xorl %eax, %eax
callq 0x9d4d
andb %r12b, %al
andb %r14b, %bl
andb %al, %bl
andb 0xa(%rsp), %r15b
andb %bl, %r15b
cmpb $0x0, 0x9(%rsp)
je 0x7f4e
leaq 0xcd3b(%rip), %r14      # 0x14c72
movq %r14, %rdi
callq 0xa2ce
movl %eax, %ebx
movq %r14, %rdi
callq 0xa2ce
andb %bl, %al
andb %al, %r15b
cmpb $0x0, 0x8(%rsp)
movb 0xb(%rsp), %r12b
je 0x7f78
leaq 0xcd1c(%rip), %r14      # 0x14c7d
movq %r14, %rdi
callq 0xa302
movl %eax, %ebx
movq %r14, %rdi
callq 0xa302
andb %bl, %al
andb %al, %r15b
testb %r12b, %r12b
je 0x7f8a
movl $0x5700, %edi           # imm = 0x5700
callq 0xa286
andb %al, %r15b
leaq 0xccfd(%rip), %rdi      # 0x14c8e
movl %ebp, %esi
movl $0x5, %edx
leaq 0xb4ea(%rip), %r12      # 0x13489
movq %r12, %rcx
xorl %eax, %eax
callq 0x9e0b
movl %eax, %ebx
leaq 0xcd10(%rip), %rdi      # 0x14cc2
movl %ebp, %esi
movl $0x5, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x9ec9
movl %eax, %r14d
leaq 0xcd26(%rip), %rdi      # 0x14cf3
movl %ebp, %esi
movl $0x5, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x9f87
movl %eax, %r12d
callq 0x9a36
andb %r12b, %al
andb %bl, %r14b
andb %al, %r14b
andb %r15b, %r14b
je 0x800c
incl %ebp
cmpl $0x6, %ebp
movl 0x1c(%rsp), %r15d
leaq 0x20(%rsp), %r12
jne 0x7d1e
movb $0x1, %r14b
movzbl %r14b, %edi
xorl %esi, %esi
callq 0x3b04
movzbl %al, %edi
xorl %esi, %esi
callq 0x3b04
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq