static unsigned long get_error_values(int inc, int top, const char **file,
                                      int *line, const char **data,
                                      int *flags)
{
    int i = 0;
    ERR_STATE *es;
    unsigned long ret;
    es = ERR_get_state();
    if (es == NULL)
        return 0;
    if (inc && top) {
        if (file)
            *file = "";
        if (line)
            *line = 0;
        if (data)
            *data = "";
        if (flags)
            *flags = 0;
        return ERR_R_INTERNAL_ERROR;
    }
    if (es->bottom == es->top)
        return 0;
    if (top)
        i = es->top;
    else
        i = (es->bottom + 1) % ERR_NUM_ERRORS;
    ret = es->err_buffer[i];
    if (inc) {
        es->bottom = i;
        es->err_buffer[i] = 0;
    }
    if (file != NULL && line != NULL) {
        if (es->err_file[i] == NULL) {
            *file = "NA";
            *line = 0;
        } else {
            *file = es->err_file[i];
            *line = es->err_line[i];
        }
    }
    if (data == NULL) {
        if (inc) {
            err_clear_data(es, i);
        }
    } else {
        if (es->err_data[i] == NULL) {
            *data = "";
            if (flags != NULL)
                *flags = 0;
        } else {
            *data = es->err_data[i];
            if (flags != NULL)
                *flags = es->err_data_flags[i];
        }
    }
    return ret;
}
['static unsigned long get_error_values(int inc, int top, const char **file,\n                                      int *line, const char **data,\n                                      int *flags)\n{\n    int i = 0;\n    ERR_STATE *es;\n    unsigned long ret;\n    es = ERR_get_state();\n    if (es == NULL)\n        return 0;\n    if (inc && top) {\n        if (file)\n            *file = "";\n        if (line)\n            *line = 0;\n        if (data)\n            *data = "";\n        if (flags)\n            *flags = 0;\n        return ERR_R_INTERNAL_ERROR;\n    }\n    if (es->bottom == es->top)\n        return 0;\n    if (top)\n        i = es->top;\n    else\n        i = (es->bottom + 1) % ERR_NUM_ERRORS;\n    ret = es->err_buffer[i];\n    if (inc) {\n        es->bottom = i;\n        es->err_buffer[i] = 0;\n    }\n    if (file != NULL && line != NULL) {\n        if (es->err_file[i] == NULL) {\n            *file = "NA";\n            *line = 0;\n        } else {\n            *file = es->err_file[i];\n            *line = es->err_line[i];\n        }\n    }\n    if (data == NULL) {\n        if (inc) {\n            err_clear_data(es, i);\n        }\n    } else {\n        if (es->err_data[i] == NULL) {\n            *data = "";\n            if (flags != NULL)\n                *flags = 0;\n        } else {\n            *data = es->err_data[i];\n            if (flags != NULL)\n                *flags = es->err_data_flags[i];\n        }\n    }\n    return ret;\n}', 'ERR_STATE *ERR_get_state(void)\n{\n    ERR_STATE *state = NULL;\n    if (!RUN_ONCE(&err_init, err_do_init))\n        return NULL;\n    if (!OPENSSL_init_crypto(0, NULL))\n        return NULL;\n    state = CRYPTO_THREAD_get_local(&err_thread_local);\n    if (state == NULL) {\n        state = OPENSSL_zalloc(sizeof(*state));\n        if (state == NULL)\n            return NULL;\n        if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ERR_STATE)\n            || !CRYPTO_THREAD_set_local(&err_thread_local, state)) {\n            ERR_STATE_free(state);\n            return NULL;\n        }\n        OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);\n    }\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}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    FAILTEST();\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    INCREMENT(malloc_count);\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\n    if (allow_customize) {\n        allow_customize = 0;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    (void)(file); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\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}']