static ossl_inline void constant_time_lookup(void *RESTRICT out_,
                                             const void *table_,
                                             word_t elem_bytes,
                                             word_t n_table,
                                             word_t idx)
{
    big_register_t big_one = br_set_to_mask(1), big_i = br_set_to_mask(idx);
    unsigned char *out = (unsigned char *)out_;
    const unsigned char *table = (const unsigned char *)table_;
    word_t j, k;
# ifndef HAS_UNALIGNED_STRUCTS
    unsigned char maskc;
# endif
    memset(out, 0, elem_bytes);
    for (j = 0; j < n_table; j++, big_i -= big_one) {
        big_register_t br_mask = br_is_zero(big_i);
        word_t mask;
# ifndef HAS_UNALIGNED_STRUCTS
        maskc = (unsigned char)br_mask;
# endif
        for (k = 0; k <= elem_bytes - sizeof(big_register_t);
             k += sizeof(big_register_t)) {
            if (elem_bytes % sizeof(big_register_t)) {
# ifdef HAS_UNALIGNED_STRUCTS
                ((unaligned_br_t *)(out + k))->unaligned |=
                        br_mask
                        & ((const unaligned_br_t *)
                           (&table[k + j * elem_bytes]))->unaligned;
# else
                size_t i;
                for (i = 0; i < sizeof(big_register_t); i++)
                    out[k + i] |= maskc
                                  & ((unsigned char *) table)
                                    [k + (j * elem_bytes) + i];
# endif
            } else {
                *(big_register_t *)(out + k) |=
                        br_mask
                        & *(const big_register_t *)(&table[k + j * elem_bytes]);
            }
        }
        mask = word_is_zero(idx ^ j);
# ifndef HAS_UNALIGNED_STRUCTS
        maskc = (unsigned char)mask;
# endif
        if (elem_bytes % sizeof(big_register_t) >= sizeof(word_t)) {
            for (; k <= elem_bytes - sizeof(word_t); k += sizeof(word_t)) {
                if (elem_bytes % sizeof(word_t)) {
# ifdef HAS_UNALIGNED_STRUCTS
                    *(word_t *)(out + k) |=
                            mask
                            & ((const unaligned_word_t *)
                               (&table[k + j * elem_bytes]))->unaligned;
# else
                    size_t i;
                    for (i = 0; i < sizeof(word_t); i++)
                        out[k + i] |= maskc
                                      & ((unsigned char *)table)
                                         [k + (j * elem_bytes) + i];
# endif
                } else {
                    *(word_t *)(out + k) |=
                            mask
                            & *(const word_t *)(&table[k + j * elem_bytes]);
                }
            }
        }
        if (elem_bytes % sizeof(word_t)) {
            for (; k < elem_bytes; k += 1) {
                out[k] |= mask & table[k + j * elem_bytes];
            }
        }
    }
}
['static ossl_inline void constant_time_lookup(void *RESTRICT out_,\n                                             const void *table_,\n                                             word_t elem_bytes,\n                                             word_t n_table,\n                                             word_t idx)\n{\n    big_register_t big_one = br_set_to_mask(1), big_i = br_set_to_mask(idx);\n    unsigned char *out = (unsigned char *)out_;\n    const unsigned char *table = (const unsigned char *)table_;\n    word_t j, k;\n# ifndef HAS_UNALIGNED_STRUCTS\n    unsigned char maskc;\n# endif\n    memset(out, 0, elem_bytes);\n    for (j = 0; j < n_table; j++, big_i -= big_one) {\n        big_register_t br_mask = br_is_zero(big_i);\n        word_t mask;\n# ifndef HAS_UNALIGNED_STRUCTS\n        maskc = (unsigned char)br_mask;\n# endif\n        for (k = 0; k <= elem_bytes - sizeof(big_register_t);\n             k += sizeof(big_register_t)) {\n            if (elem_bytes % sizeof(big_register_t)) {\n# ifdef HAS_UNALIGNED_STRUCTS\n                ((unaligned_br_t *)(out + k))->unaligned |=\n                        br_mask\n                        & ((const unaligned_br_t *)\n                           (&table[k + j * elem_bytes]))->unaligned;\n# else\n                size_t i;\n                for (i = 0; i < sizeof(big_register_t); i++)\n                    out[k + i] |= maskc\n                                  & ((unsigned char *) table)\n                                    [k + (j * elem_bytes) + i];\n# endif\n            } else {\n                *(big_register_t *)(out + k) |=\n                        br_mask\n                        & *(const big_register_t *)(&table[k + j * elem_bytes]);\n            }\n        }\n        mask = word_is_zero(idx ^ j);\n# ifndef HAS_UNALIGNED_STRUCTS\n        maskc = (unsigned char)mask;\n# endif\n        if (elem_bytes % sizeof(big_register_t) >= sizeof(word_t)) {\n            for (; k <= elem_bytes - sizeof(word_t); k += sizeof(word_t)) {\n                if (elem_bytes % sizeof(word_t)) {\n# ifdef HAS_UNALIGNED_STRUCTS\n                    *(word_t *)(out + k) |=\n                            mask\n                            & ((const unaligned_word_t *)\n                               (&table[k + j * elem_bytes]))->unaligned;\n# else\n                    size_t i;\n                    for (i = 0; i < sizeof(word_t); i++)\n                        out[k + i] |= maskc\n                                      & ((unsigned char *)table)\n                                         [k + (j * elem_bytes) + i];\n# endif\n                } else {\n                    *(word_t *)(out + k) |=\n                            mask\n                            & *(const word_t *)(&table[k + j * elem_bytes]);\n                }\n            }\n        }\n        if (elem_bytes % sizeof(word_t)) {\n            for (; k < elem_bytes; k += 1) {\n                out[k] |= mask & table[k + j * elem_bytes];\n            }\n        }\n    }\n}']