ERR_STATE *ERR_get_state(void)
{
    ERR_STATE *state;
    int saveerrno = get_last_sys_error();
    if (!OPENSSL_init_crypto(OPENSSL_INIT_BASE_ONLY, NULL))
        return NULL;
    if (!RUN_ONCE(&err_init, err_do_init))
        return NULL;
    state = CRYPTO_THREAD_get_local(&err_thread_local);
    if (state == (ERR_STATE*)-1)
        return NULL;
    if (state == NULL) {
        if (!CRYPTO_THREAD_set_local(&err_thread_local, (ERR_STATE*)-1))
            return NULL;
        if ((state = OPENSSL_zalloc(sizeof(*state))) == NULL) {
            CRYPTO_THREAD_set_local(&err_thread_local, NULL);
            return NULL;
        }
        if (!ossl_init_thread_start(NULL, NULL, err_delete_thread_state)
                || !CRYPTO_THREAD_set_local(&err_thread_local, state)) {
            ERR_STATE_free(state);
            CRYPTO_THREAD_set_local(&err_thread_local, NULL);
            return NULL;
        }
        OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
    }
    set_sys_error(saveerrno);
    return state;
}
['ERR_STATE *ERR_get_state(void)\n{\n    ERR_STATE *state;\n    int saveerrno = get_last_sys_error();\n    if (!OPENSSL_init_crypto(OPENSSL_INIT_BASE_ONLY, NULL))\n        return NULL;\n    if (!RUN_ONCE(&err_init, err_do_init))\n        return NULL;\n    state = CRYPTO_THREAD_get_local(&err_thread_local);\n    if (state == (ERR_STATE*)-1)\n        return NULL;\n    if (state == NULL) {\n        if (!CRYPTO_THREAD_set_local(&err_thread_local, (ERR_STATE*)-1))\n            return NULL;\n        if ((state = OPENSSL_zalloc(sizeof(*state))) == NULL) {\n            CRYPTO_THREAD_set_local(&err_thread_local, NULL);\n            return NULL;\n        }\n        if (!ossl_init_thread_start(NULL, NULL, err_delete_thread_state)\n                || !CRYPTO_THREAD_set_local(&err_thread_local, state)) {\n            ERR_STATE_free(state);\n            CRYPTO_THREAD_set_local(&err_thread_local, NULL);\n            return NULL;\n        }\n        OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);\n    }\n    set_sys_error(saveerrno);\n    return state;\n}', 'int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))\n{\n    if (pthread_once(once, init) != 0)\n        return 0;\n    return 1;\n}', 'void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key)\n{\n    return pthread_getspecific(*key);\n}', 'int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)\n{\n    if (pthread_setspecific(*key, val) != 0)\n        return 0;\n    return 1;\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    return c_CRYPTO_zalloc(num, file, line);\n}']