// File: /workspace/github_c_makefile_star2_O0/aremmell[P]libsir/src/sirinternal.c
// Function: sir_cleanup
bool _sir_cleanup(void) {
    if (!_sir_sanity())
        return false;

    _SIR_LOCK_SECTION(sirfcache, sfc, SIRMI_FILECACHE, false);
    bool cleanup   = true;
    bool destroyfc = _sir_fcache_destroy(sfc);
    SIR_ASSERT(destroyfc);

    _SIR_UNLOCK_SECTION(SIRMI_FILECACHE);
    _sir_eqland(cleanup, destroyfc);

#if !defined(SIR_NO_PLUGINS)
    _SIR_LOCK_SECTION(sir_plugincache, spc, SIRMI_PLUGINCACHE, false);
    bool destroypc = _sir_plugin_cache_destroy(spc);
    SIR_ASSERT(destroypc);
    _SIR_UNLOCK_SECTION(SIRMI_PLUGINCACHE);
    _sir_eqland(cleanup, destroypc);
#endif

    _SIR_LOCK_SECTION(sirconfig, _cfg, SIRMI_CONFIG, false);

#if !defined(SIR_NO_SYSTEM_LOGGERS)
    if (!_sir_syslog_close(&_cfg->si.d_syslog)) {
        cleanup = false;
        _sir_selflog("error: failed to close system logger!");
    }

    _sir_syslog_reset(&_cfg->si.d_syslog);
#endif

#if !defined(SIR_NO_TEXT_STYLING)
    if (!_sir_resettextstyles()) {
        cleanup = false;
        _sir_selflog("error: failed to reset text styles!");
    }
#endif

#if defined(__HAVE_ATOMIC_H__)
    atomic_store(&_sir_magic, 0);
#else
    _sir_magic = 0U;
#endif

    _sir_reset_tls();

    (void)memset(_cfg, 0, sizeof(sirconfig));
    _SIR_UNLOCK_SECTION(SIRMI_CONFIG);

    _sir_selflog("cleaned up %s", (cleanup ? "successfully" : "with errors"));

    SIR_ASSERT(cleanup);
    return cleanup;
}

// Assembly:
subq $0x48, %rsp
callq 0x9d10
testb $0x1, %al
jne 0x9b17
movb $0x0, 0x47(%rsp)
jmp 0x9cfd
movl $0x1, %edi
callq 0x9650
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x38(%rsp)
jne 0x9b55
movl $0x800f0000, %edi       # imm = 0x800F0000
leaq 0x75f8(%rip), %rsi      # 0x11132
leaq 0x7555(%rip), %rdx      # 0x11096
movl $0xd9, %ecx
callq 0x3940
movb $0x0, 0x47(%rsp)
jmp 0x9cfd
jmp 0x9b57
movb $0x1, 0x37(%rsp)
movq 0x38(%rsp), %rdi
callq 0x6710
andb $0x1, %al
movb %al, 0x36(%rsp)
movl $0x1, %edi
callq 0x9aa0
xorl %eax, %eax
testb $0x1, 0x36(%rsp)
movb %al, 0xf(%rsp)
je 0x9b8b
movb 0x37(%rsp), %al
movb %al, 0xf(%rsp)
movb 0xf(%rsp), %al
andb $0x1, %al
movb %al, 0x37(%rsp)
movl $0x2, %edi
callq 0x9650
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%rsp)
jne 0x9bd3
movl $0x800f0000, %edi       # imm = 0x800F0000
leaq 0x757a(%rip), %rsi      # 0x11132
leaq 0x74d7(%rip), %rdx      # 0x11096
movl $0xe2, %ecx
callq 0x3940
movb $0x0, 0x47(%rsp)
jmp 0x9cfd
jmp 0x9bd5
movq 0x28(%rsp), %rdi
callq 0xe0b0
andb $0x1, %al
movb %al, 0x27(%rsp)
movl $0x2, %edi
callq 0x9aa0
xorl %eax, %eax
testb $0x1, 0x27(%rsp)
movb %al, 0xe(%rsp)
je 0x9c04
movb 0x37(%rsp), %al
movb %al, 0xe(%rsp)
movb 0xe(%rsp), %al
andb $0x1, %al
movb %al, 0x37(%rsp)
xorl %edi, %edi
callq 0x9650
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x18(%rsp)
jne 0x9c49
movl $0x800f0000, %edi       # imm = 0x800F0000
leaq 0x7504(%rip), %rsi      # 0x11132
leaq 0x7461(%rip), %rdx      # 0x11096
movl $0xe9, %ecx
callq 0x3940
movb $0x0, 0x47(%rsp)
jmp 0x9cfd
jmp 0x9c4b
movq 0x18(%rsp), %rdi
addq $0x10, %rdi
callq 0x9d50
testb $0x1, %al
jne 0x9c70
movb $0x0, 0x37(%rsp)
leaq 0x74d6(%rip), %rdi      # 0x1113f
movb $0x0, %al
callq 0x9730
movq 0x18(%rsp), %rdi
addq $0x10, %rdi
callq 0x9750
callq 0xebc0
testb $0x1, %al
jne 0x9c9a
movb $0x0, 0x37(%rsp)
leaq 0x743c(%rip), %rdi      # 0x110cf
movb $0x0, %al
callq 0x9730
movq $0x0, 0x10(%rsp)
movq 0x10(%rsp), %rax
xchgq %rax, 0xc841(%rip)      # 0x164f0
callq 0x96d0
movq 0x18(%rsp), %rdi
xorl %esi, %esi
movl $0x290, %edx            # imm = 0x290
callq 0x21c0
xorl %edi, %edi
callq 0x9aa0
movb 0x37(%rsp), %cl
leaq 0x744f(%rip), %rsi      # 0x11126
leaq 0x68fd(%rip), %rax      # 0x105db
testb $0x1, %cl
cmovneq %rax, %rsi
leaq 0x7479(%rip), %rdi      # 0x11165
movb $0x0, %al
callq 0x9730
movb 0x37(%rsp), %al
andb $0x1, %al
movb %al, 0x47(%rsp)
movb 0x47(%rsp), %al
andb $0x1, %al
addq $0x48, %rsp
retq
nopl (%rax,%rax)