// File: /workspace/github_c_makefile_star2_O0/aremmell[P]libsir/tests/tests.c
// Function: threadrace_thread
unsigned __stdcall threadrace_thread(void* arg) {
#endif
    pid_t threadid       = _sir_gettid();
    thread_args* my_args = (thread_args*)arg;

    rmfile(my_args->log_file, cl_cfg.leave_logs);
    sirfileid id = sir_addfile(my_args->log_file, SIRL_ALL, SIRO_MSGONLY);

    if (0U == id) {
        bool unused = print_test_error(false, false);
        SIR_UNUSED(unused);
#if !defined(__WIN__)
        return NULL;
#else /* __WIN__ */
        return 0;
#endif
    }

    TEST_MSG("hi, i'm thread (id: " SIR_TIDFORMAT "), logging to: '%s'...",
            PID_CAST threadid, my_args->log_file);

#if !defined(DUMA)
# if !defined(__EMSCRIPTEN__)
#  define NUM_ITERATIONS 400
# else
#  define NUM_ITERATIONS 200
# endif
#else
# define NUM_ITERATIONS 100
#endif

    for (size_t n = 0; n < NUM_ITERATIONS; n++) {
        /* choose a random level, and colors. */
        sir_textcolor fg = SIRTC_DEFAULT;
        sir_textcolor bg = SIRTC_DEFAULT;

        if (n % 2 == 0) {
            fg = SIRTC_CYAN;
            bg = SIRTC_BLACK;
            (void)sir_debug("log message #%zu", n);
        } else {
            fg = SIRTC_BLACK;
            bg = SIRTC_CYAN;
            (void)sir_info("log message #%zu", n);
        }

        /* sometimes remove and re-add the log file, and set some options/styles.
         * other times, just set different options/styles. */
        uint32_t rnd = (uint32_t)(n + threadid);
        if (getrand_bool(rnd > 1U ? rnd : 1U)) {
            my_args->pass = print_test_error(sir_remfile(id), false);
            my_args->pass = print_test_error(0 != sir_addfile(my_args->log_file,
                SIRL_ALL, SIRO_MSGONLY), false);

            bool test = sir_settextstyle(SIRL_DEBUG, SIRTA_EMPH, fg, bg) &&
                        sir_settextstyle(SIRL_INFO, SIRTA_BOLD, fg, bg);
            my_args->pass = print_test_error(test, false);

            test = sir_stdoutopts(SIRO_NONAME | SIRO_NOHOST | SIRO_NOMSEC);
            my_args->pass = print_test_error(test, false);
        } else {
            bool test = sir_settextstyle(SIRL_DEBUG, SIRTA_ULINE, fg, bg) &&
                        sir_settextstyle(SIRL_INFO, SIRTA_NORMAL, fg, bg);
            my_args->pass = print_test_error(test, false);

            test = sir_fileopts(id, SIRO_NOPID | SIRO_NOHOST);
            my_args->pass = print_test_error(test, false);

            test = sir_stdoutopts(SIRO_NOTIME | SIRO_NOLEVEL);
            my_args->pass = print_test_error(test, false);
        }

        if (!my_args->pass)
            break;
    }

    my_args->pass = print_test_error(sir_remfile(id), false);

    rmfile(my_args->log_file, cl_cfg.leave_logs);

#if !defined(__WIN__)
    return NULL;
#else /* __WIN__ */
    return 0U;
#endif
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
callq 0x18410
movl %eax, 0x34(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rdi
movb 0x19821(%rip), %al      # 0x289b8
andb $0x1, %al
movzbl %al, %esi
callq 0x5530
movq 0x28(%rsp), %rdi
movl $0xff, %esi
movl $0x7f00, %edx           # imm = 0x7F00
callq 0xfee0
movl %eax, 0x24(%rsp)
xorl %eax, %eax
cmpl 0x24(%rsp), %eax
jne 0xf1de
xorl %esi, %esi
movl %esi, %edi
callq 0x4da0
andb $0x1, %al
movb %al, 0x23(%rsp)
movq $0x0, 0x40(%rsp)
jmp 0xf4e8
movl 0x34(%rsp), %esi
movq 0x28(%rsp), %rdx
leaq 0x11da9(%rip), %rdi     # 0x20f97
movb $0x0, %al
callq 0x4180
movq $0x0, 0x18(%rsp)
cmpq $0x190, 0x18(%rsp)      # imm = 0x190
jae 0xf4a4
movl $0x100, 0x14(%rsp)      # imm = 0x100
movl $0x100, 0x10(%rsp)      # imm = 0x100
movq 0x18(%rsp), %rax
andq $0x1, %rax
cmpq $0x0, %rax
jne 0xf251
movl $0x6, 0x14(%rsp)
movl $0x0, 0x10(%rsp)
movq 0x18(%rsp), %rsi
leaq 0x11d7e(%rip), %rdi     # 0x20fc6
movb $0x0, %al
callq 0xf5f0
jmp 0xf274
movl $0x0, 0x14(%rsp)
movl $0x6, 0x10(%rsp)
movq 0x18(%rsp), %rsi
leaq 0x11d59(%rip), %rdi     # 0x20fc6
movb $0x0, %al
callq 0xf770
movq 0x18(%rsp), %rax
movslq 0x34(%rsp), %rcx
addq %rcx, %rax
movl %eax, 0xc(%rsp)
cmpl $0x1, 0xc(%rsp)
jbe 0xf296
movl 0xc(%rsp), %eax
movl %eax, 0x4(%rsp)
jmp 0xf2a1
movl $0x1, %eax
movl %eax, 0x4(%rsp)
jmp 0xf2a1
movl 0x4(%rsp), %edi
callq 0xf500
testb $0x1, %al
jne 0xf2b3
jmp 0xf3b3
movl 0x24(%rsp), %edi
callq 0xff10
movzbl %al, %edi
andl $0x1, %edi
xorl %esi, %esi
callq 0x4da0
movb %al, %cl
movq 0x28(%rsp), %rax
andb $0x1, %cl
movb %cl, 0x1000(%rax)
movq 0x28(%rsp), %rdi
movl $0xff, %esi
movl $0x7f00, %edx           # imm = 0x7F00
callq 0xfee0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
setne %al
movzbl %al, %edi
andl $0x1, %edi
xorl %esi, %esi
callq 0x4da0
movb %al, %cl
movq 0x28(%rsp), %rax
andb $0x1, %cl
movb %cl, 0x1000(%rax)
movl 0x14(%rsp), %edx
movl 0x10(%rsp), %ecx
movl $0x80, %edi
movl $0x3, %esi
callq 0x100a0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x3(%rsp)
jne 0xf339
jmp 0xf354
movl 0x14(%rsp), %edx
movl 0x10(%rsp), %ecx
movl $0x40, %edi
movl $0x1, %esi
callq 0x100a0
movb %al, 0x3(%rsp)
movb 0x3(%rsp), %al
andb $0x1, %al
movb %al, 0xb(%rsp)
movb 0xb(%rsp), %al
xorl %esi, %esi
andb $0x1, %al
movzbl %al, %edi
callq 0x4da0
movb %al, %cl
movq 0x28(%rsp), %rax
andb $0x1, %cl
movb %cl, 0x1000(%rax)
movl $0x1600, %edi           # imm = 0x1600
callq 0x10210
andb $0x1, %al
movb %al, 0xb(%rsp)
movb 0xb(%rsp), %al
xorl %esi, %esi
andb $0x1, %al
movzbl %al, %edi
callq 0x4da0
movb %al, %cl
movq 0x28(%rsp), %rax
andb $0x1, %cl
movb %cl, 0x1000(%rax)
jmp 0xf47f
movl 0x14(%rsp), %edx
movl 0x10(%rsp), %ecx
movl $0x80, %edi
movl $0x4, %esi
callq 0x100a0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x2(%rsp)
jne 0xf3d9
jmp 0xf3f1
movl 0x14(%rsp), %edx
movl 0x10(%rsp), %ecx
movl $0x40, %edi
xorl %esi, %esi
callq 0x100a0
movb %al, 0x2(%rsp)
movb 0x2(%rsp), %al
andb $0x1, %al
movb %al, 0xa(%rsp)
movb 0xa(%rsp), %al
xorl %esi, %esi
andb $0x1, %al
movzbl %al, %edi
callq 0x4da0
movb %al, %cl
movq 0x28(%rsp), %rax
andb $0x1, %cl
movb %cl, 0x1000(%rax)
movl 0x24(%rsp), %edi
movl $0x2400, %esi           # imm = 0x2400
callq 0x10010
andb $0x1, %al
movb %al, 0xa(%rsp)
movb 0xa(%rsp), %al
xorl %esi, %esi
andb $0x1, %al
movzbl %al, %edi
callq 0x4da0
movb %al, %cl
movq 0x28(%rsp), %rax
andb $0x1, %cl
movb %cl, 0x1000(%rax)
movl $0x900, %edi            # imm = 0x900
callq 0x10210
andb $0x1, %al
movb %al, 0xa(%rsp)
movb 0xa(%rsp), %al
xorl %esi, %esi
andb $0x1, %al
movzbl %al, %edi
callq 0x4da0
movb %al, %cl
movq 0x28(%rsp), %rax
andb $0x1, %cl
movb %cl, 0x1000(%rax)
movq 0x28(%rsp), %rax
testb $0x1, 0x1000(%rax)
jne 0xf48f
jmp 0xf4a4
jmp 0xf491
movq 0x18(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
jmp 0xf1fe
movl 0x24(%rsp), %edi
callq 0xff10
movzbl %al, %edi
andl $0x1, %edi
xorl %esi, %esi
callq 0x4da0
movb %al, %cl
movq 0x28(%rsp), %rax
andb $0x1, %cl
movb %cl, 0x1000(%rax)
movq 0x28(%rsp), %rdi
movb 0x194e3(%rip), %al      # 0x289b8
andb $0x1, %al
movzbl %al, %esi
callq 0x5530
movq $0x0, 0x40(%rsp)
movq 0x40(%rsp), %rax
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)