Skip to content

Instantly share code, notes, and snippets.

@denandz
Created September 3, 2019 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save denandz/32891d971b793d661317070085c3382d to your computer and use it in GitHub Desktop.
Save denandz/32891d971b793d661317070085c3382d to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int32_t inc_s1(int32_t s){
uint32_t uVar1;
int32_t s1;
uVar1 = s / 0xd1a4 + (s >> 0x1f);
s1 = (s * 0x9c4e) + (uVar1 + (uVar1 >> 0x1f)) * -0x7fffffab;
if (s1 < 0) {
s1 = s1 + 0x7fffffab;
}
return s1;
}
int32_t inc_s2(int32_t s){
uint32_t uVar1;
int32_t s2;
uVar1 = s / 0xce26 + (s >> 0x1f);
s2 = s * 0x9ef4 + (uVar1 + (uVar1 >> 0x1f)) * -0x7fffff07;
if (s2 < 0) {
s2 = s2 + 0x7fffff07;
}
return s2;
}
double randES(int32_t s1, int32_t s2){
int32_t iVar1;
double dVar3;
s1 = inc_s1(s1);
s2 = inc_s2(s2);
iVar1 = s1 - s2;
if (iVar1 < 1) {
iVar1 = iVar1 + 0x7fffffaa;
}
dVar3 = iVar1 * 4.656613e-010;
return dVar3;
}
int main(int argc, char ** argv){
int s1;
int s2;
if(argc < 3){
puts("Run with: ./mssql_rand_test <S1> <S2>");
return 0;
}
s1 = atoi(argv[1]);
s2 = atoi(argv[2]);
printf("%.17f\n", randES(s1, s2));
printf("next - S1: %d S2: %d\n", inc_s1(s1), inc_s2(s2));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment