fork download
#include <iostream>

typedef unsigned char byte;

byte calc_iv(byte buffer[], size_t len)
{
    int iv = 0;
    for(int i = 0; i < len; i++) {
        byte I = buffer[i];
        iv += I;
        iv *= I + 1;
    }
    return iv / (len);
}

int main(){
    byte buf[] = {41, 32, 16};
    byte iv = calc_iv(buf, sizeof(buf)/sizeof(buf[0]));
    std::cout<<(int)iv<<std::endl;

    return 0;
}
Success #stdin #stdout 0s 4540KB
stdin
Standard input is empty
stdout
152