decompiled_code:
void __fastcall ActorInstance_RVC_decoder__texture_V__idct2d__row_constructor(__int64 a1)
{
*(_DWORD *)(a1 + 72) = 0;
}

original_code:
static void ActorInstance_RVC_decoder__texture_V__idct2d__row_constructor(AbstractActorInstance *pBase) {
  ActorInstance_RVC_decoder__texture_V__idct2d__row *thisActor=(ActorInstance_RVC_decoder__texture_V__idct2d__row*) pBase;
  thisActor->_fsmState = 0;
  {
  }
}

canonical_original_code:
static void ActorInstance_RVC_decoder__texture_V__idct2d__row_constructor(struct AbstractActorInstance *pBase) {
  struct ActorInstance_RVC_decoder__texture_V__idct2d__row *thisActor = (ActorInstance_RVC_decoder__texture_V__idct2d__row*) pBase;
  thisActor->_fsmState = 0;
  {
  }
}

variable_types: struct ActorInstance_RVC_decoder__texture_V__idct2d__row { struct AbstractActorInstance { struct dllist_link_tag { struct dllist_link_tag *suc; } listEntry; struct ActorClass { unsigned int majorVersion; unsigned int minorVersion; char *name; int sizeActorInstance; int numInputPorts; struct PortDescription { int dummy; char *name; int tokenSize; struct tokenFn { char *(*serialize)(void *, char *); char *(*deserialize)(void **, char *); long (*size)(void *); int (*free)(void *, int); } *functions; } *inputPortDescriptions; int numOutputPorts; struct PortDescription *outputPortDescriptions; int numActions; struct ActionDescription { char *name; int *consumption; int *production; } *actionDescriptions; int *(*action_scheduler)(struct AbstractActorInstance *); void (*constructor)(struct AbstractActorInstance *); void (*destructor)(struct AbstractActorInstance *); void (*set_param)(struct AbstractActorInstance *, char *, char *); } *actorClass; char *instanceName; int numInputPorts; struct InputPort { struct dllist_link_tag asConsumer; struct OutputPort { struct LocalOutputPort { void *bufferStart; void *bufferEnd; void *writePtr; unsigned int spaceLeft; } localOutputPort; unsigned int capacity; unsigned int tokensProduced; unsigned int fullAt; struct tokenFn functions; struct dllist_head_t { struct dllist_link_tag head_element; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; } consumers; } *producer; struct LocalInputPort { void *bufferStart; void *bufferEnd; void *readPtr; unsigned int available; } localInputPort; unsigned int tokensConsumed; unsigned int drainedAt; unsigned int capacity; struct tokenFn functions; } *inputPort; int numOutputPorts; struct OutputPort *outputPort; int *(*action_scheduler)(struct AbstractActorInstance *); } base; int _fsmState; } *

user_defined_types: struct ActorInstance_RVC_decoder__texture_V__idct2d__row { struct AbstractActorInstance base; int _fsmState; }

user_defined_types: struct dllist_head_t { struct dllist_link_tag head_element; union pthread_mutex_t mutex; }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }


repo: Caltoopia/caltoopia-calvin

decompiled_code:
void *__fastcall RVC_decoder__texture_V__idct2d__row_action_scheduler(__int64 a1)
{
unsigned int v1; // eax

v1 = pinAvailIn_int32_t_isra_0(*(_DWORD *)(*(_QWORD *)(a1 + 40) + 48LL));
do
{
while ( v1 > 7 )
{
if ( (unsigned int)pinAvailOut_int32_t_isra_0(*(_DWORD *)(*(_QWORD *)(a1 + 56) + 24LL)) <= 7 )
return &exitcode_block_Any;
action0(a1);
v1 = pinAvailIn_int32_t_isra_0(*(_DWORD *)(*(_QWORD *)(a1 + 40) + 48LL));
}
}
while ( *(_DWORD *)(a1 + 72) );
return &exitcode_block_Any;
}

canonical_decompiled_code:
void *__fastcall func19(__int64 a1)
{
unsigned int v1; // eax

v1 = func18(*(_DWORD *)(*(_QWORD *)(a1 + 40) + 48LL));
do
{
while ( v1 > 7 )
{
if ( (unsigned int)func17(*(_DWORD *)(*(_QWORD *)(a1 + 56) + 24LL)) <= 7 )
return &exitcode_block_Any;
func16(a1);
v1 = func18(*(_DWORD *)(*(_QWORD *)(a1 + 40) + 48LL));
}
}
while ( *(_DWORD *)(a1 + 72) );
return &exitcode_block_Any;
}

original_code:
static const int *RVC_decoder__texture_V__idct2d__row_action_scheduler(AbstractActorInstance *pBase) {
  const int *result = exit_code_yield;
  ActorInstance_RVC_decoder__texture_V__idct2d__row *thisActor=(ActorInstance_RVC_decoder__texture_V__idct2d__row*) pBase;
  void *context = ((void *)0); context = context;
  while(1) {
    if ((pinAvailIn_int32_t(&(thisActor->base.inputPort[0].localInputPort)) >= 8)) {
      if ((pinAvailOut_int32_t(&(thisActor->base.outputPort[0].localOutputPort)) >= 8)) {
        action0(thisActor);
        continue;
      } else {
        result = exitcode_block_Any;
        goto out;
      }
    }
    switch(thisActor->_fsmState) {
      case 0:
        result = exitcode_block_Any;
        goto out;
        break;
    }
  }
  out:

  return result;
}

canonical_original_code:
static int *RVC_decoder__texture_V__idct2d__row_action_scheduler(struct AbstractActorInstance *pBase) {
  int *result = exit_code_yield;
  struct ActorInstance_RVC_decoder__texture_V__idct2d__row *thisActor = (ActorInstance_RVC_decoder__texture_V__idct2d__row*) pBase;
  void *context = ((void *)0); context = context;
  while(1) {
    if ((pinAvailIn_int32_t(&(thisActor->base.inputPort[0].localInputPort)) >= 8)) {
      if ((pinAvailOut_int32_t(&(thisActor->base.outputPort[0].localOutputPort)) >= 8)) {
        action0(thisActor);
        continue;
      } else {
        result = exitcode_block_Any;
        goto out;
      }
    }
    switch(thisActor->_fsmState) {
      case 0:
        result = exitcode_block_Any;
        goto out;
        break;
    }
  }
  out:

  return result;
}

variable_types: struct AbstractActorInstance { struct dllist_link_tag { struct dllist_link_tag *suc; } listEntry; struct ActorClass { unsigned int majorVersion; unsigned int minorVersion; char *name; int sizeActorInstance; int numInputPorts; struct PortDescription { int dummy; char *name; int tokenSize; struct tokenFn { char *(*serialize)(void *, char *); char *(*deserialize)(void **, char *); long (*size)(void *); int (*free)(void *, int); } *functions; } *inputPortDescriptions; int numOutputPorts; struct PortDescription *outputPortDescriptions; int numActions; struct ActionDescription { char *name; int *consumption; int *production; } *actionDescriptions; int *(*action_scheduler)(struct AbstractActorInstance *); void (*constructor)(struct AbstractActorInstance *); void (*destructor)(struct AbstractActorInstance *); void (*set_param)(struct AbstractActorInstance *, char *, char *); } *actorClass; char *instanceName; int numInputPorts; struct InputPort { struct dllist_link_tag asConsumer; struct OutputPort { struct LocalOutputPort { void *bufferStart; void *bufferEnd; void *writePtr; unsigned int spaceLeft; } localOutputPort; unsigned int capacity; unsigned int tokensProduced; unsigned int fullAt; struct tokenFn functions; struct dllist_head_t { struct dllist_link_tag head_element; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; } consumers; } *producer; struct LocalInputPort { void *bufferStart; void *bufferEnd; void *readPtr; unsigned int available; } localInputPort; unsigned int tokensConsumed; unsigned int drainedAt; unsigned int capacity; struct tokenFn functions; } *inputPort; int numOutputPorts; struct OutputPort *outputPort; int *(*action_scheduler)(struct AbstractActorInstance *); } *

variable_types:
result
int *

variable_types:
context
void *

return_type: int *

user_defined_types: struct AbstractActorInstance { struct dllist_link_tag listEntry; struct ActorClass *actorClass; char *instanceName; int numInputPorts; struct InputPort *inputPort; int numOutputPorts; struct OutputPort *outputPort; int *(*action_scheduler)(struct AbstractActorInstance *); }

user_defined_types: struct ActorClass { unsigned int majorVersion; unsigned int minorVersion; char *name; int sizeActorInstance; int numInputPorts; struct PortDescription *inputPortDescriptions; int numOutputPorts; struct PortDescription *outputPortDescriptions; int numActions; struct ActionDescription *actionDescriptions; int *(*action_scheduler)(struct AbstractActorInstance *); void (*constructor)(struct AbstractActorInstance *); void (*destructor)(struct AbstractActorInstance *); void (*set_param)(struct AbstractActorInstance *, char *, char *); }

user_defined_types: struct InputPort { struct dllist_link_tag asConsumer; struct OutputPort *producer; struct LocalInputPort localInputPort; unsigned int tokensConsumed; unsigned int drainedAt; unsigned int capacity; struct tokenFn functions; }

user_defined_types: struct PortDescription { int dummy; char *name; int tokenSize; struct tokenFn *functions; }

user_defined_types: struct OutputPort { struct LocalOutputPort localOutputPort; unsigned int capacity; unsigned int tokensProduced; unsigned int fullAt; struct tokenFn functions; struct dllist_head_t consumers; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }


decompiled_code:
void __fastcall ActorInstance_RVC_decoder__texture_Y__DCsplit_constructor(__int64 a1)
{
*(_DWORD *)(a1 + 72) = 0;
}

canonical_decompiled_code:
void __fastcall func6(__int64 a1)
{
*(_DWORD *)(a1 + 72) = 0;
}

original_code:
static void ActorInstance_RVC_decoder__texture_Y__DCsplit_constructor(AbstractActorInstance *pBase) {
  ActorInstance_RVC_decoder__texture_Y__DCsplit *thisActor=(ActorInstance_RVC_decoder__texture_Y__DCsplit*) pBase;
  thisActor->_fsmState = 0;
  {
  }
}

canonical_original_code:
static void ActorInstance_RVC_decoder__texture_Y__DCsplit_constructor(struct AbstractActorInstance *pBase) {
  struct ActorInstance_RVC_decoder__texture_Y__DCsplit *thisActor = (ActorInstance_RVC_decoder__texture_Y__DCsplit*) pBase;
  thisActor->_fsmState = 0;
  {
  }
}

variable_types: struct ActorInstance_RVC_decoder__texture_Y__DCsplit { struct AbstractActorInstance { struct dllist_link_tag { struct dllist_link_tag *suc; } listEntry; struct ActorClass { unsigned int majorVersion; unsigned int minorVersion; char *name; int sizeActorInstance; int numInputPorts; struct PortDescription { int dummy; char *name; int tokenSize; struct tokenFn { char *(*serialize)(void *, char *); char *(*deserialize)(void **, char *); long (*size)(void *); int (*free)(void *, int); } *functions; } *inputPortDescriptions; int numOutputPorts; struct PortDescription *outputPortDescriptions; int numActions; struct ActionDescription { char *name; int *consumption; int *production; } *actionDescriptions; int *(*action_scheduler)(struct AbstractActorInstance *); void (*constructor)(struct AbstractActorInstance *); void (*destructor)(struct AbstractActorInstance *); void (*set_param)(struct AbstractActorInstance *, char *, char *); } *actorClass; char *instanceName; int numInputPorts; struct InputPort { struct dllist_link_tag asConsumer; struct OutputPort { struct LocalOutputPort { void *bufferStart; void *bufferEnd; void *writePtr; unsigned int spaceLeft; } localOutputPort; unsigned int capacity; unsigned int tokensProduced; unsigned int fullAt; struct tokenFn functions; struct dllist_head_t { struct dllist_link_tag head_element; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; } consumers; } *producer; struct LocalInputPort { void *bufferStart; void *bufferEnd; void *readPtr; unsigned int available; } localInputPort; unsigned int tokensConsumed; unsigned int drainedAt; unsigned int capacity; struct tokenFn functions; } *inputPort; int numOutputPorts; struct OutputPort *outputPort; int *(*action_scheduler)(struct AbstractActorInstance *); } base; int _fsmState; } *

return_type: void

user_defined_types: struct ActorInstance_RVC_decoder__texture_Y__DCsplit { struct AbstractActorInstance base; int _fsmState; }


decompiled_code:
void *__fastcall RVC_decoder__texture_Y__DCsplit_action_scheduler(__int64 a1)
{
unsigned int i; // eax
__int64 v2; // rdx

for ( i = pinAvailIn_int32_t_isra_0(*(_DWORD *)(*(_QWORD *)(a1 + 40) + 48LL));
;
i = pinAvailIn_int32_t_isra_0(*(_DWORD *)(*(_QWORD *)(a1 + 40) + 48LL)) )
{
while ( i <= 0x3F )
{
if ( !*(_DWORD *)(a1 + 72) )
return &exitcode_block_Any;
}
if ( !(unsigned int)pinAvailOut_int32_t_isra_0(*(_DWORD *)(*(_QWORD *)(a1 + 56) + 24LL))
|| (unsigned int)pinAvailOut_int32_t_isra_0(*(_DWORD *)(v2 + 160)) <= 0x3E )
{
break;
}
action0(a1);
}
return &exitcode_block_Any;
}

canonical_decompiled_code:
void *__fastcall func12(__int64 a1)
{
unsigned int i; // eax
__int64 v2; // rdx

for ( i = func11(*(_DWORD *)(*(_QWORD *)(a1 + 40) + 48LL));
;
i = func11(*(_DWORD *)(*(_QWORD *)(a1 + 40) + 48LL)) )
{
while ( i <= 0x3F )
{
if ( !*(_DWORD *)(a1 + 72) )
return &exitcode_block_Any;
}
if ( !(unsigned int)func10(*(_DWORD *)(*(_QWORD *)(a1 + 56) + 24LL))
|| (unsigned int)func10(*(_DWORD *)(v2 + 160)) <= 0x3E )
{
break;
}
func9(a1);
}
return &exitcode_block_Any;
}

original_code:
static const int *RVC_decoder__texture_Y__DCsplit_action_scheduler(AbstractActorInstance *pBase) {
  const int *result = exit_code_yield;
  ActorInstance_RVC_decoder__texture_Y__DCsplit *thisActor=(ActorInstance_RVC_decoder__texture_Y__DCsplit*) pBase;
  void *context = ((void *)0); context = context;
  while(1) {
    if ((pinAvailIn_int32_t(&(thisActor->base.inputPort[0].localInputPort)) >= 64)) {
      if ((pinAvailOut_int32_t(&(thisActor->base.outputPort[0].localOutputPort)) >= 1) && (pinAvailOut_int32_t(&(thisActor->base.outputPort[1].localOutputPort)) >= 63)) {
        action0(thisActor);
        continue;
      } else {
        result = exitcode_block_Any;
        goto out;
      }
    }
    switch(thisActor->_fsmState) {
      case 0:
        result = exitcode_block_Any;
        goto out;
        break;
    }
  }
  out:

  return result;
}

canonical_original_code:
static int *RVC_decoder__texture_Y__DCsplit_action_scheduler(struct AbstractActorInstance *pBase) {
  int *result = exit_code_yield;
  struct ActorInstance_RVC_decoder__texture_Y__DCsplit *thisActor = (ActorInstance_RVC_decoder__texture_Y__DCsplit*) pBase;
  void *context = ((void *)0); context = context;
  while(1) {
    if ((pinAvailIn_int32_t(&(thisActor->base.inputPort[0].localInputPort)) >= 64)) {
      if ((pinAvailOut_int32_t(&(thisActor->base.outputPort[0].localOutputPort)) >= 1) && (pinAvailOut_int32_t(&(thisActor->base.outputPort[1].localOutputPort)) >= 63)) {
        action0(thisActor);
        continue;
      } else {
        result = exitcode_block_Any;
        goto out;
      }
    }
    switch(thisActor->_fsmState) {
      case 0:
        result = exitcode_block_Any;
        goto out;
        break;
    }
  }
  out:

  return result;
}

user_defined_types: struct dllist_link_tag { struct dllist_link_tag *suc; }

user_defined_types: struct LocalInputPort { void *bufferStart; void *bufferEnd; void *readPtr; unsigned int available; }

user_defined_types: struct ActionDescription { char *name; int *consumption; int *production; }

user_defined_types: struct LocalOutputPort { void *bufferStart; void *bufferEnd; void *writePtr; unsigned int spaceLeft; }

user_defined_types: struct tokenFn { char *(*serialize)(void *, char *); char *(*deserialize)(void **, char *); long (*size)(void *); int (*free)(void *, int); }

user_defined_types: struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; }


bitor

decompiled_code:
__int64 __fastcall bitor(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 inline int32_t bitor(int32_t x, int32_t y) { return x | y; }

canonical_original_code: static inline int bitor(int x, int y) { return x | y; }

variable_types: x int

variable_types: y int

return_type: int


decompiled_code:
__int64 __fastcall pinRead_int32_t(__int64 a1)
{
int v1; // eax
unsigned int *v2; // rcx
unsigned int v3; // er8
_DWORD *v4; // rdx

v1 = *(_DWORD *)(a1 + 24);
v2 = *(unsigned int **)(a1 + 16);
if ( !v1 )
__assert_fail("p->available > 0", "../../actors-fifo.h", 0x6Bu, "pinRead_int32_t");
v3 = *v2;
v4 = v2 + 1;
if ( *(_QWORD *)(a1 + 8) <= (unsigned __int64)(v2 + 1) )
v4 = *(_DWORD **)a1;
*(_QWORD *)(a1 + 16) = v4;
*(_DWORD *)(a1 + 24) = v1 - 1;
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
int v1; // eax
unsigned int *v2; // rcx
unsigned int v3; // er8
_DWORD *v4; // rdx

v1 = *(_DWORD *)(a1 + 24);
v2 = *(unsigned int **)(a1 + 16);
if ( !v1 )
__assert_fail("p->available > 0", "../../actors-fifo.h", 0x6Bu, "pinRead_int32_t");
v3 = *v2;
v4 = v2 + 1;
if ( *(_QWORD *)(a1 + 8) <= (unsigned __int64)(v2 + 1) )
v4 = *(_DWORD **)a1;
*(_QWORD *)(a1 + 16) = v4;
*(_DWORD *)(a1 + 24) = v1 - 1;
return v3;
}

original_code:
static inline int32_t pinRead_int32_t(LocalInputPort *p)
{
  const int32_t *readPtr=(const int32_t *) p->readPtr;
  int32_t result;
  ((void) sizeof ((p->available > 0) ? 1 : 0), __extension__ ({ if (p->available > 0) ; else __assert_fail ("p->available > 0", "../../actors-fifo.h", 107, __extension__ __PRETTY_FUNCTION__); }));
  result = (int32_t) *readPtr++;
  if (readPtr >= (const int32_t*) p->bufferEnd)
    readPtr = (const int32_t*)p->bufferStart;
  p->readPtr=readPtr;
  p->available--;
  return result;
}

canonical_original_code:
static inline int pinRead_int32_t(struct LocalInputPort *p)
{
  int *readPtr = (const int32_t *) p->readPtr;
  int result;
  ((void) sizeof ((p->available > 0) ? 1 : 0), __extension__ ({ if (p->available > 0) ; else __assert_fail ("p->available > 0", "../../actors-fifo.h", 107, __extension__ __PRETTY_FUNCTION__); }));
  result = (int) *readPtr++;
  if (readPtr >= (int *) p->bufferEnd)
    readPtr = (int *)p->bufferStart;
  p->readPtr=readPtr;
  p->available--;
  return result;
}

variable_types: struct LocalInputPort { void *bufferStart; void *bufferEnd; void *readPtr; unsigned int available; } *

variable_types:
readPtr
int *

variable_types: result int


decompiled_code:
_BOOL8 __fastcall RVC_decoder__texture_V__IAP__DOLLAR__d10566(__int64 a1, __int64 a2)
{
return (unsigned int)pinPeek_int32_t_constprop_0(*(_QWORD *)(a2 + 40) + 232LL) == -2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func20(__int64 a1, __int64 a2)
{
return (unsigned int)func14(*(_QWORD *)(a2 + 40) + 232LL) == -2;
}

original_code:
bool_t RVC_decoder__texture_V__IAP__DOLLAR__d10566(art_action_context_t *context, ActorInstance_RVC_decoder__texture_V__IAP *thisActor) {
  int32_t s;
  {
    bool_t ret;
    s = pinPeek_int32_t(&(thisActor->base.inputPort[2].localInputPort), 0);
    ret = (s == -2);
    return ret;
  }
}

canonical_original_code:
int RVC_decoder__texture_V__IAP__DOLLAR__d10566(void *context, struct ActorInstance_RVC_decoder__texture_V__IAP *thisActor) {
  int s;
  {
    int ret;
    s = pinPeek_int32_t(&(thisActor->base.inputPort[2].localInputPort), 0);
    ret = (s == -2);
    return ret;
  }
}

variable_types: struct ActorInstance_RVC_decoder__texture_V__IAP { struct AbstractActorInstance { struct dllist_link_tag { struct dllist_link_tag *suc; } listEntry; struct ActorClass { unsigned int majorVersion; unsigned int minorVersion; char *name; int sizeActorInstance; int numInputPorts; struct PortDescription { int dummy; char *name; int tokenSize; struct tokenFn { char *(*serialize)(void *, char *); char *(*deserialize)(void **, char *); long (*size)(void *); int (*free)(void *, int); } *functions; } *inputPortDescriptions; int numOutputPorts; struct PortDescription *outputPortDescriptions; int numActions; struct ActionDescription { char *name; int *consumption; int *production; } *actionDescriptions; int *(*action_scheduler)(struct AbstractActorInstance *); void (*constructor)(struct AbstractActorInstance *); void (*destructor)(struct AbstractActorInstance *); void (*set_param)(struct AbstractActorInstance *, char *, char *); } *actorClass; char *instanceName; int numInputPorts; struct InputPort { struct dllist_link_tag asConsumer; struct OutputPort { struct LocalOutputPort { void *bufferStart; void *bufferEnd; void *writePtr; unsigned int spaceLeft; } localOutputPort; unsigned int capacity; unsigned int tokensProduced; unsigned int fullAt; struct tokenFn functions; struct dllist_head_t { struct dllist_link_tag head_element; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; } consumers; } *producer; struct LocalInputPort { void *bufferStart; void *bufferEnd; void *readPtr; unsigned int available; } localInputPort; unsigned int tokensConsumed; unsigned int drainedAt; unsigned int capacity; struct tokenFn functions; } *inputPort; int numOutputPorts; struct OutputPort *outputPort; int *(*action_scheduler)(struct AbstractActorInstance *); } base; int _fsmState; int ptr; int pred_ptr; int acpred_flag; int top; int *buf; int s_prev_quant; int count; int s_quant; } *

variable_types: s int

variable_types: ret int

user_defined_types: struct ActorInstance_RVC_decoder__texture_V__IAP { struct AbstractActorInstance base; int _fsmState; int ptr; int pred_ptr; int acpred_flag; int top; int *buf; int s_prev_quant; int count; int s_quant; }


decompiled_code:
__int64 __fastcall RVC_decoder__texture_V__IAP__DOLLAR__d10577(__int64 a1, __int64 a2)
{
return (unsigned int)pinPeek_int32_t_constprop_0(*(_QWORD *)(a2 + 40) + 232LL) >> 31;
}

canonical_decompiled_code:
__int64 __fastcall func21(__int64 a1, __int64 a2)
{
return (unsigned int)func14(*(_QWORD *)(a2 + 40) + 232LL) >> 31;
}

original_code:
bool_t RVC_decoder__texture_V__IAP__DOLLAR__d10577(art_action_context_t *context, ActorInstance_RVC_decoder__texture_V__IAP *thisActor) {
  int32_t s;
  {
    bool_t ret;
    s = pinPeek_int32_t(&(thisActor->base.inputPort[2].localInputPort), 0);
    ret = (s < 0);
    return ret;
  }
}

canonical_original_code:
int RVC_decoder__texture_V__IAP__DOLLAR__d10577(void *context, struct ActorInstance_RVC_decoder__texture_V__IAP *thisActor) {
  int s;
  {
    int ret;
    s = pinPeek_int32_t(&(thisActor->base.inputPort[2].localInputPort), 0);
    ret = (s < 0);
    return ret;
  }
}


decompiled_code:
_BOOL8 __fastcall RVC_decoder__texture_V__IAP__DOLLAR__d10606(__int64 a1, __int64 a2)
{
return *(_DWORD *)(a2 + 108) == 64;
}

original_code:
bool_t RVC_decoder__texture_V__IAP__DOLLAR__d10606(art_action_context_t *context, ActorInstance_RVC_decoder__texture_V__IAP *thisActor) {
  {
    bool_t ret;
    ret = (thisActor->count == 64);
    return ret;
  }
}

canonical_original_code:
int RVC_decoder__texture_V__IAP__DOLLAR__d10606(void *context, struct ActorInstance_RVC_decoder__texture_V__IAP *thisActor) {
  {
    int ret;
    ret = (thisActor->count == 64);
    return ret;
  }
}


decompiled_code:
void *__fastcall RVC_decoder__texture_V__IAP_action_scheduler(__int64 a1)
{
int v1; // eax
__int64 v3; // rdx
__int64 v4; // rdx
__int64 v5; // rdx

v1 = *(_DWORD *)(a1 + 72);
do
{
if ( !v1 )
goto LABEL_9;
}
while ( v1 != 1 );
LABEL_4:
while ( !(unsigned int)RVC_decoder__texture_V__IAP__DOLLAR__d10606(0LL, a1) )
{
if ( !(unsigned int)pinAvailIn_int32_t_isra_0(*(_DWORD *)(*(_QWORD *)(a1 + 40) + 48LL))
|| !(unsigned int)pinAvailOut_int32_t_isra_0(*(_DWORD *)(*(_QWORD *)(a1 + 56) + 24LL)) )
{
return &exitcode_block_Any;
}
action4__copy(a1);
*(_DWORD *)(a1 + 72) = 1;
}
action3__advance(a1);
*(_DWORD *)(a1 + 72) = 0;
LABEL_9:
while ( (unsigned int)pinAvailIn_int32_t_isra_0(*(_DWORD *)(*(_QWORD *)(a1 + 40) + 256LL)) )
{
if ( !(unsigned int)RVC_decoder__texture_V__IAP__DOLLAR__d10566(0LL, a1) )
{
if ( !(unsigned int)pinAvailIn_int32_t_isra_0(*(_DWORD *)(*(_QWORD *)(a1 + 40) + 256LL)) )
return &exitcode_block_Any;
if ( (unsigned int)RVC_decoder__texture_V__IAP__DOLLAR__d10577(0LL, a1) )
{
action1__skip(a1);
*(_DWORD *)(a1 + 72) = 1;
goto LABEL_4;
}
if ( (unsigned int)pinAvailIn_int32_t_isra_0(*(_DWORD *)(*(_QWORD *)(a1 + 40) + 256LL))
&& (unsigned int)pinAvailIn_int32_t_isra_0(*(_DWORD *)(v3 + 152))
&& (unsigned int)pinAvailIn_int32_t_isra_0(*(_DWORD *)(v4 + 360))
&& (unsigned int)pinAvailIn_int32_t_isra_0(*(_DWORD *)(v5 + 464)) )
{
action2__start(a1);
*(_DWORD *)(a1 + 72) = 1;
goto LABEL_4;
}
return &exitcode_block_Any;
}
action0__newvop(a1);
*(_DWORD *)(a1 + 72) = 0;
}
return &exitcode_block_Any;
}

canonical_decompiled_code:
void *__fastcall func23(__int64 a1)
{
int v1; // eax
__int64 v3; // rdx
__int64 v4; // rdx
__int64 v5; // rdx

v1 = *(_DWORD *)(a1 + 72);
do
{
if ( !v1 )
goto LABEL_9;
}
while ( v1 != 1 );
LABEL_4:
while ( !(unsigned int)func22(0LL, a1) )
{
if ( !(unsigned int)func19(*(_DWORD *)(*(_QWORD *)(a1 + 40) + 48LL))
|| !(unsigned int)func18(*(_DWORD *)(*(_QWORD *)(a1 + 56) + 24LL)) )
{
return &exitcode_block_Any;
}
action4__copy(a1);
*(_DWORD *)(a1 + 72) = 1;
}
func7(a1);
*(_DWORD *)(a1 + 72) = 0;
LABEL_9:
while ( (unsigned int)func19(*(_DWORD *)(*(_QWORD *)(a1 + 40) + 256LL)) )
{
if ( !(unsigned int)func20(0LL, a1) )
{
if ( !(unsigned int)func19(*(_DWORD *)(*(_QWORD *)(a1 + 40) + 256LL)) )
return &exitcode_block_Any;
if ( (unsigned int)func21(0LL, a1) )
{
func11(a1);
*(_DWORD *)(a1 + 72) = 1;
goto LABEL_4;
}
if ( (unsigned int)func19(*(_DWORD *)(*(_QWORD *)(a1 + 40) + 256LL))
&& (unsigned int)func19(*(_DWORD *)(v3 + 152))
&& (unsigned int)func19(*(_DWORD *)(v4 + 360))
&& (unsigned int)func19(*(_DWORD *)(v5 + 464)) )
{
func12(a1);
*(_DWORD *)(a1 + 72) = 1;
goto LABEL_4;
}
return &exitcode_block_Any;
}
func10(a1);
*(_DWORD *)(a1 + 72) = 0;
}
return &exitcode_block_Any;
}

original_code:
static const int *RVC_decoder__texture_V__IAP_action_scheduler(AbstractActorInstance *pBase) {
  const int *result = exit_code_yield;
  ActorInstance_RVC_decoder__texture_V__IAP *thisActor=(ActorInstance_RVC_decoder__texture_V__IAP*) pBase;
  void *context = ((void *)0); context = context;
  while(1) {
    switch(thisActor->_fsmState) {
      case 0:
        if ((pinAvailIn_int32_t(&(thisActor->base.inputPort[2].localInputPort)) >= 1)) {
          if (RVC_decoder__texture_V__IAP__DOLLAR__d10566(context, thisActor)) {
            action0__newvop(thisActor);
            thisActor->_fsmState = 0;
            continue;
          }
        }
        if ((pinAvailIn_int32_t(&(thisActor->base.inputPort[2].localInputPort)) >= 1)) {
          if (RVC_decoder__texture_V__IAP__DOLLAR__d10577(context, thisActor)) {
            action1__skip(thisActor);
            thisActor->_fsmState = 1;
            continue;
          }
        }
        if ((pinAvailIn_int32_t(&(thisActor->base.inputPort[2].localInputPort)) >= 1) && (pinAvailIn_int32_t(&(thisActor->base.inputPort[1].localInputPort)) >= 1) && (pinAvailIn_int32_t(&(thisActor->base.inputPort[3].localInputPort)) >= 1) && (pinAvailIn_int32_t(&(thisActor->base.inputPort[4].localInputPort)) >= 1)) {
          action2__start(thisActor);
          thisActor->_fsmState = 1;
          continue;
        }
        result = exitcode_block_Any;
        goto out;
        break;
      case 1:
        if (RVC_decoder__texture_V__IAP__DOLLAR__d10606(context, thisActor)) {
          action3__advance(thisActor);
          thisActor->_fsmState = 0;
          continue;
        }
        if ((pinAvailIn_int32_t(&(thisActor->base.inputPort[0].localInputPort)) >= 1)) {
          if ((pinAvailOut_int32_t(&(thisActor->base.outputPort[0].localOutputPort)) >= 1)) {
            action4__copy(thisActor);
            thisActor->_fsmState = 1;
            continue;
          } else {
            result = exitcode_block_Any;
            goto out;
          }
        }
        result = exitcode_block_Any;
        goto out;
        break;
    }
  }
  out:

  return result;
}

canonical_original_code:
static int *RVC_decoder__texture_V__IAP_action_scheduler(struct AbstractActorInstance *pBase) {
  int *result = exit_code_yield;
  struct ActorInstance_RVC_decoder__texture_V__IAP *thisActor = (ActorInstance_RVC_decoder__texture_V__IAP*) pBase;
  void *context = ((void *)0); context = context;
  while(1) {
    switch(thisActor->_fsmState) {
      case 0:
        if ((pinAvailIn_int32_t(&(thisActor->base.inputPort[2].localInputPort)) >= 1)) {
          if (RVC_decoder__texture_V__IAP__DOLLAR__d10566(context, thisActor)) {
            action0__newvop(thisActor);
            thisActor->_fsmState = 0;
            continue;
          }
        }
        if ((pinAvailIn_int32_t(&(thisActor->base.inputPort[2].localInputPort)) >= 1)) {
          if (RVC_decoder__texture_V__IAP__DOLLAR__d10577(context, thisActor)) {
            action1__skip(thisActor);
            thisActor->_fsmState = 1;
            continue;
          }
        }
        if ((pinAvailIn_int32_t(&(thisActor->base.inputPort[2].localInputPort)) >= 1) && (pinAvailIn_int32_t(&(thisActor->base.inputPort[1].localInputPort)) >= 1) && (pinAvailIn_int32_t(&(thisActor->base.inputPort[3].localInputPort)) >= 1) && (pinAvailIn_int32_t(&(thisActor->base.inputPort[4].localInputPort)) >= 1)) {
          action2__start(thisActor);
          thisActor->_fsmState = 1;
          continue;
        }
        result = exitcode_block_Any;
        goto out;
        break;
      case 1:
        if (RVC_decoder__texture_V__IAP__DOLLAR__d10606(context, thisActor)) {
          action3__advance(thisActor);
          thisActor->_fsmState = 0;
          continue;
        }
        if ((pinAvailIn_int32_t(&(thisActor->base.inputPort[0].localInputPort)) >= 1)) {
          if ((pinAvailOut_int32_t(&(thisActor->base.outputPort[0].localOutputPort)) >= 1)) {
            action4__copy(thisActor);
            thisActor->_fsmState = 1;
            continue;
          } else {
            result = exitcode_block_Any;
            goto out;
          }
        }
        result = exitcode_block_Any;
        goto out;
        break;
    }
  }
  out:

  return result;
}


decompiled_code:
void __fastcall ActorInstance_RVC_decoder__parser__splitter_BTYPE_constructor(__int64 a1)
{
*(_DWORD *)(a1 + 72) = 0;
}

original_code:
static void ActorInstance_RVC_decoder__parser__splitter_BTYPE_constructor(AbstractActorInstance *pBase) {
  ActorInstance_RVC_decoder__parser__splitter_BTYPE *thisActor=(ActorInstance_RVC_decoder__parser__splitter_BTYPE*) pBase;
  thisActor->_fsmState = 0;
  {
  }
}

canonical_original_code:
static void ActorInstance_RVC_decoder__parser__splitter_BTYPE_constructor(struct AbstractActorInstance *pBase) {
  struct ActorInstance_RVC_decoder__parser__splitter_BTYPE *thisActor = (ActorInstance_RVC_decoder__parser__splitter_BTYPE*) pBase;
  thisActor->_fsmState = 0;
  {
  }
}

variable_types: struct ActorInstance_RVC_decoder__parser__splitter_BTYPE { struct AbstractActorInstance { struct dllist_link_tag { struct dllist_link_tag *suc; } listEntry; struct ActorClass { unsigned int majorVersion; unsigned int minorVersion; char *name; int sizeActorInstance; int numInputPorts; struct PortDescription { int dummy; char *name; int tokenSize; struct tokenFn { char *(*serialize)(void *, char *); char *(*deserialize)(void **, char *); long (*size)(void *); int (*free)(void *, int); } *functions; } *inputPortDescriptions; int numOutputPorts; struct PortDescription *outputPortDescriptions; int numActions; struct ActionDescription { char *name; int *consumption; int *production; } *actionDescriptions; int *(*action_scheduler)(struct AbstractActorInstance *); void (*constructor)(struct AbstractActorInstance *); void (*destructor)(struct AbstractActorInstance *); void (*set_param)(struct AbstractActorInstance *, char *, char *); } *actorClass; char *instanceName; int numInputPorts; struct InputPort { struct dllist_link_tag asConsumer; struct OutputPort { struct LocalOutputPort { void *bufferStart; void *bufferEnd; void *writePtr; unsigned int spaceLeft; } localOutputPort; unsigned int capacity; unsigned int tokensProduced; unsigned int fullAt; struct tokenFn functions; struct dllist_head_t { struct dllist_link_tag head_element; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; } consumers; } *producer; struct LocalInputPort { void *bufferStart; void *bufferEnd; void *readPtr; unsigned int available; } localInputPort; unsigned int tokensConsumed; unsigned int drainedAt; unsigned int capacity; struct tokenFn functions; } *inputPort; int numOutputPorts; struct OutputPort *outputPort; int *(*action_scheduler)(struct AbstractActorInstance *); } base; int _fsmState; } *

user_defined_types: struct ActorInstance_RVC_decoder__parser__splitter_BTYPE { struct AbstractActorInstance base; int _fsmState; }


canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
int v1; // eax
unsigned int *v2; // rcx
unsigned int v3; // er8
_DWORD *v4; // rdx

v1 = *(_DWORD *)(a1 + 24);
v2 = *(unsigned int **)(a1 + 16);
if ( !v1 )
__assert_fail("p->available > 0", "../../actors-fifo.h", 0x6Bu, "pinRead_int32_t");
v3 = *v2;
v4 = v2 + 1;
if ( *(_QWORD *)(a1 + 8) <= (unsigned __int64)(v2 + 1) )
v4 = *(_DWORD **)a1;
*(_QWORD *)(a1 + 16) = v4;
*(_DWORD *)(a1 + 24) = v1 - 1;
return v3;
}


decompiled_code:
void *__fastcall pinReadRepeat_int32_t(char **a1, char *a2, unsigned int a3)
{
size_t v3; // r8
char *v6; // rsi
unsigned int v7; // eax
unsigned __int64 v8; // r12
char *v9; // rbp
void *result; // rax
size_t v11; // r13
char *v12; // rax

v3 = 4LL * (int)a3;
v6 = a1[2];
v7 = *((_DWORD *)a1 + 6);
v8 = (unsigned __int64)a1[1];
v9 = &v6[v3];
if ( v7 < a3 )
__assert_fail("p->available >= n", "../../actors-fifo.h", 0x7Eu, "pinReadRepeat_int32_t");
*((_DWORD *)a1 + 6) = v7 - a3;
if ( (unsigned __int64)v9 >= v8 )
{
v11 = (int)v8 - (int)v6;
v12 = (char *)memcpy(a2, v6, v11);
v6 = *a1;
v3 = (size_t)&v9[-v8];
a2 = &v12[v11];
v9 = &v9[(_QWORD)*a1 - v8];
}
result = memcpy(a2, v6, v3);
a1[2] = v9;
return result;
}

canonical_decompiled_code:
void *__fastcall func8(char **a1, char *a2, unsigned int a3)
{
size_t v3; // r8
char *v6; // rsi
unsigned int v7; // eax
unsigned __int64 v8; // r12
char *v9; // rbp
void *result; // rax
size_t v11; // r13
char *v12; // rax

v3 = 4LL * (int)a3;
v6 = a1[2];
v7 = *((_DWORD *)a1 + 6);
v8 = (unsigned __int64)a1[1];
v9 = &v6[v3];
if ( v7 < a3 )
__assert_fail("p->available >= n", "../../actors-fifo.h", 0x7Eu, "pinReadRepeat_int32_t");
*((_DWORD *)a1 + 6) = v7 - a3;
if ( (unsigned __int64)v9 >= v8 )
{
v11 = (int)v8 - (int)v6;
v12 = (char *)memcpy(a2, v6, v11);
v6 = *a1;
v3 = (size_t)&v9[-v8];
a2 = &v12[v11];
v9 = &v9[(_QWORD)*a1 - v8];
}
result = memcpy(a2, v6, v3);
a1[2] = v9;
return result;
}

original_code:
static inline void pinReadRepeat_int32_t(LocalInputPort *p,
                                            int32_t *buf,
                                            int n)
{
  const char *startPtr=(char*) p->readPtr;
  const char *endPtr=(char*) ((int32_t*) startPtr + n);
  const char *bufferEnd=(char*) p->bufferEnd;
  ((void) sizeof ((p->available >= n) ? 1 : 0), __extension__ ({ if (p->available >= n) ; else __assert_fail ("p->available >= n", "../../actors-fifo.h", 126, __extension__ __PRETTY_FUNCTION__); }));
  p->available -= n;
  if (endPtr >= bufferEnd) {
    int numBytes=bufferEnd-startPtr;
    memcpy(buf, startPtr, numBytes);
    buf=(int32_t*) ((char*) buf + numBytes);
    startPtr=p->bufferStart;
    endPtr=startPtr+(endPtr-bufferEnd);
  }
  memcpy(buf, startPtr, endPtr-startPtr);
  p->readPtr=endPtr;
}

canonical_original_code:
static inline void pinReadRepeat_int32_t(struct LocalInputPort *p, int *buf, int n)
{
  char *startPtr = (char*) p->readPtr;
  char *endPtr = (char*) ((int32_t*) startPtr + n);
  char *bufferEnd = (char*) p->bufferEnd;
  ((void) sizeof ((p->available >= n) ? 1 : 0), __extension__ ({ if (p->available >= n) ; else __assert_fail ("p->available >= n", "../../actors-fifo.h", 126, __extension__ __PRETTY_FUNCTION__); }));
  p->available -= n;
  if (endPtr >= bufferEnd) {
    int numBytes = bufferEnd-startPtr;
    memcpy(buf, startPtr, numBytes);
    buf=(int *) ((char *) buf + numBytes);
    startPtr=p->bufferStart;
    endPtr=startPtr+(endPtr-bufferEnd);
  }
  memcpy(buf, startPtr, endPtr-startPtr);
  p->readPtr=endPtr;
}

variable_types:
buf
int *

variable_types: n int

variable_types:
startPtr
char *

variable_types:
endPtr
char *

variable_types:
bufferEnd
char *

variable_types: numBytes int


original_code:
static void action2__cmd__split(ActorInstance_RVC_decoder__parser__splitter_BTYPE *thisActor) {
  int32_t* list;
  ;
  list = malloc((sizeof(int32_t) * 6));
  pinReadRepeat_int32_t(&(thisActor->base.inputPort[0].localInputPort), list, 6);
  pinWrite_int32_t(&(thisActor->base.outputPort[0].localOutputPort), list[0]);
  pinWrite_int32_t(&(thisActor->base.outputPort[0].localOutputPort), list[1]);
  pinWrite_int32_t(&(thisActor->base.outputPort[0].localOutputPort), list[2]);
  pinWrite_int32_t(&(thisActor->base.outputPort[0].localOutputPort), list[3]);
  pinWrite_int32_t(&(thisActor->base.outputPort[1].localOutputPort), list[4]);
  pinWrite_int32_t(&(thisActor->base.outputPort[2].localOutputPort), list[5]);
  free((void*) list);
  ;
}

canonical_original_code:
static void action2__cmd__split(struct ActorInstance_RVC_decoder__parser__splitter_BTYPE *thisActor) {
  int *list;
  ;
  list = malloc((sizeof(int) * 6));
  pinReadRepeat_int32_t(&(thisActor->base.inputPort[0].localInputPort), list, 6);
  pinWrite_int32_t(&(thisActor->base.outputPort[0].localOutputPort), list[0]);
  pinWrite_int32_t(&(thisActor->base.outputPort[0].localOutputPort), list[1]);
  pinWrite_int32_t(&(thisActor->base.outputPort[0].localOutputPort), list[2]);
  pinWrite_int32_t(&(thisActor->base.outputPort[0].localOutputPort), list[3]);
  pinWrite_int32_t(&(thisActor->base.outputPort[1].localOutputPort), list[4]);
  pinWrite_int32_t(&(thisActor->base.outputPort[2].localOutputPort), list[5]);
  free((void *) list);
  ;
}

variable_types:
list
int *

user_defined_types: struct dllist_head_t { struct dllist_link_tag head_element; union pthread_mutex_t mutex; }


decompiled_code:
_BOOL8 __fastcall RVC_decoder__parser__splitter_BTYPE__DOLLAR__d637(__int64 a1, __int64 a2)
{
__int16 v2; // ax

v2 = pinPeek_int32_t_constprop_0(*(_QWORD *)(a2 + 40) + 24LL);
return (unsigned int)bitand_constprop_0(v2) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func15(__int64 a1, __int64 a2)
{
__int16 v2; // ax

v2 = func11(*(_QWORD *)(a2 + 40) + 24LL);
return (unsigned int)func12(v2) != 0;
}

original_code:
bool_t RVC_decoder__parser__splitter_BTYPE__DOLLAR__d637(art_action_context_t *context, ActorInstance_RVC_decoder__parser__splitter_BTYPE *thisActor) {
  int32_t cmd;
  {
    bool_t ret;
    cmd = pinPeek_int32_t(&(thisActor->base.inputPort[0].localInputPort), 0);
    ret = (bitand(cmd, NEWVOP) != 0);
    return ret;
  }
}

canonical_original_code:
int RVC_decoder__parser__splitter_BTYPE__DOLLAR__d637(void *context, struct ActorInstance_RVC_decoder__parser__splitter_BTYPE *thisActor) {
  int cmd;
  {
    int ret;
    cmd = pinPeek_int32_t(&(thisActor->base.inputPort[0].localInputPort), 0);
    ret = (bitand(cmd, NEWVOP) != 0);
    return ret;
  }
}

variable_types:
context
void *

variable_types: cmd int

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }


decompiled_code:
void *__fastcall RVC_decoder__parser__splitter_BTYPE_action_scheduler(__int64 a1)
{
int v1; // eax
__int64 v2; // rdx
__int64 v3; // rdx
__int64 v5; // rdx
__int64 v6; // rdx
__int64 v7; // rax
__int64 v8; // rdx
__int64 v9; // rdx

v1 = *(_DWORD *)(a1 + 72);
do
{
if ( !v1 )
goto LABEL_10;
}
while ( v1 != 1 );
while ( (unsigned int)pinAvailIn_int32_t_isra_0(*(_DWORD *)(*(_QWORD *)(a1 + 40) + 48LL)) > 1
&& (unsigned int)pinAvailOut_int32_t_isra_0(*(_DWORD *)(*(_QWORD *)(a1 + 56) + 24LL)) > 1
&& (unsigned int)pinAvailOut_int32_t_isra_0(*(_DWORD *)(v2 + 160)) > 1
&& (unsigned int)pinAvailOut_int32_t_isra_0(*(_DWORD *)(v3 + 296)) > 1 )
{
action1__skip(a1);
*(_DWORD *)(a1 + 72) = 0;
LABEL_10:
if ( !(unsigned int)pinAvailIn_int32_t_isra_0(*(_DWORD *)(*(_QWORD *)(a1 + 40) + 48LL)) )
break;
while ( !(unsigned int)RVC_decoder__parser__splitter_BTYPE__DOLLAR__d637(0LL, a1) )
{
if ( (unsigned int)pinAvailIn_int32_t_isra_0(*(_DWORD *)(*(_QWORD *)(a1 + 40) + 48LL)) > 5
&& (unsigned int)pinAvailOut_int32_t_isra_0(*(_DWORD *)(*(_QWORD *)(a1 + 56) + 24LL)) > 3 )
{
if ( (unsigned int)pinAvailOut_int32_t_isra_0(*(_DWORD *)(v5 + 160)) )
{
if ( (unsigned int)pinAvailOut_int32_t_isra_0(*(_DWORD *)(v6 + 296)) )
{
action2__cmd__split(a1);
v7 = *(_QWORD *)(a1 + 40);
*(_DWORD *)(a1 + 72) = 0;
if ( (unsigned int)pinAvailIn_int32_t_isra_0(*(_DWORD *)(v7 + 48)) )
continue;
}
}
}
return &exitcode_block_Any;
}
if ( !(unsigned int)pinAvailOut_int32_t_isra_0(*(_DWORD *)(*(_QWORD *)(a1 + 56) + 24LL))
|| !(unsigned int)pinAvailOut_int32_t_isra_0(*(_DWORD *)(v8 + 160))
|| !(unsigned int)pinAvailOut_int32_t_isra_0(*(_DWORD *)(v9 + 296)) )
{
break;
}
action0__cmd__newVop(a1);
*(_DWORD *)(a1 + 72) = 1;
}
return &exitcode_block_Any;
}

canonical_decompiled_code:
void *__fastcall func16(__int64 a1)
{
int v1; // eax
__int64 v2; // rdx
__int64 v3; // rdx
__int64 v5; // rdx
__int64 v6; // rdx
__int64 v7; // rax
__int64 v8; // rdx
__int64 v9; // rdx

v1 = *(_DWORD *)(a1 + 72);
do
{
if ( !v1 )
goto LABEL_10;
}
while ( v1 != 1 );
while ( (unsigned int)func14(*(_DWORD *)(*(_QWORD *)(a1 + 40) + 48LL)) > 1
&& (unsigned int)func13(*(_DWORD *)(*(_QWORD *)(a1 + 56) + 24LL)) > 1
&& (unsigned int)func13(*(_DWORD *)(v2 + 160)) > 1
&& (unsigned int)func13(*(_DWORD *)(v3 + 296)) > 1 )
{
func10(a1);
*(_DWORD *)(a1 + 72) = 0;
LABEL_10:
if ( !(unsigned int)func14(*(_DWORD *)(*(_QWORD *)(a1 + 40) + 48LL)) )
break;
while ( !(unsigned int)func15(0LL, a1) )
{
if ( (unsigned int)func14(*(_DWORD *)(*(_QWORD *)(a1 + 40) + 48LL)) > 5
&& (unsigned int)func13(*(_DWORD *)(*(_QWORD *)(a1 + 56) + 24LL)) > 3 )
{
if ( (unsigned int)func13(*(_DWORD *)(v5 + 160)) )
{
if ( (unsigned int)func13(*(_DWORD *)(v6 + 296)) )
{
func9(a1);
v7 = *(_QWORD *)(a1 + 40);
*(_DWORD *)(a1 + 72) = 0;
if ( (unsigned int)func14(*(_DWORD *)(v7 + 48)) )
continue;
}
}
}
return &exitcode_block_Any;
}
if ( !(unsigned int)func13(*(_DWORD *)(*(_QWORD *)(a1 + 56) + 24LL))
|| !(unsigned int)func13(*(_DWORD *)(v8 + 160))
|| !(unsigned int)func13(*(_DWORD *)(v9 + 296)) )
{
break;
}
action0__cmd__newVop(a1);
*(_DWORD *)(a1 + 72) = 1;
}
return &exitcode_block_Any;
}

original_code:
static const int *RVC_decoder__parser__splitter_BTYPE_action_scheduler(AbstractActorInstance *pBase) {
  const int *result = exit_code_yield;
  ActorInstance_RVC_decoder__parser__splitter_BTYPE *thisActor=(ActorInstance_RVC_decoder__parser__splitter_BTYPE*) pBase;
  void *context = ((void *)0); context = context;
  while(1) {
    switch(thisActor->_fsmState) {
      case 0:
        if ((pinAvailIn_int32_t(&(thisActor->base.inputPort[0].localInputPort)) >= 1)) {
          if (RVC_decoder__parser__splitter_BTYPE__DOLLAR__d637(context, thisActor)) {
            if ((pinAvailOut_int32_t(&(thisActor->base.outputPort[0].localOutputPort)) >= 1) && (pinAvailOut_int32_t(&(thisActor->base.outputPort[1].localOutputPort)) >= 1) && (pinAvailOut_int32_t(&(thisActor->base.outputPort[2].localOutputPort)) >= 1)) {
              action0__cmd__newVop(thisActor);
              thisActor->_fsmState = 1;
              continue;
            } else {
              result = exitcode_block_Any;
              goto out;
            }
          }
        }
        if ((pinAvailIn_int32_t(&(thisActor->base.inputPort[0].localInputPort)) >= 6)) {
          if ((pinAvailOut_int32_t(&(thisActor->base.outputPort[0].localOutputPort)) >= 1*4) && (pinAvailOut_int32_t(&(thisActor->base.outputPort[1].localOutputPort)) >= 1) && (pinAvailOut_int32_t(&(thisActor->base.outputPort[2].localOutputPort)) >= 1)) {
            action2__cmd__split(thisActor);
            thisActor->_fsmState = 0;
            continue;
          } else {
            result = exitcode_block_Any;
            goto out;
          }
        }
        result = exitcode_block_Any;
        goto out;
        break;
      case 1:
        if ((pinAvailIn_int32_t(&(thisActor->base.inputPort[0].localInputPort)) >= 2)) {
          if ((pinAvailOut_int32_t(&(thisActor->base.outputPort[0].localOutputPort)) >= 1*2) && (pinAvailOut_int32_t(&(thisActor->base.outputPort[1].localOutputPort)) >= 1*2) && (pinAvailOut_int32_t(&(thisActor->base.outputPort[2].localOutputPort)) >= 1*2)) {
            action1__skip(thisActor);
            thisActor->_fsmState = 0;
            continue;
          } else {
            result = exitcode_block_Any;
            goto out;
          }
        }
        result = exitcode_block_Any;
        goto out;
        break;
    }
  }
  out:

  return result;
}

canonical_original_code:
static int *RVC_decoder__parser__splitter_BTYPE_action_scheduler(struct AbstractActorInstance *pBase) {
  int *result = exit_code_yield;
  struct ActorInstance_RVC_decoder__parser__splitter_BTYPE *thisActor = (ActorInstance_RVC_decoder__parser__splitter_BTYPE*) pBase;
  void *context = ((void *)0); context = context;
  while(1) {
    switch(thisActor->_fsmState) {
      case 0:
        if ((pinAvailIn_int32_t(&(thisActor->base.inputPort[0].localInputPort)) >= 1)) {
          if (RVC_decoder__parser__splitter_BTYPE__DOLLAR__d637(context, thisActor)) {
            if ((pinAvailOut_int32_t(&(thisActor->base.outputPort[0].localOutputPort)) >= 1) && (pinAvailOut_int32_t(&(thisActor->base.outputPort[1].localOutputPort)) >= 1) && (pinAvailOut_int32_t(&(thisActor->base.outputPort[2].localOutputPort)) >= 1)) {
              action0__cmd__newVop(thisActor);
              thisActor->_fsmState = 1;
              continue;
            } else {
              result = exitcode_block_Any;
              goto out;
            }
          }
        }
        if ((pinAvailIn_int32_t(&(thisActor->base.inputPort[0].localInputPort)) >= 6)) {
          if ((pinAvailOut_int32_t(&(thisActor->base.outputPort[0].localOutputPort)) >= 1*4) && (pinAvailOut_int32_t(&(thisActor->base.outputPort[1].localOutputPort)) >= 1) && (pinAvailOut_int32_t(&(thisActor->base.outputPort[2].localOutputPort)) >= 1)) {
            action2__cmd__split(thisActor);
            thisActor->_fsmState = 0;
            continue;
          } else {
            result = exitcode_block_Any;
            goto out;
          }
        }
        result = exitcode_block_Any;
        goto out;
        break;
      case 1:
        if ((pinAvailIn_int32_t(&(thisActor->base.inputPort[0].localInputPort)) >= 2)) {
          if ((pinAvailOut_int32_t(&(thisActor->base.outputPort[0].localOutputPort)) >= 1*2) && (pinAvailOut_int32_t(&(thisActor->base.outputPort[1].localOutputPort)) >= 1*2) && (pinAvailOut_int32_t(&(thisActor->base.outputPort[2].localOutputPort)) >= 1*2)) {
            action1__skip(thisActor);
            thisActor->_fsmState = 0;
            continue;
          } else {
            result = exitcode_block_Any;
            goto out;
          }
        }
        result = exitcode_block_Any;
        goto out;
        break;
    }
  }
  out:

  return result;
}

variable_types: struct AbstractActorInstance { struct dllist_link_tag { struct dllist_link_tag *suc; } listEntry; struct ActorClass { unsigned int majorVersion; unsigned int minorVersion; char *name; int sizeActorInstance; int numInputPorts; struct PortDescription { int dummy; char *name; int tokenSize; struct tokenFn { char *(*serialize)(void *, char *); char *(*deserialize)(void **, char *); long (*size)(void *); int (*free)(void *, int); } *functions; } *inputPortDescriptions; int numOutputPorts; struct PortDescription *outputPortDescriptions; int numActions; struct ActionDescription { char *name; int *consumption; int *production; } *actionDescriptions; int *(*action_scheduler)(struct AbstractActorInstance *); void (*constructor)(struct AbstractActorInstance *); void (*destructor)(struct AbstractActorInstance *); void (*set_param)(struct AbstractActorInstance *, char *, char *); } *actorClass; char *instanceName; int numInputPorts; struct InputPort { struct dllist_link_tag asConsumer; struct OutputPort { struct LocalOutputPort { void *bufferStart; void *bufferEnd; void *writePtr; unsigned int spaceLeft; } localOutputPort; unsigned int capacity; unsigned int tokensProduced; unsigned int fullAt; struct tokenFn functions; struct dllist_head_t { struct dllist_link_tag head_element; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } mutex; } consumers; } *producer; struct LocalInputPort { void *bufferStart; void *bufferEnd; void *readPtr; unsigned int available; } localInputPort; unsigned int tokensConsumed; unsigned int drainedAt; unsigned int capacity; struct tokenFn functions; } *inputPort; int numOutputPorts; struct OutputPort *outputPort; int *(*action_scheduler)(struct AbstractActorInstance *); } *

variable_types:
result
int *

user_defined_types: struct AbstractActorInstance { struct dllist_link_tag listEntry; struct ActorClass *actorClass; char *instanceName; int numInputPorts; struct InputPort *inputPort; int numOutputPorts; struct OutputPort *outputPort; int *(*action_scheduler)(struct AbstractActorInstance *); }


COORD

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

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

original_code:
static inline struct coord COORD(int x, int y) {
 return (struct coord){ .x = x, .y = y };
}

variable_types: x int

variable_types: y int

return_type: struct coord { union { int x; }; union { int y; }; }


max

decompiled_code:
__int64 __fastcall 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 func1(unsigned int a1, unsigned int a2)
{
__int64 result; // rax

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

original_code:
static int max(int a, int b) {
 return a > b ? a : b;
}

variable_types: a int

variable_types: b int


decompiled_code:
__int64 __fastcall thumb_size_for_frame(__int64 a1)
{
int v1; // eax
unsigned int v2; // er8

v1 = max(a1, HIDWORD(a1));
if ( v1 > 128 )
{
v2 = 256;
if ( v1 >= 257 )
v2 = 512;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
int v1; // eax
unsigned int v2; // er8

v1 = func1(a1, HIDWORD(a1));
if ( v1 > 128 )
{
v2 = 256;
if ( v1 >= 257 )
v2 = 512;
}
return v2;
}

original_code:
static int thumb_size_for_frame(struct coord frame_dim) {
 int longer = max(frame_dim.width, frame_dim.height);
 if (longer <= 128) {
  return 128;
 } else if (longer <= 256) {
  return 256;
 } else {
  return 512;
 }
}

variable_types: struct coord { union { int x; }; union { int y; }; }

variable_types: longer int


decompiled_code:
__int64 __fastcall next_to_update(_QWORD *a1, __int64 a2)
{
_QWORD *v2; // rbp
__int64 v3; // r12
__int64 v4; // rdx
__int64 v5; // r13
__int64 v6; // rbx
__int64 v7; // rax
__int64 v8; // rdx
__int64 v9; // r9
int v10; // eax
__int64 v11; // rdx
int v12; // eax

if ( !a1 )
return 0LL;
v2 = a1;
v3 = view_visible_rect(view);
v5 = v4;
if ( !*a1 )
return 0LL;
v6 = 0LL;
while ( 1 )
{
v7 = layout_frame_rect_by_number(a2, (unsigned int)v6);
if ( (unsigned int)rect_intersect(v7, v8, v3, v5) )
{
v9 = a1[v6];
if ( !*(_DWORD *)(v9 + 28) )
{
if ( !*(_QWORD *)(v9 + 8) )
break;
v10 = thumb_size_for_frame(**(_QWORD **)(view + 16LL));
if ( *(_DWORD *)(v9 + 24) != v10 )
break;
}
}
if ( !a1[++v6] )
{
v9 = *a1;
if ( !*a1 )
return 0LL;
v11 = view;
while ( 1 )
{
if ( !*(_DWORD *)(v9 + 28) )
{
if ( !*(_QWORD *)(v9 + 8) )
break;
v12 = thumb_size_for_frame(**(_QWORD **)(v11 + 16));
if ( *(_DWORD *)(v9 + 24) != v12 )
break;
}
v9 = v2[1];
++v2;
if ( !v9 )
return 0LL;
}
return v9;
}
}
return v9;
}

canonical_decompiled_code:
__int64 __fastcall func3(_QWORD *a1, __int64 a2)
{
_QWORD *v2; // rbp
__int64 v3; // r12
__int64 v4; // rdx
__int64 v5; // r13
__int64 v6; // rbx
__int64 v7; // rax
__int64 v8; // rdx
__int64 v9; // r9
int v10; // eax
__int64 v11; // rdx
int v12; // eax

if ( !a1 )
return 0LL;
v2 = a1;
v3 = view_visible_rect(view);
v5 = v4;
if ( !*a1 )
return 0LL;
v6 = 0LL;
while ( 1 )
{
v7 = layout_frame_rect_by_number(a2, (unsigned int)v6);
if ( (unsigned int)rect_intersect(v7, v8, v3, v5) )
{
v9 = a1[v6];
if ( !*(_DWORD *)(v9 + 28) )
{
if ( !*(_QWORD *)(v9 + 8) )
break;
v10 = func2(**(_QWORD **)(view + 16LL));
if ( *(_DWORD *)(v9 + 24) != v10 )
break;
}
}
if ( !a1[++v6] )
{
v9 = *a1;
if ( !*a1 )
return 0LL;
v11 = view;
while ( 1 )
{
if ( !*(_DWORD *)(v9 + 28) )
{
if ( !*(_QWORD *)(v9 + 8) )
break;
v12 = func2(**(_QWORD **)(v11 + 16));
if ( *(_DWORD *)(v9 + 24) != v12 )
break;
}
v9 = v2[1];
++v2;
if ( !v9 )
return 0LL;
}
return v9;
}
}
return v9;
}

original_code:
static struct thumbnail *next_to_update(struct thumbnail **list, struct layout *layout) {
 if (list == ((void *)0)) {
  return ((void *)0);
 }
 struct rect onscreen = view_visible_rect(view);
 struct thumbnail **p = list;
 int frame_num = 0;
 while (*p != ((void *)0)) {
  struct rect frame_rect = layout_frame_rect_by_number(layout, frame_num);
  if (
   rect_intersect(frame_rect, onscreen) &&
   !(*p)->failed &&
   (
    (*p)->imlib == ((void *)0) ||
    (*p)->size != thumb_size_for_frame(view->frame->thumb_dim)
   )
  ) {
   return (*p);
  }
  p++;
  frame_num++;
 }
 p = list;
 frame_num = 0;
 while (*p != ((void *)0)) {
  if (
   !(*p)->failed &&
   (
    (*p)->imlib == ((void *)0) ||
    (*p)->size != thumb_size_for_frame(view->frame->thumb_dim)
   )
  ) {
   return (*p);
  }
  p++;
  frame_num++;
 }
 return ((void *)0);
}

variable_types:
list
struct thumbnail **

variable_types: struct layout { struct coord window; int frame_count; int total_height; int _frames_per_row; double _frame_spacing; } *

variable_types: struct rect { struct coord { union { int x; }; union { int y; }; } tl; struct coord dim; }

variable_types: struct thumbnail { char *filename; void *imlib; struct coord { union { int x; }; union { int y; }; } thumb_dim; int size; int failed; } **

user_defined_types: struct rect { struct coord tl; struct coord dim; }

user_defined_types: struct thumbnail { char *filename; void *imlib; struct coord thumb_dim; int size; int failed; }


decompiled_code:
const char **__fastcall find_thumbnail_by_name(char *s1)
{
__int64 v1; // rbx
const char **v2; // r12

v1 = thumbnails;
v2 = *(const char ***)thumbnails;
if ( *(_QWORD *)thumbnails )
{
do
{
if ( !strcmp(s1, *v2) )
break;
v2 = *(const char ***)(v1 + 8);
v1 += 8LL;
}
while ( v2 );
}
return v2;
}

canonical_decompiled_code:
const char **__fastcall func4(char *s1)
{
__int64 v1; // rbx
const char **v2; // r12

v1 = thumbnails;
v2 = *(const char ***)thumbnails;
if ( *(_QWORD *)thumbnails )
{
do
{
if ( !strcmp(s1, *v2) )
break;
v2 = *(const char ***)(v1 + 8);
v1 += 8LL;
}
while ( v2 );
}
return v2;
}

original_code:
struct thumbnail *find_thumbnail_by_name(char *filename) {
 struct thumbnail **p = thumbnails;
 while (*p != ((void *)0)) {
  if (!strcmp(filename, (*p)->filename)) {
   return *p;
  }
  p++;
 }
 return ((void *)0);
}

variable_types:
filename
char *

return_type: struct thumbnail { char *filename; void *imlib; struct coord { union { int x; }; union { int y; }; } thumb_dim; int size; int failed; } *


decompiled_code:
__int64 try_update_thumbnails()
{
__int64 v0; // rbx
__int64 result; // rax
__int64 v2; // rbp
__int64 v3; // rax
unsigned int v4; // er12
unsigned int v5; // eax
__int64 v6; // rax

v0 = next_to_update((_QWORD *)thumbnails, *(_QWORD *)(view + 8LL));
result = 0LL;
if ( v0 )
{
v2 = (unsigned int)thumb_size_for_frame(**(_QWORD **)(view + 16LL));
v3 = thumbnail_from_storage(*(_QWORD *)v0, v2);
*(_QWORD *)(v0 + 8) = v3;
if ( v3 )
{
imlib_context_set_image(v3);
v4 = imlib_image_get_height();
v5 = imlib_image_get_width();
v6 = COORD(v5, v4);
*(_DWORD *)(v0 + 24) = v2;
*(_QWORD *)(v0 + 16) = v6;
result = 1LL;
}
else
{
*(_DWORD *)(v0 + 28) = 1;
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 v0; // rbx
__int64 result; // rax
__int64 v2; // rbp
__int64 v3; // rax
unsigned int v4; // er12
unsigned int v5; // eax
__int64 v6; // rax

v0 = func3((_QWORD *)thumbnails, *(_QWORD *)(view + 8LL));
result = 0LL;
if ( v0 )
{
v2 = (unsigned int)func2(**(_QWORD **)(view + 16LL));
v3 = thumbnail_from_storage(*(_QWORD *)v0, v2);
*(_QWORD *)(v0 + 8) = v3;
if ( v3 )
{
imlib_context_set_image(v3);
v4 = imlib_image_get_height();
v5 = imlib_image_get_width();
v6 = func0(v5, v4);
*(_DWORD *)(v0 + 24) = v2;
*(_QWORD *)(v0 + 16) = v6;
result = 1LL;
}
else
{
*(_DWORD *)(v0 + 28) = 1;
result = 1LL;
}
}
return result;
}

original_code:
int try_update_thumbnails() {
 struct thumbnail *t = next_to_update(thumbnails, view->layout);
 if (t == ((void *)0)) {
  return 0;
 }
 int size = thumb_size_for_frame(view->frame->thumb_dim);
 t->imlib = thumbnail_from_storage(t->filename, size);
 if (t->imlib != ((void *)0)) {
  imlib_context_set_image(t->imlib);
  t->thumb_dim = COORD(
   imlib_image_get_width(),
   imlib_image_get_height()
  );
  t->size = size;
 } else {
  t->failed = 1;
 }
 return 1;
}

variable_types: struct thumbnail { char *filename; void *imlib; struct coord { union { int x; }; union { int y; }; } thumb_dim; int size; int failed; } *

variable_types: size int


RECT

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

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

original_code:
static inline struct rect RECT(struct coord tl, struct coord dim) {
 return (struct rect){ .tl = tl, .dim = dim };
}

variable_types:
tl
struct coord

variable_types:
dim
struct coord

return_type: struct rect { struct coord { union { int x; }; union { int y; }; } tl; struct coord dim; }


original_code:
struct layout *layout_new() {
 struct layout *l = malloc(sizeof(struct layout));
 l->frame_count = 0;
 l->window = COORD(0, 0);
 l->spacing = COORD(0, 0);
 l->frame = COORD(0, 0);
 return l;
}

variable_types: struct layout { struct coord { union { int x; }; union { int y; }; } window; int frame_count; int total_height; int _frames_per_row; double _frame_spacing; } *

user_defined_types: struct layout { struct coord window; int frame_count; int total_height; int _frames_per_row; double _frame_spacing; }


original_code:
struct rect layout_frame_rect_by_number(struct layout *l, int frame) {
 if (frame >= l->frame_count) {
  return RECT(COORD(0, 0), COORD(0, 0));
 }
 struct rect r;
 int col = frame % l->_frames_per_row;
 int row = frame / l->_frames_per_row;
 r.tl.x = (col + 1) * l->_frame_spacing
        + col * l->frame.width;
 r.tl.y = (row + 1) * l->spacing.vertical
        + row * l->frame.height;
 r.dim = l->frame;
 return r;
}

variable_types: frame int

variable_types: col int

variable_types: row int

user_defined_types: struct coord { union { int x; }; union { int y; }; }


decompiled_code:
__int64 __fastcall layout_frame_number_by_coord(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
unsigned int v5; // er12
__int64 v6; // rax
__int64 v7; // rdx

if ( *(int *)(a1 + 24) <= 0 )
return 0xFFFFFFFFLL;
v5 = 0;
while ( 1 )
{
v6 = layout_frame_rect_by_number(a1, v5, a3, a4, a5);
if ( (unsigned int)rect_contains(v6, v7, a2) )
break;
if ( *(_DWORD *)(a1 + 24) <= (signed int)++v5 )
return 0xFFFFFFFFLL;
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
unsigned int v5; // er12
__int64 v6; // rax
__int64 v7; // rdx

if ( *(int *)(a1 + 24) <= 0 )
return 0xFFFFFFFFLL;
v5 = 0;
while ( 1 )
{
v6 = func3(a1, v5, a3, a4, a5);
if ( (unsigned int)rect_contains(v6, v7, a2) )
break;
if ( *(_DWORD *)(a1 + 24) <= (signed int)++v5 )
return 0xFFFFFFFFLL;
}
return v5;
}

original_code:
int layout_frame_number_by_coord(struct layout *l, struct coord probe) {
 for (int f = 0; f < l->frame_count; f++) {
  struct rect ff = layout_frame_rect_by_number(l, f);
  if (rect_contains(ff, probe)) {
   return f;
  }
 }
 return -1;
}

variable_types:
probe
struct coord

variable_types: f int


original_code:
void layout_recompute(struct layout *l) {
 int fpr = (l->window.width - l->spacing.horizontal)
         / (l->frame.width + l->spacing.horizontal);
 if (fpr < 1) {
  fpr = 1;
 }
 l->_frame_spacing = (l->window.width - l->frame.width * fpr)
                   / (double)(fpr + 1);
 l->_frames_per_row = fpr;
 int rows = ceil(l->frame_count / (double)fpr);
 l->total_height = rows * l->frame.height
                 + (rows + 1) * l->spacing.vertical;
}

variable_types: fpr int

variable_types: rows int


COORD

canonical_original_code:
static inline struct coord COORD(int x, int y) {
 return (struct coord){ .x = x, .y = y };
}

variable_types: x int

variable_types: y int


decompiled_code:
void __fastcall input_set_drag_handlers(__int64 (__fastcall *a1)(_QWORD, _QWORD), __int64 (__fastcall *a2)(_QWORD), __int64 a3)
{
ev_drag_start = a1;
ev_drag_stop = a2;
ev_drag_update = a3;
}

canonical_decompiled_code:
void __fastcall func4(__int64 (__fastcall *a1)(_QWORD, _QWORD), __int64 (__fastcall *a2)(_QWORD), __int64 a3)
{
ev_drag_start = a1;
ev_drag_stop = a2;
ev_drag_update = a3;
}

original_code:
void input_set_drag_handlers(
 void (*drag_start )(int, struct coord),
 void (*drag_stop )(int),
 void (*drag_update)(int, struct coord, struct coord)
) {
 ev_drag_start = drag_start;
 ev_drag_stop = drag_stop;
 ev_drag_update = drag_update;
}

canonical_original_code:
void input_set_drag_handlers(void (*drag_start)(int, struct coord), void (*drag_stop)(int), void (*drag_update)(int, struct coord, struct coord)) {
 ev_drag_start = drag_start;
 ev_drag_stop = drag_stop;
 ev_drag_update = drag_update;
}

variable_types: void (*)(int, struct coord { union { int x; }; union { int y; }; })

variable_types: void (*)(int, struct coord, struct coord)


decompiled_code:
void __fastcall input_set_click_handler(__int64 a1)
{
ev_click = a1;
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1)
{
ev_click = a1;
}

original_code:
void input_set_click_handler(void (*click)(int, struct coord)) {
 ev_click = click;
}


decompiled_code:
void __fastcall input_set_hover_handler(__int64 a1)
{
ev_hover = a1;
}

canonical_decompiled_code:
void __fastcall func6(__int64 a1)
{
ev_hover = a1;
}

original_code:
void input_set_hover_handler(void (*hover)(struct coord)) {
 ev_hover = hover;
}

variable_types: void (*)(struct coord { union { int x; }; union { int y; }; })


decompiled_code:
void input_set_drag_limits()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code:
void input_set_drag_limits(int xneg, int xpos, int yneg, int ypos) {
 drag_limit_xneg = xneg;
 drag_limit_xpos = xpos;
 drag_limit_yneg = yneg;
 drag_limit_ypos = ypos;
}

variable_types: xneg int

variable_types: xpos int

variable_types: yneg int

variable_types: ypos int


decompiled_code:
__int64 __fastcall coord_scale_to_fit(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
__int64 v3; // rdx

v2 = a2;
v3 = (unsigned int)(int)((double)(int)a2 * (double)SHIDWORD(a1) / (double)(int)a1);
if ( (int)v3 > SHIDWORD(a2) )
{
v3 = HIDWORD(a2);
v2 = (int)((double)SHIDWORD(a2) * (double)(int)a1 / (double)SHIDWORD(a1));
}
return (v3 << 32) | v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
unsigned int v2; // eax
__int64 v3; // rdx

v2 = a2;
v3 = (unsigned int)(int)((double)(int)a2 * (double)SHIDWORD(a1) / (double)(int)a1);
if ( (int)v3 > SHIDWORD(a2) )
{
v3 = HIDWORD(a2);
v2 = (int)((double)SHIDWORD(a2) * (double)(int)a1 / (double)SHIDWORD(a1));
}
return (v3 << 32) | v2;
}

original_code:
struct coord coord_scale_to_fit(struct coord obj, struct coord fit) {
 struct coord new;
 new.x = fit.x;
 new.y = fit.x * (double)obj.y / obj.x;
 if (new.y > fit.y) {
  new.x = fit.y * (double)obj.x / obj.y;
  new.y = fit.y;
 }
 return new;
}

variable_types:
obj
struct coord

variable_types:
fit
struct coord

variable_types: struct coord { union { int x; }; union { int y; }; }


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

if ( (int)a1 >= (int)a2 || SHIDWORD(a1) >= SHIDWORD(a2) )
result = coord_scale_to_fit(a1, a2);
else
result = (a1 >> 32 << 32) | (unsigned int)a1;
return result;
}

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

if ( (int)a1 >= (int)a2 || SHIDWORD(a1) >= SHIDWORD(a2) )
result = func0(a1, a2);
else
result = (a1 >> 32 << 32) | (unsigned int)a1;
return result;
}

original_code:
struct coord coord_downscale_to_fit(struct coord obj, struct coord fit) {
 if (obj.x < fit.x && obj.y < fit.y) {
  return obj;
 } else {
  return coord_scale_to_fit(obj, fit);
 }
}


decompiled_code:
_BOOL8 __fastcall rect_intersect(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
_BOOL8 result; // rax
__int64 v5; // rdi
__int64 v6; // rdx

result = 0LL;
if ( (int)a1 + (int)a2 >= (int)a3 && (int)a3 + (int)a4 >= (int)a1 )
{
v5 = a1 >> 32;
v6 = a3 >> 32;
if ( (int)v5 + HIDWORD(a2) >= (int)v6 )
result = HIDWORD(a4) + (int)v6 >= (int)v5;
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
_BOOL8 result; // rax
__int64 v5; // rdi
__int64 v6; // rdx

result = 0LL;
if ( (int)a1 + (int)a2 >= (int)a3 && (int)a3 + (int)a4 >= (int)a1 )
{
v5 = a1 >> 32;
v6 = a3 >> 32;
if ( (int)v5 + HIDWORD(a2) >= (int)v6 )
result = HIDWORD(a4) + (int)v6 >= (int)v5;
}
return result;
}

original_code:
int rect_intersect(struct rect r1, struct rect r2) {
 return !(
  r2.tl.x > r1.tl.x + r1.dim.width ||
  r2.tl.x + r2.dim.width < r1.tl.x ||
  r2.tl.y > r1.tl.y + r1.dim.height ||
  r2.tl.y + r2.dim.height < r1.tl.y
 );
}

variable_types: struct rect { struct coord { union { int x; }; union { int y; }; } tl; struct coord dim; }


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

result = 0LL;
if ( (int)a3 >= (int)a1 )
{
if ( (int)a2 + (int)a1 >= (int)a3 && SHIDWORD(a1) <= SHIDWORD(a3) )
result = HIDWORD(a1) + HIDWORD(a2) >= SHIDWORD(a3);
else
result = 0LL;
}
return result;
}

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

result = 0LL;
if ( (int)a3 >= (int)a1 )
{
if ( (int)a2 + (int)a1 >= (int)a3 && SHIDWORD(a1) <= SHIDWORD(a3) )
result = HIDWORD(a1) + HIDWORD(a2) >= SHIDWORD(a3);
else
result = 0LL;
}
return result;
}

original_code:
int rect_contains(struct rect r, struct coord c) {
 return (
  r.tl.x <= c.x && r.tl.x + r.dim.width >= c.x &&
  r.tl.y <= c.y && r.tl.y + r.dim.height >= c.y
 );
}

variable_types:
c
struct coord


decompiled_code:
const char *__fastcall imlib_load_error_string(int a1)
{
__int64 v1; // rdi
const char *result; // rax

v1 = (unsigned int)(a1 - 1);
result = "Unknown error";
if ( (unsigned int)v1 <= 0xD )
result = CSWTCH_1[v1];
return result;
}

canonical_decompiled_code:
const char *__fastcall func0(int a1)
{
__int64 v1; // rdi
const char *result; // rax

v1 = (unsigned int)(a1 - 1);
result = "Unknown error";
if ( (unsigned int)v1 <= 0xD )
result = CSWTCH_1[v1];
return result;
}

original_code:
const char *imlib_load_error_string(Imlib_Load_Error e) {
 switch (e) {
 case IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST : return "No such file or directory";
 case IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY : return "Is a directory";
 case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ : return "Permission denied";
 case IMLIB_LOAD_ERROR_UNKNOWN :
 case IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT : return "No Imlib2 loader for that file format";
 case IMLIB_LOAD_ERROR_PATH_TOO_LONG : return "Filename too long";
 case IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT : return "No such file or directory (along path)";
 case IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY : return "Not a directory";
 case IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE : return "Bad address";
 case IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS : return "Too many levels of symbolic links";
 case IMLIB_LOAD_ERROR_OUT_OF_MEMORY : return "Out of memory";
 case IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS : return "Too many open files";
 case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_WRITE : return "Permission denied (to write to directory)";
 case IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE : return "No space left on device";
 default : return "Unknown error";
 }
}

canonical_original_code:
char *imlib_load_error_string(enum _imlib_load_error e) {
 switch (e) {
 case IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST : return "No such file or directory";
 case IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY : return "Is a directory";
 case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ : return "Permission denied";
 case IMLIB_LOAD_ERROR_UNKNOWN :
 case IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT : return "No Imlib2 loader for that file format";
 case IMLIB_LOAD_ERROR_PATH_TOO_LONG : return "Filename too long";
 case IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT : return "No such file or directory (along path)";
 case IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY : return "Not a directory";
 case IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE : return "Bad address";
 case IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS : return "Too many levels of symbolic links";
 case IMLIB_LOAD_ERROR_OUT_OF_MEMORY : return "Out of memory";
 case IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS : return "Too many open files";
 case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_WRITE : return "Permission denied (to write to directory)";
 case IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE : return "No space left on device";
 default : return "Unknown error";
 }
}

variable_types: enum _imlib_load_error { IMLIB_LOAD_ERROR_NONE=0, IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST=1, IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY=2, IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ=3, IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT=4, IMLIB_LOAD_ERROR_PATH_TOO_LONG=5, IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT=6, IMLIB_LOAD_ERROR_PATH_COMPONENT_NOT_DIRECTORY=7, IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE=8, IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS=9, IMLIB_LOAD_ERROR_OUT_OF_MEMORY=10, IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS=11, IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_WRITE=12, IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE=13, IMLIB_LOAD_ERROR_UNKNOWN=14 }

return_type: char *


decompiled_code:
int __fastcall ctl_handle_fd(int fd)
{
FILE *v1; // rdi
char v3; // [rsp+Ah] [rbp-11Eh] BYREF
int buf; // [rsp+Bh] [rbp-11Dh] BYREF
char v5; // [rsp+Fh] [rbp-119h]
char v6[280]; // [rsp+10h] [rbp-118h] BYREF

buf = 0;
v5 = 0;
read(fd, &buf, 4uLL);
if ( strcmp((const char *)&buf, "OPEN") )
return fprintf(stderr, "unknown command on ctl pipe: %s\n", (const char *)&buf);
read(fd, &v3, 1uLL);
read(fd, v6, v3);
v1 = stderr;
v6[v3] = 0;
fprintf(v1, "loading image file: %s\n", v6);
load_image(v6);
return render_image();
}

canonical_decompiled_code:
int __fastcall func0(int fd)
{
FILE *v1; // rdi
char v3; // [rsp+Ah] [rbp-11Eh] BYREF
int buf; // [rsp+Bh] [rbp-11Dh] BYREF
char v5; // [rsp+Fh] [rbp-119h]
char v6[280]; // [rsp+10h] [rbp-118h] BYREF

buf = 0;
v5 = 0;
read(fd, &buf, 4uLL);
if ( strcmp((const char *)&buf, "OPEN") )
return fprintf(stderr, "unknown command on ctl pipe: %s\n", (const char *)&buf);
read(fd, &v3, 1uLL);
read(fd, v6, v3);
v1 = stderr;
v6[v3] = 0;
fprintf(v1, "loading image file: %s\n", v6);
load_image(v6);
return render_image();
}

original_code:
void ctl_handle_fd(int fd) {
 char command[5];
 memset(command, '\0', 5);
 read(fd, command, 4);
 if (!strcmp(command, "OPEN")) {
  char count;
  read(fd, &count, 1);
  char filename[256];
  read(fd, filename, count);
  filename[count] = '\0';
  fprintf(stderr, "loading image file: %s\n", filename);
  load_image(filename);
  render_image();
 } else {
  fprintf(stderr, "unknown command on ctl pipe: %s\n", command);
 }
}

variable_types: fd int

variable_types:
command
char [5]

variable_types: count char

variable_types:
filename
char [256]


RECT

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

canonical_original_code:
static inline struct rect RECT(struct coord tl, struct coord dim) {
 return (struct rect){ .tl = tl, .dim = dim };
}

variable_types:
tl
struct coord

variable_types:
dim
struct coord


fileread

repo: pentix/frontdown

decompiled_code:
size_t __fastcall fileread(void *a1, int a2, int a3, FILE *a4)
{
return fread(a1, a2, a3, a4);
}

canonical_decompiled_code:
size_t __fastcall func3(void *a1, int a2, int a3, FILE *a4)
{
return fread(a1, a2, a3, a4);
}

original_code:
int fileread(void *ptr, int size, int n, void *stream){
 return (curl_off_t)fread(ptr, size, n, stream);
}

canonical_original_code:
int fileread(void *ptr, int size, int n, void *stream){
 return (long)fread(ptr, size, n, stream);
}

variable_types:
ptr
void *

variable_types: size int

variable_types: n int

variable_types:
stream
void *


decompiled_code:
__int64 __fastcall create_dest_dir(__int64 a1, __int64 a2)
{
char *v3; // rax
int *v4; // r8
unsigned int (__fastcall *v5)(__int64, __int64, __int128 *); // rax
__int128 v6; // [rsp+0h] [rbp-8018h] BYREF
char s[32752]; // [rsp+10h] [rbp-8008h] BYREF

v6 = 0LL;
memset(s, 0, sizeof(s));
if ( *(_DWORD *)(a1 + 32) == 1 )
{
v3 = stpcpy((char *)&v6, (const char *)(*(_QWORD *)(a1 + 8) + 7LL));
strcpy(v3, (const char *)(a2 + 1));
if ( mkdir((const char *)&v6, 0x1FDu) )
{
v4 = _errno_location();
v5 = *(unsigned int (__fastcall **)(__int64, __int64, __int128 *))(a1 + 56);
if ( *v4 != 17 )
{
LABEL_8:
v5(1LL, 1LL, &v6);
return 0xFFFFFFFFLL;
}
if ( v5(1LL, 0LL, &v6) )
{
v5 = *(unsigned int (__fastcall **)(__int64, __int64, __int128 *))(a1 + 56);
goto LABEL_8;
}
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
char *v3; // rax
int *v4; // r8
unsigned int (__fastcall *v5)(__int64, __int64, __int128 *); // rax
__int128 v6; // [rsp+0h] [rbp-8018h] BYREF
char s[32752]; // [rsp+10h] [rbp-8008h] BYREF

v6 = 0LL;
memset(s, 0, sizeof(s));
if ( *(_DWORD *)(a1 + 32) == 1 )
{
v3 = stpcpy((char *)&v6, (const char *)(*(_QWORD *)(a1 + 8) + 7LL));
strcpy(v3, (const char *)(a2 + 1));
if ( mkdir((const char *)&v6, 0x1FDu) )
{
v4 = _errno_location();
v5 = *(unsigned int (__fastcall **)(__int64, __int64, __int128 *))(a1 + 56);
if ( *v4 != 17 )
{
LABEL_8:
v5(1LL, 1LL, &v6);
return 0xFFFFFFFFLL;
}
if ( v5(1LL, 0LL, &v6) )
{
v5 = *(unsigned int (__fastcall **)(__int64, __int64, __int128 *))(a1 + 56);
goto LABEL_8;
}
}
}
return 0LL;
}

original_code:
int create_dest_dir(struct frontdown_config *config, char *relpath){
 char fullpath[16384*2]={0};
 switch(config->con_type){
  case _FILE_:
   strcpy(fullpath, &config->destination[7]);
   strcat(fullpath, &relpath[1]);
   if((mkdir(fullpath , (0400|0200|0100) | ((0400|0200|0100) >> 3) | ((0400 >> 3) >> 3) | ((0100 >> 3) >> 3)))!=0){
    if(((*__errno_location ())==17)&&(config->error(_MKDIR_ERROR_, 0, fullpath)==0)){
     return 0;
    } else {
     config->error(_MKDIR_ERROR_, 1, fullpath);
     return -1;
    }
   }
  break;
  case _UNKNOWN_:
  default:
  break;
 }
 return 0;
}

canonical_original_code:
int create_dest_dir(struct frontdown_config *config, char *relpath){
 char fullpath[-1] = {0};
 switch(config->con_type){
  case _FILE_:
   strcpy(fullpath, &config->destination[7]);
   strcat(fullpath, &relpath[1]);
   if((mkdir(fullpath , (0400|0200|0100) | ((0400|0200|0100) >> 3) | ((0400 >> 3) >> 3) | ((0100 >> 3) >> 3)))!=0){
    if(((*__errno_location ())==17)&&(config->error(_MKDIR_ERROR_, 0, fullpath)==0)){
     return 0;
    } else {
     config->error(_MKDIR_ERROR_, 1, fullpath);
     return -1;
    }
   }
  break;
  case _UNKNOWN_:
  default:
  break;
 }
 return 0;
}

variable_types: struct frontdown_config { char *source; char *destination; char *destinationUname; char *destinationPwd; enum frontdown_connection_type { _DICT_=0, _FILE_=1, _FTP_=2, _HTTP_=3, _IMAP_=4, _LDAP_=5, _POP3_=6, _RTMP_=7, _RTSP_=8, _SCP_=9, _SFTP_=10, _SMTP_=11, _TELNET_=12, _TFTP_=13, _UNKNOWN_=14 } con_type; struct frontdown_exclude_list { char exclude_path[16384]; struct frontdown_exclude_list *next; } *excludes; int (*info)(char *); int (*error)(enum frontdown_error_code { _INDEX_DB_ERROR_=0, _MKDIR_ERROR_=1, _DST_CONNECTION_ERROR_=2, _PUT_FILE_ERROR_=3 }, char, char *); char last_backup; char verbose; long long now; } *

variable_types:
relpath
char *

variable_types:
fullpath
char [-1]

user_defined_types: struct frontdown_config { char *source; char *destination; char *destinationUname; char *destinationPwd; enum frontdown_connection_type con_type; struct frontdown_exclude_list *excludes; int (*info)(char *); int (*error)(enum frontdown_error_code, char, char *); char last_backup; char verbose; long long now; }


decompiled_code:
__int64 close_destination()
{
curl_easy_cleanup(dst_connection);
curl_global_cleanup();
return 0LL;
}

canonical_decompiled_code:
__int64 func6()
{
curl_easy_cleanup(dst_connection);
curl_global_cleanup();
return 0LL;
}

original_code:
int close_destination(){
 curl_easy_cleanup(dst_connection.curl);
 curl_global_cleanup();
 return 0;
}


info

decompiled_code:
int __fastcall info(const char *a1)
{
int result; // eax

if ( *((_BYTE *)&config + 65) )
result = printf("INFO: %s\n", a1);
return result;
}

canonical_decompiled_code:
int __fastcall func0(const char *a1)
{
int result; // eax

if ( *((_BYTE *)&config + 65) )
result = printf("INFO: %s\n", a1);
return result;
}

original_code:
void info(char *text){
 if(config.verbose){
  printf("INFO: %s\n",text);
 }
}

variable_types:
text
char *


error

decompiled_code:
__int64 __fastcall error(__int64 a1, char a2, const char *a3)
{
printf("ERROR: %s\n", a3);
if ( a2 )
return 0xFFFFFFFFLL;
puts("Ignore nonfatal error");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, char a2, const char *a3)
{
printf("ERROR: %s\n", a3);
if ( a2 )
return 0xFFFFFFFFLL;
puts("Ignore nonfatal error");
return 0LL;
}

original_code:
int error(enum frontdown_error_code error_code, char fatal, char *text){
 printf("ERROR: %s\n",text);
 if(!fatal){
  printf("Ignore nonfatal error\n");
  return 0;
 }
 return -1;
}

variable_types: enum frontdown_error_code { _INDEX_DB_ERROR_=0, _MKDIR_ERROR_=1, _DST_CONNECTION_ERROR_=2, _PUT_FILE_ERROR_=3 }

variable_types: fatal char


usage

decompiled_code:
int usage()
{
puts("Usage: frontdown [OPTIONS] \n");
puts("\t-h --help Print this help");
puts("\t-v --verbose Verbose Output\n");
puts("\t-c --conf Configuration file");
puts("\t-e --exclude File/Folder to exclude as POSIX Extended Regular Expressions");
puts("\t-i --incremental Only backup what has changed since last time\n");
puts("\t-s --source Backup source");
puts("\t-d --destination Backup destination");
puts("\t-l --login Destination requires login\n");
puts("There are no bugs - just random features.");
puts("Mail them to: <nosupport@nowhere.nix>\n");
return puts("(C) Copyright 2012-2013 by Patrick Eigensatz & Florian Wernli\n");
}

canonical_decompiled_code:
int func3()
{
puts("Usage: frontdown [OPTIONS] \n");
puts("\t-h --help Print this help");
puts("\t-v --verbose Verbose Output\n");
puts("\t-c --conf Configuration file");
puts("\t-e --exclude File/Folder to exclude as POSIX Extended Regular Expressions");
puts("\t-i --incremental Only backup what has changed since last time\n");
puts("\t-s --source Backup source");
puts("\t-d --destination Backup destination");
puts("\t-l --login Destination requires login\n");
puts("There are no bugs - just random features.");
puts("Mail them to: <nosupport@nowhere.nix>\n");
return puts("(C) Copyright 2012-2013 by Patrick Eigensatz & Florian Wernli\n");
}

original_code:
void usage(void){
 printf("Usage: frontdown [OPTIONS] \n\n");
 printf("\t-h --help          Print this help\n");
 printf("\t-v --verbose       Verbose Output\n\n");
 printf("\t-c --conf          Configuration file\n");
 printf("\t-e --exclude       File/Folder to exclude as POSIX Extended Regular Expressions\n");
 printf("\t-i --incremental   Only backup what has changed since last time\n\n");
 printf("\t-s --source        Backup source\n");
 printf("\t-d --destination   Backup destination\n");
 printf("\t-l --login         Destination requires login\n\n");
 printf("There are no bugs - just random features.\n");
 printf("Mail them to: <nosupport@nowhere.nix>\n\n");
 printf("(C) Copyright 2012-2013 by Patrick Eigensatz & Florian Wernli\n\n");
}

canonical_original_code:
void usage(){
 printf("Usage: frontdown [OPTIONS] \n\n");
 printf("\t-h --help          Print this help\n");
 printf("\t-v --verbose       Verbose Output\n\n");
 printf("\t-c --conf          Configuration file\n");
 printf("\t-e --exclude       File/Folder to exclude as POSIX Extended Regular Expressions\n");
 printf("\t-i --incremental   Only backup what has changed since last time\n\n");
 printf("\t-s --source        Backup source\n");
 printf("\t-d --destination   Backup destination\n");
 printf("\t-l --login         Destination requires login\n\n");
 printf("There are no bugs - just random features.\n");
 printf("Mail them to: <nosupport@nowhere.nix>\n\n");
 printf("(C) Copyright 2012-2013 by Patrick Eigensatz & Florian Wernli\n\n");
}


help

decompiled_code:
int help()
{
version();
return usage();
}

canonical_decompiled_code:
int func4()
{
func2();
return func3();
}

original_code:
void help(){
 version();
 usage();
}

canonical_original_code:
void help(){
 version();
 usage();
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // rax
_BYTE *v4; // r12
_BYTE *v5; // rax
char *v6; // rbp
const char *v7; // rsi
const char *v8; // rsi
const char *v9; // rsi
char *v11; // rbp
size_t v12; // rbx
void *v13; // rax
char *v14; // rbp
size_t v15; // rbx
void *v16; // rax
__int64 v17[2051]; // [rsp+0h] [rbp-4018h] BYREF

v3 = calloc(1uLL, 0x4008uLL);
*(&config + 5) = (__int64)v3;
if ( !v3 )
{
fwrite("Make sure you have enough memory and run it again", 1uLL, 0x31uLL, stderr);
exit(1);
}
*(&config + 9) = time(0LL);
latest_exclude = *(&config + 5);
v4 = malloc(0x4000uLL);
config = (__int64)v4;
v5 = malloc(0x4000uLL);
*v4 = 0;
*v5 = 0;
*(&config + 1) = (__int64)v5;
*(&config + 2) = 0LL;
*(&config + 3) = 0LL;
*(&config + 6) = (__int64)info;
*(&config + 7) = (__int64)error;
*((_WORD *)&config + 32) = 0;
if ( (int)parse_options((unsigned int)argc, argv) < 0 )
{
fprintf(stderr, "\nRun '%s --help' for help\n", *argv);
exit(64);
}
v6 = (char *)*(&config + 1);
if ( !memcmp(v6, "file://", 7uLL) )
{
*((_DWORD *)&config + 8) = 1;
}
else
{
if ( !memcmp((const void *)*(&config + 1), "ftp://", 6uLL) )
{
LABEL_8:
*((_DWORD *)&config + 8) = 2;
goto LABEL_9;
}
if ( strncmp((const char *)*(&config + 1), "sftp://", 7uLL) )
{
if ( strncmp(v6, "ftps://", 7uLL) )
{
v17[0] = 0x2F2F3A656C6966LL;
*((_DWORD *)&config + 8) = 1;
strncat((char *)v17, v6, 0x3FF8uLL);
strcpy(v6, (const char *)v17);
goto LABEL_9;
}
goto LABEL_8;
}
*((_DWORD *)&config + 8) = 10;
}
LABEL_9:
puts("================================ CONFIG ================================");
v7 = "None";
if ( conf )
v7 = &conf;
printf("Configuration File: %s\n", v7);
printf("Source: %s\n", (const char *)config);
printf("Destination: %s\n", (const char *)*(&config + 1));
v8 = "no";
if ( *((_BYTE *)&config + 64) )
v8 = "yes";
printf("Backuped before: %s\n", v8);
v9 = "no";
if ( *((_BYTE *)&config + 65) )
v9 = "yes";
printf("Verbose output: %s\n", v9);
puts("========================================================================\n");
if ( destinationLogin )
{
v11 = getpass("User: ");
*(&config + 2) = (__int64)v11;
v12 = strlen(v11);
v13 = malloc(v12);
*(&config + 2) = (__int64)memcpy(v13, v11, v12 + 1);
v14 = getpass("Password: ");
*(&config + 3) = (__int64)v14;
v15 = strlen(v14);
v16 = malloc(v15);
*(&config + 3) = (__int64)memcpy(v16, v14, v15 + 1);
puts("\n");
}
frontdown(&config);
return 0;
}

original_code:
int main(int argc, char **argv){
 if((config.excludes = calloc(1, sizeof(struct frontdown_exclude_list)))==((void *)0)){
  fprintf(stderr,"Make sure you have enough memory and run it again");
  exit(1);
 }
 config.now=(long long)time(((void *)0));
 latest_exclude = config.excludes;
 config.source=malloc(16384);
 config.destination=malloc(16384);
 config.destinationUname=((void *)0);
 config.destinationPwd=((void *)0);
 config.info=&info;
 config.error=&error;
 config.source[0]=0;
 config.destination[0]=0;
 config.last_backup=0;
 config.verbose=0;
 if(parse_options(argc, argv)<0){
  fprintf(stderr,"\nRun '%s --help' for help\n", argv[0]);
  exit(64);
 }
 char urlbuffer[16384];
 if(strstr(config.destination, "file://") == config.destination) config.con_type=_FILE_;
 else if(strstr(config.destination, "ftp://") == config.destination) config.con_type=_FTP_;
 else if(strstr(config.destination, "sftp://") == config.destination) config.con_type=_SFTP_;
 else if(strstr(config.destination, "ftps://") == config.destination) config.con_type=_FTP_;
 else {
  config.con_type=_FILE_;
  strcpy(urlbuffer, "file://");
  strncat(urlbuffer, config.destination, 16384 -8);
  strcpy(config.destination, urlbuffer);
 }
 printf("================================ CONFIG ================================\n");
 printf("Configuration File:     %s\n", strlen(conf)==0?"None":conf);
 printf("Source:                 %s\n", config.source);
 printf("Destination:            %s\n", config.destination);
 printf("Backuped before:        %s\n", config.last_backup!=0?"yes":"no");
 printf("Verbose output:         %s\n", config.verbose!=0?"yes":"no");
 printf("========================================================================\n\n");
 char *buf;
 if(destinationLogin){
  config.destinationUname=getpass("User: ");
  buf=malloc(strlen(config.destinationUname));
  strcpy(buf, config.destinationUname);
  config.destinationUname=buf;
  config.destinationPwd=getpass("Password: ");
  buf=malloc(strlen(config.destinationPwd));
  strcpy(buf, config.destinationPwd);
  config.destinationPwd=buf;
  printf("\n\n");
 }
 frontdown(&config);
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
urlbuffer
char [16384]

variable_types:
buf
char *

user_defined_types: struct frontdown_exclude_list { char exclude_path[16384]; struct frontdown_exclude_list *next; }


decompiled_code:
void search_destroy()
{
_QWORD *v0; // rdi
__int64 v1; // rbx
void *v2; // rdi

v0 = _PARSER_SEARCH;
if ( _PARSER_SEARCH )
{
if ( _PARSER_KEYS_READ )
{
v1 = 0LL;
do
{
v2 = (void *)v0[v1++];
free(v2);
v0 = _PARSER_SEARCH;
}
while ( _PARSER_KEYS_READ > (unsigned int)v1 );
}
free(v0);
_PARSER_KEYS_READ = 0;
}
else
{
_PARSER_KEYS_READ = 0;
}
}

canonical_decompiled_code:
void func2()
{
_QWORD *v0; // rdi
__int64 v1; // rbx
void *v2; // rdi

v0 = _PARSER_SEARCH;
if ( _PARSER_SEARCH )
{
if ( _PARSER_KEYS_READ )
{
v1 = 0LL;
do
{
v2 = (void *)v0[v1++];
free(v2);
v0 = _PARSER_SEARCH;
}
while ( _PARSER_KEYS_READ > (unsigned int)v1 );
}
free(v0);
_PARSER_KEYS_READ = 0;
}
else
{
_PARSER_KEYS_READ = 0;
}
}

original_code:
void search_destroy(void){
 int i;
 if(__PARSER_SEARCH != ((void *)0)){
  for(i=0; i<__PARSER_KEYS_READ; i++){
   free(__PARSER_SEARCH[i]);
  }
  free(__PARSER_SEARCH);
 }
 __PARSER_KEYS_READ = 0;
}

canonical_original_code:
void search_destroy(){
 int i;
 if(__PARSER_SEARCH != ((void *)0)){
  for(i=0; i<__PARSER_KEYS_READ; i++){
   free(__PARSER_SEARCH[i]);
  }
  free(__PARSER_SEARCH);
 }
 __PARSER_KEYS_READ = 0;
}

variable_types: i int


decompiled_code:
const char *__fastcall search_for_key(char *s2, char a2)
{
const char ***v2; // rbx
const char ***v3; // r13
const char **v4; // r12
const char *result; // rax
const char ***v6; // rbx
const char ***v7; // r13
const char *v8; // [rsp+8h] [rbp-30h]

if ( _PARSER_SEARCH )
{
if ( a2 )
{
if ( _PARSER_KEYS_READ )
{
v6 = (const char ***)_PARSER_SEARCH;
v7 = (const char ***)((char *)_PARSER_SEARCH + 8 * (unsigned int)(_PARSER_KEYS_READ - 1) + 8);
do
{
v4 = *v6;
if ( !strcmp(**v6, s2) )
return v4[1];
++v6;
}
while ( v6 != v7 );
}
}
else if ( _PARSER_KEYS_READ )
{
v2 = (const char ***)_PARSER_SEARCH;
v3 = (const char ***)((char *)_PARSER_SEARCH + 8 * (unsigned int)(_PARSER_KEYS_READ - 1) + 8);
do
{
v4 = *v2;
if ( !strcasecmp(**v2, s2) )
return v4[1];
++v2;
}
while ( v3 != v2 );
}
result = 0LL;
}
else
{
v8 = (const char *)_PARSER_SEARCH;
perror("Error: Search was not initialized!\n");
result = v8;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func3(char *s2, char a2)
{
const char ***v2; // rbx
const char ***v3; // r13
const char **v4; // r12
const char *result; // rax
const char ***v6; // rbx
const char ***v7; // r13
const char *v8; // [rsp+8h] [rbp-30h]

if ( _PARSER_SEARCH )
{
if ( a2 )
{
if ( _PARSER_KEYS_READ )
{
v6 = (const char ***)_PARSER_SEARCH;
v7 = (const char ***)((char *)_PARSER_SEARCH + 8 * (unsigned int)(_PARSER_KEYS_READ - 1) + 8);
do
{
v4 = *v6;
if ( !strcmp(**v6, s2) )
return v4[1];
++v6;
}
while ( v6 != v7 );
}
}
else if ( _PARSER_KEYS_READ )
{
v2 = (const char ***)_PARSER_SEARCH;
v3 = (const char ***)((char *)_PARSER_SEARCH + 8 * (unsigned int)(_PARSER_KEYS_READ - 1) + 8);
do
{
v4 = *v2;
if ( !strcasecmp(**v2, s2) )
return v4[1];
++v2;
}
while ( v3 != v2 );
}
result = 0LL;
}
else
{
v8 = (const char *)_PARSER_SEARCH;
perror("Error: Search was not initialized!\n");
result = v8;
}
return result;
}

original_code:
char *search_for_key(char *key, char case_sensitive){
 if(__PARSER_SEARCH == ((void *)0)){
  perror("Error: Search was not initialized!\n");
  return ((void *)0);
 }
 unsigned int i=0;
 if(case_sensitive == 0){
  for(i=0; i<__PARSER_KEYS_READ; i++){
   if(strcasecmp(__PARSER_SEARCH[i]->key, key) == 0)
    return __PARSER_SEARCH[i]->value;
  }
 } else {
  for(i=0; i<__PARSER_KEYS_READ; i++){
   if(strcmp(__PARSER_SEARCH[i]->key, key) == 0)
    return __PARSER_SEARCH[i]->value;
  }
 }
 return ((void *)0);
}

canonical_original_code:
char *search_for_key(char *key, char case_sensitive){
 if(__PARSER_SEARCH == ((void *)0)){
  perror("Error: Search was not initialized!\n");
  return ((void *)0);
 }
 unsigned int i = 0;
 if(case_sensitive == 0){
  for(i=0; i<__PARSER_KEYS_READ; i++){
   if(strcasecmp(__PARSER_SEARCH[i]->key, key) == 0)
    return __PARSER_SEARCH[i]->value;
  }
 } else {
  for(i=0; i<__PARSER_KEYS_READ; i++){
   if(strcmp(__PARSER_SEARCH[i]->key, key) == 0)
    return __PARSER_SEARCH[i]->value;
  }
 }
 return ((void *)0);
}

variable_types:
key
char *

variable_types:
i
unsigned int


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

if ( ptr )
{
v2 = *(void **)ptr;
if ( v2 )
free(v2);
v3 = (void *)*((_QWORD *)ptr + 1);
if ( v3 )
free(v3);
free(ptr);
}
}

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

if ( ptr )
{
v2 = *(void **)ptr;
if ( v2 )
free(v2);
v3 = (void *)*((_QWORD *)ptr + 1);
if ( v3 )
free(v3);
free(ptr);
}
}

original_code:
void key_value_destroy(struct key_value *keyval){
 if(keyval != ((void *)0)){
  if(keyval->key != ((void *)0))
   free(keyval->key);
  if(keyval->value != ((void *)0))
   free(keyval->value);
  free(keyval);
 }
}

variable_types: struct key_value { char *key; char *value; } *


upload

decompiled_code:
__int64 __fastcall upload(__int64 a1, __int64 a2, const char *a3, const char *a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9, __int64 a10, __int64 a11, __int64 a12, __int64 a13)
{
const char *v15; // rbx
int v16; // eax
char v17; // al
unsigned int v18; // er8
__int128 v20; // [rsp+0h] [rbp-10038h] BYREF
char s[32752]; // [rsp+10h] [rbp-10028h] BYREF
char dest[16]; // [rsp+8000h] [rbp-8038h] BYREF
char v23[32752]; // [rsp+8010h] [rbp-8028h] BYREF

v20 = 0LL;
memset(s, 0, sizeof(s));
*(_OWORD *)dest = 0LL;
memset(v23, 0, sizeof(v23));
strcpy((char *)&v20, a4);
v15 = *(const char **)(a1 + 8);
strcpy(dest, v15);
LODWORD(v15) = strlen(v15);
dest[(int)v15] = 47;
strcpy(&dest[(int)v15 + 1], a3);
v16 = (_DWORD)v15 + strlen(a3);
dest[v16 + 1] = 47;
strcpy(&dest[v16 + 2], a4);
(*(void (__fastcall **)(char *))(a1 + 48))(dest);
v17 = put_file(a1, &v20, a4, dest, a13);
if ( v17 )
{
v18 = -2;
if ( v17 == -1 )
{
v18 = -1;
++FilesFailed;
}
}
else
{
v18 = 0;
++FilesUpdated;
}
return v18;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, const char *a3, const char *a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9, __int64 a10, __int64 a11, __int64 a12, __int64 a13)
{
const char *v15; // rbx
int v16; // eax
char v17; // al
unsigned int v18; // er8
__int128 v20; // [rsp+0h] [rbp-10038h] BYREF
char s[32752]; // [rsp+10h] [rbp-10028h] BYREF
char dest[16]; // [rsp+8000h] [rbp-8038h] BYREF
char v23[32752]; // [rsp+8010h] [rbp-8028h] BYREF

v20 = 0LL;
memset(s, 0, sizeof(s));
*(_OWORD *)dest = 0LL;
memset(v23, 0, sizeof(v23));
strcpy((char *)&v20, a4);
v15 = *(const char **)(a1 + 8);
strcpy(dest, v15);
LODWORD(v15) = strlen(v15);
dest[(int)v15] = 47;
strcpy(&dest[(int)v15 + 1], a3);
v16 = (_DWORD)v15 + strlen(a3);
dest[v16 + 1] = 47;
strcpy(&dest[v16 + 2], a4);
(*(void (__fastcall **)(char *))(a1 + 48))(dest);
v17 = put_file(a1, &v20, a4, dest, a13);
if ( v17 )
{
v18 = -2;
if ( v17 == -1 )
{
v18 = -1;
++FilesFailed;
}
}
else
{
v18 = 0;
++FilesUpdated;
}
return v18;
}

original_code:
int upload(struct frontdown_config *config, const char *source, char *relpath, char *name, struct stat filestat){
 char srcpathstring[16384*2]={0};
 char dstpathstring[16384*2]={0};
 char ret;
 int len=-1;
 strcpy(&srcpathstring[len+1], name);
 strcpy(dstpathstring, config->destination);
 len=strlen(config->destination);
 dstpathstring[len]='/';
 strcpy(&dstpathstring[len+1], relpath);
 len+=1+strlen(relpath);
 dstpathstring[len]='/';
 strcpy(&dstpathstring[len+1], name);
 config->info(dstpathstring);
 if((ret=put_file(config, srcpathstring, name, dstpathstring, filestat.st_size))==0){
  FilesUpdated++;
  return 0;
 } else if(ret==-1){
  FilesFailed++;
  return -1;
 } else {
  return -2;
 }
}

canonical_original_code:
int upload(struct frontdown_config *config, char *source, char *relpath, char *name, struct stat filestat){
 char srcpathstring[-1] = {0};
 char dstpathstring[-1] = {0};
 char ret;
 int len = -1;
 strcpy(&srcpathstring[len+1], name);
 strcpy(dstpathstring, config->destination);
 len=strlen(config->destination);
 dstpathstring[len]='/';
 strcpy(&dstpathstring[len+1], relpath);
 len+=1+strlen(relpath);
 dstpathstring[len]='/';
 strcpy(&dstpathstring[len+1], name);
 config->info(dstpathstring);
 if((ret=put_file(config, srcpathstring, name, dstpathstring, filestat.st_size))==0){
  FilesUpdated++;
  return 0;
 } else if(ret==-1){
  FilesFailed++;
  return -1;
 } else {
  return -2;
 }
}

variable_types:
source
char *

variable_types:
name
char *

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

variable_types:
srcpathstring
char [-1]

variable_types:
dstpathstring
char [-1]

variable_types: ret char

variable_types: len int

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

user_defined_types: enum frontdown_connection_type { _DICT_=0, _FILE_=1, _FTP_=2, _HTTP_=3, _IMAP_=4, _LDAP_=5, _POP3_=6, _RTMP_=7, _RTSP_=8, _SCP_=9, _SFTP_=10, _SMTP_=11, _TELNET_=12, _TFTP_=13, _UNKNOWN_=14 }

user_defined_types: enum frontdown_error_code { _INDEX_DB_ERROR_=0, _MKDIR_ERROR_=1, _DST_CONNECTION_ERROR_=2, _PUT_FILE_ERROR_=3 }