// File: /workspace/github_c_makefile_star2_O0/aremmell[P]libsir/src/sirinternal.c
// Function: sir_logv
bool _sir_logv(sir_level level, PRINTF_FORMAT const char* format, va_list args) {
    if (!_sir_sanity() || !_sir_validlevel(level) || !_sir_validstr(format))
        return false;

    (void)_sir_seterror(_SIR_E_NOERROR);

    _SIR_LOCK_SECTION(sirconfig, _cfg, SIRMI_CONFIG, false);

    sirbuf buf = {0};

    /* from time to time, update the host name in the config, just in case. */
    time_t now_sec = -1;
    if (-1 != time(&now_sec) &&
        (now_sec - _cfg->state.last_hname_chk) > SIR_HNAME_CHK_INTERVAL) {
        _sir_selflog("updating hostname...");
        if (!_sir_gethostname(_cfg->state.hostname)) {
            _sir_selflog("error: failed to get hostname!");
        } else {
            _cfg->state.last_hname_chk = now_sec;
            _sir_selflog("hostname: '%s'", _cfg->state.hostname);
        }
    }

    /* format timestamp (h/m/s only if the integer time has changed). */
    long now_msec = 0L;
    bool gettime = _sir_clock_gettime(SIR_WALLCLOCK, &now_sec, &now_msec);
    SIR_ASSERT_UNUSED(gettime, gettime);

    /* milliseconds. */
    _sir_snprintf_trunc(buf.msec, SIR_MAXMSEC, SIR_MSECFORMAT, now_msec);

    /* hours/minutes/seconds. */
    if (now_sec > _sir_last_timestamp || !*_cfg->state.timestamp) {
        _sir_last_timestamp = now_sec;
        bool fmt = _sir_formattime(now_sec, _cfg->state.timestamp, SIR_TIMEFORMAT);
        SIR_ASSERT_UNUSED(fmt, fmt);
    }

    /* check elapsed time since updating thread identifier/name. */
    sir_time thrd_chk;
    double msec_since_thrd_chk = _sir_msec_since(&_sir_last_thrd_chk, &thrd_chk);

    /* update the thread identifier/name if enough time has elapsed. */
    if (msec_since_thrd_chk > SIR_THRD_CHK_INTERVAL) {
        _sir_last_thrd_chk = thrd_chk;

        pid_t tid         = _sir_gettid();
        bool resolved_tid = false;

        /* prefer thread names. */
        resolved_tid = _sir_getthreadname(_sir_tid);

        /* if tid is identical to pid... */
        if (!resolved_tid && tid == _cfg->state.pid) {
            /* don't use anything to identify the thread. */
            _sir_resetstr(_sir_tid);
            resolved_tid = true;
        }

        /* fall back on tid. */
        if (!resolved_tid)
            _sir_snprintf_trunc(_sir_tid, SIR_MAXPID, SIR_TIDFORMAT,
                PID_CAST tid);
    }

    sirconfig cfg;
    (void)memcpy(&cfg, _cfg, sizeof(sirconfig));
    _SIR_UNLOCK_SECTION(SIRMI_CONFIG);

    buf.timestamp = cfg.state.timestamp;
    buf.hostname  = cfg.state.hostname;
    buf.pid       = cfg.state.pidbuf;
    buf.name      = cfg.si.name;

#if !defined(SIR_NO_TEXT_STYLING)
    const char* style_str = _sir_gettextstyle(level);

    SIR_ASSERT(NULL != style_str);
    if (NULL != style_str)
        (void)_sir_strncpy(buf.style, SIR_MAXSTYLE, style_str,
            strnlen(style_str, SIR_MAXSTYLE));
#endif

    buf.level = _sir_formattedlevelstr(level);

    if (_sir_validstrnofail(_sir_tid))
        (void)_sir_strncpy(buf.tid, SIR_MAXPID, _sir_tid,
            strnlen(_sir_tid, SIR_MAXPID));

    (void)vsnprintf(buf.message, SIR_MAXMESSAGE, format, args);

    if (!_sir_validstrnofail(buf.message))
        return _sir_seterror(_SIR_E_INTERNAL);

    bool match             = false;
    bool exit_early        = false;
    bool update_last_props = true;
    uint64_t hash          = 0ULL;

    if (cfg.state.last.level == level &&
        cfg.state.last.prefix[0] == buf.message[0]  &&
        cfg.state.last.prefix[1] == buf.message[1]) {
        hash  = FNV64_1a(buf.message);
        match = cfg.state.last.hash == hash;
    }

    if (match) {
        cfg.state.last.counter++;

        if (cfg.state.last.counter >= cfg.state.last.threshold - 2) {
            size_t old_threshold = cfg.state.last.threshold;

            update_last_props = false;
            cfg.state.last.threshold *= SIR_SQUELCH_BACKOFF_FACTOR;
            cfg.state.last.squelch = true;

            _sir_selflog("hit squelch threshold of %zu; setting new threshold"
                         " to %zu (factor: %d)", old_threshold,
                         cfg.state.last.threshold, SIR_SQUELCH_BACKOFF_FACTOR);

            (void)snprintf(buf.message, SIR_MAXMESSAGE, SIR_SQUELCH_MSG_FORMAT, old_threshold);
        } else if (cfg.state.last.squelch) {
            exit_early = true;
        }
    } else {
        cfg.state.last.squelch   = false;
        cfg.state.last.counter   = 0;
        cfg.state.last.threshold = SIR_SQUELCH_THRESHOLD;
        /* _sir_selflog("message '%s' does not match last; resetting", buf.message); */
    }

    _cfg = _sir_locksection(SIRMI_CONFIG);
    if (!_cfg)
        return _sir_seterror(_SIR_E_INTERNAL);

    _cfg->state.last.squelch = cfg.state.last.squelch;

    if (update_last_props) {
        _cfg->state.last.level     = level;
        _cfg->state.last.hash      = hash;
        _cfg->state.last.prefix[0] = buf.message[0];
        _cfg->state.last.prefix[1] = buf.message[1];
    }

    _cfg->state.last.counter   = cfg.state.last.counter;
    _cfg->state.last.threshold = cfg.state.last.threshold;

    _SIR_UNLOCK_SECTION(SIRMI_CONFIG);

    if (exit_early)
        return false;

    bool dispatched = _sir_dispatch(&cfg.si, level, &buf);
    return update_last_props ? dispatched : false;
}

// Assembly:
subq $0x24c8, %rsp           # imm = 0x24C8
movw %di, %ax
movw %ax, 0x24c4(%rsp)
movq %rsi, 0x24b8(%rsp)
movq %rdx, 0x24b0(%rsp)
callq 0x9d10
testb $0x1, %al
jne 0xacdd
jmp 0xad2d
leaq 0x65e8(%rip), %rsi      # 0x112cc
leaq 0x63ab(%rip), %rdx      # 0x11096
movl $0x22c, %ecx            # imm = 0x22C
movzwl 0x24c4(%rsp), %edi
callq 0x8080
testb $0x1, %al
jne 0xad03
jmp 0xad2d
movq 0x24b8(%rsp), %rdi
movl $0x1, %esi
leaq 0x65b5(%rip), %rdx      # 0x112cc
leaq 0x6378(%rip), %rcx      # 0x11096
movl $0x22c, %r8d            # imm = 0x22C
callq 0xa720
testb $0x1, %al
jne 0xad3a
movb $0x0, 0x24c7(%rsp)
jmp 0xb550
movl $0x80010000, %edi       # imm = 0x80010000
leaq 0x6586(%rip), %rsi      # 0x112cc
leaq 0x6349(%rip), %rdx      # 0x11096
movl $0x22f, %ecx            # imm = 0x22F
callq 0x3940
xorl %edi, %edi
callq 0x9650
movq %rax, 0x24a8(%rsp)
cmpq $0x0, 0x24a8(%rsp)
jne 0xad9b
movl $0x800f0000, %edi       # imm = 0x800F0000
leaq 0x654f(%rip), %rsi      # 0x112cc
leaq 0x6312(%rip), %rdx      # 0x11096
movl $0x231, %ecx            # imm = 0x231
callq 0x3940
movb $0x0, 0x24c7(%rsp)
jmp 0xb550
jmp 0xad9d
leaq 0x348(%rsp), %rdi
xorl %esi, %esi
movl $0x2160, %edx           # imm = 0x2160
callq 0x21c0
movq $-0x1, 0x340(%rsp)
leaq 0x340(%rsp), %rdi
callq 0x22d0
movq %rax, %rcx
movq $-0x1, %rax
cmpq %rcx, %rax
je 0xae66
movq 0x340(%rsp), %rax
movq 0x24a8(%rsp), %rcx
subq 0x208(%rcx), %rax
cmpq $0x3c, %rax
jle 0xae66
leaq 0x64d5(%rip), %rdi      # 0x112d6
movb $0x0, %al
callq 0x9730
movq 0x24a8(%rsp), %rdi
addq $0x108, %rdi            # imm = 0x108
callq 0xb570
testb $0x1, %al
jne 0xae30
leaq 0x64c4(%rip), %rdi      # 0x112eb
movb $0x0, %al
callq 0x9730
jmp 0xae64
movq 0x340(%rsp), %rcx
movq 0x24a8(%rsp), %rax
movq %rcx, 0x208(%rax)
movq 0x24a8(%rsp), %rsi
addq $0x108, %rsi            # imm = 0x108
leaq 0x64ad(%rip), %rdi      # 0x1130a
movb $0x0, %al
callq 0x9730
jmp 0xae66
movq $0x0, 0x338(%rsp)
movl $0x5, %edi
leaq 0x340(%rsp), %rsi
leaq 0x338(%rsp), %rdx
callq 0xb5e0
andb $0x1, %al
movb %al, 0x337(%rsp)
movq $0x5, 0x328(%rsp)
leaq 0x348(%rsp), %rdi
addq $0x38, %rdi
movq 0x328(%rsp), %rsi
movq 0x338(%rsp), %rcx
leaq 0x6455(%rip), %rdx      # 0x11319
movb $0x0, %al
callq 0x2170
cmpl $0x0, %eax
jne 0xaed8
movq 0x328(%rsp), %rax
jmp 0xaeda
movq 0x340(%rsp), %rax
movq %rax, 0x38(%rsp)
movq %fs:0x0, %rax
movq %rax, %rcx
movq 0x38(%rsp), %rax
leaq -0x10(%rcx), %rcx
cmpq (%rcx), %rax
jg 0xaf18
movq 0x24a8(%rsp), %rax
cmpb $0x0, 0x224(%rax)
jne 0xaf73
movq 0x340(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %fs:0x0, %rax
movq 0x30(%rsp), %rcx
leaq -0x10(%rax), %rax
movq %rcx, (%rax)
movq 0x340(%rsp), %rdi
movq 0x24a8(%rsp), %rsi
addq $0x108, %rsi            # imm = 0x108
addq $0x11c, %rsi            # imm = 0x11C
leaq 0x63bb(%rip), %rdx      # 0x11320
callq 0xb6b0
andb $0x1, %al
movb %al, 0x327(%rsp)
movq %fs:0x0, %rax
leaq -0x20(%rax), %rdi
leaq 0x310(%rsp), %rsi
callq 0xb740
movsd %xmm0, 0x308(%rsp)
movsd 0x308(%rsp), %xmm0
movsd 0x60cb(%rip), %xmm1     # 0x11078
ucomisd %xmm1, %xmm0
jbe 0xb0b2
movq %fs:0x0, %rax
leaq -0x20(%rax), %rax
movq 0x310(%rsp), %rcx
movq %rcx, (%rax)
movq 0x318(%rsp), %rcx
movq %rcx, 0x8(%rax)
callq 0xb890
movl %eax, 0x304(%rsp)
movb $0x0, 0x303(%rsp)
movq %fs:0x0, %rax
leaq -0x30(%rax), %rdi
callq 0xb8b0
andb $0x1, %al
movb %al, 0x303(%rsp)
testb $0x1, 0x303(%rsp)
jne 0xb057
movl 0x304(%rsp), %eax
movq 0x24a8(%rsp), %rcx
cmpl 0x220(%rcx), %eax
jne 0xb057
movq %fs:0x0, %rax
leaq -0x30(%rax), %rdi
callq 0x9e20
movb $0x1, 0x303(%rsp)
testb $0x1, 0x303(%rsp)
jne 0xb0b0
jmp 0xb063
movq $0x10, 0x2f8(%rsp)
movq %fs:0x0, %rax
leaq -0x30(%rax), %rdi
movq 0x2f8(%rsp), %rsi
movl 0x304(%rsp), %ecx
leaq 0x5f81(%rip), %rdx      # 0x11019
movb $0x0, %al
callq 0x2170
cmpl $0x0, %eax
jne 0xb0ac
movq 0x2f8(%rsp), %rax
jmp 0xb0ae
jmp 0xb0b0
jmp 0xb0b2
movq 0x24a8(%rsp), %rsi
leaq 0x68(%rsp), %rdi
movl $0x290, %edx            # imm = 0x290
callq 0x22a0
xorl %edi, %edi
callq 0x9aa0
leaq 0x68(%rsp), %rax
addq $0x108, %rax            # imm = 0x108
addq $0x11c, %rax            # imm = 0x11C
movq %rax, 0x378(%rsp)
leaq 0x68(%rsp), %rax
addq $0x108, %rax            # imm = 0x108
movq %rax, 0x388(%rsp)
leaq 0x68(%rsp), %rax
addq $0x108, %rax            # imm = 0x108
addq $0x108, %rax            # imm = 0x108
movq %rax, 0x390(%rsp)
leaq 0x68(%rsp), %rax
addq $0xe8, %rax
movq %rax, 0x3a0(%rsp)
movzwl 0x24c4(%rsp), %edi
callq 0xe440
movq %rax, 0x60(%rsp)
xorl %eax, %eax
cmpq 0x60(%rsp), %rax
je 0xb180
leaq 0x348(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x60(%rsp), %rdi
movl $0x2b, %esi
callq 0x21d0
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rdx
movq %rax, %rcx
movl $0x2b, %esi
callq 0x83d0
movzwl 0x24c4(%rsp), %edi
callq 0xb940
movq %rax, 0x398(%rsp)
movq %fs:0x0, %rax
leaq -0x30(%rax), %rdi
xorl %esi, %esi
leaq 0x611b(%rip), %rdx      # 0x112cc
leaq 0x5ede(%rip), %rcx      # 0x11096
movl $0x280, %r8d            # imm = 0x280
callq 0xa720
testb $0x1, %al
jne 0xb1c9
jmp 0xb226
leaq 0x348(%rsp), %rax
addq $0x60, %rax
movq %rax, 0x10(%rsp)
movq %fs:0x0, %rax
leaq -0x30(%rax), %rax
movq %rax, 0x18(%rsp)
movq %fs:0x0, %rax
leaq -0x30(%rax), %rdi
movl $0x10, %esi
callq 0x21d0
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rdx
movq %rax, %rcx
movl $0x10, %esi
callq 0x83d0
leaq 0x348(%rsp), %rdi
addq $0x70, %rdi
movq 0x24b8(%rsp), %rdx
movq 0x24b0(%rsp), %rcx
movl $0x1000, %esi           # imm = 0x1000
callq 0x20c0
leaq 0x348(%rsp), %rdi
addq $0x70, %rdi
xorl %esi, %esi
leaq 0x606b(%rip), %rdx      # 0x112cc
leaq 0x5e2e(%rip), %rcx      # 0x11096
movl $0x286, %r8d            # imm = 0x286
callq 0xa720
testb $0x1, %al
jne 0xb2a2
movl $0x800f0000, %edi       # imm = 0x800F0000
leaq 0x6049(%rip), %rsi      # 0x112cc
leaq 0x5e0c(%rip), %rdx      # 0x11096
movl $0x287, %ecx            # imm = 0x287
callq 0x3940
andb $0x1, %al
movb %al, 0x24c7(%rsp)
jmp 0xb550
movb $0x0, 0x5f(%rsp)
movb $0x0, 0x5e(%rsp)
movb $0x1, 0x5d(%rsp)
movq $0x0, 0x50(%rsp)
movzwl 0x2e2(%rsp), %eax
movzwl 0x24c4(%rsp), %ecx
cmpl %ecx, %eax
jne 0xb322
movsbl 0x2e0(%rsp), %eax
movsbl 0x3b8(%rsp), %ecx
cmpl %ecx, %eax
jne 0xb322
movsbl 0x2e1(%rsp), %eax
movsbl 0x3b9(%rsp), %ecx
cmpl %ecx, %eax
jne 0xb322
leaq 0x348(%rsp), %rdi
addq $0x70, %rdi
callq 0xba70
movq %rax, 0x50(%rsp)
movq 0x2d8(%rsp), %rax
cmpq 0x50(%rsp), %rax
sete %al
andb $0x1, %al
movb %al, 0x5f(%rsp)
testb $0x1, 0x5f(%rsp)
je 0xb3e0
movq 0x2e8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x2e8(%rsp)
movq 0x2e8(%rsp), %rax
movq 0x2f0(%rsp), %rcx
subq $0x2, %rcx
cmpq %rcx, %rax
jb 0xb3cd
movq 0x2f0(%rsp), %rax
movq %rax, 0x48(%rsp)
movb $0x0, 0x5d(%rsp)
movq 0x2f0(%rsp), %rax
shlq %rax
movq %rax, 0x2f0(%rsp)
movb $0x1, 0x2d0(%rsp)
movq 0x48(%rsp), %rsi
movq 0x2f0(%rsp), %rdx
leaq 0x5f8e(%rip), %rdi      # 0x11329
movl $0x2, %ecx
movb $0x0, %al
callq 0x9730
leaq 0x348(%rsp), %rdi
addq $0x70, %rdi
movq 0x48(%rsp), %rcx
movl $0x1000, %esi           # imm = 0x1000
leaq 0x5fad(%rip), %rdx      # 0x11371
movb $0x0, %al
callq 0x2170
jmp 0xb3de
testb $0x1, 0x2d0(%rsp)
je 0xb3dc
movb $0x1, 0x5e(%rsp)
jmp 0xb3de
jmp 0xb400
movb $0x0, 0x2d0(%rsp)
movq $0x0, 0x2e8(%rsp)
movq $0x5, 0x2f0(%rsp)
xorl %edi, %edi
callq 0x9650
movq %rax, 0x24a8(%rsp)
cmpq $0x0, 0x24a8(%rsp)
jne 0xb445
movl $0x800f0000, %edi       # imm = 0x800F0000
leaq 0x5ea6(%rip), %rsi      # 0x112cc
leaq 0x5c69(%rip), %rdx      # 0x11096
movl $0x2b0, %ecx            # imm = 0x2B0
callq 0x3940
andb $0x1, %al
movb %al, 0x24c7(%rsp)
jmp 0xb550
movb 0x2d0(%rsp), %cl
movq 0x24a8(%rsp), %rax
andb $0x1, %cl
movb %cl, 0x268(%rax)
testb $0x1, 0x5d(%rsp)
je 0xb4b9
movw 0x24c4(%rsp), %cx
movq 0x24a8(%rsp), %rax
movw %cx, 0x27a(%rax)
movq 0x50(%rsp), %rcx
movq 0x24a8(%rsp), %rax
movq %rcx, 0x270(%rax)
movb 0x3b8(%rsp), %cl
movq 0x24a8(%rsp), %rax
movb %cl, 0x278(%rax)
movb 0x3b9(%rsp), %cl
movq 0x24a8(%rsp), %rax
movb %cl, 0x279(%rax)
movq 0x2e8(%rsp), %rcx
movq 0x24a8(%rsp), %rax
movq %rcx, 0x280(%rax)
movq 0x2f0(%rsp), %rcx
movq 0x24a8(%rsp), %rax
movq %rcx, 0x288(%rax)
xorl %edi, %edi
callq 0x9aa0
testb $0x1, 0x5e(%rsp)
je 0xb4ff
movb $0x0, 0x24c7(%rsp)
jmp 0xb550
leaq 0x68(%rsp), %rdi
leaq 0x348(%rsp), %rdx
movzwl 0x24c4(%rsp), %esi
callq 0xbae0
andb $0x1, %al
movb %al, 0x47(%rsp)
testb $0x1, 0x5d(%rsp)
je 0xb535
movb 0x47(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0xc(%rsp)
jmp 0xb53d
xorl %eax, %eax
movl %eax, 0xc(%rsp)
jmp 0xb53d
movl 0xc(%rsp), %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, 0x24c7(%rsp)
movb 0x24c7(%rsp), %al
andb $0x1, %al
addq $0x24c8, %rsp           # imm = 0x24C8
retq
nopw %cs:(%rax,%rax)