// File: /workspace/github_c_makefile_star2_O3/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 $0x138, %rsp            # imm = 0x138
leaq 0xce5e(%rip), %rsi      # 0x14acb
leaq 0xb815(%rip), %rcx      # 0x13489
leaq 0xb815(%rip), %r8       # 0x13490
leaq 0xb811(%rip), %r9       # 0x13493
movl $0x1, %r14d
movl $0x1, %edi
movl $0x5, %edx
xorl %eax, %eax
callq 0x3400
callq 0xd136
movl %eax, %ebp
callq 0xe0a9
movl %eax, %r15d
addl %ebp, %r15d
movl %r15d, %eax
xorl $0x5a5a5a5a, %eax       # imm = 0x5A5A5A5A
movl %eax, 0x1c(%rsp)
movl %r15d, %eax
xorl $0xc9c9c9c9, %eax       # imm = 0xC9C9C9C9
movl %eax, 0x10(%rsp)
movl %r15d, %eax
xorl $0x32323232, %eax       # imm = 0x32323232
movl %eax, 0x14(%rsp)
movl %r15d, %eax
xorl $0xe7e7e7e7, %eax       # imm = 0xE7E7E7E7
movl %eax, 0x20(%rsp)
leaq 0x30(%rsp), %r13
movl $0x0, 0x18(%rsp)
movl %r15d, 0x24(%rsp)
cmpl $0x5a5a5a5a, %r15d      # imm = 0x5A5A5A5A
jne 0x7d09
movl 0x10(%rsp), %edi
callq 0x408e
testb $0x1, %al
sete %r12b
movb $0x1, %bl
jmp 0x7d27
movl 0x1c(%rsp), %edi
callq 0x408e
testb $0x1, %al
sete %bl
movb $0x1, %r12b
cmpl $0xc9c9c9c9, %r15d      # imm = 0xC9C9C9C9
jne 0x7fed
movl 0x14(%rsp), %edi
callq 0x408e
testb $0x1, %al
sete 0xc(%rsp)
movl 0x20(%rsp), %edi
callq 0x408e
testb $0x1, %al
sete %al
movzbl %bl, %ebp
movzbl %r12b, %ecx
movzbl 0xc(%rsp), %r8d
movb %al, 0xd(%rsp)
movzbl %al, %r9d
movl $0x1, %edi
leaq 0xcdc4(%rip), %rsi      # 0x14b2a
movl %ebp, %edx
xorl %eax, %eax
callq 0x3400
movl $0x108, %edx            # imm = 0x108
movq %r13, %rdi
xorl %esi, %esi
callq 0x31f0
movl $0x4400, 0x34(%rsp)     # imm = 0x4400
movw $0xff, 0x30(%rsp)
movl $0x100000, 0x3c(%rsp)   # imm = 0x100000
testb %bpl, %bpl
leaq 0x9528(%rip), %rdx      # 0x112c7
leaq 0xcdca(%rip), %rax      # 0x14b70
cmovneq %rax, %rdx
cmpb $0x0, (%rdx)
je 0x7dc6
movl $0x20, %esi
movl $0x20, %ecx
leaq 0x118(%rsp), %rdi
callq 0xc874
movl $0x100000, 0x44(%rsp)   # imm = 0x100000
movw $0x100, 0x40(%rsp)      # imm = 0x100
testb %r12b, %r12b
je 0x7df5
movl $0x40, %esi
movl $0x80, %ecx
leaq 0x58(%rsp), %rdi
leaq 0xb6a0(%rip), %rdx      # 0x13490
callq 0xc874
cmpb $0x0, 0xc(%rsp)
je 0x7e1a
movl $0x40, %esi
movl $0x40, %ecx
leaq 0xd8(%rsp), %rdi
leaq 0xb67e(%rip), %rdx      # 0x13493
callq 0xc874
movq %r13, %rdi
callq 0x9a21
movl %eax, %ebx
cmpb $0x0, 0xd(%rsp)
movb %r12b, 0xf(%rsp)
je 0x7e3c
movl $0xff, %edi
callq 0xa22d
andb %al, %bl
movb %bl, 0xe(%rsp)
leaq 0xcd34(%rip), %rdi      # 0x14b7b
movl %r14d, %esi
movl $0x5, %edx
leaq 0xb633(%rip), %r12      # 0x13489
movq %r12, %rcx
xorl %eax, %eax
callq 0x9a45
movl %eax, %r15d
leaq 0xcd42(%rip), %rdi      # 0x14bac
movl %r14d, %esi
movl $0x5, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x9b03
movl %eax, %r13d
leaq 0xcd56(%rip), %rdi      # 0x14bdc
movl %r14d, %esi
movl $0x5, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x9bc1
movl %eax, %ebp
leaq 0xcd6d(%rip), %rdi      # 0x14c0e
movl %r14d, %esi
movl $0x5, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x9c7f
movl %eax, %ebx
leaq 0xcd85(%rip), %rdi      # 0x14c41
movq %r14, 0x28(%rsp)
movl %r14d, %esi
movl $0x5, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x9d3d
andb %bl, %al
andb %r13b, %bpl
andb %al, %bpl
andb 0xe(%rsp), %r15b
andb %bpl, %r15b
cmpb $0x0, 0xf(%rsp)
je 0x7f08
leaq 0xcd81(%rip), %r14      # 0x14c72
movq %r14, %rdi
callq 0xa2be
movl %eax, %ebx
movq %r14, %rdi
callq 0xa2be
andb %bl, %al
andb %al, %r15b
cmpb $0x0, 0xc(%rsp)
movq 0x28(%rsp), %r12
je 0x7f32
leaq 0xcd62(%rip), %r14      # 0x14c7d
movq %r14, %rdi
callq 0xa2f2
movl %eax, %ebx
movq %r14, %rdi
callq 0xa2f2
andb %bl, %al
andb %al, %r15b
movb 0xd(%rsp), %al
testb %al, %al
je 0x7f47
movl $0x5700, %edi           # imm = 0x5700
callq 0xa276
andb %al, %r15b
movl %r15d, %r14d
leaq 0xcd3d(%rip), %rdi      # 0x14c8e
movl %r12d, %esi
movl $0x5, %edx
leaq 0xb529(%rip), %rbx      # 0x13489
movq %rbx, %rcx
xorl %eax, %eax
callq 0x9dfb
movl %eax, %r15d
leaq 0xcd4e(%rip), %rdi      # 0x14cc2
movl %r12d, %esi
movl $0x5, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x9eb9
movl %eax, %r13d
leaq 0xcd63(%rip), %rdi      # 0x14cf3
movl %r12d, %esi
movl $0x5, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x9f77
movl %eax, %ebp
callq 0x9a26
testb %al, %al
je 0x8032
testb %bpl, %bpl
je 0x8032
testb %r13b, %r13b
je 0x8032
testb %r15b, %r15b
je 0x8032
testb %r14b, %r14b
movl 0x24(%rsp), %r15d
leaq 0x30(%rsp), %r13
je 0x8032
cmpl $0x5, %r12d
leal 0x1(%r12), %eax
setae %cl
movl %ecx, 0x18(%rsp)
movl %eax, %r14d
cmpl $0x6, %eax
jne 0x7ced
jmp 0x8032
movl 0x10(%rsp), %edi
callq 0x408e
testb $0x1, %al
sete %r12b
movb $0x1, 0xc(%rsp)
cmpl $0x32323232, %r15d      # imm = 0x32323232
je 0x7d37
movl 0x14(%rsp), %edi
callq 0x408e
testb $0x1, %al
sete 0xc(%rsp)
movb $0x1, %al
cmpl $0xe7e7e7e7, %r15d      # imm = 0xE7E7E7E7
jne 0x7d37
jmp 0x7d45
movzbl 0x18(%rsp), %edi
andl $0x1, %edi
xorl %esi, %esi
callq 0x3b6d
movzbl %al, %edi
xorl %esi, %esi
callq 0x3b6d
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq