static int write_record(BIO *b, size_t len, int rectype, int recversion)
{
    unsigned char header[SSL3_RT_HEADER_LENGTH];
    size_t written;
    unsigned char buf[256];
    memset(buf, 0, sizeof(buf));
    header[0] = rectype;
    header[1] = (recversion >> 8) & 0xff;
    header[2] = recversion & 0xff;
    header[3] = (len >> 8) & 0xff;
    header[4] = len & 0xff;
    if (!BIO_write_ex(b, header, SSL3_RT_HEADER_LENGTH, &written)
            || written != SSL3_RT_HEADER_LENGTH)
        return 0;
    while (len > 0) {
        size_t outlen;
        if (len > sizeof(buf))
            outlen = sizeof(buf);
        else
            outlen = len;
        if (!BIO_write_ex(b, buf, outlen, &written)
                || written != outlen)
            return 0;
        len -= outlen;
    }
    return 1;
}
['static int write_record(BIO *b, size_t len, int rectype, int recversion)\n{\n    unsigned char header[SSL3_RT_HEADER_LENGTH];\n    size_t written;\n    unsigned char buf[256];\n    memset(buf, 0, sizeof(buf));\n    header[0] = rectype;\n    header[1] = (recversion >> 8) & 0xff;\n    header[2] = recversion & 0xff;\n    header[3] = (len >> 8) & 0xff;\n    header[4] = len & 0xff;\n    if (!BIO_write_ex(b, header, SSL3_RT_HEADER_LENGTH, &written)\n            || written != SSL3_RT_HEADER_LENGTH)\n        return 0;\n    while (len > 0) {\n        size_t outlen;\n        if (len > sizeof(buf))\n            outlen = sizeof(buf);\n        else\n            outlen = len;\n        if (!BIO_write_ex(b, buf, outlen, &written)\n                || written != outlen)\n            return 0;\n        len -= outlen;\n    }\n    return 1;\n}']