<commit_before>typedef unsigned char b8;
typedef unsigned b32;
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int rpr(b32 *h) {
    printf("%08x%08x%08x%08x%08x\n", *h, *(h+1),*(h+2), *(h+3), *(h+4));
    return 0;
}

int die(char *msg) {
    fputs( msg, stderr);
    exit(0);
} //libpk

b8 *wr32be(b32 n, b8 *msg) {
    b32 mask = 0xff;
    *msg = n >> 24; ++msg;
    *msg = (n >> 16) & mask; ++msg;
    *msg = (n >> 8) & mask; ++msg;
    *msg = n & mask;  return ++msg;
} //unused libpk

b8 *rd32be(b32 *n, b8 *msg) {
    *n = *msg << 24; ++msg;
    *n |= *msg << 16; ++msg;
    *n |= *msg << 8; ++msg;
    *n |= *msg;  return ++msg;
} //libpk

int sha1(b8 * msg, b32 n_bits[2], b32 hash[5]) {
    b32 a[5];
    b32 h[5]={ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0};
    b32 w[80];
    b32 left[2];
    int i, j, b;

    left[0]=n_bits[0];
    left[1]=n_bits[1];

    while(left[1]||(left[0]>512)) {
        for(i=0; i<16; i++) msg=rd32be(w+i,msg);
        grind(w,a,h);
        left[0]-=512;
        if (left[0]>512){
            left[1]--;
	    if (left[1]>1) die("underflow\n");
        }
    }

    j=left[0]/32; b=left[0];
    for(i=0; i<j; i++) msg=rd32be(w+i,msg);
    left[0]-=j*32;
    w[i]= 1 << (31 - left[0]);
    if (b > 0) { w[i] |= *msg << 24; ++msg; b-=8;}
    if (b > 0) { w[i] |= *msg << 16; ++msg; b-=8;}
    if (b > 0) { w[i] |= *msg << 8; ++msg; b-=8;}
    if (b > 0) { w[i] |= *msg; ++msg; b-=8;}
    w[i]&= 0xffffffff << (31 - left[0]); i++;
    if(j>=14) {
        if(i==15) w[15]=0;
        grind(w,a,h);
        i=0;
    }
    for(;i<14;i++) w[i]=0;
    w[i]=n_bits[1]; i++;
    w[i]=n_bits[0];
    grind(w,a,h);
    for(i=0; i<5; i++) hash[i]=h[i];
    return 0;

}

b32 f(b32 t, b32 *a, b32 *w){
    b32 temp=0;
    b32 k[4]={ 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6};
    temp = ((a[0] << 5) | (a[0] >> 27)) + a[4] + w[t];
    switch(t/20){
        case 0:
	    temp+=k[0];
	    temp+=(a[1]&a[2])|((~a[1])&a[3]);
	    break;
	case 1:
	    temp+=k[1];
	    temp+=a[1]^a[2]^a[3];
	    break;
	case 2:
	    temp+=k[2];
	    temp+=(a[1]&a[2])|(a[1]&a[3])|(a[2]&a[3]);
	    break;
	case 3:
	    temp+=k[3];
	    temp+=a[1]^a[2]^a[3];
	    break;<commit_msg>fixed sha1.c and optimized it.<commit_after>typedef unsigned char b8;
typedef unsigned b32;
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int rpr(b32 *h) {
    printf("%08x%08x%08x%08x%08x\n", *h, *(h+1),*(h+2), *(h+3), *(h+4));
    return 0;
}

int die(char *msg) {
    fputs( msg, stderr);
    exit(0);
} //libpk

b8 *wr32be(b32 n, b8 *msg) {
    b32 mask = 0xff;
    *msg = n >> 24; ++msg;
    *msg = (n >> 16) & mask; ++msg;
    *msg = (n >> 8) & mask; ++msg;
    *msg = n & mask;  return ++msg;
} //unused libpk

b8 *rd32be(b32 *n, b8 *msg) {
    *n = *msg << 24; ++msg;
    *n |= *msg << 16; ++msg;
    *n |= *msg << 8; ++msg;
    *n |= *msg;  return ++msg;
} //libpk

int sha1(b8 * msg, b32 bits, b32 hash[5]) {
    b32 a[5];
    b32 h[5]={ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0};
    b32 w[80];
    static b32 len[2] = {0};
    int i, j, b;

    len[0]+=bits; if(len[0]<bits) len[1]++;

    while(bits>=512) {
        for(i=0; i<16; i++) msg=rd32be(w+i,msg);
        grind(w,a,h);
        bits-=512;
    }

    if (bits) {
        if (bits>=32) {
            for(i=0, j=bits/32; i<j; i++) msg=rd32be(w+i,msg);
            bits%=32;
        }
        w[i]= 1 << (31 - bits);
        w[i] |= *msg << 24; ++msg; bits-=8;
        if (bits) {
            w[i] |= *msg << 16; ++msg; bits-=8;
            if (bits) {
                w[i] |= *msg << 8; ++msg; bits-=8;
                if (bits) {
                    w[i] |= *msg; ++msg; bits-=8;
                }
            }
        }
       //TODO Thu Jul 31 21:25:17 IST 2014 pk was here
    
        w[i]&= 0xffffffff << (31 - bits); i++;
        if(j>=14) {
            if(i==15) w[15]=0;
            grind(w,a,h);
            i=0;
        }
    }
    for(;i<14;i++) w[i]=0;
    w[i]=len[1]; i++;
    w[i]=len[0];
    grind(w,a,h);
    for(i=0; i<5; i++) hash[i]=h[i];
    return 0;

}

b32 f(b32 t, b32 *a, b32 *w){
    b32 temp=0;
    b32 k[4]={ 0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6};
    temp = ((a[0] << 5) | (a[0] >> 27)) + a[4] + w[t];
    switch(t/20){
        case 0:
	    temp+=k[0];
	    temp+=(a[1]&a[2])|((~a[1])&a[3]);
	    break;
	case 1:
	    temp+=k[1];
	    temp+=a[1]^a[2]^a[3];
	    break;
	case 2:
	    temp+=k[2];
	    temp+=(a[1]&a[2])|(a[1]&a[3])|(a[2]&a[3]);
	    break;
	case 3:
	    temp+=k[3];
	    temp+=a[1]^a[2]^a[3];
	    break;
{'fraction_non_alphanumeric': 0.25829694323144103, 'fraction_numerical': 0.10109170305676855, 'mean_word_length': 2.159310344827586, 'pattern_counts': {'":': 0, '<': 54, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6352789', 'n_tokens_mistral': 2515, 'n_tokens_neox': 2245, 'n_words': 463}