// File: /workspace/github_c_makefile_star2_O0/aremmell[P]libsir/tests/tests.c
// Function: sirtest_threadidsanity
bool sirtest_threadidsanity(void)
{
#if defined(SIR_NO_THREAD_NAMES)
    TEST_MSG_0(SIR_DGRAY("test skipped for this system configuration"));
    return true;
#endif
    INIT(si, SIRL_ALL, 0, 0, 0);
    bool pass = si_init;

    static const char* thread_name = "mythread";
    static const char* logfilename = MAKE_LOG_NAME("thread-id-name.log");

    TEST_MSG("adding log file '%s' to libsir...", logfilename);
    sirfileid id = sir_addfile(logfilename, SIRL_DEBUG, SIRO_NOHDR | SIRO_NOHOST);
    _sir_eqland(pass, 0U != id);

    (void)print_test_error(pass, false);

    TEST_MSG_0("logging a message normally...");
    _sir_eqland(pass, sir_debug("this is a test of the libsir system"));

    TEST_MSG("setting the thread name to '%s' and logging again...", thread_name);

    _sir_eqland(pass, _sir_setthreadname(thread_name));
    sir_sleep_msec((uint32_t)SIR_THRD_CHK_INTERVAL + 200U);

    (void)print_test_error(pass, false);

    _sir_eqland(pass, sir_debug("this is a test of the libsir system after setting thread name"));

    TEST_MSG_0("setting the thread name to '' and logging again...");

    _sir_eqland(pass, _sir_setthreadname(""));
    sir_sleep_msec((uint32_t)SIR_THRD_CHK_INTERVAL + 200U);

    (void)print_test_error(pass, false);

    _sir_eqland(pass, sir_debug("this is a test of the libsir system after clearing thread name"));

     /* remove the log file from libsir, then open it and read it line by line. */
    TEST_MSG("removing %s from libsir...", logfilename);
    _sir_eqland(pass, sir_remfile(id));

    TEST_MSG("opening %s for reading...", logfilename);

    FILE* f = fopen(logfilename, "r");
    if (!f) {
        pass = false;
    } else {
        /* look for, in order, TID, thread name, TID. */
        for (size_t n = 0; n < 3; n++) {
            char buf[256] = {0};
            _sir_eqland(pass, 0 != sir_readline(f, buf, 256));
            TEST_MSG("read line %zu: '%s'", n, buf);

            char search[SIR_MAXPID] = {0};
            switch (n) {
                case 0:
                case 2:
                    (void)snprintf(search, SIR_MAXPID, SIR_TIDFORMAT, _sir_gettid());
                break;
                case 1:
                    (void)_sir_strncpy(search, SIR_MAXPID, thread_name, strlen(thread_name));
                break;
                default: break; // GCOVR_EXCL_LINE
            }

            bool found = NULL != strstr(buf, search);
            _sir_eqland(pass, found);

            if (found)
                TEST_MSG(SIR_GREEN("line %zu: found '%s'"), n, search);
            else
                TEST_MSG(SIR_RED("line %zu: did not find '%s'"), n, search);
        }

        _sir_safefclose(&f);
        TEST_MSG("deleting %s...", logfilename);
        rmfile(logfilename, cl_cfg.leave_logs);
    }

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

// Assembly:
subq $0x278, %rsp            # imm = 0x278
leaq 0x170(%rsp), %rdi
xorl %esi, %esi
movl $0x108, %edx            # imm = 0x108
callq 0x4210
movl $0x100000, 0x174(%rsp) # imm = 0x100000
movw $0xff, 0x170(%rsp)
movl $0x100000, 0x17c(%rsp) # imm = 0x100000
movw $0x0, 0x178(%rsp)
leaq 0x1719b(%rip), %rdi     # 0x1d2c7
xorl %esi, %esi
leaq 0x176b0(%rip), %rdx     # 0x1d7e5
leaq 0x173f1(%rip), %rcx     # 0x1d52d
movl $0xf2, %r8d
callq 0x5ce0
testb $0x1, %al
jne 0x614d
jmp 0x6170
leaq 0x170(%rsp), %rdi
addq $0xe8, %rdi
movl $0x20, %ecx
leaq 0x1715f(%rip), %rdx     # 0x1d2c7
movq %rcx, %rsi
callq 0x14f50
movb $0x0, 0x16f(%rsp)
leaq 0x170(%rsp), %rdi
callq 0xf560
andb $0x1, %al
movb %al, 0x16f(%rsp)
movb 0x16f(%rsp), %al
andb $0x1, %al
movb %al, 0x16e(%rsp)
movq 0x224eb(%rip), %rsi     # 0x28690
leaq 0x1755c(%rip), %rdi     # 0x1d708
movb $0x0, %al
callq 0x4180
movq 0x224d6(%rip), %rdi     # 0x28690
movl $0x80, %esi
movl $0x10400, %edx          # imm = 0x10400
callq 0xfee0
movl %eax, 0x168(%rsp)
xorl %eax, %eax
xorl %ecx, %ecx
cmpl 0x168(%rsp), %ecx
movb %al, 0x3e(%rsp)
je 0x61ec
movb 0x16e(%rsp), %al
movb %al, 0x3e(%rsp)
movb 0x3e(%rsp), %al
andb $0x1, %al
movb %al, 0x16e(%rsp)
movb 0x16e(%rsp), %al
xorl %esi, %esi
andb $0x1, %al
movzbl %al, %edi
callq 0x4da0
leaq 0x1760c(%rip), %rdi     # 0x1d81f
movb $0x0, %al
callq 0x4180
leaq 0x1761e(%rip), %rdi     # 0x1d83f
movb $0x0, %al
callq 0xf5f0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x3d(%rsp)
jne 0x6237
jmp 0x6242
movb 0x16e(%rsp), %al
movb %al, 0x3d(%rsp)
movb 0x3d(%rsp), %al
andb $0x1, %al
movb %al, 0x16e(%rsp)
movq 0x22432(%rip), %rsi     # 0x28688
leaq 0x17606(%rip), %rdi     # 0x1d863
movb $0x0, %al
callq 0x4180
movq 0x2241d(%rip), %rdi     # 0x28688
callq 0x19320
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x3c(%rsp)
jne 0x627f
jmp 0x628a
movb 0x16e(%rsp), %al
movb %al, 0x3c(%rsp)
movb 0x3c(%rsp), %al
andb $0x1, %al
movb %al, 0x16e(%rsp)
movl $0x215, %edi            # imm = 0x215
callq 0x53e0
movb 0x16e(%rsp), %al
xorl %esi, %esi
andb $0x1, %al
movzbl %al, %edi
callq 0x4da0
leaq 0x175df(%rip), %rdi     # 0x1d89a
movb $0x0, %al
callq 0xf5f0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x3b(%rsp)
jne 0x62d1
jmp 0x62dc
movb 0x16e(%rsp), %al
movb %al, 0x3b(%rsp)
movb 0x3b(%rsp), %al
andb $0x1, %al
movb %al, 0x16e(%rsp)
leaq 0x175e8(%rip), %rdi     # 0x1d8d8
movb $0x0, %al
callq 0x4180
leaq 0x16fc9(%rip), %rdi     # 0x1d2c7
callq 0x19320
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x3a(%rsp)
jne 0x6312
jmp 0x631d
movb 0x16e(%rsp), %al
movb %al, 0x3a(%rsp)
movb 0x3a(%rsp), %al
andb $0x1, %al
movb %al, 0x16e(%rsp)
movl $0x215, %edi            # imm = 0x215
callq 0x53e0
movb 0x16e(%rsp), %al
xorl %esi, %esi
andb $0x1, %al
movzbl %al, %edi
callq 0x4da0
leaq 0x175bf(%rip), %rdi     # 0x1d90d
movb $0x0, %al
callq 0xf5f0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x39(%rsp)
jne 0x6364
jmp 0x636f
movb 0x16e(%rsp), %al
movb %al, 0x39(%rsp)
movb 0x39(%rsp), %al
andb $0x1, %al
movb %al, 0x16e(%rsp)
movq 0x2230d(%rip), %rsi     # 0x28690
leaq 0x173c8(%rip), %rdi     # 0x1d752
movb $0x0, %al
callq 0x4180
movl 0x168(%rsp), %edi
callq 0xff10
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x38(%rsp)
jne 0x63ac
jmp 0x63b7
movb 0x16e(%rsp), %al
movb %al, 0x38(%rsp)
movb 0x38(%rsp), %al
andb $0x1, %al
movb %al, 0x16e(%rsp)
movq 0x222c5(%rip), %rsi     # 0x28690
leaq 0x1739d(%rip), %rdi     # 0x1d76f
movb $0x0, %al
callq 0x4180
movq 0x222b0(%rip), %rdi     # 0x28690
leaq 0x1ad98(%rip), %rsi     # 0x2117f
callq 0x44a0
movq %rax, 0x160(%rsp)
cmpq $0x0, 0x160(%rsp)
jne 0x640c
movb $0x0, 0x16e(%rsp)
jmp 0x6608
movq $0x0, 0x158(%rsp)
cmpq $0x3, 0x158(%rsp)
jae 0x65cf
leaq 0x50(%rsp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x4210
movq 0x160(%rsp), %rdi
leaq 0x50(%rsp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x5430
movq %rax, %rdx
xorl %eax, %eax
xorl %ecx, %ecx
cmpq %rdx, %rcx
movb %al, 0x37(%rsp)
je 0x646a
movb 0x16e(%rsp), %al
movb %al, 0x37(%rsp)
movb 0x37(%rsp), %al
andb $0x1, %al
movb %al, 0x16e(%rsp)
movq 0x158(%rsp), %rsi
leaq 0x174c6(%rip), %rdi     # 0x1d94c
xorl %eax, %eax
leaq 0x50(%rsp), %rdx
callq 0x4180
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq 0x158(%rsp), %rax
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0x64c8
jmp 0x64ae
movq 0x28(%rsp), %rax
subq $0x1, %rax
je 0x64f3
jmp 0x64bb
movq 0x28(%rsp), %rax
subq $0x2, %rax
jne 0x652e
jmp 0x64c8
leaq 0x40(%rsp), %rax
movq %rax, 0x20(%rsp)
callq 0x18410
movq 0x20(%rsp), %rdi
movl %eax, %ecx
movl $0x10, %esi
leaq 0x1b75f(%rip), %rdx     # 0x21c49
movb $0x0, %al
callq 0x41b0
jmp 0x6530
leaq 0x40(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x22184(%rip), %rax     # 0x28688
movq %rax, 0x18(%rsp)
movq 0x22178(%rip), %rdi     # 0x28688
callq 0x4160
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rdx
movq %rax, %rcx
movl $0x10, %esi
callq 0x14f50
jmp 0x6530
jmp 0x6530
leaq 0x50(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x45a0
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
setne %al
andb $0x1, %al
movb %al, 0x3f(%rsp)
xorl %eax, %eax
testb $0x1, 0x3f(%rsp)
movb %al, 0xf(%rsp)
je 0x6568
movb 0x16e(%rsp), %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
andb $0x1, %al
movb %al, 0x16e(%rsp)
testb $0x1, 0x3f(%rsp)
je 0x6599
movq 0x158(%rsp), %rsi
leaq 0x40(%rsp), %rdx
leaq 0x173d2(%rip), %rdi     # 0x1d962
movb $0x0, %al
callq 0x4180
jmp 0x65b4
movq 0x158(%rsp), %rsi
leaq 0x40(%rsp), %rdx
leaq 0x173e0(%rip), %rdi     # 0x1d98d
movb $0x0, %al
callq 0x4180
jmp 0x65b6
movq 0x158(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x158(%rsp)
jmp 0x6418
leaq 0x160(%rsp), %rdi
callq 0x14530
movq 0x220ad(%rip), %rsi     # 0x28690
leaq 0x171ea(%rip), %rdi     # 0x1d7d4
movb $0x0, %al
callq 0x4180
movq 0x22098(%rip), %rdi     # 0x28690
movb 0x223ba(%rip), %al      # 0x289b8
andb $0x1, %al
movzbl %al, %esi
callq 0x5530
callq 0xf580
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0xe(%rsp)
jne 0x661c
jmp 0x6627
movb 0x16e(%rsp), %al
movb %al, 0xe(%rsp)
movb 0xe(%rsp), %al
andb $0x1, %al
movb %al, 0x16e(%rsp)
movb 0x16e(%rsp), %al
xorl %esi, %esi
andb $0x1, %al
movzbl %al, %edi
callq 0x4da0
andb $0x1, %al
addq $0x278, %rsp            # imm = 0x278
retq
nopw %cs:(%rax,%rax)