compInds

decompiled_code:
__int64 __fastcall compInds(const void *a1, const void *a2)
{
double v2; // xmm0_8
__int64 result; // rax

v2 = *(double *)a1 - *(double *)a2;
result = 0xFFFFFFFFLL;
if ( v2 >= 0.0 )
result = v2 != 0.0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(const void *a1, const void *a2)
{
double v2; // xmm0_8
__int64 result; // rax

v2 = *(double *)a1 - *(double *)a2;
result = 0xFFFFFFFFLL;
if ( v2 >= 0.0 )
result = v2 != 0.0;
return result;
}

original_code:
int compInds(const void *a, const void *b){
  double diff = (double)( (*((sortitem*)a)).val - (*((sortitem*)b)).val );
  if(diff<0)
    return -1;
  else if(diff==0)
    return 0;
  else
    return 1;
}

canonical_original_code:
int compInds(void *a, void *b){
  double diff = (double)( (*((sortitem*)a)).val - (*((sortitem*)b)).val );
  if(diff<0)
    return -1;
  else if(diff==0)
    return 0;
  else
    return 1;
}

variable_types:
a
void *

variable_types:
b
void *

variable_types: diff double


mean

repo: lcayton/bbtree

decompiled_code:
double *__fastcall mean(double *a1, __int64 a2, double *a3, int a4, int a5)
{
double *result; // rax
double *v8; // rdx
__int64 v9; // r11
__int64 v10; // rsi

result = a1;
if ( a5 > 0 )
{
v8 = result;
v9 = (__int64)&result[(unsigned int)(a5 - 1) + 1];
v10 = 0LL;
do
{
result = a3;
if ( a4 > 0 )
{
do
{
*v8 = *v8 + *(double *)(*(_QWORD *)(a2 + 8LL * *(int *)result) + v10);
result = (double *)((char *)result + 4);
}
while ( result != (double *)((char *)a3 + 4 * (unsigned int)(a4 - 1) + 4) );
}
*v8 = *v8 / (double)a4;
++v8;
v10 += 8LL;
}
while ( v8 != (double *)v9 );
}
return result;
}

canonical_decompiled_code:
double *__fastcall func1(double *a1, __int64 a2, double *a3, int a4, int a5)
{
double *result; // rax
double *v8; // rdx
__int64 v9; // r11
__int64 v10; // rsi

result = a1;
if ( a5 > 0 )
{
v8 = result;
v9 = (__int64)&result[(unsigned int)(a5 - 1) + 1];
v10 = 0LL;
do
{
result = a3;
if ( a4 > 0 )
{
do
{
*v8 = *v8 + *(double *)(*(_QWORD *)(a2 + 8LL * *(int *)result) + v10);
result = (double *)((char *)result + 4);
}
while ( result != (double *)((char *)a3 + 4 * (unsigned int)(a4 - 1) + 4) );
}
*v8 = *v8 / (double)a4;
++v8;
v10 += 8LL;
}
while ( v8 != (double *)v9 );
}
return result;
}

original_code:
void mean(double* mu,double** data,int* inds, int n, int d){
  int i,j;
  for(i=0;i<d;i++){
    for(j=0;j<n;j++){
      mu[i]+=data[inds[j]][i];
    }
    mu[i]/=((double)n);
  }
}

canonical_original_code:
void mean(double *mu, double **data, int *inds, int n, int d){
  int i; int j;
  for(i=0;i<d;i++){
    for(j=0;j<n;j++){
      mu[i]+=data[inds[j]][i];
    }
    mu[i]/=((double)n);
  }
}

variable_types:
mu
double *

variable_types:
data
double **

variable_types:
inds
int *

variable_types: n int

variable_types: d int

variable_types: i int

variable_types: j int

return_type: void


genRand

decompiled_code:
__int64 __fastcall genRand(int a1)
{
__int64 result; // rax

do
result = (unsigned int)(rand() / (int)(0x80000000 / a1));
while ( a1 <= (int)result );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
__int64 result; // rax

do
result = (unsigned int)(rand() / (int)(0x80000000 / a1));
while ( a1 <= (int)result );
return result;
}

original_code:
int genRand(int n){
  int val;
  while(n<= (val= rand()/(int)(((unsigned)2147483647 + 1) / n)));
  return val;
}

canonical_original_code:
int genRand(int n){
  int val;
  while(n<= (val= rand()/(int)(((unsigned int)2147483647 + 1) / n)));
  return val;
}

variable_types: val int

return_type: int


sortWithInds

original_code:
void sortWithInds(double* a, int* inds, int length){
  int i;
  sortitem *s;
  s = calloc(length,sizeof(sortitem));
  for(i=0;i<length;i++){
    s[i].val = a[i];
    s[i].ind = inds[i];
  }
  qsort(s,length,sizeof(sortitem),compInds);
  for(i=0;i<length;i++){
    inds[i]=s[i].ind;
    a[i]=s[i].val;
  }
  free(s);
}

canonical_original_code:
void sortWithInds(double *a, int *inds, int length){
  int i;
  struct sortitem *s;
  s = calloc(length,sizeof(sortitem));
  for(i=0;i<length;i++){
    s[i].val = a[i];
    s[i].ind = inds[i];
  }
  qsort(s,length,sizeof(sortitem),compInds);
  for(i=0;i<length;i++){
    inds[i]=s[i].ind;
    a[i]=s[i].val;
  }
  free(s);
}

variable_types:
a
double *

variable_types: length int

variable_types: struct sortitem { double val; int ind; } *


insert

original_code:
void insert(int* NNs, double* dtoNNs, int newNN, double dNNnew, int k){
  int i=0;
  while (i < (k-1) && dtoNNs[i+1]>dNNnew){
    NNs[i]=NNs[i+1];
    dtoNNs[i]=dtoNNs[i+1];
    i++;
  }
  NNs[i]=newNN;
  dtoNNs[i]=dNNnew;
}

canonical_original_code:
void insert(int *NNs, double *dtoNNs, int newNN, double dNNnew, int k){
  int i = 0;
  while (i < (k-1) && dtoNNs[i+1]>dNNnew){
    NNs[i]=NNs[i+1];
    dtoNNs[i]=dtoNNs[i+1];
    i++;
  }
  NNs[i]=newNN;
  dtoNNs[i]=dNNnew;
}

variable_types:
NNs
int *

variable_types:
dtoNNs
double *

variable_types: newNN int

variable_types: dNNnew double

variable_types: k int


contarCruzD

repo: lccrubik/doc

variable_types: struct cubo { int F[9]; int B[9]; int U[9]; int D[9]; int R[9]; int L[9]; } *


decompiled_code:
_BOOL8 __fastcall cruz2D(_DWORD *a1)
{
return (int)contarCruzD(a1) > 1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(_DWORD *a1)
{
return (int)func0(a1) > 1;
}

original_code: int cruz2D(cubo *C) { return contarCruzD(C) >= 2; }

canonical_original_code: int cruz2D(struct cubo *C) { return contarCruzD(C) >= 2; }

user_defined_types: struct cubo { int F[9]; int B[9]; int U[9]; int D[9]; int R[9]; int L[9]; }


decompiled_code:
_BOOL8 __fastcall cruz3D(_DWORD *a1)
{
return (int)contarCruzD(a1) > 2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(_DWORD *a1)
{
return (int)func0(a1) > 2;
}

original_code: int cruz3D(cubo *C) { return contarCruzD(C) >= 3; }

canonical_original_code: int cruz3D(struct cubo *C) { return contarCruzD(C) >= 3; }


decompiled_code:
_BOOL8 __fastcall cruz4D(_DWORD *a1)
{
return (int)contarCruzD(a1) > 3;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(_DWORD *a1)
{
return (int)func0(a1) > 3;
}

original_code: int cruz4D(cubo *C) { return contarCruzD(C) >= 4; }

canonical_original_code: int cruz4D(struct cubo *C) { return contarCruzD(C) >= 4; }


decompiled_code:
_BOOL8 __fastcall esqD1(_DWORD *a1)
{
return (int)contarEsqD(a1) > 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(_DWORD *a1)
{
return (int)func4(a1) > 0;
}

original_code: int esqD1(cubo *C) { return contarEsqD(C) >= 1; }

canonical_original_code: int esqD1(struct cubo *C) { return contarEsqD(C) >= 1; }


decompiled_code:
_BOOL8 __fastcall esqD2(_DWORD *a1)
{
return (int)contarEsqD(a1) > 1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func6(_DWORD *a1)
{
return (int)func4(a1) > 1;
}

original_code: int esqD2(cubo *C) { return contarEsqD(C) >= 2; }

canonical_original_code: int esqD2(struct cubo *C) { return contarEsqD(C) >= 2; }


decompiled_code:
_BOOL8 __fastcall esqD3(_DWORD *a1)
{
return (int)contarEsqD(a1) > 2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func7(_DWORD *a1)
{
return (int)func4(a1) > 2;
}

original_code: int esqD3(cubo *C) { return contarEsqD(C) >= 3; }

canonical_original_code: int esqD3(struct cubo *C) { return contarEsqD(C) >= 3; }


decompiled_code:
_BOOL8 __fastcall esqD4(_DWORD *a1)
{
return (int)contarEsqD(a1) > 3;
}

canonical_decompiled_code:
_BOOL8 __fastcall func8(_DWORD *a1)
{
return (int)func4(a1) > 3;
}

original_code: int esqD4(cubo *C) { return contarEsqD(C) >= 4; }

canonical_original_code: int esqD4(struct cubo *C) { return contarEsqD(C) >= 4; }


contarBordes

decompiled_code:
__int64 __fastcall contarBordes(_DWORD *a1)
{
__int64 result; // rax
int v2; // edx

result = esqD4(a1);
if ( (_DWORD)result )
{
v2 = a1[4];
result = 0LL;
if ( a1[5] == v2 )
result = a1[39] == a1[40];
if ( a1[41] == a1[40] )
result = (a1[12] == a1[13]) + (unsigned int)result;
if ( a1[14] == a1[13] )
result = (a1[48] == a1[49]) + (unsigned int)result;
if ( a1[50] == a1[49] )
result = (v2 == a1[3]) + (unsigned int)result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(_DWORD *a1)
{
__int64 result; // rax
int v2; // edx

result = func8(a1);
if ( (_DWORD)result )
{
v2 = a1[4];
result = 0LL;
if ( a1[5] == v2 )
result = a1[39] == a1[40];
if ( a1[41] == a1[40] )
result = (a1[12] == a1[13]) + (unsigned int)result;
if ( a1[14] == a1[13] )
result = (a1[48] == a1[49]) + (unsigned int)result;
if ( a1[50] == a1[49] )
result = (v2 == a1[3]) + (unsigned int)result;
}
return result;
}


decompiled_code:
_BOOL8 __fastcall bordesUD1(_DWORD *a1)
{
return (int)contarBordes(a1) > 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func10(_DWORD *a1)
{
return (int)func9(a1) > 0;
}

original_code: int bordesUD1(cubo *C) { return contarBordes(C) >= 1; }

canonical_original_code: int bordesUD1(struct cubo *C) { return contarBordes(C) >= 1; }


decompiled_code:
_BOOL8 __fastcall bordesUD2(_DWORD *a1)
{
return (int)contarBordes(a1) > 1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func11(_DWORD *a1)
{
return (int)func9(a1) > 1;
}

original_code: int bordesUD2(cubo *C) { return contarBordes(C) >= 2; }

canonical_original_code: int bordesUD2(struct cubo *C) { return contarBordes(C) >= 2; }


decompiled_code:
_BOOL8 __fastcall bordesUD3(_DWORD *a1)
{
return (int)contarBordes(a1) > 2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func12(_DWORD *a1)
{
return (int)func9(a1) > 2;
}

original_code: int bordesUD3(cubo *C) { return contarBordes(C) >= 3; }

canonical_original_code: int bordesUD3(struct cubo *C) { return contarBordes(C) >= 3; }


decompiled_code:
_BOOL8 __fastcall bordesUD4(_DWORD *a1)
{
return (int)contarBordes(a1) > 3;
}

canonical_decompiled_code:
_BOOL8 __fastcall func13(_DWORD *a1)
{
return (int)func9(a1) > 3;
}

original_code: int bordesUD4(cubo *C) { return contarBordes(C) >= 4; }

canonical_original_code: int bordesUD4(struct cubo *C) { return contarBordes(C) >= 4; }


reemplazar

original_code:
static int reemplazar(char* orig, char* a, char* b)
{
 int j,k;
 int R = 0;
 char* dest = orig;
 while(*orig != 0)
 {
  j = 0;
  while(orig[j] != 0 && a[j] != 0 && orig[j] == a[j]) j++;
  if(a[j] == 0)
  {
   R = 1;
   for(k=0;b[k]!=0;++k)
    dest[k] = b[k];
   dest+=k;
   orig+=j;
  } else
   *dest++ = *orig++;
 }
 *dest = 0;
 return R; }

canonical_original_code:
static int reemplazar(char *orig, char *a, char *b)
{
 int j; int k;
 int R = 0;
 char *dest = orig;
 while(*orig != 0)
 {
  j = 0;
  while(orig[j] != 0 && a[j] != 0 && orig[j] == a[j]) j++;
  if(a[j] == 0)
  {
   R = 1;
   for(k=0;b[k]!=0;++k)
    dest[k] = b[k];
   dest+=k;
   orig+=j;
  } else
   *dest++ = *orig++;
 }
 *dest = 0;
 return R; }

variable_types:
orig
char *

variable_types:
a
char *

variable_types:
b
char *

variable_types: R int

variable_types:
dest
char *


simplificar

decompiled_code:
__int64 __fastcall simplificar(_BYTE *a1)
{
void **v1; // rbx
int v2; // ebp
__int64 result; // rax

do
{
v1 = &tabla;
v2 = 0;
do
{
result = reemplazar(a1, (__int64)*v1, (char *)v1[1]);
v2 += result;
v1 += 2;
}
while ( &unk_460 != (_UNKNOWN *)v1 );
}
while ( v2 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_BYTE *a1)
{
void **v1; // rbx
int v2; // ebp
__int64 result; // rax

do
{
v1 = &tabla;
v2 = 0;
do
{
result = func0(a1, (__int64)*v1, (char *)v1[1]);
v2 += result;
v1 += 2;
}
while ( &unk_460 != (_UNKNOWN *)v1 );
}
while ( v2 );
return result;
}

original_code:
void simplificar(char* str)
{
 unsigned int i;
 int R = 1;
 while(R != 0)
 {
  R = 0;
  for(i=0;i<sizeof(tabla)/sizeof(char*);i+=2)
   R += reemplazar(str,tabla[i],tabla[i+1]);
 }
}

canonical_original_code:
void simplificar(char *str)
{
 unsigned int i;
 int R = 1;
 while(R != 0)
 {
  R = 0;
  for(i=0;i<sizeof(tabla)/sizeof(char *);i+=2)
   R += reemplazar(str,tabla[i],tabla[i+1]);
 }
}

variable_types:
str
char *

variable_types:
i
unsigned int


reload

repo: lcrocker/ojcardlib

decompiled_code:
__int64 *reload()
{
__int64 v0; // rsi
__int64 v1; // rcx
unsigned int v2; // er11
unsigned __int64 v3; // r8
unsigned int v4; // er10
unsigned __int64 v5; // rdi
char *v6; // r9
unsigned __int64 v7; // rcx
unsigned int v8; // edx
unsigned __int64 v9; // rax
__int64 *result; // rax

if ( !seeded )
_assert_fail("_seeded", "/usr/src/repo/source/library/prng.c", 0x6Fu, "reload");
v0 = x;
v1 = y;
v2 = z1;
LODWORD(v3) = c1;
v4 = z2;
LODWORD(v5) = c2;
v6 = (char *)˚
do
{
v0 = 0x14ADA13ED78492ADLL * v0 + 123456789;
v7 = v1 ^ (v1 << 21) ^ ((v1 ^ (unsigned __int64)(v1 << 21)) >> 17);
v1 = (v7 << 30) ^ v7;
v8 = -382903 * v2 + v3;
v3 = (4294584393LL * v2 + (unsigned __int64)(unsigned int)v3) >> 32;
v2 = v8;
v9 = 4246477509LL * v4 + (unsigned int)v5;
v5 = HIDWORD(v9);
v4 = v9;
*(_QWORD *)v6 = v1 + v0 + (v9 << 32) + v8;
v6 += 8;
}
while ( (char *)&ring + 2048 != v6 );
x = v0;
y = v1;
z1 = v8;
c1 = v3;
c2 = HIDWORD(v9);
z2 = v9;
result = &rptr;
rptr = (__int64)&rptr;
return result;
}

canonical_decompiled_code:
__int64 *func0()
{
__int64 v0; // rsi
__int64 v1; // rcx
unsigned int v2; // er11
unsigned __int64 v3; // r8
unsigned int v4; // er10
unsigned __int64 v5; // rdi
char *v6; // r9
unsigned __int64 v7; // rcx
unsigned int v8; // edx
unsigned __int64 v9; // rax
__int64 *result; // rax

if ( !seeded )
_assert_fail("_seeded", "/usr/src/repo/source/library/prng.c", 0x6Fu, "reload");
v0 = x;
v1 = y;
v2 = z1;
LODWORD(v3) = c1;
v4 = z2;
LODWORD(v5) = c2;
v6 = (char *)˚
do
{
v0 = 0x14ADA13ED78492ADLL * v0 + 123456789;
v7 = v1 ^ (v1 << 21) ^ ((v1 ^ (unsigned __int64)(v1 << 21)) >> 17);
v1 = (v7 << 30) ^ v7;
v8 = -382903 * v2 + v3;
v3 = (4294584393LL * v2 + (unsigned __int64)(unsigned int)v3) >> 32;
v2 = v8;
v9 = 4246477509LL * v4 + (unsigned int)v5;
v5 = HIDWORD(v9);
v4 = v9;
*(_QWORD *)v6 = v1 + v0 + (v9 << 32) + v8;
v6 += 8;
}
while ( (char *)&ring + 2048 != v6 );
x = v0;
y = v1;
z1 = v8;
c1 = v3;
c2 = HIDWORD(v9);
z2 = v9;
result = &rptr;
rptr = (__int64)&rptr;
return result;
}

variable_types: i int

variable_types:
t
unsigned long


decompiled_code:
__int64 __fastcall ojr_seed(int a1)
{
__int64 result; // rax
int v2; // eax
int v3; // ebx
__int64 v4; // rax
time_t timer; // [rsp+0h] [rbp-30h] BYREF
__int64 buf; // [rsp+8h] [rbp-28h] BYREF
__int64 v7; // [rsp+10h] [rbp-20h]
int v8; // [rsp+18h] [rbp-18h]
int v9; // [rsp+1Ch] [rbp-14h]
int v10; // [rsp+20h] [rbp-10h]
int v11; // [rsp+24h] [rbp-Ch]

rptr = (__int64)˚
x = 0x1CBE991A83LL;
y = 0xE5F4C8F743LL;
z1 = 43219876;
c1 = 6543217;
z2 = 21987643;
c2 = 1732654;
seeded = 0;
if ( a1 )
{
x = a1 & 0x5A5A5A5A ^ 0x1CBE991A83LL;
y = a1 & 0xA5A5A5A5 ^ 0xE5F4C8F743LL;
seeded = 1;
result = 0LL;
}
else
{
v2 = open("/dev/urandom", 0);
v3 = v2;
if ( v2 != -1 )
{
if ( read(v2, &buf, 0x20uLL) == 32 )
seeded = 1;
close(v3);
}
if ( seeded )
{
x = buf;
v4 = v7;
if ( !v7 )
v4 = 0xE5F4C8F743LL;
y = v4;
z1 = v8;
c1 = v9 | 0x10000000;
z2 = v10;
c2 = v11 | 0x20000000;
}
else
{
time(&timer);
x = (unsigned int)timer & 0xA5A5A5A5 ^ (unsigned __int64)x;
y ^= timer & 0x5A5A5A5A;
seeded = 1;
}
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
__int64 result; // rax
int v2; // eax
int v3; // ebx
__int64 v4; // rax
time_t timer; // [rsp+0h] [rbp-30h] BYREF
__int64 buf; // [rsp+8h] [rbp-28h] BYREF
__int64 v7; // [rsp+10h] [rbp-20h]
int v8; // [rsp+18h] [rbp-18h]
int v9; // [rsp+1Ch] [rbp-14h]
int v10; // [rsp+20h] [rbp-10h]
int v11; // [rsp+24h] [rbp-Ch]

rptr = (__int64)˚
x = 0x1CBE991A83LL;
y = 0xE5F4C8F743LL;
z1 = 43219876;
c1 = 6543217;
z2 = 21987643;
c2 = 1732654;
seeded = 0;
if ( a1 )
{
x = a1 & 0x5A5A5A5A ^ 0x1CBE991A83LL;
y = a1 & 0xA5A5A5A5 ^ 0xE5F4C8F743LL;
seeded = 1;
result = 0LL;
}
else
{
v2 = open("/dev/urandom", 0);
v3 = v2;
if ( v2 != -1 )
{
if ( read(v2, &buf, 0x20uLL) == 32 )
seeded = 1;
close(v3);
}
if ( seeded )
{
x = buf;
v4 = v7;
if ( !v7 )
v4 = 0xE5F4C8F743LL;
y = v4;
z1 = v8;
c1 = v9 | 0x10000000;
z2 = v10;
c2 = v11 | 0x20000000;
}
else
{
time(&timer);
x = (unsigned int)timer & 0xA5A5A5A5 ^ (unsigned __int64)x;
y ^= timer & 0x5A5A5A5A;
seeded = 1;
}
result = 0LL;
}
return result;
}

variable_types: seed int

variable_types:
s
unsigned int [8]

variable_types: t long

variable_types: fn int


decompiled_code:
__int64 ojr_next16()
{
if ( !seeded )
_assert_fail("_seeded", "/usr/src/repo/source/library/prng.c", 0x86u, "ojr_next16");
if ( (_UNKNOWN *)rptr == &ring )
reload();
rptr -= 2LL;
return *(unsigned __int16 *)rptr;
}

canonical_decompiled_code:
__int64 func2()
{
if ( !seeded )
_assert_fail("_seeded", "/usr/src/repo/source/library/prng.c", 0x86u, "ojr_next16");
if ( (_UNKNOWN *)rptr == &ring )
func0();
rptr -= 2LL;
return *(unsigned __int16 *)rptr;
}

original_code:
uint16_t ojr_next16(void) {
    ((_seeded) ? (void) (0) : __assert_fail ("_seeded", "/usr/src/repo/source/library/prng.c", 134, __extension__ __PRETTY_FUNCTION__));
    if (rptr == ring) reload();
    return *--rptr;
}

canonical_original_code:
unsigned short ojr_next16() {
    ((_seeded) ? (void) (0) : __assert_fail ("_seeded", "/usr/src/repo/source/library/prng.c", 134, __extension__ __PRETTY_FUNCTION__));
    if (rptr == ring) reload();
    return *--rptr;
}

return_type: unsigned short


decompiled_code:
__int64 ojr_next32()
{
if ( !seeded )
_assert_fail("_seeded", "/usr/src/repo/source/library/prng.c", 0x8Cu, "ojr_next32");
if ( rptr < (unsigned __int64)&unk_504 )
reload();
rptr -= 4LL;
return *(unsigned int *)rptr;
}

canonical_decompiled_code:
__int64 func3()
{
if ( !seeded )
_assert_fail("_seeded", "/usr/src/repo/source/library/prng.c", 0x8Cu, "ojr_next32");
if ( rptr < (unsigned __int64)&unk_504 )
func0();
rptr -= 4LL;
return *(unsigned int *)rptr;
}

original_code:
uint32_t ojr_next32(void) {
    ((_seeded) ? (void) (0) : __assert_fail ("_seeded", "/usr/src/repo/source/library/prng.c", 140, __extension__ __PRETTY_FUNCTION__));
    if (rptr < (ring + 2)) reload();
    rptr -= 2;
    return *((uint32_t *)rptr);
}

canonical_original_code:
unsigned int ojr_next32() {
    ((_seeded) ? (void) (0) : __assert_fail ("_seeded", "/usr/src/repo/source/library/prng.c", 140, __extension__ __PRETTY_FUNCTION__));
    if (rptr < (ring + 2)) reload();
    rptr -= 2;
    return *((unsigned int *)rptr);
}

return_type: unsigned int


decompiled_code:
__int64 ojr_next64()
{
if ( !seeded )
_assert_fail("_seeded", "/usr/src/repo/source/library/prng.c", 0x93u, "ojr_next64");
if ( rptr < (unsigned __int64)&unk_508 )
reload();
rptr -= 8LL;
return *(_QWORD *)rptr;
}

canonical_decompiled_code:
__int64 func4()
{
if ( !seeded )
_assert_fail("_seeded", "/usr/src/repo/source/library/prng.c", 0x93u, "ojr_next64");
if ( rptr < (unsigned __int64)&unk_508 )
func0();
rptr -= 8LL;
return *(_QWORD *)rptr;
}

original_code:
uint64_t ojr_next64(void) {
    ((_seeded) ? (void) (0) : __assert_fail ("_seeded", "/usr/src/repo/source/library/prng.c", 147, __extension__ __PRETTY_FUNCTION__));
    if (rptr < (ring + 4)) reload();
    rptr -= 4;
    return *((uint64_t *)rptr);
}

canonical_original_code:
unsigned long ojr_next64() {
    ((_seeded) ? (void) (0) : __assert_fail ("_seeded", "/usr/src/repo/source/library/prng.c", 147, __extension__ __PRETTY_FUNCTION__));
    if (rptr < (ring + 4)) reload();
    rptr -= 4;
    return *((unsigned long *)rptr);
}

return_type: unsigned long


decompiled_code:
double ojr_next_double()
{
return COERCE_DOUBLE(((unsigned __int64)ojr_next64() >> 12) | 0x3FF0000000000000LL) - 1.0;
}

canonical_decompiled_code:
double func5()
{
return COERCE_DOUBLE(((unsigned __int64)ojr_next64() >> 12) | 0x3FF0000000000000LL) - 1.0;
}

original_code:
double ojr_next_double(void) {
    uint64_t r = ojr_next64();
    ieee.i = (r >> 12) | 0x3FF0000000000000;
    return ieee.d - 1.0;
}

canonical_original_code:
double ojr_next_double() {
    unsigned long r = ojr_next64();
    ieee.i = (r >> 12) | 0x3FF0000000000000;
    return ieee.d - 1.0;
}

variable_types:
r
unsigned long

return_type: double


decompiled_code:
__int64 __fastcall ojr_rand(int a1)
{
int v1; // ebp
int v2; // ebp
int v3; // ebp
__int64 result; // rax

if ( !seeded )
_assert_fail("_seeded", "/usr/src/repo/source/library/prng.c", 0xA9u, "ojr_rand");
if ( a1 <= 0 )
_assert_fail("limit > 0", "/usr/src/repo/source/library/prng.c", 0xAAu, "ojr_rand");
if ( a1 > 0xFFFF )
_assert_fail("limit < 65536", "/usr/src/repo/source/library/prng.c", 0xABu, "ojr_rand");
v1 = a1 - 1;
v2 = ((v1 | (v1 >> 1)) >> 2) | v1 | (v1 >> 1) | ((((v1 | (v1 >> 1)) >> 2) | v1 | (v1 >> 1)) >> 4);
v3 = (v2 >> 8) | v2;
do
{
if ( (_UNKNOWN *)rptr == &ring )
reload();
rptr -= 2LL;
result = (unsigned __int16)(v3 & *(_WORD *)rptr);
}
while ( a1 <= (int)result );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1)
{
int v1; // ebp
int v2; // ebp
int v3; // ebp
__int64 result; // rax

if ( !seeded )
_assert_fail("_seeded", "/usr/src/repo/source/library/prng.c", 0xA9u, "ojr_rand");
if ( a1 <= 0 )
_assert_fail("limit > 0", "/usr/src/repo/source/library/prng.c", 0xAAu, "ojr_rand");
if ( a1 > 0xFFFF )
_assert_fail("limit < 65536", "/usr/src/repo/source/library/prng.c", 0xABu, "ojr_rand");
v1 = a1 - 1;
v2 = ((v1 | (v1 >> 1)) >> 2) | v1 | (v1 >> 1) | ((((v1 | (v1 >> 1)) >> 2) | v1 | (v1 >> 1)) >> 4);
v3 = (v2 >> 8) | v2;
do
{
if ( (_UNKNOWN *)rptr == &ring )
func0();
rptr -= 2LL;
result = (unsigned __int16)(v3 & *(_WORD *)rptr);
}
while ( a1 <= (int)result );
return result;
}

original_code:
int ojr_rand(int limit) {
    int v, m = limit - 1;
    ((_seeded) ? (void) (0) : __assert_fail ("_seeded", "/usr/src/repo/source/library/prng.c", 169, __extension__ __PRETTY_FUNCTION__));
    ((limit > 0) ? (void) (0) : __assert_fail ("limit > 0", "/usr/src/repo/source/library/prng.c", 170, __extension__ __PRETTY_FUNCTION__));
    ((limit < 65536) ? (void) (0) : __assert_fail ("limit < 65536", "/usr/src/repo/source/library/prng.c", 171, __extension__ __PRETTY_FUNCTION__));
    m |= m >> 1;
    m |= m >> 2;
    m |= m >> 4;
    m |= m >> 8;
    do {
        if (rptr == ring) reload();
        v = m & *--rptr;
    } while (v >= limit);
    return v;
}

canonical_original_code:
int ojr_rand(int limit) {
    int v; int m = limit - 1;
    ((_seeded) ? (void) (0) : __assert_fail ("_seeded", "/usr/src/repo/source/library/prng.c", 169, __extension__ __PRETTY_FUNCTION__));
    ((limit > 0) ? (void) (0) : __assert_fail ("limit > 0", "/usr/src/repo/source/library/prng.c", 170, __extension__ __PRETTY_FUNCTION__));
    ((limit < 65536) ? (void) (0) : __assert_fail ("limit < 65536", "/usr/src/repo/source/library/prng.c", 171, __extension__ __PRETTY_FUNCTION__));
    m |= m >> 1;
    m |= m >> 2;
    m |= m >> 4;
    m |= m >> 8;
    do {
        if (rptr == ring) reload();
        v = m & *--rptr;
    } while (v >= limit);
    return v;
}

variable_types: limit int

variable_types: v int

variable_types: m int


decompiled_code:
__int64 ojd_ntypes()
{
return 7LL;
}

canonical_decompiled_code:
__int64 func0()
{
return 7LL;
}

original_code: int ojd_ntypes(void) { return 7; }

canonical_original_code: int ojd_ntypes() { return 7; }


decompiled_code:
__int64 __fastcall ojd_size(unsigned int a1)
{
return *((_QWORD *)&oj_common_decks + 11 * a1 + 2);
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
return *((_QWORD *)&oj_common_decks + 11 * a1 + 2);
}

original_code: int ojd_size(oj_decktype t) { return _oj_common_decks[t].length; }

canonical_original_code: int ojd_size(enum _oj_decktype t) { return _oj_common_decks[t].length; }

variable_types: enum _oj_decktype { OJD_STANDARD=0, OJD_ONEJOKER=1, OJD_TWOJOKERS=2, OJD_SKAT=3, OJD_PAN=4, OJD_PANJ=5, OJD_PINOCHLE=6 }


decompiled_code:
char *__fastcall ojd_deck(unsigned int a1)
{
return (char *)&oj_common_decks + 88 * a1;
}

canonical_decompiled_code:
char *__fastcall func2(unsigned int a1)
{
return (char *)&oj_common_decks + 88 * a1;
}

original_code: oj_cardlist *ojd_deck(oj_decktype t) { return &_oj_common_decks[t]; }

canonical_original_code: struct _oj_cardlist *ojd_deck(enum _oj_decktype t) { return &_oj_common_decks[t]; }

return_type: struct _oj_cardlist { int _johnnymoss; long allocation; long pflags; unsigned long mask; char *cards; void *filler[4]; } *

user_defined_types: enum _oj_decktype { OJD_STANDARD=0, OJD_ONEJOKER=1, OJD_TWOJOKERS=2, OJD_SKAT=3, OJD_PAN=4, OJD_PANJ=5, OJD_PINOCHLE=6 }


original_code:
int64_t ojc_binomial(int n, int k) {
    ((n >= 0 && k >= 0) ? (void) (0) : __assert_fail ("n >= 0 && k >= 0", "/usr/src/repo/source/library/combiner.c", 21, __extension__ __PRETTY_FUNCTION__));
    if (0 == k || n == k) return 1LL;
    if (k > n) return 0LL;
    if (k > (n - k)) k = n - k;
    if (1 == k) return (long long)n;
    if (n <= 54 && k <= 54) {
        return bctable[(((n - 3) * (n - 3)) >> 2) + k];
    }
    int64_t b = 1LL;
    for (int i = 1; i <= k; ++i) {
        b *= (n - (k - i));
        if (b < 0) return -1LL;
        b /= i;
    }
    return b;
}

canonical_original_code:
long ojc_binomial(int n, int k) {
    ((n >= 0 && k >= 0) ? (void) (0) : __assert_fail ("n >= 0 && k >= 0", "/usr/src/repo/source/library/combiner.c", 21, __extension__ __PRETTY_FUNCTION__));
    if (0 == k || n == k) return 1LL;
    if (k > n) return 0LL;
    if (k > (n - k)) k = n - k;
    if (1 == k) return (long long)n;
    if (n <= 54 && k <= 54) {
        return bctable[(((n - 3) * (n - 3)) >> 2) + k];
    }
    long b = 1LL;
    for (int i = 1; i <= k; ++i) {
        b *= (n - (k - i));
        if (b < 0) return -1LL;
        b /= i;
    }
    return b;
}

variable_types: n int

variable_types: k int

variable_types: b long

return_type: long


original_code:
int ojc_new(
    oj_combiner *cp,
    oj_cardlist *deck,
    oj_cardlist *hand,
    int k,
    int64_t count)
{
    int i;
    ((0 != cp && 0 != deck && 0 != hand) ? (void) (0) : __assert_fail ("0 != cp && 0 != deck && 0 != hand", "/usr/src/repo/source/library/combiner.c", 52, __extension__ __PRETTY_FUNCTION__));
    ((hand->allocation >= k) ? (void) (0) : __assert_fail ("hand->allocation >= k", "/usr/src/repo/source/library/combiner.c", 53, __extension__ __PRETTY_FUNCTION__));
    ((deck->length >= k && deck->length <= 54) ? (void) (0) : __assert_fail ("deck->length >= k && deck->length <= 54", "/usr/src/repo/source/library/combiner.c", 54, __extension__ __PRETTY_FUNCTION__));
    ((k >= 0 && k <= 54) ? (void) (0) : __assert_fail ("k >= 0 && k <= 54", "/usr/src/repo/source/library/combiner.c", 55, __extension__ __PRETTY_FUNCTION__));
    if (hand->pflags & 1) return (-2);
    if (hand->pflags & 2) return (-4);
    cp->_johnnymoss = 0x10ACE0FF;
    cp->deck = deck;
    cp->hand = hand;
    cp->k = k;
    cp->total = ojc_binomial(deck->length, k);
    if (0 == count) cp->remaining = cp->total;
    else cp->remaining = count;
    hand->length = k;
    for (i = 0; i < k; ++i) hand->cards[i] = deck->cards[i];
    for (i = 0; i < deck->length; ++i) {
        cp->map[i] = cp->invert[deck->cards[i]] = i;
    }
    hand->eflags = 0;
    return 0;
}

canonical_original_code:
int ojc_new(struct _oj_combiner *cp, struct _oj_cardlist *deck, struct _oj_cardlist *hand, int k, long count)
{
    int i;
    ((0 != cp && 0 != deck && 0 != hand) ? (void) (0) : __assert_fail ("0 != cp && 0 != deck && 0 != hand", "/usr/src/repo/source/library/combiner.c", 52, __extension__ __PRETTY_FUNCTION__));
    ((hand->allocation >= k) ? (void) (0) : __assert_fail ("hand->allocation >= k", "/usr/src/repo/source/library/combiner.c", 53, __extension__ __PRETTY_FUNCTION__));
    ((deck->length >= k && deck->length <= 54) ? (void) (0) : __assert_fail ("deck->length >= k && deck->length <= 54", "/usr/src/repo/source/library/combiner.c", 54, __extension__ __PRETTY_FUNCTION__));
    ((k >= 0 && k <= 54) ? (void) (0) : __assert_fail ("k >= 0 && k <= 54", "/usr/src/repo/source/library/combiner.c", 55, __extension__ __PRETTY_FUNCTION__));
    if (hand->pflags & 1) return (-2);
    if (hand->pflags & 2) return (-4);
    cp->_johnnymoss = 0x10ACE0FF;
    cp->deck = deck;
    cp->hand = hand;
    cp->k = k;
    cp->total = ojc_binomial(deck->length, k);
    if (0 == count) cp->remaining = cp->total;
    else cp->remaining = count;
    hand->length = k;
    for (i = 0; i < k; ++i) hand->cards[i] = deck->cards[i];
    for (i = 0; i < deck->length; ++i) {
        cp->map[i] = cp->invert[deck->cards[i]] = i;
    }
    hand->eflags = 0;
    return 0;
}

variable_types: struct _oj_combiner { int _johnnymoss; long k; struct _oj_cardlist { int _johnnymoss; long allocation; long pflags; unsigned long mask; char *cards; void *filler[4]; } *deck; char map[56]; long total; void *filler[4]; } *

variable_types:
deck
struct _oj_cardlist *

variable_types:
hand
struct _oj_cardlist *

variable_types: count long

user_defined_types: struct _oj_combiner { int _johnnymoss; long k; struct _oj_cardlist *deck; char map[56]; long total; void *filler[4]; }


original_code:
int ojc_next(oj_combiner *cp) {
    int i, j, k = cp->k, n = cp->deck->length;
    oj_card *a = cp->map;
    ((0 != cp && 0x10ACE0FF == cp->_johnnymoss) ? (void) (0) : __assert_fail ("0 != cp && 0x10ACE0FF == cp->_johnnymoss", "/usr/src/repo/source/library/combiner.c", 83, __extension__ __PRETTY_FUNCTION__));
    if (0 == cp->remaining) return 0;
    if (cp->remaining != cp->total) {
        for (i = 0; i < k-1; ++i) {
            if (a[i] < a[i+1] - 1) break;
        }
        ((! ((i == k-1) && (a[i] == n-1))) ? (void) (0) : __assert_fail ("! ((i == k-1) && (a[i] == n-1))", "/usr/src/repo/source/library/combiner.c", 91, __extension__ __PRETTY_FUNCTION__));
        ++a[i];
        for (j = 0; j < i; ++j) a[j] = j;
    }
    for (int c = 0; c < k; ++c) {
        cp->hand->cards[c] = cp->deck->cards[a[c]];
    }
    --cp->remaining;
    cp->hand->eflags = 0;
    return 1;
}

canonical_original_code:
int ojc_next(struct _oj_combiner *cp) {
    int i; int j; int k = cp->k; int n = cp->deck->length;
    char *a = cp->map;
    ((0 != cp && 0x10ACE0FF == cp->_johnnymoss) ? (void) (0) : __assert_fail ("0 != cp && 0x10ACE0FF == cp->_johnnymoss", "/usr/src/repo/source/library/combiner.c", 83, __extension__ __PRETTY_FUNCTION__));
    if (0 == cp->remaining) return 0;
    if (cp->remaining != cp->total) {
        for (i = 0; i < k-1; ++i) {
            if (a[i] < a[i+1] - 1) break;
        }
        ((! ((i == k-1) && (a[i] == n-1))) ? (void) (0) : __assert_fail ("! ((i == k-1) && (a[i] == n-1))", "/usr/src/repo/source/library/combiner.c", 91, __extension__ __PRETTY_FUNCTION__));
        ++a[i];
        for (j = 0; j < i; ++j) a[j] = j;
    }
    for (int c = 0; c < k; ++c) {
        cp->hand->cards[c] = cp->deck->cards[a[c]];
    }
    --cp->remaining;
    cp->hand->eflags = 0;
    return 1;
}

variable_types: i int

variable_types: j int

variable_types:
a
char *

variable_types: c int

user_defined_types: struct _oj_cardlist { int _johnnymoss; long allocation; long pflags; unsigned long mask; char *cards; void *filler[4]; }


original_code:
int ojc_next_random(oj_combiner *cp) {
    int k = cp->k, n = cp->deck->length;
    oj_card *mp = cp->map;
    ((0 != cp && 0x10ACE0FF == cp->_johnnymoss) ? (void) (0) : __assert_fail ("0 != cp && 0x10ACE0FF == cp->_johnnymoss", "/usr/src/repo/source/library/combiner.c", 107, __extension__ __PRETTY_FUNCTION__));
    if (0 == cp->remaining) return 0;
    int_fast64_t set = 0ll, m;
    for (int j = n - k; j < n; ++j) {
        int r = ojr_rand(j+1);
        m = 1ll << r;
        if (set & m) {
            *mp++ = j;
            set |= (1ll << j);
        } else {
            *mp++ = r;
            set |= m;
        }
    }
    for (int i = 0; i < k; ++i) {
        cp->hand->cards[i] = cp->deck->cards[cp->map[i]];
    }
    --cp->remaining;
    cp->hand->eflags = 0;
    return 1;
}

canonical_original_code:
int ojc_next_random(struct _oj_combiner *cp) {
    int k = cp->k; int n = cp->deck->length;
    char *mp = cp->map;
    ((0 != cp && 0x10ACE0FF == cp->_johnnymoss) ? (void) (0) : __assert_fail ("0 != cp && 0x10ACE0FF == cp->_johnnymoss", "/usr/src/repo/source/library/combiner.c", 107, __extension__ __PRETTY_FUNCTION__));
    if (0 == cp->remaining) return 0;
    long set = 0ll; long m;
    for (int j = n - k; j < n; ++j) {
        int r = ojr_rand(j+1);
        m = 1ll << r;
        if (set & m) {
            *mp++ = j;
            set |= (1ll << j);
        } else {
            *mp++ = r;
            set |= m;
        }
    }
    for (int i = 0; i < k; ++i) {
        cp->hand->cards[i] = cp->deck->cards[cp->map[i]];
    }
    --cp->remaining;
    cp->hand->eflags = 0;
    return 1;
}

variable_types:
mp
char *

variable_types: set long

variable_types: m long

variable_types: r int


decompiled_code:
__int64 __fastcall ojc_colex_rank(__int64 a1, __int64 a2)
{
__int64 v3; // rdx
__int64 v4; // rsi
__int64 v5; // rcx
__int64 i; // rax
__int64 v7; // rbx
__int64 v8; // r12
char v10[104]; // [rsp+0h] [rbp-68h] BYREF

if ( !a2 || !a1 )
_assert_fail("0 != hand && 0 != cp", "/usr/src/repo/source/library/combiner.c", 0x8Bu, "ojc_colex_rank");
v3 = *(_QWORD *)(a2 + 16);
if ( v3 > 63 )
_assert_fail("hand->length < 64", "/usr/src/repo/source/library/combiner.c", 0x8Cu, "ojc_colex_rank");
v4 = *(_QWORD *)(a1 + 8);
if ( v3 != v4 )
return -1LL;
if ( v4 > 0 )
{
v5 = *(_QWORD *)(a2 + 48);
for ( i = 0LL; i != v4; ++i )
v10[i] = *(_BYTE *)(a1 + *(char *)(v5 + i) + 96);
}
ojl_sort_cards(v10);
if ( *(__int64 *)(a1 + 8) <= 0 )
return 0LL;
v7 = 0LL;
v8 = 0LL;
do
{
v8 += ojc_binomial(v10[v7], (int)v7 + 1);
++v7;
}
while ( *(_QWORD *)(a1 + 8) > v7 );
return v8;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
__int64 v3; // rdx
__int64 v4; // rsi
__int64 v5; // rcx
__int64 i; // rax
__int64 v7; // rbx
__int64 v8; // r12
char v10[104]; // [rsp+0h] [rbp-68h] BYREF

if ( !a2 || !a1 )
_assert_fail("0 != hand && 0 != cp", "/usr/src/repo/source/library/combiner.c", 0x8Bu, "ojc_colex_rank");
v3 = *(_QWORD *)(a2 + 16);
if ( v3 > 63 )
_assert_fail("hand->length < 64", "/usr/src/repo/source/library/combiner.c", 0x8Cu, "ojc_colex_rank");
v4 = *(_QWORD *)(a1 + 8);
if ( v3 != v4 )
return -1LL;
if ( v4 > 0 )
{
v5 = *(_QWORD *)(a2 + 48);
for ( i = 0LL; i != v4; ++i )
v10[i] = *(_BYTE *)(a1 + *(char *)(v5 + i) + 96);
}
ojl_sort_cards(v10);
if ( *(__int64 *)(a1 + 8) <= 0 )
return 0LL;
v7 = 0LL;
v8 = 0LL;
do
{
v8 += func0(v10[v7], (int)v7 + 1);
++v7;
}
while ( *(_QWORD *)(a1 + 8) > v7 );
return v8;
}

original_code:
int64_t ojc_colex_rank(oj_combiner *cp, oj_cardlist *hand) {
    oj_card buf[56];
    int64_t r = 0LL;
    ((0 != hand && 0 != cp) ? (void) (0) : __assert_fail ("0 != hand && 0 != cp", "/usr/src/repo/source/library/combiner.c", 139, __extension__ __PRETTY_FUNCTION__));
    ((hand->length < 64) ? (void) (0) : __assert_fail ("hand->length < 64", "/usr/src/repo/source/library/combiner.c", 140, __extension__ __PRETTY_FUNCTION__));
    if (hand->length != cp->k) return -1LL;
    for (int i = 0; i < cp->k; ++i) buf[i] = cp->invert[hand->cards[i]];
    _ojl_sort_cards(buf, cp->k);
    for (int i = 0; i < cp->k; ++i) r += ojc_binomial(buf[i], i + 1);
    return r;
}

canonical_original_code:
long ojc_colex_rank(struct _oj_combiner *cp, struct _oj_cardlist *hand) {
    char buf[56];
    long r = 0LL;
    ((0 != hand && 0 != cp) ? (void) (0) : __assert_fail ("0 != hand && 0 != cp", "/usr/src/repo/source/library/combiner.c", 139, __extension__ __PRETTY_FUNCTION__));
    ((hand->length < 64) ? (void) (0) : __assert_fail ("hand->length < 64", "/usr/src/repo/source/library/combiner.c", 140, __extension__ __PRETTY_FUNCTION__));
    if (hand->length != cp->k) return -1LL;
    for (int i = 0; i < cp->k; ++i) buf[i] = cp->invert[hand->cards[i]];
    _ojl_sort_cards(buf, cp->k);
    for (int i = 0; i < cp->k; ++i) r += ojc_binomial(buf[i], i + 1);
    return r;
}

variable_types:
buf
char [56]

variable_types: r long


original_code:
int ojc_colex_hand_at(oj_combiner *cp, int64_t rank, oj_cardlist *hand) {
    int i, n = cp->deck->length;
    oj_card buf[64];
    int64_t b;
    ((0 != hand && 0 != cp) ? (void) (0) : __assert_fail ("0 != hand && 0 != cp", "/usr/src/repo/source/library/combiner.c", 155, __extension__ __PRETTY_FUNCTION__));
    if (hand->pflags & 1) return (-2);
    if (hand->allocation < cp->k) return (-3);
    if (rank >= cp->total) return (-5);
    for (i = cp->k; i >= 1; --i) {
        while ((b = ojc_binomial(n, i)) > rank) --n;
        buf[i-1] = n;
        rank -= b;
    }
    hand->length = cp->k;
    for (i = 0; i < cp->k; ++i) hand->cards[i] = cp->deck->cards[buf[i]];
    hand->eflags = 0;
    return 0;
}

canonical_original_code:
int ojc_colex_hand_at(struct _oj_combiner *cp, long rank, struct _oj_cardlist *hand) {
    int i; int n = cp->deck->length;
    char buf[64];
    long b;
    ((0 != hand && 0 != cp) ? (void) (0) : __assert_fail ("0 != hand && 0 != cp", "/usr/src/repo/source/library/combiner.c", 155, __extension__ __PRETTY_FUNCTION__));
    if (hand->pflags & 1) return (-2);
    if (hand->allocation < cp->k) return (-3);
    if (rank >= cp->total) return (-5);
    for (i = cp->k; i >= 1; --i) {
        while ((b = ojc_binomial(n, i)) > rank) --n;
        buf[i-1] = n;
        rank -= b;
    }
    hand->length = cp->k;
    for (i = 0; i < cp->k; ++i) hand->cards[i] = cp->deck->cards[buf[i]];
    hand->eflags = 0;
    return 0;
}

variable_types: rank long

variable_types: n int

variable_types:
buf
char [64]


decompiled_code:
__int64 __fastcall ojp_eval5(__int64 a1)
{
char *v1; // rcx

if ( !a1 || *(_DWORD *)a1 != 279765247 )
_assert_fail("0 != p && 0x10ACE0FF == p->_johnnymoss", "/usr/src/repo/source/library/poker.c", 0x14u, "ojp_eval5");
if ( *(_QWORD *)(a1 + 16) != 5LL )
_assert_fail("5 == p->length", "/usr/src/repo/source/library/poker.c", 0x15u, "ojp_eval5");
v1 = *(char **)(a1 + 48);
return (unsigned int)ldc4[ldc3[ldc2[v1[2] + ldc1[52 * *v1 - 52 + v1[1]]] + v1[3]] + v1[4]];
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
char *v1; // rcx

if ( !a1 || *(_DWORD *)a1 != 279765247 )
_assert_fail("0 != p && 0x10ACE0FF == p->_johnnymoss", "/usr/src/repo/source/library/poker.c", 0x14u, "ojp_eval5");
if ( *(_QWORD *)(a1 + 16) != 5LL )
_assert_fail("5 == p->length", "/usr/src/repo/source/library/poker.c", 0x15u, "ojp_eval5");
v1 = *(char **)(a1 + 48);
return (unsigned int)ldc4[ldc3[ldc2[v1[2] + ldc1[52 * *v1 - 52 + v1[1]]] + v1[3]] + v1[4]];
}

original_code:
int ojp_eval5(oj_cardlist *p) {
    ((0 != p && 0x10ACE0FF == p->_johnnymoss) ? (void) (0) : __assert_fail ("0 != p && 0x10ACE0FF == p->_johnnymoss", "/usr/src/repo/source/library/poker.c", 20, __extension__ __PRETTY_FUNCTION__));
    ((5 == p->length) ? (void) (0) : __assert_fail ("5 == p->length", "/usr/src/repo/source/library/poker.c", 21, __extension__ __PRETTY_FUNCTION__));
    return ldc4[ ldc3[ ldc2[ ldc1[
        52 * (p->cards[0] - 1) + p->cards[1] ]
           + p->cards[2] ] + p->cards[3] ] + p->cards[4] ];
}

canonical_original_code:
int ojp_eval5(struct _oj_cardlist *p) {
    ((0 != p && 0x10ACE0FF == p->_johnnymoss) ? (void) (0) : __assert_fail ("0 != p && 0x10ACE0FF == p->_johnnymoss", "/usr/src/repo/source/library/poker.c", 20, __extension__ __PRETTY_FUNCTION__));
    ((5 == p->length) ? (void) (0) : __assert_fail ("5 == p->length", "/usr/src/repo/source/library/poker.c", 21, __extension__ __PRETTY_FUNCTION__));
    return ldc4[ ldc3[ ldc2[ ldc1[
        52 * (p->cards[0] - 1) + p->cards[1] ]
           + p->cards[2] ] + p->cards[3] ] + p->cards[4] ];
}

variable_types: struct _oj_cardlist { int _johnnymoss; long allocation; long pflags; unsigned long mask; char *cards; void *filler[4]; } *


variable_types:
h
char *

variable_types: best int


decompiled_code:
__int64 __fastcall ojp_best5(__int64 a1, __int64 a2)
{
__int64 v2; // rax
int v3; // ebp
int v4; // ebx

if ( !a1 || (v2 = *(_QWORD *)(a1 + 16), v2 <= 4) )
_assert_fail("0 != p && p->length >= 5", "/usr/src/repo/source/library/poker.c", 0x8Du, "ojp_best5");
if ( !a2 || *(__int64 *)(a2 + 8) <= 4 || (*(_BYTE *)(a2 + 24) & 1) != 0 )
_assert_fail(
"0 != bh && bh->allocation >= 5 && (!(bh->pflags & OJF_RDONLY))",
"/usr/src/repo/source/library/poker.c",
0x8Eu,
"ojp_best5");
if ( v2 == 5 )
{
ojl_copy(a2, a1);
v3 = ojp_eval5(a1);
}
else
{
ojl_new(&hand, &hbuf, 5LL);
ojc_new(&cmb, a1, &hand, 5LL, 0LL);
v3 = 9999;
while ( (unsigned int)ojc_next(&cmb) )
{
v4 = ojp_eval5((__int64)&hand);
if ( v3 > v4 )
{
ojl_copy(a2, &hand);
v3 = v4;
}
}
}
return (unsigned int)v3;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
__int64 v2; // rax
int v3; // ebp
int v4; // ebx

if ( !a1 || (v2 = *(_QWORD *)(a1 + 16), v2 <= 4) )
_assert_fail("0 != p && p->length >= 5", "/usr/src/repo/source/library/poker.c", 0x8Du, "ojp_best5");
if ( !a2 || *(__int64 *)(a2 + 8) <= 4 || (*(_BYTE *)(a2 + 24) & 1) != 0 )
_assert_fail(
"0 != bh && bh->allocation >= 5 && (!(bh->pflags & OJF_RDONLY))",
"/usr/src/repo/source/library/poker.c",
0x8Eu,
"ojp_best5");
if ( v2 == 5 )
{
ojl_copy(a2, a1);
v3 = func0(a1);
}
else
{
ojl_new(&hand, &hbuf, 5LL);
ojc_new(&cmb, a1, &hand, 5LL, 0LL);
v3 = 9999;
while ( (unsigned int)ojc_next(&cmb) )
{
v4 = func0((__int64)&hand);
if ( v3 > v4 )
{
ojl_copy(a2, &hand);
v3 = v4;
}
}
}
return (unsigned int)v3;
}

original_code:
int ojp_best5(oj_cardlist *p, oj_cardlist *bh) {
    ((0 != p && p->length >= 5) ? (void) (0) : __assert_fail ("0 != p && p->length >= 5", "/usr/src/repo/source/library/poker.c", 141, __extension__ __PRETTY_FUNCTION__));
    ((0 != bh && bh->allocation >= 5 && (!(bh->pflags & 1))) ? (void) (0) : __assert_fail ("0 != bh && bh->allocation >= 5 && (!(bh->pflags & OJF_RDONLY))", "/usr/src/repo/source/library/poker.c", 142, __extension__ __PRETTY_FUNCTION__));
    if (5 == p->length) {
        ojl_copy(bh, p);
        return ojp_eval5(p);
    }
    ojl_new(&_hand, _hbuf, 5);
    ojc_new(&_cmb, p, &_hand, 5, 0LL);
    int best = 9999;
    while (ojc_next(&_cmb)) {
        int v = ojp_eval5(&_hand);
        if (v < best) {
            best = v;
            ojl_copy(bh, &_hand);
        }
    }
    return best;
}

canonical_original_code:
int ojp_best5(struct _oj_cardlist *p, struct _oj_cardlist *bh) {
    ((0 != p && p->length >= 5) ? (void) (0) : __assert_fail ("0 != p && p->length >= 5", "/usr/src/repo/source/library/poker.c", 141, __extension__ __PRETTY_FUNCTION__));
    ((0 != bh && bh->allocation >= 5 && (!(bh->pflags & 1))) ? (void) (0) : __assert_fail ("0 != bh && bh->allocation >= 5 && (!(bh->pflags & OJF_RDONLY))", "/usr/src/repo/source/library/poker.c", 142, __extension__ __PRETTY_FUNCTION__));
    if (5 == p->length) {
        ojl_copy(bh, p);
        return ojp_eval5(p);
    }
    ojl_new(&_hand, _hbuf, 5);
    ojc_new(&_cmb, p, &_hand, 5, 0LL);
    int best = 9999;
    while (ojc_next(&_cmb)) {
        int v = ojp_eval5(&_hand);
        if (v < best) {
            best = v;
            ojl_copy(bh, &_hand);
        }
    }
    return best;
}

variable_types:
bh
struct _oj_cardlist *

variable_types: v int


original_code:
int ojp_hand_info(oj_poker_hand_info *pi, oj_cardlist *p, int val) {
    oj_card t[5], *h = p->cards;
    ((0 != pi && 0 != p) ? (void) (0) : __assert_fail ("0 != pi && 0 != p", "/usr/src/repo/source/library/poker.c", 167, __extension__ __PRETTY_FUNCTION__));
    ((5 == p->length) ? (void) (0) : __assert_fail ("5 == p->length", "/usr/src/repo/source/library/poker.c", 168, __extension__ __PRETTY_FUNCTION__));
    if (-1 == val) val = ojp_eval5(p);
    pi->val = val;
    ojl_sort(p);
    ojl_reverse(p);
    if (val < 11) {
        pi->group = 1;
        pi->nranks = 1;
        pi->ranks[0] = ((oj_rank)(((h[0]) - 1) >> 2));
        if (OJR_ACE == pi->ranks[0] && OJR_FIVE == ((oj_rank)(((h[1]) - 1) >> 2))) {
            pi->ranks[0] = OJR_FIVE;
            t[0] = h[0];
            memmove(h, h + 1, 4 * sizeof(oj_card));
            h[4] = t[0];
        }
    } else if (val < 167) {
        pi->group = 2;
        pi->nranks = 2;
        if (((oj_rank)(((h[0]) - 1) >> 2)) != ((oj_rank)(((h[1]) - 1) >> 2))) {
            t[0] = h[0];
            memmove(h, h + 1, 4 * sizeof(oj_card));
            h[4] = t[0];
        }
        pi->ranks[0] = ((oj_rank)(((h[0]) - 1) >> 2));
        pi->ranks[1] = ((oj_rank)(((h[4]) - 1) >> 2));
    } else if (val < 323) {
        pi->group = 3;
        pi->nranks = 2;
        if (((oj_rank)(((h[0]) - 1) >> 2)) != ((oj_rank)(((h[2]) - 1) >> 2))) {
            memmove(t, h, 2 * sizeof(oj_card));
            memmove(h, h + 2, 3 * sizeof(oj_card));
            memmove(h + 3, t, 2 * sizeof(oj_card));
        }
        pi->ranks[0] = ((oj_rank)(((h[0]) - 1) >> 2));
        pi->ranks[1] = ((oj_rank)(((h[3]) - 1) >> 2));
    } else if (val < 1600) {
        pi->group = 4;
        pi->nranks = 5;
        for (int i = 0; i < 5; ++i) pi->ranks[i] = ((oj_rank)(((h[i]) - 1) >> 2));
    } else if (val < 1610) {
        pi->group = 5;
        pi->nranks = 1;
        pi->ranks[0] = ((oj_rank)(((h[0]) - 1) >> 2));
        if (OJR_ACE == pi->ranks[0] && OJR_FIVE == ((oj_rank)(((h[1]) - 1) >> 2))) {
            pi->ranks[0] = OJR_FIVE;
            t[0] = h[0];
            memmove(h, h + 1, 4 * sizeof(oj_card));
            h[4] = t[0];
        }
    } else if (val < 2468) {
        pi->group = 6;
        pi->nranks = 3;
        for (int i = 0; i < 3; ++i) t[i] = ((oj_rank)(((h[i]) - 1) >> 2));
        if (t[0] != t[1]) {
            if (t[1] != t[2]) {
                memmove(t, h, 2 * sizeof(oj_card));
                memmove(h, h + 2, 3 * sizeof(oj_card));
                memmove(h + 3, t, 2 * sizeof(oj_card));
            } else {
                t[0] = h[0];
                memmove(h, h + 1, 3 * sizeof(oj_card));
                h[3] = t[0];
            }
        }
        for (int i = 0; i < 3; ++i) pi->ranks[i] = ((oj_rank)(((h[i+2]) - 1) >> 2));
    } else if (val < 3326) {
        pi->group = 7;
        pi->nranks = 3;
        for (int i = 0; i < 5; ++i) t[i] = ((oj_rank)(((h[i]) - 1) >> 2));
        if (t[3] == t[4]) {
            if (t[0] == t[1]) {
                t[0] = h[2];
                memmove(h + 2, h + 3, 2 * sizeof(oj_card));
                h[4] = t[0];
            } else {
                t[0] = h[0];
                memmove(h, h + 1, 4 * sizeof(oj_card));
                h[4] = t[0];
            }
        }
        for (int i = 0; i < 3; ++i) pi->ranks[i] = ((oj_rank)(((h[i << 1]) - 1) >> 2));
    } else if (val < 6186) {
        pi->group = 8;
        pi->nranks = 4;
        for (int i = 0; i < 5; ++i) t[i] = ((oj_rank)(((h[i]) - 1) >> 2));
        if (t[1] == t[2]) {
            t[0] = h[0];
            memmove(h, h + 1, 2 * sizeof(oj_card));
            h[2] = t[0];
        } else if (t[2] == t[3]) {
            memmove(t, h, 2 * sizeof(oj_card));
            memmove(h, h + 2, 2 * sizeof(oj_card));
            memmove(h + 2, t, 2 * sizeof(oj_card));
        } else if (t[3] == t[4]) {
            memmove(t, h, 3 * sizeof(oj_card));
            memmove(h, h + 3, 2 * sizeof(oj_card));
            memmove(h + 2, t, 3 * sizeof(oj_card));
        }
        for (int i = 0; i < 4; ++i) pi->ranks[i] = ((oj_rank)(((h[i+1]) - 1) >> 2));
    } else {
        pi->group = 9;
        pi->nranks = 5;
        for (int i = 0; i < 5; ++i) pi->ranks[i] = ((oj_rank)(((h[i]) - 1) >> 2));
    }
    pi->_johnnymoss = 0x10ACE0FF;
    return pi->group;
}

canonical_original_code:
int ojp_hand_info(struct _oj_poker_hand_info *pi, struct _oj_cardlist *p, int val) {
    char t[5]; char *h = p->cards;
    ((0 != pi && 0 != p) ? (void) (0) : __assert_fail ("0 != pi && 0 != p", "/usr/src/repo/source/library/poker.c", 167, __extension__ __PRETTY_FUNCTION__));
    ((5 == p->length) ? (void) (0) : __assert_fail ("5 == p->length", "/usr/src/repo/source/library/poker.c", 168, __extension__ __PRETTY_FUNCTION__));
    if (-1 == val) val = ojp_eval5(p);
    pi->val = val;
    ojl_sort(p);
    ojl_reverse(p);
    if (val < 11) {
        pi->group = 1;
        pi->nranks = 1;
        pi->ranks[0] = ((oj_rank)(((h[0]) - 1) >> 2));
        if (OJR_ACE == pi->ranks[0] && OJR_FIVE == ((oj_rank)(((h[1]) - 1) >> 2))) {
            pi->ranks[0] = OJR_FIVE;
            t[0] = h[0];
            memmove(h, h + 1, 4 * sizeof(oj_card));
            h[4] = t[0];
        }
    } else if (val < 167) {
        pi->group = 2;
        pi->nranks = 2;
        if (((oj_rank)(((h[0]) - 1) >> 2)) != ((oj_rank)(((h[1]) - 1) >> 2))) {
            t[0] = h[0];
            memmove(h, h + 1, 4 * sizeof(oj_card));
            h[4] = t[0];
        }
        pi->ranks[0] = ((oj_rank)(((h[0]) - 1) >> 2));
        pi->ranks[1] = ((oj_rank)(((h[4]) - 1) >> 2));
    } else if (val < 323) {
        pi->group = 3;
        pi->nranks = 2;
        if (((oj_rank)(((h[0]) - 1) >> 2)) != ((oj_rank)(((h[2]) - 1) >> 2))) {
            memmove(t, h, 2 * sizeof(oj_card));
            memmove(h, h + 2, 3 * sizeof(oj_card));
            memmove(h + 3, t, 2 * sizeof(oj_card));
        }
        pi->ranks[0] = ((oj_rank)(((h[0]) - 1) >> 2));
        pi->ranks[1] = ((oj_rank)(((h[3]) - 1) >> 2));
    } else if (val < 1600) {
        pi->group = 4;
        pi->nranks = 5;
        for (int i = 0; i < 5; ++i) pi->ranks[i] = ((oj_rank)(((h[i]) - 1) >> 2));
    } else if (val < 1610) {
        pi->group = 5;
        pi->nranks = 1;
        pi->ranks[0] = ((oj_rank)(((h[0]) - 1) >> 2));
        if (OJR_ACE == pi->ranks[0] && OJR_FIVE == ((oj_rank)(((h[1]) - 1) >> 2))) {
            pi->ranks[0] = OJR_FIVE;
            t[0] = h[0];
            memmove(h, h + 1, 4 * sizeof(oj_card));
            h[4] = t[0];
        }
    } else if (val < 2468) {
        pi->group = 6;
        pi->nranks = 3;
        for (int i = 0; i < 3; ++i) t[i] = ((oj_rank)(((h[i]) - 1) >> 2));
        if (t[0] != t[1]) {
            if (t[1] != t[2]) {
                memmove(t, h, 2 * sizeof(oj_card));
                memmove(h, h + 2, 3 * sizeof(oj_card));
                memmove(h + 3, t, 2 * sizeof(oj_card));
            } else {
                t[0] = h[0];
                memmove(h, h + 1, 3 * sizeof(oj_card));
                h[3] = t[0];
            }
        }
        for (int i = 0; i < 3; ++i) pi->ranks[i] = ((oj_rank)(((h[i+2]) - 1) >> 2));
    } else if (val < 3326) {
        pi->group = 7;
        pi->nranks = 3;
        for (int i = 0; i < 5; ++i) t[i] = ((oj_rank)(((h[i]) - 1) >> 2));
        if (t[3] == t[4]) {
            if (t[0] == t[1]) {
                t[0] = h[2];
                memmove(h + 2, h + 3, 2 * sizeof(oj_card));
                h[4] = t[0];
            } else {
                t[0] = h[0];
                memmove(h, h + 1, 4 * sizeof(oj_card));
                h[4] = t[0];
            }
        }
        for (int i = 0; i < 3; ++i) pi->ranks[i] = ((oj_rank)(((h[i << 1]) - 1) >> 2));
    } else if (val < 6186) {
        pi->group = 8;
        pi->nranks = 4;
        for (int i = 0; i < 5; ++i) t[i] = ((oj_rank)(((h[i]) - 1) >> 2));
        if (t[1] == t[2]) {
            t[0] = h[0];
            memmove(h, h + 1, 2 * sizeof(oj_card));
            h[2] = t[0];
        } else if (t[2] == t[3]) {
            memmove(t, h, 2 * sizeof(oj_card));
            memmove(h, h + 2, 2 * sizeof(oj_card));
            memmove(h + 2, t, 2 * sizeof(oj_card));
        } else if (t[3] == t[4]) {
            memmove(t, h, 3 * sizeof(oj_card));
            memmove(h, h + 3, 2 * sizeof(oj_card));
            memmove(h + 2, t, 3 * sizeof(oj_card));
        }
        for (int i = 0; i < 4; ++i) pi->ranks[i] = ((oj_rank)(((h[i+1]) - 1) >> 2));
    } else {
        pi->group = 9;
        pi->nranks = 5;
        for (int i = 0; i < 5; ++i) pi->ranks[i] = ((oj_rank)(((h[i]) - 1) >> 2));
    }
    pi->_johnnymoss = 0x10ACE0FF;
    return pi->group;
}

variable_types: struct _oj_poker_hand_info { int _johnnymoss; int val; int ranks[5]; void *filler[4]; } *

variable_types: val int

variable_types:
t
char [5]

variable_types: i int


decompiled_code:
__int64 __fastcall ojp_hand_group_name(int a1)
{
if ( (unsigned int)(a1 - 1) > 8 )
_assert_fail("g >= 1 && g <= 9", "/usr/src/repo/source/library/poker.c", 0x11Du, "ojp_hand_group_name");
return ojp_hand_group_names[a1];
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1)
{
if ( (unsigned int)(a1 - 1) > 8 )
_assert_fail("g >= 1 && g <= 9", "/usr/src/repo/source/library/poker.c", 0x11Du, "ojp_hand_group_name");
return ojp_hand_group_names[a1];
}

original_code:
char *ojp_hand_group_name(int g) {
    ((g >= 1 && g <= 9) ? (void) (0) : __assert_fail ("g >= 1 && g <= 9", "/usr/src/repo/source/library/poker.c", 285, __extension__ __PRETTY_FUNCTION__));
    return _ojp_hand_group_names[g];
}

variable_types: g int

return_type: char *


decompiled_code:
char *__fastcall ojp_hand_description(_DWORD *a1, char *a2, int a3)
{
__int64 v5; // rdi
const char *v6; // rax
const char *v7; // r13
__int64 v8; // rdi
const char *v9; // rbx
const char *v10; // rax
__int64 v12; // rdi
const char *v13; // r14
const char *v14; // r13
__int64 v15; // rdi
const char *v16; // rbx
const char *v17; // rax
const char *v18; // r15
const char *v19; // r14
const char *v20; // r13
const char *v21; // rax
const char *v22; // rax
const char *v23; // r14
const char *v24; // r13
__int64 v25; // rdi
const char *v26; // rbx
const char *v27; // rax
const char *v28; // r15
__int64 v29; // rdi
const char *v30; // r14
const char *v31; // r13
__int64 v32; // rdi
const char *v33; // rbx
const char *v34; // rax
const char *v35; // r15
const char *v36; // r14
const char *v37; // r13
__int64 v38; // rdi
const char *v39; // rbx
const char *v40; // rax
const char *v41; // r15
const char *v42; // r14
const char *v43; // r13
const char *v44; // rax
const char *v45; // [rsp+8h] [rbp-40h]
const char *v46; // [rsp+8h] [rbp-40h]

if ( *a1 != 279765247 )
_assert_fail(
"0x10ACE0FF == pi->_johnnymoss",
"/usr/src/repo/source/library/poker.c",
0x125u,
"ojp_hand_description");
switch ( a1[2] )
{
case 1:
v5 = (unsigned int)a1[4];
if ( (_DWORD)v5 == 12 )
{
snprintf(a2, a3, "Royal Flush");
}
else
{
v6 = (const char *)ojt_rank(v5);
snprintf(a2, a3, "%s-high Straight Flush", v6);
}
break;
case 2:
v7 = (const char *)ojt_rank((unsigned int)a1[5]);
v8 = (unsigned int)a1[4];
v9 = "es";
if ( (_DWORD)v8 != 4 )
v9 = "s";
v10 = (const char *)ojt_rank(v8);
snprintf(a2, a3, "Four %s%s, %s", v10, v9, v7);
break;
case 3:
v12 = (unsigned int)a1[5];
v13 = "es";
if ( (_DWORD)v12 != 4 )
v13 = "s";
v14 = (const char *)ojt_rank(v12);
v15 = (unsigned int)a1[4];
v16 = "es";
if ( (_DWORD)v15 != 4 )
v16 = "s";
v17 = (const char *)ojt_rank(v15);
snprintf(a2, a3, "%s%s Full of %s%s", v17, v16, v14, v13);
break;
case 4:
v18 = (const char *)ojt_rank((unsigned int)a1[8]);
v19 = (const char *)ojt_rank((unsigned int)a1[7]);
v20 = (const char *)ojt_rank((unsigned int)a1[6]);
v45 = (const char *)ojt_rank((unsigned int)a1[5]);
v21 = (const char *)ojt_rank((unsigned int)a1[4]);
snprintf(a2, a3, "Flush, %s, %s, %s, %s, %s", v21, v45, v20, v19, v18);
break;
case 5:
v22 = (const char *)ojt_rank((unsigned int)a1[4]);
snprintf(a2, a3, "%s-high Straight", v22);
break;
case 6:
v23 = (const char *)ojt_rank((unsigned int)a1[6]);
v24 = (const char *)ojt_rank((unsigned int)a1[5]);
v25 = (unsigned int)a1[4];
v26 = "es";
if ( (_DWORD)v25 != 4 )
v26 = "s";
v27 = (const char *)ojt_rank(v25);
snprintf(a2, a3, "Three %s%s, %s, %s", v27, v26, v24, v23);
break;
case 7:
v28 = (const char *)ojt_rank((unsigned int)a1[6]);
v29 = (unsigned int)a1[5];
v30 = "es";
if ( (_DWORD)v29 != 4 )
v30 = "s";
v31 = (const char *)ojt_rank(v29);
v32 = (unsigned int)a1[4];
v33 = "es";
if ( (_DWORD)v32 != 4 )
v33 = "s";
v34 = (const char *)ojt_rank(v32);
snprintf(a2, a3, "Two Pair, %s%s and %s%s, %s", v34, v33, v31, v30, v28);
break;
case 8:
v35 = (const char *)ojt_rank((unsigned int)a1[7]);
v36 = (const char *)ojt_rank((unsigned int)a1[6]);
v37 = (const char *)ojt_rank((unsigned int)a1[5]);
v38 = (unsigned int)a1[4];
v39 = "es";
if ( (_DWORD)v38 != 4 )
v39 = "s";
v40 = (const char *)ojt_rank(v38);
snprintf(a2, a3, "Pair of %s%s, %s, %s, %s", v40, v39, v37, v36, v35);
break;
case 9:
v41 = (const char *)ojt_rank((unsigned int)a1[8]);
v42 = (const char *)ojt_rank((unsigned int)a1[7]);
v43 = (const char *)ojt_rank((unsigned int)a1[6]);
v46 = (const char *)ojt_rank((unsigned int)a1[5]);
v44 = (const char *)ojt_rank((unsigned int)a1[4]);
snprintf(a2, a3, "No Pair, %s, %s, %s, %s, %s", v44, v46, v43, v42, v41);
break;
default:
return a2;
}
return a2;
}

canonical_decompiled_code:
char *__fastcall func5(_DWORD *a1, char *a2, int a3)
{
__int64 v5; // rdi
const char *v6; // rax
const char *v7; // r13
__int64 v8; // rdi
const char *v9; // rbx
const char *v10; // rax
__int64 v12; // rdi
const char *v13; // r14
const char *v14; // r13
__int64 v15; // rdi
const char *v16; // rbx
const char *v17; // rax
const char *v18; // r15
const char *v19; // r14
const char *v20; // r13
const char *v21; // rax
const char *v22; // rax
const char *v23; // r14
const char *v24; // r13
__int64 v25; // rdi
const char *v26; // rbx
const char *v27; // rax
const char *v28; // r15
__int64 v29; // rdi
const char *v30; // r14
const char *v31; // r13
__int64 v32; // rdi
const char *v33; // rbx
const char *v34; // rax
const char *v35; // r15
const char *v36; // r14
const char *v37; // r13
__int64 v38; // rdi
const char *v39; // rbx
const char *v40; // rax
const char *v41; // r15
const char *v42; // r14
const char *v43; // r13
const char *v44; // rax
const char *v45; // [rsp+8h] [rbp-40h]
const char *v46; // [rsp+8h] [rbp-40h]

if ( *a1 != 279765247 )
_assert_fail(
"0x10ACE0FF == pi->_johnnymoss",
"/usr/src/repo/source/library/poker.c",
0x125u,
"ojp_hand_description");
switch ( a1[2] )
{
case 1:
v5 = (unsigned int)a1[4];
if ( (_DWORD)v5 == 12 )
{
snprintf(a2, a3, "Royal Flush");
}
else
{
v6 = (const char *)ojt_rank(v5);
snprintf(a2, a3, "%s-high Straight Flush", v6);
}
break;
case 2:
v7 = (const char *)ojt_rank((unsigned int)a1[5]);
v8 = (unsigned int)a1[4];
v9 = "es";
if ( (_DWORD)v8 != 4 )
v9 = "s";
v10 = (const char *)ojt_rank(v8);
snprintf(a2, a3, "Four %s%s, %s", v10, v9, v7);
break;
case 3:
v12 = (unsigned int)a1[5];
v13 = "es";
if ( (_DWORD)v12 != 4 )
v13 = "s";
v14 = (const char *)ojt_rank(v12);
v15 = (unsigned int)a1[4];
v16 = "es";
if ( (_DWORD)v15 != 4 )
v16 = "s";
v17 = (const char *)ojt_rank(v15);
snprintf(a2, a3, "%s%s Full of %s%s", v17, v16, v14, v13);
break;
case 4:
v18 = (const char *)ojt_rank((unsigned int)a1[8]);
v19 = (const char *)ojt_rank((unsigned int)a1[7]);
v20 = (const char *)ojt_rank((unsigned int)a1[6]);
v45 = (const char *)ojt_rank((unsigned int)a1[5]);
v21 = (const char *)ojt_rank((unsigned int)a1[4]);
snprintf(a2, a3, "Flush, %s, %s, %s, %s, %s", v21, v45, v20, v19, v18);
break;
case 5:
v22 = (const char *)ojt_rank((unsigned int)a1[4]);
snprintf(a2, a3, "%s-high Straight", v22);
break;
case 6:
v23 = (const char *)ojt_rank((unsigned int)a1[6]);
v24 = (const char *)ojt_rank((unsigned int)a1[5]);
v25 = (unsigned int)a1[4];
v26 = "es";
if ( (_DWORD)v25 != 4 )
v26 = "s";
v27 = (const char *)ojt_rank(v25);
snprintf(a2, a3, "Three %s%s, %s, %s", v27, v26, v24, v23);
break;
case 7:
v28 = (const char *)ojt_rank((unsigned int)a1[6]);
v29 = (unsigned int)a1[5];
v30 = "es";
if ( (_DWORD)v29 != 4 )
v30 = "s";
v31 = (const char *)ojt_rank(v29);
v32 = (unsigned int)a1[4];
v33 = "es";
if ( (_DWORD)v32 != 4 )
v33 = "s";
v34 = (const char *)ojt_rank(v32);
snprintf(a2, a3, "Two Pair, %s%s and %s%s, %s", v34, v33, v31, v30, v28);
break;
case 8:
v35 = (const char *)ojt_rank((unsigned int)a1[7]);
v36 = (const char *)ojt_rank((unsigned int)a1[6]);
v37 = (const char *)ojt_rank((unsigned int)a1[5]);
v38 = (unsigned int)a1[4];
v39 = "es";
if ( (_DWORD)v38 != 4 )
v39 = "s";
v40 = (const char *)ojt_rank(v38);
snprintf(a2, a3, "Pair of %s%s, %s, %s, %s", v40, v39, v37, v36, v35);
break;
case 9:
v41 = (const char *)ojt_rank((unsigned int)a1[8]);
v42 = (const char *)ojt_rank((unsigned int)a1[7]);
v43 = (const char *)ojt_rank((unsigned int)a1[6]);
v46 = (const char *)ojt_rank((unsigned int)a1[5]);
v44 = (const char *)ojt_rank((unsigned int)a1[4]);
snprintf(a2, a3, "No Pair, %s, %s, %s, %s, %s", v44, v46, v43, v42, v41);
break;
default:
return a2;
}
return a2;
}

original_code:
char *ojp_hand_description(oj_poker_hand_info *pi, char *buf, int size) {
    ((0x10ACE0FF == pi->_johnnymoss) ? (void) (0) : __assert_fail ("0x10ACE0FF == pi->_johnnymoss", "/usr/src/repo/source/library/poker.c", 293, __extension__ __PRETTY_FUNCTION__));
    switch (pi->group) {
    case 1:
        if (12 == pi->ranks[0]) {
            snprintf(buf, size, "Royal Flush");
        } else {
            snprintf(buf, size, "%s-high Straight Flush", (ojt_rank(pi->ranks[0])));
        }
        break;
    case 2:
        snprintf(buf, size, "Four %s%s, %s", (ojt_rank(pi->ranks[0])), ((OJR_SIX==pi->ranks[0])?"es":"s"), (ojt_rank(pi->ranks[1])));
        break;
    case 3:
        snprintf(buf, size, "%s%s Full of %s%s", (ojt_rank(pi->ranks[0])), ((OJR_SIX==pi->ranks[0])?"es":"s"),
            (ojt_rank(pi->ranks[1])), ((OJR_SIX==pi->ranks[1])?"es":"s"));
        break;
    case 4:
        snprintf(buf, size, "Flush, %s, %s, %s, %s, %s", (ojt_rank(pi->ranks[0])), (ojt_rank(pi->ranks[1])),
            (ojt_rank(pi->ranks[2])), (ojt_rank(pi->ranks[3])), (ojt_rank(pi->ranks[4])));
        break;
    case 5:
        snprintf(buf, size, "%s-high Straight", (ojt_rank(pi->ranks[0])));
        break;
    case 6:
        snprintf(buf, size, "Three %s%s, %s, %s", (ojt_rank(pi->ranks[0])), ((OJR_SIX==pi->ranks[0])?"es":"s"),
            (ojt_rank(pi->ranks[1])), (ojt_rank(pi->ranks[2])));
        break;
    case 7:
        snprintf(buf, size, "Two Pair, %s%s and %s%s, %s", (ojt_rank(pi->ranks[0])), ((OJR_SIX==pi->ranks[0])?"es":"s"),
            (ojt_rank(pi->ranks[1])), ((OJR_SIX==pi->ranks[1])?"es":"s"), (ojt_rank(pi->ranks[2])));
        break;
    case 8:
        snprintf(buf, size, "Pair of %s%s, %s, %s, %s", (ojt_rank(pi->ranks[0])), ((OJR_SIX==pi->ranks[0])?"es":"s"),
            (ojt_rank(pi->ranks[1])), (ojt_rank(pi->ranks[2])), (ojt_rank(pi->ranks[3])));
        break;
    case 9:
        snprintf(buf, size, "No Pair, %s, %s, %s, %s, %s", (ojt_rank(pi->ranks[0])), (ojt_rank(pi->ranks[1])),
            (ojt_rank(pi->ranks[2])), (ojt_rank(pi->ranks[3])), (ojt_rank(pi->ranks[4])));
        break;
    }
    return buf;
}

canonical_original_code:
char *ojp_hand_description(struct _oj_poker_hand_info *pi, char *buf, int size) {
    ((0x10ACE0FF == pi->_johnnymoss) ? (void) (0) : __assert_fail ("0x10ACE0FF == pi->_johnnymoss", "/usr/src/repo/source/library/poker.c", 293, __extension__ __PRETTY_FUNCTION__));
    switch (pi->group) {
    case 1:
        if (12 == pi->ranks[0]) {
            snprintf(buf, size, "Royal Flush");
        } else {
            snprintf(buf, size, "%s-high Straight Flush", (ojt_rank(pi->ranks[0])));
        }
        break;
    case 2:
        snprintf(buf, size, "Four %s%s, %s", (ojt_rank(pi->ranks[0])), ((OJR_SIX==pi->ranks[0])?"es":"s"), (ojt_rank(pi->ranks[1])));
        break;
    case 3:
        snprintf(buf, size, "%s%s Full of %s%s", (ojt_rank(pi->ranks[0])), ((OJR_SIX==pi->ranks[0])?"es":"s"),
            (ojt_rank(pi->ranks[1])), ((OJR_SIX==pi->ranks[1])?"es":"s"));
        break;
    case 4:
        snprintf(buf, size, "Flush, %s, %s, %s, %s, %s", (ojt_rank(pi->ranks[0])), (ojt_rank(pi->ranks[1])),
            (ojt_rank(pi->ranks[2])), (ojt_rank(pi->ranks[3])), (ojt_rank(pi->ranks[4])));
        break;
    case 5:
        snprintf(buf, size, "%s-high Straight", (ojt_rank(pi->ranks[0])));
        break;
    case 6:
        snprintf(buf, size, "Three %s%s, %s, %s", (ojt_rank(pi->ranks[0])), ((OJR_SIX==pi->ranks[0])?"es":"s"),
            (ojt_rank(pi->ranks[1])), (ojt_rank(pi->ranks[2])));
        break;
    case 7:
        snprintf(buf, size, "Two Pair, %s%s and %s%s, %s", (ojt_rank(pi->ranks[0])), ((OJR_SIX==pi->ranks[0])?"es":"s"),
            (ojt_rank(pi->ranks[1])), ((OJR_SIX==pi->ranks[1])?"es":"s"), (ojt_rank(pi->ranks[2])));
        break;
    case 8:
        snprintf(buf, size, "Pair of %s%s, %s, %s, %s", (ojt_rank(pi->ranks[0])), ((OJR_SIX==pi->ranks[0])?"es":"s"),
            (ojt_rank(pi->ranks[1])), (ojt_rank(pi->ranks[2])), (ojt_rank(pi->ranks[3])));
        break;
    case 9:
        snprintf(buf, size, "No Pair, %s, %s, %s, %s, %s", (ojt_rank(pi->ranks[0])), (ojt_rank(pi->ranks[1])),
            (ojt_rank(pi->ranks[2])), (ojt_rank(pi->ranks[3])), (ojt_rank(pi->ranks[4])));
        break;
    }
    return buf;
}

variable_types:
buf
char *

variable_types: size int

user_defined_types: struct _oj_poker_hand_info { int _johnnymoss; int val; int ranks[5]; void *filler[4]; }


decompiled_code:
char *__fastcall ojt_card(char a1)
{
if ( (unsigned __int8)(a1 - 1) > 0x35u )
_assert_fail("c > 0 && c < 55", "/usr/src/repo/source/library/text.c", 0x1Cu, "ojt_card");
return cardnames[a1 - 1];
}

canonical_decompiled_code:
char *__fastcall func1(char a1)
{
if ( (unsigned __int8)(a1 - 1) > 0x35u )
_assert_fail("c > 0 && c < 55", "/usr/src/repo/source/library/text.c", 0x1Cu, "ojt_card");
return cardnames[a1 - 1];
}

original_code:
char *ojt_card(oj_card c) {
    ((c > 0 && c < 55) ? (void) (0) : __assert_fail ("c > 0 && c < 55", "/usr/src/repo/source/library/text.c", 28, __extension__ __PRETTY_FUNCTION__));
    return _cardnames[c - 1];
}

canonical_original_code:
char *ojt_card(char c) {
    ((c > 0 && c < 55) ? (void) (0) : __assert_fail ("c > 0 && c < 55", "/usr/src/repo/source/library/text.c", 28, __extension__ __PRETTY_FUNCTION__));
    return _cardnames[c - 1];
}

variable_types: c char


decompiled_code:
char *__fastcall ojt_rank(unsigned int a1)
{
if ( a1 > 0xD )
_assert_fail("r <= 13", "/usr/src/repo/source/library/text.c", 0x27u, "ojt_rank");
return ranknames[a1];
}

canonical_decompiled_code:
char *__fastcall func2(unsigned int a1)
{
if ( a1 > 0xD )
_assert_fail("r <= 13", "/usr/src/repo/source/library/text.c", 0x27u, "ojt_rank");
return ranknames[a1];
}

original_code:
char *ojt_rank(oj_rank r) {
    ((r <= 13) ? (void) (0) : __assert_fail ("r <= 13", "/usr/src/repo/source/library/text.c", 39, __extension__ __PRETTY_FUNCTION__));
    return _ranknames[r];
}

canonical_original_code:
char *ojt_rank(enum _oj_rank r) {
    ((r <= 13) ? (void) (0) : __assert_fail ("r <= 13", "/usr/src/repo/source/library/text.c", 39, __extension__ __PRETTY_FUNCTION__));
    return _ranknames[r];
}

variable_types: enum _oj_rank { OJR_DEUCE=0, OJR_TWO=0, OJR_TREY=1, OJR_THREE=1, OJR_FOUR=2, OJR_FIVE=3, OJR_SIX=4, OJR_SEVEN=5, OJR_EIGHT=6, OJR_NINE=7, OJR_TEN=8, OJR_JACK=9, OJR_KNAVE=9, OJR_QUEEN=10, OJR_KING=11, OJR_ACE=12, OJR_JOKER=13 }


decompiled_code:
char *__fastcall ojt_suit(unsigned int a1)
{
if ( a1 > 3 )
_assert_fail("s <= 3", "/usr/src/repo/source/library/text.c", 0x31u, "ojt_suit");
return suitnames[a1];
}

canonical_decompiled_code:
char *__fastcall func3(unsigned int a1)
{
if ( a1 > 3 )
_assert_fail("s <= 3", "/usr/src/repo/source/library/text.c", 0x31u, "ojt_suit");
return suitnames[a1];
}

original_code:
char *ojt_suit(oj_suit s) {
    ((s <= 3) ? (void) (0) : __assert_fail ("s <= 3", "/usr/src/repo/source/library/text.c", 49, __extension__ __PRETTY_FUNCTION__));
    return _suitnames[s];
}

canonical_original_code:
char *ojt_suit(enum _oj_suit s) {
    ((s <= 3) ? (void) (0) : __assert_fail ("s <= 3", "/usr/src/repo/source/library/text.c", 49, __extension__ __PRETTY_FUNCTION__));
    return _suitnames[s];
}

variable_types: enum _oj_suit { OJS_CLUB=0, OJS_DIAMOND=1, OJS_HEART=2, OJS_SPADE=3 }


decompiled_code:
char *__fastcall ojt_fullname(char a1, char *a2, int a3)
{
if ( (unsigned __int8)(a1 - 1) > 0x35u )
_assert_fail("c > 0 && c < 55", "/usr/src/repo/source/library/text.c", 0x37u, "ojt_fullname");
if ( !a2 || !a3 )
_assert_fail("0 != buf && 0 != size", "/usr/src/repo/source/library/text.c", 0x38u, "ojt_fullname");
*a2 = 0;
if ( a1 == 54 )
strncat(a2, "red joker", a3 - 1);
else
snprintf(a2, a3, "%s of %ss", ranknames[(a1 - 1) >> 2], suitnames[(a1 - 1) & 3]);
return a2;
}

canonical_decompiled_code:
char *__fastcall func4(char a1, char *a2, int a3)
{
if ( (unsigned __int8)(a1 - 1) > 0x35u )
_assert_fail("c > 0 && c < 55", "/usr/src/repo/source/library/text.c", 0x37u, "ojt_fullname");
if ( !a2 || !a3 )
_assert_fail("0 != buf && 0 != size", "/usr/src/repo/source/library/text.c", 0x38u, "ojt_fullname");
*a2 = 0;
if ( a1 == 54 )
strncat(a2, "red joker", a3 - 1);
else
snprintf(a2, a3, "%s of %ss", ranknames[(a1 - 1) >> 2], suitnames[(a1 - 1) & 3]);
return a2;
}

original_code:
char *ojt_fullname(oj_card c, char *buf, int size) {
    ((c > 0 && c < 55) ? (void) (0) : __assert_fail ("c > 0 && c < 55", "/usr/src/repo/source/library/text.c", 55, __extension__ __PRETTY_FUNCTION__));
    ((0 != buf && 0 != size) ? (void) (0) : __assert_fail ("0 != buf && 0 != size", "/usr/src/repo/source/library/text.c", 56, __extension__ __PRETTY_FUNCTION__));
    *buf = '\0';
    if (54 == c) {
        strncat(buf, "red joker", size - 1);
    } else if (53 == 3) {
        strncat(buf, "joker", size - 1);
    } else {
        snprintf(buf, size, "%s of %ss",
            _ranknames[((oj_rank)(((c) - 1) >> 2))], _suitnames[((oj_suit)(((c) - 1) & 3))]);
    }
    return buf;
}

canonical_original_code:
char *ojt_fullname(char c, char *buf, int size) {
    ((c > 0 && c < 55) ? (void) (0) : __assert_fail ("c > 0 && c < 55", "/usr/src/repo/source/library/text.c", 55, __extension__ __PRETTY_FUNCTION__));
    ((0 != buf && 0 != size) ? (void) (0) : __assert_fail ("0 != buf && 0 != size", "/usr/src/repo/source/library/text.c", 56, __extension__ __PRETTY_FUNCTION__));
    *buf = '\0';
    if (54 == c) {
        strncat(buf, "red joker", size - 1);
    } else if (53 == 3) {
        strncat(buf, "joker", size - 1);
    } else {
        snprintf(buf, size, "%s of %ss",
            _ranknames[((oj_rank)(((c) - 1) >> 2))], _suitnames[((oj_suit)(((c) - 1) & 3))]);
    }
    return buf;
}


decompiled_code:
__int64 __fastcall ojt_val(char *a1)
{
__int64 v2; // [rsp+8h] [rbp-10h] BYREF

return parse_card(a1, &v2);
}

canonical_decompiled_code:
__int64 __fastcall func5(char *a1)
{
__int64 v2; // [rsp+8h] [rbp-10h] BYREF

return func0(a1, &v2);
}

original_code:
oj_card ojt_val(char *str) {
    char *next;
    return _parse_card(str, &next);
}

canonical_original_code:
char ojt_val(char *str) {
    char *next;
    return _parse_card(str, &next);
}

variable_types:
str
char *

variable_types:
next
char *

return_type: char


decompiled_code:
__int64 __fastcall ojt_vals(char *a1, _BYTE *a2, int a3)
{
_BYTE *v3; // rbx
_BYTE *v4; // r12
unsigned int v5; // ebp
char v6; // al
char *v8; // [rsp+8h] [rbp-30h] BYREF

if ( a3 == 0 || a2 == 0LL || !a1 )
_assert_fail("0 != str && 0 != arr && 0 != size", "/usr/src/repo/source/library/text.c", 0x87u, "ojt_vals");
v3 = a2;
v4 = &a2[a3 - 1];
v5 = 0;
while ( 1 )
{
v6 = parse_card(a1, &v8);
if ( !v6 )
break;
*v3 = v6;
++v5;
if ( v3 == v4 )
break;
a1 = v8;
++v3;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func6(char *a1, _BYTE *a2, int a3)
{
_BYTE *v3; // rbx
_BYTE *v4; // r12
unsigned int v5; // ebp
char v6; // al
char *v8; // [rsp+8h] [rbp-30h] BYREF

if ( a3 == 0 || a2 == 0LL || !a1 )
_assert_fail("0 != str && 0 != arr && 0 != size", "/usr/src/repo/source/library/text.c", 0x87u, "ojt_vals");
v3 = a2;
v4 = &a2[a3 - 1];
v5 = 0;
while ( 1 )
{
v6 = func0(a1, &v8);
if ( !v6 )
break;
*v3 = v6;
++v5;
if ( v3 == v4 )
break;
a1 = v8;
++v3;
}
return v5;
}

original_code:
int ojt_vals(char *str, oj_card *arr, int size) {
    int v, i = 0;
    char *next;
    ((0 != str && 0 != arr && 0 != size) ? (void) (0) : __assert_fail ("0 != str && 0 != arr && 0 != size", "/usr/src/repo/source/library/text.c", 135, __extension__ __PRETTY_FUNCTION__));
    while ((v = _parse_card(str, &next))) {
        arr[i] = v;
        if (++i == size) return i;
        str = next;
    }
    return i;
}

canonical_original_code:
int ojt_vals(char *str, char *arr, int size) {
    int v; int i = 0;
    char *next;
    ((0 != str && 0 != arr && 0 != size) ? (void) (0) : __assert_fail ("0 != str && 0 != arr && 0 != size", "/usr/src/repo/source/library/text.c", 135, __extension__ __PRETTY_FUNCTION__));
    while ((v = _parse_card(str, &next))) {
        arr[i] = v;
        if (++i == size) return i;
        str = next;
    }
    return i;
}

variable_types:
arr
char *


original_code:
int ojb_total(oj_cardlist *p) {
    int total = 0, ace = 0, soft = 0;
    ((0x10ACE0FF == p->_johnnymoss) ? (void) (0) : __assert_fail ("0x10ACE0FF == p->_johnnymoss", "/usr/src/repo/source/library/blackjack.c", 19, __extension__ __PRETTY_FUNCTION__));
    for (int i = 0; i < p->length; ++i) {
        int c = p->cards[i];
        if (c >= ((oj_card)((((int)(OJR_ACE) << 2) | (int)(OJS_CLUB)) + 1))) {
            ace = 1;
            total += 1;
        } else if (c >= ((oj_card)((((int)(OJR_TEN) << 2) | (int)(OJS_CLUB)) + 1))) {
            total += 10;
        } else {
            total += ((oj_rank)(((c) - 1) >> 2)) + 2;
        }
    }
    if (ace && total < 12) {
        total += 10;
        soft = 1;
    }
    return soft ? -total : total;
}

canonical_original_code:
int ojb_total(struct _oj_cardlist *p) {
    int total = 0; int ace = 0; int soft = 0;
    ((0x10ACE0FF == p->_johnnymoss) ? (void) (0) : __assert_fail ("0x10ACE0FF == p->_johnnymoss", "/usr/src/repo/source/library/blackjack.c", 19, __extension__ __PRETTY_FUNCTION__));
    for (int i = 0; i < p->length; ++i) {
        int c = p->cards[i];
        if (c >= ((oj_card)((((int)(OJR_ACE) << 2) | (int)(OJS_CLUB)) + 1))) {
            ace = 1;
            total += 1;
        } else if (c >= ((oj_card)((((int)(OJR_TEN) << 2) | (int)(OJS_CLUB)) + 1))) {
            total += 10;
        } else {
            total += ((oj_rank)(((c) - 1) >> 2)) + 2;
        }
    }
    if (ace && total < 12) {
        total += 10;
        soft = 1;
    }
    return soft ? -total : total;
}

variable_types: struct _oj_cardlist { int _johnnymoss; long allocation; long pflags; unsigned long mask; char *cards; void *filler[4]; } *

variable_types: total int

variable_types: ace int

variable_types: soft int

variable_types: c int


decompiled_code:
__int64 oj_init_library()
{
__int64 result; // rax

result = ojr_seed();
if ( !(_DWORD)result )
oj_johnnymoss = 279765247;
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax

result = ojr_seed();
if ( !(_DWORD)result )
oj_johnnymoss = 279765247;
return result;
}

original_code:
int oj_init_library(int seed) {
    int r;
    r = ojr_seed(seed);
    if (r) return r;
    _oj_johnnymoss = 0x10ACE0FF;
    return 0;
}

variable_types: seed int

variable_types: r int


repo: lcrocker/ojrandlib

decompiled_code:
__int64 ojr_structure_size()
{
return 96LL;
}

canonical_decompiled_code:
__int64 func1()
{
return 96LL;
}

original_code: int ojr_structure_size(void) { return sizeof(ojr_generator); }

canonical_original_code: int ojr_structure_size() { return sizeof(ojr_generator); }


decompiled_code:
__int64 __fastcall ojr_get_seeded(_DWORD *a1)
{
if ( *a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x22u, "ojr_get_seeded");
return a1[2] & 1;
}

canonical_decompiled_code:
__int64 __fastcall func2(_DWORD *a1)
{
if ( *a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x22u, "ojr_get_seeded");
return a1[2] & 1;
}

original_code:
int ojr_get_seeded(ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 34, __extension__ __PRETTY_FUNCTION__));
    return 0 != (g->flags & 0x01);
}

canonical_original_code:
int ojr_get_seeded(struct _ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 34, __extension__ __PRETTY_FUNCTION__));
    return 0 != (g->flags & 0x01);
}

variable_types: struct _ojr_generator { int init; int leftover; int flags; int algorithm; int statesize; int bufsize; unsigned int *state; unsigned int *buf; unsigned int *bptr; struct _ojr_generator *next; void *extra; void *padding[4]; } *


decompiled_code:
__int64 __fastcall ojr_get_algorithm(_DWORD *a1)
{
if ( *a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x2Du, "ojr_get_algorithm");
return (unsigned int)a1[3];
}

canonical_decompiled_code:
__int64 __fastcall func4(_DWORD *a1)
{
if ( *a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x2Du, "ojr_get_algorithm");
return (unsigned int)a1[3];
}

original_code:
int ojr_get_algorithm(ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 45, __extension__ __PRETTY_FUNCTION__));
    return g->algorithm;
}

canonical_original_code:
int ojr_get_algorithm(struct _ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 45, __extension__ __PRETTY_FUNCTION__));
    return g->algorithm;
}

user_defined_types: struct _ojr_generator { int init; int leftover; int flags; int algorithm; int statesize; int bufsize; unsigned int *state; unsigned int *buf; unsigned int *bptr; struct _ojr_generator *next; void *extra; void *padding[4]; }


decompiled_code:
__int64 __fastcall ojr_get_statesize(_DWORD *a1)
{
if ( *a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x38u, "ojr_get_statesize");
return (unsigned int)a1[4];
}

canonical_decompiled_code:
__int64 __fastcall func6(_DWORD *a1)
{
if ( *a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x38u, "ojr_get_statesize");
return (unsigned int)a1[4];
}

original_code:
int ojr_get_statesize(ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 56, __extension__ __PRETTY_FUNCTION__));
    return g->statesize;
}

canonical_original_code:
int ojr_get_statesize(struct _ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 56, __extension__ __PRETTY_FUNCTION__));
    return g->statesize;
}


decompiled_code:
__int64 __fastcall ojr_get_state(__int64 a1)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x3Du, "ojr_get_state");
return *(_QWORD *)(a1 + 24);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x3Du, "ojr_get_state");
return *(_QWORD *)(a1 + 24);
}

original_code:
uint32_t *ojr_get_state(ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 61, __extension__ __PRETTY_FUNCTION__));
    return g->state;
}

canonical_original_code:
unsigned int *ojr_get_state(struct _ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 61, __extension__ __PRETTY_FUNCTION__));
    return g->state;
}

return_type: unsigned int *


decompiled_code:
void __fastcall ojr_set_state(__int64 a1, __int64 a2, int a3)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x42u, "ojr_set_state");
if ( !a2 || !a3 )
_assert_fail("0 != state && 0 != size", "/usr/src/repo/source/library/generator.c", 0x43u, "ojr_set_state");
*(_DWORD *)(a1 + 16) = a3;
*(_QWORD *)(a1 + 24) = a2;
}

canonical_decompiled_code:
void __fastcall func8(__int64 a1, __int64 a2, int a3)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x42u, "ojr_set_state");
if ( !a2 || !a3 )
_assert_fail("0 != state && 0 != size", "/usr/src/repo/source/library/generator.c", 0x43u, "ojr_set_state");
*(_DWORD *)(a1 + 16) = a3;
*(_QWORD *)(a1 + 24) = a2;
}

original_code:
void ojr_set_state(ojr_generator *g, uint32_t *state, int size) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 66, __extension__ __PRETTY_FUNCTION__));
    ((0 != state && 0 != size) ? (void) (0) : __assert_fail ("0 != state && 0 != size", "/usr/src/repo/source/library/generator.c", 67, __extension__ __PRETTY_FUNCTION__));
    g->statesize = size;
    g->state = state;
}

canonical_original_code:
void ojr_set_state(struct _ojr_generator *g, unsigned int *state, int size) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 66, __extension__ __PRETTY_FUNCTION__));
    ((0 != state && 0 != size) ? (void) (0) : __assert_fail ("0 != state && 0 != size", "/usr/src/repo/source/library/generator.c", 67, __extension__ __PRETTY_FUNCTION__));
    g->statesize = size;
    g->state = state;
}

variable_types:
state
unsigned int *


decompiled_code:
__int64 __fastcall ojr_get_bufsize(_DWORD *a1)
{
if ( *a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x49u, "ojr_get_bufsize");
return (unsigned int)a1[5];
}

canonical_decompiled_code:
__int64 __fastcall func9(_DWORD *a1)
{
if ( *a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x49u, "ojr_get_bufsize");
return (unsigned int)a1[5];
}

original_code:
int ojr_get_bufsize(ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 73, __extension__ __PRETTY_FUNCTION__));
    return g->bufsize;
}

canonical_original_code:
int ojr_get_bufsize(struct _ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 73, __extension__ __PRETTY_FUNCTION__));
    return g->bufsize;
}


decompiled_code:
__int64 __fastcall ojr_get_buffer(__int64 a1)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x4Eu, "ojr_get_buffer");
return *(_QWORD *)(a1 + 32);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x4Eu, "ojr_get_buffer");
return *(_QWORD *)(a1 + 32);
}

original_code:
uint32_t *ojr_get_buffer(ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 78, __extension__ __PRETTY_FUNCTION__));
    return g->buf;
}

canonical_original_code:
unsigned int *ojr_get_buffer(struct _ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 78, __extension__ __PRETTY_FUNCTION__));
    return g->buf;
}


decompiled_code:
__int64 __fastcall ojr_get_buffer_ptr(__int64 a1)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x53u, "ojr_get_buffer_ptr");
return *(_QWORD *)(a1 + 40);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x53u, "ojr_get_buffer_ptr");
return *(_QWORD *)(a1 + 40);
}

original_code:
uint32_t *ojr_get_buffer_ptr(ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 83, __extension__ __PRETTY_FUNCTION__));
    return g->bptr;
}

canonical_original_code:
unsigned int *ojr_get_buffer_ptr(struct _ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 83, __extension__ __PRETTY_FUNCTION__));
    return g->bptr;
}


decompiled_code:
void __fastcall ojr_set_buffer(__int64 a1, __int64 a2, int a3)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x58u, "ojr_set_buffer");
*(_DWORD *)(a1 + 20) = a3;
*(_QWORD *)(a1 + 40) = a2;
*(_QWORD *)(a1 + 32) = a2;
}

canonical_decompiled_code:
void __fastcall func12(__int64 a1, __int64 a2, int a3)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x58u, "ojr_set_buffer");
*(_DWORD *)(a1 + 20) = a3;
*(_QWORD *)(a1 + 40) = a2;
*(_QWORD *)(a1 + 32) = a2;
}

original_code:
void ojr_set_buffer(ojr_generator *g, uint32_t *buf, int size) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 88, __extension__ __PRETTY_FUNCTION__));
    g->bufsize = size;
    g->buf = g->bptr = buf;
}

canonical_original_code:
void ojr_set_buffer(struct _ojr_generator *g, unsigned int *buf, int size) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 88, __extension__ __PRETTY_FUNCTION__));
    g->bufsize = size;
    g->buf = g->bptr = buf;
}

variable_types:
buf
unsigned int *


decompiled_code:
__int64 __fastcall ojr_set_buffer_ptr(__int64 a1, __int64 a2)
{
__int64 result; // rax

if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x5Eu, "ojr_set_buffer_ptr");
if ( !a2 || (result = (a2 - *(_QWORD *)(a1 + 32)) >> 2, result > *(int *)(a1 + 20)) )
_assert_fail(
"0 != bptr && (bptr - g->buf) <= g->bufsize",
"/usr/src/repo/source/library/generator.c",
0x5Fu,
"ojr_set_buffer_ptr");
*(_QWORD *)(a1 + 40) = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2)
{
__int64 result; // rax

if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x5Eu, "ojr_set_buffer_ptr");
if ( !a2 || (result = (a2 - *(_QWORD *)(a1 + 32)) >> 2, result > *(int *)(a1 + 20)) )
_assert_fail(
"0 != bptr && (bptr - g->buf) <= g->bufsize",
"/usr/src/repo/source/library/generator.c",
0x5Fu,
"ojr_set_buffer_ptr");
*(_QWORD *)(a1 + 40) = a2;
return result;
}

original_code:
void ojr_set_buffer_ptr(ojr_generator *g, uint32_t *bptr) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 94, __extension__ __PRETTY_FUNCTION__));
    ((0 != bptr && (bptr - g->buf) <= g->bufsize) ? (void) (0) : __assert_fail ("0 != bptr && (bptr - g->buf) <= g->bufsize", "/usr/src/repo/source/library/generator.c", 95, __extension__ __PRETTY_FUNCTION__));
    g->bptr = bptr;
}

canonical_original_code:
void ojr_set_buffer_ptr(struct _ojr_generator *g, unsigned int *bptr) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 94, __extension__ __PRETTY_FUNCTION__));
    ((0 != bptr && (bptr - g->buf) <= g->bufsize) ? (void) (0) : __assert_fail ("0 != bptr && (bptr - g->buf) <= g->bufsize", "/usr/src/repo/source/library/generator.c", 95, __extension__ __PRETTY_FUNCTION__));
    g->bptr = bptr;
}

variable_types:
bptr
unsigned int *


decompiled_code:
__int64 __fastcall ojr_get_extra(__int64 a1)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x64u, "ojr_get_extra");
return *(_QWORD *)(a1 + 56);
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x64u, "ojr_get_extra");
return *(_QWORD *)(a1 + 56);
}

original_code:
void *ojr_get_extra(ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 100, __extension__ __PRETTY_FUNCTION__));
    return g->extra;
}

canonical_original_code:
void *ojr_get_extra(struct _ojr_generator *g) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 100, __extension__ __PRETTY_FUNCTION__));
    return g->extra;
}

return_type: void *


decompiled_code:
void __fastcall ojr_set_extra(__int64 a1, __int64 a2)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x69u, "ojr_set_extra");
*(_QWORD *)(a1 + 56) = a2;
}

canonical_decompiled_code:
void __fastcall func15(__int64 a1, __int64 a2)
{
if ( *(_DWORD *)a1 != 1592598101 )
_assert_fail("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 0x69u, "ojr_set_extra");
*(_QWORD *)(a1 + 56) = a2;
}

original_code:
void ojr_set_extra(ojr_generator *g, void *extra) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 105, __extension__ __PRETTY_FUNCTION__));
    g->extra = extra;
}

canonical_original_code:
void ojr_set_extra(struct _ojr_generator *g, void *extra) {
    ((0x5eed1e55 == g->init) ? (void) (0) : __assert_fail ("0x5eed1e55 == g->init", "/usr/src/repo/source/library/generator.c", 105, __extension__ __PRETTY_FUNCTION__));
    g->extra = extra;
}

variable_types:
extra
void *


original_code:
void ojr_default_reseed(ojr_generator *g, uint32_t *seed, int size) {
    int i, j = 0;
    for (i = 0; i < g->statesize; ++i) {
        g->state[i] ^= seed[j];
        if (++j >= size) j = 0;
    }
}

canonical_original_code:
void ojr_default_reseed(struct _ojr_generator *g, unsigned int *seed, int size) {
    int i; int j = 0;
    for (i = 0; i < g->statesize; ++i) {
        g->state[i] ^= seed[j];
        if (++j >= size) j = 0;
    }
}

variable_types:
seed
unsigned int *

variable_types: size int

variable_types: i int

variable_types: j int


decompiled_code:
void __fastcall ojr_call_reseed(__int64 a1, __int64 a2, int a3)
{
int v3; // eax
void (*v4)(void); // rax

v3 = *(_DWORD *)(a1 + 12);
if ( !v3 )
v3 = 1;
v4 = *(void (**)(void))(ojr_algorithms[v3 - 1] + 48LL);
if ( v4 )
v4();
else
ojr_default_reseed(a1, a2, a3);
}

canonical_decompiled_code:
void __fastcall func17(__int64 a1, __int64 a2, int a3)
{
int v3; // eax
void (*v4)(void); // rax

v3 = *(_DWORD *)(a1 + 12);
if ( !v3 )
v3 = 1;
v4 = *(void (**)(void))(ojr_algorithms[v3 - 1] + 48LL);
if ( v4 )
v4();
else
func16(a1, a2, a3);
}

original_code:
void ojr_call_reseed(ojr_generator *g, uint32_t *seed, int size) {
    int id = g->algorithm;
    void (*f)(ojr_generator *, uint32_t *, int);
    if (0 == id) id = 1;
    f = ojr_algorithms[id - 1]->reseed;
    if (f) { (*f)(g, seed, size); }
    else ojr_default_reseed(g, seed, size);
}

canonical_original_code:
void ojr_call_reseed(struct _ojr_generator *g, unsigned int *seed, int size) {
    int id = g->algorithm;
    void (*f)(struct _ojr_generator *, unsigned int *, int);
    if (0 == id) id = 1;
    f = ojr_algorithms[id - 1]->reseed;
    if (f) { (*f)(g, seed, size); }
    else ojr_default_reseed(g, seed, size);
}

variable_types: id int

variable_types: void (*)(struct _ojr_generator { int init; int leftover; int flags; int algorithm; int statesize; int bufsize; unsigned int *state; unsigned int *buf; unsigned int *bptr; struct _ojr_generator *next; void *extra; void *padding[4]; } *, unsigned int *, int)


original_code:
void ojr_default_seed(ojr_generator *g, uint32_t *seed, int size) {
    int i, x, j = 0;
    x = 232497429;
    for (i = 0; i < g->statesize; ++i) {
        x = (69069 * x) + 764385 + seed[j];
        g->state[i] = x;
        if (++j >= size) j = 0;
    }
}

canonical_original_code:
void ojr_default_seed(struct _ojr_generator *g, unsigned int *seed, int size) {
    int i; int x; int j = 0;
    x = 232497429;
    for (i = 0; i < g->statesize; ++i) {
        x = (69069 * x) + 764385 + seed[j];
        g->state[i] = x;
        if (++j >= size) j = 0;
    }
}

variable_types: x int


decompiled_code:
void __fastcall ojr_call_seed(__int64 a1, __int64 a2, int a3)
{
int v3; // eax
void (*v4)(void); // rax

v3 = *(_DWORD *)(a1 + 12);
if ( !v3 )
v3 = 1;
v4 = *(void (**)(void))(ojr_algorithms[v3 - 1] + 40LL);
if ( v4 )
v4();
else
ojr_default_seed(a1, a2, a3);
}

canonical_decompiled_code:
void __fastcall func19(__int64 a1, __int64 a2, int a3)
{
int v3; // eax
void (*v4)(void); // rax

v3 = *(_DWORD *)(a1 + 12);
if ( !v3 )
v3 = 1;
v4 = *(void (**)(void))(ojr_algorithms[v3 - 1] + 40LL);
if ( v4 )
v4();
else
func18(a1, a2, a3);
}

original_code:
void ojr_call_seed(ojr_generator *g, uint32_t *seed, int size) {
    int id = g->algorithm;
    void (*f)(ojr_generator *, uint32_t *, int);
    if (0 == id) id = 1;
    f = ojr_algorithms[id - 1]->seed;
    if (f) { (*f)(g, seed, size); }
    else ojr_default_seed(g, seed, size);
}

canonical_original_code:
void ojr_call_seed(struct _ojr_generator *g, unsigned int *seed, int size) {
    int id = g->algorithm;
    void (*f)(struct _ojr_generator *, unsigned int *, int);
    if (0 == id) id = 1;
    f = ojr_algorithms[id - 1]->seed;
    if (f) { (*f)(g, seed, size); }
    else ojr_default_seed(g, seed, size);
}


original_code:
void ojr_shuffle_int_array(
ojr_generator *g, int *array, int size, int count) {
    int i, r, t;
    if (size < 2) return;
    if (count == size) --count;
    for (i = 0; i < count; ++i) {
        r = ojr_rand(g, size - i);
        do { if ((i) != (i + r)) { t = array[i]; array[i] = array[i + r]; array[i + r] = t; } } while(0);
    }
}

canonical_original_code:
void ojr_shuffle_int_array(struct _ojr_generator *g, int *array, int size, int count) {
    int i; int r; int t;
    if (size < 2) return;
    if (count == size) --count;
    for (i = 0; i < count; ++i) {
        r = ojr_rand(g, size - i);
        do { if ((i) != (i + r)) { t = array[i]; array[i] = array[i + r]; array[i + r] = t; } } while(0);
    }
}

variable_types:
array
int *

variable_types: count int

variable_types: t int


original_code:
void ojr_shuffle_pointer_array(
ojr_generator *g, void **array, int size, int count) {
    int i, r;
    void *t;
    if (size < 2) return;
    if (count == size) --count;
    for (i = 0; i < count; ++i) {
        r = ojr_rand(g, size - i);
        do { if ((i) != (i + r)) { t = array[i]; array[i] = array[i + r]; array[i + r] = t; } } while(0);
    }
}

canonical_original_code:
void ojr_shuffle_pointer_array(struct _ojr_generator *g, void **array, int size, int count) {
    int i; int r;
    void *t;
    if (size < 2) return;
    if (count == size) --count;
    for (i = 0; i < count; ++i) {
        r = ojr_rand(g, size - i);
        do { if ((i) != (i + r)) { t = array[i]; array[i] = array[i + r]; array[i + r] = t; } } while(0);
    }
}

variable_types:
array
void **

variable_types:
t
void *


decompiled_code:
__int64 ojr_library_startup()
{
if ( (_DWORD *)ojr_algorithms != ojr_algorithm_mwc8222 )
_assert_fail(
"&ojr_algorithm_mwc8222 == ojr_algorithms[0]",
"/usr/src/repo/source/library/init.c",
0x1Eu,
"ojr_library_startup");
if ( ojr_algorithm_mwc8222[3] != 1 )
_assert_fail(
"1 == ojr_algorithm_mwc8222.statesize",
"/usr/src/repo/source/library/init.c",
0x1Fu,
"ojr_library_startup");
if ( ojr_algorithm_mwc8222[4] != 256 )
_assert_fail(
"256 == ojr_algorithm_mwc8222.bufsize",
"/usr/src/repo/source/library/init.c",
0x20u,
"ojr_library_startup");
ojr_init(&ojr_default_generator);
ojr_set_algorithm(&ojr_default_generator, 1LL);
ojr_set_state(&ojr_default_generator, &ojr_default_buffer, 1LL);
ojr_set_buffer(&ojr_default_generator, (char *)&ojr_default_buffer + 4, 256LL);
ojr_call_open(&ojr_default_generator);
ojr_system_seed(&ojr_default_generator);
ojr_library_initialized = 1592598101;
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
if ( (_DWORD *)ojr_algorithms != ojr_algorithm_mwc8222 )
_assert_fail(
"&ojr_algorithm_mwc8222 == ojr_algorithms[0]",
"/usr/src/repo/source/library/init.c",
0x1Eu,
"ojr_library_startup");
if ( ojr_algorithm_mwc8222[3] != 1 )
_assert_fail(
"1 == ojr_algorithm_mwc8222.statesize",
"/usr/src/repo/source/library/init.c",
0x1Fu,
"ojr_library_startup");
if ( ojr_algorithm_mwc8222[4] != 256 )
_assert_fail(
"256 == ojr_algorithm_mwc8222.bufsize",
"/usr/src/repo/source/library/init.c",
0x20u,
"ojr_library_startup");
ojr_init(&ojr_default_generator);
ojr_set_algorithm(&ojr_default_generator, 1LL);
ojr_set_state(&ojr_default_generator, &ojr_default_buffer, 1LL);
ojr_set_buffer(&ojr_default_generator, (char *)&ojr_default_buffer + 4, 256LL);
ojr_call_open(&ojr_default_generator);
ojr_system_seed(&ojr_default_generator);
ojr_library_initialized = 1592598101;
return 0LL;
}

original_code:
int ojr_library_startup(void) {
    ((&ojr_algorithm_mwc8222 == ojr_algorithms[0]) ? (void) (0) : __assert_fail ("&ojr_algorithm_mwc8222 == ojr_algorithms[0]", "/usr/src/repo/source/library/init.c", 30, __extension__ __PRETTY_FUNCTION__));
    ((1 == ojr_algorithm_mwc8222.statesize) ? (void) (0) : __assert_fail ("1 == ojr_algorithm_mwc8222.statesize", "/usr/src/repo/source/library/init.c", 31, __extension__ __PRETTY_FUNCTION__));
    ((256 == ojr_algorithm_mwc8222.bufsize) ? (void) (0) : __assert_fail ("256 == ojr_algorithm_mwc8222.bufsize", "/usr/src/repo/source/library/init.c", 32, __extension__ __PRETTY_FUNCTION__));
    ojr_init(&ojr_default_generator);
    ojr_set_algorithm(&ojr_default_generator, 1);
    ojr_set_state(&ojr_default_generator, ojr_default_buffer, 1);
    ojr_set_buffer(&ojr_default_generator, ojr_default_buffer + 1, 256);
    ojr_call_open(&ojr_default_generator);
    ojr_system_seed(&ojr_default_generator);
    _ojr_library_initialized = 0x5eed1e55;
    return 0;
}

canonical_original_code:
int ojr_library_startup() {
    ((&ojr_algorithm_mwc8222 == ojr_algorithms[0]) ? (void) (0) : __assert_fail ("&ojr_algorithm_mwc8222 == ojr_algorithms[0]", "/usr/src/repo/source/library/init.c", 30, __extension__ __PRETTY_FUNCTION__));
    ((1 == ojr_algorithm_mwc8222.statesize) ? (void) (0) : __assert_fail ("1 == ojr_algorithm_mwc8222.statesize", "/usr/src/repo/source/library/init.c", 31, __extension__ __PRETTY_FUNCTION__));
    ((256 == ojr_algorithm_mwc8222.bufsize) ? (void) (0) : __assert_fail ("256 == ojr_algorithm_mwc8222.bufsize", "/usr/src/repo/source/library/init.c", 32, __extension__ __PRETTY_FUNCTION__));
    ojr_init(&ojr_default_generator);
    ojr_set_algorithm(&ojr_default_generator, 1);
    ojr_set_state(&ojr_default_generator, ojr_default_buffer, 1);
    ojr_set_buffer(&ojr_default_generator, ojr_default_buffer + 1, 256);
    ojr_call_open(&ojr_default_generator);
    ojr_system_seed(&ojr_default_generator);
    _ojr_library_initialized = 0x5eed1e55;
    return 0;
}