listSkew

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

result = *(_QWORD *)(a1 + 16);
if ( *(_DWORD *)(a1 + 8) == *(_DWORD *)(result + 8) )
{
*(_QWORD *)(result + 16) = *(_QWORD *)(a1 + 24);
*(_QWORD *)(a1 + 24) = result;
}
return result;
}

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

result = *(_QWORD *)(a1 + 16);
if ( *(_DWORD *)(a1 + 8) == *(_DWORD *)(result + 8) )
{
*(_QWORD *)(result + 16) = *(_QWORD *)(a1 + 24);
*(_QWORD *)(a1 + 24) = result;
}
return result;
}

original_code:
void listSkew(pList list)
{
   pList l = list->left;
   if(list->level == l->level)
   {
       listSwap(list, l);
       l->left = list->right;
       list->right = l;
   }
}

canonical_original_code:
void listSkew(struct tList *list)
{
   struct tList *l = list->left;
   if(list->level == l->level)
   {
       listSwap(list, l);
       l->left = list->right;
       list->right = l;
   }
}


listSplit

repo: john-kolt/efim

decompiled_code:
__int64 __fastcall listSplit(__int64 a1)
{
__int64 v1; // rdx
__int64 result; // rax

v1 = *(_QWORD *)(a1 + 24);
result = *(unsigned int *)(a1 + 8);
if ( (_DWORD)result == *(_DWORD *)(*(_QWORD *)(v1 + 24) + 8LL) )
{
result = (unsigned int)(result + 1);
*(_QWORD *)(v1 + 24) = *(_QWORD *)(a1 + 16);
*(_QWORD *)(a1 + 16) = v1;
*(_DWORD *)(a1 + 8) = result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1)
{
__int64 v1; // rdx
__int64 result; // rax

v1 = *(_QWORD *)(a1 + 24);
result = *(unsigned int *)(a1 + 8);
if ( (_DWORD)result == *(_DWORD *)(*(_QWORD *)(v1 + 24) + 8LL) )
{
result = (unsigned int)(result + 1);
*(_QWORD *)(v1 + 24) = *(_QWORD *)(a1 + 16);
*(_QWORD *)(a1 + 16) = v1;
*(_DWORD *)(a1 + 8) = result;
}
return result;
}

original_code:
void listSplit(pList list)
{
    pList r = list->right;
    if(list->level == r->right->level)
    {
        listSwap(list, r);
        r->right = list->left;
        list->left = r;
        list->level += 1;
    }
}

canonical_original_code:
void listSplit(struct tList *list)
{
    struct tList *r = list->right;
    if(list->level == r->right->level)
    {
        listSwap(list, r);
        r->right = list->left;
        list->left = r;
        list->level += 1;
    }
}

variable_types: struct tList { int uid; int data; int level; struct tList *left; struct tList *right; } *

return_type: void


listAdd

original_code:
int listAdd(pList list, int uid, tListData data)
{
    if(uid < list->uid && list->left == 0)
    {
        pList newItem = listCreate();
        newItem->uid = uid;
        newItem->data = data;
        list->left = newItem;
        list->level += 1;
        return 1;
    }
    if(uid > list->uid && list->right == 0)
    {
        pList newItem = listCreate();
        newItem->uid = uid;
        newItem->data = data;
        list->right = newItem;
        list->level += 1;
        return 1;
    }
    if(list->level!=0)
    {
        int result = 0;
        if(uid < list->uid)
            result = listAdd(list->left, uid, data);
        else if(uid > list->uid)
            result = listAdd(list->right, uid, data);
        else if(uid == list->uid)
            result = 0;
        listSkew(list);
        listSplit(list);
        return result;
    }
}

canonical_original_code:
int listAdd(struct tList *list, int uid, int data)
{
    if(uid < list->uid && list->left == 0)
    {
        struct tList *newItem = listCreate();
        newItem->uid = uid;
        newItem->data = data;
        list->left = newItem;
        list->level += 1;
        return 1;
    }
    if(uid > list->uid && list->right == 0)
    {
        struct tList *newItem = listCreate();
        newItem->uid = uid;
        newItem->data = data;
        list->right = newItem;
        list->level += 1;
        return 1;
    }
    if(list->level!=0)
    {
        int result = 0;
        if(uid < list->uid)
            result = listAdd(list->left, uid, data);
        else if(uid > list->uid)
            result = listAdd(list->right, uid, data);
        else if(uid == list->uid)
            result = 0;
        listSkew(list);
        listSplit(list);
        return result;
    }
}

variable_types: uid int

variable_types: data int

variable_types: result int

return_type: int

user_defined_types: struct tList { int uid; int data; int level; struct tList *left; struct tList *right; }


listDel

original_code:
void listDel(pList list, int uid)
{
    pList deleted = 0;
    pList last = 0;
    if(list->level!=0)
    {
        last = list;
        if(uid < list->uid)
            listDel(list->left, uid);
        else
        {
            deleted = list;
            listDel(list->right, uid);
        }
    }
    if(list == last && deleted != 0 && uid == deleted->uid)
    {
        deleted->uid = list->uid;
        deleted = 0;
        list = list->right;
        free(last);
    }
    else if (list->left->level < list->level-1 || list->right->level < list->level-1)
    {
        list->level -= 1;
        if(list->right->level > list->level)
            list->right->level = list->level;
        listSkew(list);
        listSkew(list->right);
        listSkew(list->right->right);
        listSplit(list);
        listSplit(list->right);
    }
}

canonical_original_code:
void listDel(struct tList *list, int uid)
{
    struct tList *deleted = 0;
    struct tList *last = 0;
    if(list->level!=0)
    {
        last = list;
        if(uid < list->uid)
            listDel(list->left, uid);
        else
        {
            deleted = list;
            listDel(list->right, uid);
        }
    }
    if(list == last && deleted != 0 && uid == deleted->uid)
    {
        deleted->uid = list->uid;
        deleted = 0;
        list = list->right;
        free(last);
    }
    else if (list->left->level < list->level-1 || list->right->level < list->level-1)
    {
        list->level -= 1;
        if(list->right->level > list->level)
            list->right->level = list->level;
        listSkew(list);
        listSkew(list->right);
        listSkew(list->right->right);
        listSplit(list);
        listSplit(list->right);
    }
}


listSearch

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

while ( 1 )
{
while ( 1 )
{
if ( !*(_DWORD *)(a1 + 8) )
return 0LL;
if ( *(_DWORD *)a1 <= a2 )
break;
a1 = *(_QWORD *)(a1 + 16);
}
if ( *(_DWORD *)a1 >= a2 )
break;
a1 = *(_QWORD *)(a1 + 24);
}
result = 0LL;
if ( *(_DWORD *)a1 == a2 )
result = a1;
return result;
}

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

while ( 1 )
{
while ( 1 )
{
if ( !*(_DWORD *)(a1 + 8) )
return 0LL;
if ( *(_DWORD *)a1 <= a2 )
break;
a1 = *(_QWORD *)(a1 + 16);
}
if ( *(_DWORD *)a1 >= a2 )
break;
a1 = *(_QWORD *)(a1 + 24);
}
result = 0LL;
if ( *(_DWORD *)a1 == a2 )
result = a1;
return result;
}

original_code:
pList listSearch(pList list, int uid)
{
    if(list->level==0)
        return 0;
    else
    {
        pList result = 0;
        if(uid < list->uid)
            result = listSearch(list->left, uid);
        else if(uid > list->uid)
            result = listSearch(list->right, uid);
        else if(uid == list->uid)
            result = list;
        return result;
    }
}

canonical_original_code:
struct tList *listSearch(struct tList *list, int uid)
{
    if(list->level==0)
        return 0;
    else
    {
        struct tList *result = 0;
        if(uid < list->uid)
            result = listSearch(list->left, uid);
        else if(uid > list->uid)
            result = listSearch(list->right, uid);
        else if(uid == list->uid)
            result = list;
        return result;
    }
}

variable_types:
list
struct tList *

return_type: struct tList { int uid; int data; int level; struct tList *left; struct tList *right; } *


listPrint

decompiled_code:
int __fastcall listPrint(int *a1)
{
__int64 v2; // rdi
__int64 v3; // rdi

fprintf((FILE *)&unk_402004, (const char *)*a1);
v2 = *((_QWORD *)a1 + 2);
if ( v2 )
listPrint(v2);
v3 = *((_QWORD *)a1 + 3);
if ( v3 )
listPrint(v3);
return puts(&byte_402007);
}

canonical_decompiled_code:
int __fastcall func19(int *a1)
{
__int64 v2; // rdi
__int64 v3; // rdi

fprintf((FILE *)&unk_402004, (const char *)*a1);
v2 = *((_QWORD *)a1 + 2);
if ( v2 )
func19(v2);
v3 = *((_QWORD *)a1 + 3);
if ( v3 )
func19(v3);
return puts(&byte_402007);
}

original_code:
void listPrint(pList list)
{
    fprintf("%d ", list->uid);
    if(list->left!=0)
        listPrint(list->left);
    if(list->right!=0)
        listPrint(list->right);
    puts("");
}

canonical_original_code:
void listPrint(struct tList *list)
{
    fprintf("%d ", list->uid);
    if(list->left!=0)
        listPrint(list->left);
    if(list->right!=0)
        listPrint(list->right);
    puts("");
}


decompiled_code:
__int64 init_maestro()
{
unsigned int v0; // er12
int v2; // [rsp+0h] [rbp-58h] BYREF
int buf; // [rsp+4h] [rbp-54h] BYREF
int v4; // [rsp+8h] [rbp-50h] BYREF
int v5; // [rsp+Ch] [rbp-4Ch] BYREF
struct termios termios_p; // [rsp+10h] [rbp-48h] BYREF

v0 = open("/dev/ttyACM0", 258);
tcgetattr(v0, &termios_p);
termios_p.c_lflag &= 0xFFFF7FB4;
termios_p.c_oflag &= 0xFFFFFFF3;
tcsetattr(v0, 0, &termios_p);
v2 = 135;
if ( write(v0, &v2, 4uLL) == -1
|| (buf = 391, write(v0, &buf, 4uLL) == -1)
|| (v4 = 137, write(v0, &v4, 4uLL) == -1)
|| (v5 = 393, write(v0, &v5, 4uLL) == -1) )
{
v0 = -1;
perror("error writing");
}
return v0;
}

canonical_decompiled_code:
__int64 func0()
{
unsigned int v0; // er12
int v2; // [rsp+0h] [rbp-58h] BYREF
int buf; // [rsp+4h] [rbp-54h] BYREF
int v4; // [rsp+8h] [rbp-50h] BYREF
int v5; // [rsp+Ch] [rbp-4Ch] BYREF
struct termios termios_p; // [rsp+10h] [rbp-48h] BYREF

v0 = open("/dev/ttyACM0", 258);
tcgetattr(v0, &termios_p);
termios_p.c_lflag &= 0xFFFF7FB4;
termios_p.c_oflag &= 0xFFFFFFF3;
tcsetattr(v0, 0, &termios_p);
v2 = 135;
if ( write(v0, &v2, 4uLL) == -1
|| (buf = 391, write(v0, &buf, 4uLL) == -1)
|| (v4 = 137, write(v0, &v4, 4uLL) == -1)
|| (v5 = 393, write(v0, &v5, 4uLL) == -1) )
{
v0 = -1;
perror("error writing");
}
return v0;
}

original_code:
int init_maestro()
{
 const char * device = "/dev/ttyACM0";
 int fd = open(device, 02 | 0400);
 struct termios options;
 tcgetattr(fd, &options);
 options.c_lflag &= ~(0000010 | 0000100 | 0000002 | 0000001 | 0100000);
 options.c_oflag &= ~(0000004 | 0000010);
 tcsetattr(fd, 0, &options);
 unsigned char command[] = {0x87, 0, 0 & 0x7F, 0 >> 7 & 0x7F};
 if (write(fd, command, sizeof(command)) == -1)
 {
  perror("error writing");
  return -1;
 }
 unsigned char command2[] = {0x87, 1, 0 & 0x7F, 0 >> 7 & 0x7F};
 if (write(fd, command2, sizeof(command)) == -1)
 {
  perror("error writing");
  return -1;
 }
 unsigned char command3[] = {0x89, 0, 0 & 0x7F, 0 >> 7 & 0x7F};
 if (write(fd, command3, sizeof(command)) == -1)
 {
  perror("error writing");
  return -1;
 }
 unsigned char command4[] = {0x89, 1, 0 & 0x7F, 0 >> 7 & 0x7F};
 if (write(fd, command4, sizeof(command)) == -1)
 {
  perror("error writing");
  return -1;
 }
 return fd;
}

canonical_original_code:
int init_maestro()
{
 char *device = "/dev/ttyACM0";
 int fd = open(device, 02 | 0400);
 struct termios options;
 tcgetattr(fd, &options);
 options.c_lflag &= ~(0000010 | 0000100 | 0000002 | 0000001 | 0100000);
 options.c_oflag &= ~(0000004 | 0000010);
 tcsetattr(fd, 0, &options);
 unsigned char command[] = {0x87, 0, 0 & 0x7F, 0 >> 7 & 0x7F};
 if (write(fd, command, sizeof(command)) == -1)
 {
  perror("error writing");
  return -1;
 }
 unsigned char command2[] = {0x87, 1, 0 & 0x7F, 0 >> 7 & 0x7F};
 if (write(fd, command2, sizeof(command)) == -1)
 {
  perror("error writing");
  return -1;
 }
 unsigned char command3[] = {0x89, 0, 0 & 0x7F, 0 >> 7 & 0x7F};
 if (write(fd, command3, sizeof(command)) == -1)
 {
  perror("error writing");
  return -1;
 }
 unsigned char command4[] = {0x89, 1, 0 & 0x7F, 0 >> 7 & 0x7F};
 if (write(fd, command4, sizeof(command)) == -1)
 {
  perror("error writing");
  return -1;
 }
 return fd;
}

variable_types:
device
char *

variable_types: fd int

variable_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; }

variable_types:
command
unsigned char []


maestroSetTarget

decompiled_code:
__int64 __fastcall maestroSetTarget(int a1, char a2, unsigned __int16 a3)
{
char buf[12]; // [rsp+Ch] [rbp-Ch] BYREF

buf[1] = a2;
buf[3] = (a3 >> 7) & 0x7F;
buf[0] = -124;
buf[2] = a3 & 0x7F;
if ( write(a1, buf, 4uLL) != -1 )
return 0LL;
perror("error writing");
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, char a2, unsigned __int16 a3)
{
char buf[12]; // [rsp+Ch] [rbp-Ch] BYREF

buf[1] = a2;
buf[3] = (a3 >> 7) & 0x7F;
buf[0] = -124;
buf[2] = a3 & 0x7F;
if ( write(a1, buf, 4uLL) != -1 )
return 0LL;
perror("error writing");
return 0xFFFFFFFFLL;
}

original_code:
int maestroSetTarget(int fd, unsigned char channel, unsigned short target)
{
  unsigned char command[] = {0x84, channel, target & 0x7F, target >> 7 & 0x7F};
  if (write(fd, command, sizeof(command)) == -1)
  {
    perror("error writing");
    return -1;
  }
  return 0;
}

variable_types:
channel
unsigned char

variable_types:
target
unsigned short


maestroGetPosition

decompiled_code:
__int64 __fastcall maestroGetPosition(int fd, char a2)
{
__int64 result; // rax
char buf[2]; // [rsp+Ch] [rbp-Ch] BYREF
char v4[10]; // [rsp+Eh] [rbp-Ah] BYREF

buf[1] = a2;
buf[0] = -112;
if ( write(fd, buf, 2uLL) == -1 )
{
perror("error writing");
result = 0xFFFFFFFFLL;
}
else if ( read(fd, v4, 2uLL) == 2 )
{
result = (unsigned __int8)v4[0] + ((unsigned __int8)v4[1] << 8);
}
else
{
perror("error reading");
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int fd, char a2)
{
__int64 result; // rax
char buf[2]; // [rsp+Ch] [rbp-Ch] BYREF
char v4[10]; // [rsp+Eh] [rbp-Ah] BYREF

buf[1] = a2;
buf[0] = -112;
if ( write(fd, buf, 2uLL) == -1 )
{
perror("error writing");
result = 0xFFFFFFFFLL;
}
else if ( read(fd, v4, 2uLL) == 2 )
{
result = (unsigned __int8)v4[0] + ((unsigned __int8)v4[1] << 8);
}
else
{
perror("error reading");
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int maestroGetPosition(int fd, unsigned char channel)
{
  unsigned char command[] = {0x90, channel};
  if(write(fd, command, sizeof(command)) == -1)
  {
    perror("error writing");
    return -1;
  }
  unsigned char response[2];
  if(read(fd,response,2) != 2)
  {
    perror("error reading");
    return -1;
  }
  return response[0] + 256*response[1];
}

variable_types:
response
unsigned char [2]


decompiled_code:
// attributes: thunk
int close_maestro(int fd)
{
return close(fd);
}

canonical_decompiled_code:
int func3(int fd)
{
return close(fd);
}

original_code:
void close_maestro(int fd)
{
 close(fd);
}


maestroSetSpeed

decompiled_code:
void __fastcall maestroSetSpeed(int fd, int a2)
{
__int16 buf; // [rsp+8h] [rbp-20h] BYREF
char v3; // [rsp+Ah] [rbp-1Eh]
char v4; // [rsp+Bh] [rbp-1Dh]
__int16 v5; // [rsp+Ch] [rbp-1Ch] BYREF
char v6; // [rsp+Eh] [rbp-1Ah]
char v7; // [rsp+Fh] [rbp-19h]

buf = 135;
v3 = a2 & 0x7F;
v4 = (a2 >> 7) & 0x7F;
if ( write(fd, &buf, 4uLL) == -1 || (v7 = (a2 >> 7) & 0x7F, v5 = 391, v6 = a2 & 0x7F, write(fd, &v5, 4uLL) == -1) )
perror("error writing");
}

canonical_decompiled_code:
void __fastcall func4(int fd, int a2)
{
__int16 buf; // [rsp+8h] [rbp-20h] BYREF
char v3; // [rsp+Ah] [rbp-1Eh]
char v4; // [rsp+Bh] [rbp-1Dh]
__int16 v5; // [rsp+Ch] [rbp-1Ch] BYREF
char v6; // [rsp+Eh] [rbp-1Ah]
char v7; // [rsp+Fh] [rbp-19h]

buf = 135;
v3 = a2 & 0x7F;
v4 = (a2 >> 7) & 0x7F;
if ( write(fd, &buf, 4uLL) == -1 || (v7 = (a2 >> 7) & 0x7F, v5 = 391, v6 = a2 & 0x7F, write(fd, &v5, 4uLL) == -1) )
perror("error writing");
}

original_code:
void maestroSetSpeed(int fd, int speed)
{
 unsigned char command[] = {0x87, 0, speed & 0x7F, speed >> 7 & 0x7F};
 if (write(fd, command, sizeof(command)) == -1)
 {
  perror("error writing");
  return;
 }
 unsigned char command2[] = {0x87, 1, speed & 0x7F, speed >> 7 & 0x7F};
 if (write(fd, command2, sizeof(command)) == -1)
 {
  perror("error writing");
  return;
 }
}

variable_types: speed int


main

canonical_name: main

repo: johncausey/game

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
setup_sdl(argc, argv, envp);
setup_opengl();
main_loop();
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
func7(argc, argv, envp);
func8();
func10();
}

original_code:
int main(int argc, char ** argv) {
 setup_sdl();
 setup_opengl();
 main_loop();
 return 0;
}

canonical_original_code:
int main(int argc, char **argv) {
 setup_sdl();
 setup_opengl();
 main_loop();
 return 0;
}

variable_types: argc int

variable_types:
argv
char **


decompiled_code:
__int64 setup_sdl()
{
__int64 result; // rax
__int64 v1; // rdx
__int64 v2; // rdx
__int64 v3; // rdx

if ( (int)SDL_Init() < 0 )
{
v1 = SDL_GetError();
fprintf(_bss_start, "Couldn't initialise SDL: %s\n", v1);
goto LABEL_6;
}
atexit(SDL_Quit);
if ( !SDL_GetVideoInfo() )
{
v3 = SDL_GetError();
fprintf(_bss_start, "Couldn't get video information %s\n", v3);
LABEL_6:
exit(1);
}
SDL_GL_SetAttribute();
SDL_GL_SetAttribute();
SDL_GL_SetAttribute();
SDL_GL_SetAttribute();
SDL_GL_SetAttribute();
SDL_WM_SetCaption();
SDL_EnableKeyRepeat();
result = SDL_SetVideoMode();
if ( !result )
{
v2 = SDL_GetError();
fprintf(_bss_start, "Couldn't set video mode: %s\n", v2);
goto LABEL_6;
}
return result;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 result; // rax
__int64 v1; // rdx
__int64 v2; // rdx
__int64 v3; // rdx

if ( (int)SDL_Init() < 0 )
{
v1 = SDL_GetError();
fprintf(_bss_start, "Couldn't initialise SDL: %s\n", v1);
goto LABEL_6;
}
func13(SDL_Quit);
if ( !SDL_GetVideoInfo() )
{
v3 = SDL_GetError();
fprintf(_bss_start, "Couldn't get video information %s\n", v3);
LABEL_6:
exit(1);
}
SDL_GL_SetAttribute();
SDL_GL_SetAttribute();
SDL_GL_SetAttribute();
SDL_GL_SetAttribute();
SDL_GL_SetAttribute();
SDL_WM_SetCaption();
SDL_EnableKeyRepeat();
result = SDL_SetVideoMode();
if ( !result )
{
v2 = SDL_GetError();
fprintf(_bss_start, "Couldn't set video mode: %s\n", v2);
goto LABEL_6;
}
return result;
}

original_code:
static void setup_sdl() {
 const SDL_VideoInfo* video;
 if ( SDL_Init(0x00000020) < 0 ) {
  fprintf(stderr, "Couldn't initialise SDL: %s\n", SDL_GetError());
  exit(1);
 }
 atexit(SDL_Quit);
 video = SDL_GetVideoInfo();
 if (video == ((void *)0)) {
  fprintf(stderr, "Couldn't get video information %s\n", SDL_GetError());
  exit(1);
 }
 SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5);
 SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5);
 SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5);
 SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16);
 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1);
 SDL_WM_SetCaption( "Totally Bananas?", ((void *)0) );
 SDL_EnableKeyRepeat(70, 70);
 if (SDL_SetVideoMode(1920, 1080, 32, 0x00000002 | 0x80000000) == 0) {
  fprintf(stderr, "Couldn't set video mode: %s\n", SDL_GetError());
  exit(1);
 }
}

canonical_original_code:
static void setup_sdl() {
 struct SDL_VideoInfo *video;
 if ( SDL_Init(0x00000020) < 0 ) {
  fprintf(stderr, "Couldn't initialise SDL: %s\n", SDL_GetError());
  exit(1);
 }
 atexit(SDL_Quit);
 video = SDL_GetVideoInfo();
 if (video == ((void *)0)) {
  fprintf(stderr, "Couldn't get video information %s\n", SDL_GetError());
  exit(1);
 }
 SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5);
 SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5);
 SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5);
 SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16);
 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1);
 SDL_WM_SetCaption( "Totally Bananas?", ((void *)0) );
 SDL_EnableKeyRepeat(70, 70);
 if (SDL_SetVideoMode(1920, 1080, 32, 0x00000002 | 0x80000000) == 0) {
  fprintf(stderr, "Couldn't set video mode: %s\n", SDL_GetError());
  exit(1);
 }
}

variable_types: struct SDL_VideoInfo { unsigned int hw_available; unsigned int wm_available; unsigned int UnusedBits1; unsigned int UnusedBits2; unsigned int blit_hw; unsigned int blit_hw_CC; unsigned int blit_hw_A; unsigned int blit_sw; unsigned int blit_sw_CC; unsigned int blit_sw_A; unsigned int blit_fill; unsigned int UnusedBits3; unsigned int video_mem; struct SDL_PixelFormat { struct SDL_Palette { int ncolors; struct SDL_Color { unsigned char r; unsigned char g; unsigned char b; unsigned char unused; } *colors; } *palette; unsigned char BitsPerPixel; unsigned char BytesPerPixel; unsigned char Rloss; unsigned char Gloss; unsigned char Bloss; unsigned char Aloss; unsigned char Rshift; unsigned char Gshift; unsigned char Bshift; unsigned char Ashift; unsigned int Rmask; unsigned int Gmask; unsigned int Bmask; unsigned int Amask; unsigned int colorkey; unsigned char alpha; } *vfmt; int current_w; int current_h; } *

user_defined_types: struct SDL_VideoInfo { unsigned int hw_available; unsigned int wm_available; unsigned int UnusedBits1; unsigned int UnusedBits2; unsigned int blit_hw; unsigned int blit_hw_CC; unsigned int blit_hw_A; unsigned int blit_sw; unsigned int blit_sw_CC; unsigned int blit_sw_A; unsigned int blit_fill; unsigned int UnusedBits3; unsigned int video_mem; struct SDL_PixelFormat *vfmt; int current_w; int current_h; }

user_defined_types: struct SDL_PixelFormat { struct SDL_Palette *palette; unsigned char BitsPerPixel; unsigned char BytesPerPixel; unsigned char Rloss; unsigned char Gloss; unsigned char Bloss; unsigned char Aloss; unsigned char Rshift; unsigned char Gshift; unsigned char Bshift; unsigned char Ashift; unsigned int Rmask; unsigned int Gmask; unsigned int Bmask; unsigned int Amask; unsigned int colorkey; unsigned char alpha; }

user_defined_types: struct SDL_Palette { int ncolors; struct SDL_Color *colors; }


decompiled_code:
__int64 setup_opengl()
{
glViewport();
glMatrixMode();
glClearColor();
return glDisable();
}

canonical_decompiled_code:
__int64 func8()
{
glViewport();
glMatrixMode();
glClearColor();
return glDisable();
}

original_code:
static void setup_opengl() {
 float aspect = (float)1920 / (float)1080;
 glViewport(0, 0, 1920, 1080);
 glMatrixMode(0x1701);
 glClearColor(0.5, 0.5, 0.5, 0);
 glDisable(0x0B71);
}

variable_types: aspect float


repaint

decompiled_code:
__int64 repaint()
{
glClear();
glLoadIdentity();
glEnd();
return SDL_GL_SwapBuffers();
}

canonical_decompiled_code:
__int64 func9()
{
glClear();
glLoadIdentity();
glEnd();
return SDL_GL_SwapBuffers();
}

original_code:
static void repaint() {
 glClear(0x00004000 | 0x00000100);
 glLoadIdentity();
 glEnd();
 SDL_GL_SwapBuffers();
}


urand

repo: johncheetham/gse

original_code:
unsigned int
urand(void)
{
    next *= 1103515245;
    next += 12345;
    return ((unsigned int) (next >> 16) & 0xFFFF);
}

canonical_original_code:
unsigned int urand()
{
    next *= 1103515245;
    next += 12345;
    return ((unsigned int) (next >> 16) & 0xFFFF);
}

return_type: unsigned int


gsrand

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

result = a1;
next = a1;
return result;
}

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

result = a1;
next = a1;
return result;
}

original_code:
void
gsrand(unsigned int seed)
{
    next = seed;
}

variable_types:
seed
unsigned int


TimeCalc

decompiled_code:
void TimeCalc()
{
int v0; // er11
int v1; // er8
__int64 v2; // rsi
__int64 v3; // r9
__int64 v4; // rcx
__int16 v5; // r9
int v6; // eax
bool v7; // cl
__int16 v8; // r11

if ( GameCnt <= 7 )
return;
v0 = (timeopp[3] + timeopp[2] + timeopp[1] + timeopp[0]) / 400;
v1 = (timecomp[3] + timecomp[2] + timecomp[1] + timecomp[0]) / 400;
v2 = *((_QWORD *)&TimeControl + computer + 1) / 100LL;
v3 = *((_QWORD *)&TimeControl + opponent + 1);
v4 = v3 / 100;
v5 = *((_WORD *)&TimeControl + computer);
if ( (int)v2 < (int)v4 )
{
v6 = 3;
if ( (int)v4 - (int)v2 <= 60 )
v6 = ((int)v2 < 120) + 2;
if ( v0 >= v1 )
{
if ( TCadd )
{
LABEL_7:
v7 = v6 > 0;
goto LABEL_8;
}
LABEL_18:
LOWORD(v6) = v6 + 2;
goto LABEL_19;
}
LOWORD(v6) = v6 + 2;
LABEL_17:
v7 = 1;
if ( TCadd )
goto LABEL_8;
goto LABEL_18;
}
if ( v0 < v1 )
{
LOWORD(v6) = 2;
goto LABEL_17;
}
if ( v5 > 14 )
{
if ( (int)v2 > (int)v4 && v0 > v1 )
{
*((_WORD *)&TimeControl + computer) = v5 - 1;
return;
}
v8 = 0;
v6 = 0;
if ( !TCadd )
{
LABEL_10:
*((_WORD *)&TimeControl + computer) = v8 + v5;
return;
}
goto LABEL_7;
}
if ( !TCadd )
{
LOWORD(v6) = 3;
LABEL_19:
v7 = 1;
goto LABEL_8;
}
v7 = 1;
LOWORD(v6) = 1;
LABEL_8:
if ( !(_DWORD)v2 )
{
v8 = v6 + 2;
if ( v7 )
goto LABEL_10;
}
*((_WORD *)&TimeControl + computer) = v6 + v5;
}

canonical_decompiled_code:
void func2()
{
int v0; // er11
int v1; // er8
__int64 v2; // rsi
__int64 v3; // r9
__int64 v4; // rcx
__int16 v5; // r9
int v6; // eax
bool v7; // cl
__int16 v8; // r11

if ( GameCnt <= 7 )
return;
v0 = (timeopp[3] + timeopp[2] + timeopp[1] + timeopp[0]) / 400;
v1 = (timecomp[3] + timecomp[2] + timecomp[1] + timecomp[0]) / 400;
v2 = *((_QWORD *)&TimeControl + computer + 1) / 100LL;
v3 = *((_QWORD *)&TimeControl + opponent + 1);
v4 = v3 / 100;
v5 = *((_WORD *)&TimeControl + computer);
if ( (int)v2 < (int)v4 )
{
v6 = 3;
if ( (int)v4 - (int)v2 <= 60 )
v6 = ((int)v2 < 120) + 2;
if ( v0 >= v1 )
{
if ( TCadd )
{
LABEL_7:
v7 = v6 > 0;
goto LABEL_8;
}
LABEL_18:
LOWORD(v6) = v6 + 2;
goto LABEL_19;
}
LOWORD(v6) = v6 + 2;
LABEL_17:
v7 = 1;
if ( TCadd )
goto LABEL_8;
goto LABEL_18;
}
if ( v0 < v1 )
{
LOWORD(v6) = 2;
goto LABEL_17;
}
if ( v5 > 14 )
{
if ( (int)v2 > (int)v4 && v0 > v1 )
{
*((_WORD *)&TimeControl + computer) = v5 - 1;
return;
}
v8 = 0;
v6 = 0;
if ( !TCadd )
{
LABEL_10:
*((_WORD *)&TimeControl + computer) = v8 + v5;
return;
}
goto LABEL_7;
}
if ( !TCadd )
{
LOWORD(v6) = 3;
LABEL_19:
v7 = 1;
goto LABEL_8;
}
v7 = 1;
LOWORD(v6) = 1;
LABEL_8:
if ( !(_DWORD)v2 )
{
v8 = v6 + 2;
if ( v7 )
goto LABEL_10;
}
*((_WORD *)&TimeControl + computer) = v6 + v5;
}

original_code:
void
TimeCalc()
{
    int increment = 0;
    int topsum = 0;
    int tcompsum = 0;
    int me, him;
    int i;
    if (GameCnt < (4 * 2))
        return;
    for (i = 0; i < 4; i++)
    {
        tcompsum += timecomp[i];
        topsum += timeopp[i];
    }
    topsum /= (100 * 4);
    tcompsum /= (100 * 4);
    me = TimeControl.clock[computer] / 100;
    him = TimeControl.clock[opponent] / 100;
    if (me < him)
        increment += 2;
    if (((him - me) > 60) || ((me < him) && (me < 120)))
        increment++;
    if (tcompsum > topsum)
    {
        increment += 2;
    }
    else if ((TimeControl.moves[computer] < 15) && !increment)
    {
        increment++;
    }
    else if ((me > him) && (tcompsum < topsum))
    {
        increment = -1;
    }
    if ((TCadd == 0) && (increment > 0))
        increment += 2;
    if ((me == 0) && (increment > 0))
        increment += 2;
    TimeControl.moves[computer] += increment;
}

canonical_original_code:
void TimeCalc()
{
    int increment = 0;
    int topsum = 0;
    int tcompsum = 0;
    int me; int him;
    int i;
    if (GameCnt < (4 * 2))
        return;
    for (i = 0; i < 4; i++)
    {
        tcompsum += timecomp[i];
        topsum += timeopp[i];
    }
    topsum /= (100 * 4);
    tcompsum /= (100 * 4);
    me = TimeControl.clock[computer] / 100;
    him = TimeControl.clock[opponent] / 100;
    if (me < him)
        increment += 2;
    if (((him - me) > 60) || ((me < him) && (me < 120)))
        increment++;
    if (tcompsum > topsum)
    {
        increment += 2;
    }
    else if ((TimeControl.moves[computer] < 15) && !increment)
    {
        increment++;
    }
    else if ((me > him) && (tcompsum < topsum))
    {
        increment = -1;
    }
    if ((TCadd == 0) && (increment > 0))
        increment += 2;
    if ((me == 0) && (increment > 0))
        increment += 2;
    TimeControl.moves[computer] += increment;
}

variable_types: increment int

variable_types: topsum int

variable_types: tcompsum int

variable_types: me int

variable_types: him int

variable_types: i int


SetResponseTime

decompiled_code:
void __fastcall SetResponseTime(__int16 a1)
{
__int64 v2; // rdx
__int64 v3; // rcx
__int64 v4; // rcx
__int16 v5; // r11
_BOOL4 v6; // er9
__int64 v7; // rax
int v8; // esi
int v9; // er10
__int64 v10; // r9
int v11; // er11
int v12; // edi
__int64 v13; // rcx
int v14; // kr00_4
__int64 v15; // rsi
__int64 v16; // rax

if ( TCflag )
{
TCcount = 0;
v2 = a1;
if ( *((__int16 *)&TimeControl + a1) <= 0 )
*((_WORD *)&TimeControl + a1) = 1;
v3 = *((_QWORD *)&TimeControl + a1 + 1);
if ( flag[20] )
{
v4 = v3 - 100;
v5 = hard_time_limit;
TCleft = 0LL;
v6 = 1;
ResponseTime = v4;
if ( v4 > 99 )
goto LABEL_6;
}
else
{
if ( v3 <= 0 )
{
TCleft = 10LL;
ResponseTime = 100LL;
return;
}
if ( flag[22] )
{
v10 = 4LL;
v9 = 2;
}
else
{
v9 = 8;
if ( stage > 32 )
v9 = 2;
v10 = 2LL * (stage > 32) + 2;
}
v11 = TCadd;
v12 = *((__int16 *)&TimeControl + a1);
v13 = TCadd + v3;
*((_QWORD *)&TimeControl + v2 + 1) = v13;
v14 = v11;
v5 = hard_time_limit;
v15 = v13 / (v9 * v12 + 1);
v16 = v15 / v10;
v4 = v15 + v14 / 2;
ResponseTime = v4;
v6 = (__int16)v12 > 4;
TCleft = v16;
if ( v4 > 99 )
{
LABEL_6:
if ( !v5 && v4 <= 199 || !v6 )
return;
goto LABEL_8;
}
}
ResponseTime = 100LL;
return;
}
TCleft = 0LL;
ResponseTime = MaxResponseTime;
ElapsedTime(1LL);
v4 = ResponseTime;
LABEL_8:
if ( TCleft && (v7 = (int)(*((_QWORD *)&TimeControl + a1 + 1) - v4) / 2 / (__int64)TCleft, v7 > 0) )
{
v8 = 0;
if ( v7 <= 10 )
v8 = 10 - v7;
TCcount = v8;
}
else
{
TCcount = 10;
}
if ( v4 <= 99 )
{
ResponseTime = 100LL;
if ( TCcount > 10 )
_assert_fail("TCcount <= MAXTCCOUNTX", "tcontrl.c", 0x142u, "SetResponseTime");
}
}

canonical_decompiled_code:
void __fastcall func3(__int16 a1)
{
__int64 v2; // rdx
__int64 v3; // rcx
__int64 v4; // rcx
__int16 v5; // r11
_BOOL4 v6; // er9
__int64 v7; // rax
int v8; // esi
int v9; // er10
__int64 v10; // r9
int v11; // er11
int v12; // edi
__int64 v13; // rcx
int v14; // kr00_4
__int64 v15; // rsi
__int64 v16; // rax

if ( TCflag )
{
TCcount = 0;
v2 = a1;
if ( *((__int16 *)&TimeControl + a1) <= 0 )
*((_WORD *)&TimeControl + a1) = 1;
v3 = *((_QWORD *)&TimeControl + a1 + 1);
if ( flag[20] )
{
v4 = v3 - 100;
v5 = hard_time_limit;
TCleft = 0LL;
v6 = 1;
ResponseTime = v4;
if ( v4 > 99 )
goto LABEL_6;
}
else
{
if ( v3 <= 0 )
{
TCleft = 10LL;
ResponseTime = 100LL;
return;
}
if ( flag[22] )
{
v10 = 4LL;
v9 = 2;
}
else
{
v9 = 8;
if ( stage > 32 )
v9 = 2;
v10 = 2LL * (stage > 32) + 2;
}
v11 = TCadd;
v12 = *((__int16 *)&TimeControl + a1);
v13 = TCadd + v3;
*((_QWORD *)&TimeControl + v2 + 1) = v13;
v14 = v11;
v5 = hard_time_limit;
v15 = v13 / (v9 * v12 + 1);
v16 = v15 / v10;
v4 = v15 + v14 / 2;
ResponseTime = v4;
v6 = (__int16)v12 > 4;
TCleft = v16;
if ( v4 > 99 )
{
LABEL_6:
if ( !v5 && v4 <= 199 || !v6 )
return;
goto LABEL_8;
}
}
ResponseTime = 100LL;
return;
}
TCleft = 0LL;
ResponseTime = MaxResponseTime;
ElapsedTime(1LL);
v4 = ResponseTime;
LABEL_8:
if ( TCleft && (v7 = (int)(*((_QWORD *)&TimeControl + a1 + 1) - v4) / 2 / (__int64)TCleft, v7 > 0) )
{
v8 = 0;
if ( v7 <= 10 )
v8 = 10 - v7;
TCcount = v8;
}
else
{
TCcount = 10;
}
if ( v4 <= 99 )
{
ResponseTime = 100LL;
if ( TCcount > 10 )
_assert_fail("TCcount <= MAXTCCOUNTX", "tcontrl.c", 0x142u, "SetResponseTime");
}
}

original_code:
void SetResponseTime(short side)
{
    int DetermineTCcount = 1;
    if (TCflag)
    {
        TCcount = 0;
        if (TimeControl.moves[side] < 1)
            TimeControl.moves[side] = 1;
        if (flag.onemove)
        {
            ResponseTime = TimeControl.clock[side] - 100;
            TCleft = 0;
        }
        else
        {
            if (TimeControl.clock[side] <= 0)
            {
                ResponseTime = 0;
                TCleft = (long)100 / 10;
            }
            else
            {
                short rtf = (!flag.tsume && (stage < 33)) ? 8 : 2;
                short tcq = (!flag.tsume && (stage < 33)) ? 2 : 4;
                TimeControl.clock[side] += TCadd;
                ResponseTime = (TimeControl.clock[side])
                    / (((TimeControl.moves[side]) * rtf) + 1);
                TCleft = (long)ResponseTime / tcq;
                ResponseTime += TCadd / 2;
            }
            if (TimeControl.moves[side] < 5)
            {
                TCcount = 10 - 10;
                if (TCcount < 0)
                    TCcount = 0;
                DetermineTCcount = 0;
            }
        }
        if (ResponseTime < 100)
        {
            ResponseTime = 100;
            TCcount = 10 - 10;
            if (TCcount < 0)
                TCcount = 0;
            DetermineTCcount = 0;
        }
        if (!hard_time_limit && (ResponseTime < 2 * 100))
        {
            TCcount = 10 - 10;
            if (TCcount < 0)
                TCcount = 0;
            DetermineTCcount = 0;
        }
    }
    else
    {
        TCleft = 0;
        ResponseTime = MaxResponseTime;
        ElapsedTime(COMPUTE_AND_INIT_MODE);
    }
    if (DetermineTCcount)
    {
        if (TCleft )
        {
            int AllowedCounts
                = ((int)((TimeControl.clock[side] - ResponseTime)) / 2)
                / TCleft;
            if (AllowedCounts <= 0)
                TCcount = 10;
            else if (AllowedCounts > 10)
                TCcount = 0;
            else
                TCcount = 10 - AllowedCounts;
        }
        else
        {
            TCcount = 10;
        }
    }
    if (ResponseTime < 100)
        ResponseTime = 100;
    ((TCcount <= 10) ? (void) (0) : __assert_fail ("TCcount <= MAXTCCOUNTX", "tcontrl.c", 322, __extension__ __PRETTY_FUNCTION__));
}

variable_types: side short

variable_types: DetermineTCcount int

variable_types: rtf short

variable_types: tcq short

variable_types: AllowedCounts int


CheckForTimeout

decompiled_code:
__int64 __fastcall CheckForTimeout(int a1, int a2, int a3, int a4)
{
__int64 result; // rax
int v5; // er9

if ( flag[11] || Sdepth >= MaxSearchDepth )
{
flag[10] = 1;
}
else if ( TCflag )
{
if ( Sdepth > 1 )
{
v5 = TCcount;
if ( TCcount <= 3 )
{
if ( killr0[1] == PrVar[1] || (v5 = TCcount + 1, ExtraTime += TCleft, TCcount = v5, v5 != 4) )
{
if ( (int)abs32(a1 - a2) / Sdepth > 10 )
{
TCcount = v5 + 1;
ExtraTime += TCleft;
}
}
}
}
}
if ( a3 - a4 < a1 && *(__int16 *)(Tree + 14LL) + 250 < a1 )
ExtraTime = 0LL;
result = ElapsedTime(2LL);
if ( (*(_BYTE *)(root + 10LL) & 0x40) != 0
|| Sdepth > 1 && TCflag && (result = ResponseTime, 4LL * et > ExtraTime + 2LL * ResponseTime) )
{
flag[10] = 1;
return ShowMessage("timeout");
}
if ( flag[10] )
return ShowMessage("timeout");
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1, int a2, int a3, int a4)
{
__int64 result; // rax
int v5; // er9

if ( flag[11] || Sdepth >= MaxSearchDepth )
{
flag[10] = 1;
}
else if ( TCflag )
{
if ( Sdepth > 1 )
{
v5 = TCcount;
if ( TCcount <= 3 )
{
if ( killr0[1] == PrVar[1] || (v5 = TCcount + 1, ExtraTime += TCleft, TCcount = v5, v5 != 4) )
{
if ( (int)abs32(a1 - a2) / Sdepth > 10 )
{
TCcount = v5 + 1;
ExtraTime += TCleft;
}
}
}
}
}
if ( a3 - a4 < a1 && *(__int16 *)(Tree + 14LL) + 250 < a1 )
ExtraTime = 0LL;
result = ElapsedTime(2LL);
if ( (*(_BYTE *)(root + 10LL) & 0x40) != 0
|| Sdepth > 1 && TCflag && (result = ResponseTime, 4LL * et > ExtraTime + 2LL * ResponseTime) )
{
flag[10] = 1;
return ShowMessage("timeout");
}
if ( flag[10] )
return ShowMessage("timeout");
return result;
}

original_code:
void
CheckForTimeout(int score, int globalscore, int Jscore, int zwndw)
{
    if (flag.musttimeout || (Sdepth >= MaxSearchDepth))
        flag.timeout = 1;
    else if (TCflag && (Sdepth > (2 - 1)) && (TCcount < 4))
    {
        if (killr0[1] != PrVar[1] )
        {
            TCcount++;
            ExtraTime += TCleft;
        }
        if ((TCcount < 4)
            && (abs(score - globalscore) / Sdepth) > 10)
        {
            TCcount++;
            ExtraTime += TCleft;
        }
    }
    if ((score > (Jscore - zwndw)) && (score > (Tree[1].score + 250)))
        ExtraTime = 0;
    ElapsedTime(COMPUTE_MODE);
    if (root->flags & 0x0040)
        flag.timeout = 1;
    else if (!(Sdepth < 2)
             && TCflag
             && ((4 * et) > (2*ResponseTime + ExtraTime)))
        flag.timeout = 1;
    if (flag.timeout)
        ShowMessage("timeout");
}

variable_types: score int

variable_types: globalscore int

variable_types: Jscore int

variable_types: zwndw int


SqAttacked

original_code:
int
SqAttacked(short square, short side, short *blockable)
{
    unsigned char *ppos, *pdir;
    short u, ptyp;
    if (((threats_signature[side].hashbd == hashbd) && (threats_signature[side].hashkey == hashkey)))
    {
        *blockable = 1;
        return (attack[side][square] != 0);
    }
    *blockable = 0;
    ptyp = ptype[0][14];
    pdir = (*nextdir[ptyp])[square];
    u = pdir[square];
    do
    {
        if (color[u] == side)
        {
            if (piece_distance(side, board[u], u, square) == 1)
                return 1;
        }
        u = pdir[u];
    }
    while (u != square);
    ptyp = ptype[side ^ 1][3];
    pdir = (*nextdir[ptyp])[square];
    u = pdir[square];
    do
    {
        if (color[u] == side && board[u] == 3)
            return 1;
        u = pdir[u];
    }
    while (u != square);
    *blockable = 1;
    ptyp = ptype[0][6];
    ppos = (*nextpos[ptyp])[square];
    pdir = (*nextdir[ptyp])[square];
    u = ppos[square];
    do
    {
        if (color[u] == 2)
        u = ppos[u];
        else
        {
            if (color[u] == side && (unpromoted[board[u]] == 6))
                return 1;
            u = pdir[u];
        }
    }
    while (u != square);
    ptyp = ptype[0][7];
    ppos = (*nextpos[ptyp])[square];
    pdir = (*nextdir[ptyp])[square];
    u = ppos[square];
    do
    {
        if (color[u] == 2)
        {
            u = ppos[u];
        }
        else
        {
            if (color[u] == side && (unpromoted[board[u]] == 7))
                return 1;
            u = pdir[u];
        }
    }
    while (u != square);
    ptyp = ptype[side ^ 1][2];
    ppos = (*nextpos[ptyp])[square];
    u = ppos[square];
    do
    {
        if (color[u] == 2)
        {
            u = ppos[u];
        }
        else
        {
            if ((color[u] == side) && (board[u] == 2))
                return 1;
            u = square;
        }
    }
    while (u != square);
    return 0;
}

canonical_original_code:
int SqAttacked(short square, short side, short *blockable)
{
    unsigned char *ppos; unsigned char *pdir;
    short u; short ptyp;
    if (((threats_signature[side].hashbd == hashbd) && (threats_signature[side].hashkey == hashkey)))
    {
        *blockable = 1;
        return (attack[side][square] != 0);
    }
    *blockable = 0;
    ptyp = ptype[0][14];
    pdir = (*nextdir[ptyp])[square];
    u = pdir[square];
    do
    {
        if (color[u] == side)
        {
            if (piece_distance(side, board[u], u, square) == 1)
                return 1;
        }
        u = pdir[u];
    }
    while (u != square);
    ptyp = ptype[side ^ 1][3];
    pdir = (*nextdir[ptyp])[square];
    u = pdir[square];
    do
    {
        if (color[u] == side && board[u] == 3)
            return 1;
        u = pdir[u];
    }
    while (u != square);
    *blockable = 1;
    ptyp = ptype[0][6];
    ppos = (*nextpos[ptyp])[square];
    pdir = (*nextdir[ptyp])[square];
    u = ppos[square];
    do
    {
        if (color[u] == 2)
        u = ppos[u];
        else
        {
            if (color[u] == side && (unpromoted[board[u]] == 6))
                return 1;
            u = pdir[u];
        }
    }
    while (u != square);
    ptyp = ptype[0][7];
    ppos = (*nextpos[ptyp])[square];
    pdir = (*nextdir[ptyp])[square];
    u = ppos[square];
    do
    {
        if (color[u] == 2)
        {
            u = ppos[u];
        }
        else
        {
            if (color[u] == side && (unpromoted[board[u]] == 7))
                return 1;
            u = pdir[u];
        }
    }
    while (u != square);
    ptyp = ptype[side ^ 1][2];
    ppos = (*nextpos[ptyp])[square];
    u = ppos[square];
    do
    {
        if (color[u] == 2)
        {
            u = ppos[u];
        }
        else
        {
            if ((color[u] == side) && (board[u] == 2))
                return 1;
            u = square;
        }
    }
    while (u != square);
    return 0;
}

variable_types: square short

variable_types:
blockable
short *

variable_types:
ppos
unsigned char *

variable_types:
pdir
unsigned char *

variable_types: u short

variable_types: ptyp short


decompiled_code:
__int64 __fastcall ElapsedTime_NOFIONREAD(int a1)
{
time_t v1; // rdx
__int64 result; // rax
__int64 v3; // rsi

v1 = time(0LL);
ETnodes = NodeCnt + znodes;
result = 5 * (v1 - time0);
v3 = 100 * (v1 - time0);
if ( v3 < 0 )
v3 = 0LL;
et = v3;
if ( a1 == 1 )
{
if ( ResponseTime + ExtraTime < et && Sdepth > 2 )
flag[10] = 1;
time0 = v1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
time_t v1; // rdx
__int64 result; // rax
__int64 v3; // rsi

v1 = time(0LL);
ETnodes = NodeCnt + znodes;
result = 5 * (v1 - time0);
v3 = 100 * (v1 - time0);
if ( v3 < 0 )
v3 = 0LL;
et = v3;
if ( a1 == 1 )
{
if ( ResponseTime + ExtraTime < et && Sdepth > 2 )
flag[10] = 1;
time0 = v1;
}
return result;
}

original_code:
void
ElapsedTime_NOFIONREAD(ElapsedTime_mode iop)
{
    long current_time;
    et = ((current_time = time((long *) 0)) - time0) * 100;
    {
        ETnodes = NodeCnt + znodes;
        if (et < 0)
        {
            et = 0;
        }
        if (iop == COMPUTE_AND_INIT_MODE)
        {
            if ((et > (ResponseTime + ExtraTime)) && (Sdepth > 2))
                flag.timeout = 1;
            time0 = current_time;
        }
    }
}

canonical_original_code:
void ElapsedTime_NOFIONREAD(enum ElapsedTime_mode iop)
{
    long current_time;
    et = ((current_time = time((long *) 0)) - time0) * 100;
    {
        ETnodes = NodeCnt + znodes;
        if (et < 0)
        {
            et = 0;
        }
        if (iop == COMPUTE_AND_INIT_MODE)
        {
            if ((et > (ResponseTime + ExtraTime)) && (Sdepth > 2))
                flag.timeout = 1;
            time0 = current_time;
        }
    }
}

variable_types: enum ElapsedTime_mode { COMPUTE_AND_INIT_MODE=1, COMPUTE_MODE=2 }


ElapsedTime

decompiled_code:
// attributes: thunk
__int64 __fastcall ElapsedTime(int a1)
{
return ElapsedTime_NOFIONREAD(a1);
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
return func0(a1);
}

original_code:
void
ElapsedTime(ElapsedTime_mode iop)
{
    ElapsedTime_NOFIONREAD(iop);
}

canonical_original_code:
void ElapsedTime(enum ElapsedTime_mode iop)
{
    ElapsedTime_NOFIONREAD(iop);
}

user_defined_types: enum ElapsedTime_mode { COMPUTE_AND_INIT_MODE=1, COMPUTE_MODE=2 }


main

repo: johndgiese/c-bootstrap

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
float v3; // xmm0_4
float v4; // xmm0_4
float v6; // [rsp+8h] [rbp-10h]
unsigned int v7[3]; // [rsp+Ch] [rbp-Ch] BYREF

printf("Enter a number: ");
__isoc99_scanf();
printf("Enter a number: ");
__isoc99_scanf();
v3 = add("%f", v7, COERCE_DOUBLE((unsigned __int64)LODWORD(v6)), COERCE_DOUBLE((unsigned __int64)v7[0]));
printf("Sum: %f\n", v3);
v4 = subtract(v6, *(float *)v7);
printf("Difference: %f\n", v4);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
float v3; // xmm0_4
float v4; // xmm0_4
float v6; // [rsp+8h] [rbp-10h]
unsigned int v7[3]; // [rsp+Ch] [rbp-Ch] BYREF

printf("Enter a number: ");
__isoc99_scanf();
printf("Enter a number: ");
__isoc99_scanf();
v3 = func7("%f", v7, COERCE_DOUBLE((unsigned __int64)LODWORD(v6)), COERCE_DOUBLE((unsigned __int64)v7[0]));
printf("Sum: %f\n", v3);
v4 = func8(v6, *(float *)v7);
printf("Difference: %f\n", v4);
return 0;
}

original_code:
int main(int argc, const char *argv[]) {
    float a, b;
    printf("Enter a number: ");
    scanf("%f", &a);
    printf("Enter a number: ");
    scanf("%f", &b);
    printf("Sum: %f\n", add(a, b));
    printf("Difference: %f\n", subtract(a, b));
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
    float a; float b;
    printf("Enter a number: ");
    scanf("%f", &a);
    printf("Enter a number: ");
    scanf("%f", &b);
    printf("Sum: %f\n", add(a, b));
    printf("Difference: %f\n", subtract(a, b));
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: a float

variable_types: b float


problem

repo: johndgiese/knking-c

decompiled_code:
int __fastcall problem(unsigned int a1, unsigned int a2)
{
return printf("\nPROBLEM %2d.%-4d\n", a1, a2);
}

canonical_decompiled_code:
int __fastcall func7(unsigned int a1, unsigned int a2)
{
return printf("\nPROBLEM %2d.%-4d\n", a1, a2);
}

original_code:
void problem(int chapter, int number) {
    printf("\nPROBLEM %2d.%-4d\n", chapter, number);
}

variable_types: chapter int

variable_types: number int


main

variable_types: a int

variable_types: b int

variable_types: c int

variable_types: d int

variable_types: aa float

variable_types: bb float

variable_types: cc float

variable_types: dd float


decompiled_code:
__int64 grab_single_number()
{
__isoc99_scanf();
return 1234LL;
}

canonical_decompiled_code:
__int64 func9()
{
__isoc99_scanf();
return 1234LL;
}

original_code:
unsigned int grab_single_number(unsigned int *number_p) {
    int status = scanf("%u", number_p);
    return 1234;
}

variable_types: status int


decompiled_code:
__int64 prompt_for_amount()
{
unsigned int v1[3]; // [rsp+Ch] [rbp-Ch] BYREF

while ( 1 )
{
printf("Enter a dollar amount: ");
if ( !(unsigned int)grab_single_number(v1) )
break;
puts("Values must be whole numbers.");
}
return v1[0];
}

canonical_decompiled_code:
__int64 func10()
{
unsigned int v1[3]; // [rsp+Ch] [rbp-Ch] BYREF

while ( 1 )
{
printf("Enter a dollar amount: ");
if ( !(unsigned int)func9(v1) )
break;
puts("Values must be whole numbers.");
}
return v1[0];
}

original_code:
unsigned int prompt_for_amount() {
    unsigned int amount;
    while (1) {
        printf("Enter a dollar amount: ");
        int status = grab_single_number(&amount);
        if (status) {
            printf("Values must be whole numbers.\n");
        } else {
            break;
        }
    }
    return amount;
}

variable_types:
amount
unsigned int


decompiled_code:
unsigned __int64 __fastcall breakdown_amount(int a1)
{
return (unsigned int)(a1 % 20 % 10 % 5) | ((unsigned __int64)(unsigned int)(a1 % 20 % 10 / 5) << 32);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func11(int a1)
{
return (unsigned int)(a1 % 20 % 10 % 5) | ((unsigned __int64)(unsigned int)(a1 % 20 % 10 / 5) << 32);
}

original_code:
billbreakdown breakdown_amount(int amount) {
    billbreakdown b;
    b.twenties = amount/20;
    amount = amount - 20*b.twenties;
    b.tens = amount/10;
    amount = amount - 10*b.tens;
    b.fives = amount/5;
    amount = amount - 5*b.fives;
    b.ones = amount;
    return b;
}

canonical_original_code:
struct billbreakdown breakdown_amount(int amount) {
    struct billbreakdown b;
    b.twenties = amount/20;
    amount = amount - 20*b.twenties;
    b.tens = amount/10;
    amount = amount - 10*b.tens;
    b.fives = amount/5;
    amount = amount - 5*b.fives;
    b.ones = amount;
    return b;
}

variable_types: amount int

variable_types: struct billbreakdown { int ones; int fives; int tens; int twenties; }


decompiled_code:
int __fastcall print_breakdown(__int64 a1, __int64 a2)
{
printf("$20 bills: %d\n", a2 >> 32);
printf("$10 bills: %d\n", (unsigned int)a2);
printf(" $5 bills: %d\n", a1 >> 32);
return printf(" $1 bills: %d\n", (unsigned int)a1);
}

canonical_decompiled_code:
int __fastcall func12(__int64 a1, __int64 a2)
{
printf("$20 bills: %d\n", a2 >> 32);
printf("$10 bills: %d\n", (unsigned int)a2);
printf(" $5 bills: %d\n", a1 >> 32);
return printf(" $1 bills: %d\n", (unsigned int)a1);
}

original_code:
void print_breakdown(billbreakdown b) {
    printf("$20 bills: %d\n", b.twenties);
    printf("$10 bills: %d\n", b.tens);
    printf(" $5 bills: %d\n", b.fives);
    printf(" $1 bills: %d\n", b.ones);
}

canonical_original_code:
void print_breakdown(struct billbreakdown b) {
    printf("$20 bills: %d\n", b.twenties);
    printf("$10 bills: %d\n", b.tens);
    printf(" $5 bills: %d\n", b.fives);
    printf(" $1 bills: %d\n", b.ones);
}

user_defined_types: struct billbreakdown { int ones; int fives; int tens; int twenties; }


decompiled_code:
__int64 __fastcall int_max(unsigned int a1, unsigned int a2)
{
__int64 result; // rax

result = a1;
if ( (int)a2 >= (int)a1 )
result = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int a1, unsigned int a2)
{
__int64 result; // rax

result = a1;
if ( (int)a2 >= (int)a1 )
result = a2;
return result;
}

original_code: int int_max(int x, int y) { return x > y ? x : y; }

variable_types: x int

variable_types: y int


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

result = a1;
if ( a2 >= a1 )
result = a2;
return result;
}

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

result = a1;
if ( a2 >= a1 )
result = a2;
return result;
}

original_code: unsigned long ul_max(unsigned long x, unsigned long y) { return x > y ? x : y; }

variable_types:
x
unsigned long

variable_types:
y
unsigned long

return_type: unsigned long


decompiled_code:
__int64 __fastcall dummy_gettext(__int64 a1)
{
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return a1;
}

original_code: static char * dummy_gettext (const char *msgid) { return (char *) (msgid); }

canonical_original_code: static char *dummy_gettext(char *msgid) { return (char *) (msgid); }

variable_types:
msgid
char *

return_type: char *


decompiled_code:
__int64 __fastcall dummy_dgettext(__int64 a1, __int64 a2)
{
return a2;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
return a2;
}

original_code: static char * dummy_dgettext (const char *domainname, const char *msgid) { return (char *) (msgid); }

canonical_original_code: static char *dummy_dgettext(char *domainname, char *msgid) { return (char *) (msgid); }

variable_types:
domainname
char *


decompiled_code:
__int64 __fastcall dummy_dcgettext(__int64 a1, __int64 a2)
{
return a2;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
return a2;
}

original_code: static char * dummy_dcgettext (const char *domainname, const char *msgid, int category) { return (char *) (msgid); }

canonical_original_code: static char *dummy_dcgettext(char *domainname, char *msgid, int category) { return (char *) (msgid); }

variable_types: category int


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

result = a2;
if ( a3 == 1 )
result = a1;
return result;
}

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

result = a2;
if ( a3 == 1 )
result = a1;
return result;
}

original_code: static char * dummy_ngettext (const char *msgid1, const char *msgid2, unsigned long int n) { return (char *) (n == 1 ? msgid1 : msgid2); }

canonical_original_code: static char *dummy_ngettext(char *msgid1, char *msgid2, unsigned long n) { return (char *) (n == 1 ? msgid1 : msgid2); }

variable_types:
n
unsigned long


decompiled_code:
__int64 __fastcall dummy_dngettext(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax

result = a3;
if ( a4 == 1 )
result = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax

result = a3;
if ( a4 == 1 )
result = a2;
return result;
}

original_code: static char * dummy_dngettext (const char *domainname, const char *msgid1, const char *msgid2, unsigned long int n) { return (char *) (n == 1 ? msgid1 : msgid2); }

canonical_original_code: static char *dummy_dngettext(char *domainname, char *msgid1, char *msgid2, unsigned long n) { return (char *) (n == 1 ? msgid1 : msgid2); }


decompiled_code:
__int64 __fastcall dummy_dcngettext(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax

result = a3;
if ( a4 == 1 )
result = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax

result = a3;
if ( a4 == 1 )
result = a2;
return result;
}

original_code: static char * dummy_dcngettext (const char *domainname, const char *msgid1, const char *msgid2, unsigned long int n, int category) { return (char *) (n == 1 ? msgid1 : msgid2); }

canonical_original_code: static char *dummy_dcngettext(char *domainname, char *msgid1, char *msgid2, unsigned long n, int category) { return (char *) (n == 1 ? msgid1 : msgid2); }


decompiled_code:
const char *dummy_bindtextdomain()
{
return "/dummy";
}

canonical_decompiled_code:
const char *func6()
{
return "/dummy";
}

original_code: static char * dummy_bindtextdomain (const char *domainname, const char *dirname) { return (char *) ("/dummy"); }

canonical_original_code: static char *dummy_bindtextdomain(char *domainname, char *dirname) { return (char *) ("/dummy"); }

variable_types:
dirname
char *


decompiled_code:
// attributes: thunk
__int64 __fastcall dummy_bind_textdomain_codeset(__int64 a1, __int64 a2)
{
return dummy_dgettext(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
return func1(a1, a2);
}

original_code: static char * dummy_bind_textdomain_codeset (const char *domainname, const char *codeset) { return (char *) (codeset); }

canonical_original_code: static char *dummy_bind_textdomain_codeset(char *domainname, char *codeset) { return (char *) (codeset); }

variable_types:
codeset
char *


decompiled_code:
void use_dummy()
{
p_gettext = (__int64)dummy_gettext;
p_dgettext = (__int64)dummy_dgettext;
p_dcgettext = (__int64)dummy_dcgettext;
p_ngettext = (__int64)dummy_ngettext;
p_dngettext = (__int64)dummy_dngettext;
p_dcngettext = (__int64)dummy_dcngettext;
p_textdomain = (__int64)dummy_textdomain;
p_bindtextdomain = (__int64)dummy_bindtextdomain;
p_bind_textdomain_codeset = (__int64)dummy_bind_textdomain_codeset;
}

canonical_decompiled_code:
void func8()
{
p_gettext = (__int64)dummy_gettext;
p_dgettext = (__int64)dummy_dgettext;
p_dcgettext = (__int64)dummy_dcgettext;
p_ngettext = (__int64)dummy_ngettext;
p_dngettext = (__int64)dummy_dngettext;
p_dcngettext = (__int64)dummy_dcngettext;
p_textdomain = (__int64)dummy_textdomain;
p_bindtextdomain = (__int64)dummy_bindtextdomain;
p_bind_textdomain_codeset = (__int64)dummy_bind_textdomain_codeset;
}

original_code:
static void
use_dummy (void)
{
  p_gettext = dummy_gettext;
  p_dgettext = dummy_dgettext;
  p_dcgettext = dummy_dcgettext;
  p_ngettext = dummy_ngettext;
  p_dngettext = dummy_dngettext;
  p_dcngettext = dummy_dcngettext;
  p_textdomain = dummy_textdomain;
  p_bindtextdomain = dummy_bindtextdomain;
  p_bind_textdomain_codeset = dummy_bind_textdomain_codeset;
}

canonical_original_code:
static void use_dummy()
{
  p_gettext = dummy_gettext;
  p_dgettext = dummy_dgettext;
  p_dcgettext = dummy_dcgettext;
  p_ngettext = dummy_ngettext;
  p_dngettext = dummy_dngettext;
  p_dcngettext = dummy_dcngettext;
  p_textdomain = dummy_textdomain;
  p_bindtextdomain = dummy_bindtextdomain;
  p_bind_textdomain_codeset = dummy_bind_textdomain_codeset;
}


decompiled_code:
_BOOL8 __fastcall use_intl_dll(void *handle)
{
p_gettext = (__int64)dlsym(handle, "gettext");
if ( !p_gettext )
return 0LL;
p_dgettext = (__int64)dlsym(handle, "dgettext");
if ( !p_dgettext )
return 0LL;
p_dcgettext = (__int64)dlsym(handle, "dcgettext");
if ( !p_dcgettext )
return 0LL;
p_ngettext = (__int64)dlsym(handle, "ngettext");
if ( !p_ngettext )
return 0LL;
p_dngettext = (__int64)dlsym(handle, "dngettext");
if ( !p_dngettext )
return 0LL;
p_dcngettext = (__int64)dlsym(handle, "dcngettext");
if ( !p_dcngettext )
return 0LL;
p_textdomain = (__int64)dlsym(handle, "textdomain");
if ( !p_textdomain )
return 0LL;
p_bindtextdomain = (__int64)dlsym(handle, "bindtextdomain");
if ( !p_bindtextdomain )
return 0LL;
p_bind_textdomain_codeset = (__int64)dlsym(handle, "bind_textdomain_codeset");
return p_bind_textdomain_codeset != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func9(void *handle)
{
p_gettext = (__int64)dlsym(handle, "gettext");
if ( !p_gettext )
return 0LL;
p_dgettext = (__int64)dlsym(handle, "dgettext");
if ( !p_dgettext )
return 0LL;
p_dcgettext = (__int64)dlsym(handle, "dcgettext");
if ( !p_dcgettext )
return 0LL;
p_ngettext = (__int64)dlsym(handle, "ngettext");
if ( !p_ngettext )
return 0LL;
p_dngettext = (__int64)dlsym(handle, "dngettext");
if ( !p_dngettext )
return 0LL;
p_dcngettext = (__int64)dlsym(handle, "dcngettext");
if ( !p_dcngettext )
return 0LL;
p_textdomain = (__int64)dlsym(handle, "textdomain");
if ( !p_textdomain )
return 0LL;
p_bindtextdomain = (__int64)dlsym(handle, "bindtextdomain");
if ( !p_bindtextdomain )
return 0LL;
p_bind_textdomain_codeset = (__int64)dlsym(handle, "bind_textdomain_codeset");
return p_bind_textdomain_codeset != 0;
}

original_code:
static int
use_intl_dll (HMODULE dll)
{
  p_gettext = (void *) dlsym (dll, "gettext"); if (p_gettext == ((void *)0)) return 0;
  p_dgettext = (void *) dlsym (dll, "dgettext"); if (p_dgettext == ((void *)0)) return 0;
  p_dcgettext = (void *) dlsym (dll, "dcgettext"); if (p_dcgettext == ((void *)0)) return 0;
  p_ngettext = (void *) dlsym (dll, "ngettext"); if (p_ngettext == ((void *)0)) return 0;
  p_dngettext = (void *) dlsym (dll, "dngettext"); if (p_dngettext == ((void *)0)) return 0;
  p_dcngettext = (void *) dlsym (dll, "dcngettext"); if (p_dcngettext == ((void *)0)) return 0;
  p_textdomain = (void *) dlsym (dll, "textdomain"); if (p_textdomain == ((void *)0)) return 0;
  p_bindtextdomain = (void *) dlsym (dll, "bindtextdomain"); if (p_bindtextdomain == ((void *)0)) return 0;
  p_bind_textdomain_codeset = (void *) dlsym (dll, "bind_textdomain_codeset"); if (p_bind_textdomain_codeset == ((void *)0)) return 0;
    return 1;
}

canonical_original_code:
static int use_intl_dll(void *dll)
{
  p_gettext = (void *) dlsym (dll, "gettext"); if (p_gettext == ((void *)0)) return 0;
  p_dgettext = (void *) dlsym (dll, "dgettext"); if (p_dgettext == ((void *)0)) return 0;
  p_dcgettext = (void *) dlsym (dll, "dcgettext"); if (p_dcgettext == ((void *)0)) return 0;
  p_ngettext = (void *) dlsym (dll, "ngettext"); if (p_ngettext == ((void *)0)) return 0;
  p_dngettext = (void *) dlsym (dll, "dngettext"); if (p_dngettext == ((void *)0)) return 0;
  p_dcngettext = (void *) dlsym (dll, "dcngettext"); if (p_dcngettext == ((void *)0)) return 0;
  p_textdomain = (void *) dlsym (dll, "textdomain"); if (p_textdomain == ((void *)0)) return 0;
  p_bindtextdomain = (void *) dlsym (dll, "bindtextdomain"); if (p_bindtextdomain == ((void *)0)) return 0;
  p_bind_textdomain_codeset = (void *) dlsym (dll, "bind_textdomain_codeset"); if (p_bind_textdomain_codeset == ((void *)0)) return 0;
    return 1;
}

variable_types:
dll
void *


setup

decompiled_code:
void setup()
{
void *v0; // rdi

if ( !beenhere_0 )
{
v0 = dlopen("libintl.so", 1);
if ( v0 && use_intl_dll(v0) )
{
beenhere_0 = 1;
}
else
{
use_dummy();
beenhere_0 = 1;
}
}
}

canonical_decompiled_code:
void func10()
{
void *v0; // rdi

if ( !beenhere_0 )
{
v0 = dlopen("libintl.so", 1);
if ( v0 && func9(v0) )
{
beenhere_0 = 1;
}
else
{
func8();
beenhere_0 = 1;
}
}
}

original_code:
static void
setup (void)
{
  static int beenhere = 0;
  if (!beenhere)
    {
      HMODULE intl_dll = dlopen ("libintl.so", 0x00001);
      if (intl_dll != ((void *)0) &&
   use_intl_dll (intl_dll))
 ;
      else
 use_dummy ();
      beenhere = 1;
    }
}

canonical_original_code:
static void setup()
{
  static int beenhere = 0;
  if (!beenhere)
    {
      void *intl_dll = dlopen ("libintl.so", 0x00001);
      if (intl_dll != ((void *)0) &&
   use_intl_dll (intl_dll))
 ;
      else
 use_dummy ();
      beenhere = 1;
    }
}

variable_types: beenhere int


decompiled_code:
char *__fastcall dummy_textdomain(char *s)
{
char *result; // rax

result = (char *)current_domain;
if ( s )
{
free(current_domain);
result = strdup(s);
current_domain = result;
}
else if ( !current_domain )
{
result = strdup("messages");
current_domain = result;
}
return result;
}

canonical_decompiled_code:
char *__fastcall func11(char *s)
{
char *result; // rax

result = (char *)current_domain;
if ( s )
{
free(current_domain);
result = strdup(s);
current_domain = result;
}
else if ( !current_domain )
{
result = strdup("messages");
current_domain = result;
}
return result;
}

original_code: static char * dummy_textdomain (const char *domainname) { return (char *) ((domainname ? (free (current_domain), current_domain = strdup (domainname)) : (current_domain ? current_domain : (current_domain = strdup ("messages"))))); }

canonical_original_code: static char *dummy_textdomain(char *domainname) { return (char *) ((domainname ? (free (current_domain), current_domain = strdup (domainname)) : (current_domain ? current_domain : (current_domain = strdup ("messages"))))); }


gettext

decompiled_code:
__int64 __fastcall gettext(__int64 a1)
{
setup();
return p_gettext(a1);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
func10();
return p_gettext(a1);
}

original_code: char * gettext (const char *msgid) { setup (); return p_gettext (msgid); }

canonical_original_code: char *gettext(char *msgid) { setup (); return p_gettext (msgid); }


dgettext

decompiled_code:
__int64 __fastcall dgettext(__int64 a1, __int64 a2)
{
setup();
return p_dgettext(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, __int64 a2)
{
func10();
return p_dgettext(a1, a2);
}

original_code: char * dgettext (const char *domainname, const char *msgid) { setup (); return p_dgettext (domainname, msgid); }

canonical_original_code: char *dgettext(char *domainname, char *msgid) { setup (); return p_dgettext (domainname, msgid); }


dcgettext

decompiled_code:
__int64 __fastcall dcgettext(__int64 a1, __int64 a2, unsigned int a3)
{
setup();
return p_dcgettext(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, __int64 a2, unsigned int a3)
{
func10();
return p_dcgettext(a1, a2, a3);
}

original_code: char * dcgettext (const char *domainname, const char *msgid, int category) { setup (); return p_dcgettext (domainname, msgid, category); }

canonical_original_code: char *dcgettext(char *domainname, char *msgid, int category) { setup (); return p_dcgettext (domainname, msgid, category); }


ngettext

decompiled_code:
__int64 __fastcall ngettext(__int64 a1, __int64 a2, __int64 a3)
{
setup();
return p_ngettext(a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, __int64 a2, __int64 a3)
{
func10();
return p_ngettext(a1, a2, a3);
}

original_code: char * ngettext (const char *msgid1, const char *msgid2, unsigned long int n) { setup (); return p_ngettext (msgid1, msgid2, n); }

canonical_original_code: char *ngettext(char *msgid1, char *msgid2, unsigned long n) { setup (); return p_ngettext (msgid1, msgid2, n); }


dngettext

decompiled_code:
__int64 __fastcall dngettext(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
setup();
return p_dngettext(a1, a2, a3, a4);
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
func10();
return p_dngettext(a1, a2, a3, a4);
}

original_code: char * dngettext (const char *domainname, const char *msgid1, const char *msgid2, unsigned long int n) { setup (); return p_dngettext (domainname, msgid1, msgid2, n); }

canonical_original_code: char *dngettext(char *domainname, char *msgid1, char *msgid2, unsigned long n) { setup (); return p_dngettext (domainname, msgid1, msgid2, n); }


dcngettext

decompiled_code:
__int64 __fastcall dcngettext(__int64 a1, __int64 a2, __int64 a3, __int64 a4, unsigned int a5)
{
setup();
return p_dcngettext(a1, a2, a3, a4, a5);
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1, __int64 a2, __int64 a3, __int64 a4, unsigned int a5)
{
func10();
return p_dcngettext(a1, a2, a3, a4, a5);
}

original_code: char * dcngettext (const char *domainname, const char *msgid1, const char *msgid2, unsigned long int n, int category) { setup (); return p_dcngettext (domainname, msgid1, msgid2, n, category); }

canonical_original_code: char *dcngettext(char *domainname, char *msgid1, char *msgid2, unsigned long n, int category) { setup (); return p_dcngettext (domainname, msgid1, msgid2, n, category); }


textdomain

decompiled_code:
__int64 __fastcall textdomain(__int64 a1)
{
setup();
return p_textdomain(a1);
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1)
{
func10();
return p_textdomain(a1);
}

original_code: char * textdomain (const char *domainname) { setup (); return p_textdomain (domainname); }

canonical_original_code: char *textdomain(char *domainname) { setup (); return p_textdomain (domainname); }


bindtextdomain

decompiled_code:
__int64 __fastcall bindtextdomain(__int64 a1, __int64 a2)
{
setup();
return p_bindtextdomain(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func19(__int64 a1, __int64 a2)
{
func10();
return p_bindtextdomain(a1, a2);
}

original_code: char * bindtextdomain (const char *domainname, const char *dirname) { setup (); return p_bindtextdomain (domainname, dirname); }

canonical_original_code: char *bindtextdomain(char *domainname, char *dirname) { setup (); return p_bindtextdomain (domainname, dirname); }


decompiled_code:
__int64 __fastcall bind_textdomain_codeset(__int64 a1, __int64 a2)
{
setup();
return p_bind_textdomain_codeset(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 a1, __int64 a2)
{
func10();
return p_bind_textdomain_codeset(a1, a2);
}

original_code: char * bind_textdomain_codeset (const char *domainname, const char *codeset) { setup (); return p_bind_textdomain_codeset (domainname, codeset); }

canonical_original_code: char *bind_textdomain_codeset(char *domainname, char *codeset) { setup (); return p_bind_textdomain_codeset (domainname, codeset); }


repo: johnjlee/opticalflow

original_code:
void draw_needle(struct image *im, int Ax, int Ay, int Bx, int By)
{
   int dX = abs(Bx-Ax);
   int dY = abs(By-Ay);
   int Xincr, Yincr;
   if (Ax > Bx) { Xincr=-1; } else { Xincr=1; }
   if (Ay > By) { Yincr=-1; } else { Yincr=1; }
   if (dX >= dY)
   {
      int dPr = dY<<1;
      int dPru = dPr - (dX<<1);
      int P = dPr - dX;
      for (; dX>=0; dX--)
      {
         if(Ax <= im->xres && Ay <= im->yres &&
            Ax >= 0 && Ay >= 0)
         {
            im->s[Ax][Ay] = 0;
         }
         if (P > 0)
         {
            Ax+=Xincr;
            Ay+=Yincr;
            P+=dPru;
         }
         else
         {
            Ax+=Xincr;
            P+=dPr;
         }
      }
   }
   else
   {
      int dPr = dX<<1;
      int dPru = dPr - (dY<<1);
      int P = dPr - dY;
      for (; dY>=0; dY--)
      {
         if(Ax <= im->xres && Ay <= im->yres &&
            Ax >= 0 && Ay >= 0)
         {
            im->s[Ax][Ay] = 0;
         }
         if (P > 0)
         {
            Ax+=Xincr;
            Ay+=Yincr;
            P+=dPru;
         }
         else
         {
            Ay+=Yincr;
            P+=dPr;
         }
      }
   }
}

canonical_original_code:
void draw_needle(struct image *im, int Ax, int Ay, int Bx, int By)
{
   int dX = abs(Bx-Ax);
   int dY = abs(By-Ay);
   int Xincr; int Yincr;
   if (Ax > Bx) { Xincr=-1; } else { Xincr=1; }
   if (Ay > By) { Yincr=-1; } else { Yincr=1; }
   if (dX >= dY)
   {
      int dPr = dY<<1;
      int dPru = dPr - (dX<<1);
      int P = dPr - dX;
      for (; dX>=0; dX--)
      {
         if(Ax <= im->xres && Ay <= im->yres &&
            Ax >= 0 && Ay >= 0)
         {
            im->s[Ax][Ay] = 0;
         }
         if (P > 0)
         {
            Ax+=Xincr;
            Ay+=Yincr;
            P+=dPru;
         }
         else
         {
            Ax+=Xincr;
            P+=dPr;
         }
      }
   }
   else
   {
      int dPr = dX<<1;
      int dPru = dPr - (dY<<1);
      int P = dPr - dY;
      for (; dY>=0; dY--)
      {
         if(Ax <= im->xres && Ay <= im->yres &&
            Ax >= 0 && Ay >= 0)
         {
            im->s[Ax][Ay] = 0;
         }
         if (P > 0)
         {
            Ax+=Xincr;
            Ay+=Yincr;
            P+=dPru;
         }
         else
         {
            Ay+=Yincr;
            P+=dPr;
         }
      }
   }
}

variable_types:
im
struct image { int **s; int xres; } *

variable_types: Ax int

variable_types: Ay int

variable_types: Bx int

variable_types: By int

variable_types: dX int

variable_types: dY int

variable_types: Xincr int

variable_types: Yincr int

variable_types: dPr int

variable_types: dPru int

variable_types: P int


original_code:
void render_needles(struct image *small, struct image *big,
                    struct vector_field *uv)
{
   ((void) sizeof ((small != ((void *)0)) ? 1 : 0), __extension__ ({ if (small != ((void *)0)) ; else __assert_fail ("small != NULL", "needles.c", 8, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof ((big != ((void *)0)) ? 1 : 0), __extension__ ({ if (big != ((void *)0)) ; else __assert_fail ("big != NULL", "needles.c", 9, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof ((uv != ((void *)0)) ? 1 : 0), __extension__ ({ if (uv != ((void *)0)) ; else __assert_fail ("uv != NULL", "needles.c", 10, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof ((small->xres == uv->xres) ? 1 : 0), __extension__ ({ if (small->xres == uv->xres) ; else __assert_fail ("small->xres == uv->xres", "needles.c", 11, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof ((small->yres == uv->yres) ? 1 : 0), __extension__ ({ if (small->yres == uv->yres) ; else __assert_fail ("small->yres == uv->yres", "needles.c", 12, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof (((big->xres % small->xres) == 0) ? 1 : 0), __extension__ ({ if ((big->xres % small->xres) == 0) ; else __assert_fail ("(big->xres % small->xres) == 0", "needles.c", 13, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof (((big->yres % small->yres) == 0) ? 1 : 0), __extension__ ({ if ((big->yres % small->yres) == 0) ; else __assert_fail ("(big->yres % small->yres) == 0", "needles.c", 14, __extension__ __PRETTY_FUNCTION__); }));
   int i,j;
   int xwidth = big->xres / small->xres;
   int ywidth = big->yres / small->yres;
   for(i=0; i < uv->xres - 1; i++)
   {
      for(j=0; j < uv->yres - 1; j++)
      {
         int centerx = i*xwidth + (xwidth/2);
         int centery = j*ywidth + (ywidth/2);
         big->s[centerx][centery] = 0;
         big->s[centerx][centery+1] = 0;
         big->s[centerx+1][centery] = 0;
         big->s[centerx+1][centery+1] = 0;
         draw_needle(big, centerx, centery, centerx + uv->s[i][j].x,
                     centery + uv->s[i][j].y);
      }
   }
}

canonical_original_code:
void render_needles(struct image *small, struct image *big, struct vector_field *uv)
{
   ((void) sizeof ((small != ((void *)0)) ? 1 : 0), __extension__ ({ if (small != ((void *)0)) ; else __assert_fail ("small != NULL", "needles.c", 8, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof ((big != ((void *)0)) ? 1 : 0), __extension__ ({ if (big != ((void *)0)) ; else __assert_fail ("big != NULL", "needles.c", 9, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof ((uv != ((void *)0)) ? 1 : 0), __extension__ ({ if (uv != ((void *)0)) ; else __assert_fail ("uv != NULL", "needles.c", 10, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof ((small->xres == uv->xres) ? 1 : 0), __extension__ ({ if (small->xres == uv->xres) ; else __assert_fail ("small->xres == uv->xres", "needles.c", 11, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof ((small->yres == uv->yres) ? 1 : 0), __extension__ ({ if (small->yres == uv->yres) ; else __assert_fail ("small->yres == uv->yres", "needles.c", 12, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof (((big->xres % small->xres) == 0) ? 1 : 0), __extension__ ({ if ((big->xres % small->xres) == 0) ; else __assert_fail ("(big->xres % small->xres) == 0", "needles.c", 13, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof (((big->yres % small->yres) == 0) ? 1 : 0), __extension__ ({ if ((big->yres % small->yres) == 0) ; else __assert_fail ("(big->yres % small->yres) == 0", "needles.c", 14, __extension__ __PRETTY_FUNCTION__); }));
   int i; int j;
   int xwidth = big->xres / small->xres;
   int ywidth = big->yres / small->yres;
   for(i=0; i < uv->xres - 1; i++)
   {
      for(j=0; j < uv->yres - 1; j++)
      {
         int centerx = i*xwidth + (xwidth/2);
         int centery = j*ywidth + (ywidth/2);
         big->s[centerx][centery] = 0;
         big->s[centerx][centery+1] = 0;
         big->s[centerx+1][centery] = 0;
         big->s[centerx+1][centery+1] = 0;
         draw_needle(big, centerx, centery, centerx + uv->s[i][j].x,
                     centery + uv->s[i][j].y);
      }
   }
}

variable_types:
small
struct image { int **s; int xres; } *

variable_types:
big
struct image *

variable_types: struct vector_field { struct vec3 { float x; } **s; int xres; } *

variable_types: i int

variable_types: j int

variable_types: xwidth int

variable_types: ywidth int

variable_types: centerx int

variable_types: centery int

user_defined_types: struct vector_field { struct vec3 **s; int xres; }


variable_types:
uavg
float *

variable_types:
vavg
float *


original_code:
void render_foe(struct image *small, struct image *big,
                    struct vector_field *uv)
{
   ((void) sizeof ((small != ((void *)0)) ? 1 : 0), __extension__ ({ if (small != ((void *)0)) ; else __assert_fail ("small != NULL", "foe.c", 8, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof ((big != ((void *)0)) ? 1 : 0), __extension__ ({ if (big != ((void *)0)) ; else __assert_fail ("big != NULL", "foe.c", 9, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof ((uv != ((void *)0)) ? 1 : 0), __extension__ ({ if (uv != ((void *)0)) ; else __assert_fail ("uv != NULL", "foe.c", 10, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof ((small->xres == uv->xres) ? 1 : 0), __extension__ ({ if (small->xres == uv->xres) ; else __assert_fail ("small->xres == uv->xres", "foe.c", 11, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof ((small->yres == uv->yres) ? 1 : 0), __extension__ ({ if (small->yres == uv->yres) ; else __assert_fail ("small->yres == uv->yres", "foe.c", 12, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof (((big->xres % small->xres) == 0) ? 1 : 0), __extension__ ({ if ((big->xres % small->xres) == 0) ; else __assert_fail ("(big->xres % small->xres) == 0", "foe.c", 13, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof (((big->yres % small->yres) == 0) ? 1 : 0), __extension__ ({ if ((big->yres % small->yres) == 0) ; else __assert_fail ("(big->yres % small->yres) == 0", "foe.c", 14, __extension__ __PRETTY_FUNCTION__); }));
   int i,j;
   int xwidth = big->xres / small->xres;
   int ywidth = big->yres / small->yres;
   int besti=0, bestj=0;
   float minval = (uv->s[0][0].x)*(uv->s[0][0].x) +
      (uv->s[0][0].y)*(uv->s[0][0].y);
   for(i=3; i < uv->xres - 3; i++)
   {
      for(j=3; j < uv->yres - 3; j++)
      {
         float val = (uv->s[i][j].x)*(uv->s[i][j].x) +
            (uv->s[i][j].y)*(uv->s[i][j].y);
         if(val < minval)
         {
            minval = val;
            besti = i;
            bestj = j;
         }
      }
   }
   int centerx = besti*xwidth + (xwidth/2);
   int centery = bestj*ywidth + (ywidth/2);
   for(i=centerx-2; i <= centerx+2; i++)
   {
      for(j=centery-2; j <= centery+2; j++)
      {
         big->s[i][j] = 255;
      }
   }
}

canonical_original_code:
void render_foe(struct image *small, struct image *big, struct vector_field *uv)
{
   ((void) sizeof ((small != ((void *)0)) ? 1 : 0), __extension__ ({ if (small != ((void *)0)) ; else __assert_fail ("small != NULL", "foe.c", 8, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof ((big != ((void *)0)) ? 1 : 0), __extension__ ({ if (big != ((void *)0)) ; else __assert_fail ("big != NULL", "foe.c", 9, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof ((uv != ((void *)0)) ? 1 : 0), __extension__ ({ if (uv != ((void *)0)) ; else __assert_fail ("uv != NULL", "foe.c", 10, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof ((small->xres == uv->xres) ? 1 : 0), __extension__ ({ if (small->xres == uv->xres) ; else __assert_fail ("small->xres == uv->xres", "foe.c", 11, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof ((small->yres == uv->yres) ? 1 : 0), __extension__ ({ if (small->yres == uv->yres) ; else __assert_fail ("small->yres == uv->yres", "foe.c", 12, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof (((big->xres % small->xres) == 0) ? 1 : 0), __extension__ ({ if ((big->xres % small->xres) == 0) ; else __assert_fail ("(big->xres % small->xres) == 0", "foe.c", 13, __extension__ __PRETTY_FUNCTION__); }));
   ((void) sizeof (((big->yres % small->yres) == 0) ? 1 : 0), __extension__ ({ if ((big->yres % small->yres) == 0) ; else __assert_fail ("(big->yres % small->yres) == 0", "foe.c", 14, __extension__ __PRETTY_FUNCTION__); }));
   int i; int j;
   int xwidth = big->xres / small->xres;
   int ywidth = big->yres / small->yres;
   int besti = 0; int bestj = 0;
   float minval = (uv->s[0][0].x)*(uv->s[0][0].x) +
      (uv->s[0][0].y)*(uv->s[0][0].y);
   for(i=3; i < uv->xres - 3; i++)
   {
      for(j=3; j < uv->yres - 3; j++)
      {
         float val = (uv->s[i][j].x)*(uv->s[i][j].x) +
            (uv->s[i][j].y)*(uv->s[i][j].y);
         if(val < minval)
         {
            minval = val;
            besti = i;
            bestj = j;
         }
      }
   }
   int centerx = besti*xwidth + (xwidth/2);
   int centery = bestj*ywidth + (ywidth/2);
   for(i=centerx-2; i <= centerx+2; i++)
   {
      for(j=centery-2; j <= centery+2; j++)
      {
         big->s[i][j] = 255;
      }
   }
}

variable_types: besti int

variable_types: bestj int

variable_types: minval float

variable_types: val float


decompiled_code:
void __fastcall free_vector_field(void *ptr)
{
__int64 v2; // rbx
void *v3; // rdi

if ( *((int *)ptr + 2) > 0 )
{
v2 = 0LL;
do
{
v3 = *(void **)(*(_QWORD *)ptr + 8 * v2++);
free(v3);
}
while ( *((_DWORD *)ptr + 2) > (int)v2 );
}
free(*(void **)ptr);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
__int64 v2; // rbx
void *v3; // rdi

if ( *((int *)ptr + 2) > 0 )
{
v2 = 0LL;
do
{
v3 = *(void **)(*(_QWORD *)ptr + 8 * v2++);
free(v3);
}
while ( *((_DWORD *)ptr + 2) > (int)v2 );
}
free(*(void **)ptr);
free(ptr);
}

original_code:
void free_vector_field(struct vector_field *s)
{
   int i;
   for(i=0; i < s->xres; i++)
   {
      free(s->s[i]);
   }
   free(s->s);
   free(s);
}


decompiled_code:
void __fastcall free_image(void *ptr)
{
__int64 v2; // rbx
void *v3; // rdi

if ( *((int *)ptr + 2) > 0 )
{
v2 = 0LL;
do
{
v3 = *(void **)(*(_QWORD *)ptr + 8 * v2++);
free(v3);
}
while ( *((_DWORD *)ptr + 2) > (int)v2 );
}
free(*(void **)ptr);
free(ptr);
}

original_code:
void free_image(struct image *s)
{
   int i;
   for(i=0; i < s->xres; i++)
   {
      free(s->s[i]);
   }
   free(s->s);
   free(s);
}

variable_types:
s
struct image { int **s; int xres; } *


usage

repo: johnkerl/bridge-walk-count

decompiled_code:
void __fastcall __noreturn usage(const char *a1)
{
fprintf(stderr, "Usage: %s {constraints name} {N} [options]\n", a1);
fprintf(stderr, "Or: %s {constraints name} {Nmin-Nmax} [options]\n", a1);
list_constraints_names(stderr);
fwrite("Options: \"stdout\" or \"stderr\" to print individual walks.\n", 1uLL, 0x39uLL, stderr);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(const char *a1)
{
fprintf(stderr, "Usage: %s {constraints name} {N} [options]\n", a1);
fprintf(stderr, "Or: %s {constraints name} {Nmin-Nmax} [options]\n", a1);
list_constraints_names(stderr);
fwrite("Options: \"stdout\" or \"stderr\" to print individual walks.\n", 1uLL, 0x39uLL, stderr);
exit(1);
}

original_code:
static void usage(char* argv0)
{
 fprintf(stderr, "Usage: %s {constraints name} {N} [options]\n", argv0);
 fprintf(stderr, "Or:    %s {constraints name} {Nmin-Nmax} [options]\n",
  argv0);
 list_constraints_names(stderr);
 fprintf(stderr, "Options: \"stdout\" or \"stderr\" to print individual walks.\n");
 exit(1);
}

canonical_original_code:
static void usage(char *argv0)
{
 fprintf(stderr, "Usage: %s {constraints name} {N} [options]\n", argv0);
 fprintf(stderr, "Or:    %s {constraints name} {Nmin-Nmax} [options]\n",
  argv0);
 list_constraints_names(stderr);
 fprintf(stderr, "Options: \"stdout\" or \"stderr\" to print individual walks.\n");
 exit(1);
}


repo: johnkerl/ctools

decompiled_code:
const char *AESF_explain_error()
{
return "not there yet";
}

canonical_decompiled_code:
const char *func1()
{
return "not there yet";
}

original_code:
static char * AESF_explain_error(
 int code)
{
 return "not there yet";
}

canonical_original_code:
static char *AESF_explain_error(int code)
{
 return "not there yet";
}

variable_types: code int


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

if ( a1 > 0x20 )
result = 4294967285LL;
else
result = ((1LL << a1) & 0x101010000LL) == 0 ? -11 : 1;
return result;
}

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

if ( a1 > 0x20 )
result = 4294967285LL;
else
result = ((1LL << a1) & 0x101010000LL) == 0 ? -11 : 1;
return result;
}

original_code:
static int AESF_check_bl(
 int bl)
{
 switch (bl) {
 case 16:
 case 24:
 case 32:
  return 1;
 default:
  return -11;
 }
}

canonical_original_code:
static int AESF_check_bl(int bl)
{
 switch (bl) {
 case 16:
 case 24:
 case 32:
  return 1;
 default:
  return -11;
 }
}

variable_types: bl int


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

if ( a1 > 0x20 )
result = 4294967284LL;
else
result = ((1LL << a1) & 0x101010000LL) == 0 ? -12 : 1;
return result;
}

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

if ( a1 > 0x20 )
result = 4294967284LL;
else
result = ((1LL << a1) & 0x101010000LL) == 0 ? -12 : 1;
return result;
}

original_code:
static int AESF_check_kl(
 int kl)
{
 switch (kl) {
 case 16:
 case 24:
 case 32:
  return 1;
 default:
  return -12;
 }
}

canonical_original_code:
static int AESF_check_kl(int kl)
{
 switch (kl) {
 case 16:
 case 24:
 case 32:
  return 1;
 default:
  return -12;
 }
}

variable_types: kl int


decompiled_code:
__int64 __fastcall AESF_make_key(__int64 a1, unsigned int *a2)
{
unsigned int v2; // ebp
void *v3; // rax
void *v4; // r12
unsigned int v5; // edx
_BYTE v7[64]; // [rsp+0h] [rbp-A8h] BYREF
char v8[104]; // [rsp+40h] [rbp-68h] BYREF

v2 = a2[1];
if ( !(unsigned int)valid_key_length(v2) )
return 4294967292LL;
v3 = malloc(0x3C0uLL);
v4 = v3;
if ( !v3 )
return 4294967294LL;
v5 = a2[35];
*((_QWORD *)a2 + 18) = v3;
if ( v5 )
{
memcpy(v7, a2 + 19, (int)v2);
}
else
{
fill_region_from_string(v7, v2, a1);
v2 = a2[1];
}
AESF_bytes_to_block(v2, v7, v8);
if ( a2[39] )
hex_dump_region("AESF key material", v7, a2[1], 16LL);
AESF_key_schedule(v8, a2[1], *a2, v4);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, unsigned int *a2)
{
unsigned int v2; // ebp
void *v3; // rax
void *v4; // r12
unsigned int v5; // edx
_BYTE v7[64]; // [rsp+0h] [rbp-A8h] BYREF
char v8[104]; // [rsp+40h] [rbp-68h] BYREF

v2 = a2[1];
if ( !(unsigned int)func0(v2) )
return 4294967292LL;
v3 = malloc(0x3C0uLL);
v4 = v3;
if ( !v3 )
return 4294967294LL;
v5 = a2[35];
*((_QWORD *)a2 + 18) = v3;
if ( v5 )
{
memcpy(v7, a2 + 19, (int)v2);
}
else
{
fill_region_from_string(v7, v2, a1);
v2 = a2[1];
}
AESF_bytes_to_block(v2, v7, v8);
if ( a2[39] )
hex_dump_region("AESF key material", v7, a2[1], 16LL);
AESF_key_schedule(v8, a2[1], *a2, v4);
return 1LL;
}

original_code:
int AESF_make_key(
 char * key_material,
 block_cipher_instance_t * pciphinst)
{
 char full_key_material[64];
 AESF_key_schedule_t * pks;
 u32 key_mat_block[(256/32)];
 if (!valid_key_length(pciphinst->kl))
  return -4;
 pks = (AESF_key_schedule_t *)malloc(sizeof(AESF_key_schedule_t));
 if (pks == 0)
  return -2;
 pciphinst->pkey_schedule = pks;
 if (pciphinst->have_user_key_mat) {
  memcpy(full_key_material, pciphinst->user_key_mat,
   pciphinst->kl);
 }
 else {
  fill_region_from_string(full_key_material,
   pciphinst->kl, key_material);
 }
 AESF_bytes_to_block(pciphinst->kl, full_key_material, key_mat_block);
 if (pciphinst->alg_debug) {
  hex_dump_region("AESF key material",
   full_key_material,
   pciphinst->kl,16);
 }
 AESF_key_schedule(key_mat_block, pciphinst->kl,
  pciphinst->bl, pks->rk);
 return 1;
}

canonical_original_code:
int AESF_make_key(char *key_material, struct _block_cipher_instance_t *pciphinst)
{
 char full_key_material[64];
 struct _AESF_key_schedule_t *pks;
 unsigned long key_mat_block[-1];
 if (!valid_key_length(pciphinst->kl))
  return -4;
 pks = (struct _AESF_key_schedule_t *)malloc(sizeof(AESF_key_schedule_t));
 if (pks == 0)
  return -2;
 pciphinst->pkey_schedule = pks;
 if (pciphinst->have_user_key_mat) {
  memcpy(full_key_material, pciphinst->user_key_mat,
   pciphinst->kl);
 }
 else {
  fill_region_from_string(full_key_material,
   pciphinst->kl, key_material);
 }
 AESF_bytes_to_block(pciphinst->kl, full_key_material, key_mat_block);
 if (pciphinst->alg_debug) {
  hex_dump_region("AESF key material",
   full_key_material,
   pciphinst->kl,16);
 }
 AESF_key_schedule(key_mat_block, pciphinst->kl,
  pciphinst->bl, pks->rk);
 return 1;
}

variable_types: struct _block_cipher_instance_t { int bl; int kl; char user_IV[64]; int have_user_IV; char user_key_mat[64]; int have_user_key_mat; void *pkey_schedule; int do_cbc; int alg_debug; } *

variable_types: struct _AESF_key_schedule_t { unsigned long rk[-1][-1]; } *


decompiled_code:
void __fastcall AESF_free_key(__int64 a1, __int64 a2)
{
free(*(void **)(a2 + 144));
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1, __int64 a2)
{
free(*(void **)(a2 + 144));
}

original_code:
void AESF_free_key(
 char * key_material,
 block_cipher_instance_t * pciphinst)
{
 AESF_key_schedule_t * pkey =
  (AESF_key_schedule_t *)pciphinst->pkey_schedule;
 free(pkey);
}

canonical_original_code:
void AESF_free_key(char *key_material, struct _block_cipher_instance_t *pciphinst)
{
 struct _AESF_key_schedule_t *pkey = (AESF_key_schedule_t *)pciphinst->pkey_schedule;
 free(pkey);
}

user_defined_types: struct _block_cipher_instance_t { int bl; int kl; char user_IV[64]; int have_user_IV; char user_key_mat[64]; int have_user_key_mat; void *pkey_schedule; int do_cbc; int alg_debug; }

user_defined_types: struct _AESF_key_schedule_t { unsigned long rk[-1][-1]; }


decompiled_code:
__int64 __fastcall AESF_encrypt_bytes(__int64 a1, __int64 a2, unsigned int *a3)
{
__int64 v4; // r12
_BYTE v6[64]; // [rsp+0h] [rbp-98h] BYREF
char v7[88]; // [rsp+40h] [rbp-58h] BYREF

v4 = *((_QWORD *)a3 + 18);
AESF_bytes_to_block(*a3, a1, v6);
LODWORD(v4) = AESF_encrypt_block(v6, v7, a3[1], *a3, v4);
AESF_block_to_bytes(*a3, v7, a2);
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2, unsigned int *a3)
{
__int64 v4; // r12
_BYTE v6[64]; // [rsp+0h] [rbp-98h] BYREF
char v7[88]; // [rsp+40h] [rbp-58h] BYREF

v4 = *((_QWORD *)a3 + 18);
AESF_bytes_to_block(*a3, a1, v6);
LODWORD(v4) = AESF_encrypt_block(v6, v7, a3[1], *a3, v4);
AESF_block_to_bytes(*a3, v7, a2);
return (unsigned int)v4;
}

original_code:
int AESF_encrypt_bytes(
 char * bytes_in,
 char * bytes_out,
 block_cipher_instance_t * pciphinst)
{
 u32 block_in [(256/32)];
 u32 block_out[(256/32)];
 AESF_key_schedule_t * pkey =
  (AESF_key_schedule_t *)pciphinst->pkey_schedule;
 int rv;
 AESF_bytes_to_block(pciphinst->bl, bytes_in, block_in);
 rv = AESF_encrypt_block(block_in, block_out,
  pciphinst->kl, pciphinst->bl, pkey->rk);
 AESF_block_to_bytes(pciphinst->bl, block_out, bytes_out);
 return rv;
}

canonical_original_code:
int AESF_encrypt_bytes(char *bytes_in, char *bytes_out, struct _block_cipher_instance_t *pciphinst)
{
 unsigned long block_in[-1];
 unsigned long block_out[-1];
 struct _AESF_key_schedule_t *pkey = (AESF_key_schedule_t *)pciphinst->pkey_schedule;
 int rv;
 AESF_bytes_to_block(pciphinst->bl, bytes_in, block_in);
 rv = AESF_encrypt_block(block_in, block_out,
  pciphinst->kl, pciphinst->bl, pkey->rk);
 AESF_block_to_bytes(pciphinst->bl, block_out, bytes_out);
 return rv;
}

variable_types: rv int


decompiled_code:
__int64 __fastcall AESF_decrypt_bytes(__int64 a1, __int64 a2, unsigned int *a3)
{
__int64 v4; // r12
_BYTE v6[64]; // [rsp+0h] [rbp-98h] BYREF
char v7[88]; // [rsp+40h] [rbp-58h] BYREF

v4 = *((_QWORD *)a3 + 18);
AESF_bytes_to_block(*a3, a1, v6);
LODWORD(v4) = AESF_decrypt_block(v6, v7, a3[1], *a3, v4);
AESF_block_to_bytes(*a3, v7, a2);
return (unsigned int)v4;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2, unsigned int *a3)
{
__int64 v4; // r12
_BYTE v6[64]; // [rsp+0h] [rbp-98h] BYREF
char v7[88]; // [rsp+40h] [rbp-58h] BYREF

v4 = *((_QWORD *)a3 + 18);
AESF_bytes_to_block(*a3, a1, v6);
LODWORD(v4) = AESF_decrypt_block(v6, v7, a3[1], *a3, v4);
AESF_block_to_bytes(*a3, v7, a2);
return (unsigned int)v4;
}

original_code:
int AESF_decrypt_bytes(
 char * bytes_in,
 char * bytes_out,
 block_cipher_instance_t * pciphinst)
{
 u32 block_in [(256/32)];
 u32 block_out[(256/32)];
 AESF_key_schedule_t * pkey =
  (AESF_key_schedule_t *)pciphinst->pkey_schedule;
 int rv;
 AESF_bytes_to_block(pciphinst->bl, bytes_in, block_in);
 rv = AESF_decrypt_block(block_in, block_out,
  pciphinst->kl, pciphinst->bl, pkey->rk);
 AESF_block_to_bytes(pciphinst->bl, block_out, bytes_out);
 return rv;
}

canonical_original_code:
int AESF_decrypt_bytes(char *bytes_in, char *bytes_out, struct _block_cipher_instance_t *pciphinst)
{
 unsigned long block_in[-1];
 unsigned long block_out[-1];
 struct _AESF_key_schedule_t *pkey = (AESF_key_schedule_t *)pciphinst->pkey_schedule;
 int rv;
 AESF_bytes_to_block(pciphinst->bl, bytes_in, block_in);
 rv = AESF_decrypt_block(block_in, block_out,
  pciphinst->kl, pciphinst->bl, pkey->rk);
 AESF_block_to_bytes(pciphinst->bl, block_out, bytes_out);
 return rv;
}


decompiled_code:
__int64 __fastcall valid_key_length(int a1)
{
return (a1 == 32) | (unsigned __int8)((a1 & 0xFFFFFFF7) == 16);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
return (a1 == 32) | (unsigned __int8)((a1 & 0xFFFFFFF7) == 16);
}

original_code:
static int valid_key_length(
 int kl)
{
 if (kl == 16)
  return 1;
 else if (kl == 24)
  return 1;
 else if (kl == 32)
  return 1;
 else
  return 0;
}

canonical_original_code:
static int valid_key_length(int kl)
{
 if (kl == 16)
  return 1;
 else if (kl == 24)
  return 1;
 else if (kl == 32)
  return 1;
 else
  return 0;
}


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

if ( a1 > 0x20 )
result = 4294967285LL;
else
result = ((1LL << a1) & 0x101010000LL) == 0 ? -11 : 1;
return result;
}

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

if ( a1 > 0x20 )
result = 4294967285LL;
else
result = ((1LL << a1) & 0x101010000LL) == 0 ? -11 : 1;
return result;
}

original_code:
static int sfei_check_bl(
 int bl)
{
 switch (bl) {
 case 16:
 case 24:
 case 32:
  return 1;
 default:
  return -11;
 }
}

canonical_original_code:
static int sfei_check_bl(int bl)
{
 switch (bl) {
 case 16:
 case 24:
 case 32:
  return 1;
 default:
  return -11;
 }
}


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

if ( a1 > 0x20 )
result = 4294967284LL;
else
result = ((1LL << a1) & 0x101010000LL) == 0 ? -12 : 1;
return result;
}

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

if ( a1 > 0x20 )
result = 4294967284LL;
else
result = ((1LL << a1) & 0x101010000LL) == 0 ? -12 : 1;
return result;
}

original_code:
static int sfei_check_kl(
 int kl)
{
 switch (kl) {
 case 16:
 case 24:
 case 32:
  return 1;
 default:
  return -12;
 }
}

canonical_original_code:
static int sfei_check_kl(int kl)
{
 switch (kl) {
 case 16:
 case 24:
 case 32:
  return 1;
 default:
  return -12;
 }
}


decompiled_code:
const char *sfei_explain_error()
{
return "SFEI does not yet feel the need to explain itself";
}

canonical_decompiled_code:
const char *func3()
{
return "SFEI does not yet feel the need to explain itself";
}

original_code:
static char * sfei_explain_error(
 int error_code)
{
 return "SFEI does not yet feel the need to explain itself";
}

canonical_original_code:
static char *sfei_explain_error(int error_code)
{
 return "SFEI does not yet feel the need to explain itself";
}


decompiled_code:
void __fastcall sfei_free_key(__int64 a1, __int64 a2)
{
free(*(void **)(a2 + 144));
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1, __int64 a2)
{
free(*(void **)(a2 + 144));
}

original_code:
static void sfei_free_key(
 char * key_material,
 block_cipher_instance_t * pciphinst)
{
 char * ks = (char *)pciphinst->pkey_schedule;
 free(ks);
}

canonical_original_code:
static void sfei_free_key(char *key_material, struct _block_cipher_instance_t *pciphinst)
{
 char *ks = (char *)pciphinst->pkey_schedule;
 free(ks);
}

variable_types:
ks
char *


decompiled_code:
__int64 __fastcall sfei_make_key(char *s, __int64 a2)
{
void *v2; // rax
void *v3; // rbp
size_t v4; // rax
unsigned int v5; // er12

v2 = malloc(0x10uLL);
if ( !v2 )
return (unsigned int)-2;
*(_QWORD *)(a2 + 144) = v2;
v3 = v2;
v4 = strlen(s);
v5 = 1;
fill_region_from_other(v3, 16LL, s, v4);
if ( !*(_DWORD *)(a2 + 156) )
return v5;
hex_dump_region("SFEI KS", v3, 16LL, 4LL);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(char *s, __int64 a2)
{
void *v2; // rax
void *v3; // rbp
size_t v4; // rax
unsigned int v5; // er12

v2 = malloc(0x10uLL);
if ( !v2 )
return (unsigned int)-2;
*(_QWORD *)(a2 + 144) = v2;
v3 = v2;
v4 = strlen(s);
v5 = 1;
fill_region_from_other(v3, 16LL, s, v4);
if ( !*(_DWORD *)(a2 + 156) )
return v5;
hex_dump_region("SFEI KS", v3, 16LL, 4LL);
return 1LL;
}

original_code:
static int sfei_make_key(
 char * key_material,
 block_cipher_instance_t * pciphinst)
{
 char * ks;
 int rv = 1;
 int len;
 ks = (char *)malloc(sizeof(char) * 4 * 4);
 if (ks == 0)
  return -2;
 pciphinst->pkey_schedule = (void *)ks;
 len = strlen(key_material);
 fill_region_from_other(ks, 4 * 4, key_material, len);
 if (pciphinst->alg_debug)
  hex_dump_region("SFEI KS", ks, 4 * 4, 4);
 return rv;
}

canonical_original_code:
static int sfei_make_key(char *key_material, struct _block_cipher_instance_t *pciphinst)
{
 char *ks;
 int rv = 1;
 int len;
 ks = (char *)malloc(sizeof(char) * 4 * 4);
 if (ks == 0)
  return -2;
 pciphinst->pkey_schedule = (void *)ks;
 len = strlen(key_material);
 fill_region_from_other(ks, 4 * 4, key_material, len);
 if (pciphinst->alg_debug)
  hex_dump_region("SFEI KS", ks, 4 * 4, 4);
 return rv;
}

variable_types: len int


original_code:
static int sfei_encrypt_block(
 char * bytes_in,
 char * bytes_out,
 block_cipher_instance_t * pciphinst)
{
 char * ks = (char *)pciphinst->pkey_schedule;
 char * rk = &ks[0];
 int r;
 int i;
 if (pciphinst->alg_debug)
  dump("blin", bytes_in, (4 * 2));
 for (i = 0; i < (4 * 2); i++)
  bytes_out[i] = bytes_in[i];
 for (r = 0; r < 4; r++) {
  char * L = &bytes_out[0];
  char * R = &bytes_out[4];
  char Lt[4];
  char Rt[4];
  char fXK[4];
  f(fXK, R, rk);
  for (i = 0; i < 4; i++) {
   Lt[i] = R[i];
   Rt[i] = L[i] ^ fXK[i];
  }
  for (i = 0; i < 4; i++) {
   L[i] = Lt[i];
   R[i] = Rt[i];
  }
  if (pciphinst->alg_debug)
   dump3("rnd", "rk", "fXK",
    bytes_out, rk, fXK, (4 * 2), 4, 4);
  rk += 4;
 }
 if (pciphinst->alg_debug)
  fprintf(stderr, "\n");
 return 1;
}

canonical_original_code:
static int sfei_encrypt_block(char *bytes_in, char *bytes_out, struct _block_cipher_instance_t *pciphinst)
{
 char *ks = (char *)pciphinst->pkey_schedule;
 char *rk = &ks[0];
 int r;
 int i;
 if (pciphinst->alg_debug)
  dump("blin", bytes_in, (4 * 2));
 for (i = 0; i < (4 * 2); i++)
  bytes_out[i] = bytes_in[i];
 for (r = 0; r < 4; r++) {
  char *L = &bytes_out[0];
  char *R = &bytes_out[4];
  char Lt[4];
  char Rt[4];
  char fXK[4];
  f(fXK, R, rk);
  for (i = 0; i < 4; i++) {
   Lt[i] = R[i];
   Rt[i] = L[i] ^ fXK[i];
  }
  for (i = 0; i < 4; i++) {
   L[i] = Lt[i];
   R[i] = Rt[i];
  }
  if (pciphinst->alg_debug)
   dump3("rnd", "rk", "fXK",
    bytes_out, rk, fXK, (4 * 2), 4, 4);
  rk += 4;
 }
 if (pciphinst->alg_debug)
  fprintf(stderr, "\n");
 return 1;
}

variable_types:
rk
char *

variable_types: r int

variable_types: i int

variable_types:
L
char *

variable_types:
R
char *

variable_types:
Lt
char [4]

variable_types:
Rt
char [4]

variable_types:
fXK
char [4]


original_code:
static int sfei_decrypt_block(
 char * bytes_in,
 char * bytes_out,
 block_cipher_instance_t * pciphinst)
{
 char * ks = (char *)pciphinst->pkey_schedule;
 char * rk = &ks[(4 - 1) * 4];
 int r;
 int i;
 if (pciphinst->alg_debug)
  dump("blin", bytes_in, (4 * 2));
 for (i = 0; i < (4 * 2); i++)
  bytes_out[i] = bytes_in[i];
 for (r = 0; r < 4; r++) {
  char * L = &bytes_out[0];
  char * R = &bytes_out[4];
  char Lt[4];
  char Rt[4];
  char fXK[4];
  f(fXK, L, rk);
  for (i = 0; i < 4; i++) {
   Lt[i] = R[i] ^ fXK[i];
   Rt[i] = L[i];
  }
  for (i = 0; i < 4; i++) {
   L[i] = Lt[i];
   R[i] = Rt[i];
  }
  if (pciphinst->alg_debug)
   dump3("rnd", "rk", "fXK",
    bytes_out, rk, fXK, (4 * 2), 4, 4);
  rk -= 4;
 }
 if (pciphinst->alg_debug)
  fprintf(stderr, "\n");
 return 1;
}

canonical_original_code:
static int sfei_decrypt_block(char *bytes_in, char *bytes_out, struct _block_cipher_instance_t *pciphinst)
{
 char *ks = (char *)pciphinst->pkey_schedule;
 char *rk = &ks[(4 - 1) * 4];
 int r;
 int i;
 if (pciphinst->alg_debug)
  dump("blin", bytes_in, (4 * 2));
 for (i = 0; i < (4 * 2); i++)
  bytes_out[i] = bytes_in[i];
 for (r = 0; r < 4; r++) {
  char *L = &bytes_out[0];
  char *R = &bytes_out[4];
  char Lt[4];
  char Rt[4];
  char fXK[4];
  f(fXK, L, rk);
  for (i = 0; i < 4; i++) {
   Lt[i] = R[i] ^ fXK[i];
   Rt[i] = L[i];
  }
  for (i = 0; i < 4; i++) {
   L[i] = Lt[i];
   R[i] = Rt[i];
  }
  if (pciphinst->alg_debug)
   dump3("rnd", "rk", "fXK",
    bytes_out, rk, fXK, (4 * 2), 4, 4);
  rk -= 4;
 }
 if (pciphinst->alg_debug)
  fprintf(stderr, "\n");
 return 1;
}


original_code:
static int binv_encrypt_block(
 char * bytes_in,
 char * bytes_out,
 block_cipher_instance_t * pciphinst)
{
 int i;
 for (i = 0; i < pciphinst->bl; i++)
  *bytes_out++ = ~*bytes_in++;
 return 1;
}

canonical_original_code:
static int binv_encrypt_block(char *bytes_in, char *bytes_out, struct _block_cipher_instance_t *pciphinst)
{
 int i;
 for (i = 0; i < pciphinst->bl; i++)
  *bytes_out++ = ~*bytes_in++;
 return 1;
}