// File: /workspace/github_c_makefile_star2_O2/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 0xc182(%rip), %rsi      # 0x13a8b
leaq 0xab39(%rip), %rcx      # 0x12449
leaq 0xab39(%rip), %r8       # 0x12450
leaq 0xab35(%rip), %r9       # 0x12453
pushq $0x1
popq %rbp
pushq $0x5
popq %rdx
movl %ebp, %edi
xorl %eax, %eax
callq 0x3410
callq 0xc8ce
movl %eax, %ebx
callq 0xd7d8
addl %ebx, %eax
movl %eax, %ecx
xorl $0x5a5a5a5a, %ecx       # imm = 0x5A5A5A5A
movl %ecx, 0x18(%rsp)
movl %eax, %ecx
xorl $0xc9c9c9c9, %ecx       # imm = 0xC9C9C9C9
movl %ecx, 0x14(%rsp)
movl %eax, %ecx
xorl $0x32323232, %ecx       # imm = 0x32323232
movl %ecx, 0x10(%rsp)
xorl $0xe7e7e7e7, %eax       # imm = 0xE7E7E7E7
movl %eax, 0x1c(%rsp)
leaq 0x20(%rsp), %r13
movl %ebp, %r14d
cmpl $0x6, %ebp
je 0x7c10
movl 0x18(%rsp), %edi
callq 0x948a
movl %eax, %ebx
movl 0x14(%rsp), %edi
callq 0x948a
movl %eax, %r12d
movl 0x10(%rsp), %edi
callq 0x948a
movl %eax, %r15d
movl 0x1c(%rsp), %edi
callq 0x948a
movl %eax, %ebp
movzbl %bl, %ebx
movzbl %r12b, %ecx
movzbl %r15b, %r8d
movzbl %al, %r9d
pushq $0x1
popq %rdi
leaq 0xc12a(%rip), %rsi      # 0x13aea
movl %ebx, %edx
xorl %eax, %eax
callq 0x3410
movl $0x108, %edx            # imm = 0x108
movq %r13, %rdi
xorl %esi, %esi
callq 0x31f0
movl $0x4400, 0x24(%rsp)     # imm = 0x4400
movw $0xff, 0x20(%rsp)
movl $0x100000, 0x2c(%rsp)   # imm = 0x100000
testb %bl, %bl
leaq 0x88cf(%rip), %rdx      # 0x102c7
leaq 0xc131(%rip), %rax      # 0x13b30
cmovneq %rax, %rdx
cmpb $0x0, (%rdx)
je 0x7a1b
leaq 0x108(%rsp), %rdi
pushq $0x20
popq %rcx
movq %rcx, %rsi
callq 0xc015
movl $0x100000, 0x34(%rsp)   # imm = 0x100000
movw $0x100, 0x30(%rsp)      # imm = 0x100
testb %r12b, %r12b
je 0x7a48
movl $0x80, %ecx
leaq 0x48(%rsp), %rdi
pushq $0x40
popq %rsi
leaq 0xaa0d(%rip), %rdx      # 0x12450
callq 0xc015
testb %r15b, %r15b
je 0x7a67
leaq 0xc8(%rsp), %rdi
pushq $0x40
popq %rcx
movq %rcx, %rsi
leaq 0xa9f1(%rip), %rdx      # 0x12453
callq 0xc015
movq %r13, %rdi
callq 0x94a9
movl %eax, %ebx
testb %bpl, %bpl
movb %bpl, 0xd(%rsp)
movb %r15b, 0xc(%rsp)
movb %r12b, 0xf(%rsp)
je 0x7a91
movl $0xff, %edi
callq 0x9c4f
andb %al, %bl
movb %bl, 0xb(%rsp)
leaq 0xc09f(%rip), %rdi      # 0x13b3b
movl %r14d, %esi
pushq $0x5
popq %r15
movl %r15d, %edx
leaq 0xa99c(%rip), %r12      # 0x12449
movq %r12, %rcx
xorl %eax, %eax
callq 0x94cd
movl %eax, %ebx
leaq 0xc0ac(%rip), %rdi      # 0x13b6c
movl %r14d, %esi
movl %r15d, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x95a2
movb %al, 0xe(%rsp)
leaq 0xc0c1(%rip), %rdi      # 0x13b9c
movl %r14d, %esi
movl %r15d, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x9651
movl %eax, %ebp
leaq 0xc0da(%rip), %rdi      # 0x13bce
movl %r14d, %esi
movl %r15d, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x9700
movl %eax, %r13d
leaq 0xc0f3(%rip), %rdi      # 0x13c01
movl %r14d, %esi
movl %r15d, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x97af
andb %r13b, %al
andb 0xe(%rsp), %bpl
andb %al, %bpl
andb 0xb(%rsp), %bl
andb %bpl, %bl
cmpb $0x0, 0xf(%rsp)
je 0x7b55
leaq 0xc0f4(%rip), %r15      # 0x13c32
movq %r15, %rdi
callq 0x9cd8
movl %eax, %ebp
movq %r15, %rdi
callq 0x9cd8
andb %bpl, %al
andb %al, %bl
movb 0xc(%rsp), %al
testb %al, %al
je 0x7b7b
leaq 0xc0d9(%rip), %r15      # 0x13c3d
movq %r15, %rdi
callq 0x9d09
movl %eax, %ebp
movq %r15, %rdi
callq 0x9d09
andb %bpl, %al
andb %al, %bl
movb 0xd(%rsp), %al
testb %al, %al
je 0x7b8f
movl $0x5700, %edi           # imm = 0x5700
callq 0x9c93
andb %al, %bl
leaq 0xc0b8(%rip), %rdi      # 0x13c4e
movl %r14d, %esi
pushq $0x5
popq %r13
movl %r13d, %edx
leaq 0xa8a2(%rip), %r12      # 0x12449
movq %r12, %rcx
xorl %eax, %eax
callq 0x985e
movl %eax, %ebp
leaq 0xc0c8(%rip), %rdi      # 0x13c82
movl %r14d, %esi
movl %r13d, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x990d
movl %eax, %r15d
leaq 0xc0df(%rip), %rdi      # 0x13cb3
movl %r14d, %esi
movl %r13d, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x99bc
movl %eax, %r12d
callq 0x94ae
testb %al, %al
leaq 0x20(%rsp), %r13
je 0x7c10
testb %r12b, %r12b
je 0x7c10
testb %r15b, %r15b
je 0x7c10
testb %bpl, %bpl
je 0x7c10
leal 0x1(%r14), %ebp
testb %bl, %bl
jne 0x796d
xorl %edi, %edi
cmpl $0x6, %r14d
setae %dil
xorl %esi, %esi
callq 0x3ac9
movzbl %al, %edi
xorl %esi, %esi
callq 0x3ac9
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq