RemovePaybackFunction

decompiled_code:
void __fastcall RemovePaybackFunction(__int64 a1)
{
__int64 *v2; // rdi
__int64 *v3; // rdx

v2 = (__int64 *)paybacklist;
v3 = &paybacklist;
if ( paybacklist )
{
while ( *v2 != a1 )
{
v3 = v2 + 1;
v2 = (__int64 *)v2[1];
if ( !v2 )
return;
}
*v3 = v2[1];
mm_free(v2);
}
}

canonical_decompiled_code:
void __fastcall func11(__int64 a1)
{
__int64 *v2; // rdi
__int64 *v3; // rdx

v2 = (__int64 *)paybacklist;
v3 = &paybacklist;
if ( paybacklist )
{
while ( *v2 != a1 )
{
v3 = v2 + 1;
v2 = (__int64 *)v2[1];
if ( !v2 )
return;
}
*v3 = v2[1];
func1(v2);
}
}

original_code:
void RemovePaybackFunction(void (*function)(void))
{
  PaybackFunc **pbf;
  pbf=&paybacklist;
  while ((*pbf) && (*pbf)->function != function) pbf=&(*pbf)->next;
  if (*pbf) {
    PaybackFunc *h;
    h=*pbf;
    *pbf = h->next;
    mm_free(h);
  }
}

canonical_original_code:
void RemovePaybackFunction(void (*function)())
{
  struct _PaybackFunc **pbf;
  pbf=&paybacklist;
  while ((*pbf) && (*pbf)->function != function) pbf=&(*pbf)->next;
  if (*pbf) {
    struct _PaybackFunc *h;
    h=*pbf;
    *pbf = h->next;
    mm_free(h);
  }
}

variable_types:
function
void (*)()

variable_types: struct _PaybackFunc { void (*function)(); struct _PaybackFunc *next; } **


repo: jff/mathspad

decompiled_code:
int __fastcall button_enter(__int64 a1)
{
*(_DWORD *)(a1 + 24) = 1;
return button_draw(a1);
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1)
{
*(_DWORD *)(a1 + 24) = 1;
return func0(a1);
}

original_code:
static void button_enter(void *data)
{
    BUTTONINFO *binfo = (BUTTONINFO *) data;
    binfo->inside = 1;
    button_draw(data);
}

canonical_original_code:
static void button_enter(void *data)
{
    struct BUTTONINFO *binfo = (BUTTONINFO *) data;
    binfo->inside = 1;
    button_draw(data);
}

variable_types:
data
void *

variable_types: struct BUTTONINFO { unsigned long win_id; int number; unsigned int but_width; int pressed; unsigned short *text; int length; int border; void *data; void (*funcpress[3])(void *, int); void (*funcrelease[3])(void *, int); } *

return_type: void


decompiled_code:
int __fastcall button_leave(__int64 a1)
{
*(_DWORD *)(a1 + 24) = 0;
return button_draw(a1);
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1)
{
*(_DWORD *)(a1 + 24) = 0;
return func0(a1);
}

original_code:
static void button_leave(void *data)
{
    BUTTONINFO *binfo = (BUTTONINFO *) data;
    binfo->inside = 0;
    button_draw(data);
}

canonical_original_code:
static void button_leave(void *data)
{
    struct BUTTONINFO *binfo = (BUTTONINFO *) data;
    binfo->inside = 0;
    button_draw(data);
}

user_defined_types: struct BUTTONINFO { unsigned long win_id; int number; unsigned int but_width; int pressed; unsigned short *text; int length; int border; void *data; void (*funcpress[3])(void *, int); void (*funcrelease[3])(void *, int); }


decompiled_code:
__int64 __fastcall button_width(__int64 a1)
{
int v1; // ebx

push_attributes(0LL);
v1 = string_width(a1, 0xFFFFFFFFLL);
pop_attributes();
return (unsigned int)(v1 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
int v1; // ebx

push_attributes(0LL);
v1 = string_width(a1, 0xFFFFFFFFLL);
pop_attributes();
return (unsigned int)(v1 + 8);
}

original_code:
unsigned int button_width(Uchar *txt)
{
    int i;
    push_attributes(0);
    i = 2+3*2 + string_width(txt, -1);
    pop_attributes();
    return i;
}

canonical_original_code:
unsigned int button_width(unsigned short *txt)
{
    int i;
    push_attributes(0);
    i = 2+3*2 + string_width(txt, -1);
    pop_attributes();
    return i;
}

variable_types:
txt
unsigned short *

variable_types: i int

return_type: unsigned int


decompiled_code:
__int64 button_init()
{
button_mask = 26666LL;
button_attr.background_pixel = white_pixel;
button_attr.border_pixel = black_pixel;
button_attr.colormap = colormap;
button_attr.win_gravity = 1;
button_attr.event_mask = 237756LL;
button_attr.cursor = XCreateFontCursor(display, 0x3Cu);
push_attributes(0LL);
button_height = font_height() + 6;
return pop_attributes();
}

canonical_decompiled_code:
__int64 func6()
{
button_mask = 26666LL;
button_attr.background_pixel = white_pixel;
button_attr.border_pixel = black_pixel;
button_attr.colormap = colormap;
button_attr.win_gravity = 1;
button_attr.event_mask = 237756LL;
button_attr.cursor = XCreateFontCursor(display, 0x3Cu);
push_attributes(0LL);
button_height = font_height() + 6;
return pop_attributes();
}

original_code:
void button_init(void)
{
    button_mask =
 ((1L<<1) | (1L<<3) | (1L<<14) | (1L<<5) |
  (1L<<13) | (1L<<11));
    button_attr.background_pixel = white_pixel;
    button_attr.border_pixel = black_pixel;
    button_attr.colormap = colormap;
    button_attr.win_gravity = 1;
    button_attr.event_mask = ((1L<<15) | (1L<<2) |
         (1L<<3) | (1L<<13) |
         (1L<<17) | (1L<<7) |
                              (1L<<4) | (1L<<5) |
         (1L<<16));
    button_attr.cursor = XCreateFontCursor(display,60);
    push_attributes(0);
    button_height = 3*2+font_height();
    pop_attributes();
}

canonical_original_code:
void button_init()
{
    button_mask =
 ((1L<<1) | (1L<<3) | (1L<<14) | (1L<<5) |
  (1L<<13) | (1L<<11));
    button_attr.background_pixel = white_pixel;
    button_attr.border_pixel = black_pixel;
    button_attr.colormap = colormap;
    button_attr.win_gravity = 1;
    button_attr.event_mask = ((1L<<15) | (1L<<2) |
         (1L<<3) | (1L<<13) |
         (1L<<17) | (1L<<7) |
                              (1L<<4) | (1L<<5) |
         (1L<<16));
    button_attr.cursor = XCreateFontCursor(display,60);
    push_attributes(0);
    button_height = 3*2+font_height();
    pop_attributes();
}


decompiled_code:
void __fastcall button_stick(int a1)
{
button_attr.win_gravity = a1;
}

canonical_decompiled_code:
void __fastcall func7(int a1)
{
button_attr.win_gravity = a1;
}

original_code:
void button_stick(int gravity)
{
    button_attr.win_gravity=gravity;
}

variable_types: gravity int


decompiled_code:
int __fastcall button_move(Window *a1, int a2, int a3)
{
return XMoveWindow(display, *a1, a2, a3);
}

canonical_decompiled_code:
int __fastcall func8(Window *a1, int a2, int a3)
{
return XMoveWindow(display, *a1, a2, a3);
}

original_code:
void button_move(void *data, int x, int y)
{
    BUTTONINFO *binfo = (BUTTONINFO*) data;
    XMoveWindow(display, binfo->win_id, x, y);
}

canonical_original_code:
void button_move(void *data, int x, int y)
{
    struct BUTTONINFO *binfo = (BUTTONINFO*) data;
    XMoveWindow(display, binfo->win_id, x, y);
}

variable_types: x int

variable_types: y int


FifoMake

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

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

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

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

original_code:
FifoList *FifoMake(void)
{
  FIFOList *fl;
  fl=mm_malloc(sizeof(FIFOList));
  if (!fl) return (FifoList*)fl;
  fl->first=0;
  fl->last=0;
  fl->length=0;
  return (FifoList*)fl;
}

canonical_original_code:
struct _FifoList *FifoMake()
{
  struct _FIFOList *fl;
  fl=mm_malloc(sizeof(FIFOList));
  if (!fl) return (struct _FifoList *)fl;
  fl->first=0;
  fl->last=0;
  fl->length=0;
  return (struct _FifoList *)fl;
}

variable_types: struct _FIFOList { struct _ObjectList { void *object; struct _ObjectList *next; } *first; struct _ObjectList *last; int length; } *

return_type: struct _FifoList { void *first; void *last; int length; } *

user_defined_types: struct _FIFOList { struct _ObjectList *first; struct _ObjectList *last; int length; }


FifoPop

decompiled_code:
__int64 __fastcall FifoPop(__int64 a1)
{
int v1; // eax
__int64 *v2; // rbp
__int64 v3; // r12

if ( !a1 )
return 0LL;
v1 = *(_DWORD *)(a1 + 16);
if ( !v1 )
return 0LL;
*(_DWORD *)(a1 + 16) = v1 - 1;
v2 = *(__int64 **)a1;
if ( *(_QWORD *)a1 )
{
v3 = *v2;
*(_QWORD *)a1 = v2[1];
FreeList_free(&freeobjects, v2);
if ( !*(_DWORD *)(a1 + 16) )
{
if ( *(_QWORD *)a1 )
{
fwrite("Bad FIFO stack. Should be empty (memory leaked)\n", 1uLL, 0x30uLL, stderr);
*(_QWORD *)a1 = 0LL;
}
*(_QWORD *)(a1 + 8) = *(_QWORD *)a1;
}
}
else
{
fwrite("Bad FIFO stack. Should contain elements\n", 1uLL, 0x28uLL, stderr);
v3 = 0LL;
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
int v1; // eax
__int64 *v2; // rbp
__int64 v3; // r12

if ( !a1 )
return 0LL;
v1 = *(_DWORD *)(a1 + 16);
if ( !v1 )
return 0LL;
*(_DWORD *)(a1 + 16) = v1 - 1;
v2 = *(__int64 **)a1;
if ( *(_QWORD *)a1 )
{
v3 = *v2;
*(_QWORD *)a1 = v2[1];
FreeList_free(&freeobjects, v2);
if ( !*(_DWORD *)(a1 + 16) )
{
if ( *(_QWORD *)a1 )
{
fwrite("Bad FIFO stack. Should be empty (memory leaked)\n", 1uLL, 0x30uLL, stderr);
*(_QWORD *)a1 = 0LL;
}
*(_QWORD *)(a1 + 8) = *(_QWORD *)a1;
}
}
else
{
fwrite("Bad FIFO stack. Should contain elements\n", 1uLL, 0x28uLL, stderr);
v3 = 0LL;
}
return v3;
}

original_code:
void *FifoPop(FifoList *flist)
{
  FIFOList *fl = (FIFOList*) flist;
  void *res;
  ObjectList *obl;
  if (!fl || !fl->length) return 0;
  fl->length--;
  if (!fl->first) {
    fprintf(stderr, "Bad FIFO stack. Should contain elements\n");
    return 0;
  }
  res=fl->first->object;
  obl=fl->first;
  fl->first=obl->next;
  FreeList_free(&freeobjects, (obl));
  if (!fl->length) {
    if (fl->first) {
      fprintf(stderr, "Bad FIFO stack. Should be empty (memory leaked)\n");
      fl->first=0;
    }
    fl->last=fl->first;
  }
  return res;
}

canonical_original_code:
void *FifoPop(struct _FifoList *flist)
{
  struct _FIFOList *fl = (FIFOList*) flist;
  void *res;
  struct _ObjectList *obl;
  if (!fl || !fl->length) return 0;
  fl->length--;
  if (!fl->first) {
    fprintf(stderr, "Bad FIFO stack. Should contain elements\n");
    return 0;
  }
  res=fl->first->object;
  obl=fl->first;
  fl->first=obl->next;
  FreeList_free(&freeobjects, (obl));
  if (!fl->length) {
    if (fl->first) {
      fprintf(stderr, "Bad FIFO stack. Should be empty (memory leaked)\n");
      fl->first=0;
    }
    fl->last=fl->first;
  }
  return res;
}

variable_types: struct _FifoList { void *first; void *last; int length; } *

variable_types:
res
void *

variable_types: struct _ObjectList { void *object; struct _ObjectList *next; } *

return_type: void *


FifoDestroy

decompiled_code:
__int64 __fastcall FifoDestroy(__int64 a1, void (__fastcall *a2)(_QWORD))
{
FifoClear(a1, a2);
return mm_free(a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, void (__fastcall *a2)(_QWORD))
{
FifoClear(a1, a2);
return mm_free(a1);
}

original_code:
void FifoDestroy(FifoList *flist, void (*destfunc)(void*))
{
  FifoClear(flist,destfunc);
  mm_free(flist);
}

canonical_original_code:
void FifoDestroy(struct _FifoList *flist, void (*destfunc)(void *))
{
  FifoClear(flist,destfunc);
  mm_free(flist);
}

variable_types:
destfunc
void (*)(void *)

user_defined_types: struct _FifoList { void *first; void *last; int length; }


empcall

decompiled_code:
__int64 __fastcall empcall(__int64 (*a1)(void))
{
return a1();
}

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

original_code:
static int empcall(int (*fcal)(), void **args __attribute__((unused)))
{
    return (*fcal)();
}

canonical_original_code:
static int empcall(int (*fcal)(), void **args)
{
    return (*fcal)();
}

variable_types:
fcal
int (*)()

variable_types:
args
void **

return_type: int


refcall

decompiled_code:
__int64 __fastcall refcall(__int64 (__fastcall *a1)(_QWORD), _QWORD **a2)
{
return a1(**a2);
}

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

original_code:
static int refcall(int (*fcal)(), void **args)
{
    return (*fcal)(*((void**)args[0]));
}

canonical_original_code:
static int refcall(int (*fcal)(), void **args)
{
    return (*fcal)(*((void **)args[0]));
}


intcall

decompiled_code:
__int64 __fastcall intcall(__int64 (__fastcall *a1)(_QWORD), unsigned int **a2)
{
return a1(**a2);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 (__fastcall *a1)(_QWORD), unsigned int **a2)
{
return a1(**a2);
}

original_code:
static int intcall(int(*fcal)(), void **args)
{
    return (*fcal)(*((int*)args[0]));
}

canonical_original_code:
static int intcall(int (*fcal)(), void **args)
{
    return (*fcal)(*((int *)args[0]));
}


protocmp

original_code:
static int protocmp(const void *pr1, const void *pr2)
{
    int i=0,l;
    Prototype *p1= (Prototype*)pr1;
    Prototype *p2= (Prototype*)pr2;
    if (p1->n < p2->n) l=p1->n; else l=p2->n;
    while (i<l && p1->type[i]==p2->type[i]) i++;
    if (i==l) {
      if (p1->n==p2->n) {
 if (p1->restype==p2->restype)
   return 0;
 else
   return (p1->restype < p2->restype ? -1 : 1);
      } else {
 return p1->n - p2->n;
      }
    } else
      return (p1->type[i] < p2->type[i] ? -1:1);
}

canonical_original_code:
static int protocmp(void *pr1, void *pr2)
{
    int i = 0; int l;
    struct Prototype *p1 = (Prototype*)pr1;
    struct Prototype *p2 = (Prototype*)pr2;
    if (p1->n < p2->n) l=p1->n; else l=p2->n;
    while (i<l && p1->type[i]==p2->type[i]) i++;
    if (i==l) {
      if (p1->n==p2->n) {
 if (p1->restype==p2->restype)
   return 0;
 else
   return (p1->restype < p2->restype ? -1 : 1);
      } else {
 return p1->n - p2->n;
      }
    } else
      return (p1->type[i] < p2->type[i] ? -1:1);
}

variable_types: l int

variable_types: struct Prototype { unsigned int *type; int n; unsigned int restype; int max; int (*caller)(); } *


decompiled_code:
__int64 __fastcall define_prototype(void *src, int a2, int a3, __int64 a4)
{
size_t v5; // rbx
char *v6; // r12
void *v7; // [rsp+0h] [rbp-38h] BYREF
int v8; // [rsp+8h] [rbp-30h]
int v9; // [rsp+Ch] [rbp-2Ch]
int v10; // [rsp+10h] [rbp-28h]
__int64 v11; // [rsp+18h] [rbp-20h]

v7 = src;
v8 = a2;
v9 = a3;
v10 = a2;
v11 = a4;
if ( !LT_member(&prototree, &v7) )
{
v5 = 4LL * (a2 + 1);
v6 = (char *)malloc(v5);
v7 = v6;
memcpy(v6, src, v5 - 4);
*(_DWORD *)&v6[v5 - 4] = 0;
LT_insert(&prototree, &v7);
}
return LT_found_leaf();
}

canonical_decompiled_code:
__int64 __fastcall func4(void *src, int a2, int a3, __int64 a4)
{
size_t v5; // rbx
char *v6; // r12
void *v7; // [rsp+0h] [rbp-38h] BYREF
int v8; // [rsp+8h] [rbp-30h]
int v9; // [rsp+Ch] [rbp-2Ch]
int v10; // [rsp+10h] [rbp-28h]
__int64 v11; // [rsp+18h] [rbp-20h]

v7 = src;
v8 = a2;
v9 = a3;
v10 = a2;
v11 = a4;
if ( !LT_member(&prototree, &v7) )
{
v5 = 4LL * (a2 + 1);
v6 = (char *)malloc(v5);
v7 = v6;
memcpy(v6, src, v5 - 4);
*(_DWORD *)&v6[v5 - 4] = 0;
LT_insert(&prototree, &v7);
}
return LT_found_leaf();
}

original_code:
Prototype *define_prototype(const Type *typelist, const int n,
       const Type restype, int (*caller)())
{
    Prototype p;
    p.type = (Type*) typelist;
    p.n=n;
    p.restype=restype;
    p.max=n;
    p.caller=caller;
    if (!LT_member(&prototree, &p)) {
 p.type = malloc(sizeof(Type)*(n+1));
 memcpy(p.type, typelist, sizeof(Type)*n);
 p.type[n]=0;
 LT_insert(&prototree, &p);
    }
    return LT_found_leaf();
}

canonical_original_code:
struct Prototype *define_prototype(unsigned int *typelist, int n, unsigned int restype, int (*caller)())
{
    struct Prototype p;
    p.type = (unsigned int *) typelist;
    p.n=n;
    p.restype=restype;
    p.max=n;
    p.caller=caller;
    if (!LT_member(&prototree, &p)) {
 p.type = malloc(sizeof(Type)*(n+1));
 memcpy(p.type, typelist, sizeof(Type)*n);
 p.type[n]=0;
 LT_insert(&prototree, &p);
    }
    return LT_found_leaf();
}

variable_types:
typelist
unsigned int *

variable_types: n int

variable_types:
restype
unsigned int

variable_types:
caller
int (*)()

return_type: struct Prototype { unsigned int *type; int n; unsigned int restype; int max; int (*caller)(); } *


decompiled_code:
__int64 __fastcall make_value_prototype(_DWORD *a1, int a2, int a3, __int64 a4)
{
_DWORD *v7; // rax
_DWORD *v8; // rdx
__int64 v9; // rsi
_BYTE v11[1032]; // [rsp+0h] [rbp-408h] BYREF

if ( a2 > 0 )
{
v7 = a1;
v8 = v11;
v9 = (__int64)&a1[4 * (a2 - 1) + 4];
do
{
*v8 = *v7;
v7 += 4;
++v8;
}
while ( v7 != (_DWORD *)v9 );
}
return define_prototype(v11, a2, a3, a4);
}

original_code:
Prototype *make_value_prototype(const Value *valuelist, const int n,
    Type result, int (*caller)())
{
    Type typelist[256];
    int i;
    for (i=0; i<n; i++) typelist[i]=valuelist[i].type;
    return define_prototype(typelist, n,result, caller);
}

canonical_original_code:
struct Prototype *make_value_prototype(struct Value *valuelist, int n, unsigned int result, int (*caller)())
{
    unsigned int typelist[256];
    int i;
    for (i=0; i<n; i++) typelist[i]=valuelist[i].type;
    return define_prototype(typelist, n,result, caller);
}

variable_types: struct Value { unsigned int type; union TVal { int ival; double rval; void *stval; int *iref; double *rref; void **stref; } val; } *

variable_types:
result
unsigned int

variable_types:
typelist
unsigned int [256]

variable_types: i int

user_defined_types: struct Value { unsigned int type; union TVal val; }

user_defined_types: struct Prototype { unsigned int *type; int n; unsigned int restype; int max; int (*caller)(); }


decompiled_code:
__int64 __fastcall proto_add_to_database(__int64 a1)
{
__int64 result; // rax
void *v2; // [rsp+0h] [rbp-38h] BYREF
int v3; // [rsp+8h] [rbp-30h]
int v4; // [rsp+Ch] [rbp-2Ch]
int v5; // [rsp+10h] [rbp-28h]
__int64 v6; // [rsp+18h] [rbp-20h]

result = a1;
if ( a1 )
{
result = LT_member(&prototree, a1);
if ( !result )
{
v5 = *(_DWORD *)(a1 + 8);
v3 = v5;
v4 = *(_DWORD *)(a1 + 12);
v6 = *(_QWORD *)(a1 + 24);
v2 = malloc(4LL * v5);
memcpy(v2, *(const void **)a1, 4LL * v5);
LT_insert(&prototree, &v2);
result = LT_found_leaf(&prototree, &v2);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
__int64 result; // rax
void *v2; // [rsp+0h] [rbp-38h] BYREF
int v3; // [rsp+8h] [rbp-30h]
int v4; // [rsp+Ch] [rbp-2Ch]
int v5; // [rsp+10h] [rbp-28h]
__int64 v6; // [rsp+18h] [rbp-20h]

result = a1;
if ( a1 )
{
result = LT_member(&prototree, a1);
if ( !result )
{
v5 = *(_DWORD *)(a1 + 8);
v3 = v5;
v4 = *(_DWORD *)(a1 + 12);
v6 = *(_QWORD *)(a1 + 24);
v2 = malloc(4LL * v5);
memcpy(v2, *(const void **)a1, 4LL * v5);
LT_insert(&prototree, &v2);
result = LT_found_leaf(&prototree, &v2);
}
}
return result;
}

original_code:
Prototype *proto_add_to_database(Prototype *proto)
{
    Prototype *retval=0;
    if (proto) {
 if (!((retval = LT_member(&prototree, proto)))) {
     Prototype p;
     p.n=p.max=proto->n;
     p.restype=proto->restype;
     p.caller=proto->caller;
     p.type=malloc(sizeof(Type)*p.n);
     memcpy(p.type, proto->type, sizeof(Type)*p.n);
     LT_insert(&prototree, &p);
     retval=LT_found_leaf();
 }
    }
    return retval;
}

canonical_original_code:
struct Prototype *proto_add_to_database(struct Prototype *proto)
{
    struct Prototype *retval = 0;
    if (proto) {
 if (!((retval = LT_member(&prototree, proto)))) {
     struct Prototype p;
     p.n=p.max=proto->n;
     p.restype=proto->restype;
     p.caller=proto->caller;
     p.type=malloc(sizeof(Type)*p.n);
     memcpy(p.type, proto->type, sizeof(Type)*p.n);
     LT_insert(&prototree, &p);
     retval=LT_found_leaf();
 }
    }
    return retval;
}

variable_types:
proto
struct Prototype *

variable_types: struct Prototype { unsigned int *type; int n; unsigned int restype; int max; int (*caller)(); }


decompiled_code:
__int64 __fastcall add_type(__int64 a1, int a2)
{
int v3; // eax
int v4; // er12
_DWORD *v5; // rdi
void *v6; // rax
_DWORD *v7; // rdx
int v8; // eax

v3 = *(_DWORD *)(a1 + 16);
if ( *(_DWORD *)(a1 + 8) > v3 )
goto LABEL_6;
v4 = v3 + 4;
v5 = *(_DWORD **)a1;
if ( v5 )
v6 = realloc(v5, 4LL * v4);
else
v6 = malloc(4LL * v4);
if ( v6 )
{
*(_QWORD *)a1 = v6;
*(_DWORD *)(a1 + 16) = v4;
LABEL_6:
v7 = *(_DWORD **)a1;
v8 = *(_DWORD *)(a1 + 8);
*(_DWORD *)(a1 + 8) = v8 + 1;
v7[v8] = a2;
return 0LL;
}
return 1LL;
}

original_code:
int add_type(Prototype *p, const Type type)
{
    if (p->n <= p->max) {
 int ns=p->max+4;
 Type *nt;
 if (p->type) {
     nt=realloc(p->type, sizeof(Type)*ns);
 } else {
     nt=malloc(sizeof(Type)*ns);
 }
 if (!nt) return 1;
 p->type=nt;
 p->max=ns;
    }
    p->type[p->n++]=type;
    return 0;
}

canonical_original_code:
int add_type(struct Prototype *p, unsigned int type)
{
    if (p->n <= p->max) {
 int ns = p->max+4;
 unsigned int *nt;
 if (p->type) {
     nt=realloc(p->type, sizeof(Type)*ns);
 } else {
     nt=malloc(sizeof(Type)*ns);
 }
 if (!nt) return 1;
 p->type=nt;
 p->max=ns;
    }
    p->type[p->n++]=type;
    return 0;
}

variable_types:
type
unsigned int

variable_types: ns int

variable_types:
nt
unsigned int *


decompiled_code:
void __fastcall add_result_type(__int64 a1, int a2)
{
if ( a1 )
*(_DWORD *)(a1 + 12) = a2;
}

canonical_decompiled_code:
void __fastcall func8(__int64 a1, int a2)
{
if ( a1 )
*(_DWORD *)(a1 + 12) = a2;
}

original_code:
int add_result_type(Prototype *prototype, const Type type)
{
  if (prototype) {
    prototype->restype=type;
  }
}

canonical_original_code:
int add_result_type(struct Prototype *prototype, unsigned int type)
{
  if (prototype) {
    prototype->restype=type;
  }
}


decompiled_code:
void __fastcall destroy_prototype(void *ptr)
{
void *v2; // rdi

if ( ptr )
{
v2 = *(void **)ptr;
if ( v2 )
free(v2);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func9(void *ptr)
{
void *v2; // rdi

if ( ptr )
{
v2 = *(void **)ptr;
if ( v2 )
free(v2);
free(ptr);
}
}

original_code:
void destroy_prototype(Prototype *p)
{
    if (p) {
 if (p->type) free(p->type);
 free(p);
    }
}

canonical_original_code:
void destroy_prototype(struct Prototype *p)
{
    if (p) {
 if (p->type) free(p->type);
 free(p);
    }
}


decompiled_code:
__int64 __fastcall matches_prototype(__int64 a1, __int64 *a2, int a3)
{
__int64 v3; // rsi
__int64 v4; // rcx
__int64 v5; // rdx
int v6; // eax

if ( a3 <= 0 )
return 1LL;
v3 = *a2;
v4 = (unsigned int)a3;
v5 = 0LL;
while ( 1 )
{
v6 = *(_DWORD *)(v3 + 4 * v5) ^ *(_DWORD *)(a1 + 4 * v5);
if ( (v6 & 0x1FFF) != 0 || v6 == 49152 )
break;
if ( ++v5 == v4 )
return 1LL;
}
return 0LL;
}

original_code:
int matches_prototype(Type *typelist, Prototype *p, int nr)
{
    int i;
    for (i=0; i<nr; i++) {
 if (!(((!(((typelist[i])^(p->type[i]))&0x1FFF)) && (((typelist[i])^(p->type[i]))!=0xC000)))) return 0;
    }
    return 1;
}

canonical_original_code:
int matches_prototype(unsigned int *typelist, struct Prototype *p, int nr)
{
    int i;
    for (i=0; i<nr; i++) {
 if (!(((!(((typelist[i])^(p->type[i]))&0x1FFF)) && (((typelist[i])^(p->type[i]))!=0xC000)))) return 0;
    }
    return 1;
}

variable_types: nr int


protoinit

decompiled_code:
void **protoinit()
{
void **result; // rax
void **v1; // rbx

result = &protopredef;
if ( *((_DWORD *)&protopredef + 4) )
{
v1 = &protopredef;
do
{
result = (void **)LT_insert(&prototree, v1);
v1 += 4;
}
while ( *((_DWORD *)v1 + 4) );
}
return result;
}

canonical_decompiled_code:
void **func11()
{
void **result; // rax
void **v1; // rbx

result = &protopredef;
if ( *((_DWORD *)&protopredef + 4) )
{
v1 = &protopredef;
do
{
result = (void **)LT_insert(&prototree, v1);
v1 += 4;
}
while ( *((_DWORD *)v1 + 4) );
}
return result;
}

original_code:
void protoinit(void)
{
    int i;
    i=0;
    while (protopredef[i].max) {
 LT_insert(&prototree, &protopredef[i]);
 i++;
    }
}

canonical_original_code:
void protoinit()
{
    int i;
    i=0;
    while (protopredef[i].max) {
 LT_insert(&prototree, &protopredef[i]);
 i++;
    }
}


decompiled_code:
__int64 __fastcall hash_string(char *a1)
{
char v1; // al
int v2; // edx
int v3; // ecx
unsigned int v4; // esi

if ( !a1 )
return 0;
v1 = *a1;
if ( !*a1 )
return 0;
v2 = 0;
v3 = 0;
v4 = 0;
do
{
v4 ^= v1 << v3;
v3 = (v3 + 5) % 23;
++a1;
++v2;
v1 = *a1;
}
while ( v2 <= 14 && v1 );
return v4;
}

original_code:
static int hash_string(char *str)
{
  int i,k,j;
  i=0; k=0;j=0;
  if (!str) return 0;
  while (*str && j<15) {
    i=i^((*str)<<k);
    (k) = ((k)+5)%23;
    str++;
    j++;
  }
  return i;
}

canonical_original_code:
static int hash_string(char *str)
{
  int i; int k; int j;
  i=0; k=0;j=0;
  if (!str) return 0;
  while (*str && j<15) {
    i=i^((*str)<<k);
    (k) = ((k)+5)%23;
    str++;
    j++;
  }
  return i;
}

variable_types:
str
char *

variable_types: k int

variable_types: j int


original_code:
static TransLang *new_language(void)
{
  TransLang *tlang;
  int i;
  tlang = mm_malloc(sizeof(TransLang));
  tlang->languagecode=0;
  tlang->langname=0;
  tlang->entries=0;
  tlang->hashsize=7;
  tlang->translist = mm_malloc(sizeof(Translation*)*7);
  for (i=0; i<7; i++) {
    tlang->translist[i]=0;
  }
  return tlang;
}

canonical_original_code:
static struct TransLang *new_language()
{
  struct TransLang *tlang;
  int i;
  tlang = mm_malloc(sizeof(TransLang));
  tlang->languagecode=0;
  tlang->langname=0;
  tlang->entries=0;
  tlang->hashsize=7;
  tlang->translist = mm_malloc(sizeof(struct Translation *)*7);
  for (i=0; i<7; i++) {
    tlang->translist[i]=0;
  }
  return tlang;
}

variable_types: struct TransLang { unsigned short *langname; int languagecode; int entries; int hashsize; struct Translation { char *original; unsigned short *translate; int hashvalue; int autoconv; struct Translation *next; } **translist; } *

user_defined_types: struct TransLang { unsigned short *langname; int languagecode; int entries; int hashsize; struct Translation **translist; }


original_code:
static void rehash_translang(TransLang *transl)
{
  if (transl->entries/transl->hashsize > 6) {
    int i;
    int nhs;
    Translation **tlist;
    nhs = transl->hashsize*2+1;
    tlist = mm_malloc(sizeof(Translation*)*nhs);
    for (i=0; i<nhs; i++) tlist[i]=0;
    for (i=0; i<transl->hashsize; i++) {
      Translation *tl, *tlh, *tlg;
      tl = transl->translist[i];
      tlh=0;
      while (tl) {
 tlg=tl;
 tl=tl->next;
 tlg->next=tlh;
 tlh=tlg;
      }
      tl = tlh;
      while (tl) {
 tlh=tl->next;
 tl->next=tlist[tl->hashvalue%nhs];
 tlist[tl->hashvalue%nhs]=tl;
 tl=tlh;
      }
    }
    mm_free(transl->translist);
    transl->translist=tlist;
    transl->hashsize=nhs;
  }
}

canonical_original_code:
static void rehash_translang(struct TransLang *transl)
{
  if (transl->entries/transl->hashsize > 6) {
    int i;
    int nhs;
    struct Translation **tlist;
    nhs = transl->hashsize*2+1;
    tlist = mm_malloc(sizeof(struct Translation *)*nhs);
    for (i=0; i<nhs; i++) tlist[i]=0;
    for (i=0; i<transl->hashsize; i++) {
      struct Translation *tl; struct Translation *tlh; struct Translation *tlg;
      tl = transl->translist[i];
      tlh=0;
      while (tl) {
 tlg=tl;
 tl=tl->next;
 tlg->next=tlh;
 tlh=tlg;
      }
      tl = tlh;
      while (tl) {
 tlh=tl->next;
 tl->next=tlist[tl->hashvalue%nhs];
 tlist[tl->hashvalue%nhs]=tl;
 tl=tlh;
      }
    }
    mm_free(transl->translist);
    transl->translist=tlist;
    transl->hashsize=nhs;
  }
}

variable_types: nhs int

variable_types: struct Translation { char *original; unsigned short *translate; int hashvalue; int autoconv; struct Translation *next; } **


translate

decompiled_code:
__int64 __fastcall translate(char *s2)
{
int v1; // ebp
__int64 v2; // rbx
int v3; // er14
__int64 v4; // rbx
__int64 v5; // rax
__int64 v6; // rdx
__int64 v7; // rax
__int64 v8; // rdi

if ( !s2 )
return 0LL;
v1 = hash_string(s2);
if ( !currentlang )
currentlang = new_language();
v2 = *(_QWORD *)(*(_QWORD *)(currentlang + 24) + 8LL * (v1 % *(_DWORD *)(currentlang + 16)));
if ( v2 )
{
while ( *(_DWORD *)(v2 + 16) != v1 || strcmp(*(const char **)v2, s2) )
{
v2 = *(_QWORD *)(v2 + 24);
if ( !v2 )
goto LABEL_5;
}
v4 = *(_QWORD *)(v2 + 8);
}
else
{
LABEL_5:
v3 = strlen(s2);
v4 = mm_malloc(2LL * (v3 + 1));
v5 = 0LL;
if ( v3 + 1 > 0 )
{
do
{
*(_WORD *)(v4 + 2 * v5) = s2[v5];
v6 = v5++;
}
while ( v6 != v3 );
}
v7 = mm_malloc(32LL);
*(_DWORD *)(v7 + 16) = v1;
*(_QWORD *)v7 = s2;
*(_QWORD *)(v7 + 8) = v4;
*(_DWORD *)(v7 + 20) = 1;
v8 = currentlang;
*(_QWORD *)(v7 + 24) = *(_QWORD *)(*(_QWORD *)(currentlang + 24) + 8LL * (v1 % *(_DWORD *)(currentlang + 16)));
*(_QWORD *)(*(_QWORD *)(v8 + 24) + 8LL * (v1 % *(_DWORD *)(v8 + 16))) = v7;
++*(_DWORD *)(v8 + 12);
rehash_translang(v8);
}
return v4;
}

original_code:
Uchar *translate(char *orig)
{
  int i;
  Translation *tl;
  if (!orig) return 0;
  i=hash_string(orig);
  if (!currentlang) currentlang=new_language();
  tl = currentlang->translist[i%currentlang->hashsize];
  while (tl && (tl->hashvalue!=i || strcmp(tl->original, orig))) tl=tl->next;
  if (tl) {
    return tl->translate;
  } else {
    int l,n;
    Uchar *trans;
    l=strlen(orig)+1;
    trans = mm_malloc(sizeof(Uchar)*l);
    for (n=0; n<l; n++) trans[n]=(unsigned)(orig[n]);
    tl= mm_malloc(sizeof(Translation));
    tl->hashvalue=i;
    tl->original=orig;
    tl->translate=trans;
    tl->autoconv=1;
    tl->next=currentlang->translist[i%currentlang->hashsize];
    currentlang->translist[i%currentlang->hashsize]=tl;
    currentlang->entries++;
    rehash_translang(currentlang);
    return trans;
  }
}

canonical_original_code:
unsigned short *translate(char *orig)
{
  int i;
  struct Translation *tl;
  if (!orig) return 0;
  i=hash_string(orig);
  if (!currentlang) currentlang=new_language();
  tl = currentlang->translist[i%currentlang->hashsize];
  while (tl && (tl->hashvalue!=i || strcmp(tl->original, orig))) tl=tl->next;
  if (tl) {
    return tl->translate;
  } else {
    int l; int n;
    unsigned short *trans;
    l=strlen(orig)+1;
    trans = mm_malloc(sizeof(Uchar)*l);
    for (n=0; n<l; n++) trans[n]=(unsigned int)(orig[n]);
    tl= mm_malloc(sizeof(Translation));
    tl->hashvalue=i;
    tl->original=orig;
    tl->translate=trans;
    tl->autoconv=1;
    tl->next=currentlang->translist[i%currentlang->hashsize];
    currentlang->translist[i%currentlang->hashsize]=tl;
    currentlang->entries++;
    rehash_translang(currentlang);
    return trans;
  }
}

variable_types:
orig
char *

variable_types: struct Translation { char *original; unsigned short *translate; int hashvalue; int autoconv; struct Translation *next; } *

variable_types: l int

variable_types: n int

variable_types:
trans
unsigned short *

return_type: unsigned short *


decompiled_code:
__int64 __fastcall set_translation8(char *a1, __int64 a2)
{
int v2; // ebx
__int64 v3; // rax
__int64 v4; // rdi

if ( !currentlang )
currentlang = new_language();
v2 = hash_string(a1);
v3 = mm_malloc(32LL);
*(_DWORD *)(v3 + 16) = v2;
*(_QWORD *)v3 = a1;
*(_QWORD *)(v3 + 8) = a2;
*(_DWORD *)(v3 + 20) = 0;
v4 = currentlang;
*(_QWORD *)(v3 + 24) = *(_QWORD *)(*(_QWORD *)(currentlang + 24) + 8LL * (v2 % *(_DWORD *)(currentlang + 16)));
*(_QWORD *)(*(_QWORD *)(v4 + 24) + 8LL * (v2 % *(_DWORD *)(v4 + 16))) = v3;
++*(_DWORD *)(v4 + 12);
return rehash_translang(v4);
}

original_code:
void set_translation8(char *orig, Uchar *transl)
{
  int i;
  Translation *tl;
  if (!currentlang) currentlang=new_language();
  i=hash_string(orig);
  tl = mm_malloc(sizeof(Translation));
  tl->hashvalue=i;
  tl->original=orig;
  tl->translate=transl;
  tl->autoconv=0;
  tl->next=currentlang->translist[i%currentlang->hashsize];
  currentlang->translist[i%currentlang->hashsize]=tl;
  currentlang->entries++;
  rehash_translang(currentlang);
}

canonical_original_code:
void set_translation8(char *orig, unsigned short *transl)
{
  int i;
  struct Translation *tl;
  if (!currentlang) currentlang=new_language();
  i=hash_string(orig);
  tl = mm_malloc(sizeof(Translation));
  tl->hashvalue=i;
  tl->original=orig;
  tl->translate=transl;
  tl->autoconv=0;
  tl->next=currentlang->translist[i%currentlang->hashsize];
  currentlang->translist[i%currentlang->hashsize]=tl;
  currentlang->entries++;
  rehash_translang(currentlang);
}

variable_types:
transl
unsigned short *

variable_types: i int

user_defined_types: struct Translation { char *original; unsigned short *translate; int hashvalue; int autoconv; struct Translation *next; }


decompiled_code:
__int64 __fastcall set_translation(char *a1, __int64 a2)
{
__int16 v2; // ax
char *v3; // rdx
char *v4; // rcx
int v5; // er12
__int64 v6; // rax
__int64 v7; // rdi

v2 = *(_WORD *)a1;
if ( *(_WORD *)a1 )
{
v3 = a1;
v4 = a1;
do
{
*v3++ = v2;
v4 += 2;
v2 = *(_WORD *)v4;
}
while ( *(_WORD *)v4 );
}
else
{
v3 = a1;
}
*v3 = 0;
if ( !currentlang )
currentlang = new_language();
v5 = hash_string(a1);
v6 = mm_malloc(32LL);
*(_DWORD *)(v6 + 16) = v5;
*(_QWORD *)v6 = a1;
*(_QWORD *)(v6 + 8) = a2;
*(_DWORD *)(v6 + 20) = 0;
v7 = currentlang;
*(_QWORD *)(v6 + 24) = *(_QWORD *)(*(_QWORD *)(currentlang + 24) + 8LL * (v5 % *(_DWORD *)(currentlang + 16)));
*(_QWORD *)(*(_QWORD *)(v7 + 24) + 8LL * (v5 % *(_DWORD *)(v7 + 16))) = v6;
++*(_DWORD *)(v7 + 12);
return rehash_translang(v7);
}

original_code:
void set_translation(Uchar *orig, Uchar *transl)
{
  int i;
  char *h, *orig8;
  Translation *tl;
  orig8 = h = (char*) orig;
  while (*orig) {
    *h = *orig;
    h++;
    orig++;
  }
  *h=0;
  if (!currentlang) currentlang=new_language();
  i=hash_string(orig8);
  tl = mm_malloc(sizeof(Translation));
  tl->hashvalue=i;
  tl->original=orig8;
  tl->translate=transl;
  tl->autoconv=0;
  tl->next=currentlang->translist[i%currentlang->hashsize];
  currentlang->translist[i%currentlang->hashsize]=tl;
  currentlang->entries++;
  rehash_translang(currentlang);
}

canonical_original_code:
void set_translation(unsigned short *orig, unsigned short *transl)
{
  int i;
  char *h; char *orig8;
  struct Translation *tl;
  orig8 = h = (char *) orig;
  while (*orig) {
    *h = *orig;
    h++;
    orig++;
  }
  *h=0;
  if (!currentlang) currentlang=new_language();
  i=hash_string(orig8);
  tl = mm_malloc(sizeof(Translation));
  tl->hashvalue=i;
  tl->original=orig8;
  tl->translate=transl;
  tl->autoconv=0;
  tl->next=currentlang->translist[i%currentlang->hashsize];
  currentlang->translist[i%currentlang->hashsize]=tl;
  currentlang->entries++;
  rehash_translang(currentlang);
}

variable_types:
orig
unsigned short *

variable_types:
h
char *


intadd

decompiled_code:
__int64 __fastcall intadd(int a1, int a2)
{
return (unsigned int)(a1 + a2);
}

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

original_code:
static int intadd(int i, int j)
{
  return i+j;
}


intminus

decompiled_code:
__int64 __fastcall intminus(int a1, int a2)
{
return (unsigned int)(a1 - a2);
}

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

original_code:
static int intminus(int i, int j)
{
  return i-j;
}


intmult

decompiled_code:
__int64 __fastcall intmult(int a1, int a2)
{
return (unsigned int)(a2 * a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, int a2)
{
return (unsigned int)(a2 * a1);
}

original_code:
static int intmult(int i, int j)
{
  return i*j;
}


intdivide

decompiled_code:
__int64 __fastcall intdivide(int a1, int a2)
{
return (unsigned int)(a1 / a2);
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1, int a2)
{
return (unsigned int)(a1 / a2);
}

original_code:
static int intdivide(int i, int j)
{
  return i/j;
}


intremain

decompiled_code:
__int64 __fastcall intremain(int a1, int a2)
{
return (unsigned int)(a1 % a2);
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1, int a2)
{
return (unsigned int)(a1 % a2);
}

original_code:
static int intremain(int i, int j)
{
  return i%j;
}


intand

decompiled_code:
__int64 __fastcall intand(unsigned int a1, int a2)
{
return a2 & a1;
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned int a1, int a2)
{
return a2 & a1;
}

original_code:
static int intand(int i, int j)
{
  return i&j;
}


intor

decompiled_code:
__int64 __fastcall intor(unsigned int a1, int a2)
{
return a2 | a1;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int a1, int a2)
{
return a2 | a1;
}

original_code:
static int intor(int i, int j)
{
  return i|j;
}


intxor

decompiled_code:
__int64 __fastcall intxor(unsigned int a1, int a2)
{
return a2 ^ a1;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int a1, int a2)
{
return a2 ^ a1;
}

original_code:
static int intxor(int i, int j)
{
  return i^j;
}


intnot

decompiled_code:
__int64 __fastcall intnot(int a1)
{
return (unsigned int)~a1;
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1)
{
return (unsigned int)~a1;
}

original_code:
static int intnot(int i)
{
    return ~i;
}

canonical_original_code:
static int intnot(int i)
{
    return ~i;
}


intland

decompiled_code:
__int64 __fastcall intland(int a1, int a2)
{
return (a1 != 0) & (unsigned __int8)(a2 != 0);
}

canonical_decompiled_code:
__int64 __fastcall func10(int a1, int a2)
{
return (a1 != 0) & (unsigned __int8)(a2 != 0);
}

original_code:
static int intland(int i, int j)
{
  return i&&j;
}


intlor

decompiled_code:
_BOOL8 __fastcall intlor(int a1, int a2)
{
return (a2 | a1) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func11(int a1, int a2)
{
return (a2 | a1) != 0;
}

original_code:
static int intlor(int i, int j)
{
  return i||j;
}


intlxor

decompiled_code:
__int64 __fastcall intlxor(int a1, int a2)
{
return (a2 != 0) ^ (unsigned __int8)(a1 != 0);
}

canonical_decompiled_code:
__int64 __fastcall func12(int a1, int a2)
{
return (a2 != 0) ^ (unsigned __int8)(a1 != 0);
}

original_code:
static int intlxor(int i, int j)
{
  return (i&&!j)||(!i&&j);
}


intlnot

decompiled_code:
_BOOL8 __fastcall intlnot(int a1)
{
return a1 == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func13(int a1)
{
return a1 == 0;
}

original_code:
static int intlnot(int i)
{
  return !i;
}


intequal

decompiled_code:
_BOOL8 __fastcall intequal(int a1, int a2)
{
return a1 == a2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func14(int a1, int a2)
{
return a1 == a2;
}

original_code:
static int intequal(int i, int j)
{
  return i==j;
}


intnotequal

decompiled_code:
_BOOL8 __fastcall intnotequal(int a1, int a2)
{
return a1 != a2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func15(int a1, int a2)
{
return a1 != a2;
}

original_code:
static int intnotequal(int i, int j)
{
  return i!=j;
}


intgreater

decompiled_code:
_BOOL8 __fastcall intgreater(int a1, int a2)
{
return a1 > a2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func16(int a1, int a2)
{
return a1 > a2;
}

original_code:
static int intgreater(int i, int j)
{
  return i>j;
}


intless

decompiled_code:
_BOOL8 __fastcall intless(int a1, int a2)
{
return a1 < a2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func17(int a1, int a2)
{
return a1 < a2;
}

original_code:
static int intless(int i, int j)
{
  return i<j;
}


intlessequal

decompiled_code:
_BOOL8 __fastcall intlessequal(int a1, int a2)
{
return a1 <= a2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func18(int a1, int a2)
{
return a1 <= a2;
}

original_code:
static int intlessequal(int i, int j)
{
  return i<=j;
}


intgreaterequal

decompiled_code:
_BOOL8 __fastcall intgreaterequal(int a1, int a2)
{
return a1 >= a2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func19(int a1, int a2)
{
return a1 >= a2;
}

original_code:
static int intgreaterequal(int i, int j)
{
  return i>=j;
}


intshiftleft

decompiled_code:
__int64 __fastcall intshiftleft(int a1, char a2)
{
return (unsigned int)(a1 << a2);
}

canonical_decompiled_code:
__int64 __fastcall func20(int a1, char a2)
{
return (unsigned int)(a1 << a2);
}

original_code:
static int intshiftleft(int i, int j)
{
  return i<<j;
}


intshiftright

decompiled_code:
__int64 __fastcall intshiftright(int a1, char a2)
{
return (unsigned int)(a1 >> a2);
}

canonical_decompiled_code:
__int64 __fastcall func21(int a1, char a2)
{
return (unsigned int)(a1 >> a2);
}

original_code:
static int intshiftright(int i, int j)
{
  return i>>j;
}


decompiled_code:
__int64 __fastcall call_intref(__int64 (__fastcall *a1)(_QWORD), _QWORD **a2)
{
return a1(**a2);
}

canonical_decompiled_code:
__int64 __fastcall func22(__int64 (__fastcall *a1)(_QWORD), _QWORD **a2)
{
return a1(**a2);
}

original_code:
static int call_intref(int (*fcal)(), void **args)
{
   return (*fcal)(*((int**)args[0]));
}

canonical_original_code:
static int call_intref(int (*fcal)(), void **args)
{
   return (*fcal)(*((int **)args[0]));
}

variable_types:
fcal
int (*)()

variable_types:
args
void **


decompiled_code:
__int64 __fastcall call_intintref(__int64 (__fastcall *a1)(_QWORD, _QWORD), unsigned int **a2)
{
return a1(**a2, *(_QWORD *)a2[1]);
}

canonical_decompiled_code:
__int64 __fastcall func23(__int64 (__fastcall *a1)(_QWORD, _QWORD), unsigned int **a2)
{
return a1(**a2, *(_QWORD *)a2[1]);
}

original_code:
static int call_intintref(int (*fcal)(), void **args)
{
   return (*fcal)(*((int*)args[0]), *((int**)args[1]));
}

canonical_original_code:
static int call_intintref(int (*fcal)(), void **args)
{
   return (*fcal)(*((int *)args[0]), *((int **)args[1]));
}


decompiled_code:
__int64 __fastcall call_intintresint(__int64 (__fastcall *a1)(_QWORD, _QWORD), unsigned int **a2)
{
_DWORD *v2; // rbx

v2 = *(_DWORD **)a2[2];
*v2 = a1(**a2, *a2[1]);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func24(__int64 (__fastcall *a1)(_QWORD, _QWORD), unsigned int **a2)
{
_DWORD *v2; // rbx

v2 = *(_DWORD **)a2[2];
*v2 = a1(**a2, *a2[1]);
return 0LL;
}

original_code:
static int call_intintresint(int (*fcal)(), void **args)
{
  *(*((int**)args[2])) = (*fcal)(*((int*)args[0]), *((int*)args[1]));
  return 0;
}

canonical_original_code:
static int call_intintresint(int (*fcal)(), void **args)
{
  *(*((int **)args[2])) = (*fcal)(*((int *)args[0]), *((int *)args[1]));
  return 0;
}


decompiled_code:
__int64 __fastcall call_intresint(__int64 (__fastcall *a1)(_QWORD), unsigned int **a2)
{
_DWORD *v2; // rbx

v2 = *(_DWORD **)a2[1];
*v2 = a1(**a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func25(__int64 (__fastcall *a1)(_QWORD), unsigned int **a2)
{
_DWORD *v2; // rbx

v2 = *(_DWORD **)a2[1];
*v2 = a1(**a2);
return 0LL;
}

original_code:
static int call_intresint(int (*fcal)(), void **args)
{
  *(*((int**)args[1])) = (*fcal)(*((int*)args[0]));
  return 0;
}

canonical_original_code:
static int call_intresint(int (*fcal)(), void **args)
{
  *(*((int **)args[1])) = (*fcal)(*((int *)args[0]));
  return 0;
}


decompiled_code:
__int64 __fastcall call_strint(__int64 (__fastcall *a1)(_QWORD, _QWORD), __int64 a2)
{
return a1(**(_QWORD **)a2, **(unsigned int **)(a2 + 8));
}

canonical_decompiled_code:
__int64 __fastcall func26(__int64 (__fastcall *a1)(_QWORD, _QWORD), __int64 a2)
{
return a1(**(_QWORD **)a2, **(unsigned int **)(a2 + 8));
}

original_code:
static int call_strint(int (*fcal)(), void **args)
{
   return (*fcal)(*((Uchar**)args[0]), *((int*)args[1]));
}

canonical_original_code:
static int call_strint(int (*fcal)(), void **args)
{
   return (*fcal)(*((unsigned short **)args[0]), *((int *)args[1]));
}


printint

decompiled_code:
int __fastcall printint(__int64 a1, unsigned int a2)
{
const char *v2; // rax

v2 = (const char *)UstrtoLocale();
return printf("%s: %i\n", v2, a2);
}

canonical_decompiled_code:
int __fastcall func27(__int64 a1, unsigned int a2)
{
const char *v2; // rax

v2 = (const char *)UstrtoLocale();
return printf("%s: %i\n", v2, a2);
}

original_code:
static void printint(Uchar *str, int x)
{
    printf("%s: %i\n", UstrtoLocale(str), x);
}

canonical_original_code:
static void printint(unsigned short *str, int x)
{
    printf("%s: %i\n", UstrtoLocale(str), x);
}

variable_types:
str
unsigned short *

variable_types: x int


updateedit

decompiled_code:
int __fastcall updateedit(const void *a1)
{
return printf("Updated editfield for %p\n", a1);
}

canonical_decompiled_code:
int __fastcall func28(const void *a1)
{
return printf("Updated editfield for %p\n", a1);
}

original_code:
static void updateedit(int *x)
{
    printf("Updated editfield for %p\n", x);
}

variable_types:
x
int *


updatevar

decompiled_code:
int __fastcall updatevar(const void *a1)
{
return printf("Updated variable %p\n", a1);
}

canonical_decompiled_code:
int __fastcall func29(const void *a1)
{
return printf("Updated variable %p\n", a1);
}

original_code:
static void updatevar(int *x)
{
    printf("Updated variable %p\n", x);
}


decompiled_code:
__int64 init_library()
{
__int64 v0; // rbx
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rbx
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rbx
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rax
__int64 v16; // rax
__int64 v17; // rax
__int64 v18; // rax
__int64 v19; // rax
__int64 v20; // rax
__int64 v21; // rax
__int64 v22; // rax
__int64 v23; // rax
__int64 v24; // rax
__int64 v25; // rax
__int64 v26; // rax

v0 = define_prototype(&tlist, 1LL, 0LL, call_intref);
define_function("UpdateVar", &LC3, v0, updatevar);
define_function("UpdateEdit", &LC3, v0, updateedit);
v1 = define_prototype(&unk_650, 2LL, 0LL, call_strint);
define_function("PrintInt", &LC3, v1, printint);
v2 = define_prototype(&tlist, 2LL, 0LL, call_intintref);
v3 = define_function("Assign", &LC3, v2, assign);
define_operator(1LL, v3);
v4 = define_prototype(&tlist, 1LL, 1LL, call_intresint);
v5 = define_function("IntNot", &LC3, v4, intnot);
define_operator(44LL, v5);
v6 = define_function("IntLogicNot", &LC3, v4, intlnot);
define_operator(24LL, v6);
v7 = define_prototype(&unk_660, 2LL, 1LL, call_intintresint);
v8 = define_function("IntAdd", &LC3, v7, intadd);
define_operator(11LL, v8);
v9 = define_function("IntMin", &LC3, v7, intminus);
define_operator(12LL, v9);
v10 = define_function("IntMult", &LC3, v7, intmult);
define_operator(13LL, v10);
v11 = define_function("IntDivide", &LC3, v7, intdivide);
define_operator(14LL, v11);
v12 = define_function("IntRemain", &LC3, v7, intremain);
define_operator(15LL, v12);
v13 = define_function("IntAnd", &LC3, v7, intand);
define_operator(41LL, v13);
v14 = define_function("IntOr", &LC3, v7, intor);
define_operator(42LL, v14);
v15 = define_function("IntXor", &LC3, v7, intxor);
define_operator(43LL, v15);
v16 = define_function("IntLogicAnd", &LC3, v7, intland);
define_operator(21LL, v16);
v17 = define_function("IntLogicOr", &LC3, v7, intlor);
define_operator(22LL, v17);
v18 = define_function("IntLogicXor", &LC3, v7, intlxor);
define_operator(23LL, v18);
v19 = define_function("IntEqual", &LC3, v7, intequal);
define_operator(25LL, v19);
v20 = define_function("IntNotEqual", &LC3, v7, intnotequal);
define_operator(26LL, v20);
v21 = define_function("IntGreater", &LC3, v7, intgreater);
define_operator(27LL, v21);
v22 = define_function("IntLess", &LC3, v7, intless);
define_operator(28LL, v22);
v23 = define_function("IntLessEqual", &LC3, v7, intlessequal);
define_operator(29LL, v23);
v24 = define_function("IntGreaterEqual", &LC3, v7, intgreaterequal);
define_operator(30LL, v24);
v25 = define_function("IntShiftLeft", &LC3, v7, intshiftleft);
define_operator(45LL, v25);
v26 = define_function("IntShiftRight", &LC3, v7, intshiftright);
define_operator(46LL, v26);
return 1LL;
}

canonical_decompiled_code:
__int64 func30()
{
__int64 v0; // rbx
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rbx
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rbx
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rax
__int64 v16; // rax
__int64 v17; // rax
__int64 v18; // rax
__int64 v19; // rax
__int64 v20; // rax
__int64 v21; // rax
__int64 v22; // rax
__int64 v23; // rax
__int64 v24; // rax
__int64 v25; // rax
__int64 v26; // rax

v0 = define_prototype(&tlist, 1LL, 0LL, call_intref);
define_function("UpdateVar", &LC3, v0, updatevar);
define_function("UpdateEdit", &LC3, v0, updateedit);
v1 = define_prototype(&unk_650, 2LL, 0LL, call_strint);
define_function("PrintInt", &LC3, v1, printint);
v2 = define_prototype(&tlist, 2LL, 0LL, call_intintref);
v3 = define_function("Assign", &LC3, v2, assign);
define_operator(1LL, v3);
v4 = define_prototype(&tlist, 1LL, 1LL, call_intresint);
v5 = define_function("IntNot", &LC3, v4, intnot);
define_operator(44LL, v5);
v6 = define_function("IntLogicNot", &LC3, v4, intlnot);
define_operator(24LL, v6);
v7 = define_prototype(&unk_660, 2LL, 1LL, call_intintresint);
v8 = define_function("IntAdd", &LC3, v7, intadd);
define_operator(11LL, v8);
v9 = define_function("IntMin", &LC3, v7, intminus);
define_operator(12LL, v9);
v10 = define_function("IntMult", &LC3, v7, intmult);
define_operator(13LL, v10);
v11 = define_function("IntDivide", &LC3, v7, intdivide);
define_operator(14LL, v11);
v12 = define_function("IntRemain", &LC3, v7, intremain);
define_operator(15LL, v12);
v13 = define_function("IntAnd", &LC3, v7, intand);
define_operator(41LL, v13);
v14 = define_function("IntOr", &LC3, v7, intor);
define_operator(42LL, v14);
v15 = define_function("IntXor", &LC3, v7, intxor);
define_operator(43LL, v15);
v16 = define_function("IntLogicAnd", &LC3, v7, intland);
define_operator(21LL, v16);
v17 = define_function("IntLogicOr", &LC3, v7, intlor);
define_operator(22LL, v17);
v18 = define_function("IntLogicXor", &LC3, v7, intlxor);
define_operator(23LL, v18);
v19 = define_function("IntEqual", &LC3, v7, intequal);
define_operator(25LL, v19);
v20 = define_function("IntNotEqual", &LC3, v7, intnotequal);
define_operator(26LL, v20);
v21 = define_function("IntGreater", &LC3, v7, intgreater);
define_operator(27LL, v21);
v22 = define_function("IntLess", &LC3, v7, intless);
define_operator(28LL, v22);
v23 = define_function("IntLessEqual", &LC3, v7, intlessequal);
define_operator(29LL, v23);
v24 = define_function("IntGreaterEqual", &LC3, v7, intgreaterequal);
define_operator(30LL, v24);
v25 = define_function("IntShiftLeft", &LC3, v7, intshiftleft);
define_operator(45LL, v25);
v26 = define_function("IntShiftRight", &LC3, v7, intshiftright);
define_operator(46LL, v26);
return 1LL;
}

original_code:
int init_library(void)
{
    Prototype *pt;
    FuncRef fr;
    pt=define_prototype(tlist[0], 1, 0, call_intref);
    define_function("UpdateVar", "", pt,(Function) updatevar);
    define_function("UpdateEdit", "", pt, (Function) updateedit);
    pt=define_prototype(tlist[1], 2, 0, call_strint);
    define_function("PrintInt", "", pt, (Function) printint);
    pt=define_prototype(tlist[0], 2, 0, call_intintref);
    fr = define_function("Assign", "", pt, (Function) assign);
    define_operator(1, fr);
    pt=define_prototype(tlist[0], 1, 1, call_intresint);
    fr = define_function("IntNot", "", pt, (Function) intnot);
    define_operator(44, fr);
    fr = define_function("IntLogicNot", "", pt, (Function) intlnot);
    define_operator(24, fr);
    pt=define_prototype(tlist[2], 2, 1, call_intintresint);
    fr = define_function("IntAdd", "", pt, (Function) intadd);
    define_operator(11, fr);
    fr = define_function("IntMin", "", pt, (Function) intminus);
    define_operator(12, fr);
    fr = define_function("IntMult", "", pt, (Function) intmult);
    define_operator(13, fr);
    fr = define_function("IntDivide", "", pt, (Function) intdivide);
    define_operator(14, fr);
    fr = define_function("IntRemain", "", pt, (Function) intremain);
    define_operator(15, fr);
    fr = define_function("IntAnd", "", pt, (Function) intand);
    define_operator(41, fr);
    fr = define_function("IntOr", "", pt, (Function) intor);
    define_operator(42, fr);
    fr = define_function("IntXor", "", pt, (Function) intxor);
    define_operator(43, fr);
    fr = define_function("IntLogicAnd", "", pt, (Function) intland);
    define_operator(21, fr);
    fr = define_function("IntLogicOr", "", pt, (Function) intlor);
    define_operator(22, fr);
    fr = define_function("IntLogicXor", "", pt, (Function) intlxor);
    define_operator(23, fr);
    fr = define_function("IntEqual", "", pt, (Function) intequal);
    define_operator(25, fr);
    fr = define_function("IntNotEqual", "", pt, (Function) intnotequal);
    define_operator(26, fr);
    fr = define_function("IntGreater", "", pt, (Function) intgreater);
    define_operator(27, fr);
    fr = define_function("IntLess", "", pt, (Function) intless);
    define_operator(28, fr);
    fr = define_function("IntLessEqual", "", pt, (Function) intlessequal);
    define_operator(29, fr);
    fr = define_function("IntGreaterEqual", "", pt, (Function) intgreaterequal);
    define_operator(30, fr);
    fr = define_function("IntShiftLeft", "", pt, (Function) intshiftleft);
    define_operator(45, fr);
    fr = define_function("IntShiftRight", "", pt, (Function) intshiftright);
    define_operator(46, fr);
    return 1;
}

canonical_original_code:
int init_library()
{
    struct Prototype *pt;
    struct FuncDef *fr;
    pt=define_prototype(tlist[0], 1, 0, call_intref);
    define_function("UpdateVar", "", pt,(void (*)()) updatevar);
    define_function("UpdateEdit", "", pt, (void (*)()) updateedit);
    pt=define_prototype(tlist[1], 2, 0, call_strint);
    define_function("PrintInt", "", pt, (void (*)()) printint);
    pt=define_prototype(tlist[0], 2, 0, call_intintref);
    fr = define_function("Assign", "", pt, (void (*)()) assign);
    define_operator(1, fr);
    pt=define_prototype(tlist[0], 1, 1, call_intresint);
    fr = define_function("IntNot", "", pt, (void (*)()) intnot);
    define_operator(44, fr);
    fr = define_function("IntLogicNot", "", pt, (void (*)()) intlnot);
    define_operator(24, fr);
    pt=define_prototype(tlist[2], 2, 1, call_intintresint);
    fr = define_function("IntAdd", "", pt, (void (*)()) intadd);
    define_operator(11, fr);
    fr = define_function("IntMin", "", pt, (void (*)()) intminus);
    define_operator(12, fr);
    fr = define_function("IntMult", "", pt, (void (*)()) intmult);
    define_operator(13, fr);
    fr = define_function("IntDivide", "", pt, (void (*)()) intdivide);
    define_operator(14, fr);
    fr = define_function("IntRemain", "", pt, (void (*)()) intremain);
    define_operator(15, fr);
    fr = define_function("IntAnd", "", pt, (void (*)()) intand);
    define_operator(41, fr);
    fr = define_function("IntOr", "", pt, (void (*)()) intor);
    define_operator(42, fr);
    fr = define_function("IntXor", "", pt, (void (*)()) intxor);
    define_operator(43, fr);
    fr = define_function("IntLogicAnd", "", pt, (void (*)()) intland);
    define_operator(21, fr);
    fr = define_function("IntLogicOr", "", pt, (void (*)()) intlor);
    define_operator(22, fr);
    fr = define_function("IntLogicXor", "", pt, (void (*)()) intlxor);
    define_operator(23, fr);
    fr = define_function("IntEqual", "", pt, (void (*)()) intequal);
    define_operator(25, fr);
    fr = define_function("IntNotEqual", "", pt, (void (*)()) intnotequal);
    define_operator(26, fr);
    fr = define_function("IntGreater", "", pt, (void (*)()) intgreater);
    define_operator(27, fr);
    fr = define_function("IntLess", "", pt, (void (*)()) intless);
    define_operator(28, fr);
    fr = define_function("IntLessEqual", "", pt, (void (*)()) intlessequal);
    define_operator(29, fr);
    fr = define_function("IntGreaterEqual", "", pt, (void (*)()) intgreaterequal);
    define_operator(30, fr);
    fr = define_function("IntShiftLeft", "", pt, (void (*)()) intshiftleft);
    define_operator(45, fr);
    fr = define_function("IntShiftRight", "", pt, (void (*)()) intshiftright);
    define_operator(46, fr);
    return 1;
}

variable_types: struct Prototype { unsigned int *type; int n; unsigned int restype; int max; int (*caller)(); } *

variable_types: struct FuncDef { char *name; char *description; char nr_args; char functype; unsigned int rettype; void *prototype; } *


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

result = (unsigned int)(a3 * a1 / a2);
if ( a3 <= (int)result )
result = (unsigned int)(a3 - 1);
if ( (int)result < 0 )
result = 0LL;
return result;
}

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

result = (unsigned int)(a3 * a1 / a2);
if ( a3 <= (int)result )
result = (unsigned int)(a3 - 1);
if ( (int)result < 0 )
result = 0LL;
return result;
}

original_code:
static int pos_to_line(int pos, int size, int nr_lines)
{
    int i;
    i= ((pos - 0) * nr_lines) / (size - 2*0);
    if (i>=nr_lines) i=nr_lines-1;
    if (i<0) return 0;
    return i;
}

variable_types: pos int

variable_types: size int


decompiled_code:
__int64 __fastcall line_to_pos(int a1, int a2, int a3)
{
unsigned int v4; // edi
int v5; // eax

v4 = 1;
if ( a3 > 0 )
{
v5 = a2 * a1 / a3;
v4 = a2 - 1;
if ( a2 > v5 )
{
v4 = 1;
if ( v5 > 0 )
v4 = v5;
}
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, int a2, int a3)
{
unsigned int v4; // edi
int v5; // eax

v4 = 1;
if ( a3 > 0 )
{
v5 = a2 * a1 / a3;
v4 = a2 - 1;
if ( a2 > v5 )
{
v4 = 1;
if ( v5 > 0 )
v4 = v5;
}
}
return v4;
}

original_code:
static int line_to_pos(int line, int size, int nr_lines)
{
    int i;
    if (nr_lines<=0) return 0 +1;
    i = ((size- 2*0) * line / nr_lines + 0);
    if (i> size-0 -1) return size-0 -1;
    if (i< 0 +1) return 0 +1;
    return i;
}

variable_types: line int


decompiled_code:
__int64 __fastcall end_pixel(int *a1)
{
int v1; // ecx
__int64 result; // rax

v1 = a1[7];
if ( v1 )
result = line_to_pos(a1[8] + a1[6] / a1[9], a1[6], v1);
else
result = (unsigned int)(a1[6] - 1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(int *a1)
{
int v1; // ecx
__int64 result; // rax

v1 = a1[7];
if ( v1 )
result = func1(a1[8] + a1[6] / a1[9], a1[6], v1);
else
result = (unsigned int)(a1[6] - 1);
return result;
}

original_code:
static int end_pixel(SCROLLBARINFO *sbi)
{
    if (sbi->nr_lines)
 return line_to_pos(sbi->first_line + sbi->sb_size/sbi->line_size,
      sbi->sb_size, sbi->nr_lines);
    else
 return sbi->sb_size - 0 -1;
}

canonical_original_code:
static int end_pixel(struct SCROLLBARINFO *sbi)
{
    if (sbi->nr_lines)
 return line_to_pos(sbi->first_line + sbi->sb_size/sbi->line_size,
      sbi->sb_size, sbi->nr_lines);
    else
 return sbi->sb_size - 0 -1;
}

variable_types: struct SCROLLBARINFO { unsigned long win_id; int vertical; int shrt; int startpix; void (*func)(void *, int); void *data; } *


decompiled_code:
int __fastcall draw_rectangle(Drawable a1, int a2, unsigned int a3, int a4, unsigned int a5)
{
struct _XGC *v6; // rax
int result; // eax
struct _XGC *v8; // rax

if ( a4 )
{
v6 = (struct _XGC *)get_GC(a5, 0LL, 0LL);
result = XFillRectangle(display, a1, v6, 1, a2, 0xBu, a3);
}
else
{
v8 = (struct _XGC *)get_GC(a5, 0LL, 0LL);
result = XFillRectangle(display, a1, v8, a2, 1, a3, 0xBu);
}
return result;
}

canonical_decompiled_code:
int __fastcall func4(Drawable a1, int a2, unsigned int a3, int a4, unsigned int a5)
{
struct _XGC *v6; // rax
int result; // eax
struct _XGC *v8; // rax

if ( a4 )
{
v6 = (struct _XGC *)get_GC(a5, 0LL, 0LL);
result = XFillRectangle(display, a1, v6, 1, a2, 0xBu, a3);
}
else
{
v8 = (struct _XGC *)get_GC(a5, 0LL, 0LL);
result = XFillRectangle(display, a1, v8, a2, 1, a3, 0xBu);
}
return result;
}

original_code:
static void draw_rectangle(Window win, int x, int xs, int kind, TextMode col)
{
    if (kind)
 XFillRectangle(display, win, get_GC(col,0,0),
         1, x, 12 -1, xs);
    else
 XFillRectangle(display, win, get_GC(col,0,0),
         x, 1, xs, 12 -1);
}

canonical_original_code:
static void draw_rectangle(unsigned long win, int x, int xs, int kind, enum TextMode col)
{
    if (kind)
 XFillRectangle(display, win, get_GC(col,0,0),
         1, x, 12 -1, xs);
    else
 XFillRectangle(display, win, get_GC(col,0,0),
         x, 1, xs, 12 -1);
}

variable_types:
win
unsigned long

variable_types: xs int

variable_types: kind int

variable_types: enum TextMode { Normal=0, Reverse=1, Xor=2 }


decompiled_code:
int __fastcall scrollbar_draw(__int64 a1)
{
unsigned int v1; // ebp
struct _XGC *v2; // rax
struct _XGC *v4; // rax

v1 = *(_DWORD *)(a1 + 24) - 1;
if ( *(_DWORD *)(a1 + 8) )
{
v2 = (struct _XGC *)get_GC(0LL, 0LL, 0LL);
XDrawRectangle(display, *(_QWORD *)a1, v2, 0, 0, 0xCu, v1);
}
else
{
v4 = (struct _XGC *)get_GC(0LL, 0LL, 0LL);
XDrawRectangle(display, *(_QWORD *)a1, v4, 0, 0, v1, 0xCu);
}
return draw_rectangle(*(_QWORD *)a1, *(_DWORD *)(a1 + 16), *(_DWORD *)(a1 + 20), *(_DWORD *)(a1 + 8), 0);
}

canonical_decompiled_code:
int __fastcall func5(__int64 a1)
{
unsigned int v1; // ebp
struct _XGC *v2; // rax
struct _XGC *v4; // rax

v1 = *(_DWORD *)(a1 + 24) - 1;
if ( *(_DWORD *)(a1 + 8) )
{
v2 = (struct _XGC *)get_GC(0LL, 0LL, 0LL);
XDrawRectangle(display, *(_QWORD *)a1, v2, 0, 0, 0xCu, v1);
}
else
{
v4 = (struct _XGC *)get_GC(0LL, 0LL, 0LL);
XDrawRectangle(display, *(_QWORD *)a1, v4, 0, 0, v1, 0xCu);
}
return func4(*(_QWORD *)a1, *(_DWORD *)(a1 + 16), *(_DWORD *)(a1 + 20), *(_DWORD *)(a1 + 8), 0);
}

original_code:
static void scrollbar_draw(void *data)
{
    SCROLLBARINFO *sbi = (SCROLLBARINFO *) data;
    int postri;
    postri = sbi->sb_size - 0 -1;
    if (sbi->vertical) {
 XDrawRectangle(display, sbi->win_id, get_GC(Normal,0,0),
         0, 0, 12, sbi->sb_size-1);
    } else {
 XDrawRectangle(display, sbi->win_id, get_GC(Normal,0,0),
         0, 0, sbi->sb_size-1, 12);
    }
    draw_rectangle(sbi->win_id, sbi->startpix, sbi->sizepix,
     sbi->vertical, Normal);
}

canonical_original_code:
static void scrollbar_draw(void *data)
{
    struct SCROLLBARINFO *sbi = (SCROLLBARINFO *) data;
    int postri;
    postri = sbi->sb_size - 0 -1;
    if (sbi->vertical) {
 XDrawRectangle(display, sbi->win_id, get_GC(Normal,0,0),
         0, 0, 12, sbi->sb_size-1);
    } else {
 XDrawRectangle(display, sbi->win_id, get_GC(Normal,0,0),
         0, 0, sbi->sb_size-1, 12);
    }
    draw_rectangle(sbi->win_id, sbi->startpix, sbi->sizepix,
     sbi->vertical, Normal);
}

variable_types:
data
void *

variable_types: postri int

user_defined_types: struct SCROLLBARINFO { unsigned long win_id; int vertical; int shrt; int startpix; void (*func)(void *, int); void *data; }


decompiled_code:
int __fastcall redraw_rectangle(int *a1)
{
int v1; // ebx
int v2; // esi
int v3; // er12
int v4; // er13
int result; // eax

v1 = start_pixel(a1);
v2 = end_pixel(a1);
if ( v1 == v2 )
{
if ( v1 <= 1 )
++v2;
else
--v1;
}
v3 = a1[4];
v4 = a1[5] + v3;
a1[4] = v1;
result = v2 - v1;
a1[5] = v2 - v1;
if ( v1 > v4 )
{
result = v1;
v1 = v4;
v4 = result;
}
if ( v2 > v3 )
{
result = v2;
v2 = v3;
v3 = result;
}
if ( v1 < v2 )
{
result = draw_rectangle(*(_QWORD *)a1, v1, v2 - v1, a1[2], 0);
}
else if ( v1 > v2 )
{
result = draw_rectangle(*(_QWORD *)a1, v2, v1 - v2, a1[2], 1u);
}
if ( v3 > v4 )
return draw_rectangle(*(_QWORD *)a1, v4, v3 - v4, a1[2], 0);
if ( v3 < v4 )
result = draw_rectangle(*(_QWORD *)a1, v3, v4 - v3, a1[2], 1u);
return result;
}

original_code:
static void redraw_rectangle(SCROLLBARINFO *sbi)
{
    int ns, ne, os, oe, h;
    ns = start_pixel(sbi);
    ne = end_pixel(sbi);
    if (ne==ns)
 if (ns>0 +1)
     ns--;
 else
     ne++;
    os = sbi->startpix;
    oe = os + sbi->sizepix;
    sbi->startpix = ns;
    sbi->sizepix = ne-ns;
    if (oe<ns) h=oe,oe=ns,ns=h;
    if (os<ne) h=os,os=ne,ne=h;
    if (ns<ne)
 draw_rectangle(sbi->win_id, ns, ne-ns, sbi->vertical, Normal);
    if (ns>ne)
 draw_rectangle(sbi->win_id, ne, ns-ne, sbi->vertical, Reverse);
    if (os>oe)
 draw_rectangle(sbi->win_id, oe, os-oe, sbi->vertical, Normal);
    if (os<oe)
 draw_rectangle(sbi->win_id, os, oe-os, sbi->vertical, Reverse);
}

canonical_original_code:
static void redraw_rectangle(struct SCROLLBARINFO *sbi)
{
    int ns; int ne; int os; int oe; int h;
    ns = start_pixel(sbi);
    ne = end_pixel(sbi);
    if (ne==ns)
 if (ns>0 +1)
     ns--;
 else
     ne++;
    os = sbi->startpix;
    oe = os + sbi->sizepix;
    sbi->startpix = ns;
    sbi->sizepix = ne-ns;
    if (oe<ns) h=oe,oe=ns,ns=h;
    if (os<ne) h=os,os=ne,ne=h;
    if (ns<ne)
 draw_rectangle(sbi->win_id, ns, ne-ns, sbi->vertical, Normal);
    if (ns>ne)
 draw_rectangle(sbi->win_id, ne, ns-ne, sbi->vertical, Reverse);
    if (os>oe)
 draw_rectangle(sbi->win_id, oe, os-oe, sbi->vertical, Normal);
    if (os<oe)
 draw_rectangle(sbi->win_id, os, oe-os, sbi->vertical, Reverse);
}

variable_types: ns int

variable_types: ne int

variable_types: os int

variable_types: oe int

variable_types: h int


decompiled_code:
__int64 __fastcall position_changed(__int64 a1, int a2)
{
int v4; // ecx
int v5; // er8
int v6; // esi
int v7; // ebp
__int64 result; // rax
int v9; // edx
bool v10; // cc
int v11; // eax
int v12; // ebp
int v13; // edx
int v14; // esi

v4 = *(_DWORD *)(a1 + 36);
v5 = a2 / v4;
v6 = a2 / v4;
v7 = *(_DWORD *)(a1 + 28);
if ( *(_DWORD *)(a1 + 12) )
{
v7 = v7 - *(_DWORD *)(a1 + 24) / v4 + 1;
if ( v7 <= 0 )
v7 = 1;
}
if ( !v5 )
v6 = 1;
result = mouse_button;
switch ( mouse_button )
{
case 2:
result = pos_to_line(a2, *(_DWORD *)(a1 + 24), *(_DWORD *)(a1 + 28));
if ( *(_DWORD *)(a1 + 32) != (_DWORD)result )
{
if ( v7 <= (int)result )
LODWORD(result) = v7 - 1;
*(_DWORD *)(a1 + 32) = result;
goto LABEL_18;
}
break;
case 3:
result = *(unsigned int *)(a1 + 32);
v12 = v7 - 1;
if ( (_DWORD)result != v12 )
{
v13 = v12 - v6;
v14 = result + v6;
if ( (int)result < v13 )
v12 = v14;
*(_DWORD *)(a1 + 32) = v12;
goto LABEL_18;
}
break;
case 1:
result = *(unsigned int *)(a1 + 32);
if ( (_DWORD)result )
{
v9 = result - v6;
v10 = (int)result <= v6;
v11 = 0;
if ( !v10 )
v11 = v9;
*(_DWORD *)(a1 + 32) = v11;
LABEL_18:
redraw_rectangle((int *)a1);
return (*(__int64 (__fastcall **)(_QWORD, _QWORD))(a1 + 40))(*(_QWORD *)(a1 + 48), *(unsigned int *)(a1 + 8));
}
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, int a2)
{
int v4; // ecx
int v5; // er8
int v6; // esi
int v7; // ebp
__int64 result; // rax
int v9; // edx
bool v10; // cc
int v11; // eax
int v12; // ebp
int v13; // edx
int v14; // esi

v4 = *(_DWORD *)(a1 + 36);
v5 = a2 / v4;
v6 = a2 / v4;
v7 = *(_DWORD *)(a1 + 28);
if ( *(_DWORD *)(a1 + 12) )
{
v7 = v7 - *(_DWORD *)(a1 + 24) / v4 + 1;
if ( v7 <= 0 )
v7 = 1;
}
if ( !v5 )
v6 = 1;
result = mouse_button;
switch ( mouse_button )
{
case 2:
result = func0(a2, *(_DWORD *)(a1 + 24), *(_DWORD *)(a1 + 28));
if ( *(_DWORD *)(a1 + 32) != (_DWORD)result )
{
if ( v7 <= (int)result )
LODWORD(result) = v7 - 1;
*(_DWORD *)(a1 + 32) = result;
goto LABEL_18;
}
break;
case 3:
result = *(unsigned int *)(a1 + 32);
v12 = v7 - 1;
if ( (_DWORD)result != v12 )
{
v13 = v12 - v6;
v14 = result + v6;
if ( (int)result < v13 )
v12 = v14;
*(_DWORD *)(a1 + 32) = v12;
goto LABEL_18;
}
break;
case 1:
result = *(unsigned int *)(a1 + 32);
if ( (_DWORD)result )
{
v9 = result - v6;
v10 = (int)result <= v6;
v11 = 0;
if ( !v10 )
v11 = v9;
*(_DWORD *)(a1 + 32) = v11;
LABEL_18:
func6((int *)a1);
return (*(__int64 (__fastcall **)(_QWORD, _QWORD))(a1 + 40))(*(_QWORD *)(a1 + 48), *(unsigned int *)(a1 + 8));
}
break;
}
return result;
}

original_code:
static void position_changed(SCROLLBARINFO *sbi, int pos)
{
    int max=sbi->nr_lines;
    int nr=pos/sbi->line_size;
    int changed = 0;
    if (sbi->shrt) {
 max = max - sbi->sb_size/sbi->line_size + 1;
 if (max<=0) max=1;
    }
    if (!nr) nr=1;
    switch (mouse_button) {
    case 1:
 if (!sbi->first_line) break;
 if (sbi->first_line <= nr)
     sbi->first_line=0;
 else
     sbi->first_line -= nr;
 changed = 1;
 break;
    case 2:
 {
     int i;
     i = pos_to_line(pos, sbi->sb_size, sbi->nr_lines);
     if (i!=sbi->first_line) {
  if (i<max)
      sbi->first_line = i;
  else
      sbi->first_line = max-1;
  changed = 1;
     }
 }
 break;
    case 3:
 if (sbi->first_line==max-1) break;
 if (sbi->first_line >= max-1-nr)
     sbi->first_line=max-1;
 else
     sbi->first_line += nr;
 changed = 1;
 break;
    }
    if (changed) {
 redraw_rectangle(sbi);
 (*(sbi->func))(sbi->data, sbi->vertical);
    }
}

canonical_original_code:
static void position_changed(struct SCROLLBARINFO *sbi, int pos)
{
    int max = sbi->nr_lines;
    int nr = pos/sbi->line_size;
    int changed = 0;
    if (sbi->shrt) {
 max = max - sbi->sb_size/sbi->line_size + 1;
 if (max<=0) max=1;
    }
    if (!nr) nr=1;
    switch (mouse_button) {
    case 1:
 if (!sbi->first_line) break;
 if (sbi->first_line <= nr)
     sbi->first_line=0;
 else
     sbi->first_line -= nr;
 changed = 1;
 break;
    case 2:
 {
     int i;
     i = pos_to_line(pos, sbi->sb_size, sbi->nr_lines);
     if (i!=sbi->first_line) {
  if (i<max)
      sbi->first_line = i;
  else
      sbi->first_line = max-1;
  changed = 1;
     }
 }
 break;
    case 3:
 if (sbi->first_line==max-1) break;
 if (sbi->first_line >= max-1-nr)
     sbi->first_line=max-1;
 else
     sbi->first_line += nr;
 changed = 1;
 break;
    }
    if (changed) {
 redraw_rectangle(sbi);
 (*(sbi->func))(sbi->data, sbi->vertical);
    }
}

variable_types: max int

variable_types: nr int

variable_types: changed int

variable_types: i int


decompiled_code:
__int64 __fastcall scrollbar_motion(__int64 a1, int a2, int a3)
{
if ( *(_DWORD *)(a1 + 8) )
a2 = a3;
return position_changed(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, int a2, int a3)
{
if ( *(_DWORD *)(a1 + 8) )
a2 = a3;
return func7(a1, a2);
}

original_code:
static void scrollbar_motion(void *data, int x_pos, int y_pos)
{
    SCROLLBARINFO *sbi = (SCROLLBARINFO *) data;
    int pos;
    if (sbi->vertical)
 pos = y_pos;
    else
 pos = x_pos;
    position_changed(sbi, pos);
}

canonical_original_code:
static void scrollbar_motion(void *data, int x_pos, int y_pos)
{
    struct SCROLLBARINFO *sbi = (SCROLLBARINFO *) data;
    int pos;
    if (sbi->vertical)
 pos = y_pos;
    else
 pos = x_pos;
    position_changed(sbi, pos);
}

variable_types: pos int


decompiled_code:
int __fastcall scrollbar_move(Window *a1, int a2, int a3)
{
return XMoveWindow(display, *a1, a2, a3);
}

canonical_decompiled_code:
int __fastcall func11(Window *a1, int a2, int a3)
{
return XMoveWindow(display, *a1, a2, a3);
}

original_code:
void scrollbar_move(void *data, int xpos, int ypos)
{
    SCROLLBARINFO *sbi = (SCROLLBARINFO *) data;
    XMoveWindow(display, sbi->win_id, xpos, ypos);
}

canonical_original_code:
void scrollbar_move(void *data, int xpos, int ypos)
{
    struct SCROLLBARINFO *sbi = (SCROLLBARINFO *) data;
    XMoveWindow(display, sbi->win_id, xpos, ypos);
}

variable_types: xpos int

variable_types: ypos int

variable_types: struct SCROLLBARINFO { unsigned long win_id; int vertical; int shrt; int startpix; void (*func)(void *, int); void *data; } *


decompiled_code:
int __fastcall scrollbar_resize(int *a1, unsigned int a2)
{
unsigned int v2; // ebp
int v3; // er12

v2 = 24;
if ( a2 >= 0x18 )
v2 = a2;
a1[6] = v2;
v3 = start_pixel(a1);
a1[4] = v3;
a1[5] = end_pixel(a1) - v3;
if ( a1[2] )
XResizeWindow(display, *(_QWORD *)a1, 0xDu, v2);
else
XResizeWindow(display, *(_QWORD *)a1, v2, 0xDu);
return scrollbar_draw((__int64)a1);
}

canonical_decompiled_code:
int __fastcall func12(int *a1, unsigned int a2)
{
unsigned int v2; // ebp
int v3; // er12

v2 = 24;
if ( a2 >= 0x18 )
v2 = a2;
a1[6] = v2;
v3 = func2(a1);
a1[4] = v3;
a1[5] = func3(a1) - v3;
if ( a1[2] )
XResizeWindow(display, *(_QWORD *)a1, 0xDu, v2);
else
XResizeWindow(display, *(_QWORD *)a1, v2, 0xDu);
return func5((__int64)a1);
}

original_code:
void scrollbar_resize(void *data, unsigned int newsize)
{
    SCROLLBARINFO *sbi = (SCROLLBARINFO *) data;
    if ((newsize) < 2*12) newsize = 2*12;
    sbi->sb_size = newsize;
    sbi->startpix = start_pixel(sbi);
    sbi->sizepix = end_pixel(sbi) - sbi->startpix;
    if (sbi->vertical)
 XResizeWindow(display, sbi->win_id, 12 +1, newsize);
    else
 XResizeWindow(display, sbi->win_id, newsize, 12 +1);
    scrollbar_draw(data);
}

canonical_original_code:
void scrollbar_resize(void *data, unsigned int newsize)
{
    struct SCROLLBARINFO *sbi = (SCROLLBARINFO *) data;
    if ((newsize) < 2*12) newsize = 2*12;
    sbi->sb_size = newsize;
    sbi->startpix = start_pixel(sbi);
    sbi->sizepix = end_pixel(sbi) - sbi->startpix;
    if (sbi->vertical)
 XResizeWindow(display, sbi->win_id, 12 +1, newsize);
    else
 XResizeWindow(display, sbi->win_id, newsize, 12 +1);
    scrollbar_draw(data);
}

variable_types:
newsize
unsigned int


decompiled_code:
Cursor scrollbar_init()
{
Cursor result; // rax
__int64 v1; // rbx

scrollbar_mask = 26634LL;
scrollbar_attr.background_pixel = white_pixel;
scrollbar_attr.border_pixel = black_pixel;
result = colormap;
scrollbar_attr.colormap = colormap;
scrollbar_attr.event_mask = 237708LL;
if ( n_cursors > 0 )
{
v1 = 0LL;
do
{
result = XCreateFontCursor(display, cursors[v1]);
cursors[v1++] = result;
}
while ( n_cursors > (int)v1 );
}
return result;
}

canonical_decompiled_code:
Cursor func13()
{
Cursor result; // rax
__int64 v1; // rbx

scrollbar_mask = 26634LL;
scrollbar_attr.background_pixel = white_pixel;
scrollbar_attr.border_pixel = black_pixel;
result = colormap;
scrollbar_attr.colormap = colormap;
scrollbar_attr.event_mask = 237708LL;
if ( n_cursors > 0 )
{
v1 = 0LL;
do
{
result = XCreateFontCursor(display, cursors[v1]);
cursors[v1++] = result;
}
while ( n_cursors > (int)v1 );
}
return result;
}

original_code:
void scrollbar_init(void)
{
    int i;
    scrollbar_mask =
        ((1L<<1) | (1L<<3) | (1L<<14) | (1L<<11) | (1L<<13));
    scrollbar_attr.background_pixel = white_pixel;
    scrollbar_attr.border_pixel = black_pixel;
    scrollbar_attr.colormap = colormap;
    scrollbar_attr.event_mask = ((1L<<15) | (1L<<2)
     | (1L<<13) | (1L<<7)
     | (1L<<3) | (1L<<17)
     | (1L<<16));
    for (i=0; i<n_cursors; i++)
 cursors[i] = XCreateFontCursor(display,cursors[i]);
}

canonical_original_code:
void scrollbar_init()
{
    int i;
    scrollbar_mask =
        ((1L<<1) | (1L<<3) | (1L<<14) | (1L<<11) | (1L<<13));
    scrollbar_attr.background_pixel = white_pixel;
    scrollbar_attr.border_pixel = black_pixel;
    scrollbar_attr.colormap = colormap;
    scrollbar_attr.event_mask = ((1L<<15) | (1L<<2)
     | (1L<<13) | (1L<<7)
     | (1L<<3) | (1L<<17)
     | (1L<<16));
    for (i=0; i<n_cursors; i++)
 cursors[i] = XCreateFontCursor(display,cursors[i]);
}


decompiled_code:
int __fastcall scrollbar_set(int *a1, int a2, int a3)
{
a1[7] = a3;
a1[8] = a2;
return redraw_rectangle(a1);
}

canonical_decompiled_code:
int __fastcall func14(int *a1, int a2, int a3)
{
a1[7] = a3;
a1[8] = a2;
return func6(a1);
}

original_code:
void scrollbar_set(void *data, int f_line, int total_lines)
{
    SCROLLBARINFO *sbi = (SCROLLBARINFO *) data;
    sbi->nr_lines = total_lines;
    sbi->first_line = f_line;
    redraw_rectangle(sbi);
}

canonical_original_code:
void scrollbar_set(void *data, int f_line, int total_lines)
{
    struct SCROLLBARINFO *sbi = (SCROLLBARINFO *) data;
    sbi->nr_lines = total_lines;
    sbi->first_line = f_line;
    redraw_rectangle(sbi);
}


decompiled_code:
__int64 __fastcall scrollbar_line(int *a1, int a2)
{
int v2; // esi
int v3; // edx
int v4; // eax

if ( !a2 )
return (unsigned int)a1[8];
v2 = a1[8] + a2;
if ( v2 < 0 )
v2 = 0;
v3 = a1[7];
v4 = v3 - 1;
if ( v2 < v3 )
v4 = v2;
a1[8] = v4;
redraw_rectangle(a1);
return (unsigned int)a1[8];
}

canonical_decompiled_code:
__int64 __fastcall func15(int *a1, int a2)
{
int v2; // esi
int v3; // edx
int v4; // eax

if ( !a2 )
return (unsigned int)a1[8];
v2 = a1[8] + a2;
if ( v2 < 0 )
v2 = 0;
v3 = a1[7];
v4 = v3 - 1;
if ( v2 < v3 )
v4 = v2;
a1[8] = v4;
func6(a1);
return (unsigned int)a1[8];
}

original_code:
int scrollbar_line(void *data, int delta)
{
    SCROLLBARINFO *sbi = (SCROLLBARINFO *) data;
    if (!delta)
 return sbi->first_line;
    sbi->first_line+=delta;
    if (sbi->first_line<0) sbi->first_line=0;
    if (sbi->first_line>=sbi->nr_lines) sbi->first_line = sbi->nr_lines-1;
    redraw_rectangle(sbi);
    return sbi->first_line;
}

canonical_original_code:
int scrollbar_line(void *data, int delta)
{
    struct SCROLLBARINFO *sbi = (SCROLLBARINFO *) data;
    if (!delta)
 return sbi->first_line;
    sbi->first_line+=delta;
    if (sbi->first_line<0) sbi->first_line=0;
    if (sbi->first_line>=sbi->nr_lines) sbi->first_line = sbi->nr_lines-1;
    redraw_rectangle(sbi);
    return sbi->first_line;
}

variable_types: delta int


decompiled_code:
int __fastcall scrollbar_linesize(int *a1, int a2)
{
a1[9] = a2;
return redraw_rectangle(a1);
}

canonical_decompiled_code:
int __fastcall func16(int *a1, int a2)
{
a1[9] = a2;
return func6(a1);
}

original_code:
void scrollbar_linesize(void *data, int newsize)
{
    SCROLLBARINFO *sbi = (SCROLLBARINFO *) data;
    sbi->line_size = newsize;
    redraw_rectangle(sbi);
}

canonical_original_code:
void scrollbar_linesize(void *data, int newsize)
{
    struct SCROLLBARINFO *sbi = (SCROLLBARINFO *) data;
    sbi->line_size = newsize;
    redraw_rectangle(sbi);
}

variable_types:
data
void *

variable_types: newsize int


assigndouble

decompiled_code:
void __fastcall assigndouble(double *a1, double a2)
{
*a1 = a2;
}

canonical_decompiled_code:
void __fastcall func0(double *a1, double a2)
{
*a1 = a2;
}

original_code:
static void assigndouble(double y, double *x)
{
    *x=y;
}

variable_types: y double

variable_types:
x
double *


doubleadd

decompiled_code:
double __fastcall doubleadd(double a1, double a2)
{
return a1 + a2;
}

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

original_code:
static double doubleadd(double i, double j)
{
  return i+j;
}

variable_types: i double

variable_types: j double

return_type: double


doubleminus

decompiled_code:
double __fastcall doubleminus(double a1, double a2)
{
return a1 - a2;
}

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

original_code:
static double doubleminus(double i, double j)
{
  return i-j;
}


doublemult

decompiled_code:
double __fastcall doublemult(double a1, double a2)
{
return a1 * a2;
}

canonical_decompiled_code:
double __fastcall func3(double a1, double a2)
{
return a1 * a2;
}

original_code:
static double doublemult(double i, double j)
{
  return i*j;
}


doubledivide

decompiled_code:
double __fastcall doubledivide(double a1, double a2)
{
return a1 / a2;
}

canonical_decompiled_code:
double __fastcall func4(double a1, double a2)
{
return a1 / a2;
}

original_code:
static double doubledivide(double i, double j)
{
  return i/j;
}


doublenot

decompiled_code:
__m128d __fastcall doublenot(__m128d a1)
{
return _mm_xor_pd(a1, (__m128d)LC0);
}

canonical_decompiled_code:
__m128d __fastcall func5(__m128d a1)
{
return _mm_xor_pd(a1, (__m128d)LC0);
}

original_code:
static double doublenot(double i)
{
    return -i;
}


doubleland

decompiled_code:
double __fastcall doubleland(double a1, double a2)
{
return (double)((a2 != 0.0) & (unsigned __int8)(a1 != 0.0));
}

canonical_decompiled_code:
double __fastcall func6(double a1, double a2)
{
return (double)((a2 != 0.0) & (unsigned __int8)(a1 != 0.0));
}

original_code:
static double doubleland(double i, double j)
{
  return i && j;
}


doublelor

decompiled_code:
double __fastcall doublelor(double a1, double a2)
{
return (double)((a2 != 0.0) | (unsigned __int8)(a1 != 0.0));
}

canonical_decompiled_code:
double __fastcall func7(double a1, double a2)
{
return (double)((a2 != 0.0) | (unsigned __int8)(a1 != 0.0));
}

original_code:
static double doublelor(double i, double j)
{
  return i || j;
}


doublelxor

decompiled_code:
double __fastcall doublelxor(double a1, double a2)
{
return (double)((a2 != 0.0) ^ (unsigned __int8)(a1 != 0.0));
}

canonical_decompiled_code:
double __fastcall func8(double a1, double a2)
{
return (double)((a2 != 0.0) ^ (unsigned __int8)(a1 != 0.0));
}

original_code:
static double doublelxor(double i, double j)
{
  return (i&&!j)||(!i&&j);
}


doublelnot

decompiled_code:
double __fastcall doublelnot(double a1)
{
double result; // xmm0_8

if ( a1 == 0.0 )
result = *(double *)&LC2;
else
result = 0.0;
return result;
}

canonical_decompiled_code:
double __fastcall func9(double a1)
{
double result; // xmm0_8

if ( a1 == 0.0 )
result = *(double *)&LC2;
else
result = 0.0;
return result;
}

original_code:
static double doublelnot(double i)
{
  return !i;
}


doubleequal

decompiled_code:
double __fastcall doubleequal(double a1, double a2)
{
double result; // xmm0_8

if ( a1 == a2 )
result = *(double *)&LC2;
else
result = 0.0;
return result;
}

canonical_decompiled_code:
double __fastcall func10(double a1, double a2)
{
double result; // xmm0_8

if ( a1 == a2 )
result = *(double *)&LC2;
else
result = 0.0;
return result;
}

original_code:
static double doubleequal(double i, double j)
{
  return i==j;
}


doublenotequal

decompiled_code:
double __fastcall doublenotequal(double a1, double a2)
{
double result; // xmm0_8

if ( a1 == a2 )
result = 0.0;
else
result = *(double *)&LC2;
return result;
}

canonical_decompiled_code:
double __fastcall func11(double a1, double a2)
{
double result; // xmm0_8

if ( a1 == a2 )
result = 0.0;
else
result = *(double *)&LC2;
return result;
}

original_code:
static double doublenotequal(double i, double j)
{
  return i != j;
}


doublegreater

decompiled_code:
double __fastcall doublegreater(double a1, double a2)
{
double result; // xmm0_8

if ( a1 > a2 )
result = *(double *)&LC2;
else
result = 0.0;
return result;
}

canonical_decompiled_code:
double __fastcall func12(double a1, double a2)
{
double result; // xmm0_8

if ( a1 > a2 )
result = *(double *)&LC2;
else
result = 0.0;
return result;
}

original_code:
static double doublegreater(double i, double j)
{
  return i>j;
}


doubleless

decompiled_code:
double __fastcall doubleless(double a1, double a2)
{
double result; // xmm0_8

if ( a2 > a1 )
result = *(double *)&LC2;
else
result = 0.0;
return result;
}

canonical_decompiled_code:
double __fastcall func13(double a1, double a2)
{
double result; // xmm0_8

if ( a2 > a1 )
result = *(double *)&LC2;
else
result = 0.0;
return result;
}

original_code:
static double doubleless(double i, double j)
{
  return i<j;
}


doublelessequal

decompiled_code:
double __fastcall doublelessequal(double a1, double a2)
{
double result; // xmm0_8

if ( a2 >= a1 )
result = *(double *)&LC2;
else
result = 0.0;
return result;
}

canonical_decompiled_code:
double __fastcall func14(double a1, double a2)
{
double result; // xmm0_8

if ( a2 >= a1 )
result = *(double *)&LC2;
else
result = 0.0;
return result;
}

original_code:
static double doublelessequal(double i, double j)
{
  return i<=j;
}


doublegreaterequal

decompiled_code:
double __fastcall doublegreaterequal(double a1, double a2)
{
double result; // xmm0_8

if ( a1 >= a2 )
result = *(double *)&LC2;
else
result = 0.0;
return result;
}

canonical_decompiled_code:
double __fastcall func15(double a1, double a2)
{
double result; // xmm0_8

if ( a1 >= a2 )
result = *(double *)&LC2;
else
result = 0.0;
return result;
}

original_code:
static double doublegreaterequal(double i, double j)
{
  return i>=j;
}


decompiled_code:
__int64 __fastcall call_doubleref(__int64 (__fastcall *a1)(_QWORD), _QWORD **a2)
{
return a1(**a2);
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 (__fastcall *a1)(_QWORD), _QWORD **a2)
{
return a1(**a2);
}

original_code:
static int call_doubleref(int (*fcal)(), void **args)
{
   return (*fcal)(*((double**)args[0]));
}

canonical_original_code:
static int call_doubleref(int (*fcal)(), void **args)
{
   return (*fcal)(*((double **)args[0]));
}

variable_types:
fcal
int (*)()

variable_types:
args
void **


decompiled_code:
__int64 __fastcall call_doubledoubleref(__int64 (__fastcall *a1)(_QWORD, double), __int64 a2)
{
return a1(**(_QWORD **)(a2 + 8), **(double **)a2);
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 (__fastcall *a1)(_QWORD, double), __int64 a2)
{
return a1(**(_QWORD **)(a2 + 8), **(double **)a2);
}

original_code:
static int call_doubledoubleref(int (*fcal)(), void **args)
{
   return (*fcal)(*((double*)args[0]), *((double**)args[1]));
}

canonical_original_code:
static int call_doubledoubleref(int (*fcal)(), void **args)
{
   return (*fcal)(*((double *)args[0]), *((double **)args[1]));
}


decompiled_code:
__int64 __fastcall call_doubleresdouble(double (__fastcall *a1)(double), __int64 a2)
{
double *v2; // rbx

v2 = **(double ***)(a2 + 8);
*v2 = a1(**(double **)a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func18(double (__fastcall *a1)(double), __int64 a2)
{
double *v2; // rbx

v2 = **(double ***)(a2 + 8);
*v2 = a1(**(double **)a2);
return 0LL;
}

original_code:
static int call_doubleresdouble(double (*fcal)(), void **args)
{
   *(*((double**)args[1]))= (*fcal)(*((double*)args[0]));
   return 0;
}

canonical_original_code:
static int call_doubleresdouble(double (*fcal)(), void **args)
{
   *(*((double **)args[1]))= (*fcal)(*((double *)args[0]));
   return 0;
}

variable_types:
fcal
double (*)()


decompiled_code:
void __fastcall call_doubledoubleresdouble(double (__fastcall *a1)(double, double), __int64 a2)
{
double *v2; // rbx

v2 = **(double ***)(a2 + 16);
*v2 = a1(**(double **)a2, **(double **)(a2 + 8));
}

canonical_decompiled_code:
void __fastcall func19(double (__fastcall *a1)(double, double), __int64 a2)
{
double *v2; // rbx

v2 = **(double ***)(a2 + 16);
*v2 = a1(**(double **)a2, **(double **)(a2 + 8));
}

original_code:
static int call_doubledoubleresdouble(double (*fcal)(), void **args)
{
   *(*((double**)args[2]))= (*fcal)(*((double*)args[0]), *((double*)args[1]));
}

canonical_original_code:
static int call_doubledoubleresdouble(double (*fcal)(), void **args)
{
   *(*((double **)args[2]))= (*fcal)(*((double *)args[0]), *((double *)args[1]));
}


decompiled_code:
__int64 __fastcall call_strdouble(__int64 (__fastcall *a1)(_QWORD, double), __int64 a2)
{
return a1(**(_QWORD **)a2, **(double **)(a2 + 8));
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 (__fastcall *a1)(_QWORD, double), __int64 a2)
{
return a1(**(_QWORD **)a2, **(double **)(a2 + 8));
}

original_code:
static int call_strdouble(int (*fcal)(), void **args)
{
   return (*fcal)(*((Uchar**)args[0]), *((double*)args[1]));
}

canonical_original_code:
static int call_strdouble(int (*fcal)(), void **args)
{
   return (*fcal)(*((unsigned short **)args[0]), *((double *)args[1]));
}


doubleshiftright

decompiled_code:
double __fastcall doubleshiftright(double a1, double a2)
{
return pow(0.5, a2) * a1;
}

canonical_decompiled_code:
double __fastcall func21(double a1, double a2)
{
return pow(0.5, a2) * a1;
}

original_code:
static double doubleshiftright(double i, double j)
{
  return i*pow(0.5,j);
}


doubleshiftleft

decompiled_code:
double __fastcall doubleshiftleft(double a1, double a2)
{
return pow(2.0, a2) * a1;
}

canonical_decompiled_code:
double __fastcall func22(double a1, double a2)
{
return pow(2.0, a2) * a1;
}

original_code:
static double doubleshiftleft(double i, double j)
{
  return i*pow(2.0,j);
}


doublexor

decompiled_code:
double __fastcall doublexor(double a1, double a2)
{
return pow(a1, a2);
}

canonical_decompiled_code:
double __fastcall func23(double a1, double a2)
{
return pow(a1, a2);
}

original_code:
static double doublexor(double i, double j)
{
  return pow(i,j);
}


doubleremain

decompiled_code:
double __fastcall doubleremain(double a1, double a2)
{
return fmod(a1, a2);
}

canonical_decompiled_code:
double __fastcall func24(double a1, double a2)
{
return fmod(a1, a2);
}

original_code:
static double doubleremain(double i, double j)
{
  return fmod(i,j);
}


printdouble

decompiled_code:
int __fastcall printdouble(double a1)
{
const char *v1; // rax

v1 = (const char *)UstrtoLocale();
return printf("%s: %lg\n", v1, a1);
}

canonical_decompiled_code:
int __fastcall func25(double a1)
{
const char *v1; // rax

v1 = (const char *)UstrtoLocale();
return printf("%s: %lg\n", v1, a1);
}

original_code:
static void printdouble(Uchar *str, double x)
{
    printf("%s: %lg\n", UstrtoLocale(str), x);
}

canonical_original_code:
static void printdouble(unsigned short *str, double x)
{
    printf("%s: %lg\n", UstrtoLocale(str), x);
}

variable_types:
str
unsigned short *

variable_types: x double


updateeditdouble

decompiled_code:
int __fastcall updateeditdouble(const void *a1)
{
return printf("Updated editfield for %p\n", a1);
}

canonical_decompiled_code:
int __fastcall func26(const void *a1)
{
return printf("Updated editfield for %p\n", a1);
}

original_code:
static void updateeditdouble(double *x)
{
    printf("Updated editfield for %p\n", x);
}


updatevardouble

decompiled_code:
int __fastcall updatevardouble(const void *a1)
{
return printf("Updated variable %p\n", a1);
}

canonical_decompiled_code:
int __fastcall func27(const void *a1)
{
return printf("Updated variable %p\n", a1);
}

original_code:
static void updatevardouble(double *x)
{
    printf("Updated variable %p\n", x);
}